/* =====================================================================
   Thème « Halloween » — douillet, façon illustration d'automne :
   crème, citrouille, brun chocolat, vert olive. Décor dessiné par halloween.js.
   ===================================================================== */

.spooky { display: none; }

:root[data-theme="halloween"] {
  --cream: #fbe3c5;
  --paper: #fff4e6;
  --ink: #3a2114;
  --bg: var(--cream);
  --surface: rgb(255 244 230 / .66);
  --surface-2: rgb(255 236 214 / .35);
  --text: var(--ink);
  --muted: #8a5a3b;
  --line: rgb(150 95 55 / .17);
  --line-strong: rgb(150 95 55 / .3);
  --accent: #e8772e;
  --today-bg: rgb(246 167 90 / .16);
  --now: #d9541e;
  --bad: #c2452d;
  --shadow: 0 4px 0 rgb(150 95 55 / .14), 0 14px 34px rgb(150 95 55 / .14);
  --radius: 26px;
  --font: "Nunito", "Varela Round", system-ui, sans-serif;
  /* Grain façon crayon / papier, comme l'illustration d'inspiration */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .25 0 0 0 0 .1 0 0 0 .16 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  color-scheme: light;
}

[data-theme="halloween"] body {
  background: var(--grain), var(--cream);
  font-family: var(--font);
}
[data-theme="halloween"] button,
[data-theme="halloween"] .event-dialog { font-family: var(--font); }

/* ---------- Décor ---------- */

[data-theme="halloween"] .spooky {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.spooky-scene, .spooky-scene svg, .spooky-cats, .spooky-leaves { position: absolute; inset: 0; }
.spooky-scene svg { width: 100%; height: 100%; }
/* Le grain recouvre aussi le décor */
.spooky::after { content: ""; position: absolute; inset: 0; background: var(--grain); }

.pcat {
  position: absolute;
  transform-origin: 50% 85%;
  will-change: transform;
  animation: pcat-waddle 4s ease-in-out infinite;
}
.pcat svg { display: block; }
@keyframes pcat-waddle {
  0%, 100% { transform: scaleX(var(--flip)) rotate(calc(var(--rot) - 3deg)) translateY(0); }
  50%      { transform: scaleX(var(--flip)) rotate(calc(var(--rot) + 3deg)) translateY(-4%); }
}

.fall {
  position: absolute;
  top: -40px;
  will-change: transform;
  animation: leaf-fall 30s linear infinite;
}
@keyframes leaf-fall {
  0%   { transform: translate3d(0, 0, 0) rotate(var(--r0)) scale(var(--s)); }
  25%  { transform: translate3d(var(--sway), 27vh, 0) rotate(calc(var(--r0) + 90deg)) scale(var(--s)); }
  50%  { transform: translate3d(0, 54vh, 0) rotate(calc(var(--r0) + 180deg)) scale(var(--s)); }
  75%  { transform: translate3d(calc(var(--sway) * -1), 81vh, 0) rotate(calc(var(--r0) + 270deg)) scale(var(--s)); }
  100% { transform: translate3d(0, 110vh, 0) rotate(calc(var(--r0) + 360deg)) scale(var(--s)); }
}
.still .pcat, .still .fall { animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) { .pcat, .fall { animation: none; } }

[data-theme="halloween"] .calendar { position: relative; z-index: 1; }
/* La barre du haut passe devant le planning (son menu d'orientation s'ouvre par-dessus) */
[data-theme="halloween"] .topbar { position: relative; z-index: 5; }
[data-theme="halloween"] .topbar { padding-left: 32px; padding-right: 32px; }
[data-theme="halloween"] .calendar { margin: 0 32px max(28px, env(safe-area-inset-bottom)); }

/* ---------- En-tête ---------- */

[data-theme="halloween"] .clock { display: flex; align-items: center; gap: 6px; }
[data-theme="halloween"] .clock-deco { display: block; flex-shrink: 0; margin: -14px -2px -14px -12px; }
[data-theme="halloween"] .clock-deco svg { display: block; }
[data-theme="halloween"] .clock-time { font-size: 3.6rem; font-weight: 900; color: var(--ink); letter-spacing: -.01em; }
[data-theme="halloween"] .clock-date { color: var(--muted); font-weight: 800; font-size: 1.1rem; }
[data-theme="halloween"] .period { font-size: 1.7rem; font-weight: 900; white-space: nowrap; }
[data-theme="halloween"] .clock-time,
[data-theme="halloween"] .clock-date,
[data-theme="halloween"] .period {
  text-shadow: 0 0 12px var(--cream), 0 0 4px var(--cream), 0 0 2px var(--cream);
}

[data-theme="halloween"] .segmented,
[data-theme="halloween"] .icon-btn,
[data-theme="halloween"] .today-btn,
[data-theme="halloween"] .person {
  background: var(--paper);
  border: 2px solid #efcfa6;
  box-shadow: 0 3px 0 rgb(150 95 55 / .16);
  color: var(--ink);
  font-weight: 800;
}
[data-theme="halloween"] .segmented button { color: var(--muted); font-weight: 800; }
[data-theme="halloween"] .segmented button[aria-selected="true"],
[data-theme="halloween"] .ed-close {
  background: var(--accent);
  color: #fff;
  box-shadow: inset 0 -3px 0 rgb(150 60 20 / .25);
}
[data-theme="halloween"] .status { color: var(--muted); font-weight: 700; text-shadow: 0 0 8px var(--cream); }
[data-theme="halloween"] .status.bad { color: var(--bad); }
[data-theme="halloween"] .person[aria-pressed="true"] {
  background: color-mix(in srgb, var(--c) 20%, var(--paper));
  border-color: color-mix(in srgb, var(--c) 55%, var(--paper));
}
[data-theme="halloween"] .person[aria-pressed="false"] { opacity: .5; }
[data-theme="halloween"] .person .dot { box-shadow: 0 0 0 3px var(--paper); }

/* ---------- Calendrier : feuille de papier crème, légèrement translucide ---------- */

[data-theme="halloween"] .calendar {
  background: var(--grain), var(--surface);
  border: 2px solid #f1d2ab;
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  box-shadow: var(--shadow);
}

[data-theme="halloween"] .wk-day-head .wd { font-size: 1.05rem; font-weight: 800; color: var(--muted); }
[data-theme="halloween"] .wk-day-head .dn { font-size: 1.7rem; font-weight: 900; }
[data-theme="halloween"] .mo-wd { font-size: 1.05rem; font-weight: 900; color: var(--muted); }
[data-theme="halloween"] .mo-num { font-size: 1.25rem; font-weight: 900; }

/* Le numéro du jour est posé dans une petite citrouille */
[data-theme="halloween"] .wk-day-head.today .dn,
[data-theme="halloween"] .mo-cell.today .mo-num {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M19 9q-1-5 3-7' fill='none' stroke='%2393502c' stroke-width='3.5' stroke-linecap='round'/%3E%3Cellipse cx='20' cy='23' rx='18.5' ry='15' fill='%23f08a3c'/%3E%3Cpath d='M12 10q-5 13 0 26M28 10q5 13 0 26M20 8v30' fill='none' stroke='%23df6c27' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
  color: #fff;
  text-shadow: 0 1px 0 rgb(150 60 20 / .5), 0 0 6px rgb(150 60 20 / .35);
  padding-top: .18em;
  box-shadow: none;
}
[data-theme="halloween"] .wk-day-head.today .dn { font-size: 1.3rem; min-width: 2.5em; height: 2.3em; }
[data-theme="halloween"] .mo-cell.today .mo-num { min-width: 2.3em; height: 2.1em; }
[data-theme="halloween"] .wk-allday-cell.today,
[data-theme="halloween"] .wk-col.today,
[data-theme="halloween"] .mo-cell.today { background-color: var(--today-bg); }

/* ---------- Rendez-vous : étiquettes bien visibles ---------- */

[data-theme="halloween"] .event,
[data-theme="halloween"] .chip,
[data-theme="halloween"] .mo-ev {
  --ev-bg: color-mix(in srgb, var(--c) 42%, #fff4e6);
  --ev-ink: color-mix(in srgb, var(--c) 22%, #24120a);
}
[data-theme="halloween"] .event {
  font-size: 1rem;
  background: var(--ev-bg);
  border: 2px solid var(--paper);
  border-left: 6px solid var(--c);
  border-radius: 12px;
  box-shadow: 0 3px 0 rgb(120 70 40 / .18);
  color: var(--ev-ink);
  padding: 5px 9px;
}
[data-theme="halloween"] .event .ev-title { font-size: 1.05em; font-weight: 900; line-height: 1.15; }
[data-theme="halloween"] .event .ev-time { color: var(--ev-ink); font-size: .9em; font-weight: 800; opacity: .8; }
[data-theme="halloween"] .event .ev-loc { color: var(--ev-ink); font-size: .85em; font-weight: 700; opacity: .7; }

[data-theme="halloween"] .chip,
[data-theme="halloween"] .mo-ev.allday {
  background: var(--c);
  color: #fff;
  border: 2px solid var(--paper);
  border-radius: 10px;
  box-shadow: 0 3px 0 rgb(120 70 40 / .18);
  font-weight: 900;
  text-shadow: 0 1px 0 rgb(0 0 0 / .18);
}
[data-theme="halloween"] .chip { font-size: 1rem; padding: 5px 10px; }

[data-theme="halloween"] .mo-list { gap: 3px; }
[data-theme="halloween"] .mo-ev { font-size: .95rem; padding: 3px 7px; border-radius: 8px; color: var(--ev-ink); }
[data-theme="halloween"] .mo-ev:not(.allday) { background: var(--ev-bg); border-left: 4px solid var(--c); }
[data-theme="halloween"] .mo-ev .dot { display: none; }
[data-theme="halloween"] .mo-ev .mo-time { color: var(--ev-ink); font-weight: 800; opacity: .8; }
[data-theme="halloween"] .mo-ev .mo-title { font-weight: 900; }
[data-theme="halloween"] .mo-ev.allday .mo-title { color: #fff; }
[data-theme="halloween"] .mo-more { background: var(--accent); color: #fff; font-weight: 900; box-shadow: 0 2px 0 rgb(150 60 20 / .25); }

[data-theme="halloween"] .event.past,
[data-theme="halloween"] .chip.past,
[data-theme="halloween"] .mo-ev.past { opacity: .55; filter: saturate(.7); box-shadow: none; }

[data-theme="halloween"] .now-line { height: 3px; background: var(--now); border-radius: 2px; }
[data-theme="halloween"] .now-line::before {
  width: 14px; height: 12px; left: -7px; top: -5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--paper);
}

/* ---------- Fenêtre de détail ---------- */

[data-theme="halloween"] .event-dialog {
  overflow: visible;
  background: var(--grain), var(--paper);
  border: 2px solid #efcfa6;
  border-radius: 28px;
  box-shadow: 0 6px 0 rgb(150 95 55 / .2), 0 30px 70px rgb(90 50 20 / .3);
}
[data-theme="halloween"] .event-dialog::backdrop { background: rgb(120 70 30 / .25); }
[data-theme="halloween"] .event-dialog h2 { font-size: 2rem; font-weight: 900; padding-right: 80px; }
[data-theme="halloween"] .ed-person {
  background: color-mix(in srgb, var(--c) 25%, var(--paper));
  color: var(--ink);
  border: 2px solid color-mix(in srgb, var(--c) 50%, var(--paper));
  font-weight: 800;
}
[data-theme="halloween"] .ed-deco {
  display: block;
  position: absolute;
  top: -58px;
  right: -26px;
  pointer-events: none;
}

/* ---------- Tablette ~1280 px : en-tête sur une ligne ---------- */

@container app (min-width: 1100px) and (max-width: 1500px) {
  [data-theme="halloween"] .topbar { gap: 16px; padding-top: 10px; padding-bottom: 10px; }
  [data-theme="halloween"] .clock-deco { margin: -16px -6px -16px -16px; }
  [data-theme="halloween"] .clock-time { font-size: 2.8rem; }
  [data-theme="halloween"] .clock-date { font-size: .95rem; }
  [data-theme="halloween"] .nav { flex-wrap: nowrap; gap: 10px; }
  [data-theme="halloween"] .period { font-size: 1.35rem; min-width: 0; }
  [data-theme="halloween"] .segmented button { padding: 8px 16px; }
  [data-theme="halloween"] .icon-btn { width: 42px; height: 42px; font-size: 1.5rem; }
  [data-theme="halloween"] .icon-btn.small { width: 36px; height: 36px; font-size: 1rem; }
  [data-theme="halloween"] .today-btn { height: 42px; padding: 0 14px; }
  [data-theme="halloween"] .person { padding: 6px 12px 6px 9px; }
  [data-theme="halloween"] .side { gap: 4px; }
}
@container app (max-width: 700px) {
  [data-theme="halloween"] .calendar { margin: 0 10px 12px; }
  [data-theme="halloween"] .topbar { padding-left: 16px; padding-right: 16px; }
  [data-theme="halloween"] .clock-deco { display: none; }
}
