/* Tokens shared with AetherLake Log (PhosphorConsole.jsx) so all four sites share one look.
   Three colour schemes, picked with data-theme on <html>:
     cga    (1, default) 4-colour CGA, palette 1 high intensity: cyan, magenta, yellow on black
     green  (2) P1 green phosphor with its complement, magenta-pink, as the accent
     amber  (3) amber phosphor with pink accents, the original look */
:root, [data-theme="cga"] {
  --c1: 85, 255, 255;      /* main text, lines, dots */
  --c2: 255, 85, 255;      /* accent: LAKE, live dot, focus */
  --c3: 255, 255, 85;      /* highlight: sparkles, moon */
  --bg: #000000;
}
[data-theme="green"] {
  --c1: 51, 255, 102;
  --c2: 255, 79, 216;
  --c3: 210, 255, 215;
  --bg: #020a04;
}
[data-theme="amber"] {
  --c1: 255, 176, 0;
  --c2: 255, 92, 138;
  --c3: 255, 215, 130;
  --bg: #0b0805;
}
:root {
  --main: rgb(var(--c1));
  --pink: rgb(var(--c2));
  --a10: rgba(var(--c1), 0.1);
  --a25: rgba(var(--c1), 0.25);
  --a40: rgba(var(--c1), 0.4);
  --a50: rgba(var(--c1), 0.5);
  --a60: rgba(var(--c1), 0.6);
  --glow: 0 0 8px rgba(var(--c1), 0.28);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); }
body {
  font-family: var(--mono);
  color: var(--main);
  text-shadow: var(--glow);
  -webkit-font-smoothing: antialiased;
  animation: crt-flicker 7s linear infinite;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 200ms ease-out, color 200ms ease-out;
}

.lake { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; opacity: 0.55; }

.shell {
  position: relative; z-index: 1;
  min-height: 100dvh;
  display: flex; flex-direction: column;
  padding: max(12px, env(safe-area-inset-top)) clamp(16px, 4vw, 48px) max(16px, env(safe-area-inset-bottom));
  max-width: 1200px; margin: 0 auto;
}

.top {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  border-bottom: 1px solid var(--a25); padding: 12px 0;
}
.brand { margin: 0; font-weight: 700; letter-spacing: 0.3em; font-size: 14px; display: flex; align-items: center; gap: 12px; white-space: nowrap; }
@media (max-width: 1100px) { .themes .name { display: none; } }
@media (max-width: 420px) { .brand { letter-spacing: 0.15em; font-size: 12px; } }
.right { display: flex; align-items: center; gap: 16px; }
.status { margin: 0; font-size: 10px; color: var(--a60); white-space: nowrap; }
.dot { display: inline-block; width: 6px; height: 6px; background: var(--pink); box-shadow: 0 0 6px var(--pink); animation: blink 1.6s steps(2) infinite; vertical-align: 1px; }

/* Logos are amber PNGs used as masks, so they take the theme's colour. */
.mark {
  display: inline-block; flex: none;
  background: var(--main);
  -webkit-mask: var(--src) center / contain no-repeat;
          mask: var(--src) center / contain no-repeat;
}
[data-theme="cga"] .mark { background: linear-gradient(135deg, rgb(var(--c1)), rgb(var(--c2)) 60%, rgb(var(--c3))); }
/* Glow lives on a wrapper: a filter on the masked element itself would be clipped by the mask. */
.glowbox { display: inline-flex; filter: drop-shadow(0 0 6px rgba(var(--c1), 0.4)); }
.glowbox .mark, .ch .logo .mark { width: 100%; height: 100%; display: block; }
.brand .glowbox { height: 30px; width: 38px; }

/* Theme switcher */
.themes { display: flex; gap: 6px; }
.themes button {
  font: inherit; font-size: 10px; letter-spacing: 0.15em; cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  min-height: 28px; padding: 0 8px;
  color: var(--a60); background: transparent; border: 1px solid var(--a25);
  transition: border-color 160ms ease-out, color 160ms ease-out;
}
.themes button[aria-pressed="true"] { color: var(--main); border-color: var(--pink); }
.themes .sw { display: inline-flex; gap: 2px; }
.themes .sw i { width: 6px; height: 6px; display: block; }
@media (hover: hover) and (pointer: fine) { .themes button:hover { color: var(--main); border-color: var(--a60); } }
.themes button:focus-visible { outline: 2px solid var(--pink); outline-offset: 2px; }

main { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 6vh 0 4vh; }

.hero { text-align: center; }
.label { margin: 0 0 12px; font-size: 10px; letter-spacing: 0.3em; color: var(--a50); }
.hero h1 {
  margin: 0; font-size: clamp(44px, 11vw, 132px); line-height: 0.9; letter-spacing: 0.06em; font-weight: 700;
  text-shadow: 0 0 18px rgba(var(--c1), 0.45);
}
.pink { color: var(--pink); text-shadow: 0 0 18px rgba(var(--c2), 0.5); }
.lede { margin: 16px auto 0; font-size: 13px; color: var(--a60); max-width: 46ch; }

.channels {
  margin-top: 6vh;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px;
}
.ch {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px;
  min-height: 230px; padding: 18px; text-align: center; overflow: hidden;
  color: var(--main); text-decoration: none;
  border: 1px solid var(--a40);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  box-shadow: inset 0 0 40px rgba(var(--c1), 0.06);
  backdrop-filter: blur(2px);
  transition: background-color 160ms ease-out, border-color 160ms ease-out, transform 160ms ease-out;
}
.ch:focus-visible { outline: 2px solid var(--pink); outline-offset: 3px; }
.ch .num { align-self: stretch; font-size: 10px; color: var(--a50); display: flex; justify-content: space-between; }
.ch .num .tag { letter-spacing: 0.2em; }
.ch .art { position: relative; width: 100%; height: 64px; display: flex; align-items: center; justify-content: center; margin: 6px 0 2px; }
.ch .art canvas { position: absolute; left: 0; top: -12px; width: 100%; height: calc(100% + 24px); pointer-events: none; }
.ch .logo {
  position: relative; height: 34px; width: var(--w, 80px);
  animation: logo-float 4.8s ease-in-out infinite, logo-glow 3.2s ease-in-out infinite, logo-glitch 9s steps(1) infinite;
  animation-delay: var(--d, 0s), var(--d, 0s), var(--d, 0s);
}
.ch h2 { margin: auto 0 0; font-size: 18px; letter-spacing: 0.12em; font-weight: 700; }
.ch p { margin: 0; font-size: 11px; line-height: 1.55; color: var(--a60); max-width: 30ch; }
.ch .go {
  margin-top: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.2em;
  border: 1px solid var(--main); padding: 7px 12px;
  transition: background-color 160ms ease-out, color 160ms ease-out;
}

@media (hover: hover) and (pointer: fine) {
  .ch:hover { border-color: var(--main); background: rgba(var(--c1), 0.08); }
  .ch:hover .go { background: var(--main); color: var(--bg); text-shadow: none; }
}
.ch:active { transform: scale(0.985); }

.hint { margin: 18px 0 0; font-size: 10px; color: var(--a40); text-align: center; }
kbd { font-family: inherit; border: 1px solid var(--a40); padding: 0 5px; color: var(--main); }

.foot { border-top: 1px solid var(--a25); padding-top: 12px; font-size: 10px; color: rgba(var(--c1), 0.3); text-align: center; }
.foot a { color: rgba(var(--c1), 0.55); text-decoration: none; }
.foot a:hover { color: var(--main); }

/* CRT overlay: same values as Log's CrtOverlay */
.crt { pointer-events: none; position: fixed; inset: 0; z-index: 65; }
.scan { position: absolute; inset: 0; background: repeating-linear-gradient(0deg, rgba(0,0,0,0.22) 0px, rgba(0,0,0,0.22) 1px, transparent 1px, transparent 3px); }
.vignette { position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.5) 100%); }

/* Boot sequence: same lines style as Log's BootSequence */
.boot {
  position: fixed; inset: 0; z-index: 80; background: var(--bg);
  display: flex; flex-direction: column; justify-content: center;
  padding: 0 clamp(24px, 8vw, 64px); font-size: 12px; line-height: 1.7;
  text-shadow: 0 0 8px rgba(var(--c1), 0.35);
  transition: opacity 300ms ease-out;
}
.boot pre { margin: 0; white-space: pre-wrap; font: inherit; }
.boot.done { opacity: 0; pointer-events: none; }
.cursor { margin-top: 8px; animation: blink 1s steps(2) infinite; }

@keyframes crt-flicker { 0%, 91%, 94%, 100% { opacity: 1; } 92.5% { opacity: 0.93; } }
@keyframes blink { to { visibility: hidden; } }
@keyframes logo-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes logo-glow {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(var(--c1), 0.3)); }
  50% { filter: drop-shadow(0 0 12px rgba(var(--c1), 0.7)); }
}
/* A brief signal glitch every few seconds: a sideways jolt and a dip. */
@keyframes logo-glitch {
  0%, 93%, 100% { opacity: 1; translate: 0 0; }
  94% { opacity: 0.4; translate: 3px 0; }
  95% { opacity: 1; translate: -2px 0; }
  96% { opacity: 0.7; translate: 0 0; }
}

@media (max-width: 760px) {
  .channels { grid-template-columns: 1fr; }
  .ch { min-height: 0; }
  .ch h2 { margin-top: 8px; }
  .status { display: none; }
  .hint { display: none; }
  .themes .name { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  body, .dot, .cursor, .ch .logo { animation: none; }
  .ch, .ch .go, .boot, body { transition: none; }
}
