/* The Core Cat. One object: a trace map of bordered nodes joined by cables.
   Built to art/ref/trace-map.jpg. Every token below was measured off that file
   or computed against it; see NOTE.md > Reference teardown. */

@font-face {
  font-family: "Proto";
  src: url("../assets/fonts/0xproto-regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Proto";
  src: url("../assets/fonts/0xproto-bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* ground: his two biggest buckets, #0a0a0a and a warm olive black */
  --ground: #080808;
  --node: #0c0e0a;
  --node-red: #14100f;
  --node-teal: #081110;

  /* four inks, as in the picture */
  --ink: #cdec62;        /* 15.0:1 on ground: borders, labels, cables */
  --ink-2: #9ab64a;      /*  8.7:1 secondary labels */
  --ink-idle: #768c3c;   /*  5.5:1 idle cable, idle port block */
  --paper: #f2f0e6;      /* 17.5:1 node body text */
  --paper-2: #b9b9ad;    /* 10.1:1 secondary body text */
  --red: #ff6168;        /*  6.8:1 leaks (his #bb2b35 measures 3.5:1 and fails) */
  --teal: #8fe3dc;       /* 13.5:1 the one second-colour node */
  --port: #ffffff;       /* 20.0:1 threshold ports */
  --mute: #8d8d84;       /*  6.0:1 separators and keys that cannot be pressed yet */

  /* one scale, nothing off it */
  --t-body: 16px;
  --t-value: 20px;
  --t-head: 26px;
  --t-display: 72px;

  --page: 1180px;
  --gutter: 24px;
  --node-pad-x: 20px;
  --node-pad-y: 18px;
  --tab-h: 44px;
  --port-w: 22px;
  --line: 1px;
}

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

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

body {
  margin: 0;
  background: var(--ground);
  color: var(--paper);
  font-family: "Proto", ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: var(--t-body);
  font-weight: 400;
  font-synthesis: none;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; }

::selection { background: var(--ink); color: #0a0a0a; }

:focus-visible {
  outline: 2px solid var(--port);
  outline-offset: 2px;
}

.page {
  width: 100%;
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 var(--gutter) 96px;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: #0a0a0a;
  padding: 12px 20px;
  z-index: 40;
}
.skip:focus { left: var(--gutter); top: 12px; }

/* ---- masthead: one line in the page's own face -------------------------- */

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px 18px;
  padding: 28px 0 0;
}
.masthead__name {
  font-size: var(--t-value);
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--paper);
  margin: 0;
}
.masthead__ticker { color: var(--ink); font-weight: 700; }
.masthead__line { color: var(--paper-2); margin: 0; }
.masthead__meta {
  margin-left: auto;
  color: var(--ink-2);
  font-size: var(--t-body);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ---- the cable bus: the navigation -------------------------------------- */

.bus {
  position: relative;
  margin: 26px 0 0;
  padding-top: 1px;
}
.bus__wire {
  height: var(--line);
  background: var(--ink);
  width: 100%;
}
.bus__ports {
  display: flex;
  align-items: flex-start;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}
.bus__ports li { flex: 0 0 auto; }
/* uneven x positions and uneven drop lengths: the picture has no grid */
.bus__ports li:nth-child(1) { margin-left: 1.5%; --drop: 14px; }
.bus__ports li:nth-child(2) { margin-left: 7.5%; --drop: 26px; }
.bus__ports li:nth-child(3) { margin-left: 6%;  --drop: 18px; }
.bus__ports li:nth-child(4) { margin-left: 8.5%; --drop: 32px; }

.port {
  display: block;
  position: relative;
  min-height: 48px;
  padding-top: var(--drop);
  text-decoration: none;
  color: var(--ink-2);
}
.port::before { /* the drop: a cable hanging off the wire */
  content: "";
  position: absolute;
  left: calc(var(--port-w) / 2);
  top: 0;
  width: var(--line);
  height: var(--drop);
  background: var(--ink-idle);
}
.port__chip {
  display: flex;
  align-items: stretch;
  height: var(--tab-h);
}
.port__block { /* the filled port block, exactly his pale chip */
  width: var(--port-w);
  background: var(--ink-idle);
  flex: 0 0 auto;
}
.port__label {
  display: flex;
  align-items: center;
  line-height: 1;
  border: var(--line) solid var(--ink-idle);
  border-left: 0;
  padding: 0 18px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  font-weight: 600;
}
.port:hover { color: var(--ink); }
.port:hover::before,
.port:hover .port__block { background: var(--ink); }
.port:hover .port__label { border-color: var(--ink); }
.port[aria-current="page"] { color: #0a0a0a; }
.port[aria-current="page"]::before,
.port[aria-current="page"] .port__block { background: var(--ink); }
.port[aria-current="page"] .port__label {
  background: var(--ink);
  border-color: var(--ink);
  color: #0a0a0a;
}

/* ---- the map ------------------------------------------------------------ */

.map {
  position: relative;
  display: grid;
  grid-template-columns: 40% 46%;
  column-gap: 11%;
  align-items: start;
  margin-top: 44px;
}
.map__cables {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}
.col {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}
.col--b { align-items: flex-end; }

/* ---- a node: his unit object -------------------------------------------- */

.node {
  position: relative;
  width: 100%;
  margin-top: var(--stagger, 52px);
  min-width: 0;
}
.col > .node:first-child { margin-top: 0; }
.node--w86 { width: 86%; }
.node--w72 { width: 72%; }

.node__tab { /* the label chip, sitting ON the top border, flush to one edge */
  display: flex;
  align-items: stretch;
  height: var(--tab-h);
  position: relative;
  z-index: 2;
}
.node--right .node__tab { justify-content: flex-end; }
.node__port {
  width: var(--port-w);
  background: var(--ink);
  flex: 0 0 auto;
}
.node__name {
  display: flex;
  align-items: center;
  line-height: 1;
  border: var(--line) solid var(--ink);
  border-left: 0;
  padding: 0 18px;
  color: var(--ink);
  font-size: var(--t-body);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}


.node__body {
  border: var(--line) solid var(--ink);
  background: var(--node);
  padding: var(--node-pad-y) var(--node-pad-x);
  margin-top: -1px;
  min-width: 0;
}
.node__body { overflow-wrap: anywhere; }
.node__body > :first-child { margin-top: 0; }
.node__body > :last-child { margin-bottom: 0; }
.node__body p { margin: 0 0 10px; }
.node__body p:last-child { margin-bottom: 0; }

/* a node with no body at all: his white threshold ports */
.node--threshold { width: auto; max-width: 100%; }
.node--threshold .node__port {
  background: var(--port);
  box-shadow: 0 0 18px 4px rgba(255, 255, 255, 0.45);
}
.node--threshold .node__name { border-color: var(--port); color: var(--port); }

.node--leak .node__port { background: var(--red); }
.node--leak .node__name { border-color: var(--red); color: var(--red); }
.node--leak .node__body { border-color: var(--red); background: var(--node-red); }

.node--token .node__port { background: var(--teal); }
.node--token .node__name { border-color: var(--teal); color: var(--teal); }
.node--token .node__body { border-color: var(--teal); background: var(--node-teal); }

/* 0xProto's text rect runs well past its line box, so the score needs room measured against
   the glyph box, not the type size: shots.mjs measures the rect, and so should we. */
.node--score .node__body { padding: 46px 32px; }

.node--idle .node__port { background: var(--ink-idle); }
.node--idle .node__name { border-color: var(--ink-idle); color: var(--ink-2); }
.node--idle .node__body { border-color: var(--ink-idle); }

/* ---- what goes inside a node -------------------------------------------- */

.rows { display: grid; grid-template-columns: max-content 1fr; gap: 8px 22px; }
.rows dt { color: var(--ink-2); letter-spacing: 0.06em; text-transform: uppercase; }
.rows dd { margin: 0; color: var(--paper); overflow-wrap: anywhere; min-width: 0; }

.val { font-size: var(--t-value); font-weight: 600; line-height: 1.25; }
.sub { color: var(--paper-2); }
.dim { color: var(--mute); }

.addr {
  display: block;
  font-size: var(--t-body);
  color: var(--paper);
  overflow-wrap: anywhere;
  word-break: break-word;
  user-select: all;
  border: var(--line) solid var(--ink-idle);
  background: #060806;
  padding: 14px 18px;
  min-width: 0;
}

.score {
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
}
.score__n {
  font-size: var(--t-display);
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
  letter-spacing: -0.02em;
  text-shadow: 0 0 26px rgba(205, 236, 98, 0.42);
  font-variant-numeric: tabular-nums;
}
.score__n--low { color: var(--red); text-shadow: 0 0 26px rgba(255, 97, 104, 0.38); }
.score__n--none { color: var(--mute); text-shadow: none; font-size: var(--t-head); }
.score__of { color: var(--ink-2); font-size: var(--t-value); }
.score__verdict { color: var(--paper-2); }

/* the points a leak cost, drawn as blocks: his ######## row, made readable */
.blocks {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin: 2px 0 12px;
}
.blocks i {
  display: block;
  width: 11px;
  height: 14px;
  background: var(--red);
}
.cost { color: var(--red); font-weight: 700; letter-spacing: 0.04em; }

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

.key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 21px;
  border: var(--line) solid var(--ink);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s linear, color 0.12s linear, border-color 0.12s linear;
}
.key:hover:not([aria-disabled="true"]):not(:disabled) { background: var(--ink); color: #0a0a0a; }
.key:active:not([aria-disabled="true"]):not(:disabled) { transform: translateY(1px); }
.key--primary { background: var(--ink); color: #0a0a0a; }
.key--primary:hover:not([aria-disabled="true"]):not(:disabled) { background: var(--paper); border-color: var(--paper); }
.key--teal { border-color: var(--teal); color: var(--teal); }
.key--teal:hover:not([aria-disabled="true"]) { background: var(--teal); color: #061110; }
.key[aria-disabled="true"], .key:disabled {
  border-color: var(--mute);
  color: var(--mute);
  cursor: not-allowed;
  opacity: 0.74;
}
.key__mark { height: 17px; width: auto; display: block; flex: 0 0 auto; }
.key[aria-disabled="true"] .key__mark { filter: grayscale(1); opacity: 0.74; }

/* ---- the input node ----------------------------------------------------- */

.field { display: flex; flex-wrap: wrap; gap: 12px; }
.field__in {
  flex: 1 1 320px;
  min-width: 0;
  min-height: 48px;
  border: var(--line) solid var(--ink);
  background: #060806;
  color: var(--paper);
  font: inherit;
  padding: 0 16px;
  letter-spacing: 0.01em;
}
.field__in::placeholder { color: var(--mute); }
.field__in:focus { outline: 2px solid var(--port); outline-offset: 0; }

.note { color: var(--paper-2); margin-top: 14px; }
.err { color: var(--red); margin-top: 14px; }

/* ---- the mascot node ---------------------------------------------------- */

/* his render is lit line on black: screen drops the black into the node's own fill.
   No filter, opacity or transform on any ancestor, or the blend stops working. */
.figure {
  display: block;
  width: 100%;
  height: auto;
  mix-blend-mode: screen;
}

/* ---- lists inside a node ------------------------------------------------ */

.stack { display: flex; flex-direction: column; gap: 14px; }
.lede { font-size: var(--t-value); line-height: 1.35; margin: 0 0 16px; }
.val + p, .lede + p { margin-top: 0; }
.num { font-variant-numeric: tabular-nums; }
.rule-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 14px; }
.rule-line > :last-child { margin-left: auto; }
.hr { height: var(--line); background: #20261a; margin: 16px 0; }

/* ---- dialog ------------------------------------------------------------- */

dialog {
  border: var(--line) solid var(--ink);
  background: var(--node);
  color: var(--paper);
  padding: 0;
  max-width: 620px;
  width: calc(100% - 48px);
}
dialog::backdrop { background: rgba(4, 4, 4, 0.86); }
.dlg__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: var(--line) solid var(--ink);
  padding: 0 20px 0 0;
  min-height: 48px;
}
.dlg__name {
  background: var(--ink);
  color: #0a0a0a;
  padding: 0 18px;
  display: flex;
  align-items: center;
  align-self: stretch;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.dlg__body { padding: 24px 28px 28px; }

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

@keyframes port-breathe {
  0%, 100% { box-shadow: 0 0 14px 3px rgba(255, 255, 255, 0.32); }
  50%      { box-shadow: 0 0 22px 6px rgba(255, 255, 255, 0.55); }
}
.node--threshold .node__port { animation: port-breathe 4.2s ease-in-out infinite; }

.is-busy .score__n { opacity: 0.45; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---- narrow: one column, the map becomes one run of nodes --------------- */

@media (max-width: 980px) {
  :root { --t-display: 64px; --gutter: 20px; }
  .node--score .node__body { padding: 42px 34px; }
  /* one run of nodes. The columns go to display:contents so every node is a flex item of the
     map and the phone can get the order it needs: the field, then the verdict, then the rest. */
  .map { display: flex; flex-direction: column; column-gap: 0; }
  .col { display: contents; }
  .node, .node--w86, .node--w72 { width: 100%; margin-top: 38px; }
  .col > .node:first-child { margin-top: 38px; }
  .node--threshold { width: auto; }
  .node--right .node__tab { justify-content: flex-start; }
  [data-node="input"], [data-node="connect"], [data-node="start"], [data-node="clock"] { order: -3; margin-top: 0; }
  [data-node="score"] { order: -2; }
  [data-node="subject"] { order: -1; }
  .bus__ports { flex-wrap: wrap; gap: 0 4%; }
  .bus__ports li { margin-left: 0 !important; }
  .bus__ports li:nth-child(n) { --drop: 16px; }
  .masthead__meta { margin-left: 0; width: 100%; }
  /* one column means no diagonals: the cables become one drop from each node to the next,
     in the same grammar, and the canvas stands down */
  .map__cables { display: none; }
  .node::before {
    content: "";
    position: absolute;
    left: calc(var(--port-w) / 2);
    top: -38px;
    width: var(--line);
    height: 38px;
    background: var(--ink-idle);
  }
  [data-node=input]::before, [data-node=connect]::before,
  [data-node=start]::before, [data-node=clock]::before { display: none; }
}

@media (max-width: 560px) {
  :root { --t-display: 56px; --node-pad-x: 22px; --node-pad-y: 16px; }
  .node--score .node__body { padding: 38px 34px; }
  .rows { grid-template-columns: 100%; gap: 4px 0; }
  .rows dd { margin-bottom: 10px; }
  .rows dd:last-child { margin-bottom: 0; }
  .keys .key { flex: 1 1 100%; }
}

@media (max-width: 380px) {
  :root { --t-display: 48px; --gutter: 16px; }
  .node--score .node__body { padding: 34px 34px; }
  .rule-line > :last-child { margin-left: 0; }
}

@media (min-width: 1500px) {
  :root { --page: 1280px; }
}

/* ---- helpers ------------------------------------------------------------ */

.contents { display: contents; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

/* a class rule beats the user agent's [hidden], so say it here or a hidden key stays on screen */
[hidden] { display: none !important; }

/* a key that cannot be pressed is still text: the primary key keeps a dark label on a dimmed
   fill (5.4:1) instead of going grey on lime (2.5:1) */
.key--primary[aria-disabled="true"],
.key--primary:disabled {
  background: var(--ink-idle);
  border-color: var(--ink-idle);
  color: #0a0a0a;
  opacity: 1;
}
