/* signal: every station has a world of its own. a colour (--station), a glow layer that cross fades when you tune,
   the moving backdrop (ambient_scenes.ts), title lock-in and the live dial (signal.ts), and the power-on.
   all of it sits on top of the theme and goes away with html[data-worlds="off"], .calm, .nojuice or reduced motion */

/* ---------- a colour per station. bright on dark themes, deep on light ones so text mixed with it keeps its contrast ---------- */
body[data-station="home"] { --station: #ff5fae; }
body[data-station="plan"] { --station: #4fb8ff; }
body[data-station="studio"] { --station: #b48cff; }
body[data-station="practice"] { --station: #5fe07f; }
body[data-station="money"] { --station: #ffc94f; }
body[data-station="tools"] { --station: #ff9a4f; }
body[data-station="core"] { --station: #4fe0c0; }
html[data-tone="light"] body[data-station="home"] { --station: #c2307a; }
html[data-tone="light"] body[data-station="plan"] { --station: #1c78c4; }
html[data-tone="light"] body[data-station="studio"] { --station: #7a4fd6; }
html[data-tone="light"] body[data-station="practice"] { --station: #1f8a43; }
html[data-tone="light"] body[data-station="money"] { --station: #a66a00; }
html[data-tone="light"] body[data-station="tools"] { --station: #c25a10; }
html[data-tone="light"] body[data-station="core"] { --station: #138a72; }

/* the theme accent leaned toward the station, for decoration. text keeps using --chi, which is contrast checked */
body[data-station] { --chi-s: color-mix(in srgb, var(--chi) 55%, var(--station)); --jx-tint: color-mix(in srgb, var(--station) 11%, transparent); }

/* ---------- the glow layer: a wash from the top edge and a corner light, tinted by the station ---------- */
@property --tint { syntax: "<color>"; inherits: false; initial-value: transparent; }
.station-glow {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; contain: strict;
  --tint: var(--station, transparent);
  transition: --tint 0.7s ease;
  background:
    radial-gradient(75% 42% at 50% -6%, color-mix(in srgb, var(--tint) 27%, transparent), transparent 72%),
    radial-gradient(55% 38% at 100% 100%, color-mix(in srgb, var(--tint) 17%, transparent), transparent 72%);
  opacity: min(1, calc(0.35 + 0.65 * var(--k-fog, 1)));
}
html[data-worlds="off"] .station-glow { display: none; }
html.calm .station-glow, html.nojuice .station-glow { transition: none; }
@media (prefers-reduced-motion: reduce) { .station-glow { transition: none; } }
@media (prefers-contrast: more) { html:root .station-glow { display: none; } }
@media (forced-colors: active) { .station-glow, .sig-dial, .sig-boot { display: none; } }

/* the channel stamp over a title takes a little of the station colour (mixed into --ink-2, so still readable) */
html:not([data-worlds="off"]) body[data-station] .view.active h1[data-code]::before { color: color-mix(in srgb, var(--ink-2) 62%, var(--station)); }
html:not([data-worlds="off"]):not(.calm):not(.nojuice) body[data-station] .view.active h1 { text-shadow: 0 0 22px color-mix(in srgb, var(--station) 34%, transparent); }

/* ---------- title lock-in: the text is scrambled by script, a brief colour split sits on it meanwhile ---------- */
h1.sig-lock { text-shadow: 2px 0 color-mix(in srgb, var(--red, #ff4458) 70%, transparent), -2px 0 color-mix(in srgb, var(--chi) 70%, transparent) !important; overflow: hidden; }

/* ---------- live dial: a scale beside the channel stamp and a needle that swings to the station with a spring ---------- */
.sig-dial {
  position: absolute; top: 0; right: 0; width: clamp(72px, 34%, 168px); height: 11px; overflow: hidden; pointer-events: none;
  background:
    linear-gradient(var(--ink-3), var(--ink-3)) 0 100% / 100% 1px no-repeat,
    repeating-linear-gradient(90deg, var(--ink-3) 0 1px, transparent 1px 6px) 0 100% / 100% 4px no-repeat,
    linear-gradient(90deg, var(--ink-3) 0 1px, transparent 1px) 0 100% / calc(100% / 6) 9px repeat-x,
    linear-gradient(var(--ink-3), var(--ink-3)) 100% 100% / 1px 9px no-repeat;
  opacity: 0.75;
}
.sig-dial[hidden], .sig-dial.tight { display: none; }
html[data-worlds="off"] .sig-dial { display: none; }
/* the needle layer is as wide as the scale, so a percent of its own width is a place on the dial */
.sig-needle { position: absolute; inset: 0; transform: translateX(calc(var(--to, 0) * 100%)); }
.sig-needle b { position: absolute; left: -1px; top: 0; bottom: 0; width: 2px; background: var(--red, #ff4458); box-shadow: 0 0 6px var(--red, #ff4458); }
@keyframes sig-swing { from { transform: translateX(calc(var(--from, 0) * 100%)); } }
@keyframes sig-tremble { 0%, 100% { transform: translateX(0); } 30% { transform: translateX(0.7px); } 62% { transform: translateX(-0.6px); } }
@media (prefers-reduced-motion: no-preference) {
  html:not(.calm):not(.nojuice) .sig-dial.go .sig-needle { animation: sig-swing 0.8s cubic-bezier(0.25, 1.7, 0.5, 1) both; }
  html:not(.calm):not(.nojuice) .sig-needle b { animation: sig-tremble 2.4s ease-in-out infinite; }
}

/* ---------- power-on: black screen, a bright line opens to full screen, the mark flickers, then it clears ---------- */
.sig-boot {
  position: fixed; inset: 0; z-index: 9999; pointer-events: none; background: #04060a; color: #e9eef7;
  display: grid; place-items: center; overflow: hidden;
  animation: sig-boot-out 0.8s linear forwards;
}
.sig-boot.skip { animation: none; opacity: 0; transition: opacity 0.14s; }
.sig-boot i { position: absolute; left: 0; right: 0; top: 50%; height: 100%; margin-top: -50%; background: #f4fbff; transform-origin: 50% 50%; animation: sig-line 0.62s cubic-bezier(0.7, 0, 0.2, 1) forwards; }
.sig-boot b { position: relative; font: 700 clamp(34px, 11vw, 64px)/1 var(--font-display, sans-serif); letter-spacing: 0.34em; margin-right: -0.34em; color: #fff; mix-blend-mode: difference; opacity: 0; animation: sig-mark 0.62s steps(1) 0.12s forwards; }
@keyframes sig-line {
  0% { transform: scale(0.02, 0.004); opacity: 1; }
  34% { transform: scale(1, 0.004); }
  58% { transform: scale(1, 1); }
  100% { transform: scale(1, 1); opacity: 1; }
}
@keyframes sig-mark { 0% { opacity: 0; } 14% { opacity: 1; } 24% { opacity: 0.2; } 36% { opacity: 1; } 46% { opacity: 0.5; } 60%, 100% { opacity: 1; } }
@keyframes sig-boot-out { 0%, 58% { opacity: 1; } 100% { opacity: 0; } }
