/* Motyw Halloween. Dołączany przez serwer tylko wtedy, gdy w Panel > Ustawienia wybrano "Halloween".
   Wszystko jest pod html[data-theme="halloween"], więc wyłączenie motywu przywraca zwykły wygląd. */

html[data-theme="halloween"] {
  --hw-orange: #ff8a1f;
  --hw-orange-soft: #ffbe6b;
  --hw-orange-deep: #e0520f;
  --hw-purple: #8b5cf6;
  --hw-purple-soft: #b794ff;
  --hw-night: #07040b;
  --hw-panel: rgba(18, 11, 27, 0.9);
  --hw-panel-strong: #110a1a;
  --hw-line: rgba(139, 92, 246, 0.16);

  --bg-dark: var(--hw-night);
  --bg-mid: #0d0814;
  --bg-soft: #110a1a;
  --bg-card: rgba(139, 92, 246, 0.05);
  --bg-card-s: rgba(139, 92, 246, 0.09);
  --pink: #ff9a3c;
  --orange: #ff6a00;
  --cyan: #ffc078;
  --purple: #8b5cf6;
  --border: rgba(255, 138, 31, 0.14);
  --border-s: rgba(255, 138, 31, 0.26);
  --glow-pink: rgba(255, 138, 31, 0.25);
  --glow-ora: rgba(224, 82, 15, 0.22);
  --plrp-panel: var(--hw-panel);
  --plrp-panel-strong: var(--hw-panel-strong);
  --plrp-amber: #ff9a3c;
  --plrp-amber-soft: #ffc078;
  --plrp-copper: #e0601a;
  --plrp-line: rgba(255, 138, 31, 0.16);

  --sn-amber: #ff9a3c;
  --sn-amber-soft: #ffc078;
  --sn-copper: #e0601a;
  --sn-line-warm: rgba(255, 138, 31, 0.22);

  background: var(--hw-night);
}

html[data-theme="halloween"] body {
  background: var(--hw-night);
}

/* Night sky: moonlight top right, purple haze, pumpkin glow low on the page. */
html[data-theme="halloween"] body::before {
  background:
    radial-gradient(700px 520px at 86% -4%, rgba(255, 220, 160, 0.11), transparent 60%),
    radial-gradient(900px 640px at 4% 8%, rgba(124, 58, 237, 0.17), transparent 62%),
    radial-gradient(900px 700px at 92% 96%, rgba(255, 106, 0, 0.12), transparent 60%),
    radial-gradient(1100px 760px at 14% 104%, rgba(88, 28, 135, 0.22), transparent 62%);
}

html[data-theme="halloween"] ::selection {
  color: #12070a;
  background: var(--hw-orange);
}

html[data-theme="halloween"] ::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--hw-orange), var(--hw-purple));
}

/* ---------- Navigation ---------- */

html[data-theme="halloween"] .site-nav {
  background: linear-gradient(180deg, rgba(12, 6, 18, 0.9) 0%, rgba(12, 6, 18, 0.7) 100%);
  border-bottom-color: var(--hw-line);
}

html[data-theme="halloween"] .site-nav::after {
  background: linear-gradient(90deg, transparent 0%, rgba(255, 138, 31, 0.45) 30%, rgba(139, 92, 246, 0.45) 70%, transparent 100%);
}

html[data-theme="halloween"] .sn-brand img {
  object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(255, 138, 31, 0.45));
}

html[data-theme="halloween"] .sn-brand-text span {
  color: var(--hw-orange);
}

html[data-theme="halloween"] :is(.sn-menu, .sn-notif-panel, .sn-drawer) {
  background: rgba(16, 9, 24, 0.98);
}

/* ---------- Hero ---------- */

html[data-theme="halloween"] .hero {
  background:
    radial-gradient(circle at 74% 42%, rgba(255, 150, 50, 0.16), transparent 34%),
    radial-gradient(circle at 74% 42%, rgba(139, 92, 246, 0.16), transparent 58%);
  border-bottom-color: var(--hw-line);
}

html[data-theme="halloween"] .hero::after {
  background: linear-gradient(90deg, transparent, rgba(255, 138, 31, 0.5), rgba(139, 92, 246, 0.5), transparent);
}

html[data-theme="halloween"] .hero-bg-banner {
  /* The glow is painted as gradients behind the logo instead of drop-shadow filters, which the browser would
     recompute on every frame of the float animation. */
  background:
    url('../img/halloween/logo-halloween.webp') 86% 58% / auto 80% no-repeat,
    radial-gradient(ellipse 30% 42% at 80% 58%, rgba(255, 120, 20, 0.2), transparent 70%),
    radial-gradient(ellipse 44% 60% at 78% 56%, rgba(139, 92, 246, 0.14), transparent 72%);
  opacity: 0.95;
  filter: none;
  mask-image: linear-gradient(90deg, transparent 0%, black 30%);
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, black 30%);
  animation: hw-float 7s ease-in-out infinite;
  will-change: transform;
}

.hw-paused .hero-bg-banner,
.hw-paused .hw-bat,
.hw-paused .hw-bat-body,
.hw-paused .hw-bat svg,
.hw-paused .hw-spider,
.hw-paused .hw-spider svg,
.hw-paused .hw-spider-thread,
.hw-paused .hw-fog {
  animation-play-state: paused !important;
}

.hw-paused .hw-layer {
  visibility: hidden;
}

html[data-theme="halloween"] canvas#particles {
  opacity: 0.4;
}

html[data-theme="halloween"] .hero .grad2,
html[data-theme="halloween"] .docs-hero-content .grad2 {
  font-family: 'Eater', 'Poppins', cursive;
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1.12;
  background: linear-gradient(180deg, #ffd98a 0%, #ff8a1f 52%, #c2410c 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 22px rgba(255, 120, 20, 0.45));
}

html[data-theme="halloween"] .hero .grad2 {
  font-size: 0.86em;
}

html[data-theme="halloween"] .hero-info-box {
  background: rgba(18, 10, 26, 0.78);
  border-color: var(--hw-line);
}

html[data-theme="halloween"] .hero-info-dot {
  width: auto;
  height: auto;
  background: none;
  box-shadow: none;
  animation: none;
}

html[data-theme="halloween"] .hero-info-dot::before {
  content: "🎃";
  font-size: 18px;
  line-height: 1;
  filter: drop-shadow(0 0 8px rgba(255, 120, 20, 0.6));
}

html[data-theme="halloween"] .hero-restart {
  background: rgba(18, 10, 26, 0.7);
  border-color: var(--hw-line);
}

.hw-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 138, 31, 0.4);
  background: linear-gradient(90deg, rgba(255, 138, 31, 0.16), rgba(139, 92, 246, 0.16));
  color: #ffd2a0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  box-shadow: 0 0 24px rgba(255, 120, 20, 0.18);
}

/* ---------- Buttons ---------- */

html[data-theme="halloween"] :is(.btn-primary, .btn-submit-pink, .btn-pink, .btn-send, .btn-blue, .doc-open) {
  background: linear-gradient(135deg, #ffbe6b, #ff7a1a 55%, #d9480f) !important;
  border-color: rgba(255, 210, 160, 0.3) !important;
  box-shadow: 0 10px 28px rgba(255, 106, 0, 0.25) !important;
}

html[data-theme="halloween"] :is(.btn-secondary, .back-btn, .action-btn, .btn-action, .btn-view):hover {
  background: rgba(139, 92, 246, 0.12);
  border-color: rgba(183, 148, 255, 0.45);
  box-shadow: 0 0 22px rgba(139, 92, 246, 0.2);
}

html[data-theme="halloween"] :is(.sn-cta, .pn-btn-primary, .rules-staff-btn.is-primary) {
  background: linear-gradient(135deg, #ffbe6b 0%, #ff7a1a 50%, #d9480f 100%);
  box-shadow: 0 8px 24px rgba(255, 106, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

html[data-theme="halloween"] .pn-btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #ffbe6b 0%, #ff7a1a 50%, #d9480f 100%);
}

/* ---------- Sections and cards ---------- */

html[data-theme="halloween"] .section.bg-soft {
  background: rgba(139, 92, 246, 0.03);
}

html[data-theme="halloween"] .section-tag::before,
html[data-theme="halloween"] .step-line {
  background: linear-gradient(90deg, var(--hw-orange), var(--hw-purple));
}

html[data-theme="halloween"] :is(.feat-card, .step-card, .status-card, .faction-card, .acc-item, .faq-item, .discord-box, .rules-intro, .rules-search) {
  background: rgba(20, 11, 30, 0.6);
  border-color: var(--hw-line);
}

html[data-theme="halloween"] :is(.feat-card, .step-card, .status-card, .faction-card, .acc-item, .faq-item):hover {
  border-color: rgba(255, 138, 31, 0.4);
  box-shadow: 0 0 0 1px rgba(255, 138, 31, 0.08), 0 18px 40px rgba(88, 28, 135, 0.25);
}

html[data-theme="halloween"] .feat-num {
  color: var(--hw-orange);
  text-shadow: 0 0 18px rgba(255, 120, 20, 0.45);
}

html[data-theme="halloween"] .rules-intro {
  border-left-color: var(--hw-orange);
}

html[data-theme="halloween"] .acc-header[aria-expanded="true"] {
  color: var(--hw-orange-soft);
  background: rgba(255, 138, 31, 0.06);
}

html[data-theme="halloween"] .gallery-grid img {
  filter: saturate(0.85) hue-rotate(-8deg) contrast(1.05);
  transition: filter .3s ease;
}

html[data-theme="halloween"] .gallery-grid img:hover {
  filter: none;
}

html[data-theme="halloween"] footer {
  background: rgba(10, 5, 16, 0.85);
  border-top-color: var(--hw-line);
}

html[data-theme="halloween"] .footer-year {
  color: var(--hw-orange);
}

/* ---------- Player and staff panels ---------- */

html[data-theme="halloween"] :is(.pn-card, .pn-row, .pn-empty, .adm-stat, .adm-tabs, .adm-me, .adm-item, .adm-veh, .adm-modal-box, .ac-status, .tk-closed) {
  background-color: var(--hw-panel);
  border-color: var(--hw-line);
}

html[data-theme="halloween"] .pn-row:hover,
html[data-theme="halloween"] .pn-row:focus-visible {
  background-color: rgba(26, 14, 38, 0.95);
  border-color: rgba(255, 138, 31, 0.4);
}

html[data-theme="halloween"] .pn-eyebrow {
  color: var(--hw-orange);
}

html[data-theme="halloween"] .pn-hero h1,
html[data-theme="halloween"] .ac-hero-main h1 {
  text-shadow: 0 0 30px rgba(139, 92, 246, 0.35);
}

html[data-theme="halloween"] :is(.pn-row-id, .rx-badge) {
  border-color: rgba(255, 138, 31, 0.35);
  background: rgba(255, 138, 31, 0.1);
  color: var(--hw-orange-soft);
}

html[data-theme="halloween"] :is(.adm-tab.is-active, .adm-chip.is-active) {
  background: linear-gradient(90deg, rgba(255, 138, 31, 0.16), rgba(139, 92, 246, 0.16));
}

html[data-theme="halloween"] .tk-thread {
  background: rgba(14, 8, 21, 0.9);
}

html[data-theme="halloween"] .tk-composer {
  background: rgba(18, 10, 27, 0.97);
  border-color: rgba(255, 138, 31, 0.22);
}

html[data-theme="halloween"] .tk-msg.is-staff .tk-bubble {
  border-color: rgba(255, 138, 31, 0.28);
  background: rgba(255, 138, 31, 0.08);
}

/* ---------- Decorations (added by theme-halloween.js) ---------- */

.hw-layer {
  position: fixed;
  inset: 0;
  z-index: 4;
  overflow: hidden;
  pointer-events: none;
}

.hw-bat {
  position: absolute;
  left: 0;
  /* Never under the site nav (the bob moves a bat up to 18 px up). */
  top: max(var(--y, 20vh), calc(var(--sn-h, 72px) + 26px));
  width: calc(46px * var(--s, 1));
  color: #12081c;
  opacity: 0.9;
  animation: hw-fly var(--dur, 22s) linear var(--delay, 0s) infinite;
  will-change: transform;
}

.hw-bat-body {
  display: block;
  animation: hw-bob var(--bob, 3s) ease-in-out infinite alternate;
}

.hw-bat-body svg {
  display: block;
  width: 100%;
  height: auto;
  transform-origin: 50% 40%;
  animation: hw-flap 0.22s ease-in-out infinite alternate;
}

/* A thin orange rim keeps the bats visible on the night sky without a per-frame blur filter. */
.hw-bat-body path {
  stroke: rgba(255, 138, 31, 0.4);
  stroke-width: 1.2;
}

.hw-web {
  position: absolute;
  width: 220px;
  height: 220px;
  color: rgba(230, 220, 255, 0.16);
  pointer-events: none;
  z-index: 1;
}

.hw-web--tl {
  top: 0;
  left: 0;
}

.hw-web--br {
  right: 0;
  bottom: 0;
  transform: rotate(180deg);
}

.hw-spider {
  position: absolute;
  top: var(--sn-h, 72px);
  right: 9%;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  --thread: 150px;
}

/* The thread stretches from the top edge and the spider rides its end, so the spider itself keeps its shape. */
.hw-spider-thread {
  width: 1px;
  height: var(--thread);
  background: linear-gradient(180deg, rgba(230, 220, 255, 0), rgba(230, 220, 255, 0.45));
  transform-origin: top center;
  animation: hw-thread 6s ease-in-out infinite alternate;
}

.hw-spider svg {
  width: 34px;
  margin-top: -2px;
  animation: hw-dangle 6s ease-in-out infinite alternate;
  color: #160a20;
  filter: drop-shadow(0 0 8px rgba(255, 138, 31, 0.45));
}

.hw-fog {
  position: absolute;
  left: -10%;
  right: -10%;
  bottom: -40px;
  height: 220px;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 30% 60% at 20% 70%, rgba(190, 170, 230, 0.12), transparent 70%),
    radial-gradient(ellipse 35% 55% at 55% 80%, rgba(190, 170, 230, 0.1), transparent 70%),
    radial-gradient(ellipse 30% 60% at 85% 70%, rgba(190, 170, 230, 0.12), transparent 70%);
  animation: hw-fog 26s ease-in-out infinite alternate;
}

html[data-theme="halloween"] .hero,
html[data-theme="halloween"] footer {
  overflow: hidden;
}

@keyframes hw-fly {
  from { transform: translateX(-12vw); }
  to { transform: translateX(112vw); }
}

@keyframes hw-bob {
  from { transform: translateY(-18px) rotate(-4deg); }
  to { transform: translateY(18px) rotate(5deg); }
}

@keyframes hw-flap {
  from { transform: scaleY(1); }
  to { transform: scaleY(0.45); }
}

/* Floats downwards only, so the logo never slides under the site nav. */
@keyframes hw-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(10px); }
}

@keyframes hw-thread {
  from { transform: scaleY(0.75); }
  to { transform: scaleY(1.15); }
}

@keyframes hw-dangle {
  from { transform: translateY(calc(var(--thread) * -0.25)); }
  to { transform: translateY(calc(var(--thread) * 0.15)); }
}

@keyframes hw-fog {
  from { transform: translateX(-4%); }
  to { transform: translateX(4%); }
}

@media (max-width: 760px) {
  .hw-web {
    width: 140px;
    height: 140px;
  }

  .hw-spider {
    right: 6%;
    --thread: 90px;
  }

  /* On phones the logo sits behind the hero text, so it is dimmer and fades out downwards like the normal theme. */
  html[data-theme="halloween"] .hero-bg-banner {
    opacity: 0.22;
    mask-image: linear-gradient(180deg, black 10%, transparent 90%);
    -webkit-mask-image: linear-gradient(180deg, black 10%, transparent 90%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hw-bat,
  .hw-bat-body,
  .hw-bat-body svg,
  .hw-spider,
  .hw-spider-thread,
  .hw-spider svg,
  .hw-fog,
  html[data-theme="halloween"] .hero-bg-banner {
    animation: none !important;
  }

  .hw-layer {
    display: none;
  }
}
