/* Cure Coins v2. A lab bench: a pale grey bench, white instrument panels on it, hairlines inside
   them, one medical teal. The panels and the keys are Codex renders worn as nine-slices
   (img/panel.png, img/pill-*.png); the lenses, slide, tubes and objects are Codex renders too.
   CSS draws text, hairlines, focus rings and nothing else. */

@font-face {
  font-family: "Instrument Sans";
  src: url("/fonts/InstrumentSans.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: "Martian Mono";
  src: url("/fonts/MartianMono-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Martian Mono";
  src: url("/fonts/MartianMono-500.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

:root {
  --bench: #eef2f2;
  --paper: #fbfcfb;
  --ink: #0f2221;
  --ink-2: #4a5f5d;
  --ink-3: #6f8282;
  --line: #e1e8e7;
  --line-2: #c9d6d4;
  --teal: #0b8f87;
  --teal-ink: #07706a;
  --teal-wash: #e6f3f1;
  --bad: #9a3a2a;
  --sans: "Instrument Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "Martian Mono", ui-monospace, Consolas, monospace;
  --gut: clamp(12px, 2.4vw, 32px);
  --max: 1440px;
  --gap: clamp(12px, 1.6vw, 20px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bench); color: var(--ink); font: 400 16px/1.55 var(--sans); font-synthesis: none; overflow-x: hidden; }
img { max-width: 100%; display: block; }
a { color: var(--teal-ink); text-underline-offset: 3px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; border-radius: 6px; }
main { display: block; outline: none; }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.015em; margin: 0; text-wrap: balance; line-height: 1.08; }
p { margin: 0 0 0.8em; }
code, .mono { font-family: var(--mono); font-size: 0.86em; overflow-wrap: anywhere; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--paper); padding: 8px 12px; }
.skip:focus { top: 12px; }
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 var(--gut); }
.kicker { font: 500 11px/1.4 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--teal-ink); margin: 0 0 12px; }
.lead { font-size: clamp(16px, 1.15vw, 18px); color: var(--ink-2); max-width: 40em; }
.muted { color: var(--ink-3); }
.fine { font-size: 13px; color: var(--ink-3); }
.label-s { font: 500 10.5px/1.3 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }

/* ---------------------------------------------------------------- the instrument panel */
.panel {
  position: relative;
  border-style: solid;
  border-width: 0;
  border-image: url("/img/panel.png") 40 fill / 14px stretch;
  min-width: 0;
}
.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 20px;
  flex-wrap: wrap;
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--line);
}
.panel__head h2, .panel__head h3 { font-size: 15px; letter-spacing: 0; }
.panel__body { padding: 20px; }
.panel__foot { padding: 14px 20px; border-top: 1px solid var(--line); }

/* ---------------------------------------------------------------- the nosepiece: a window, five cells */
.nose { max-width: var(--max); margin: 14px auto 0; padding: 0 var(--gut); position: relative; z-index: 5; }
.nose__panel { display: flex; align-items: stretch; }
.nose__brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: 12px 22px;
  min-width: 190px;
  text-decoration: none;
  color: var(--ink);
  border-right: 1px solid var(--line);
}
.nose__brand b { font: 600 19px/1.1 var(--sans); letter-spacing: -0.01em; }
.nose__brand span { font: 500 11px/1.2 var(--mono); color: var(--teal-ink); letter-spacing: 0.08em; }
.nose__row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); flex: 1; }
.nose__status { display: flex; flex-direction: column; justify-content: center; padding: 10px 22px; border-left: 1px solid var(--line); min-width: 210px; }
.nose__status b { font: 500 13px/1.3 var(--mono); color: var(--ink); }
.lens {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px 14px;
  text-decoration: none;
  color: var(--ink-2);
  border-left: 1px solid var(--line);
}
.lens:first-child { border-left: 0; }
.lens__glass { width: 26px; height: 44px; overflow: visible; display: flex; align-items: flex-end; justify-content: center; flex: none; transition: transform 220ms cubic-bezier(.2, .8, .2, 1); }
.lens__glass img { height: calc(var(--h) * 0.48); width: auto; }
.lens__text { display: flex; flex-direction: column; min-width: 0; }
.lens__mag { font: 500 10.5px/1.2 var(--mono); color: var(--ink-3); }
.lens__word { font: 600 15px/1.25 var(--sans); color: var(--ink); white-space: nowrap; }
.lens:hover .lens__glass { transform: translateY(2px); }
.lens[aria-current="page"] .lens__glass { transform: translateY(3px); }
.lens[aria-current="page"] .lens__mag, .lens[aria-current="page"] .lens__word { color: var(--teal-ink); }
.lens[aria-current="page"]::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: 6px; height: 3px; border-radius: 2px; background: var(--teal); }

/* ---------------------------------------------------------------- keys (nine-sliced pills) */
.key {
  --kh: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  height: var(--kh);
  padding: 0 calc(var(--kh) * 0.55);
  border: 0 solid transparent;
  border-image: url("/img/pill-white.png") 79 80 fill / calc(var(--kh) / 2) calc(var(--kh) / 2) stretch;
  background: none;
  color: var(--ink);
  font: 600 15px/1 var(--sans);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 110ms ease, filter 110ms ease;
  -webkit-tap-highlight-color: transparent;
}
.key--teal { border-image-source: url("/img/pill-teal.png"); color: #fff; }
.key:hover { filter: brightness(1.04); color: var(--ink); }
.key--teal:hover { color: #fff; }
.key:active { transform: translateY(1px) scale(0.985); }
.key[aria-disabled="true"], .key:disabled { opacity: 0.45; cursor: not-allowed; transform: none; filter: grayscale(0.6); }
.key__mark { width: 18px; height: 18px; object-fit: contain; }
.key--small { --kh: 38px; font-size: 13.5px; }
.key--icon { padding: 0; width: calc(var(--kh) * 1.5); }
.keys { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.textlink { font: 500 14px/1.4 var(--sans); background: none; border: 0; padding: 0; cursor: pointer; color: var(--teal-ink); text-decoration: underline; text-underline-offset: 3px; }

/* ---------------------------------------------------------------- the home: premise + instrument */
.home { display: grid; grid-template-columns: minmax(330px, 4fr) minmax(0, 8fr); gap: var(--gap); margin-top: var(--gap); align-items: stretch; }
.premise .panel__body { display: flex; flex-direction: column; height: 100%; padding: 28px 28px 24px; }
.premise h1 { font-size: clamp(32px, 2.8vw, 46px); margin-bottom: 16px; }
.premise .lead { font-size: 16px; }
.premise .keys { margin: 6px 0 0; }
.premise__coin { margin-top: auto; padding-top: 24px; }

.instrument { display: flex; flex-direction: column; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 12.5px; color: var(--ink-3); }
.legend b { font-weight: 500; color: var(--ink-2); }
.stage { position: relative; flex: 1; min-height: clamp(320px, 36vw, 540px); }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: pan-y; }
.tags { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.tag { position: absolute; transform: translate(-50%, 0); display: flex; gap: 6px; align-items: baseline; white-space: nowrap; }
.tag__well { font: 500 10px/1 var(--mono); color: var(--ink-3); }
.tag__sym { font: 600 12.5px/1.2 var(--sans); color: var(--ink); }
.tag[data-on] .tag__sym { color: var(--teal-ink); }

/* the inspector: the selected well, in a row under the plate */
.inspect { display: grid; grid-template-columns: minmax(220px, 2fr) repeat(4, minmax(0, 1fr)) auto; align-items: center; border-top: 1px solid var(--line); }
.inspect > div { padding: 14px 18px; border-left: 1px solid var(--line); min-width: 0; }
.inspect > div:first-child { border-left: 0; }
.inspect__n { display: block; font: 500 15px/1.35 var(--mono); color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inspect__who { display: block; font: 600 17px/1.3 var(--sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inspect--empty { grid-template-columns: 1fr auto; }

/* the $CURE slide inside the premise panel */
.slide { border-top: 1px solid var(--line); padding-top: 18px; }
.slide__glass { position: relative; aspect-ratio: 1400 / 458; background: url("/img/slide.jpg") center / 100% 100% no-repeat; display: grid; grid-template-columns: 26% 1fr; }
.slide__label { display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 6% 3% 6% 8%; }
.slide__tk { font: 500 clamp(13px, 1.1vw, 16px)/1.1 var(--mono); color: var(--ink); }
.slide__nm { font-size: 10.5px; color: var(--ink-3); margin-top: 4px; }
.slide__body { display: flex; flex-direction: column; justify-content: center; padding: 5% 7% 5% 5%; min-width: 0; }
.slide__ca { font: 400 11.5px/1.5 var(--mono); color: var(--ink); word-break: break-all; user-select: all; margin: 0; }
.slide__ca--none { color: var(--ink-3); user-select: none; font-family: var(--sans); font-size: 13px; word-break: normal; }
.slide__keys { margin-top: 12px; }
.slide__why { font-size: 12.5px; color: var(--ink-3); margin: 10px 0 0; }

/* ---------------------------------------------------------------- reports */
.section { margin-top: var(--gap); }
.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.figures > div { padding: 16px 20px; border-left: 1px solid var(--line); }
.figures > div:first-child { border-left: 0; }
.fig__n { display: block; font: 500 21px/1.2 var(--mono); color: var(--ink); }
.fig__l { display: block; font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.report { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.report th { text-align: left; font: 500 10.5px/1.3 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); padding: 12px 14px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.report td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.report tr:last-child td { border-bottom: 0; }
.report th:first-child, .report td:first-child { padding-left: 20px; }
.report th:last-child, .report td:last-child { padding-right: 20px; }
.report td.n, .report th.n { text-align: right; font-family: var(--mono); font-size: 13px; white-space: nowrap; }
.report tr[data-href] { cursor: pointer; }
.report tr[data-href]:hover td { background: var(--teal-wash); }
.report .coin { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.report .coin img { width: 30px; height: 30px; object-fit: cover; border-radius: 6px; flex: none; }
.report .coin b { font-weight: 600; }
.report .coin span span { color: var(--ink-3); font-size: 13px; }
.place { font: 500 12px var(--mono); color: var(--teal-ink); }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.empty { padding: 22px 20px; color: var(--ink-2); margin: 0; }
.page-head { margin: calc(var(--gap) + 10px) 0 var(--gap); padding: 0 6px; }
.page-head h1 { font-size: clamp(28px, 2.6vw, 42px); margin-bottom: 10px; }

/* ---------------------------------------------------------------- the coin page */
.specimen { display: grid; grid-template-columns: minmax(0, 7fr) minmax(320px, 5fr); gap: var(--gap); margin-top: var(--gap); align-items: start; }
.viewer { position: relative; aspect-ratio: 4 / 3; width: 100%; }
.viewer canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; touch-action: none; cursor: grab; }
.coinhead { display: flex; gap: 14px; align-items: center; }
.coinhead img { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; }
.coinhead h1 { font-size: clamp(26px, 2.3vw, 36px); }
.facts { display: grid; grid-template-columns: auto 1fr; margin: 0; }
.facts dt, .facts dd { padding: 10px 0; border-bottom: 1px solid var(--line); margin: 0; }
.facts dt { color: var(--ink-3); font-size: 13.5px; padding-right: 16px; }
.facts dd { font-family: var(--mono); font-size: 13px; text-align: right; }
.facts dt:last-of-type, .facts dd:last-of-type { border-bottom: 0; }
.warn { color: var(--bad); }
.chart { width: 100%; height: 220px; display: block; }
.log td:first-child { white-space: nowrap; color: var(--ink-3); font-size: 13px; }

/* ---------------------------------------------------------------- prepare */
.prep { display: grid; grid-template-columns: minmax(0, 8fr) minmax(300px, 4fr); gap: var(--gap); margin-top: var(--gap); align-items: start; }
.rack { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 0; margin: 0; padding: 0; border: 0; }
.rack legend { padding: 0; margin-bottom: 12px; }
.tube { position: relative; display: flex; flex-direction: column; align-items: center; cursor: pointer; padding: 10px 2px 12px; border-radius: 10px; }
.tube input { position: absolute; opacity: 0; inset: 0; cursor: pointer; margin: 0; }
.tube img { height: 104px; width: auto; transition: transform 200ms ease; }
.tube__full { display: none; }
.tube input:checked ~ .tube__full { display: block; }
.tube input:checked ~ .tube__empty { display: none; }
.tube:has(input:checked) { background: var(--teal-wash); }
.tube input:checked ~ .tube__name { color: var(--teal-ink); font-weight: 600; }
.tube:hover img { transform: translateY(-3px); }
.tube:has(input:focus-visible) { outline: 3px solid var(--teal); outline-offset: -3px; }
.tube__name { font-size: 12.5px; text-align: center; margin-top: 8px; line-height: 1.2; min-height: 2.4em; }
.field { display: block; margin: 0 0 18px; }
.field > span { display: block; margin-bottom: 6px; }
.field input[type="text"], .field input[type="number"], .field textarea {
  width: 100%;
  font: 400 16px/1.4 var(--sans);
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1.5px solid var(--line-2);
  padding: 8px 0;
  border-radius: 0;
}
.field textarea { resize: vertical; min-height: 60px; }
.field input:focus, .field textarea:focus { outline: none; border-bottom-color: var(--teal); }
.field small { display: block; color: var(--ink-3); font-size: 12.5px; margin-top: 5px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.file { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.file small { margin: 0; }
.file .key:has(input:focus-visible) { outline: 3px solid var(--teal); outline-offset: 2px; }
.status { min-height: 1.5em; font: 400 13px/1.5 var(--mono); color: var(--teal-ink); margin: 12px 0 0; }
.split { display: grid; grid-template-columns: 70fr 15fr 15fr; gap: 3px; margin: 6px 0 14px; }
.split div { padding: 8px 0 0; border-top: 4px solid var(--teal); font-size: 12.5px; color: var(--ink-3); }
.split div:nth-child(2) { border-top-color: var(--line-2); }
.split div:nth-child(3) { border-top-color: var(--ink); }
.split b { display: block; font: 500 15px var(--mono); color: var(--ink); }

/* ---------------------------------------------------------------- method */
.steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.step { padding: 22px; border-left: 1px solid var(--line); }
.step:first-child { border-left: 0; }
.step__pic { height: 170px; display: flex; align-items: flex-end; justify-content: center; margin-bottom: 16px; }
.step__pic img { max-height: 170px; width: auto; }
.step h3 { font-size: 18px; margin: 4px 0 8px; }
.step p { font-size: 14.5px; color: var(--ink-2); }
.notes { max-width: 820px; }
.notes h3 { font-size: 17px; margin: 22px 0 6px; }
.notes p { color: var(--ink-2); }
.risk { margin-top: 28px; font-size: 12.5px; color: var(--ink-3); }

.foot-space { height: clamp(40px, 6vw, 80px); }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 60; background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 8px; font-size: 14px; max-width: calc(100vw - 32px); }
.toast--bad { background: var(--bad); }

/* ---------------------------------------------------------------- narrower */
@media (max-width: 1320px) {
  .nose__status { display: none; }
  .lens { padding: 10px 12px; gap: 8px; }
}
@media (max-width: 1100px) {
  .home { grid-template-columns: 1fr; }
  .specimen, .prep { grid-template-columns: 1fr; }
  .specimen > section:last-child { order: -1; }
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .step:nth-child(3) { border-left: 0; }
  .step:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .inspect { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .inspect > div:nth-child(4) { border-left: 0; }
  .inspect > div:nth-child(n + 4) { border-top: 1px solid var(--line); }
}
@media (max-width: 860px) {
  .nose__panel { flex-direction: column; }
  .nose__brand { border-right: 0; border-bottom: 1px solid var(--line); flex-direction: row; align-items: baseline; gap: 10px; padding: 10px 16px; min-width: 0; }
  .lens { flex-direction: column; gap: 4px; padding: 8px 2px 12px; text-align: center; align-items: center; }
  .lens__text { align-items: center; }
  .lens__glass { height: 40px; }
  .lens__word { font-size: 12px; }
  .lens__mag { font-size: 9.5px; }
  .lens[aria-current="page"]::after { left: 20%; right: 20%; }
}
@media (max-width: 640px) {
  .figures { grid-template-columns: 1fr 1fr; }
  .figures > div:nth-child(3) { border-left: 0; }
  .figures > div:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .rack { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .pair { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; }
  .step { border-left: 0 !important; border-top: 1px solid var(--line); }
  .step:first-child { border-top: 0; }
  .report th, .report td { padding: 10px 8px; }
  .hide-s { display: none; }
  .report .coin span span { display: none; }
  .premise h1 { font-size: 30px; }
  .tag__well { display: none; }
  .tag__sym { font-size: 11px; }
  .inspect { grid-template-columns: 1fr 1fr; }
  .inspect > div { border-left: 0 !important; border-top: 1px solid var(--line); }
  .inspect > div:nth-child(odd) { border-left: 1px solid var(--line) !important; }
  .inspect > div:first-child { grid-column: 1 / -1; border-top: 0; border-left: 0 !important; }
  .premise .panel__body { padding: 20px; }
  .panel__head, .panel__body { padding-left: 16px; padding-right: 16px; }
}
@media (max-width: 360px) {
  .lens__word { font-size: 10.5px; }
  .key { font-size: 13.5px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
