/* System font stacks only — no webfont import, no font in impeccable's
   overused-font list. Two families for real hierarchy: a monospace for
   data/scores, a plain system sans for prose. */
:root {
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --bg: #f7f5f0;
  --fg: #17150f;
  --fg-muted: #514d41;
  --border: #d8d3c5;
  --accent: #b5450f;
  --accent-fg: #fffaf3;
  --surface: #ffffff;
  --slop-tag: #b5450f;
  --quality-tag: #3d5a3d;
  --radius: 3px;
  /* Full width of main's content box, so the header/form/status column
     matches the width of the result section below it. */
  --content-width: 100%;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15130f;
    --fg: #ede8dc;
    --fg-muted: #a9a290;
    --border: #3a352b;
    --accent: #e8763f;
    --accent-fg: #15130f;
    --surface: #1c1a14;
    --slop-tag: #e8763f;
    --quality-tag: #7fb17f;
  }
}

* { box-sizing: border-box; }

html { color-scheme: light dark; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
}

main {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 24px 96px;
}

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

/* Header */
.site-header {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 56px 24px 8px;
}

.header-inner {
  max-width: var(--content-width);
  margin: 0 auto;
  font-size: 19px;
}

.wordmark {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 36px;
  letter-spacing: -0.01em;
  color: var(--fg);
  text-decoration: none;
}

.subhead {
  margin: 12px 0 0;
  color: var(--fg-muted);
  font-size: 1em;
}

/* Scan form */
.scan-form-section {
  padding: 28px 0 40px;
}

#scan-form {
  display: flex;
  gap: 10px;
  max-width: var(--content-width);
  margin: 0 auto;
  font-size: 19px;
}

#url-input {
  flex: 1;
  min-width: 0;
  padding: 16px 17px;
  font-size: 17px;
  font-family: var(--mono);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg);
}

#url-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

#url-input:disabled {
  opacity: 0.55;
  cursor: default;
}

#scan-button {
  padding: 16px 25px;
  font-size: 17px;
  font-weight: 600;
  font-family: var(--sans);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-fg);
  cursor: pointer;
}

#scan-button:hover { filter: brightness(1.08); }
#scan-button:disabled { opacity: 0.55; cursor: default; }

.quick-try {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  max-width: var(--content-width);
  margin: 14px auto 0;
}

.quick-try-label {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--fg-muted);
}

.quick-try-chip {
  padding: 4px 10px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--fg-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}

.quick-try-chip:hover {
  color: var(--fg);
  border-color: var(--accent);
}

.quick-try-chip:disabled {
  opacity: 0.55;
  cursor: default;
}

.quick-try-chip:disabled:hover {
  color: var(--fg-muted);
  border-color: var(--border);
}

/* Status */
.status {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: var(--content-width);
  margin: 0 auto;
  max-height: 120px;
  padding: 28px 0;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--fg-muted);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  transition: opacity 0.25s ease, max-height 0.25s ease, padding 0.25s ease, border-color 0.25s ease;
}

.status[hidden] { display: none; }

.status.is-error { color: var(--slop-tag); }

.status.is-fading {
  opacity: 0;
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-color: transparent;
}

.status-spinner {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.status.is-error .status-spinner { display: none; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .status-spinner { animation-duration: 1.6s; }
  .status, .result { transition: none; }
}

/* Result */
.result {
  padding: 40px 0;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.result.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.result-top {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 20px 28px;
  align-items: start;
}

.gauge-card {
  position: relative;
  width: 216px;
  padding: 14px 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}

.gauge {
  width: 100%;
  height: auto;
  display: block;
}

.gauge-track {
  fill: none;
  stroke: var(--border);
  stroke-width: 14;
  stroke-linecap: round;
}

.gauge-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 14;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease, stroke 0.6s ease;
}

/* Gauge color by score band — green (clean) through red (maximum slop).
   Same boundaries as GAUGE_BANDS in app.js / GRADE_BANDS in score.ts. */
.gauge-fill.band-0 { stroke: #3d7a3d; }
.gauge-fill.band-1 { stroke: #6b8f3d; }
.gauge-fill.band-2 { stroke: #b5900f; }
.gauge-fill.band-3 { stroke: #c2701a; }
.gauge-fill.band-4 { stroke: #b5450f; }
.gauge-fill.band-5 { stroke: #8f2a0a; }

@media (prefers-color-scheme: dark) {
  .gauge-fill.band-0 { stroke: #6fbf6f; }
  .gauge-fill.band-1 { stroke: #9dc25a; }
  .gauge-fill.band-2 { stroke: #e0b83a; }
  .gauge-fill.band-3 { stroke: #e8894a; }
  .gauge-fill.band-4 { stroke: #e8763f; }
  .gauge-fill.band-5 { stroke: #e0543a; }
}

.gauge-number {
  position: absolute;
  left: 50%;
  top: 60%;
  transform: translate(-50%, -50%);
  font-family: var(--mono);
  font-weight: 700;
  font-size: 40px;
  line-height: 1;
}

.gauge-label {
  position: absolute;
  left: 50%;
  top: 80%;
  transform: translate(-50%, -50%);
  width: 100%;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--fg-muted);
  white-space: nowrap;
}

.result-url {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--fg);
  word-break: break-all;
}

.result-blurb {
  margin: 8px 0 0;
  font-size: 16px;
}

.result-counts {
  margin: 8px 0 0;
  font-size: 13.5px;
  color: var(--fg-muted);
  font-family: var(--mono);
}

.result-screenshot {
  display: block;
  width: 100%;
  max-height: 380px;
  object-fit: cover;
  object-position: top;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0 0 32px;
}

.verdict {
  margin: 28px 0 0;
  padding: 16px 18px;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  font-size: 16px;
}

/* Overview + top offenders — the "organized" summary layer that sits above
   the full findings list. */
.overview-block { margin-top: 36px; }

.block-heading {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 700;
}

.overview-row {
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.overview-row:first-child { border-top: none; padding-top: 0; }

.overview-row-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.overview-row-name { font-weight: 600; font-size: 14.5px; }

.overview-row-count {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--fg-muted);
}

.overview-row-pct {
  font-family: var(--mono);
  font-size: 14.5px;
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
}

.overview-bar-track {
  margin-top: 6px;
  height: 5px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
}

.overview-bar-fill {
  height: 100%;
  background: var(--accent);
}

.top-findings { display: flex; flex-direction: column; }

.top-finding-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 9px 0;
  border-top: 1px solid var(--border);
  font-size: 14.5px;
}

.top-finding-row:first-child { border-top: none; padding-top: 0; }

.top-finding-rank {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg-muted);
  width: 1.4em;
  flex-shrink: 0;
}

.top-finding-name { font-weight: 600; }

.top-finding-where {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg-muted);
  opacity: 0.8;
}

/* Findings, grouped by section — plain list rows, deliberately not a grid
   of icon-topped cards. */
.section-block {
  padding: 22px 0;
  border-top: 1px solid var(--border);
}

.section-block:first-child { border-top: none; padding-top: 0; }

.section-heading {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 700;
}

.section-count {
  font-family: var(--mono);
  font-weight: 400;
  font-size: 13px;
  color: var(--fg-muted);
}

.finding {
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.finding:first-child { border-top: none; padding-top: 0; }

.finding-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}

.finding-name { font-weight: 600; font-size: 15px; }

.finding-tag {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: var(--radius);
  border: 1px solid currentColor;
}

.finding-tag.slop { color: var(--slop-tag); }
.finding-tag.quality { color: var(--quality-tag); }

.finding-desc {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--fg-muted);
}

.finding-detail {
  margin: 6px 0 0;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--fg-muted);
  word-break: break-word;
}

.finding-selector {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--fg-muted);
  opacity: 0.75;
}

.empty-state {
  padding: 24px 0;
  color: var(--fg-muted);
}

@media (max-width: 560px) {
  .result-top { grid-template-columns: 1fr; }
  .gauge-card { width: 100%; max-width: 280px; margin: 0 auto; }
}
