/* Palette, glass and decay, carried verbatim from Keraunos. Nothing
   page-specific belongs here.

   Type is self-hosted; `fonts/` travels with this stylesheet. Latin and
   latin-ext only: Plex Mono ships no Greek. */
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/ibm-plex-mono-400-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/ibm-plex-mono-400-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/ibm-plex-mono-500-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/ibm-plex-mono-500-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/ibm-plex-mono-600-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/ibm-plex-mono-600-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* White is reserved: nothing reaches it but the record currently tuned in. */
:root,
:root[data-theme='dark'] {
  color-scheme: dark;

  --c-void: #0a0a0b;
  --c-panel: #0f0f11;
  --c-line: #26262b;
  --c-land: #4c4c55;
  --c-dim: #7b7b81;
  --c-text: #c8c8cc;
  --c-strike: #ffffff;

  --ink-hot: #ffffff;
  --ink-rest: #c8c8cc;
  --scan: rgba(255, 255, 255, 0.05);
  --sweep: rgba(255, 255, 255, 0.028);
  --vignette: rgba(0, 0, 0, 0.62);
  --bloom: rgba(255, 255, 255, 0.14);
  --bloom-hot: rgba(255, 255, 255, 0.3);
  /* Tuned by eye on a real display; turn down if the glass looks dirty rather
     than uneven. Its own token because a broad field needs more alpha than a
     narrow band to read at all. */
  --drift: rgba(255, 255, 255, 0.024);
}

/* Ink on a chart recorder's roll, not an inverted tube. Black takes over the
   reserved role; cool neutral stock, never cream. */
:root[data-theme='light'] {
  color-scheme: light;

  --c-void: #dedee0;
  --c-panel: #e7e7e9;
  --c-line: #c2c2c6;
  --c-land: #9a9aa2;
  --c-dim: #626268;
  --c-text: #2a2a2e;
  --c-strike: #000000;

  --ink-hot: #000000;
  --ink-rest: #2a2a2e;
  --scan: rgba(0, 0, 0, 0.045);
  --sweep: rgba(0, 0, 0, 0.022);
  --vignette: rgba(0, 0, 0, 0.14);
  --bloom: rgba(0, 0, 0, 0.16);
  --bloom-hot: rgba(0, 0, 0, 0.28);
  /* Less than the tube's: paper shows a shadow sooner than a tube shows a bloom. */
  --drift: rgba(0, 0, 0, 0.018);
}

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

html,
body {
  height: 100%;
}

body {
  background: var(--c-void);
  color: var(--c-text);
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, monospace;
  font-size: 12px;
  line-height: 18px;
  /* Digits must not jitter as readouts tick. */
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

:focus-visible {
  outline: 1px solid var(--c-text);
  outline-offset: 2px;
}

/* Reserved for live values, never labels. */
.glow {
  text-shadow: 0 0 6px var(--bloom);
}

.glow-hot {
  text-shadow: 0 0 10px var(--bloom-hot);
}

/* Arrivals come in at full white and settle into the interface gray. */
@keyframes settle {
  from {
    color: var(--ink-hot);
    text-shadow: 0 0 10px var(--bloom-hot);
  }
  to {
    color: var(--ink-rest);
    text-shadow: 0 0 6px var(--bloom);
  }
}

@keyframes breathe {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

@keyframes seek {
  0%,
  100% {
    opacity: 0.25;
  }
  50% {
    opacity: 1;
  }
}

.settle {
  animation: settle 1.4s ease-out;
}

.breathe {
  animation: breathe 2.8s ease-in-out infinite;
}

.seek {
  animation: seek 1.6s ease-in-out infinite;
}

/* Above everything, catches no pointer events. The only place the treatment
   lives; the page underneath stays clean. */
.crt {
  position: fixed;
  inset: 0;
  z-index: 50;
  overflow: hidden;
  pointer-events: none;
}

.crt-scanlines {
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    to bottom,
    var(--scan) 0px,
    var(--scan) 1px,
    transparent 1px,
    transparent 3px
  );
}

.crt-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(125% 105% at 50% 50%, transparent 52%, var(--vignette) 100%);
}

@keyframes refresh-sweep {
  from {
    transform: translateY(-14vh);
  }
  to {
    transform: translateY(104vh);
  }
}

.crt-sweep {
  position: absolute;
  inset-inline: 0;
  top: 0;
  height: 14vh;
  background: linear-gradient(to bottom, transparent, var(--sweep), transparent);
  animation: refresh-sweep 7.5s linear infinite;
  /* Runs forever over the whole viewport; keep it off the repaint path. */
  will-change: transform;
}

/* Two soft blooms on periods that do not divide into each other, so brightness
   never quite repeats. Transform only: these are full-viewport layers, and
   animating anything that repaints hands the compositor the whole page. */
.crt-drift {
  position: absolute;
  inset: 0;
}

.crt-drift::before,
.crt-drift::after {
  content: '';
  position: absolute;
  /* Wider and the per-pixel gradient drops under what a display can show. */
  width: 75vmax;
  height: 75vmax;
  background: radial-gradient(closest-side, var(--drift), transparent);
  animation: drift-a 37s ease-in-out infinite alternate;
}

/* Off the corners, where the vignette is heaviest. */
.crt-drift::before {
  top: -22vmax;
  left: -18vmax;
}

.crt-drift::after {
  bottom: -22vmax;
  right: -18vmax;
  animation-name: drift-b;
  animation-duration: 53s;
}

/* The three pieces a reader can take off. Drift is the faintest and the most
   expensive to composite, so it goes first on a struggling machine. */
:root[data-scanlines='off'] .crt-scanlines,
:root[data-sweep='off'] .crt-sweep,
:root[data-drift='off'] .crt-drift {
  display: none;
}

/* Crossing vectors, not one reversed: parallel blooms read as one layer
   sliding. */
@keyframes drift-a {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(26vmax, 16vmax, 0);
  }
}

@keyframes drift-b {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(-21vmax, 13vmax, 0);
  }
}

.tick {
  position: absolute;
  width: 9px;
  height: 9px;
  border-color: var(--c-land);
  border-style: solid;
  border-width: 0;
  pointer-events: none;
}

.tick.tl {
  top: 0;
  left: 0;
  border-top-width: 1px;
  border-left-width: 1px;
}

.tick.tr {
  top: 0;
  right: 0;
  border-top-width: 1px;
  border-right-width: 1px;
}

.tick.bl {
  bottom: 0;
  left: 0;
  border-bottom-width: 1px;
  border-left-width: 1px;
}

.tick.br {
  bottom: 0;
  right: 0;
  border-bottom-width: 1px;
  border-right-width: 1px;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: var(--c-line);
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--c-land);
}

@media (prefers-reduced-motion: reduce) {
  .settle,
  .breathe,
  .seek,
  .crt-sweep,
  .crt-drift::before,
  .crt-drift::after {
    animation: none;
  }
}
