/* ═══════════════════════════════════════════════
   CHRONOS-Ω · VISUAL DOCTRINE
   (it's a clock)
   ═══════════════════════════════════════════════ */
:root {
  --cyan: #00f0ff;
  --cyan-dim: rgba(0, 240, 255, .35);
  --mag: #ff2bd6;
  --amber: #ffb800;
  --lime: #7dff6a;
  --text: #bfefff;
  --bright: #eaffff;
  --muted: rgba(191, 239, 255, .5);
  --line: rgba(0, 240, 255, .22);
  --mono: 'Share Tech Mono', ui-monospace, Consolas, 'Malgun Gothic', monospace;
  --disp: 'Orbitron', 'Share Tech Mono', 'Malgun Gothic', sans-serif;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: radial-gradient(ellipse at center, #061426 0%, #02040a 70%);
  color: var(--text);
  font-family: var(--mono);
  cursor: crosshair;
  user-select: none;
}

noscript { position: fixed; inset: 0; z-index: 99; display: grid; place-items: center; font-size: 18px; }

#bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; }
#fx { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 6; pointer-events: none; }

/* ── layout ─────────────────────────────────── */
#hud {
  position: relative;
  z-index: 2;
  height: 100vh;
  display: grid;
  grid-template-columns: minmax(250px, 310px) minmax(0, 1fr) minmax(250px, 310px);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "top top top" "left core right" "bottom bottom bottom";
  gap: 14px;
  --pad-y: 14px;
  --pad-x: 18px;
  /* keep clear of the notch / status bar when launched from the iPhone home screen */
  padding: max(var(--pad-y), env(safe-area-inset-top)) max(var(--pad-x), env(safe-area-inset-right))
           max(var(--pad-y), env(safe-area-inset-bottom)) max(var(--pad-x), env(safe-area-inset-left));
  transition: opacity .6s ease;
}
body.booting #hud { opacity: 0; }
html:has(body.booting), body.booting { overflow: hidden; }
body.idle, body.idle * { cursor: none !important; }

.side { display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.left { grid-area: left; --from: -40px; }
.right { grid-area: right; --from: 40px; }

/* ── panels ─────────────────────────────────── */
.panel {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 10px 12px 12px;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(0, 44, 66, .5), rgba(2, 8, 18, .72));
  box-shadow: inset 0 0 28px rgba(0, 240, 255, .06), 0 0 18px rgba(0, 0, 0, .4);
  overflow: hidden;
}
.panel.grow { flex: 1 1 0; }

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(var(--cyan), var(--cyan)) left top / 14px 2px no-repeat,
    linear-gradient(var(--cyan), var(--cyan)) left top / 2px 14px no-repeat,
    linear-gradient(var(--cyan), var(--cyan)) right bottom / 14px 2px no-repeat,
    linear-gradient(var(--cyan), var(--cyan)) right bottom / 2px 14px no-repeat,
    linear-gradient(var(--mag), var(--mag)) right top / 6px 2px no-repeat,
    linear-gradient(var(--mag), var(--mag)) left bottom / 6px 2px no-repeat;
}
.panel::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 45%;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent, rgba(0, 240, 255, .06), transparent);
  animation: panelScan 7s linear infinite;
}
.side .panel:nth-child(2)::after { animation-delay: -2.3s; }
.side .panel:nth-child(3)::after { animation-delay: -4.1s; }
.side .panel:nth-child(4)::after { animation-delay: -5.6s; }

body:not(.booting) .panel { animation: panelIn .8s cubic-bezier(.2, .8, .2, 1) both; }
body:not(.booting) .side .panel:nth-child(2) { animation-delay: .12s; }
body:not(.booting) .side .panel:nth-child(3) { animation-delay: .24s; }
body:not(.booting) .side .panel:nth-child(4) { animation-delay: .36s; }

.panel h3 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px dashed var(--line);
  font: 600 10.5px/1 var(--disp);
  letter-spacing: .16em;
  color: var(--cyan);
  text-shadow: 0 0 8px var(--cyan-dim);
  white-space: nowrap;
}
.panel h3 span { overflow: hidden; text-overflow: ellipsis; }
.panel h3 span::before { content: "▮ "; color: var(--mag); animation: blink 1.2s infinite; }
.panel h3 em { flex: none; font: normal 10px var(--mono); color: var(--mag); letter-spacing: .1em; }

/* ── top bar ────────────────────────────────── */
.topbar {
  grid-area: top;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(0, 240, 255, .09), rgba(255, 43, 214, .05) 50%, rgba(0, 240, 255, .09));
  overflow: hidden;
}
.topbar::after {
  content: "";
  position: absolute;
  left: 0; bottom: 0;
  width: 30%; height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  animation: sweep 4s linear infinite;
}

.brand { display: flex; align-items: center; gap: 16px; }
.logo {
  position: relative;
  width: 40px; height: 40px;
  display: grid;
  place-items: center;
  font: 900 22px var(--disp);
  color: var(--cyan);
  border: 2px solid var(--cyan);
  border-radius: 50%;
  box-shadow: 0 0 14px var(--cyan), inset 0 0 12px var(--cyan-dim);
  text-shadow: 0 0 10px var(--cyan);
}
.logo::before {
  content: "";
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  border: 1px dashed var(--mag);
  animation: spin 8s linear infinite;
}
.logo::after {
  content: "";
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--cyan);
  animation: spin 2.4s linear infinite reverse;
}
.brand-name { font: 900 20px var(--disp); letter-spacing: .22em; color: var(--bright); text-shadow: 0 0 12px var(--cyan); }
.brand-name span { color: var(--mag); text-shadow: 0 0 12px var(--mag); }
.brand-sub { margin-top: 2px; font-size: 10px; letter-spacing: .32em; color: var(--muted); }

.status { display: flex; flex-wrap: wrap; gap: 10px; }
.pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  font-size: 11px;
  letter-spacing: .12em;
  color: var(--muted);
  white-space: nowrap;
}
.pill b { font-weight: normal; color: var(--bright); }
.pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); animation: blink 1.2s infinite; }
.pill.ok i { background: var(--lime); box-shadow: 0 0 8px var(--lime); }
.pill.hot i { background: var(--amber); box-shadow: 0 0 8px var(--amber); animation-duration: .7s; }

.date { text-align: right; font: 600 15px var(--disp); letter-spacing: .06em; color: var(--bright); white-space: nowrap; }
.date-sub { margin-top: 3px; font: 11px var(--mono); letter-spacing: .2em; color: var(--mag); }

/* ── telemetry ──────────────────────────────── */
.telemetry { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 5px 10px; font-size: 12px; }
.telemetry dt { color: var(--muted); letter-spacing: .06em; white-space: nowrap; }
.telemetry dd { text-align: right; color: var(--bright); white-space: nowrap; font-variant-numeric: tabular-nums; text-shadow: 0 0 6px rgba(0, 240, 255, .55); }
.bar { grid-column: 1 / -1; position: relative; height: 5px; margin: -1px 0 3px; border: 1px solid var(--line); background: rgba(0, 240, 255, .08); overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, var(--cyan), var(--mag)); box-shadow: 0 0 10px var(--cyan); }
.bar i::after { content: ""; position: absolute; right: 0; top: -2px; bottom: -2px; width: 2px; background: #fff; box-shadow: 0 0 8px #fff; }

/* ── binary matrix ──────────────────────────── */
.binary { flex: 1; display: grid; grid-template-columns: repeat(6, 1fr); align-content: center; justify-items: center; gap: 4px; padding: 4px 0; }
.binary .col { display: flex; flex-direction: column; align-items: center; gap: 6px; --c: var(--cyan); }
.binary .col:nth-child(-n+2) { --c: var(--amber); }
.binary .col:nth-child(3), .binary .col:nth-child(4) { --c: var(--mag); }
.binary .col b { margin-top: 2px; font: 600 10px var(--disp); color: var(--muted); }
.bit { width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--line); background: rgba(0, 240, 255, .05); transition: background .25s, box-shadow .25s; }
.bit.on { border-color: transparent; background: var(--c); box-shadow: 0 0 10px var(--c), 0 0 22px var(--c); }
.bin-hex { margin-top: 6px; text-align: center; font-size: 11px; letter-spacing: .1em; color: var(--muted); }

/* ── time zones ─────────────────────────────── */
.zones { list-style: none; display: flex; flex-direction: column; font-size: 12px; }
.zones li { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid rgba(0, 240, 255, .08); }
.zones li:last-child { border-bottom: 0; }
.zones .code { font-size: 10px; letter-spacing: .1em; color: var(--mag); }
.zones .n { color: var(--muted); }
.zones .t { font-size: 14px; letter-spacing: .06em; color: var(--bright); text-shadow: 0 0 8px rgba(0, 240, 255, .5); }
.zones li.mars .code, .zones li.mars .t { color: #ff7a4d; text-shadow: 0 0 8px rgba(255, 122, 77, .6); }

/* ── core ───────────────────────────────────── */
.core { grid-area: core; position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; will-change: transform; }
#rings { position: absolute; inset: 0; width: 100%; height: 100%; }
.readout { position: relative; text-align: center; pointer-events: none; animation: holo 6s infinite; }
.readout-label {
  margin-bottom: calc(var(--r, 300px) * .02);
  font: 600 max(9px, calc(var(--r, 300px) * .026)) var(--disp);
  letter-spacing: .32em;
  color: var(--muted);
}
.time {
  font: 900 calc(var(--r, 300px) * .18) / 1 var(--disp);
  color: var(--bright);
  white-space: nowrap;
  text-shadow: 0 0 10px var(--cyan), 0 0 28px var(--cyan), 0 0 70px rgba(0, 240, 255, .55);
}
.time .d { display: inline-block; width: .84em; text-align: center; }
.time .c { display: inline-block; width: .34em; text-align: center; transform: translateY(-.06em); transition: opacity .15s; }
.time.glitch { animation: glitch .45s steps(1) both; }
.readout-ms {
  margin-top: calc(var(--r, 300px) * .03);
  font-size: max(12px, calc(var(--r, 300px) * .045));
  letter-spacing: .18em;
  color: var(--mag);
  text-shadow: 0 0 10px var(--mag);
}
.readout-ms small { margin-left: 3px; font-size: .6em; opacity: .7; }
.readout-sub { margin-top: calc(var(--r, 300px) * .025); font-size: max(8px, calc(var(--r, 300px) * .022)); letter-spacing: .26em; color: var(--muted); }

/* ── visualizers & log ──────────────────────── */
.viz { display: block; width: 100%; flex: 1 1 0; min-height: 40px; }
.log { list-style: none; flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; font-size: 11px; line-height: 1.5; }
.log li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; animation: logIn .35s ease-out; }
.log li:last-child { color: var(--bright); }
.log .ts { color: var(--muted); }
.log .tag { margin: 0 6px; }
.tag.ok { color: var(--lime); }
.tag.warn { color: var(--amber); }
.tag.info { color: var(--cyan); }
.tag.sync { color: var(--mag); }

/* ── bottom bar ─────────────────────────────── */
.bottombar { grid-area: bottom; display: flex; align-items: center; gap: 16px; min-width: 0; padding: 6px 12px; border: 1px solid var(--line); background: rgba(0, 20, 32, .55); font-size: 12px; }
.ticker {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
}
.ticker-track { display: inline-block; color: var(--cyan); animation: marquee 80s linear infinite; }
.ticker-track b { margin: 0 22px; font-weight: normal; color: var(--mag); }
.hint { font-size: 10px; letter-spacing: .2em; color: var(--muted); white-space: nowrap; }
.disclaimer { color: var(--amber); white-space: nowrap; text-shadow: 0 0 8px rgba(255, 184, 0, .55); }
.sfx { padding: 5px 10px; border: 1px solid var(--line); background: rgba(0, 240, 255, .06); font: 11px var(--mono); letter-spacing: .2em; color: var(--cyan); cursor: pointer; transition: all .2s; }
.sfx:hover { background: rgba(0, 240, 255, .15); }
.sfx.on { color: var(--lime); border-color: var(--lime); box-shadow: 0 0 12px rgba(125, 255, 106, .35); }

/* ── overlays ───────────────────────────────── */
.overlay { position: fixed; inset: 0; pointer-events: none; }
.scanlines { z-index: 7; background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, .16) 0 1px, transparent 1px 3px); animation: flicker 5s infinite; }
.scanlines::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 140px;
  background: linear-gradient(to bottom, transparent, rgba(0, 240, 255, .045), transparent);
  animation: crt 8s linear infinite;
}
.vignette { z-index: 7; background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, .7) 100%); }

.alert {
  position: fixed;
  left: 50%; top: 16%;
  z-index: 9;
  padding: 12px 44px;
  opacity: 0;
  transform: translate(-50%, -50%);
  pointer-events: none;
  text-align: center;
  white-space: nowrap;
  font: 900 clamp(15px, 2.2vw, 32px) var(--disp);
  letter-spacing: .28em;
  color: #fff;
  border-top: 2px solid var(--mag);
  border-bottom: 2px solid var(--mag);
  background: linear-gradient(90deg, transparent, rgba(255, 43, 214, .28), transparent);
  text-shadow: 0 0 12px var(--mag), 0 0 30px var(--mag);
}
.alert small { display: block; margin-top: 6px; font: 13px var(--mono); letter-spacing: .25em; color: var(--cyan); text-shadow: 0 0 8px var(--cyan); }
.alert.show { animation: alertIn 3.4s cubic-bezier(.2, .8, .2, 1) forwards; }
.flash { position: fixed; inset: 0; z-index: 8; pointer-events: none; animation: flash .9s ease-out forwards; }

/* ── boot sequence ──────────────────────────── */
.boot {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  padding: 6vh 8vw;
  background: radial-gradient(ellipse at center, #03101c, #000 75%);
  cursor: pointer;
}
.boot-log { max-width: 820px; font-size: 14px; line-height: 1.7; color: var(--cyan); text-shadow: 0 0 6px rgba(0, 240, 255, .6); }
.bl { display: flex; align-items: baseline; gap: 10px; }
.bl i { flex: 1; border-bottom: 1px dotted rgba(0, 240, 255, .35); transform: translateY(-4px); }
.bl b { font-weight: normal; white-space: nowrap; }
.bl b.ok { color: var(--lime); }
.bl b.skip { color: var(--amber); }
.bl.big { margin-top: 14px; font: 600 clamp(16px, 2vw, 24px) var(--disp); color: #fff; text-shadow: 0 0 12px var(--mag), 0 0 28px var(--mag); }
.bl.big span::after { content: "█"; margin-left: 4px; color: var(--mag); animation: blink 1s infinite; }
.boot-bar { position: relative; max-width: 820px; height: 4px; background: rgba(0, 240, 255, .1); overflow: hidden; }
.boot-bar i { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, var(--cyan), var(--mag)); box-shadow: 0 0 12px var(--cyan); transition: width .15s; }
.boot-hint { font-size: 10px; letter-spacing: .4em; color: var(--muted); animation: blink 1.4s infinite; }
.boot.out { pointer-events: none; animation: crtOff .8s cubic-bezier(.7, 0, .3, 1) forwards; }

/* ── keyframes ──────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: .15; } }
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@keyframes panelScan { from { transform: translateY(-100%); } to { transform: translateY(330%); } }
@keyframes crt { from { transform: translateY(-140px); } to { transform: translateY(100vh); } }
@keyframes flicker { 0%, 100% { opacity: 1; } 47% { opacity: .85; } 48% { opacity: 1; } 76% { opacity: .9; } }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }
@keyframes holo { 0%, 90%, 100% { opacity: 1; } 91% { opacity: .55; } 92% { opacity: 1; } 95% { opacity: .75; } 96% { opacity: 1; } }
@keyframes logIn { from { opacity: 0; transform: translateX(-10px); background: rgba(0, 240, 255, .2); } to { opacity: 1; transform: none; background: transparent; } }
@keyframes panelIn {
  from { opacity: 0; transform: translateX(var(--from, -40px)) scale(.96); filter: blur(6px) brightness(2); }
  to { opacity: 1; transform: none; filter: none; }
}
@keyframes glitch {
  0% { text-shadow: -4px 0 var(--mag), 4px 0 var(--cyan); transform: translate(2px, -1px) skewX(-6deg); clip-path: inset(10% 0 55% 0); }
  20% { transform: translate(-3px, 2px); clip-path: inset(60% 0 5% 0); }
  40% { text-shadow: 5px 0 var(--mag), -5px 0 var(--amber); transform: translate(1px, 0) skewX(10deg); clip-path: inset(30% 0 30% 0); }
  60% { transform: translate(-1px, -2px); clip-path: inset(0 0 70% 0); }
  80% { text-shadow: -2px 0 var(--mag), 2px 0 var(--cyan); transform: none; clip-path: inset(45% 0 20% 0); }
  100% { transform: none; clip-path: none; }
}
@keyframes alertIn {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(1.6); filter: blur(10px); }
  8% { opacity: 1; transform: translate(-50%, -50%) scale(1); filter: blur(0); }
  11% { opacity: .35; }
  14% { opacity: 1; }
  85% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(.96); }
}
@keyframes crtOff {
  0% { transform: none; filter: none; opacity: 1; }
  40% { transform: scale(1, .004); filter: brightness(4); opacity: 1; }
  70% { transform: scale(0, .004); filter: brightness(6); opacity: 1; }
  100% { transform: scale(0, 0); opacity: 0; }
}

/* ── responsive ─────────────────────────────── */
/* short desktop screens (e.g. 1280×720 laptops): compact the side panels */
@media (min-width: 1101px) and (max-height: 860px) {
  #hud { gap: 10px; --pad-y: 10px; --pad-x: 14px; }
  .side { gap: 10px; }
  .topbar { padding: 5px 14px; }
  .logo { width: 34px; height: 34px; font-size: 18px; }
  .panel { padding: 8px 10px 9px; }
  .panel h3 { padding-bottom: 6px; margin-bottom: 6px; }
  .telemetry { gap: 2px 10px; font-size: 11px; }
  .zones li { padding: 2px 0; }
  .binary .col { gap: 4px; }
  .bit { width: 12px; height: 12px; }
}
@media (min-width: 1101px) and (max-height: 700px) {
  .telemetry .opt, .bin-hex { display: none; }
}
@media (max-width: 1100px) {
  html, body { height: auto; overflow-x: hidden; overflow-y: auto; }
  #hud {
    height: auto;
    min-height: 100vh;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto;
    grid-template-areas: "top top" "core core" "left right" "bottom bottom";
  }
  .core { height: min(92vw, 640px); }
  .panel, .panel.grow { flex: 0 0 auto; }
  .viz { flex: none; height: 150px; }
  .log { flex: none; height: 170px; }
  .binary { min-height: 110px; }
  .topbar { flex-wrap: wrap; }
  .status { order: 3; width: 100%; }
}
@media (max-width: 680px) {
  #hud { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "core" "left" "right" "bottom"; gap: 10px; --pad-y: 10px; --pad-x: 10px; }
  .status, .hint, .brand-sub { display: none; }
  .bottombar { flex-wrap: wrap; }
  .disclaimer { white-space: normal; }
  .readout-sub { display: none; }
  .readout-label { font-size: 8px; letter-spacing: .12em; }
  .alert { width: 92vw; padding: 10px 14px; white-space: normal; letter-spacing: .12em; }
}
@media (prefers-reduced-motion: reduce) {
  .panel::after, .scanlines, .scanlines::after, .readout { animation: none; }
  .ticker-track { animation-duration: 240s; }
}
