/* Type Pace Lab — quiet typographic laboratory */

:root {
  --bg: #F4F3EE;
  --ink: #27333A;
  --dark: #202D35;
  --test: #F1F1E9;
  --accent: #D78B52;
  --ok: #6D9A85;
  --bad: #C56F68;
  --line: #D4D9D5;
  --muted: #728087;
  --paper: #FFFcf7;
  --max: 1200px;
  --testw: 980px;
  --read: 720px;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: ui-serif, Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { overflow-x: hidden; }
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    linear-gradient(180deg, transparent 0, transparent 23px, rgba(39, 51, 58, 0.035) 23px, rgba(39, 51, 58, 0.035) 24px, transparent 24px);
  background-size: 100% 24px;
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  overflow-x: hidden;
}

body::before,
body::after {
  pointer-events: none;
  position: fixed;
  z-index: 0;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: rgba(39, 51, 58, 0.18);
}
body::before { content: "WPM"; top: 78px; right: 12px; }
body::after { content: "+"; bottom: 16px; left: 12px; }

main, .masthead, .site-footer { position: relative; z-index: 1; }

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--ink); }

h1, h2, h3 {
  font-family: var(--sans);
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin: 0 0 0.45em;
}

.article-body h1,
.article-body h2,
.article-body h3,
.prose h1, .prose h2, .prose h3 {
  font-family: var(--serif);
}

p { margin: 0 0 1em; }

.lab, .anno, .metric-k, .strip-lab {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.nums, .metric-v, .timer, time {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -44px;
  background: var(--dark);
  color: #fff;
  padding: 8px 12px;
  z-index: 40;
}
.skip-link:focus { top: 8px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.wrap { width: min(100% - 32px, var(--max)); margin-inline: auto; }
.wrap-test { width: min(100% - 32px, var(--testw)); margin-inline: auto; }
.wrap-narrow { width: min(100% - 32px, var(--read)); margin-inline: auto; }

.masthead {
  height: 64px;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 243, 238, 0.94);
  position: sticky;
  top: 0;
  z-index: 20;
}
.masthead-inner {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: var(--ink);
  font-weight: 750;
  letter-spacing: 0.16em;
  font-size: 12px;
  line-height: 1.1;
}
.nav {
  display: flex;
  gap: 16px;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}
.nav a { color: var(--ink); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--accent); }
.nav-toggle {
  display: none;
  border: 1px solid var(--line);
  background: var(--paper);
  min-height: 36px;
  padding: 0 12px;
  font: 700 13px var(--sans);
  cursor: pointer;
}

.section { padding: 48px 0; border-top: 1px solid var(--line); }
.intro { max-width: 62ch; color: #3d4c54; }

.station { padding: 28px 0 8px; }
.station h1 { font-size: clamp(32px, 4vw, 44px); }

.surface {
  background: var(--dark);
  color: var(--test);
  padding: 22px 22px 18px;
  border: 1px solid #172128;
}
.surface .anno,
.surface .lab { color: #9aa7ae; }
.surface-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}
.timer {
  font-size: 28px;
  letter-spacing: 0.08em;
  color: var(--accent);
}
.passage {
  font-family: var(--mono);
  font-size: clamp(20px, 2.2vw, 28px);
  line-height: 1.72;
  max-height: 280px;
  overflow: auto;
  margin-bottom: 14px;
  word-break: break-word;
}
.ch { border-bottom: 2px solid transparent; }
.ch.is-ok { border-bottom-color: var(--ok); }
.ch.is-bad {
  background: rgba(197, 111, 104, 0.35);
  box-shadow: inset 0 0 0 1px var(--bad);
}
.ch.is-now {
  outline: 1px dashed #c5cdc8;
  outline-offset: 1px;
}
.ch.is-now::after {
  content: "|";
  color: var(--accent);
  font-weight: 400;
}

.field-lab {
  display: block;
  margin-bottom: 6px;
}
.typing-input {
  width: 100%;
  min-height: 120px;
  padding: 12px;
  border: 1px solid #3a4a53;
  background: #182329;
  color: var(--test);
  font: 18px/1.5 var(--mono);
  resize: vertical;
}
.hint { font-size: 14px; color: #9aa7ae; margin: 10px 0 0; }

.rail {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.metric {
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 10px 12px;
}
.metric-v { font-size: 28px; display: block; }

.strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 16px;
}
.chip {
  border: 1px solid var(--line);
  background: transparent;
  min-height: 40px;
  padding: 0 12px;
  font: 650 13px var(--sans);
  cursor: pointer;
  color: var(--ink);
}
.chip[aria-pressed="true"] {
  background: var(--dark);
  color: var(--test);
  border-color: var(--dark);
}
.btn {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #1b1b1b;
  font: 700 13px var(--sans);
  letter-spacing: 0.04em;
  cursor: pointer;
}
.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.note { min-height: 1.3em; font-size: 14px; color: var(--muted); }
.error-summary { font-size: 14px; }

.sheet {
  margin-top: 22px;
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 22px;
  box-shadow: 2px 2px 0 #e7e2d6;
}
.sheet-hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.big {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(36px, 5vw, 56px);
  line-height: 1;
}
.sheet dl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px; }
.sheet dt { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.sheet dd { margin: 0; font-family: var(--mono); }

.lane {
  display: grid;
  grid-template-columns: 160px 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.lane-n { font-family: var(--mono); color: var(--muted); }

.word-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.word-target {
  font-family: var(--mono);
  font-size: 28px;
  padding: 16px;
  border: 1px dashed var(--line);
  background: var(--paper);
}

.practice-ref {
  font-family: var(--mono);
  font-size: 22px;
  line-height: 1.7;
  min-height: 3em;
}

.lined {
  background: repeating-linear-gradient(#fffdf8, #fffdf8 27px, #e6e0d4 28px);
  padding: 16px;
  border: 1px solid var(--line);
}

.ledger { width: 100%; border-collapse: collapse; font-size: 14px; }
.ledger th, .ledger td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.ledger .is-early { color: var(--muted); }
.table-scroll { overflow-x: auto; }
.chart { max-width: 640px; }
.chart svg { width: 100%; height: auto; }

.tech {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.tech article { padding-bottom: 12px; border-bottom: 1px solid var(--line); }

.calc {
  background: var(--paper);
  border: 1px dashed var(--line);
  padding: 18px;
  font-family: var(--mono);
  font-size: 15px;
}

.article-index a {
  display: block;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
}
.article-index strong { display: block; font-family: var(--serif); font-size: 20px; }

.article-body { padding: 48px 0 80px; }
.article-body p, .prose p { font-family: var(--serif); font-size: 18px; }
.faq dt { font-weight: 700; margin-top: 12px; }
.faq dd { margin: 4px 0 0; }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.contact-block { line-height: 1.8; }
.muted { color: var(--muted); }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.key-ghost {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 1px solid rgba(39, 51, 58, 0.12);
  margin-right: 4px;
  vertical-align: middle;
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 28px 0 48px;
  font-size: 14px;
}
.footer-id { font-weight: 750; margin-bottom: 10px; }
.footer-nav { display: flex; flex-wrap: wrap; gap: 6px 0; margin-bottom: 8px; }
.footer-nav span { margin: 0 8px; color: var(--line); }
.footer-nav a { color: var(--ink); text-decoration: none; }

@media (max-width: 1100px) {
  .nav {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    flex-direction: column;
    padding: 12px 16px 16px;
    gap: 10px;
    white-space: normal;
  }
  .nav.is-open { display: flex; }
  .nav-toggle { display: inline-flex; align-items: center; }
}

@media (max-width: 760px) {
  .rail { grid-template-columns: 1fr 1fr; }
  .lane, .sheet-hero, .sheet dl, .tech { grid-template-columns: 1fr; }
  .strip { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; }
  .typing-input { min-height: 140px; }
  .passage { font-size: 21px; }
}

@media (max-width: 360px) {
  .wrap, .wrap-test, .wrap-narrow { width: calc(100% - 16px); }
  .passage { font-size: 20px; }
  .brand { font-size: 11px; }
}
