@font-face {
  font-family: "Archivo";
  src: url("fonts/archivo.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/jetbrains-mono.woff2") format("woff2");
  font-weight: 100 800;
  font-display: swap;
}

/* The rack at 2am: powder-coated steel, label tape, patch cables. */
:root {
  color-scheme: dark;
  --steel: #16171a;
  --steel-2: #1d1f23;       /* filler panels */
  --steel-3: #26282d;       /* server bezel */
  --edge: #34373e;
  --tape: #f4f1e6;
  --tape-y: #ffd23f;
  --tape-r: #e2483d;
  --ink: #111111;
  --blue: #2f7fd0;
  --led-off: #2d3036;
  --text-dim: #a9a69c;
  --paper: #f7f5ee;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --label: "Archivo", "Arial Narrow", sans-serif;
  --code: "JetBrains Mono", ui-monospace, monospace;
  --rail: 14px;
  --gutter: 16px;
  --u: 44px;                /* one rack unit on screen */
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  padding: 0 var(--rail);
  background-color: var(--steel);
  /* blank 1U filler panels down the whole rack */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='44'%3E%3Crect y='42' width='8' height='1' fill='%230c0d0f'/%3E%3Crect y='43' width='8' height='1' fill='%23222428'/%3E%3C/svg%3E");
  color: var(--tape);
  font-family: var(--label);
  font-size: 1.0625rem;
  line-height: 1.35;
  caret-color: var(--tape-y);
  -webkit-font-smoothing: antialiased;
}

/* Rack rails with square cage-nut holes, three per U. */
body::before,
body::after {
  content: "";
  position: fixed;
  top: 0;
  bottom: 0;
  width: var(--rail);
  z-index: 3;
  pointer-events: none;
  background-color: #202227;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='44'%3E%3Crect x='4' y='5' width='6' height='6' rx='0.5' fill='%230a0a0b'/%3E%3Crect x='4' y='19' width='6' height='6' rx='0.5' fill='%230a0a0b'/%3E%3Crect x='4' y='33' width='6' height='6' rx='0.5' fill='%230a0a0b'/%3E%3C/svg%3E");
  background-size: var(--rail) var(--u);
  box-shadow: inset -1px 0 0 #2c2f35, inset 1px 0 0 #2c2f35;
}
body::before { left: 0; }
body::after { right: 0; }

::selection { background: var(--tape-y); color: var(--ink); }
:focus-visible { outline: 2px solid var(--tape-y); outline-offset: 3px; }
* { scrollbar-width: thin; scrollbar-color: #3a3d44 transparent; }
[hidden] { display: none !important; }
.defs { position: absolute; width: 0; height: 0; }

/* ---------- label tape ---------- */

.tape {
  display: inline-block;
  margin: 0;
  padding: 0.32em 0.7em 0.36em;
  border-radius: 3px;
  background-color: var(--tape);
  background-image: linear-gradient(rgb(255 255 255 / 0.28), rgb(255 255 255 / 0) 45%);
  color: var(--ink);
  font-family: var(--label);
  font-weight: 650;
  font-stretch: 88%;
  letter-spacing: 0.01em;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.55), 0 0 0 0.5px rgb(0 0 0 / 0.4);
}
.tape-y { background-color: var(--tape-y); }
.tape-xs {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.25em 0.6em 0.28em;
}

/* ---------- boot: the server ---------- */

.boot {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: max(16px, env(safe-area-inset-top)) var(--gutter) max(16px, env(safe-area-inset-bottom));
}
.filler { display: flex; justify-content: center; padding: 8px 0; }
.filler .tape { transform: rotate(-0.6deg); }

.server {
  position: relative;
  justify-self: center;
  width: min(100%, 400px);
  padding: 18px 26px;
  border-radius: 6px;
  background:
    linear-gradient(rgb(255 255 255 / 0.05), rgb(255 255 255 / 0) 30%),
    var(--steel-3);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.07),
    inset 0 -2px 0 rgb(0 0 0 / 0.35),
    0 10px 30px rgb(0 0 0 / 0.55);
  view-transition-name: rig;
}
/* rack ears with their mounting screws */
.ear {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 18px;
  background:
    radial-gradient(circle at 50% 22px, #0d0d0e 0 3px, #5b5f68 3.5px 6px, transparent 6.5px),
    radial-gradient(circle at 50% calc(100% - 22px), #0d0d0e 0 3px, #5b5f68 3.5px 6px, transparent 6.5px),
    #2e3036;
}
.ear-l { left: 0; border-radius: 6px 0 0 6px; }
.ear-r { right: 0; border-radius: 0 6px 6px 0; }

.face {
  display: grid;
  grid-template-areas: "tapes" "fans" "bays" "power";
  gap: 18px;
}
.tapes { grid-area: tapes; display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px 10px; }
.tape-name { flex-basis: 100%; max-width: max-content; }
.tape-name {
  font-size: clamp(2.6rem, 13vw, 5.25rem);
  font-weight: 800;
  font-stretch: 72%;
  line-height: 0.95;
  text-transform: uppercase;
  letter-spacing: 0.005em;
  padding: 0.1em 0.28em 0.12em;
  transform: rotate(-1deg);
}
.tape-role {
  font-size: 0.9375rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transform: rotate(0.5deg);
}

.fans { grid-area: fans; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.fan { width: 100%; height: auto; display: block; }
.fan .blades { transform-origin: 100px 100px; }

.bays { grid-area: bays; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bay {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 10px;
  border-radius: 3px;
  background: #1c1e22;
  box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.6), 0 1px 0 rgb(255 255 255 / 0.05);
}
.bay .tape { font-size: 0.6875rem; }
.led {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--led-off);
  transition: background-color 120ms, box-shadow 120ms;
}

.power {
  grid-area: power;
  display: flex;
  align-items: center;
  gap: 16px;
}
.pwr {
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  padding: 0;
  border: 4px solid #1f4a78;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #3a3d44, #222429 70%);
  color: #8fa4bb;
  box-shadow: 0 4px 10px rgb(0 0 0 / 0.5), inset 0 1px 0 rgb(255 255 255 / 0.1);
  cursor: pointer;
  transition: transform 120ms var(--ease), border-color 200ms, box-shadow 200ms, color 200ms;
}
.pwr svg { width: 34px; height: 34px; }
.pwr:hover { border-color: var(--blue); color: var(--tape); }
.pwr:active { transform: scale(0.96); }
.power .tape { transform: rotate(-1deg); }

/* Power on: ring lights, drives come up one by one. */
.powering .pwr,
.on .pwr {
  border-color: var(--blue);
  color: var(--tape);
  box-shadow: 0 0 0 3px rgb(47 127 208 / 0.25), 0 0 18px rgb(47 127 208 / 0.6), 0 4px 10px rgb(0 0 0 / 0.5);
}
.powering .led,
.on .led {
  background: var(--blue);
  box-shadow: 0 0 6px rgb(47 127 208 / 0.9);
}
.powering .bay:nth-child(2) .led { transition-delay: 250ms; }
.powering .bay:nth-child(3) .led { transition-delay: 500ms; }
.powering .bay:nth-child(4) .led { transition-delay: 750ms; }
.led.act { background: var(--tape-y) !important; box-shadow: 0 0 8px rgb(255 210 63 / 0.9) !important; transition: none; }

@media (min-width: 860px) {
  :root { --rail: 30px; --gutter: 40px; }
  body::before, body::after { background-size: 30px var(--u); }
  body::before, body::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='44'%3E%3Crect x='11' y='5' width='8' height='7' rx='0.5' fill='%230a0a0b'/%3E%3Crect x='11' y='18.5' width='8' height='7' rx='0.5' fill='%230a0a0b'/%3E%3Crect x='11' y='32' width='8' height='7' rx='0.5' fill='%230a0a0b'/%3E%3C/svg%3E");
  }
  .server { width: min(100%, 1180px); padding: 26px 48px; }
  .ear { width: 26px; }
  .face {
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr) auto;
    grid-template-areas:
      "tapes tapes power"
      "fans  bays  power";
    align-items: center;
    column-gap: 32px;
    row-gap: 22px;
  }
  .tape-name { font-size: clamp(4rem, 7.4vw, 7rem); }
  .tape-role { font-size: 1.125rem; }
  .fans { max-width: 520px; }
  .bays { grid-template-columns: 1fr; align-self: stretch; align-content: center; }
  .bay { height: 46px; }
  .power { flex-direction: column; align-self: stretch; justify-content: center; padding-left: 8px; }
  .pwr { width: 112px; height: 112px; border-width: 5px; }
  .pwr svg { width: 44px; height: 44px; }
}

/* ---------- powered: chat, cable, code sheet ---------- */

.app {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-areas: "bar" "chat" "code" "controls";
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

.bar {
  grid-area: bar;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px calc(var(--gutter) - 6px);
}
.bar .server {
  width: 132px;
  padding: 6px 12px;
  border-radius: 3px;
  view-transition-name: rig;
}
.bar .ear { width: 8px; background: #2e3036; }
.bar .tapes, .bar .power, .bar .bay .tape { display: none; }
.bar .face { grid-template-columns: 1fr 1fr; grid-template-areas: "fans bays"; gap: 6px; align-items: center; }
.bar .fans { gap: 4px; }
.bar .bays { gap: 3px; grid-template-columns: 1fr 1fr; }
.bar .bay { height: 9px; padding: 0 3px; }
.bar .led { width: 4px; height: 4px; }
.tape-bar {
  font-size: 1.25rem;
  font-weight: 800;
  font-stretch: 72%;
  text-transform: uppercase;
  transform: rotate(-1deg);
}
.tape-bar { white-space: nowrap; }
@media (max-width: 480px) {
  .bar-note, .code-note { display: none; }
  .tape-bar { font-size: 1.125rem; }
  .bar .server { width: 112px; }
}
.bar-note { margin: 0 0 0 auto; transform: rotate(0.8deg); }

.chat {
  grid-area: chat;
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  min-height: 0;
  padding: 10px var(--gutter) 18px;
}
.panel-tag { justify-self: start; transform: rotate(-0.8deg); }
/* U14: the chat is a mounted unit, bezel and screws behind the tapes. */
.chat {
  margin: 4px calc(var(--gutter) - 10px) 12px;
  padding: 14px 22px 16px;
  border-radius: 6px;
  background:
    radial-gradient(circle at 9px 9px, #0d0d0e 0 2.5px, #5b5f68 3px 5px, transparent 5.5px),
    radial-gradient(circle at calc(100% - 9px) 9px, #0d0d0e 0 2.5px, #5b5f68 3px 5px, transparent 5.5px),
    radial-gradient(circle at 9px calc(100% - 9px), #0d0d0e 0 2.5px, #5b5f68 3px 5px, transparent 5.5px),
    radial-gradient(circle at calc(100% - 9px) calc(100% - 9px), #0d0d0e 0 2.5px, #5b5f68 3px 5px, transparent 5.5px),
    var(--steel-3);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.07), inset 0 -2px 0 rgb(0 0 0 / 0.35), 0 8px 24px rgb(0 0 0 / 0.5);
}

.log {
  list-style: none;
  margin: 0;
  padding: 8px 4px 30px;   /* room for the cable to leave the last message */
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overscroll-behavior: contain;
}
/* Every message is printed on label tape and stuck to the panel. */
.log > li {
  max-width: min(34ch, 86%);
  font-size: 1.125rem;
  font-weight: 620;
  font-stretch: 90%;
  line-height: 1.25;
  padding: 0.45em 0.8em 0.5em;
  animation: print 420ms var(--ease) both;
}
.log > .bot { align-self: flex-start; transform: rotate(-0.4deg); }
.log > .me { align-self: flex-end; background-color: var(--tape-y); transform: rotate(0.5deg); }
.log > li:nth-child(4n + 3) { transform: rotate(0.3deg); }
@keyframes print {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}

/* The code: a printed sheet zip-tied to the rack. */
.code {
  grid-area: code;
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  margin: 0 var(--gutter);
  height: 36dvh;
  border-radius: 2px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1px 0 rgb(255 255 255 / 0.6) inset, 0 8px 22px rgb(0 0 0 / 0.55);
  transition: height 320ms var(--ease);
}
.code::before,
.code::after {
  content: "";
  position: absolute;
  top: -6px;
  width: 6px;
  height: 22px;
  border-radius: 2px;
  background: #0d0d0e;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.5);
}
.code::before { left: 22px; }
.code::after { right: 22px; }
.code.expanded { height: 72dvh; }

.code-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px 8px 14px;
  border-bottom: 1px solid #ddd9cc;
}
.code-head .tape { transform: rotate(-0.6deg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-transform: none; letter-spacing: 0.02em; }
.expand {
  margin-left: auto;
  flex: none;
  min-height: 36px;
  border: 0;
  cursor: pointer;
  transform: rotate(0.6deg);
}
.expand:hover { background-color: #fffdf5; }

.lines {
  position: relative;
  list-style: none;
  margin: 0;
  padding: 10px 0 14px;
  overflow: auto;
  font: 400 12.5px/1.6 var(--code);
  font-variant-ligatures: none;   /* show the file literally: === stays three characters */
  overscroll-behavior: contain;
}
.lines > li {
  position: relative;
  display: grid;
  grid-template-columns: 3.4ch 1fr;
  gap: 1.2ch;
  padding: 0 12px 0 6px;
  border: 1px solid transparent;
  transition: background-color 180ms;
}
.lines > li::before { content: attr(data-n); text-align: right; color: #75726a; }
.lines code {
  font: inherit;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding-left: var(--ind, 2ch);   /* wrapped lines hang under their own code */
  text-indent: calc(-1 * var(--ind, 2ch));
}
.tk-com { color: #66635b; font-style: italic; }
.tk-key { color: #1d5fa6; font-weight: 700; }
.tk-str { color: #8a3a12; }
.tk-tp { color: #1d5fa6; font-weight: 700; }

.lines > li.hit::before { color: #1d5fa6; font-weight: 700; }
/* The executing line gets a strip of yellow tape. */
.lines > li.active { background: var(--tape-y); box-shadow: 0 1px 2px rgb(0 0 0 / 0.25); }

/* Commented-out code: an empty slot, tagged NOT INSTALLED. */
.lines > li.dnp { border-left: 1.5px dashed var(--ink); border-right: 1.5px dashed var(--ink); margin: 0 8px; }
.lines > li.dnp-first { border-top: 1.5px dashed var(--ink); margin-top: 22px; }
.lines > li.dnp-last { border-bottom: 1.5px dashed var(--ink); }
.lines > li.dnp-first::after {
  content: "NOT INSTALLED";
  position: absolute;
  top: -20px;   /* sits above the dashed outline, clear of the code */
  right: 10px;
  padding: 1px 7px 2px;
  border-radius: 2px;
  background: var(--tape-r);
  color: var(--ink);
  font: 800 10.5px/1.5 var(--label);
  letter-spacing: 0.08em;
  transform: rotate(1.2deg);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.35);
}

/* Replies are keycaps. */
.controls {
  grid-area: controls;
  display: grid;
  gap: 12px;
  padding: 16px var(--gutter) max(16px, env(safe-area-inset-bottom));
  min-height: 86px;
}
.chips { display: flex; flex-wrap: wrap; gap: 12px; }
.chip, .send {
  min-height: 50px;
  min-width: 64px;
  padding: 0 18px 4px;
  border: 0;
  border-radius: 6px;
  background-color: var(--tape);
  color: var(--ink);
  font: 700 1.0625rem var(--label);
  font-stretch: 90%;
  cursor: pointer;
  /* the keycap's lower skirt, drawn as a background band */
  background-image: linear-gradient(to top, var(--skirt, #b4b0a3) 4px, transparent 4px);
  box-shadow: 0 2px 0 #0a0a0b, 0 4px 8px rgb(0 0 0 / 0.45);
  transition: transform 90ms var(--ease), box-shadow 90ms var(--ease);
  animation: rise 360ms var(--ease) both;
}
.chip:hover { background-color: #fffdf5; }
.chip:active, .send:active {
  transform: translateY(2px);
  background-image: linear-gradient(to top, var(--skirt, #b4b0a3) 2px, transparent 2px);
  box-shadow: 0 0 0 #0a0a0b, 0 2px 4px rgb(0 0 0 / 0.45);
}
.send { background-color: var(--tape-y); --skirt: #b88f12; }
.send:hover { background-color: #ffe070; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.ask { display: flex; gap: 12px; animation: rise 360ms var(--ease) both; }
.ask input {
  flex: 1;
  min-width: 0;
  min-height: 50px;
  padding: 0 14px;
  border: 0;
  border-radius: 3px;
  background: var(--tape);
  color: var(--ink);
  font: 620 1.125rem var(--label);
  font-stretch: 90%;
  caret-color: var(--ink);
  box-shadow: inset 0 2px 3px rgb(0 0 0 / 0.25);
}
.ask input::placeholder { color: #6d6a62; }

/* The patch cable from a message to the line it ran. */
.trace {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transition: opacity 200ms;
}
.trace.live { opacity: 1; }
.trace path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.cable-shade { stroke: rgb(0 0 0 / 0.55); stroke-width: 9; transform: translateY(3px); }
.cable { stroke: var(--cable, var(--blue)); stroke-width: 6; }
.cable-pulse { stroke: rgb(255 255 255 / 0.85); stroke-width: 2; stroke-dasharray: 10 100; stroke-dashoffset: 110; }
.jack { fill: #cfd5dc; stroke: #7d848e; stroke-width: 1; }

@media (min-width: 860px) {
  .app {
    max-width: 1400px;
    margin: 0 auto;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "bar bar" "chat code" "controls code";
    column-gap: 96px;
    padding: 0 var(--gutter) 28px;
  }
  .bar { padding: 16px 0 20px; }
  .bar .server { width: 168px; }
  .tape-bar { font-size: 1.625rem; }
  .controls { padding-left: 0; padding-right: 0; }
  .chat { margin: 0 0 14px; padding: 18px 30px 20px; }
  .lines > li.dnp-first::after { font-size: 12px; }
  .code { margin: 14px 0 0; height: auto; }
  .code.expanded { height: auto; }
  .expand { display: none; }
  .lines { font-size: 13.5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

::view-transition-group(rig) { animation-duration: 700ms; animation-timing-function: var(--ease); }
::view-transition-old(root),
::view-transition-new(root) { animation-duration: 450ms; }

.noscript { padding: 24px; font-size: 1.25rem; }
.noscript a { color: var(--tape-y); }
