/*
 * GOOD Measure — the web fallback's stylesheet. SPEC §5.4, STYLE.md.
 *
 * ⚠️ NOT ONE HEX VALUE, NOT ONE RAW RADIUS, NOT ONE RAW FONT SIZE.
 *
 * Every colour is `var(--…)` from `tokens.css`, every radius is `var(--r-…)`, every gap
 * is `var(--s-…)`. STYLE §8.3's parity checklist compares this surface against the Pro
 * app and the clip and says drift is fixed *"in the deviating surface, not by changing
 * the token"* — which only works if there is nowhere else for a value to hide.
 *
 * The type scale is STYLE §2.2's table. Sizes appear here once each, as a class, for the
 * same reason.
 */

/* ── reset ──────────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--background);
  color: var(--text-primary);
  font-family: var(--font);
  /* STYLE §2.2 `bodyLarge`: 15 / 400 / 1.5 */
  font-size: 15px;
  line-height: 1.5;
  /* Numbers render with tabular figures — STYLE §2.2: "dimensions always render with
   * tabular figures (`fontFeatures: tnum`)". Set on the body so a size in a heading and
   * a size in a card line up. */
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

/* ── type scale · STYLE §2.2 ────────────────────────────────────────────────── */

.hero-data     { font-size: 48px; font-weight: 700; letter-spacing: -2px;   line-height: 1;   }
.display-large { font-size: 32px; font-weight: 700; letter-spacing: -.5px;  line-height: 1.2; }
.display-medium{ font-size: 28px; font-weight: 700; letter-spacing: -.5px;  line-height: 1.2; }
.screen-title  { font-size: 24px; font-weight: 600; line-height: 1.3; }
.headline      { font-size: 20px; font-weight: 600; line-height: 1.3; }
.section-header{ font-size: 18px; font-weight: 600; line-height: 1.4; }
.title-medium  { font-size: 16px; font-weight: 600; line-height: 1.4; }
.card-title    { font-size: 15px; font-weight: 600; line-height: 1.4; }
.body-large    { font-size: 15px; font-weight: 400; line-height: 1.5; }
.body          { font-size: 14px; font-weight: 400; line-height: 1.5; color: var(--text-secondary); }
.body-small    { font-size: 13px; font-weight: 400; line-height: 1.4; color: var(--text-secondary); }
.label-medium  { font-size: 12px; font-weight: 500; line-height: 1.3; color: var(--text-secondary); }
.caption       { font-size: 12px; font-weight: 500; line-height: 1.4; color: var(--text-tertiary); }
.label-small   { font-size: 11px; font-weight: 500; line-height: 1.3; color: var(--text-tertiary); }

/* STYLE §2.2 `label`: 10 / 700 / +0.5 / UPPERCASE. Eyebrows and confidence pills. */
.label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
}

/* ── layout ─────────────────────────────────────────────────────────────────── */

.shell {
  /* STYLE §3.1: `lg` (20) is the screen edge inset. */
  max-width: 680px;
  margin: 0 auto;
  padding: var(--s-lg);
}

.section { margin-top: var(--s-xl); }        /* §3.1 `xl` (24) is the section gap */
.stack   { display: grid; gap: var(--s-md); }
.stack-sm{ display: grid; gap: var(--s-sm); }
.row     { display: flex; align-items: center; gap: var(--s-sm); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s-sm); }

/* ── the wordmark · STYLE §2.1 ──────────────────────────────────────────────── */

/*
 * ⚠️ MONTSERRAT IS NOT LOADED. STYLE §2.1: *"Do not bundle Montserrat. The wordmark
 * appears once, on the results header; ship it as a vector asset."* On the web there is
 * no binary budget, but loading a second family for seven glyphs still costs a request
 * and a layout shift — so the wordmark is the same SVG the clip uses, inlined, and it
 * tints with `currentColor` exactly as the clip's template asset does.
 */
.wordmark { display: inline-flex; align-items: center; color: var(--text-primary); }
.wordmark svg { display: block; height: 18px; width: auto; }

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: var(--s-md);
  border-bottom: 1px solid var(--border);
}

/* ── cards · STYLE §4.7 ─────────────────────────────────────────────────────── */

/*
 * §3.3: "Cards never have shadow in either mode — the `border` hairline is the edge."
 * §3.2: cards are `lg` (20).
 */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-md);
}

/* §4.7's opening card: 64 x 64 crop at left, title and size at right, pill top-right. */
.opening {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: var(--s-md);
  align-items: start;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-md);
  font: inherit;
  color: inherit;
  cursor: pointer;
  transition: border-color var(--motion-fast) var(--curve-default);
}

.opening:hover { border-color: var(--border-strong); }

.opening:focus-visible {
  /* STYLE §4.10: focus is `primaryInk` at 1.5 pt. */
  outline: none;
  border-color: var(--primary-ink);
  box-shadow: 0 0 0 1.5px var(--primary-ink);
}

.opening[aria-pressed="true"] { opacity: .45; }

/* §4.7: the crop is `sm` radius (12). */
.opening-crop {
  width: 64px;
  height: 64px;
  border-radius: var(--r-sm);
  object-fit: cover;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
}

.opening-crop-empty {
  display: grid;
  place-items: center;
  color: var(--text-tertiary);
}

.opening-text { min-width: 0; }
.opening-text > * + * { margin-top: var(--s-xs); }

/* ── confidence pill · STYLE §4.6 ───────────────────────────────────────────── */

/*
 * §4.6: pill radius, 22 pt height, `label` typography, 8 pt horizontal padding.
 * Each level is a 15% wash of its semantic colour with the colour itself as the text —
 * which is STYLE §1.1's lime rule applied to the semantics: a fill bigger than a glyph
 * is the wash, the glyph is the ink.
 */
.pill {
  display: inline-flex;
  align-items: center;
  height: var(--pill-height);
  padding: 0 var(--s-sm);
  border-radius: var(--r-pill);
  white-space: nowrap;
  flex: none;
}

.pill-high       { background: color-mix(in srgb, var(--success) 15%, transparent); color: var(--success); }
.pill-mid        { background: color-mix(in srgb, var(--warning) 15%, transparent); color: var(--warning); }
.pill-low        { background: color-mix(in srgb, var(--error) 15%, transparent);   color: var(--error);   }
.pill-processing { background: color-mix(in srgb, var(--info) 15%, transparent);    color: var(--info);    }

/* ── buttons · STYLE §4.4 ───────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-xs);
  height: var(--button-height);
  padding: 0 var(--s-xl);
  border-radius: var(--r-pill);
  border: none;
  /* §4.4: 16 / 600 */
  font-family: var(--font);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--motion-fast) var(--curve-default);
}

.btn:disabled { opacity: .4; cursor: not-allowed; }

/*
 * ⚠️ BLACK TEXT ON LIME, ALWAYS. STYLE §1.1: `primaryForeground` is *"the only legal
 * text/icon color on a `primary` fill"*, and §1.4 lists "white text on lime" first
 * among the nevers. Lime is #A6FF00 — its contrast against white is 1.4:1.
 */
.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
}

.btn-text {
  height: auto;
  padding: 0;
  background: none;
  font-size: 15px;
  font-weight: 500;
  color: var(--primary-ink);
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-wash), 0 0 0 1.5px var(--primary-ink);
}

.btn-block { width: 100%; }

/* ── chips · STYLE §4.5 ─────────────────────────────────────────────────────── */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-grid-gap);
}

.chip {
  display: inline-flex;
  align-items: center;
  height: var(--chip-height);
  padding: 0 var(--s-md);
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  /* §4.5: `glassWash` ground. On a light web surface that reads as the elevated fill. */
  background: var(--surface-elevated);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--motion-fast) var(--curve-default);
}

/* §4.5: selected is a `primary` fill with a `primaryForeground` label at 12 / 600. */
.chip[aria-pressed="true"] {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-foreground);
  font-weight: 600;
}

.chip:focus-visible {
  outline: none;
  box-shadow: 0 0 0 1.5px var(--primary-ink);
}

/* ── the capture tiles · SPEC §3.4's two big buttons ────────────────────────── */

.modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-grid-gap);
}

@media (max-width: 480px) {
  .modes { grid-template-columns: 1fr; }
}

.mode {
  display: grid;
  gap: var(--s-sm);
  padding: var(--s-xl) var(--s-md);
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: border-color var(--motion-fast) var(--curve-default);
}

.mode:hover { border-color: var(--border-strong); }

.mode[aria-pressed="true"] {
  border-color: var(--primary-ink);
  background: var(--primary-wash);
}

.mode:focus-visible { outline: none; box-shadow: 0 0 0 1.5px var(--primary-ink); }

.mode-icon { color: var(--primary-ink); display: grid; place-items: center; }

/* ── the drop zone ──────────────────────────────────────────────────────────── */

.dropzone {
  display: grid;
  gap: var(--s-sm);
  place-items: center;
  padding: var(--s-xxl) var(--s-md);
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
  background: var(--surface);
  transition: border-color var(--motion-fast) var(--curve-default),
              background var(--motion-fast) var(--curve-default);
}

.dropzone.is-over {
  border-color: var(--primary-ink);
  background: var(--primary-wash);
}

.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: var(--s-grid-gap);
}

.thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--r-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-elevated);
}

.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ── progress ───────────────────────────────────────────────────────────────── */

.bar {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--surface-elevated);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0;
  border-radius: var(--r-pill);
  background: var(--primary);
  transition: width var(--motion-slow) var(--curve-default);
}

/* ── notices · STYLE §4.9 ───────────────────────────────────────────────────── */

/* §4.9: `noticeSurface` is dark in BOTH modes, with `onNoticeSurface` text at 14 / 400. */
.toast {
  position: fixed;
  left: 50%;
  bottom: var(--s-xl);
  transform: translateX(-50%);
  max-width: calc(100% - 2 * var(--s-lg));
  padding: var(--s-md);
  border-radius: var(--r-md);
  background: var(--notice-surface);
  color: var(--on-notice);
  font-size: 14px;
  font-weight: 400;
  box-shadow: var(--shadow-sheet);
  z-index: 10;
}

.toast[hidden] { display: none; }

/* An inline banner, for the honest sentence STYLE §6 requires and for errors. */
.notice {
  padding: var(--s-md);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
}

.notice-warning {
  border-color: color-mix(in srgb, var(--warning) 40%, var(--border));
  background: color-mix(in srgb, var(--warning) 8%, var(--surface));
}

.notice-error {
  border-color: color-mix(in srgb, var(--error) 40%, var(--border));
  background: color-mix(in srgb, var(--error) 8%, var(--surface));
}

/* ── sheets · STYLE §4.8 ────────────────────────────────────────────────────── */

/* §4.8: `surfaceElevated`, top radius `xxl` (28), a grabber, `scrim` behind. */
.scrim {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  z-index: 20;
}

.scrim[hidden], .sheet[hidden] { display: none; }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 21;
  margin: 0 auto;
  max-width: 680px;
  padding: var(--s-md) var(--s-lg) var(--s-xl);
  background: var(--surface-elevated);
  border-radius: var(--r-xxl) var(--r-xxl) 0 0;
  box-shadow: var(--shadow-sheet);
}

/* §4.8: 36 x 5 pt, `borderStrong`, 8 pt from the top. */
.grabber {
  width: 36px;
  height: 5px;
  margin: var(--s-sm) auto var(--s-md);
  border-radius: var(--r-pill);
  background: var(--border-strong);
}

/* ── groups ─────────────────────────────────────────────────────────────────── */

.group-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: var(--s-xl) 0 var(--s-sm);
}

.divider { height: 1px; background: var(--border); border: none; margin: var(--s-lg) 0; }

/* ── utilities ──────────────────────────────────────────────────────────────── */

.muted { color: var(--text-secondary); }
.dim   { color: var(--text-tertiary); }
.ink   { color: var(--primary-ink); }

/*
 * ⚠️ A DESTRUCTIVE ACTION IS `error`, NEVER LIME. STYLE §4.7: "Swipe → 'Not a window'
 * (destructive, `error` text, `outline` confirm — no red fill)." And §1.1's lime rule
 * is why it matters beyond matching the spec: lime means ACTIVE OR TAPPABLE and is
 * never decoration, so painting "Not a window" in the primary accent makes the one
 * irreversible action on the sheet look like the recommended one.
 *
 * This was `.ink` — lime in dark mode — until the rendered screenshot showed it.
 */
.error-text { color: var(--error); }
.center{ text-align: center; }
.grow  { flex: 1; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ── §3.4's Reduce Motion clause ────────────────────────────────────────────── */

/*
 * STYLE §3.4: "Reduce Motion: ring still fills (it is information, not decoration)".
 * The web fallback has no ring, but the upload progress bar is the same kind of thing —
 * information — so it keeps its width transition and everything decorative stops.
 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .bar-fill { transition-duration: var(--motion-slow) !important; }
}
