/* Agent Shop. One 1984 public terminal screen, built to art/ref/ref_site.jpg.
   Everything on the page is drawn BY the screen: flat fills, hairlines, solid blocks,
   horizontal raster. No bevel, no gradient object, no shadow on a surface. */

@font-face {
  font-family: "Terminal";
  src: url("/fonts/3270-Regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Rounded";
  src: url("/fonts/mplus-rounded-900-latin.woff2") format("woff2");
  font-weight: 900; font-style: normal; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
:root {
  /* palette sampled off his picture, with its proportions kept */
  --ground: #040a07;
  --ink: #37e37c;          /* phosphor green, the machine's voice */
  --ink-hot: #86ffb8;
  --ink-dim: #2fae63;
  --signal: #00e062;       /* the solid block that finishes a number */
  --cream: #dce3c1;
  --cream-hot: #f4f2e0;
  --blue: #004fc1;
  --red: #e5262e;
  --grey: #b6b494;
  --amber: #d9b434;

  --glow-ink: 0 0 9px rgba(55, 227, 124, 0.45);
  --glow-cream: 0 0 14px rgba(220, 227, 193, 0.3);

  --hair: 2px;
  --gut: clamp(16px, 1.4vw, 26px);
  --pad: 32px;
  --side: clamp(18px, 3.3vw, 64px);

  --t-display: clamp(38px, 4.6vw, 86px);
  --t-band: clamp(23px, 2.1vw, 40px);
  --t-num: clamp(32px, 3.6vw, 70px);
  --t-body: clamp(18px, 1.3vw, 25px);
  --t-small: clamp(17px, 1.08vw, 21px);

  color-scheme: dark;
}

* { box-sizing: border-box; }

html { background: var(--ground); }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: "Terminal", ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: var(--t-body);
  line-height: 1.45;
  letter-spacing: 0.055em;
  -webkit-font-smoothing: antialiased;
  font-synthesis: none;
  overflow-x: hidden;
  scrollbar-gutter: stable;
}

img { display: block; max-width: 100%; }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 99;
  background: var(--signal); color: var(--ground);
  padding: 14px 26px; text-decoration: none; font-size: var(--t-body);
}
.skip:focus { left: 12px; top: 12px; }

:focus-visible { outline: 3px solid var(--cream-hot); outline-offset: 3px; }

/* ---------------------------------------------------------------- the screen */

.screen {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1800px;
  margin: 0 auto;
  padding: clamp(26px, 3.4vh, 48px) var(--side) clamp(40px, 6vh, 86px);
  display: flex;
  flex-direction: column;
  gap: var(--gut);
  min-height: 100svh;
}

/* --------------------------------------------- zone A: one line, one baseline */

.zone-a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--gut);
  flex-wrap: wrap;
}

/* the name and the page code are the SAME line: same face, same size, same case, one baseline */
.mast,
.ident {
  margin: 0;
  font-family: inherit;
  font-weight: 400;
  font-size: var(--t-small);
  line-height: 1.4;
  letter-spacing: 0.055em;
  white-space: nowrap;
}

.mast { color: var(--cream-hot); text-shadow: var(--glow-cream); }
.ident { color: var(--ink); text-shadow: var(--glow-ink); }

.rule-red {
  height: 3px;
  background: var(--red);
  box-shadow: 0 0 12px rgba(205, 30, 37, 0.45);
  margin-top: calc(var(--gut) * -0.45);
}

/* ------------------------------------------------------------ zone B: the panel */

/* the panel is one flat blue field carrying the same even scan rows as the rest of the screen:
   regular, 1 px on 4, drawn by the background itself so nothing can tear it up */
.panel {
  background-color: var(--blue);
  background-image: repeating-linear-gradient(to bottom,
    rgba(4, 10, 7, 0.17) 0 1px, rgba(4, 10, 7, 0) 1px 4px);
  border: var(--hair) solid var(--cream);
  padding: var(--pad);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: clamp(24px, 2.6vw, 56px);
  align-items: center;
}

.panel-left {
  grid-area: 1 / 1;
  align-self: center;
  min-width: 0;
}

.panel-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: clamp(14px, 1.2vw, 26px);
  align-items: center;
}

.panel-mark {
  width: clamp(44px, 4.4vw, 88px);
  height: auto;
}

.panel-word {
  margin: 0;
  font-family: "Rounded", system-ui, sans-serif;
  font-weight: 900;
  font-size: var(--t-display);
  line-height: 0.98;
  padding-block: 0.22em;
  letter-spacing: -0.018em;
  color: var(--cream);
  text-shadow: 2px 2px 0 rgba(0, 30, 86, 0.8), var(--glow-cream);
  overflow-wrap: anywhere;
}

.panel-sub {
  margin: clamp(12px, 1vw, 20px) 0 0;
  color: var(--cream-hot);
  font-size: var(--t-body);
  line-height: 1.55;
  max-width: 54ch;
  overflow-wrap: anywhere;
}

/* the figure is a card of its own: the same cream hairline, equal padding on all four sides,
   the picture centred inside it */
.panel-figure {
  grid-area: 1 / 2;
  margin: 0;
  padding: clamp(14px, 1.2vw, 22px);
  border: var(--hair) solid var(--cream);
  background-color: var(--blue);
  background-image: repeating-linear-gradient(to bottom,
    rgba(4, 10, 7, 0.17) 0 1px, rgba(4, 10, 7, 0) 1px 4px);
  align-self: center;
  justify-self: end;
  width: clamp(150px, 14vw, 232px);
}
.panel-figure img {
  width: 100%;
  height: auto;
  max-height: clamp(150px, 14vw, 232px);
  object-fit: contain;
  object-position: center;
}
.panel-figure figcaption {
  margin-top: clamp(10px, 0.8vw, 16px);
  color: var(--cream-hot);
  font-size: var(--t-small);
  letter-spacing: 0.06em;
  text-align: center;
}

/* three giant numerals inside the panel (P200, P300, P400, P500) */
.panel-numbers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
  gap: clamp(16px, 1.6vw, 30px);
  margin-top: clamp(16px, 1.8vw, 30px);
}
.panel-numbers .num {
  min-width: 0;
  padding-right: var(--pad);
}
.panel-numbers .num b {
  display: block;
  font-family: "Rounded", system-ui, sans-serif;
  font-weight: 900;
  font-size: var(--t-num);
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--cream-hot);
  overflow-wrap: anywhere;
}
.panel-numbers .num span {
  display: block;
  margin-top: 0.45em;
  color: var(--cream-hot);
  font-size: var(--t-small);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* ----------------------------------------------------- zone C: tile, select, stamp */

.zone-c {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  column-gap: clamp(18px, 2vw, 40px);
  align-items: start;
}

.tile {
  background: var(--blue);
  border: var(--hair) solid var(--cream);
  width: clamp(104px, 9vw, 164px);
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: clamp(12px, 1vw, 20px);
}
.tile-pict { width: 56%; height: auto; }
.tile-word {
  color: var(--cream-hot);
  font-size: var(--t-small);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  text-align: center;
  line-height: 1.1;
}

.select { min-width: 0; }

.select-label {
  margin: 0;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  text-shadow: var(--glow-ink);
}
.select-label::after { content: ":"; }

.rule-green {
  height: 2px;
  background: var(--ink);
  margin: 10px 0 12px;
  max-width: 44ch;
  box-shadow: 0 0 10px rgba(47, 209, 110, 0.4);
}

.pages {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 4px;
}
.pages a {
  color: var(--ink-dim);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 11px 0;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.pages a:hover { color: var(--ink-hot); }
.pages a[aria-current="page"] {
  color: var(--ink-hot);
  text-shadow: 0 0 14px rgba(109, 255, 166, 0.55);
}
.pages .sep { color: var(--ink-dim); padding: 0 1px; }

.live {
  margin: 0;
  color: var(--ink-hot);
  overflow-wrap: anywhere;
  min-height: 1.45em;
  text-shadow: var(--glow-ink);
}
.live .dim { color: var(--grey); }

.caret {
  display: inline-block;
  width: 0.55em;
  height: 1em;
  margin-left: 0.25em;
  background: var(--ink-hot);
  vertical-align: -0.12em;
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

.keys {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

/* the maker's stamp in the right margin, in the screen's own voice */
.stamp {
  margin: 0;
  justify-self: end;
  text-align: right;
  color: var(--ink);
  font-size: var(--t-small);
  letter-spacing: 0.06em;
  white-space: nowrap;
  text-shadow: var(--glow-ink);
}

/* ------------------------------------------------------------- the solid keys */

.key {
  font: inherit;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  background: var(--signal);
  color: #02140a;
  border: var(--hair) solid var(--signal);
  min-height: 56px;
  padding: 14px 1.4em;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.7em;
  text-decoration: none;
  cursor: pointer;
  transform: translateY(0);
  transition: background 0.12s linear, transform 0.08s linear;
}
.key:hover { background: var(--ink-hot); border-color: var(--ink-hot); }
.key:active { transform: translateY(2px); }
.key .mark { width: 18px; height: 18px; display: block; }
.key--ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink-dim);
}
.key--ghost:hover { background: transparent; color: var(--ink-hot); border-color: var(--ink); }
.key[aria-disabled="true"],
.key:disabled {
  background: transparent;
  color: var(--grey);
  border-color: rgba(169, 168, 137, 0.45);
  cursor: not-allowed;
}
.key[aria-disabled="true"]:hover,
.key:disabled:hover { background: transparent; color: var(--grey); border-color: rgba(169, 168, 137, 0.45); }
.key[aria-disabled="true"]:active { transform: none; }

/* ------------------------------------------------------------- zone D: the box */

.box {
  border: var(--hair) solid var(--ink);
  padding: var(--pad);
  box-shadow: 0 0 20px rgba(47, 209, 110, 0.12) inset;
}

.box-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr);
  column-gap: clamp(22px, 2.6vw, 56px);
  row-gap: var(--pad);
  align-items: start;
}

.box-main { min-width: 0; }
.box-side { min-width: 0; }

.box-label {
  margin: 0 0 14px;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  text-shadow: var(--glow-ink);
}
.box-note {
  margin: 0 0 14px;
  color: var(--grey);
  overflow-wrap: anywhere;
}

/* a row finished by a solid block, the reference's 1-800- grammar */
.tally { display: grid; gap: 10px; margin: 0 0 14px; }
.tally-row {
  display: grid;
  grid-template-columns: 1.6em minmax(0, 1fr) minmax(90px, 26%) 4.2em;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  letter-spacing: inherit;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  width: 100%;
}
.tally-row:disabled { cursor: default; }
.tally-row .k { color: var(--cream); }
.tally-row .n { overflow-wrap: anywhere; text-transform: uppercase; }
.tally-row .b { height: 20px; background: rgba(27, 122, 69, 0.3); position: relative; }
.tally-row .b i { position: absolute; inset: 0 auto 0 0; background: var(--signal); display: block; }
.tally-row .p { text-align: right; color: var(--ink-hot); font-variant-numeric: tabular-nums; }
.tally-row[aria-pressed="true"] .k,
.tally-row[aria-pressed="true"] .n { color: var(--ink-hot); }
.tally-row:not(:disabled):hover .n { color: var(--ink-hot); }

/* the grey progress bar with the amber cap */
.gauge {
  height: 26px;
  border: var(--hair) solid var(--grey);
  position: relative;
  margin: 12px 0 10px;
  overflow: hidden;
}
.gauge i {
  position: absolute;
  inset: 0 auto 0 0;
  background: repeating-linear-gradient(90deg, rgba(169, 168, 137, 0.95) 0 3px, rgba(140, 139, 112, 0.95) 3px 6px);
  border-right: 4px solid var(--amber);
  display: block;
}
.side-word {
  margin: 0;
  color: var(--grey);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.side-note { margin: 0; color: var(--grey); overflow-wrap: anywhere; }

/* plain machine rows: the wire, the ledger, the archive, the log */
.rows { display: grid; gap: 0; margin: 0; }
.rows .row {
  position: relative;
  display: grid;
  grid-template-columns: var(--cols, minmax(0, 1fr));
  gap: 10px clamp(14px, 1.4vw, 28px);
  padding: 12px 0;
  align-items: baseline;
}
.rows .row::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: rgba(31, 140, 79, 0.55);
}
.rows .row:last-child::after { display: none; }
.rows .row > * { min-width: 0; overflow-wrap: anywhere; }
.rows .t { color: var(--grey); font-variant-numeric: tabular-nums; }
.rows .v { color: var(--ink-hot); font-variant-numeric: tabular-nums; text-align: right; }
.rows .c { color: var(--cream); text-transform: uppercase; }
.rows .kind { color: var(--amber); text-transform: uppercase; letter-spacing: 0.07em; }
.rows .kind--no { color: var(--grey); }
.rows .kind--yes { color: var(--ink-hot); }
.rows a { color: var(--ink); }

.empty {
  margin: 0;
  color: var(--grey);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* the address well on P600 */
.mint {
  margin: 0 0 16px;
  padding: var(--pad);
  border: var(--hair) solid var(--ink-dim);
  background: rgba(7, 114, 170, 0.1);
  color: var(--cream-hot);
  font-size: var(--t-body);
  overflow-wrap: anywhere;
  user-select: all;
  min-height: 3.4em;
  display: flex;
  align-items: center;
}
.mint.is-empty { color: var(--grey); user-select: auto; }
.mint-fill {
  display: inline-block;
  width: 9em;
  height: 1.1em;
  background: var(--signal);
  vertical-align: -0.16em;
  margin-left: 0.3em;
}

.copy-state { margin: 10px 0 0; min-height: 1.45em; color: var(--ink-hot); }

/* ------------------------------------------------------- overflow bands below */

.overflow { display: grid; gap: var(--gut); }
.band { border-top: var(--hair) solid var(--ink-dim); padding-top: var(--pad); }
.band > h3 {
  margin: 0 0 var(--pad);
  font-family: "Rounded", system-ui, sans-serif;
  font-weight: 900;
  font-size: var(--t-band);
  text-transform: uppercase;
  letter-spacing: 0.01em;
  color: var(--cream-hot);
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr));
  gap: var(--gut);
}
.card {
  border: var(--hair) solid var(--cream);
  background: var(--blue);
  padding: var(--pad);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.card img { width: 100%; height: auto; }
.card b {
  font-family: "Rounded", system-ui, sans-serif;
  font-weight: 900;
  font-size: clamp(21px, 1.5vw, 28px);
  color: var(--cream-hot);
  letter-spacing: -0.01em;
  line-height: 1.08;
}
.card span { color: var(--cream-hot); font-size: var(--t-small); }

/* ------------------------------------------------------------- the CRT itself */

.crt { position: fixed; inset: 0; pointer-events: none; z-index: 40; }
.crt-scan {
  position: absolute;
  left: 0; right: 0; top: -100%;
  height: 300%;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.3) 0 1px, rgba(0, 0, 0, 0) 1px 3px);
  animation: drift 9s linear infinite;
  will-change: transform;
}
@keyframes drift { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(0, 3px, 0); } }
.crt-grain {
  position: absolute; inset: 0;
  background-image: url("/img/grain.png");
  background-size: 220px 220px;
  opacity: 0.085;
}
.crt-vignette {
  position: absolute; inset: 0;
  background: radial-gradient(128% 108% at 50% 46%, rgba(0, 0, 0, 0) 40%, rgba(0, 0, 0, 0.72) 100%);
}

/* ------------------------------------------------------------------- narrower */

@media (max-width: 1100px) {
  .box-grid { grid-template-columns: minmax(0, 1fr); }
  /* one column: the word and its line, then the figure card under it */
  .panel { grid-template-columns: minmax(0, 1fr); }
  .panel-left { grid-area: 1 / 1; }
  .panel-figure {
    grid-area: 2 / 1;
    justify-self: center;
    width: clamp(170px, 36vw, 240px);
    margin-top: var(--pad);
  }
  .panel-figure img { max-height: clamp(170px, 36vw, 240px); }
}

@media (max-width: 760px) {
  body { letter-spacing: 0.04em; }
  .zone-c { grid-template-columns: auto minmax(0, 1fr); row-gap: var(--gut); }
  .stamp { grid-column: 1 / -1; text-align: left; justify-self: start; white-space: normal; }
  .zone-a { gap: 6px var(--gut); }
  .ident { white-space: normal; }
  .keys { gap: 10px; }
  .key { width: 100%; }
  .tally-row { grid-template-columns: 1.6em minmax(0, 1fr) 4.2em; }
  .tally-row .b { grid-column: 1 / -1; }
}

/* the narrowest phone: the mark stands over the word instead of stealing a column from it */
@media (max-width: 400px) {
  .panel-head { grid-template-columns: minmax(0, 1fr); row-gap: 10px; }
  .panel-mark { width: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  .crt-scan { animation: none; }
  .caret { animation: none; }
  * { transition-duration: 0.001s !important; }
}
