/* A page of the device, on a phone: the firmware's two themes (docs/redesign/ui.md), its title
   with the rule that fills as the steps go, its hairlines, one filled key at most. The box is a
   box of the seed card, 6.5 by 8 mm, as large as the screen allows. Day or night is the
   system's, as on the landing page; a host's data-theme overrules it. */

@font-face {
  font-family: "Schibsted Grotesk";
  src: url("../fonts/SchibstedGrotesk.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --ground: #eceae5; --key: #ffffff; --hair: #cfcbc3; --text: #15130f; --muted: #6a6358;
  --amber: #e07f14; --amber-text: #9e5406; --on-amber: #15130f; --ok: #1a6b40; --danger: #b8362a;
  --ink: #15130f;                 /* the pen */
  --font: "Schibsted Grotesk", system-ui, sans-serif;
  --m: 16px;                      /* the side margin */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: #0f0e0c; --key: #1c1a17; --hair: #2b2823; --text: #ede8df; --muted: #978f83;
    --amber: #f2a33a; --amber-text: #f2a33a; --on-amber: #1a1206; --ok: #62c08e; --danger: #e8604e; --ink: #ede8df;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #0f0e0c; --key: #1c1a17; --hair: #2b2823; --text: #ede8df; --muted: #978f83;
  --amber: #f2a33a; --amber-text: #f2a33a; --on-amber: #1a1206; --ok: #62c08e; --danger: #e8604e; --ink: #ede8df;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* Nothing scrolls or bounces under a writing hand, and nothing is selected by a long press. */
body {
  margin: 0; background: var(--ground); color: var(--text); font: 500 16px/1.35 var(--font);
  letter-spacing: -0.01em; -webkit-font-smoothing: antialiased;
  overflow: hidden; overscroll-behavior: none; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
h1, p, dl, dd { margin: 0; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

.page {
  display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); height: 100svh;
  max-width: 30rem; margin: 0 auto;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

/* The title: the back arrow's target is the corner down to the rule, as on the device. */
.title { display: flex; align-items: center; height: 56px; }
.back { display: grid; place-items: center; flex: none; width: 56px; height: 56px; margin-right: -6px; }
.back svg { width: 12px; height: 20px; padding: 0; fill: none; stroke: var(--text); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.back::before { content: ""; position: absolute; width: 44px; height: 40px; border-radius: 6px; }
.back { position: relative; }
.back svg { position: relative; }
.back:active::before { background: var(--key); }
.back:active svg { translate: 0 2px; }
.back[hidden] { display: grid !important; visibility: hidden; }
.title h1 { flex: 1; font-size: 21px; font-weight: 650; letter-spacing: -0.02em; }
.act { height: 56px; padding: 0 var(--m); color: var(--amber-text); font-size: 18px; font-weight: 600; }
.act:active { translate: 0 2px; opacity: 0.75; }

.rule { height: 2px; background: var(--hair); }
.rule i { display: block; height: 100%; width: 0; background: var(--amber); transition: width 240ms cubic-bezier(0.22, 1, 0.36, 1); }
.rule.walks i { width: 56px; animation: walk 1.2s linear infinite; transition: none; }
@keyframes walk { from { translate: -56px; } to { translate: 30rem; } }

/* The character to write over its box, in a row of two each over its own; the two together in
   the middle of what the title and the bar leave. */
.writing { display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: 0; overflow: hidden; padding: 0 var(--m) 4px; }
.ask { display: grid; grid-template-columns: 1fr auto; width: 100%; flex: none; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.glyphs { grid-column: 1 / -1; display: flex; justify-content: center; padding-bottom: 6px; color: var(--text); font-size: 64px; font-weight: 600; line-height: 80px; letter-spacing: 0; }
.glyphs span { width: var(--cell, auto); text-align: center; }
.stage { flex: none; }
.box { display: block; touch-action: none; cursor: crosshair; border-radius: 2px; }

/* What is sent: every writing as it goes, small. */
.end { display: grid; grid-template-rows: minmax(0, 1fr) auto auto; min-height: 0; padding: 20px var(--m) 0; gap: 0; }
.sheet { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 6px; align-content: start; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 16px; }
.sheet canvas { width: 100%; height: auto; background: var(--key); border-radius: 2px; }
.sheet .row { grid-column: span 2; }
.rows { border-top: 1px solid var(--hair); }
.rows div { display: flex; justify-content: space-between; align-items: center; height: 48px; border-bottom: 1px solid var(--hair); gap: 1rem; }
.rows dd { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.say { min-height: 3.2em; padding-top: 14px; font-size: 14px; color: var(--muted); }
.say.ok { color: var(--ok); }
.say.no { color: var(--danger); }

/* The bar: a ghost and the one filled key; a key that cannot act yet is drawn as the keypad's OK
   is before the length holds, its word a little lighter than the device's hairline so that a
   phone's screen at arm's length still shows it. Pressed, as the device: darker by a quarter and 2 px lower. */
.bar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 16px var(--m) 16px; }
.bar button { height: 56px; border-radius: 8px; font-size: 17px; font-weight: 600; }
.ghost { border: 1px solid var(--hair); }
.ghost:active { background: var(--key); translate: 0 2px; }
.primary { background: var(--amber); color: var(--on-amber); }
.primary:active { filter: brightness(0.75); translate: 0 2px; }
.bar button:disabled { background: none; border: 1px solid var(--hair); color: color-mix(in srgb, var(--muted) 50%, transparent); cursor: default; filter: none; translate: none; }
.bar button[hidden] { display: none; }
.bar.one { grid-template-columns: 1fr; }

.none { padding: var(--m); }

@media (hover: hover) and (pointer: fine) {
  .ghost:not(:disabled):hover { background: var(--key); }
  .primary:not(:disabled):hover { filter: brightness(1.06); }
}
@media (prefers-reduced-motion: reduce) {
  .rule i { transition: none; }
  .rule.walks i { animation-duration: 3s; }
}
