/* Seasonal themes (-38): Halloween and Christmas.
 *
 * Linked only while a season is switched on in the panel (app/seasonal.py),
 * so with the theme off this file is not even requested. Every rule is
 * scoped to html[data-season="…"], every name ends in -38, and nothing here
 * takes part in layout: the decorations are fixed or absolutely positioned
 * and never receive a click. The elements are built by season-38.js.
 */

html[data-season="halloween"] {
  --season-a-38: #f97316;
  --season-b-38: #a855f7;
  --season-glow-38: rgba(249, 115, 22, 0.55);
}

html[data-season="christmas"] {
  --season-a-38: #ef4444;
  --season-b-38: #16a34a;
  --season-c-38: #facc15;
  --season-glow-38: rgba(239, 68, 68, 0.5);
}

/* ---------------------------------------------------------------------------
   The navigation bar: its button and underline take the season's colours
   --------------------------------------------------------------------------- */

html[data-season] nav.site-nav-88 a.buttonsg {
  background: linear-gradient(90deg, var(--season-a-38) 0%, var(--season-b-38) 50%, var(--season-a-38) 100%);
  background-size: 200% 100%;
  box-shadow: 0 8px 22px -10px var(--season-glow-38), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

html[data-season] nav.site-nav-88::after {
  background: linear-gradient(90deg, transparent, var(--season-a-38) 25%, var(--season-b-38) 75%, transparent);
  opacity: 0.8;
}

/* ---------------------------------------------------------------------------
   Shared pieces
   --------------------------------------------------------------------------- */

.season-layer-38 {
  position: fixed;
  inset: 0;
  z-index: 48;
  overflow: hidden;
  pointer-events: none;
}

.season-logo-38 {
  position: relative;
}

.season-badge-38 {
  position: absolute;
  z-index: 1;
  pointer-events: none;
  line-height: 0;
}

.season-badge-38 svg,
.season-web-38 svg,
.season-bat-38 svg,
.season-spider-38 svg {
  display: block;
  width: 100%;
  height: auto;
}

.season-toggle-38 {
  position: fixed;
  inset-inline-start: 16px;
  bottom: 16px;
  z-index: 49;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.82);
  color: #e5e7eb;
  cursor: pointer;
  box-shadow: 0 8px 20px -10px rgba(0, 0, 0, 0.9);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.season-toggle-38:hover {
  transform: translateY(-1px);
}

.season-toggle-38:focus-visible {
  outline: 2px solid var(--season-a-38);
  outline-offset: 3px;
}

.season-toggle-38 svg {
  width: 18px;
  height: 18px;
}

html[data-season="halloween"] .season-toggle-38 {
  color: var(--season-a-38);
}

/* A visitor who hid the effects keeps only the button, dimmed. */
html.season-hidden-38 .season-layer-38,
html.season-hidden-38 .season-web-38,
html.season-hidden-38 .season-spider-38,
html.season-hidden-38 .season-lights-38,
html.season-hidden-38 .season-badge-38 {
  display: none;
}

html.season-hidden-38 .season-toggle-38 {
  opacity: 0.55;
}

/* ---------------------------------------------------------------------------
   Halloween
   --------------------------------------------------------------------------- */

html[data-season="halloween"] .season-badge-38 {
  top: -8px;
  inset-inline-end: -12px;
  width: 22px;
  filter: drop-shadow(0 0 6px rgba(249, 115, 22, 0.6));
}

/* A cobweb in the corner under the bar, at the top of the page only. */
.season-web-38 {
  position: absolute;
  top: 56px;
  inset-inline-end: 0;
  z-index: 47;
  width: 120px;
  opacity: 0.32;
  pointer-events: none;
}

[dir="rtl"] .season-web-38 svg {
  transform: scaleX(-1);
}

/* A spider on a thread, hanging from the bottom of the bar. */
.season-spider-38 {
  position: absolute;
  top: 100%;
  inset-inline-end: 14%;
  width: 26px;
  filter: drop-shadow(0 0 4px rgba(168, 85, 247, 0.55));
  pointer-events: none;
  animation: season-bob-38 3.2s ease-in-out infinite alternate;
}

.season-spider-38::before {
  content: "";
  display: block;
  width: 1px;
  height: 30px;
  margin: 0 auto;
  background: rgba(229, 231, 235, 0.6);
}

.season-bat-38 {
  position: absolute;
  left: 0;
  width: 46px;
  opacity: 0.9;
  filter: drop-shadow(0 0 6px rgba(249, 115, 22, 0.55));
  animation: season-fly-38 var(--season-time-38, 20s) linear infinite;
  animation-delay: var(--season-delay-38, 0s);
  animation-fill-mode: backwards;
}

.season-bat-38 svg {
  animation: season-flap-38 0.32s ease-in-out infinite alternate;
  transform-origin: 50% 40%;
}

@keyframes season-fly-38 {
  0%   { transform: translate3d(-12vw, 0, 0); }
  25%  { transform: translate3d(20vw, -3vh, 0); }
  50%  { transform: translate3d(50vw, 2vh, 0); }
  75%  { transform: translate3d(80vw, -4vh, 0); }
  100% { transform: translate3d(112vw, 1vh, 0); }
}

@keyframes season-flap-38 {
  from { transform: scaleY(1); }
  to   { transform: scaleY(0.55); }
}

@keyframes season-bob-38 {
  from { transform: translateY(0); }
  to   { transform: translateY(10px); }
}

/* ---------------------------------------------------------------------------
   Christmas
   --------------------------------------------------------------------------- */

html[data-season="christmas"] .season-badge-38 {
  top: -14px;
  inset-inline-start: -10px;
  width: 28px;
  transform: rotate(-16deg);
}

/* String lights hanging from the bottom of the bar. */
.season-lights-38 {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  height: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  pointer-events: none;
}

.season-bulb-38 {
  width: 7px;
  height: 10px;
  margin-top: 2px;
  border-radius: 50% 50% 45% 45%;
  background: var(--season-bulb-38, #facc15);
  box-shadow: 0 0 8px 1px var(--season-bulb-38, #facc15);
  animation: season-twinkle-38 1.8s ease-in-out infinite alternate;
  animation-delay: var(--season-delay-38, 0s);
}

@keyframes season-twinkle-38 {
  from { opacity: 1; }
  to   { opacity: 0.35; box-shadow: none; }
}

.season-flake-38 {
  position: absolute;
  top: 0;
  width: var(--season-size-38, 5px);
  height: var(--season-size-38, 5px);
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, rgba(255, 255, 255, 0.85) 45%, rgba(255, 255, 255, 0) 70%);
  opacity: var(--season-alpha-38, 0.8);
  animation: season-fall-38 var(--season-time-38, 12s) linear infinite;
  animation-delay: var(--season-delay-38, 0s);
}

@keyframes season-fall-38 {
  from { transform: translate3d(0, -12px, 0); }
  to   { transform: translate3d(var(--season-drift-38, 30px), 102vh, 0); }
}

/* ---------------------------------------------------------------------------
   Calm and print
   --------------------------------------------------------------------------- */

@media (max-width: 640px) {
  .season-web-38 { width: 78px; top: 52px; }
  .season-spider-38 { inset-inline-end: 6%; }
}

@media (prefers-reduced-motion: reduce) {
  .season-bat-38,
  .season-flake-38 { display: none; }
  .season-spider-38,
  .season-bulb-38 { animation: none; }
}

@media print {
  .season-layer-38,
  .season-web-38,
  .season-spider-38,
  .season-lights-38,
  .season-badge-38,
  .season-toggle-38 { display: none !important; }
}
