/* Paper and ink. Colour appears only where it means something: the primary
   action and a learner's progress. Nothing here should compete with a card. */
:root {
  --ground: #f6f7f8;
  --paper: #ffffff;
  --edge: #e2e5e9;
  --ink: #1d2227;
  --soft: #5c6670;
  --accent: #33535c;
  --on-accent: #ffffff;
  --wash: #edf0f2;
  --miss: #8a4b43;
  --serif: Charter, "Bitstream Charter", "Iowan Old Style", Cambria, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #15181b;
    --paper: #1d2125;
    --edge: #2f353b;
    --ink: #e6e9ec;
    --soft: #9ca6b0;
    --accent: #a9c4cc;
    --on-accent: #15181b;
    --wash: #262b30;
    --miss: #d9a79f;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; accent-color: var(--accent); caret-color: var(--accent); }
::selection { background: color-mix(in srgb, var(--accent) 24%, transparent); color: inherit; }
.hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--ground);
  color: var(--ink);
  font: 1rem/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  padding-inline: max(20px, env(safe-area-inset-left)) max(20px, env(safe-area-inset-right));
}
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 8px; background: var(--paper); padding: 8px 12px; z-index: 10; }
.top {
  display: flex; justify-content: space-between; align-items: center; gap: 16px; min-height: calc(64px + env(safe-area-inset-top));
  max-width: 36rem; width: 100%; margin: 0 auto;
  padding-block: calc(14px + env(safe-area-inset-top)) 6px;
}
.brand { font-weight: 600; font-size: .9375rem; color: var(--ink); text-decoration: none; }
nav { display: flex; gap: 20px; }
nav a, .link { display: inline-flex; align-items: center; color: var(--soft); background: none; border: 0; padding: 8px 0; font: 400 .9375rem var(--sans); text-decoration: none; cursor: pointer; }
nav a:hover, .link:hover { color: var(--ink); }
main { flex: 1; max-width: 36rem; width: 100%; margin: 0 auto; padding-block: 28px 56px; outline: none; }
main:focus-visible { outline: none; }
h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(1.75rem, 6vw, 2.25rem); line-height: 1.18; margin: 0 0 12px; text-wrap: balance; }
h2 { font-size: 1rem; font-weight: 600; margin: 32px 0 8px; }
p { margin: 0 0 16px; }
a { color: var(--accent); }
.lede { color: var(--soft); max-width: 32rem; }
.small { font-size: .875rem; color: var(--soft); }
label { display: block; font-weight: 500; font-size: .9375rem; margin: 20px 0 6px; }
input[type=email], input[type=text], input[type=url], textarea, select {
  width: 100%; font: inherit; color: var(--ink); background: var(--paper);
  border: 1px solid var(--edge); border-radius: 8px; padding: 12px 13px;
}
input:hover, textarea:hover, select:hover { border-color: var(--soft); }
textarea { min-height: 14rem; resize: vertical; line-height: 1.5; }
input[type=file] { display: block; width: 100%; font: inherit; font-size: .9375rem; color: var(--soft); padding: 6px; background: var(--paper); border: 1px dashed var(--edge); border-radius: 8px; cursor: pointer; }
input[type=file]:hover { border-color: var(--soft); }
input[type=file]::file-selector-button { min-height: 40px; margin-right: 12px; padding: 8px 16px; font: 500 .9375rem var(--sans); color: var(--ink); background: var(--ground); border: 1px solid var(--edge); border-radius: 6px; cursor: pointer; }
fieldset { margin: 20px 0 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; font-weight: 500; font-size: .9375rem; margin-bottom: 4px; }
fieldset label { display: flex; align-items: center; gap: 10px; min-height: 44px; margin: 0; font-weight: 400; cursor: pointer; }
input[type=radio] { width: 18px; height: 18px; margin: 0; flex: none; }
input[inputmode=numeric] { letter-spacing: .3em; font-size: 1.25rem; }
.btn {
  display: inline-block; min-height: 48px; padding: 12px 22px; border-radius: 8px;
  font: 500 1rem var(--sans); text-decoration: none; text-align: center; cursor: pointer;
  background: var(--accent); color: var(--on-accent); border: 1px solid var(--accent);
}
.btn.quiet { background: transparent; color: var(--ink); border-color: var(--edge); }
.btn.quiet:hover { border-color: var(--soft); }
.btn[disabled] { opacity: .55; cursor: default; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; align-items: center; }
.actions + .small, form + .small { margin-top: 16px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.error { color: var(--miss); margin-top: 8px; }
.error:empty { display: none; }
#check { margin-top: 12px; }
#check:empty { display: none; }
.status { position: fixed; bottom: calc(16px + env(safe-area-inset-bottom)); left: 16px; right: 16px; text-align: center; pointer-events: none; z-index: 6; }
.status span { display: inline-block; background: var(--ink); color: var(--ground); padding: 8px 14px; border-radius: 8px; font-size: .875rem; }
.status:empty { display: none; }

.decks { list-style: none; margin: 20px 0 0; padding: 0; border-top: 1px solid var(--edge); }
.decks li { border-bottom: 1px solid var(--edge); }
.decks a { display: block; padding: 16px 0; color: inherit; text-decoration: none; }
.decks .row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 0; }
.decks strong { display: block; font-family: var(--serif); font-weight: 400; font-size: 1.1875rem; line-height: 1.3; margin-bottom: 2px; }
.decks a:hover strong { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.decks progress { display: block; width: 100%; height: 2px; margin-top: 10px; border: 0; overflow: hidden; background: var(--edge); appearance: none; }
.decks progress::-webkit-progress-bar { background: var(--edge); }
.decks progress::-webkit-progress-value { background: var(--accent); }
.decks progress::-moz-progress-bar { background: var(--accent); }

.choice { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.choice button { min-height: 44px; padding: 8px 14px; font: inherit; color: var(--ink); background: var(--paper); border: 1px solid var(--edge); border-radius: 8px; cursor: pointer; }
.choice button[aria-pressed=true] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

/* The card. Both sides are the same paper, so the only change is the words. */
.stage { position: relative; margin-top: 12px; }
.stack-1 { padding-bottom: 3px; }
.stack-2 { padding-bottom: 6px; }
.stack-3 { padding-bottom: 9px; }
.sheet { position: absolute; left: 0; right: 0; top: 0; bottom: 0; background: var(--paper); border: 1px solid var(--edge); border-radius: 12px; }
.sheet-1 { transform: translateY(3px); }
.sheet-2 { transform: translateY(6px); }
.sheet-3 { transform: translateY(9px); }
.card {
  position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 24px;
  width: 100%; min-height: min(52dvh, 24rem); padding: 28px 26px;
  text-align: left; font: inherit; color: var(--ink); cursor: pointer;
  background: var(--paper); border: 1px solid var(--edge); border-radius: 12px;
}
.card.answer { justify-content: flex-start; gap: 0; }
.card .small { margin: 0; }
.card-q { font-family: var(--serif); font-size: clamp(1.375rem, 5vw, 1.625rem); line-height: 1.35; margin: 0; text-wrap: pretty; }
.card-a { margin: 0; font-family: var(--serif); font-size: 1.125rem; line-height: 1.6; }
.card.has-format { padding-top: 62px; }
.card-points { margin: 0; padding: 0 0 0 1.1em; font-family: var(--serif); font-size: 1.125rem; line-height: 1.5; }
.card-points li + li { margin-top: 8px; }
.card-points li::marker { color: var(--soft); }
.format { position: absolute; top: 16px; left: 26px; z-index: 1; display: flex; gap: 16px; }
.format button { min-height: 32px; padding: 4px 0; border: 0; background: none; font: 400 .8125rem var(--sans); color: var(--soft); cursor: pointer; }
.format button[aria-pressed=true] { color: var(--ink); box-shadow: inset 0 -1px 0 var(--ink); }
.coach { margin: 20px 0 0; padding: 10px 0 0 14px; border-left: 2px solid var(--edge); font: .875rem/1.5 var(--sans); color: var(--soft); }
.coach span { display: block; font-weight: 600; font-size: .75rem; color: var(--soft); margin-bottom: 2px; }
.card .kind { font-size: .8125rem; color: var(--soft); margin: 0 0 12px; }
.flip { animation: turn .16s ease-out; }
@keyframes turn { from { opacity: .35; } }

.diagram { margin: 12px 0 0; padding: 18px 16px; background: var(--paper); border: 1px solid var(--edge); border-radius: 12px; }
.preview-card .diagram { padding: 12px 0 0; border: 0; border-top: 1px solid var(--edge); border-radius: 0; }
.diagram svg { display: block; width: 100%; max-width: 26rem; height: auto; margin: 0 auto; }
.d-box { fill: var(--wash); stroke: var(--edge); }
.d-label { fill: var(--ink); font: 12.5px var(--sans); text-anchor: middle; }
.d-edge { stroke: var(--soft); stroke-width: 1; fill: none; }
.d-head { fill: var(--soft); }
.d-gap { fill: var(--paper); }
.d-edge-label { fill: var(--soft); font: 11px var(--sans); text-anchor: middle; }

details { margin-top: 12px; }
summary { cursor: pointer; padding: 8px 0; font-size: .9375rem; color: var(--soft); }
details p { font-family: var(--serif); line-height: 1.6; }

/* Pinned to the viewport, so the answer buttons never move with the card's length. */
.controls { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; padding: 12px max(20px, env(safe-area-inset-left)) calc(12px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-right)); background: var(--ground); border-top: 1px solid var(--edge); }
.controls-in { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 36rem; margin: 0 auto; }
.controls .wide, .controls .small { grid-column: 1 / -1; }
.controls .small { margin: 0; text-align: center; font-size: .8125rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.controls-room { height: 120px; }
.controls .again { background: transparent; color: var(--ink); border-color: var(--edge); }
.controls .again:hover { border-color: var(--soft); }
.progress span:first-child { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.progress span:last-child { flex: none; }
.progress { display: flex; justify-content: space-between; gap: 16px; font-size: .8125rem; color: var(--soft); margin-bottom: 4px; }
.notice { background: transparent; border-top: 1px solid var(--edge); border-bottom: 1px solid var(--edge); padding: 12px 0; margin-bottom: 20px; font-size: .9375rem; color: var(--soft); }
.notice p { margin: 0; }
.notice details { margin-top: 2px; }
.correct { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-top: 8px; }
.correct label { flex: 1 1 9rem; margin: 0; font-size: .875rem; color: var(--ink); }
.correct select { min-height: 48px; margin-top: 4px; }
.preview-card { background: var(--paper); border: 1px solid var(--edge); border-radius: 12px; padding: 22px; margin-bottom: 12px; }
.preview-card h2 { font-family: var(--serif); font-weight: 400; font-size: 1.1875rem; line-height: 1.35; margin: 0 0 6px; }
.preview-card p { font-family: var(--serif); }
.preview-card p.small { font-family: var(--sans); }
.preview-card p:last-child { margin: 0; }
.wait { display: flex; gap: 12px; align-items: center; color: var(--soft); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--soft); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
@media (hover: none) { .btn, .link, nav a, .format button { min-height: 44px; } .format { top: 8px; } .controls .small { display: none; } .controls-room { height: 90px; } }
@media (prefers-reduced-motion: reduce) { .flip, .dot { animation: none; } }
