html[data-halloween-active="true"] {
  --halloween-amber: #f7a84b;
  --halloween-violet: #a86df2;
  --halloween-plum: #24102f;
}

html[data-halloween-active="true"] body:not(.theme-light) {
  background:
    linear-gradient(180deg, rgba(7, 2, 16, 0.42), rgba(7, 2, 16, 0.78)),
    image-set(
      url("assets/seasonal/halloween/background-dark.avif") type("image/avif"),
      url("assets/seasonal/halloween/background-dark.webp") type("image/webp")
    ) top center / cover scroll no-repeat,
    var(--bg-color);
}

html[data-halloween-active="true"] body.theme-light {
  background:
    linear-gradient(180deg, rgba(255, 249, 250, 0.24), rgba(255, 241, 246, 0.56)),
    image-set(
      url("assets/seasonal/halloween/background-light.avif") type("image/avif"),
      url("assets/seasonal/halloween/background-light.webp") type("image/webp")
    ) top center / cover scroll no-repeat,
    var(--bg-color);
}

html[data-halloween-active="true"] body:not(.theme-light) .app-container {
  background:
    linear-gradient(180deg, rgba(7, 2, 16, 0.42), rgba(7, 2, 16, 0.78)),
    image-set(
      url("assets/seasonal/halloween/background-dark.avif") type("image/avif"),
      url("assets/seasonal/halloween/background-dark.webp") type("image/webp")
    ) top center / cover scroll no-repeat,
    var(--bg-color);
}

html[data-halloween-active="true"] body.theme-light .app-container {
  background:
    linear-gradient(180deg, rgba(255, 249, 250, 0.24), rgba(255, 241, 246, 0.56)),
    image-set(
      url("assets/seasonal/halloween/background-light.avif") type("image/avif"),
      url("assets/seasonal/halloween/background-light.webp") type("image/webp")
    ) top center / cover scroll no-repeat,
    var(--bg-color);
}

html[data-halloween-active="true"] .site-chat-body:not(.theme-light) {
  background:
    linear-gradient(180deg, rgba(7, 2, 16, 0.72), rgba(7, 2, 16, 0.94)),
    image-set(
      url("assets/seasonal/halloween/background-dark.avif") type("image/avif"),
      url("assets/seasonal/halloween/background-dark.webp") type("image/webp")
    ) center / cover scroll no-repeat,
    var(--chat-bg);
}

html[data-halloween-active="true"] .site-chat-body.theme-light {
  background:
    linear-gradient(180deg, rgba(255, 249, 250, 0.64), rgba(255, 241, 246, 0.86)),
    image-set(
      url("assets/seasonal/halloween/background-light.avif") type("image/avif"),
      url("assets/seasonal/halloween/background-light.webp") type("image/webp")
    ) center / cover scroll no-repeat,
    var(--chat-bg);
}

html[data-halloween-active="true"] body.site-chat-body:not(.theme-light) .site-chat-shell {
  background:
    linear-gradient(180deg, rgba(7, 2, 16, 0.42), rgba(7, 2, 16, 0.7)),
    image-set(
      url("assets/seasonal/halloween/background-dark.avif") type("image/avif"),
      url("assets/seasonal/halloween/background-dark.webp") type("image/webp")
    ) center / cover scroll no-repeat,
    var(--chat-bg);
}

html[data-halloween-active="true"] body.site-chat-body.theme-light .site-chat-shell {
  background:
    linear-gradient(180deg, rgba(255, 249, 250, 0.28), rgba(255, 241, 246, 0.58)),
    image-set(
      url("assets/seasonal/halloween/background-light.avif") type("image/avif"),
      url("assets/seasonal/halloween/background-light.webp") type("image/webp")
    ) center / cover scroll no-repeat,
    var(--chat-bg);
}

html[data-halloween-active="true"] .header {
  position: relative;
  isolation: isolate;
  min-height: 224px;
  overflow: hidden;
  background: #160720;
  box-shadow:
    inset 0 -1px 0 rgba(247, 168, 75, 0.36),
    0 8px 24px rgba(5, 1, 12, 0.24);
}

html[data-halloween-active="true"] .header::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(10, 2, 20, 0.72) 0%, rgba(10, 2, 20, 0.34) 26%, transparent 52%),
    linear-gradient(180deg, rgba(10, 2, 20, 0.5) 0%, rgba(10, 2, 20, 0.12) 46%, transparent 72%);
}

html[data-halloween-active="true"] .header::after {
  content: "✦  ◆  ✦";
  position: absolute;
  left: 50%;
  bottom: 5px;
  transform: translateX(-50%);
  color: rgba(247, 168, 75, 0.56);
  font-size: 8px;
  letter-spacing: 4px;
  pointer-events: none;
}

.halloween-brand-art[hidden],
.halloween-setting-row[hidden] {
  display: none !important;
}

.halloween-brand-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: -2;
  pointer-events: none;
}

.halloween-brand-art picture,
.halloween-brand-art img {
  display: block;
  width: 100%;
  height: 100%;
}

.halloween-brand-art img {
  object-fit: cover;
  object-position: 88% 50%;
}

html[data-halloween-active="true"] .header > .brand,
html[data-halloween-active="true"] .header > .header-actions {
  position: relative;
  z-index: 2;
}

html[data-halloween-active="true"] .header-auth-button {
  display: none !important;
}

html[data-halloween-active="true"] .header > .header-actions {
  position: absolute;
  left: 16px;
  right: auto;
  bottom: 12px;
  display: flex;
  flex-direction: row;
  align-items: center;
  width: auto;
  gap: 8px;
}

.halloween-setting-row {
  cursor: default;
}

.halloween-switch {
  position: relative;
  width: 48px;
  height: 28px;
  justify-self: end;
}

.halloween-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.halloween-switch span {
  position: absolute;
  inset: 0;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
}

.halloween-switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text-muted);
}

.halloween-switch input:checked + span {
  border-color: var(--halloween-amber);
  background: rgba(247, 168, 75, 0.16);
}

.halloween-switch input:checked + span::after {
  left: 23px;
  background: var(--halloween-amber);
}

.halloween-switch input:focus-visible + span {
  outline: 2px solid var(--halloween-violet);
  outline-offset: 2px;
}

html[data-halloween-active="true"] body.theme-light .header {
  background: #f5c5b8;
  box-shadow:
    inset 0 -1px 0 rgba(190, 111, 39, 0.34),
    0 8px 22px rgba(133, 68, 97, 0.12);
}

html[data-halloween-active="true"] body.theme-light .header::before {
  background:
    linear-gradient(90deg, rgba(255, 242, 236, 0.72) 0%, rgba(255, 242, 236, 0.28) 27%, transparent 54%),
    linear-gradient(180deg, rgba(255, 242, 236, 0.5) 0%, rgba(255, 242, 236, 0.08) 44%, transparent 68%);
}

@media (max-width: 420px) {
  html[data-halloween-active="true"] .header {
    min-height: 220px !important;
    padding: calc(14px + env(safe-area-inset-top, 0px)) 18px 12px !important;
  }

  html[data-halloween-active="true"] .header-actions {
    display: flex;
    flex-direction: row;
    width: auto;
    align-items: center;
  }

  html[data-halloween-active="true"] .btn-premium {
    min-width: 0;
    padding-inline: 10px !important;
  }

  html[data-halloween-active="true"] .btn-admin-crown {
    width: 36px;
    height: 36px;
  }

  .halloween-brand-art img {
    object-position: 88% 50%;
  }

  .halloween-setting-row {
    grid-template-columns: 32px minmax(0, 1fr) auto;
    gap: 9px;
    padding-inline: 14px;
    font-size: 14px;
  }
}

/* Неоновая окантовка из бота (MiTi-AI webapp/season.css): оранжевые края со свечением у шапки,
   меню и карточек, фиолетовый подсвет снизу; выбранный пункт меню — тыквенно-оранжевый. */
html[data-halloween-active="true"] body:not(.theme-light) {
  --card-border: rgba(255, 138, 42, 0.38);
  --halloween-edge: rgba(255, 138, 42, 0.55);
  --halloween-edge-glow: rgba(255, 106, 26, 0.24);
  --halloween-edge-violet: rgba(157, 60, 255, 0.4);
}

html[data-halloween-active="true"] body.theme-light {
  --card-border: rgba(255, 128, 64, 0.34);
  --halloween-edge: rgba(255, 128, 64, 0.5);
  --halloween-edge-glow: rgba(255, 128, 64, 0.2);
  --halloween-edge-violet: rgba(240, 69, 122, 0.3);
}

html[data-halloween-active="true"] .header {
  border-bottom: 1px solid var(--halloween-edge);
  box-shadow: 0 6px 24px var(--halloween-edge-glow), inset 0 -1px 0 var(--halloween-edge-violet);
}

html[data-halloween-active="true"] body:not(.admin-mode) .bottom-nav,
html[data-halloween-active="true"] body.site-chat-body .site-chat-nav {
  border-top: 1px solid var(--halloween-edge);
  box-shadow: 0 -6px 24px var(--halloween-edge-glow), 0 -1px 0 var(--halloween-edge-violet);
}

html[data-halloween-active="true"] body:not(.admin-mode) .nav-item.active {
  color: #ffa94d;
}

html[data-halloween-active="true"] body.theme-light:not(.admin-mode) .nav-item.active {
  color: #e2551f;
}

/* Карточки и панели: тонкое оранжевое свечение по краю, ярче у выбранной/наведённой. */
/* style.css paints card edges violet with !important, so the season has to as well. */
html[data-halloween-active="true"] body:not(.admin-mode) :is(.catalog-card, .npc-card, .story-card, .home-media-card, .home-character-card, .home-user-list, .settings-profile-panel, .subscription-status-card, .premium-plan-card) {
  border-color: var(--card-border) !important;
  box-shadow: 0 0 0 1px var(--card-border), 0 0 14px var(--halloween-edge-glow) !important;
}

html[data-halloween-active="true"] body:not(.admin-mode) :is(.catalog-card, .npc-card, .story-card, .home-media-card, .home-character-card):is(:hover, .active, .selected) {
  border-color: rgba(255, 138, 42, 0.7) !important;
  box-shadow: 0 0 0 1px rgba(255, 138, 42, 0.7), 0 0 18px rgba(255, 122, 26, 0.55) !important;
}

/* На широком экране меню — колонка слева: свечение по правому краю. */
@media (min-width: 1100px) {
  html[data-halloween-active="true"] body:not(.admin-mode):not(.setting-play-mode) .bottom-nav {
    border-top: 0;
    border-right: 1px solid var(--halloween-edge);
    box-shadow: 6px 0 24px var(--halloween-edge-glow), 1px 0 0 var(--halloween-edge-violet);
  }

  html[data-halloween-active="true"] body:not(.admin-mode) .nav-item.active::before {
    background: linear-gradient(180deg, #ff8a2a, #b25bff);
    box-shadow: 0 0 10px rgba(255, 122, 26, 0.8);
  }
}

@media (min-width: 768px) {
  html[data-halloween-active="true"] body.site-chat-body:not(.admin-mode):not(.setting-play-mode) .site-chat-nav {
    border-top: 0;
    border-right: 1px solid var(--halloween-edge);
    box-shadow: 6px 0 24px var(--halloween-edge-glow), 1px 0 0 var(--halloween-edge-violet);
  }

  html[data-halloween-active="true"] .site-chat-nav .nav-item.active {
    color: #ffa94d;
  }

  html[data-halloween-active="true"] .site-chat-nav .nav-item.active::before {
    background: linear-gradient(180deg, #ff8a2a, #b25bff);
    box-shadow: 0 0 10px rgba(255, 122, 26, 0.8);
  }
}

/* Анимации из бота: слой с листьями/искрами/мышами, линия под шапкой, тыква у логотипа */
html[data-halloween-active="true"] .app-container {
  isolation: isolate;
}

.halloween-fx {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}

.halloween-shimmer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  z-index: 3;
  background: linear-gradient(90deg, transparent, #ff8a2a, #b25bff, #ff8a2a, transparent);
  background-size: 200% 100%;
  animation: halloween-shimmer 4s linear infinite;
  pointer-events: none;
}

html[data-halloween-active="true"] .header .logo {
  display: inline-block;
}

.halloween-logo-icon {
  display: inline-block;
  margin-left: 6px;
  font-size: 22px;
  line-height: 1;
  vertical-align: 6px;
  filter: drop-shadow(0 0 8px rgba(255, 140, 0, 0.9));
  animation: halloween-bob 3.2s ease-in-out infinite;
}

@keyframes halloween-shimmer {
  from { background-position: 0% 0; }
  to { background-position: 200% 0; }
}

@keyframes halloween-bob {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50% { transform: translateY(-3px) rotate(6deg); }
}

@media (prefers-reduced-motion: reduce) {
  .halloween-switch span,
  .halloween-switch span::after {
    transition: none;
  }

  .halloween-shimmer,
  .halloween-logo-icon {
    animation: none;
  }

  .halloween-fx {
    display: none;
  }
}
