/* Crepeteria colours (brand book: forest #233D1F, brown #865334, rose #D2B0A7, sage #878C7C)
   set in the Claptin drafting look: square corners, 1px hairlines, a faint rule grid,
   wide caps labels, mono numerals, no shadows or gradients.
   Brand fonts Lust Stencil / Linotype Aroma are licensed and not installed; Archivo and
   JetBrains Mono (SIL OFL, self-hosted) stand in. */
@font-face { font-family: "Archivo"; src: url("fonts/archivo-latin.woff2") format("woff2"); font-weight: 100 900; font-stretch: 62% 125%; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Archivo"; src: url("fonts/archivo-latin-ext.woff2") format("woff2"); font-weight: 100 900; font-stretch: 62% 125%; font-display: swap; unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "JetBrains Mono"; src: url("fonts/jetbrains-mono-latin.woff2") format("woff2"); font-weight: 100 800; font-display: swap; unicode-range: U+0000-00FF, U+2000-206F, U+2190-2199, U+2212; }
@font-face { font-family: "JetBrains Mono"; src: url("fonts/jetbrains-mono-latin-ext.woff2") format("woff2"); font-weight: 100 800; font-display: swap; unicode-range: U+0100-02AF, U+1E00-1EFF; }

:root {
  --ink: #233d1f;                    /* text and line work */
  --ink-2: rgb(35 61 31 / .64);      /* secondary text */
  --ink-3: rgb(35 61 31 / .42);      /* tertiary, disabled */
  --rule: rgb(35 61 31 / .14);       /* hairlines inside blocks */
  --rule-major: rgb(35 61 31 / .34); /* block outlines */
  --grid: rgb(35 61 31 / .045);      /* page rule grid */
  --paper: #f7f2ec;
  --field: #fffcf8;
  --brown: #865334;
  --rose: #d2b0a7;
  --wash: #ecdcd5;
  --sage: #878c7c;
  --danger: #9c3b24;
  --sans: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --ease: cubic-bezier(.22, 1, .36, 1);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 15px/1.5 var(--sans);
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--brown); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.logo .st0 { fill: var(--logo-main, var(--ink)); }
.logo .st1 { fill: var(--logo-sub, var(--brown)); }

/* type roles */
.caps { font-family: var(--sans); font-weight: 600; font-size: 11px; line-height: 1.3; letter-spacing: .14em; text-transform: uppercase; font-stretch: 125%; }
.caps-sm { font-family: var(--sans); font-weight: 600; font-size: 10px; line-height: 1.3; letter-spacing: .16em; text-transform: uppercase; font-stretch: 125%; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.muted { color: var(--ink-2); }

/* buttons: square, hairline, caps */
.btn {
  --bg: var(--ink); --fg: var(--paper); --bd: var(--ink);
  display: inline-flex; align-items: center; justify-content: space-between; gap: 18px;
  min-height: 48px; padding: 0 16px;
  border: 1px solid var(--bd); border-radius: 0;
  background: var(--bg); color: var(--fg);
  font: 600 11px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; font-stretch: 125%;
  text-decoration: none; user-select: none; -webkit-tap-highlight-color: transparent;
  transition: background-color .15s, color .15s, border-color .15s;
}
.btn::after { content: "→"; font-family: var(--mono); font-size: 14px; letter-spacing: 0; transition: transform .2s var(--ease); }
.btn.no-arrow::after { content: none; }
.btn:hover { --bg: var(--brown); --bd: var(--brown); }
.btn:hover::after { transform: translateX(3px); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { --bg: transparent; --fg: var(--ink-3); --bd: var(--rule-major); pointer-events: none; }
.btn.line { --bg: transparent; --fg: var(--ink); --bd: var(--rule-major); }
.btn.line:hover { --bg: var(--ink); --fg: var(--paper); --bd: var(--ink); }
.btn.block { width: 100%; }
.btn svg { width: 16px; height: 16px; flex: none; }

.spinner { width: 14px; height: 14px; border: 1px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* cells: a ruled grid of square options sharing hairlines */
.cells { display: grid; gap: 0; border-top: 1px solid var(--rule-major); border-left: 1px solid var(--rule-major); }
.cell {
  position: relative; isolation: isolate; border: 0 solid var(--rule-major); border-width: 0 1px 1px 0; border-radius: 0; background: var(--field); color: var(--ink);
  font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 15px;
  transition: background-color .12s, color .2s .05s;
  -webkit-tap-highlight-color: transparent;
}
/* the chosen cell fills with ink as a quick sweep from the left */
.cell::before { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--ink); transform: scaleX(0); transform-origin: left; transition: transform .32s var(--ease); }
@media (hover: hover) { .cell:hover:not([disabled]) { background: var(--wash); } }
.cell[aria-checked="true"], .cell[aria-checked="true"]:hover:not([disabled]) { color: var(--paper); }
.cell[aria-checked="true"]::before { transform: scaleX(1); }
.cell[disabled] {
  cursor: not-allowed; color: var(--ink-3);
  background: var(--field) repeating-linear-gradient(135deg, transparent 0 6px, var(--rule) 6px 7px);
}

/* motion helpers (see motion.js) */
.roll-ch { display: inline-block; overflow: hidden; vertical-align: bottom; line-height: inherit; }
.roll-ch > i { display: inline-block; font-style: normal; }
.roll-ch > i.flip { animation: flip .38s var(--ease) both; }
@keyframes flip { from { transform: translateY(105%); } }
.pop { animation: pop .42s var(--ease) both; animation-delay: calc(var(--i, 0) * 18ms); }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }
/* a hairline that draws itself across when scrolled into view */
.draw-line { position: relative; }
.draw-line::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1px; background: var(--rule-major); transform: scaleX(0); transform-origin: left; transition: transform 1.1s var(--ease); }
.draw-line.in-view::before { transform: scaleX(1); }

/* fields: label above, square box */
.field { display: grid; gap: 6px; }
.field > span { font: 600 10px/1.3 var(--sans); letter-spacing: .16em; text-transform: uppercase; font-stretch: 125%; color: var(--ink-2); }
.field input, .field textarea {
  width: 100%; border: 1px solid var(--rule-major); border-radius: 0; background: var(--field);
  padding: 12px; font-size: 15px; outline: none; resize: vertical;
  transition: border-color .12s, box-shadow .12s;
}
.field textarea { min-height: 70px; }
.field input:focus, .field textarea:focus { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.field.invalid input, .field.invalid textarea { border-color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.field.invalid > span { color: var(--danger); }

.check { display: grid; grid-template-columns: 18px 1fr; gap: 12px; align-items: start; font-size: 14px; line-height: 1.45; cursor: pointer; }
.check input { appearance: none; width: 18px; height: 18px; margin: 1px 0 0; border: 1px solid var(--ink); border-radius: 0; background: var(--field); display: grid; place-items: center; }
.check input::after { content: ""; width: 9px; height: 5px; border: solid var(--paper); border-width: 0 0 1.5px 1.5px; transform: translateY(-1px) rotate(-45deg); opacity: 0; }
.check input:checked { background: var(--ink); }
.check input:checked::after { opacity: 1; }
.check.invalid input { border-color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.form-error { margin: 0; min-height: 1.3em; color: var(--danger); font-size: 13px; font-weight: 600; }
.linkish { border: 0; background: none; padding: 0; color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }

/* dialogs: hairline box, bottom sheet on phones */
.sheet { border: 1px solid var(--ink); border-radius: 0; padding: 0; width: min(560px, 100vw); max-height: 88vh; background: var(--paper); color: var(--ink); }
.sheet::backdrop { background: rgb(35 61 31 / .32); }
.sheet[open] { animation: sheet-in .35s var(--ease); }
@keyframes sheet-in { from { transform: translateY(12px); opacity: 0; } }
.sheet form { display: grid; gap: 18px; padding: 20px; }
@media (max-width: 600px) {
  .sheet { margin: auto 0 0; width: 100vw; max-width: 100vw; border-width: 1px 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
