/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */

:root {
  /* Base */
  --color-bg: #f4ece0;        /* page background, warm off-white */
  --color-surface: #ece1d2;   /* cards, raised panels */
  --color-border: #d8cab5;    /* dividers, low-contrast warm tan */

  /* Text */
  --color-text: #3a322a;      /* body, soft near-black brown */
  --color-text-muted: #7a6f60; /* captions, metadata */

  /* Accents */
  --color-accent: #c2703d;           /* terracotta, primary */
  --color-accent-secondary: #6f7d5c; /* sage, secondary */

  /* Internal aliases */
  --bg: var(--color-bg);
  --surface: var(--color-surface);
  --line: var(--color-border);
  --ink: var(--color-text);
  --muted: var(--color-text-muted);
  --accent: var(--color-accent);
  --accent2: var(--color-accent-secondary);
  --accent-ink: #fdf6ec;
  --high: #9e3b2e;            /* warm red for flags and destructive actions */
  --ok: #586748;             /* sage-dark for the privacy pill text */
  --track: rgba(58, 50, 42, 0.14);
  --shadow: 0 1px 2px rgba(58, 40, 20, 0.10), 0 6px 18px rgba(58, 40, 20, 0.08);
  --radius: 10px;
  --content: 760px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand { font-weight: 700; letter-spacing: 0.02em; }

.pill {
  font-size: 13px;
  color: var(--ok);
  background: #e7ead8;
  border: 1px solid #cdd4ba;
  padding: 3px 10px;
  border-radius: 999px;
  cursor: default;
}

#app {
  width: 100%;
  max-width: var(--content);
  margin: 0 auto;
  padding: 24px 20px 48px;
  flex: 1;
}

.view { animation: fade 160ms ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

h1 { font-size: 24px; line-height: 1.25; margin: 18px 0 16px; }
h2 { font-size: 20px; margin: 0 0 12px; }

.privacy {
  background: #f0e6d6;
  border: 1px solid #ddccb2;
  border-radius: var(--radius);
  padding: 14px 16px;
  color: #4a3f33;
  font-size: 15px;
}
.privacy strong { display: inline; }

.copyright {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}
.copyright code { font-size: 12px; background: rgba(58, 50, 42, 0.08); padding: 1px 5px; border-radius: 4px; }

.pdf-source {
  background: #f2e2d3;
  border: 1px solid #e1c5aa;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 16px 0;
}
.pdf-source label { display: block; font-weight: 600; margin-bottom: 8px; }
.pdf-source input[type="file"] { font: inherit; max-width: 100%; }
.pdf-hint { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
.pdf-state { color: var(--muted); font-size: 13px; margin: 6px 0 0; min-height: 1.2em; }

.disclosure { margin: 16px 0; }
.disclosure summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  padding: 6px 0;
}

.canvas-frame {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  margin: 12px 0;
  overflow: hidden;
}
.canvas-frame canvas { width: 100%; height: auto; display: block; }
.canvas-frame.scale { padding: 8px 12px; }
.canvas-frame.scale.compact { margin: 8px 0 14px; padding: 6px 10px; }

.field { margin: 14px 0; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.field input {
  width: 100%;
  max-width: 360px;
  font: inherit;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.actions { display: flex; gap: 12px; margin-top: 20px; }
.actions.wrap { flex-wrap: wrap; }

button {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 10px 16px;
  transition: background 120ms ease, border-color 120ms ease, transform 60ms ease;
}
button:active { transform: translateY(1px); }
button:disabled { cursor: default; opacity: 0.55; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.primary:hover:not(:disabled) { background: #ab5f30; border-color: #ab5f30; }
.primary.big { font-size: 17px; padding: 13px 24px; font-weight: 600; }
.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.secondary:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.danger { background: transparent; color: var(--high); border-color: #d8b3aa; }
.danger:hover { background: #f3e0da; }

.status { color: var(--high); font-size: 14px; min-height: 1.2em; margin-top: 12px; }

.resume {
  background: #f2e2d3;
  border: 1px solid #e1c5aa;
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 16px 0;
}
.resume .actions { margin-top: 10px; }

/* Advanced disclosure on the review screen */
.advanced { margin: 22px 0 4px; border-top: 1px solid var(--line); padding-top: 14px; }
.advanced > summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  padding: 4px 0;
}
.advanced-body { margin-top: 6px; }
.advanced-note { color: var(--muted); font-size: 13px; margin: 4px 0 0; }

/* Progress */
.progress { margin-bottom: 8px; }
.progress-track {
  height: 8px;
  background: var(--track);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width 180ms ease;
}
.progress-text { font-size: 14px; color: var(--muted); margin-top: 6px; }

/* The item view breaks out of the prose column so the statement reads larger,
   while staying within the viewport on narrow screens. */
.stage {
  width: min(94vw, 1080px);
  margin-left: 50%;
  transform: translateX(-50%);
}

/* Item card */
.item-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin: 4px 0 18px;
  min-height: 90px;
  display: flex;
  align-items: center;
}
.item-card canvas { width: 100%; height: auto; display: block; }

/* Ratings */
.ratings {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}
.rate {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 0 10px;
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  line-height: 1.1;
}
.rate small { font-size: 11px; font-weight: 500; color: var(--muted); }
.rate:hover { border-color: var(--accent); }
.rate[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.rate[aria-pressed="true"] small { color: #f0ddc8; }

.nav { display: flex; gap: 10px; margin-top: 18px; }
.nav button { flex: 1; }
.hint { color: var(--muted); font-size: 13px; text-align: center; margin: 12px 0 0; }

/* Review grid */
.review-summary { color: var(--muted); }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  gap: 8px;
  margin: 14px 0 8px;
}
.cell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 4px;
  text-align: center;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.2;
  color: var(--ink);
}
.cell .num { color: var(--muted); font-size: 11px; }
.cell .val { font-weight: 700; font-size: 18px; }
.cell:hover { border-color: var(--accent); }
.cell.missing { border-color: #d8b3aa; background: #f3e0da; }
.cell.missing .val { color: var(--high); }

/* Scores */
.scores { margin-top: 18px; }
.scores .note { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.score-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.score-row .label { font-size: 14px; }
.score-row .abbr { color: var(--muted); font-weight: 600; margin-right: 6px; }
.score-meta { font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 14px; }
.score-meta .flag { color: var(--high); font-weight: 700; margin-left: 8px; }
.bar-wrap { grid-column: 1 / -1; height: 6px; background: var(--track); border-radius: 999px; overflow: hidden; }
.bar { height: 100%; background: var(--accent2); border-radius: 999px; }
.bar.elevated { background: var(--accent); }

.danger-row { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); }

.foot {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 18px 20px 28px;
}

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

/* Scoring page (score.html) */
.lead { color: var(--ink); margin: 0 0 8px; }
.lead code, .pdf-hint code { font-size: 13px; background: rgba(58, 50, 42, 0.08); padding: 1px 5px; border-radius: 4px; }
.result-meta { color: var(--ink); font-size: 15px; margin: 0 0 16px; }
.result-meta .dot { color: var(--muted); margin: 0 8px; }
.result-meta .muted { color: var(--muted); }

.controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 8px; }
.seg {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}
.seg-label { color: var(--muted); font-size: 13px; padding: 0 8px 0 10px; }
.seg-btn {
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  padding: 6px 14px;
  border-radius: 999px;
}
.seg-btn:hover { color: var(--accent); }
.seg-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

.score-list { margin: 8px 0 4px; }
.domain-head {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin: 22px 0 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}
.domain-head:first-child { margin-top: 6px; }

.s-row { padding: 11px 0 13px; border-bottom: 1px solid var(--line); }
.s-row.flagged { background: linear-gradient(90deg, rgba(194, 112, 61, 0.07), transparent 60%); }
.s-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.s-name { font-size: 15px; }
.s-name .abbr { color: var(--muted); font-weight: 700; margin-right: 8px; font-variant-numeric: tabular-nums; }
.s-fig { white-space: nowrap; font-variant-numeric: tabular-nums; }
.s-mean { font-weight: 700; font-size: 15px; }
.s-part { color: var(--muted); font-size: 13px; margin-left: 8px; }
.s-high { color: var(--high); font-weight: 700; font-size: 13px; margin-left: 10px; }

.s-items { display: flex; gap: 6px; margin: 9px 0 9px; }
.chip {
  min-width: 30px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 14px;
  padding: 4px 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
}
.chip.high { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.empty { color: var(--muted); border-style: dashed; }

.note { color: var(--muted); font-size: 13px; margin: 18px 0 0; }

@media (max-width: 520px) {
  .ratings { gap: 7px; }
  .rate { font-size: 19px; padding: 12px 0 8px; }
  .rate small { display: none; }
  h1 { font-size: 21px; }
}
