@font-face {
  font-family: "Departure Mono";
  src: url("../assets/fonts/DepartureMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  /* genesis tokens, settled */
  --fg: #e8ebf0;
  --dim: #9399a4;
  --faint: #5b626e;
  --accent: #7ea8f8;
  --red: #ed707c;
  --panel: #0d0f13;
  --border: rgba(194, 202, 216, 0.13);
  --mono: "Departure Mono", "SFMono-Regular", ui-monospace, Consolas, monospace;
  --display: "Inter Tight", "Helvetica Neue", system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;                 /* the whole point: no scroll */
  overflow: clip;                   /* hidden still scrolls programmatically; clip never does */
  background: #05070b;
  color: var(--fg);
  font-family: var(--mono);
  overscroll-behavior: none;
  touch-action: none;               /* the page owns every gesture — nothing here scrolls */
}
#bg { touch-action: none; }         /* touches land on the bg canvas (everything above ignores events) */

/* render layers — the occlusion sandwich */
#bg, #gl, #css3d-back, #css3d-front, #fluff, #readouts, #grain {
  position: fixed;
  inset: 0;
}
#bg          { z-index: 0; }
#css3d-back  { z-index: 1; pointer-events: none; }
#gl          { z-index: 2; pointer-events: none; }
#css3d-front { z-index: 3; pointer-events: none; }
#css3d-back .portal, #css3d-front .portal { pointer-events: auto; }
/* text and instruments sit ABOVE the grain: animated noise over glyphs
   reads as text flicker, especially on mobile — the film treatment belongs
   on the scene (bg, scan, portals), not the type */
#fluff    { z-index: 8; pointer-events: none; width: 100%; height: 100%; }
#readouts { z-index: 8; pointer-events: none; }
#overlay  { z-index: 9; }
/* film grain: one plain source-over alpha canvas, painted by main.js.
   NEVER mix-blend-mode — full-screen blend surfaces make Android's
   compositor glitch (vanishing text layers, flashing dark quads). The
   filmic response lives in the tiles' alpha channel; this opacity is the
   overall strength knob. */
#grain {
  z-index: 7;
  pointer-events: none;
  opacity: 0.55;
}

/* ---- identity ---- */
#overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  padding: clamp(16px, 3vw, 40px) clamp(16px, 4vw, 56px);
}
#overlay h1 {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.8rem, 4vw, 3.2rem);
  letter-spacing: -0.01em;
  color: #f0f2f5;
}
#overlay h1 .dud { font-family: var(--mono); }
#tagline {
  margin-top: 0.4em;
  color: var(--faint);
  font-size: clamp(0.58rem, 1.1vw, 0.7rem);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.dud { color: var(--faint); opacity: 0.7; }

/* ---- instrument layer ---- */
#fluff .f-line  { stroke: rgba(194, 202, 216, 0.28); stroke-width: 1; fill: none; }
#fluff .f-dash  { stroke: rgba(194, 202, 216, 0.22); stroke-width: 1; stroke-dasharray: 5 5; }
#fluff .f-red   { stroke: var(--red); stroke-width: 1.4; }
#fluff .f-ring circle { stroke: rgba(194, 202, 216, 0.14); }
#fluff text {
  font-family: var(--mono);
  font-size: 9px;
  fill: var(--faint);
  letter-spacing: 0.12em;
}
#fluff .f-track text { fill: var(--dim); font-size: 9px; }

#readouts .ro {
  position: absolute;
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--dim);
  text-transform: uppercase;
  line-height: 1.9;
}
#readouts .ro s { text-decoration: none; color: var(--faint); margin-right: 0.6em; }
#readouts .ro b { font-weight: 400; color: var(--fg); }
#readouts .tl { top: 158px; left: clamp(16px, 4vw, 56px); }
#readouts .tr { top: clamp(16px, 3vw, 40px); right: clamp(16px, 4vw, 56px); text-align: right; }
#readouts .bl { bottom: clamp(16px, 3vw, 40px); left: clamp(16px, 4vw, 56px); }
#readouts .br { bottom: clamp(16px, 3vw, 40px); right: clamp(16px, 4vw, 56px); text-align: right; }
#readouts .bb {
  bottom: clamp(16px, 3vw, 40px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 2px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}
#readouts .bb .seg {
  padding: 2px 14px;
  color: var(--faint);
  border-right: 1px solid var(--border);
  transition: color 0.4s, background 0.4s;
}
#readouts .bb .seg:last-child { border-right: 0; }
#readouts .bb .seg.on {
  color: var(--fg);
  background: rgba(231, 235, 242, 0.06);
}
#readouts a { color: var(--dim); text-decoration: none; pointer-events: auto; }
#readouts a:hover { color: var(--accent); }
#readouts .chip {
  display: inline-block;
  border: 1px solid var(--border);
  padding: 1px 7px;
  margin-right: 6px;
  color: var(--dim);
}
#readouts .chip.dim { opacity: 0.4; }
#ro-trk i {
  display: inline-block;
  width: 6px; height: 6px;
  background: var(--red);
  margin-right: 7px;
  animation: blink 1.6s steps(2) infinite;
}
#ro-trk { color: var(--red); }
#ro-trk.off { color: var(--faint); }
#ro-trk.off i { background: var(--faint); animation: none; }
@keyframes blink { 50% { opacity: 0.25; } }

/* ---- portals ---- */
.portal-curved {
  position: relative;
  width: 360px;
  height: 271px;
  pointer-events: none;
}
.portal-curved .portal { pointer-events: auto; }
.portal-shade {
  position: absolute;
  inset: 0;
  border-radius: 7px;
  pointer-events: none;
  background:
    linear-gradient(90deg,
      rgba(0, 0, 0, 0.50) 0%, transparent 22%,
      rgba(255, 255, 255, 0.030) 50%,
      transparent 78%, rgba(0, 0, 0, 0.50) 100%);
}

.portal {
  width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
  overflow: clip;
  transition: border-color 0.3s;
  backface-visibility: hidden;      /* calms WebKit's transformed-iframe repaint flicker */
  -webkit-backface-visibility: hidden;
}
.portal-curved:hover .portal { border-color: var(--accent); }

.portal-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border-bottom: 1px solid var(--border);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: lowercase;
  background: rgba(231, 235, 242, 0.035);
}
.portal-bar .led {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #46c997;
  flex-shrink: 0;
}
.portal-bar a, .portal-bar .host {
  color: var(--fg);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.portal-bar .ext { margin-left: auto; color: var(--dim); font-size: 0.6rem; }
/* live-site bars are one big link — led, url and arrow all forward */
a.portal-bar {
  text-decoration: none;
  cursor: pointer;
  transition: background 0.25s;
}
a.portal-bar:hover { background: rgba(231, 235, 242, 0.08); }
a.portal-bar:hover .host, a.portal-bar:hover .ext { color: var(--accent); }

.portal-body {
  width: 360px;
  height: 240px;
  /* clip, not hidden: an anchor click inside the iframe scroll-into-views
     its ancestors, and a hidden box still scrolls programmatically — the
     pane would jump. clip is unscrollable, full stop. */
  overflow: hidden;
  overflow: clip;
  position: relative;
  background: #0a0e14;
}
.portal-body iframe {
  width: 1080px;
  height: 720px;
  transform: scale(0.3334);
  transform-origin: 0 0;
  border: 0;
  display: block;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* ghost placeholder */
.portal.ghost .portal-body {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  color: var(--dim);
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  background:
    repeating-linear-gradient(0deg, transparent 0 3px, color-mix(in srgb, var(--accent) 5%, transparent) 3px 4px),
    radial-gradient(ellipse at 50% 120%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 65%),
    #0a0e14;
}
.portal.ghost .led { background: var(--faint); animation: blink 1.4s steps(2) infinite; }
.portal.ghost .scanbar {
  width: 55%;
  height: 1px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 60%, transparent), transparent);
  animation: ghost-scan 3.2s ease-in-out infinite;
}
@keyframes ghost-scan {
  0%, 100% { transform: translateY(-34px); opacity: 0.2; }
  50%      { transform: translateY(34px);  opacity: 1; }
}

/* the permanent billboard */
.portal.ad .portal-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
}
.portal.ad .led { background: var(--accent); }
.portal.ad .portal-body strong {
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--fg);
  letter-spacing: 0.06em;
}
.portal.ad .portal-body span {
  color: var(--dim);
  font-size: 0.66rem;
  letter-spacing: 0.16em;
}
.portal.ad .cta {
  margin-top: 6px;
  padding: 7px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: lowercase;
  transition: border-color 0.25s, background 0.25s;
}
.portal.ad .cta:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

@media (max-width: 720px) {
  #readouts .tl, #readouts .bb { display: none; }
}
