/*
 * Niflheim: Bifrost's December theme (js/niflheim.js turns it on). The black becomes a midnight of ice and mist,
 * the warm white ink turns to frost, and the spectrum to holly, gold, pine and ice. An aurora moves behind
 * everything, snow falls in front, and a string of Yule lights hangs along the top. Everything here is scoped to
 * [data-theme="niflheim"], so outside December this file changes nothing.
 */

/* ---------- Palette (both pages) ---------- */

:root[data-theme="niflheim"] {
  --bg: #03060d;
  --fg: #eef6ff;
  --line: rgba(200, 230, 255, 0.1);
  --spectrum: linear-gradient(90deg, #ff4d5e, #ff9a5c 20%, #ffd166 40%, #4fd98a 62%, #6cc8ff 82%, #d4eeff);
  --nifl-ice: #9fdcff;
  --nifl-holly: #ff4d5e;
  --nifl-gold: #ffd166;
  --nifl-pine: #4fd98a;
}
/* The tracker's surfaces and quieter ink (landing.css has no --surface, so these only reach the tracker). */
:root[data-theme="niflheim"]:has(link[href="css/styles.css"]) {
  --sidebar-bg: rgba(3, 6, 13, 0.74);
  --surface: #0a1120;
  --surface-2: #101a2d;
  --surface-3: #1a263d;
  --line: rgba(200, 230, 255, 0.08);
  --line-2: rgba(200, 230, 255, 0.14);
  --line-3: rgba(200, 230, 255, 0.22);
  --fg2: #a6b7cb;
  --fg3: #8798ae;
  --heat-0: #101a2d;
  --heat-1: #173451;
  --heat-2: #2a6c94;
  --heat-3: #5fb4e0;
  --heat-4: #d4eeff;
}
:root[data-theme="niflheim"]:has(link[href="css/landing.css"]) {
  --fg2: rgba(238, 246, 255, 0.66);
  --fg3: rgba(238, 246, 255, 0.54);
}

/* The sky's layers sit behind the page, so only the root paints the background (a body background would cover them). */
:root[data-theme="niflheim"] body { background: transparent; }

/* The Bifrost mark's arch, in Yule colours. */
:root[data-theme="niflheim"] #spectrum stop:nth-child(1) { stop-color: #ff4d5e; }
:root[data-theme="niflheim"] #spectrum stop:nth-child(2) { stop-color: #ff9a5c; }
:root[data-theme="niflheim"] #spectrum stop:nth-child(3) { stop-color: #ffd166; }
:root[data-theme="niflheim"] #spectrum stop:nth-child(4) { stop-color: #4fd98a; }
:root[data-theme="niflheim"] #spectrum stop:nth-child(5) { stop-color: #6cc8ff; }
:root[data-theme="niflheim"] #spectrum stop:nth-child(6) { stop-color: #d4eeff; }

/* ---------- The sky: stars, aurora and frost behind the page; snow in front ---------- */

.nifl-sky { display: contents; }
.nifl-sky > * { position: fixed; inset: 0; pointer-events: none; }
.nifl-stars, .nifl-aurora, .nifl-frost { z-index: -1; }

.nifl-stars {
  background-image:
    radial-gradient(1.2px 1.2px at 12% 18%, #fff 60%, transparent),
    radial-gradient(1px 1px at 27% 62%, #dff2ff 60%, transparent),
    radial-gradient(1.4px 1.4px at 41% 12%, #fff 60%, transparent),
    radial-gradient(1px 1px at 58% 38%, #dff2ff 60%, transparent),
    radial-gradient(1.3px 1.3px at 73% 8%, #fff 60%, transparent),
    radial-gradient(1px 1px at 86% 46%, #dff2ff 60%, transparent),
    radial-gradient(1.2px 1.2px at 94% 22%, #fff 60%, transparent),
    radial-gradient(1px 1px at 6% 78%, #dff2ff 60%, transparent);
  background-size: 640px 520px;
  opacity: .55;
  animation: nifl-twinkle-field 5s ease-in-out infinite alternate;
}
.nifl-stars.far { background-size: 410px 370px; background-position: 120px 60px; opacity: .3; animation-duration: 7s; animation-delay: -3s; }

/* Three curtains of light, blurred into one, drifting and folding slowly across the top of the sky. */
.nifl-aurora { overflow: hidden; -webkit-mask: linear-gradient(#000 0%, #000 35%, transparent 78%); mask: linear-gradient(#000 0%, #000 35%, transparent 78%); }
.nifl-aurora i {
  position: absolute;
  top: -18vh;
  left: -20vw;
  width: 140vw;
  height: 62vh;
  border-radius: 50%;
  filter: blur(60px);
  mix-blend-mode: screen;
  opacity: .5;
  transform-origin: 50% 0;
}
.nifl-aurora i:nth-child(1) {
  background: radial-gradient(50% 45% at 35% 55%, rgba(79, 217, 138, .75), transparent 70%);
  animation: nifl-curtain-a 22s ease-in-out infinite alternate;
}
.nifl-aurora i:nth-child(2) {
  background: radial-gradient(45% 40% at 65% 50%, rgba(108, 200, 255, .6), transparent 70%);
  animation: nifl-curtain-b 28s ease-in-out infinite alternate;
}
.nifl-aurora i:nth-child(3) {
  background: radial-gradient(35% 35% at 50% 40%, rgba(190, 120, 255, .4), transparent 70%);
  opacity: .38;
  animation: nifl-curtain-c 34s ease-in-out infinite alternate;
}

/* Frost creeping in from the corners of the screen. */
.nifl-frost {
  background:
    radial-gradient(70% 55% at 0% 100%, rgba(159, 220, 255, .09), transparent 60%),
    radial-gradient(70% 55% at 100% 100%, rgba(159, 220, 255, .08), transparent 60%),
    radial-gradient(120% 30% at 50% 100%, rgba(212, 238, 255, .06), transparent 70%);
  animation: nifl-breathe 9s ease-in-out infinite alternate;
}

.nifl-snow { z-index: 45; width: 100%; height: 100%; }

/* ---------- Yule lights along the top edge ---------- */

.nifl-lights {
  position: fixed;
  z-index: 46;
  top: env(safe-area-inset-top, 0px);
  left: 0;
  right: 0;
  height: 30px;
  overflow: hidden;
  pointer-events: none;
}
.nifl-lights svg { position: absolute; top: 0; left: 0; overflow: visible; }
.nifl-lights path { fill: none; stroke: rgba(30, 52, 40, .95); stroke-width: 1.6; }
.nifl-bulb {
  position: absolute;
  width: 7px;
  height: 11px;
  margin-left: -3.5px;
  border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%;
  background: radial-gradient(circle at 40% 35%, #fff 0 14%, var(--c) 46%);
  box-shadow: 0 0 6px 1px var(--c), 0 0 16px 3px color-mix(in srgb, var(--c) 45%, transparent);
  animation: nifl-bulb 3s ease-in-out infinite;
  animation-delay: calc(var(--d) * -1);
}
/* The little cap that holds each bulb on the wire. */
.nifl-bulb::before { content: ""; position: absolute; top: -3px; left: 1.5px; width: 4px; height: 4px; border-radius: 1px; background: #24372d; }

/* ---------- Landing page ---------- */

:root[data-theme="niflheim"] .top { background: linear-gradient(rgba(3, 6, 13, 0.92), transparent); padding-top: 26px; }
:root[data-theme="niflheim"] .hero-title { animation: nifl-frost-glow 6s ease-in-out infinite alternate; }
:root[data-theme="niflheim"] .seal-stage::before {
  background: radial-gradient(closest-side, rgba(159, 220, 255, 0.16), rgba(79, 217, 138, 0.05) 50%, transparent 75%);
  animation: nifl-breathe 5s ease-in-out infinite alternate;
}
:root[data-theme="niflheim"] a.pill {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-color: #eef6ff;
  background: linear-gradient(180deg, #ffffff, #d9efff);
  box-shadow: 0 0 0 0 rgba(159, 220, 255, .5), 0 8px 30px -8px rgba(108, 200, 255, .55);
  animation: nifl-pulse 3.2s ease-in-out infinite;
}
:root[data-theme="niflheim"] a.pill::after, :root[data-theme="niflheim"] .button.primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .9) 48%, rgba(159, 220, 255, .6) 52%, transparent 65%);
  z-index: -1;
  transform: translateX(-120%);
  animation: nifl-sheen 4.5s var(--ease) infinite;
  pointer-events: none;
}
.nifl-greeting {
  margin-top: 18px;
  color: var(--nifl-ice);
  font-size: 13px;
  letter-spacing: .02em;
  animation: nifl-rise 1.2s var(--ease) both .6s;
}
.nifl-greeting span { display: inline-block; margin-right: 6px; animation: nifl-spin 8s linear infinite; }
:root[data-theme="niflheim"] .hero-runes { color: var(--nifl-ice); text-shadow: 0 0 12px rgba(159, 220, 255, .55); }
:root[data-theme="niflheim"] .step-rune,
:root[data-theme="niflheim"] .feat-rune { color: var(--nifl-ice); text-shadow: 0 0 14px rgba(159, 220, 255, .6); animation: nifl-rune-glow 4s ease-in-out infinite alternate; }
:root[data-theme="niflheim"] .feat:nth-child(3n + 2) .feat-rune { color: var(--nifl-gold); text-shadow: 0 0 14px rgba(255, 209, 102, .55); animation-delay: -1.3s; }
:root[data-theme="niflheim"] .feat:nth-child(3n) .feat-rune { color: var(--nifl-pine); text-shadow: 0 0 14px rgba(79, 217, 138, .55); animation-delay: -2.6s; }
:root[data-theme="niflheim"] .shot img { box-shadow: 0 0 0 1px rgba(200, 230, 255, .12), 0 30px 80px -30px rgba(108, 200, 255, .35); }
/* The band crosses into Niflheim in holly, gold, pine and frost (landing.js draws the edges to match). */
:root[data-theme="niflheim"] .band {
  --band: linear-gradient(90deg, #ffc4cb 0%, #ffe3ad 25%, #cdf1d9 50%, #c9ecff 75%, #eef6ff 100%);
  background-size: 200% 100%;
  animation: nifl-band 18s ease-in-out infinite alternate;
}
:root[data-theme="niflheim"] .band.has-edges { background-size: 100% calc(100% - var(--edge) * 2); animation: none; }
:root[data-theme="niflheim"] .band::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .5) 50%, transparent 70%) no-repeat;
  background-size: 40% 100%;
  animation: nifl-band-sheen 9s ease-in-out infinite;
  pointer-events: none;
}
:root[data-theme="niflheim"] .band.has-edges::after { inset: var(--edge) 0; }
:root[data-theme="niflheim"] .faq details { border-color: var(--line); }

/* ---------- Tracker ---------- */

:root[data-theme="niflheim"] .sidebar { backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
:root[data-theme="niflheim"] .sidebar-top { margin-top: 14px; }
/* Title and profile pages let their backdrop run up under a clear topbar; only the other pages get the tinted bar. */
:root[data-theme="niflheim"] body:not(:is([data-page="title"], [data-page="profile"], [data-page="u"])) .topbar { background: rgba(3, 6, 13, .74); }
:root[data-theme="niflheim"] .tabbar { background: rgba(3, 6, 13, .9); }
:root[data-theme="niflheim"] .side-main[aria-current="page"] { color: #fff; text-shadow: 0 0 12px rgba(159, 220, 255, .7); }
:root[data-theme="niflheim"] .side-main[aria-current="page"] .icon { color: var(--nifl-ice); filter: drop-shadow(0 0 5px rgba(159, 220, 255, .8)); }
:root[data-theme="niflheim"] .button.primary {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: linear-gradient(180deg, #ffffff, #d9efff);
  box-shadow: 0 6px 22px -8px rgba(108, 200, 255, .6);
}
:root[data-theme="niflheim"] .poster-wrap { transition: box-shadow 300ms var(--ease), transform 400ms var(--ease); }
:root[data-theme="niflheim"] .poster-card:hover .poster-wrap {
  box-shadow: 0 0 0 1px rgba(159, 220, 255, .55), 0 0 22px -2px rgba(108, 200, 255, .45);
  transform: translateY(-3px);
}
:root[data-theme="niflheim"] .bar > span { background-size: 200% 100%; animation: nifl-band 6s linear infinite alternate; }
:root[data-theme="niflheim"] .welcome-glow,
:root[data-theme="niflheim"] .spectrum-glow {
  background:
    radial-gradient(60% 80% at 80% 0%, rgba(79, 217, 138, .22), transparent 60%),
    radial-gradient(50% 70% at 100% 70%, rgba(108, 200, 255, .16), transparent 60%),
    radial-gradient(40% 60% at 55% 0%, rgba(255, 77, 94, .16), transparent 60%);
  animation: nifl-breathe 7s ease-in-out infinite alternate;
}
:root[data-theme="niflheim"] .page-head h1 { text-shadow: 0 0 28px rgba(159, 220, 255, .28); }
:root[data-theme="niflheim"] .gate-mark { filter: drop-shadow(0 0 14px rgba(159, 220, 255, .5)); }
:root[data-theme="niflheim"] .set-rune { color: var(--nifl-ice); }

/* Settings › Appearance */
.nifl-preview {
  position: relative;
  overflow: hidden;
  height: 120px;
  margin: 4px 0 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: radial-gradient(80% 120% at 30% 0%, rgba(79, 217, 138, .35), transparent 60%), radial-gradient(60% 100% at 80% 10%, rgba(108, 200, 255, .3), transparent 60%), #03060d;
}
.nifl-preview::before {
  content: "";
  position: absolute;
  inset: -120px 0 0;
  background-image: radial-gradient(2px 2px at 20px 30px, #fff 60%, transparent), radial-gradient(1.5px 1.5px at 70px 80px, #dff2ff 60%, transparent), radial-gradient(2.5px 2.5px at 120px 20px, #fff 60%, transparent), radial-gradient(1.5px 1.5px at 160px 100px, #dff2ff 60%, transparent);
  background-size: 180px 120px;
  animation: nifl-preview-snow 6s linear infinite;
}
.nifl-preview span { position: absolute; left: 18px; bottom: 14px; font-weight: 600; font-size: 18px; letter-spacing: -.02em; text-shadow: 0 0 18px rgba(159, 220, 255, .8); }
.nifl-preview.is-off { filter: grayscale(.8) brightness(.6); }
.nifl-preview.is-off::before { animation-play-state: paused; }

/* ---------- Motion ---------- */

@keyframes nifl-twinkle-field { from { opacity: .25; } to { opacity: .6; } }
@keyframes nifl-curtain-a { 0% { transform: translateX(-6vw) skewX(-8deg) scaleY(.9); } 50% { transform: translateX(4vw) skewX(6deg) scaleY(1.1); } 100% { transform: translateX(10vw) skewX(-4deg) scaleY(.95); } }
@keyframes nifl-curtain-b { 0% { transform: translateX(8vw) skewX(10deg) scaleY(1); } 50% { transform: translateX(-6vw) skewX(-6deg) scaleY(1.15); } 100% { transform: translateX(-12vw) skewX(4deg) scaleY(.9); } }
@keyframes nifl-curtain-c { 0% { transform: translateX(0) scale(1); opacity: .2; } 50% { transform: translateX(-8vw) scale(1.2); opacity: .45; } 100% { transform: translateX(6vw) scale(.9); opacity: .3; } }
@keyframes nifl-breathe { from { opacity: .65; } to { opacity: 1; } }
@keyframes nifl-bulb { 0%, 100% { opacity: 1; filter: brightness(1.15); } 45% { opacity: .35; filter: brightness(.6); } 55% { opacity: .4; } }
@keyframes nifl-frost-glow { from { text-shadow: 0 0 18px rgba(159, 220, 255, .15); } to { text-shadow: 0 0 34px rgba(159, 220, 255, .5), 0 0 2px rgba(255, 255, 255, .6); } }
@keyframes nifl-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(159, 220, 255, .45), 0 8px 30px -8px rgba(108, 200, 255, .55); } 50% { box-shadow: 0 0 0 8px rgba(159, 220, 255, 0), 0 8px 34px -6px rgba(108, 200, 255, .7); } }
@keyframes nifl-sheen { 0%, 60% { transform: translateX(-120%); } 100% { transform: translateX(120%); } }
@keyframes nifl-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes nifl-spin { to { transform: rotate(360deg); } }
@keyframes nifl-rune-glow { from { filter: brightness(.85); } to { filter: brightness(1.25); } }
@keyframes nifl-band { from { background-position: 0% 0; } to { background-position: 100% 0; } }
@keyframes nifl-band-sheen { 0%, 40% { background-position: -60% 0; } 100% { background-position: 160% 0; } }
@keyframes nifl-preview-snow { to { transform: translateY(120px); } }

@media (prefers-reduced-motion: reduce) {
  [data-theme="niflheim"] *, [data-theme="niflheim"] *::before, [data-theme="niflheim"] *::after, .nifl-sky > *, .nifl-bulb, .nifl-preview::before { animation: none !important; }
  :root[data-theme="niflheim"] a.pill::after, :root[data-theme="niflheim"] .button.primary::after { display: none; }
}

/* Friends: the new-activity dot in ice, so it reads against the aurora rather than as a notification from elsewhere. */
:root[data-theme="niflheim"] .nav-dot { background: var(--nifl-ice); box-shadow: 0 0 8px var(--nifl-ice); }
