/* Leech: one dossier sheet on black cloth. Printed dotted rules, line-screen pictures, white ink, red only for blood. */
:root {
  --ground: #060606;
  --ink: #e8e7e0;
  --dim: #9a9993;
  --faint: #5d5c58;
  --blood: #e0241d;
  --blood-deep: #7d0f0c;
  --face: "Courier Prime", "Courier New", monospace;
  --code: "Share Tech Mono", "Courier Prime", monospace;
  --rule: 3px;
  --pad: 28px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { background: var(--ground) url(/img/grain.png); }
body {
  margin: 0; min-height: 100vh; color: var(--ink); font: 400 17px/1.45 var(--face);
  font-synthesis: none; -webkit-font-smoothing: antialiased; padding: 28px 16px 40px;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
::selection { background: var(--blood); color: var(--ink); }
[hidden] { display: none !important; }

/* the sheet: one frame, cells separated by the same printed rule */
.sheet {
  max-width: 1200px; margin: 0 auto;
  display: grid; grid-template-columns: 230px minmax(0, 0.92fr) minmax(0, 1fr);
  grid-template-areas: "bar bar bar" "main main side" "print list list";
  border: var(--rule) solid transparent; border-image: url(/img/rule.png) 3 round;
}
.cell, .bar { border: var(--rule) solid transparent; border-image: url(/img/rule.png) 3 round; margin: -1.5px; }

.bar { grid-area: bar; display: flex; align-items: center; gap: 28px; padding: 16px var(--pad); min-height: 84px; }
.code { font: 400 34px/1 var(--code); letter-spacing: 0.02em; text-decoration: none; white-space: nowrap; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-right: auto; font: 400 16px/1 var(--code); text-transform: uppercase; }
.tabs a { text-decoration: none; color: var(--dim); padding: 8px 2px; }
.tabs a b { font-weight: 400; color: var(--faint); margin-right: 4px; }
.tabs a:hover, .tabs a[aria-current="page"] { color: var(--ink); }
.tabs a[aria-current="page"] b { color: var(--blood); }
.meter { display: flex; align-items: center; gap: 12px; font: 400 22px/1 var(--code); white-space: nowrap; }
.meter-cells { display: inline-flex; gap: 3px; padding: 5px; border: 2px solid var(--ink); position: relative; }
.meter-cells::after { content: ""; position: absolute; right: -7px; top: 30%; height: 40%; width: 4px; background: var(--ink); }
.meter-cells i { width: 7px; height: 20px; background: var(--ink); opacity: 0.15; }
.meter-cells i.on { opacity: 1; }
.meter-cells i.hot { background: var(--blood); opacity: 1; }

.cell-main { grid-area: main; position: relative; min-height: 560px; padding: 0; overflow: hidden; }
.cell-side { grid-area: side; padding: 26px var(--pad) 30px; display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.cell-print { grid-area: print; padding: 20px 18px; display: flex; flex-direction: column; gap: 14px; }
.cell-list { grid-area: list; padding: 22px var(--pad) 30px; min-width: 0; }

/* the pond canvas and what sits over it */
.pond { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.pond-over { position: absolute; inset: 0; pointer-events: none; }
.pond-over > * { pointer-events: auto; }
.pond-head { position: absolute; left: 18px; right: 18px; top: 14px; display: flex; justify-content: space-between; align-items: center; gap: 12px; font: 400 15px/1.2 var(--code); text-transform: uppercase; pointer-events: none; }
.pond-head span { background: var(--ground); padding: 4px 8px; }
.pond-empty { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(80%, 420px); text-align: center; background: var(--ground); padding: 18px 20px; font-size: 16px; }
.pond-empty p { margin: 0 0 12px; }
.pond-label { position: absolute; transform: translate(-50%, 0); text-align: center; text-decoration: none; background: var(--ground); padding: 3px 8px; font: 400 14px/1.25 var(--code); white-space: nowrap; }
.pond-label b { font-weight: 400; font-size: 17px; display: block; }
.pond-label:hover b, .pond-label:focus-visible b { color: var(--blood); }
.pond-tip { position: absolute; z-index: 3; pointer-events: none; background: var(--ground); border: 1px solid var(--ink); padding: 8px 10px; font: 400 14px/1.35 var(--code); white-space: nowrap; }

/* right column: the reference's logged line, > rows, warnings, the parenthesis */
.logged { text-align: center; font: 400 19px/1.25 var(--code); text-transform: uppercase; letter-spacing: 0.04em; padding-bottom: 18px; margin: 0 calc(-1 * var(--pad)); border-bottom: var(--rule) solid transparent; border-image: url(/img/rule.png) 3 round; }
.logged .big { display: block; font-size: clamp(40px, 5vw, 60px); line-height: 1.05; margin-top: 8px; letter-spacing: 0; }
.logged .big small { font-size: 0.45em; color: var(--dim); }
.rows { list-style: none; margin: 0; padding: 0; font: 400 22px/1.55 var(--code); }
.rows li::before { content: ">  "; white-space: pre; }
.rows li { overflow-wrap: anywhere; }
.rows b { font-weight: 400; color: var(--ink); }
.rows .soft { color: var(--dim); }
.warn { font: 400 22px/1.35 var(--code); text-transform: uppercase; margin: 0; min-height: 2.7em; }
.warn p { margin: 0; overflow-wrap: anywhere; }
.warn .red { color: var(--blood); }
.warn .quiet { color: var(--dim); }
.note { font: 400 22px/1.4 var(--code); margin: 0; }
.dim { color: var(--dim); }

/* bottom left: the print (the bite) and the digit column */
.print { aspect-ratio: 3 / 4; background: #000 center / cover no-repeat; position: relative; overflow: hidden; }
.print canvas, .print img { width: 100%; height: 100%; object-fit: cover; display: block; }
.digits { list-style: none; margin: 0 -18px -20px; padding: 0; font: 400 32px/1.2 var(--code); letter-spacing: 0.01em; }
.digits li { padding: 1px 12px; border-top: var(--rule) solid transparent; border-image: url(/img/rule.png) 3 round; font-variant-numeric: tabular-nums; }
.digits li.new { color: var(--blood); }
.digits-cap { font: 400 13px/1.3 var(--code); color: var(--dim); text-transform: uppercase; margin: 0; }

/* bottom right: entries like the reference's list of roles */
.entries { margin: 0; }
.entry { margin: 0 0 18px; }
.entry dt { font: 400 17px/1.3 var(--code); text-transform: uppercase; letter-spacing: 0.03em; }
.entry dd { margin: 3px 0 0 22px; }
.entry dd::before { content: "> "; margin-left: -18px; }
.entry dd.plain::before { content: none; }
.entry a[data-link] { text-decoration: none; }
.entry dt a[data-link]:hover, .entry dt a[data-link]:focus-visible { color: var(--blood); }

/* keys: a bracketed printed key, the whole key moves on press */
.key {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 46px; padding: 10px 20px;
  background: var(--ground); border: 2px solid var(--ink); cursor: pointer; text-decoration: none; text-transform: uppercase;
  font: 400 18px/1 var(--code); letter-spacing: 0.04em; transition: transform 80ms ease, background 120ms;
}
.key:hover { background: #151514; }
.key:active { transform: translateY(2px); }
.key.solid { background: var(--ink); color: var(--ground); }
.key.solid:hover { background: #fff; }
.key.blood { background: var(--blood); border-color: var(--blood); color: #fff; }
.key.blood:hover { background: #f0352d; }
.key[disabled], .key[aria-disabled="true"] { opacity: 0.42; cursor: not-allowed; transform: none; }
.key img { width: 20px; height: 20px; object-fit: contain; }
.keys { display: flex; flex-wrap: wrap; gap: 10px; }

/* the $LEECH entry: the contract as a printed line */
.ca { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 8px 0 12px; }
.ca code { font: 400 16px/1.35 var(--code); overflow-wrap: anywhere; user-select: all; padding: 6px 10px; border: 1px dashed var(--faint); flex: 1 1 260px; }
.ca code.none { color: var(--dim); user-select: none; }

/* forms: underlined typewriter fields */
.field { display: grid; gap: 6px; }
.field label, .field .lab { font: 400 14px/1.2 var(--code); text-transform: uppercase; color: var(--dim); letter-spacing: 0.05em; }
.field input[type="text"], .field input[type="number"], .field input[inputmode] {
  width: 100%; background: transparent; border: 0; border-bottom: 2px solid var(--ink); padding: 8px 2px; font: 400 24px/1.2 var(--code); border-radius: 0;
}
.field input::placeholder { color: var(--faint); }
.field input:focus { outline: none; border-bottom-color: var(--blood); }
.seg { display: flex; gap: 0; }
.seg button { flex: 1; min-height: 46px; background: transparent; border: 2px solid var(--ink); margin-left: -2px; cursor: pointer; font: 400 18px/1 var(--code); text-transform: uppercase; }
.seg button:first-child { margin-left: 0; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--ground); }
.calc { font: 400 17px/1.45 var(--code); color: var(--dim); margin: 0; }
.calc b { color: var(--ink); font-weight: 400; }
.calc .red { color: var(--blood); }
.trade { display: grid; gap: 14px; }
.row2 { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.small { font-size: 14px; }
.drop-in { border: 2px dashed var(--faint); min-height: 120px; display: grid; place-items: center; text-align: center; cursor: pointer; padding: 12px; font: 400 15px/1.3 var(--code); color: var(--dim); position: relative; overflow: hidden; }
.drop-in.over { border-color: var(--ink); color: var(--ink); }
.drop-in canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.drop-in input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* tables for top and my blood */
.tbl { width: 100%; border-collapse: collapse; font: 400 17px/1.35 var(--code); }
.tbl th { text-align: left; font-weight: 400; font-size: 13px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.05em; padding: 6px 8px 8px 0; }
.tbl td { padding: 8px 8px 8px 0; border-top: 1px dashed var(--faint); vertical-align: top; }
.tbl td.n, .tbl th.n { text-align: right; font-variant-numeric: tabular-nums; }
.tbl a { text-decoration: none; }
.tbl a:hover { color: var(--blood); }
.scroll { overflow: auto; max-height: 100%; }

/* how: four prints */
.four { position: absolute; inset: 0; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.four figure { margin: 0; position: relative; overflow: hidden; border: 1px solid #000; }
.four img { width: 100%; height: 100%; object-fit: cover; display: block; }
.four figcaption { position: absolute; left: 10px; bottom: 10px; right: 10px; background: var(--ground); padding: 7px 10px; font: 400 15px/1.3 var(--code); }
.four figcaption b { font-weight: 400; color: var(--blood); margin-right: 8px; }

.chart { width: 100%; height: 150px; display: block; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--ink); color: var(--ground); font: 400 16px/1.3 var(--code); padding: 10px 16px; opacity: 0; pointer-events: none; transition: opacity 160ms; max-width: calc(100vw - 32px); z-index: 20; }
.toast.on { opacity: 1; }
.toast.bad { background: var(--blood); color: #fff; }

@media (max-width: 1080px) {
  .sheet { grid-template-columns: 200px minmax(0, 1fr); grid-template-areas: "bar bar" "main main" "side side" "print list"; }
  .cell-main { min-height: 480px; }
}
@media (max-width: 720px) {
  body { padding: 12px 10px 28px; font-size: 16px; }
  :root { --pad: 18px; }
  .sheet { grid-template-columns: minmax(0, 1fr); grid-template-areas: "bar" "main" "side" "list" "print"; }
  .bar { flex-wrap: wrap; gap: 12px 18px; padding: 14px var(--pad); }
  .code { font-size: 26px; }
  .tabs { order: 3; width: 100%; gap: 2px 14px; font-size: 15px; }
  .meter { margin-left: auto; font-size: 18px; }
  .meter-cells i { width: 5px; height: 16px; }
  .cell-main { min-height: 360px; }
  .rows, .warn, .note { font-size: 19px; }
  .cell-print { flex-direction: row; gap: 14px; }
  .print { width: 42%; flex: none; }
  .digits { margin: 0; font-size: 22px; flex: 1; }
  .digits li:first-child { border-top: 0; }
  .four figcaption { font-size: 13px; left: 6px; right: 6px; bottom: 6px; padding: 5px 7px; }
}
@media (prefers-reduced-motion: reduce) { .key { transition: none; } }

/* pixel pictures stay pixel */
.four img, .print img, .print canvas, .drop-in canvas { image-rendering: pixelated; }
.four figure { background: #0b0b0b; }
.four img { object-fit: contain; }

/* docs */
.doc { max-width: 78ch; }
.doc h2 { font: 400 20px/1.3 var(--code); text-transform: uppercase; letter-spacing: 0.04em; margin: 34px 0 10px; scroll-margin-top: 20px; }
.doc h2:first-child { margin-top: 0; }
.doc h2 b { color: var(--blood); font-weight: 400; margin-right: 10px; }
.doc p, .doc li { margin: 0 0 10px; }
.doc ul { padding-left: 22px; margin: 0 0 12px; }
.doc code { font: 400 15px/1.3 var(--code); overflow-wrap: anywhere; }
.doc .tbl { margin: 6px 0 16px; }
.toc { position: absolute; inset: 0; padding: 26px 28px; overflow: auto; }
.toc ol { list-style: none; margin: 0; padding: 0; font: 400 22px/1.6 var(--code); }
.toc a { text-decoration: none; }
.toc a b { color: var(--faint); font-weight: 400; margin-right: 12px; }
.toc a:hover, .toc a:focus-visible { color: var(--blood); }

/* no picture is ever cropped: whole image, caption under it, never over it */
.four figure { display: flex; flex-direction: column; min-height: 0; }
.four img { flex: 1 1 auto; min-height: 0; width: 100%; height: auto; object-fit: contain; padding: 10px 10px 0; }
.four figcaption { position: static; margin: 8px 10px 10px; }
.print { background: #0b0b0b; }
.print img, .print canvas { object-fit: contain; }
.four { position: relative; inset: auto; grid-template-rows: auto auto; height: 100%; }
.four figure { aspect-ratio: 1 / 1.08; }
.tbl-wrap { overflow-x: auto; max-width: 100%; }
.doc code { word-break: break-all; }
@media (max-width: 420px) { .doc .tbl { font-size: 14px; } .doc .tbl th { font-size: 11px; } .entry dd { margin-left: 16px; } }

.pond-label { font-size: 12px; padding: 2px 6px; max-width: 124px; overflow: hidden; text-overflow: ellipsis; }
.pond-label b { font-size: 15px; }

/* phones: the swamp needs height for every pond, a coin's pond is a square */
@media (max-width: 720px) {
  .sheet[data-page="swamp"] .cell-main { min-height: 680px; }
  .sheet[data-page="coin"] .cell-main, .sheet[data-page="launch"] .cell-main, .sheet[data-page="me"] .cell-main { min-height: 0; aspect-ratio: 1 / 1.05; }
  .pond-head { font-size: 13px; left: 10px; right: 10px; top: 10px; }
}
@media (max-width: 720px) {
  .trade .keys .key, .trade #act .key { width: 100%; }
  .chart { height: 130px; }
}
.logged { padding-left: 14px; padding-right: 14px; }
.top-list { position: absolute; inset: 0; padding: 22px 28px; overflow: auto; }
@media (max-width: 720px) {
  .sheet[data-page="top"] .cell-main, .sheet[data-page="docs"] .cell-main, .sheet[data-page="how"] .cell-main { min-height: 0; }
  .top-list, .toc { position: static; padding: 18px; }
}
@media (max-width: 480px) {
  .tbl.stack thead { display: none; }
  .tbl.stack, .tbl.stack tbody { display: block; width: 100%; }
  .tbl.stack tr { display: block; border-top: 1px dashed var(--faint); padding: 8px 0; }
  .tbl.stack td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 2px 0; text-align: right; }
  .tbl.stack td[data-label]::before { content: attr(data-label); color: var(--dim); font-size: 12px; text-transform: uppercase; text-align: left; }
  .tbl.stack td[colspan] { display: block; text-align: left; }
  .tbl-wrap { overflow-x: visible; }
}
.digits li { white-space: nowrap; overflow: hidden; }
@media (max-width: 720px) {
  .cell-print { align-items: center; }
  .print { align-self: center; }
}
@media (max-width: 380px) {
  .digits { font-size: 17px; }
  .digits li { padding: 1px 8px; }
  .print { width: 38%; }
}

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
