/* A worksheet on the left, the page it writes on the right. The page is ruled
   paper with exactly as many lines as the file is allowed to have. */

/* One dark appearance, whatever the system prefers. The names follow the
   Astryx token vocabulary (role first, then step); the short names under them
   are what the older page styles were written against. */
@font-face { font-family: "Instrument Serif"; src: url("../fonts/instrument-serif-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Instrument Serif"; src: url("../fonts/instrument-serif-latin-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("../fonts/jetbrains-mono-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("../fonts/jetbrains-mono-latin-500-normal.woff2") format("woff2"); font-weight: 500 700; font-style: normal; font-display: swap; }

:root {
  /* Surfaces: midnight, and two steps up from it. */
  --color-background-body: #02070a;
  --color-background-surface: #0a1319;
  --color-background-raised: #111d26;
  --color-border: #1f2c37;
  --color-border-strong: #3a4b59;
  /* Content. */
  --color-content-primary: #f4f1ea;
  --color-content-secondary: #a3b1bd;
  --color-content-tertiary: #7b8c99;
  /* One accent, for the thing to press. */
  --color-accent: #fc734d;
  --color-accent-hover: #ff8b69;
  --color-accent-content: #1b0a04;
  /* Light, not a colour to press: glows, focus, the selected edge. */
  --color-glow: #0297de;
  --color-status-positive: #5fd39a;
  --color-status-caution: #f2c14e;
  --color-status-negative: #ff8a7a;

  --radius-element: 10px;
  --radius-container: 18px;
  --radius-pill: 999px;
  --size-element-md: 2.75rem;
  --duration-fast: 120ms;
  --duration-slow: 420ms;
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --shadow-raised: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 24px 60px -30px rgba(0, 0, 0, 0.9);

  --font-display: "Instrument Serif", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-body: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  --font-code: "JetBrains Mono", "Cascadia Code", "SF Mono", ui-monospace, Consolas, monospace;

  --bg: var(--color-background-body);
  --ink: var(--color-content-primary);
  --quiet: var(--color-content-secondary);
  --hair: var(--color-border);
  --paper: var(--color-background-surface);
  --rule: #16222c;
  --margin: #8a3f2c;
  --ok: var(--color-status-positive);
  --mid: var(--color-status-caution);
  --bad: var(--color-status-negative);
  --bad-wash: #3a1b16;
  --focus: var(--color-glow);
  --screen: #000;
  --screen-ink: var(--color-content-primary);
  --row: 1.375rem;
  --sans: var(--font-body);
  --mono: var(--font-code);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 1rem/1.5 var(--sans);
}

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

a { color: inherit; text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: 1rem;
  top: -3rem;
  padding: 0.5rem 0.9rem;
  background: var(--ink);
  color: var(--bg);
  z-index: 10;
}
.skip:focus { top: 0.75rem; }

/* Page title on views that open with one (Home, Log a play, Rules). */
.page-title {
  margin: 0 0 1rem;
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  max-width: 38rem;
}
@media (max-width: 62rem) { .page-title { font-size: 1.8rem; } }

/* Secondary action: underlined ink text, no box. */
.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}
.link-button:hover { text-decoration-thickness: 2px; }
.link-button:disabled { opacity: 0.5; cursor: progress; }

/* Header */

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 2.5rem;
  padding: 1.25rem clamp(1rem, 4vw, 3rem) 1rem;
  border-bottom: 1px solid var(--hair);
}
.mark {
  font: 700 1.05rem var(--mono);
  letter-spacing: -0.01em;
  color: inherit;
  text-decoration: none;
}
.mark::before { content: "\25B6\00A0"; font-size: 0.8em; }
.top nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.75rem; }
.top nav a { white-space: nowrap; }
@media (max-width: 30rem) {
  .top nav { gap: 0.25rem 1.1rem; font-size: 0.95rem; }
}
.top nav a {
  color: var(--quiet);
  text-decoration: none;
  padding-bottom: 0.2rem;
  border-bottom: 2px solid transparent;
}
.top nav a:hover { color: var(--ink); }
.top nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }

main { padding: 2rem clamp(1rem, 4vw, 3rem) 5rem; }

/* Start: worksheet and page */

.start {
  display: grid;
  grid-template-columns: minmax(0, 30rem) minmax(0, 36rem);
  justify-content: space-between;
  gap: 2.5rem clamp(2rem, 6vw, 6rem);
  max-width: 78rem;
  margin: 0 auto;
}

.left { min-width: 0; }

/* The free-text box is a blank note; the worksheet below it is ruled blanks. */
.draft { margin-bottom: 3rem; padding-bottom: 1.5rem; border-bottom: 2px solid var(--ink); }
.draft label { margin-left: 0; }
.draft .idea { font-size: 1.35rem; font-weight: 650; letter-spacing: -0.01em; color: var(--ink); }
.draft .idea textarea {
  margin-top: 0.6rem;
  padding: 0.6rem 0.75rem;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  font-weight: 400;
  letter-spacing: 0;
  min-height: 5.5rem;
}
.draft .idea textarea:focus-visible { border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
.draft-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.25rem; }
.draft-row .primary { margin-top: 0; }
.draft-row .status { margin: 0; min-height: 0; }
/* Settings that stay folded until they are needed: the model, GitHub. */
.fold { margin-top: 1.1rem; }
.fold summary { cursor: pointer; color: var(--quiet); font-size: 0.9rem; width: fit-content; }
.fold summary span { color: var(--ink); }
.fold[open] summary { margin-bottom: 1rem; }
.fold label { margin-left: 0; }
.fold .tick { display: flex; align-items: center; gap: 0.5rem; color: var(--ink); cursor: pointer; }
.fold .tick input { width: auto; margin: 0; accent-color: var(--ink); }
.fold .quiet { margin: -0.4rem 0 1.1rem; }
.fold a { color: var(--ink); }
.github { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--hair); }
.github summary { color: var(--ink); font-size: 1rem; font-weight: 600; }
.github .primary { margin-top: 0.25rem; }
.github .status { margin-top: 0.75rem; }
.github .status a { color: inherit; }
code { font: 0.85em var(--mono); overflow-wrap: anywhere; }

/* Written by a model and not yet read by the person. */
[data-drafted] { border-bottom-style: dashed; border-bottom-color: var(--mid); }

.sheet { counter-reset: part; }
fieldset {
  border: 0;
  margin: 0 0 2.75rem;
  padding: 0;
  min-width: 0;
}
legend {
  counter-increment: part;
  padding: 0;
  margin-bottom: 0.75rem;
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}
legend::before {
  content: counter(part);
  display: inline-block;
  width: 2rem;
  font: 400 0.95rem var(--mono);
  color: var(--quiet);
}
label {
  display: block;
  margin: 0 0 1.1rem 2rem;
  color: var(--quiet);
  font-size: 0.9rem;
}
input, textarea, select {
  display: block;
  width: 100%;
  margin-top: 0.15rem;
  padding: 0.3rem 0;
  border: 0;
  border-bottom: 1.5px solid var(--ink);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: 1.05rem/1.45 var(--sans);
}
textarea { resize: vertical; field-sizing: content; min-height: 2.2rem; }
select { padding-right: 1rem; }
select option { background: var(--paper); color: var(--ink); }
input[type="file"] { border-bottom-style: dashed; font-size: 0.9rem; padding: 0.45rem 0; }
::placeholder { color: var(--quiet); opacity: 0.6; }
input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 0;
  border-bottom-color: var(--focus);
  box-shadow: 0 1.5px 0 var(--focus);
}

/* Sticky beside the worksheet. It scrolls on its own when it is taller than
   the window, or the buttons under the page could never be reached. */
.desk {
  position: sticky;
  top: 1.5rem;
  align-self: start;
  min-width: 0;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  padding: 0 2px 2px;   /* room for focus rings inside the scroll box */
}
.tab-row { display: flex; justify-content: space-between; align-items: end; }
.filename {
  padding: 0.3rem 0.9rem 0.25rem;
  background: var(--paper);
  border: 1px solid var(--hair);
  border-bottom: 0;
  font: 0.85rem var(--mono);
}
.lines { font: 0.85rem var(--mono); color: var(--quiet); padding-bottom: 0.3rem; }
.lines.over { color: var(--bad); font-weight: 700; }

.page {
  counter-reset: line;
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: calc(100vh - 19rem);
  min-height: 12rem;
  overflow: auto;
  border: 1px solid var(--hair);
  background:
    linear-gradient(to right, transparent 2.6rem, var(--margin) 2.6rem, var(--margin) calc(2.6rem + 1px), transparent calc(2.6rem + 1px)),
    repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--row) - 1px), var(--rule) calc(var(--row) - 1px), var(--rule) var(--row)),
    var(--paper);
  background-attachment: local;
  font: 0.78rem/var(--row) var(--mono);
  /* The file is shown as typed: no arrows for "<!--". After `font`, which resets both. */
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
}
.page li {
  counter-increment: line;
  position: relative;
  min-height: var(--row);
  padding: 0 0.75rem 0 3.2rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.page li::before {
  content: counter(line);
  position: absolute;
  left: 0;
  width: 2.2rem;
  text-align: right;
  color: var(--quiet);
  opacity: 0.7;
}
.page li.h { font-weight: 700; }
.page li.over { background: var(--bad-wash); color: var(--bad); }

.gaps { list-style: none; margin: 0.9rem 0 0; padding: 0; font-size: 0.9rem; color: var(--mid); }
.gaps li::before { content: "\25CB\00A0\00A0"; }
.gaps li.bad { color: var(--bad); }

.primary {
  margin-top: 1rem;
  padding: 0.7rem 1.4rem;
  border: 1.5px solid var(--ink);
  border-radius: 0;
  background: var(--ink);
  color: var(--bg);
  font: 600 1rem var(--sans);
  cursor: pointer;
}
.primary:hover { background: transparent; color: var(--ink); }
.primary:disabled { opacity: 0.5; cursor: progress; }

.next { margin: 1.25rem 0 0; padding-left: 1.3rem; }
.next li { margin-bottom: 0.25rem; }
kbd {
  padding: 0.05rem 0.4rem;
  border: 1px solid var(--ink);
  font: 0.9em var(--mono);
}

/* Check: score card */

.check { max-width: 78rem; margin: 0 auto; }
.check .page-title { margin-bottom: 1.5rem; }
.card { max-width: 58rem; }
.pick-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem 1.5rem; }
.pick-row .primary { margin-top: 0; }
.quiet { margin: 0; color: var(--quiet); font-size: 0.9rem; }
.status { min-height: 1.5rem; margin: 1rem 0 0; color: var(--quiet); }
.status.bad { color: var(--bad); }

.card { margin-top: 1.5rem; }
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--ink);
}
.card h2 { margin: 0; font: 700 1.1rem var(--mono); overflow-wrap: anywhere; }
.total { margin: 0; font-family: var(--mono); white-space: nowrap; }
.total output { font-size: 3.2rem; font-weight: 700; line-height: 1; letter-spacing: -0.04em; }
.total span { color: var(--quiet); font-size: 1.1rem; }
.verdict { margin: 0.9rem 0 0.5rem; font-size: 1.35rem; font-weight: 650; letter-spacing: -0.01em; }
.verdict.bad { color: var(--bad); }

.rows { width: 100%; border-collapse: collapse; }
.rows thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.rows td { padding: 0.65rem 0.75rem 0.65rem 0; border-bottom: 1px solid var(--hair); vertical-align: top; }
.rows td:first-child { width: 3rem; }
.rows td:nth-child(2) { width: 38%; font-weight: 600; }
.rows td:last-child { padding-right: 0; color: var(--quiet); overflow-wrap: anywhere; }
.rows .fix { display: block; margin-top: 0.15rem; color: var(--ink); }

.pips { display: inline-flex; gap: 2px; font: 700 0.8rem/1.5rem var(--mono); }
.pips b {
  width: 1.5rem;
  height: 1.5rem;
  text-align: center;
  border: 1.5px solid currentColor;
}
.pips[data-score="2"] { color: var(--ok); }
.pips[data-score="1"] { color: var(--mid); }
.pips[data-score="0"] { color: var(--bad); }
.pips[data-score="2"] b, .pips[data-score="1"] b, .pips[data-score="0"] b { background: currentColor; }
.pips b span { color: var(--paper); }

.card h3 { margin: 2.25rem 0 0.25rem; font-size: 1.1rem; }
.hand fieldset { margin: 0; padding: 0.9rem 0; border-bottom: 1px solid var(--hair); }
.hand legend { font-size: 1rem; font-weight: 600; margin-bottom: 0.4rem; }
.hand legend::before { content: none; }
.hand .quiet { margin: 0 0 0.5rem; }
.hand label {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 0.6rem;
  align-items: baseline;
  margin: 0 0 0.3rem;
  color: var(--ink);
  font-size: 0.95rem;
  cursor: pointer;
}
.hand input { width: auto; margin: 0; accent-color: var(--ink); }
.hand .n { font: 700 0.85rem var(--mono); color: var(--quiet); }

@media (max-width: 62rem) {
  .start { grid-template-columns: minmax(0, 1fr); }
  .desk { position: static; max-height: none; overflow: visible; }
  .page { max-height: none; }
  label { margin-left: 0; }
  legend::before { width: 1.5rem; }
  .rows td:nth-child(2) { width: auto; }
  .rows td:last-child { display: block; padding-top: 0; }
  .rows td:nth-child(2) { border-bottom: 0; padding-bottom: 0.15rem; display: block; }
  .rows tr { display: grid; grid-template-columns: 3rem 1fr; }
  .rows td:first-child { grid-row: span 2; border-bottom: 0; }
  .rows tr { border-bottom: 1px solid var(--hair); }
  .rows td { border-bottom: 0; }
  .top nav a,
  .link-button {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }
  /* Padding rather than flex: a flex summary loses its disclosure marker and
     the space between "Model:" and the value. */
  .fold summary { padding: 0.7rem 0; }
  .mark { display: inline-flex; align-items: center; min-height: 44px; }
  .fold[open] summary { margin-bottom: 0.3rem; }
  .fold .tick { min-height: 44px; }
  .hand label {
    min-height: 44px;
    align-items: center;
  }
}
