/* ── Хеллоуин: с 15 октября по 2 ноября, как в лаунчере. Класс is-halloween ставит assets/halloween.js ── */
:root.is-halloween {
  --peach: #ec8a3a; --peach-700: #8a4519; --peach-600: #bd6527; --peach-300: #f7bd85;
  --peri: #a98bd8; --peri-700: #5d468c; --peri-600: #8369b8; --peri-300: #d3c4f0;
  --sage: #93cc4f; --sage-700: #4c7425; --sage-600: #6fa23a; --sage-300: #c6ea98;
  --cream: #f2e6cc; --cream-dim: #d5c6a8; --cream-mute: #a7987f;
  --plum: #2d2337; --plum-950: #110b16; --plum-900: #18101f; --plum-850: #1f1727; --plum-800: #261c30; --plum-600: #403150; --plum-500: #524164; --plum-400: #6d5a80; --plum-300: #9787a8;
  --inset: #160f1c; --inset-hi: #0d0811; --inset-lo: #403150;
  --hi: #4b3c5b; --lo: #1d1525;
  --glow: 0 24px 60px rgba(8, 3, 12, .55);
}
.is-halloween .topbar { background: rgba(30, 20, 38, .95); }
.is-halloween .dock { background: rgba(30, 20, 38, .96); }
.is-halloween .band-deep { background: rgba(17, 11, 22, .6); }
.is-halloween .hero-art { filter: saturate(1.08) hue-rotate(-14deg) brightness(.85); }
.is-halloween .splash { text-shadow: 2px 2px 0 var(--peach-700), 0 0 14px rgba(236, 138, 58, .5); }
.is-halloween .slot.is-active svg { filter: drop-shadow(0 0 6px rgba(236, 138, 58, .8)); }
.is-halloween .hero .eyebrow .icon { color: var(--peach); }

/* Кнопка-тыква в шапке: горит, пока тема включена. */
.season-toggle { flex: none; display: grid; place-items: center; width: 39px; height: 39px; padding: 0 0 3px; border: 0; background: var(--plum-600); color: var(--plum-300); --hi: var(--plum-500); --lo: var(--plum-950); box-shadow: var(--frame-out), inset 0 var(--u) 0 0 var(--hi), inset 0 calc(var(--u) * -2) 0 0 var(--lo); }
.season-toggle .icon { width: 24px; height: 24px; }
.season-toggle:hover { --line: var(--cream); color: var(--cream); }
.season-toggle[aria-pressed="true"] { color: var(--peach); }
.season-toggle[aria-pressed="true"] .icon { filter: drop-shadow(0 0 6px rgba(236, 138, 58, .8)); }

/* ── Первый экран: пиксельная луна, звёзды и тыквенное зарево ── */
.hero-sky { position: absolute; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; background: radial-gradient(ellipse 60% 40% at 70% 100%, rgba(236, 138, 58, .2), transparent 70%), radial-gradient(ellipse 40% 35% at 10% 0%, rgba(140, 92, 204, .18), transparent 70%); }
.spooky-moon { position: absolute; top: 30px; left: 46%; width: 72px; height: 72px; fill: #f2e6cc; shape-rendering: crispEdges; filter: drop-shadow(0 0 22px rgba(242, 230, 204, .4)); }
.spooky-moon .crater { fill: #c9b993; }
.hero-sky i { position: absolute; left: calc(var(--x) * 1%); top: calc(18px + var(--y) * 5px); width: 3px; height: 3px; background: var(--cream); opacity: .2; animation: starTwinkle 3.2s steps(3) infinite; animation-delay: calc(var(--d) * -.46s); }
@keyframes starTwinkle { 0%, 100% { opacity: .15; } 50% { opacity: .8; } }
.stage-lanterns { position: absolute; z-index: 3; left: 0; bottom: -18px; display: flex; align-items: flex-end; gap: 6px; pointer-events: none; }
.stage-lanterns b { color: var(--peach); animation: lanternFlicker 2.6s steps(4) infinite; }
.stage-lanterns .is-big .icon { width: 60px; height: 60px; }
.stage-lanterns .is-small { animation-delay: -1.1s; }
.stage-lanterns .is-small .icon { width: 36px; height: 36px; }
@keyframes lanternFlicker { 0%, 100% { filter: drop-shadow(0 0 9px rgba(236, 138, 58, .8)); } 35% { filter: drop-shadow(0 0 4px rgba(236, 138, 58, .45)); } 60% { filter: drop-shadow(0 0 13px rgba(247, 189, 133, .9)); } }

/* ── Поверх страницы, под шапкой и хотбаром: паутина, паук, туман, мыши и призрак ── */
/* Паутина висит под шапкой высотой 66 px, а на странице без шапки (/discord) — от верхних углов окна.
   Такая страница может сама задать --spooky-top: 0px; в браузерах с :has() это делает правило ниже. */
.spooky-layer { position: fixed; inset: 0; z-index: 25; pointer-events: none; overflow: hidden; }
body:not(:has(> .topbar)) > .spooky-layer { --spooky-top: 0px; }
.spooky-web { position: absolute; top: var(--spooky-top, 66px); width: 130px; height: 130px; fill: none; stroke: rgba(242, 230, 204, .22); stroke-width: 1.2; shape-rendering: crispEdges; }
.spooky-web.is-left { left: 0; }
.spooky-web.is-right { top: 0; left: 0; width: 100%; height: 100%; transform: scaleX(-1); }
.spooky-fog { position: absolute; left: 0; right: 0; bottom: 0; height: 150px; opacity: .55; }
.spooky-fog i { position: absolute; inset: 0; background: radial-gradient(ellipse 140px 36px at 70px 118px, rgba(169, 139, 216, .22), transparent 70%) 0 0 / 280px 150px repeat-x; animation: fogDrift 46s linear infinite; }
.spooky-fog i + i { background: radial-gradient(ellipse 180px 32px at 90px 132px, rgba(242, 230, 204, .1), transparent 70%) 0 0 / 360px 150px repeat-x; animation-duration: 70s; animation-direction: reverse; }
@keyframes fogDrift { to { background-position-x: 720px; } }
/* Паук висит на узле правой паутины (--knot-x/--knot-y ставит assets/halloween.js). Верх нити привязан к узлу:
   качается только длина нити (--bob), паук держится за её конец, а щелчок сматывает нить (--pull) и прячет его в паутине.
   Без @property переменные берут запасные значения, а без round() узел и длина считаются обычным calc(). */
@property --bob { syntax: "<length>"; inherits: true; initial-value: 0px; }
@property --pull { syntax: "<number>"; inherits: true; initial-value: 0; }
.spooky-corner { --web: 130px; position: absolute; top: var(--spooky-top, 66px); right: 0; width: var(--web); height: var(--web); }
.spooky-drop { --rope: 60px; --len: calc((var(--rope) + var(--bob, 0px)) * (1 - var(--pull, 0))); position: absolute; left: calc(var(--web) * var(--knot-x) - 1px); top: calc(var(--web) * var(--knot-y)); animation: spiderBob 4.6s ease-in-out infinite; transition: --pull 1.3s cubic-bezier(.45, 0, .35, 1); }
@supports (width: round(1px, 1px)) {
  .spooky-drop { --len: round(calc((var(--rope) + var(--bob, 0px)) * (1 - var(--pull, 0))), 1px); left: round(calc(var(--web) * var(--knot-x) - 1px), 1px); top: round(calc(var(--web) * var(--knot-y)), 1px); }
}
.spooky-drop.is-climbing { --pull: 1; }
/* Без @property длина нити не плавнеет, а прыгает: такой паук просто висит (класс ставит assets/halloween.js). */
.spooky-drop.is-still { animation: none; }
.spooky-thread { position: absolute; left: 0; top: 0; width: 2px; height: var(--len); background: rgba(242, 230, 204, .34); }
.spooky-spider { position: absolute; left: -11px; top: 0; width: 24px; height: 24px; padding: 0; border: 0; background: none; color: var(--plum-300); pointer-events: auto; cursor: pointer; translate: 0 calc(var(--len) - 3px); }
.spooky-spider .icon { display: block; width: 24px; height: 24px; filter: drop-shadow(0 0 4px rgba(169, 139, 216, .6)); }
.spooky-spider:focus-visible { outline: none; }
@keyframes spiderBob { 0%, 100% { --bob: 0px; } 50% { --bob: 14px; } }
.spooky-bat { position: absolute; left: 0; top: 0; color: #0d0810; filter: drop-shadow(0 0 1px rgba(242, 230, 204, .55)) drop-shadow(0 0 6px rgba(236, 138, 58, .35)); }

/* ── Мыши: полоска из четырёх кадров, steps(4) листает её, а тело подпрыгивает в такт взмахам ── */
/* При планировании (is-gliding) крылья расправлены: виден средний кадр. */
.bat-sprite { display: block; width: var(--size, 24px); height: var(--size, 24px); overflow: hidden; animation: batBob var(--flap, .36s) step-end var(--phase, 0s) infinite; }
.bat-sprite .bat-strip { display: block; width: 400%; height: 100%; animation: batFlap var(--flap, .36s) steps(4) var(--phase, 0s) infinite; }
.is-gliding .bat-sprite { animation: none; }
.is-gliding .bat-sprite .bat-strip { animation: none; transform: translateX(-25%); }
@keyframes batFlap { to { transform: translateX(-100%); } }
@keyframes batBob { 0% { translate: 0 1px; } 25%, 75% { translate: 0 0; } 50% { translate: 0 -1px; } }
.spooky-ghost { position: absolute; left: 0; top: 0; width: 48px; height: 48px; padding: 0; border: 0; background: none; color: var(--cream); pointer-events: auto; cursor: pointer; filter: drop-shadow(0 0 10px rgba(242, 230, 204, .5)); }
.spooky-ghost svg { width: 48px; height: 48px; }
.spooky-ghost:focus-visible { outline: none; }
.dock-lantern { position: absolute; bottom: 15px; color: var(--peach); animation: lanternFlicker 2.8s steps(4) infinite; pointer-events: none; }
.dock-lantern .icon { width: 33px; height: 33px; }
.dock-lantern.is-left { left: -54px; }
.dock-lantern.is-right { right: -54px; animation-delay: -1.3s; }
.is-halloween .wordmark { position: relative; }
@media (min-width: 681px) { .is-halloween .topbar .wordmark { margin-right: 20px; } }
.wordmark-bat { position: absolute; left: calc(100% + 6px); top: -9px; color: var(--peri); --size: 18px; --flap: .56s; }

@media (max-width: 1040px) {
  .spooky-moon { left: auto; right: 8%; }
}
@media (max-width: 680px) {
  /* Кнопка-тыква помещается в шапку телефона рядом с логотипом и «Скачать». */
  .is-halloween .topbar { gap: 10px; padding-left: 16px; padding-right: 16px; }
  .season-toggle { flex: none; }
  .spooky-web, .spooky-corner, .dock-lantern, .topbar .wordmark-bat { display: none; }
  .spooky-moon { left: auto; right: 14px; top: 4px; width: 36px; height: 36px; }
}
@media (max-width: 480px) {
  /* С тыквой в шапке «Скачать» на узком телефоне остаётся значком. */
  .is-halloween .topbar .button-create { width: 39px; padding: 0 0 3px; }
  .is-halloween .topbar .button-create span { display: none; }
  .is-halloween .topbar .button-create .icon { width: 24px; height: 24px; }
}
/* Без лишнего движения: мыши не машут крыльями (виден средний кадр), паук не качается. */
@media (prefers-reduced-motion: reduce) {
  .bat-sprite, .bat-sprite .bat-strip, .spooky-drop { animation: none !important; }
  .bat-sprite .bat-strip { transform: translateX(-25%); }
}
