/* sus crew terminal. One machine, one glass, one face.
   Every colour, inset and rhythm here is measured off art/ref/terminal.jpg. */

@font-face {
  font-family: "Sligoil";
  src: url("../fonts/Sligoil-Micro.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Sligoil";
  src: url("../fonts/Sligoil-MicroBold.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  /* the glass, read off his picture */
  --ink: #3dff9e;
  --ink-hot: #c8ffdf;
  --ink-dim: #1f7e52;
  --glass-mid: #14261a;
  --glass-edge: #060f09;
  --amber: #ff8a2b;
  --page: #05100a;

  /* one spacing scale */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;

  /* type: one size for the whole terminal, fitted to the glass by js */
  --fs: 20px;
  --lh: 1.4;
  --pitch: calc(var(--fs) * var(--lh));

  /* the screen rect inside the shell picture, measured from its own pixels */
  --screen-l: 13.9%;
  --screen-t: 11.9%;
  --screen-w: 72.2%;
  --screen-h: 65.4%;

  --shell-ratio: 1.3333;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: "Sligoil", ui-monospace, "Courier New", monospace;
  font-synthesis: none;
  overflow: hidden;
}

body { -webkit-font-smoothing: antialiased; }

/* ---------------------------------------------------------------- the room */

.room { position: fixed; inset: 0; overflow: hidden; z-index: 0; background: #040806; }
.room__video {
  position: absolute; inset: -6%;
  width: 112%; height: 112%;
  object-fit: cover;
  filter: blur(12px) saturate(0.78) brightness(0.92);
  transform: translateZ(0);
}
.room__dim {
  position: absolute; inset: 0;
  background:
    radial-gradient(130% 100% at 50% 46%, rgba(8, 26, 16, 0.08) 0%, rgba(2, 8, 5, 0.52) 62%, rgba(0, 0, 0, 0.86) 100%);
}

/* --------------------------------------------------------------- the rig */

.rig {
  position: fixed;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  width: min(calc(100vw - var(--s6)), calc((100dvh - var(--s5)) * var(--shell-ratio) * 1.3));
  aspect-ratio: 1448 / 1086;
  max-width: 1760px;
}

.rig__shell {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  filter: drop-shadow(0 26px 46px rgba(0, 0, 0, 0.72));
  pointer-events: none;
  user-select: none;
}

/* the amber power lamp sits at 73.4% / 90.4% of the shell: its glow is laid on it */
.rig__lamp {
  position: absolute;
  left: 73.4%; top: 90.4%;
  width: 8.4%; aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 138, 43, 0.55) 0%, rgba(255, 138, 43, 0.12) 42%, rgba(255, 138, 43, 0) 70%);
  animation: lamp 5.4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes lamp { 0%, 100% { opacity: 0.72; } 50% { opacity: 1; } }

/* -------------------------------------------------------------- the glass */

.glass {
  position: absolute;
  left: var(--screen-l); top: var(--screen-t);
  width: var(--screen-w); height: var(--screen-h);
  border-radius: 4.2% / 5.6%;
  overflow: hidden;
  background:
    radial-gradient(118% 108% at 50% 44%, var(--glass-mid) 0%, #0d1c12 52%, var(--glass-edge) 100%);
  box-shadow:
    inset 0 0 calc(var(--fs) * 3) rgba(0, 0, 0, 0.9),
    0 0 calc(var(--fs) * 2.4) rgba(61, 255, 158, 0.16);
  isolation: isolate;
}

.crt {
  position: absolute;
  inset: calc(var(--fs) * 0.7) calc(var(--fs) * 1.25);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(61, 255, 158, 0.35) transparent;
  font-size: var(--fs);
  line-height: var(--lh);
  letter-spacing: 0.01em;
  text-shadow: 0 0 calc(var(--fs) * 0.42) rgba(61, 255, 158, 0.55);
  /* a line that runs past the bottom of the tube falls into the dark instead of
     being sliced in half; the last line of a file clears the fade by its padding */
  -webkit-mask-image: linear-gradient(to bottom, #000 0, #000 calc(100% - 1.7em), transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0, #000 calc(100% - 1.7em), transparent 100%);
}
/* once the tube has been scrolled, the line at the top edge fades the same way the
   one at the bottom does, so nothing is ever sliced in half */
.crt--scrolled {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 1.5em, #000 calc(100% - 1.7em), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 1.5em, #000 calc(100% - 1.7em), transparent 100%);
}
.crt::-webkit-scrollbar { width: 10px; }
.crt::-webkit-scrollbar-track { background: transparent; }
.crt::-webkit-scrollbar-thumb { background: rgba(61, 255, 158, 0.3); border-radius: 0; }
.crt::-webkit-scrollbar-button { display: none; }

/* the text column keeps 1 em from the glass on every side, 2 em at the sides */
.crt__inner {
  padding: 0 calc(var(--fs) * 0.5) calc(var(--fs) * 2.4) 0;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* ---------------------------------------------------------------- printing */

.head { margin: 0 0 calc(var(--pitch) * 0.5); text-align: center; }
.head__name, .head__sub, .head__round {
  margin: 0;
  font-size: 1em;
  font-weight: 400;
  line-height: var(--lh);
  letter-spacing: 0.02em;
}
.head__name { color: var(--ink-hot); }
.head__sub { color: var(--ink); }
.head__round { color: var(--ink); }

.state { margin: 0 0 calc(var(--pitch) * 0.45); }
.state__ident, .state__rule, .state__line { margin: 0; font-size: 1em; }
.state__rule { color: var(--ink-dim); letter-spacing: 0; overflow: hidden; white-space: nowrap; }
.state__line { color: var(--ink); overflow-wrap: anywhere; }
.state__line--hot { color: var(--ink-hot); }

.rule {
  border: 0;
  height: 2px;
  margin: calc(var(--pitch) * 0.35) 0 calc(var(--pitch) * 0.5);
  background: linear-gradient(90deg, rgba(61, 255, 158, 0.75), rgba(61, 255, 158, 0.25));
  box-shadow: 0 0 calc(var(--fs) * 0.5) rgba(61, 255, 158, 0.5);
}

/* the index: his picture selects a row by painting the whole column */
.menu { display: block; margin-bottom: calc(var(--pitch) * 0.6); }
.row {
  display: block;
  width: 100%;
  margin: 0;
  padding: calc(var(--fs) * 0.5) max(18px, calc(var(--fs) * 1.1));
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  letter-spacing: 0.01em;
  text-align: left;
  cursor: pointer;
  text-shadow: inherit;
}
.row__mark { display: inline-block; width: 1.5em; }
.row:hover { color: var(--ink-hot); }
.row:focus-visible { outline: 2px solid var(--ink-hot); outline-offset: -2px; }
.row[aria-current="true"] {
  background: var(--ink);
  color: #04170d;
  text-shadow: none;
  box-shadow: 0 0 calc(var(--fs) * 0.9) rgba(61, 255, 158, 0.45);
}

/* the file the terminal prints under the index */
.file { flex: 1 1 auto; margin-top: calc(var(--pitch) * 0.35); }
.ln, .file p, .file li { margin: 0; font-size: 1em; overflow-wrap: anywhere; }
.file .gap { height: calc(var(--pitch) * 0.7); }
.file .hot { color: var(--ink-hot); }
.file .dim { color: var(--ink-dim); }
.file .amber { color: var(--amber); text-shadow: 0 0 calc(var(--fs) * 0.42) rgba(255, 138, 43, 0.5); }
.file h2 {
  margin: 0 0 calc(var(--pitch) * 0.4);
  font-size: 1em;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink-hot);
}
.file ul { margin: 0; padding: 0; list-style: none; }
/* a numbered step hangs its number in the margin, so the sentence wraps straight */
.step { padding-left: 2.4em; }
.step__n { display: inline-block; width: 2.4em; margin-left: -2.4em; color: var(--ink-hot); }

/* a printed table: label column fixed, value column fluid, values on one line */
.tbl { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: calc(var(--fs) * 1.2); }
.tbl > span { min-width: 0; overflow-wrap: anywhere; }
.tbl > span:nth-child(even) { text-align: right; color: var(--ink-hot); white-space: nowrap; }

/* terminal keys: a pressed line of the same text, never a css card */
.key {
  display: inline-block;
  margin: 0 calc(var(--fs) * 0.6) 0 0;
  padding: calc(var(--fs) * 0.3) calc(var(--fs) * 0.8);
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  text-shadow: inherit;
  min-height: calc(var(--fs) * 2.2);
}
.key::before { content: "["; color: var(--ink-dim); margin-right: 0.35em; }
.key::after { content: "]"; color: var(--ink-dim); margin-left: 0.35em; }
.key:hover:not(:disabled) { color: #04170d; background: var(--ink); text-shadow: none; }
.key:hover:not(:disabled)::before, .key:hover:not(:disabled)::after { color: #04170d; }
.key:focus-visible { outline: 2px solid var(--ink-hot); outline-offset: -2px; }
.key:disabled { color: var(--ink-dim); cursor: not-allowed; }
.key:active:not(:disabled) { transform: translateY(1px); }

/* the four official marks sit on the generated key cap */
.marks { display: flex; flex-wrap: wrap; gap: calc(var(--fs) * 0.7); margin-top: calc(var(--pitch) * 0.4); }
.mark {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  width: calc(var(--fs) * 4.6); height: calc(var(--fs) * 2.9);
  border: 0;
  background: url("../img/key-v1.png") center / 100% 100% no-repeat;
  filter: drop-shadow(0 0 calc(var(--fs) * 0.5) rgba(61, 255, 158, 0.28));
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
  font: inherit;
  font-size: calc(var(--fs) * 0.82);
  text-shadow: none;
}
.mark img { width: calc(var(--fs) * 1.22); height: auto; display: block; }
.mark__word { font-size: calc(var(--fs) * 0.82); letter-spacing: 0.02em; color: var(--ink-hot); }
.mark[aria-disabled="true"] .mark__word { color: var(--ink-dim); }
.mark:hover { filter: drop-shadow(0 0 calc(var(--fs) * 0.9) rgba(61, 255, 158, 0.6)); }
.mark:focus-visible { outline: 2px solid var(--ink-hot); outline-offset: 2px; }
.mark[aria-disabled="true"] { opacity: 0.66; cursor: not-allowed; filter: none; }

/* the mint, printed in its own sunken line */
.mint {
  display: block;
  margin: calc(var(--pitch) * 0.3) 0 calc(var(--pitch) * 0.5);
  padding: calc(var(--fs) * 0.6) calc(var(--fs) * 0.9);
  background: rgba(0, 0, 0, 0.45);
  box-shadow: inset 0 0 0 1px rgba(61, 255, 158, 0.22);
  color: var(--ink-hot);
  overflow-wrap: anywhere;
  user-select: all;
}

.prompt { margin: calc(var(--pitch) * 0.8) 0 0; color: var(--ink-hot); }
.caret {
  display: inline-block;
  width: 0.62em; height: 1.02em;
  margin-left: 0.3em;
  background: var(--ink-hot);
  vertical-align: -0.16em;
  animation: caret 1.1s steps(1) infinite;
}
@keyframes caret { 0%, 55% { opacity: 1; } 56%, 100% { opacity: 0; } }

/* lines arrive the way a terminal prints them */
.print > * { animation: print 0.22s steps(2) both; }
@keyframes print { from { opacity: 0; } to { opacity: 1; } }

/* ------------------------------------------------------------ glass effects */

.glass__scan {
  position: absolute; inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.26) 0, rgba(0, 0, 0, 0.26) 1px,
    rgba(0, 0, 0, 0) 1px, rgba(0, 0, 0, 0) 4px);
  mix-blend-mode: multiply;
  z-index: 3;
}
.glass__bloom {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 4;
  background:
    radial-gradient(115% 105% at 50% 42%, rgba(61, 255, 158, 0.06) 0%, rgba(0, 0, 0, 0) 55%),
    radial-gradient(130% 120% at 50% 50%, rgba(0, 0, 0, 0) 58%, rgba(0, 0, 0, 0.55) 100%);
  animation: flicker 7.5s ease-in-out infinite;
}
@keyframes flicker {
  0%, 92%, 100% { opacity: 1; }
  93% { opacity: 0.86; }
  94% { opacity: 1; }
  96% { opacity: 0.92; }
}

/* a short desktop window (a 720 or 768 laptop) tightens the line pitch instead of
   dropping a line of the page: everything still prints inside the tube */
@media (min-width: 900px) and (max-height: 790px) {
  :root { --lh: 1.3; }
}
@media (min-width: 900px) and (max-height: 740px) {
  :root { --lh: 1.26; }
  .crt { inset: calc(var(--fs) * 0.55) calc(var(--fs) * 1.25); }
}

/* ------------------------------------------------------------------ phone */

@media (max-width: 899px) {
  .rig {
    width: calc(100vw - var(--s4));
    height: calc(100dvh - var(--s4));
    aspect-ratio: auto;
    max-width: none;
  }
  .rig__shell { display: none; }
  .rig__lamp { display: none; }
  .glass {
    position: absolute;
    left: 0; top: 0; width: 100%; height: 100%;
    border-radius: 3.5%/2.2%;
    border-style: solid;
    border-width: 20px 26px 38px;
    border-image: url("../img/shell-v1.png") 124 197 244 197 / 20px 26px 38px / 0 stretch;
  }
  .crt { inset: calc(var(--fs) * 0.9) calc(var(--fs) * 1.1); }
  .mark { width: calc(var(--fs) * 4.2); height: calc(var(--fs) * 2.8); }
}

/* ----------------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
  .room__video { display: none; }
  .glass__bloom, .rig__lamp { animation: none; }
  .caret { animation: none; }
  .print > * { animation: none; }
}
