/* Cardcrest app. Colours and type come only from tokens (css/tokens.css,
   generated from brand/tokens.json); data-theme on <html> switches them.
   The layout is the same in every theme. Codes are code-ink on code-ground,
   always, with their quiet zone. */

@font-face { font-family: "Inter"; src: url("/fonts/inter-var.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("/fonts/jetbrains-mono-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink);
  font: 400 17px/1.45 var(--font-sans);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
a { color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-xs); }
.screen { max-width: 560px; margin: 0 auto; outline: none; }
.screen:focus { outline: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: var(--space-3); top: -60px; z-index: 5; padding: var(--space-3) var(--space-4); border-radius: var(--radius-pill); background: var(--action); color: var(--on-action); font-weight: 600; }
.skip:focus { top: var(--space-3); }
.pad { padding: 0 var(--space-4) var(--space-8); }
.center { text-align: center; }
.boot { padding: var(--space-8) var(--space-4); color: var(--ink-muted); }

/* Type (tokens.json › type) */
.large-title { margin: 0; font-size: 36px; line-height: 40px; font-weight: 800; letter-spacing: -0.02em; }
.title { margin: var(--space-6) 0 var(--space-2); font-size: 26px; line-height: 32px; font-weight: 700; }
.callout { margin: 0 0 var(--space-6); font-size: 15px; color: var(--ink-muted); }
.footnote { margin: var(--space-4) 0 0; font-size: 13px; color: var(--ink-muted); }
.overline { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-muted); }
.mono { font-family: var(--font-mono); font-weight: 600; }

/* The home header: "Cardcrest", the first C in gold (deep gold on light). */
.home-head { display: flex; align-items: center; justify-content: space-between; padding: var(--space-6) var(--space-4) var(--space-4); }
.wordmark .c { color: var(--brand-gold); }
[data-theme="light"] .wordmark .c { color: var(--brand-gold-deep); }
.head-actions { display: flex; gap: var(--space-2); }
.icon-btn { width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: var(--radius-pill); background: var(--surface); color: var(--ink); }
.icon-btn.add { background: var(--action); color: var(--on-action); }

/* Bars with Cancel / Title / Add */
.bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 56px; padding: 0 var(--space-2); }
.bar-btn { min-height: 44px; min-width: 44px; padding: 0 var(--space-3); display: inline-flex; align-items: center; background: none; border: 0; color: var(--ink); font: inherit; text-decoration: none; cursor: pointer; }
.bar > :last-child { justify-self: end; }
.bar-btn.strong { font-weight: 600; color: var(--action); }
.bar-title { font-size: 17px; font-weight: 600; }

/* Buttons: verbs in Title Case */
.btn {
  display: flex; align-items: center; justify-content: center; width: 100%; min-height: 50px; margin: 0 0 var(--space-3);
  padding: 0 var(--space-5); border: 0; border-radius: var(--radius-md); background: var(--surface); color: var(--ink);
  font: 600 17px var(--font-sans); text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--action); color: var(--on-action); }
.btn.quiet { background: none; color: var(--ink-muted); }
.file-btn { position: relative; }
.file-btn:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.actions { margin-top: var(--space-6); }
.drop { padding: var(--space-4); border: 2px dashed var(--hairline); border-radius: var(--radius-xl); }
.drop.over { border-color: var(--action); }

.status { min-height: 1.4em; margin: var(--space-4) 0 0; font-size: 15px; font-weight: 600; }
.status[data-state="error"] { color: var(--danger); }
.status[data-state="busy"] { color: var(--ink-muted); }

/* Lists of cards (M1: rows; the stack is M3) */
.card-list { list-style: none; margin: 0; padding: 0 var(--space-4) var(--space-8); display: grid; gap: var(--space-3); }
.card-row {
  display: flex; flex-direction: column; justify-content: space-between; min-height: 96px; padding: var(--space-5);
  border-radius: var(--radius-lg); background: var(--face, var(--card-fallback)); color: var(--face-ink, var(--card-ink));
  text-decoration: none; box-shadow: var(--shadow-card);
}
.card-word { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }
.card-meta { margin: var(--space-1) 0 0; font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; opacity: 0.85; }
.empty .btn { margin-top: var(--space-4); }

/* The card face and its code */
.face { padding: var(--space-5); border-radius: var(--radius-lg); background: var(--face, var(--card-fallback)); color: var(--face-ink, var(--card-ink)); box-shadow: var(--shadow-card); }
.code-panel { margin: var(--space-5) 0 0; padding: var(--space-4); border-radius: var(--radius-sm); background: var(--code-ground); color: var(--code-ink); text-align: center; }
.code-panel img { display: block; width: 100%; height: auto; max-height: 46vh; object-fit: contain; image-rendering: pixelated; }
.code-panel.two-d img { width: min(100%, 300px); margin: 0 auto; }
.code-panel.small img { max-height: 180px; }
.card-number { margin: var(--space-2) 0 0; font-family: var(--font-mono); font-size: 18px; font-weight: 600; letter-spacing: 0.04em; color: var(--code-ink); }

/* Review */
.facts { margin: var(--space-4) 0 var(--space-6); }
.facts div { display: flex; justify-content: space-between; gap: var(--space-4); padding: var(--space-2) 0; border-bottom: 1px solid var(--hairline); }
.facts dt { color: var(--ink-muted); font-size: 15px; }
.facts dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.group { margin: 0 0 var(--space-6); padding: 0; border: 0; border-radius: var(--radius-md); background: var(--surface); overflow: hidden; }
fieldset.group { padding: var(--space-3) var(--space-4); }
fieldset.group legend { padding: var(--space-3) 0 0; float: left; width: 100%; }
.field { display: flex; align-items: center; gap: var(--space-3); min-height: 52px; padding: 0 var(--space-4); border-bottom: 1px solid var(--hairline); }
.field:last-child { border-bottom: 0; }
.field > span { flex: 0 0 72px; color: var(--ink-muted); font-size: 15px; }
.field input, .field select { flex: 1; min-width: 0; min-height: 44px; border: 0; background: transparent; color: var(--ink); font: inherit; }
.field input::placeholder { color: var(--ink-muted); }
.field input[aria-invalid="true"] { box-shadow: inset 0 -2px 0 var(--danger); }
.field select option { background: var(--surface); color: var(--ink); }
.choice { display: flex; align-items: center; gap: var(--space-3); min-height: 44px; clear: both; }
.choice input { width: 22px; height: 22px; accent-color: var(--action); }

/* Card added */
.added { padding-top: var(--space-12); }

/* Sheets */
dialog.sheet { width: min(100% - 2 * var(--space-4), 420px); border: 0; border-radius: var(--radius-xl); padding: var(--space-6) var(--space-5) var(--space-3); background: var(--surface-raised); color: var(--ink); box-shadow: var(--shadow-sheet); }
dialog.sheet::backdrop { background: color-mix(in srgb, var(--bg) 70%, transparent); }
dialog.sheet .title { margin-top: 0; }

.toast { position: fixed; left: 50%; bottom: calc(var(--space-6) + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; padding: var(--space-3) var(--space-5); border-radius: var(--radius-pill); background: var(--surface-raised); color: var(--ink); box-shadow: var(--shadow-sheet); font-size: 15px; font-weight: 600; transition: opacity var(--duration-base), transform var(--duration-base); pointer-events: none; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* Print: only #print-area, each code at wallet-card size (85.6 × 54 mm) with cut lines. */
.print-area { display: none; }
@media print {
  @page { margin: 12mm; }
  body > *:not(.print-area) { display: none !important; }
  html, body { background: var(--code-ground); padding: 0; }
  .print-area { display: flex; flex-wrap: wrap; gap: 6mm; }
  .print-card { width: 85.6mm; height: 54mm; padding: 4mm; border: 0.3mm dashed var(--code-ink); display: flex; flex-direction: column; align-items: center; justify-content: center; break-inside: avoid; background: var(--code-ground); color: var(--code-ink); font-family: var(--font-sans); }
  .print-card img { max-width: 100%; max-height: 34mm; image-rendering: pixelated; }
  .print-card.code img { max-height: 42mm; }
  .print-name { margin: 0 0 2mm; font-size: 12pt; font-weight: 800; align-self: flex-start; }
  .print-number { margin: 2mm 0 0; font: 600 10pt var(--font-mono); }
}
