/* ForFree draw checker. Served from /verify/ under the site's static CSP: this file is the page's only style.
   Colors are the ForFree document palette (design/tokens.json). Lime marks the one primary action on every
   ground (kb/funnel-design-rules.md): ink fill and lime label on paper, lime fill and ink label on ink. Orange
   is never an action color. Phone first (RULES.md section 5): 16 px margins and safe areas, 48 px controls,
   press feedback on every tap, type in rem. */

@font-face {
  font-family: "Archivo Black";
  src: url("./fonts/archivo-black-latin.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("./fonts/jetbrains-mono-latin-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("./fonts/jetbrains-mono-latin-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #F4F0E6;
  --paper-hi: #FBF9F5;
  --paper-lo: #E7E3DA;
  --ink: #15131D;
  --ink-deep: #0B0A10;
  --ink-70: #585559;
  --ink-24: #BEBBB6;
  --lime: #D4F53C;
  --orange-text: #BB441D;

  --bg: var(--paper);
  --surface: var(--paper-hi);
  --well: var(--paper-lo);
  --text: var(--ink);
  --muted: var(--ink-70);
  --rule: var(--ink-24);
  --block: var(--ink);
  --cta-fill: var(--ink);
  --cta-label: var(--lime);
  --focus: var(--ink-deep);
  --bad: var(--orange-text);
  --bar: rgba(244, 240, 230, 0.86);

  --font-display: "Archivo Black", "Arial Black", system-ui, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --gutter: 16px;
  --radius: 14px;
  --radius-control: 12px;
  --step: cubic-bezier(0.2, 0.9, 0.1, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: var(--ink);
    --surface: #2B2931;
    --well: #1F1D26;
    --text: var(--paper);
    --muted: #B1AEAA;
    --rule: #423F45;
    --block: var(--ink-deep);
    --cta-fill: var(--lime);
    --cta-label: var(--ink-deep);
    --focus: var(--paper);
    --bad: #F2551D;
    --bar: rgba(21, 19, 29, 0.86);
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Focus moves and scrolls never park anything under the action bar (WCAG 2.4.11). */
  scroll-padding-top: 12px;
  scroll-padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 1rem/1.5 var(--font-body);
  /* 64-character hashes sit in running text; they wrap instead of widening the page. */
  overflow-wrap: anywhere;
}

.page {
  max-width: 44rem;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) 0 max(var(--gutter), env(safe-area-inset-left));
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
}
.skip-link:focus {
  left: var(--gutter);
  top: 8px;
  z-index: 3;
  background: var(--surface);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius-control);
}

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

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

/* Masthead: a large title, the way an iPhone screen opens. */
.masthead {
  padding: 8px 0 4px;
}
.brandline {
  margin: 0 0 10px;
  font: 700 0.75rem/1.3 var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
h1 {
  margin: 0 0 12px;
  font: 400 2.125rem/1.05 var(--font-display);
  letter-spacing: -0.01em;
}
.lede {
  margin: 0;
  font-size: 1.0625rem;
  max-width: 34rem;
}
h2 {
  margin: 0 0 6px;
  font: 400 1.375rem/1.15 var(--font-display);
}
h3 {
  margin: 24px 0 10px;
  font-size: 1.0625rem;
  font-weight: 700;
}

.panel {
  margin: 20px 0;
  padding: 18px var(--gutter);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px var(--rule);
}

.hint {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.9375rem;
}

label {
  display: block;
  margin: 14px 0 6px;
  font-weight: 600;
}

textarea,
input[type="text"] {
  display: block;
  width: 100%;
  min-height: 48px;
  margin: 0;
  padding: 12px 14px;
  font: 400 0.875rem/1.45 var(--font-mono);
  font-variant-ligatures: none;
  color: var(--text);
  background: var(--well);
  border: 1px solid var(--rule);
  border-radius: var(--radius-control);
}
textarea {
  min-height: 9.5rem;
  resize: vertical;
}

/* Buttons. One primary action per view: the lime one. Everything else is secondary. */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  min-width: 44px;
  margin: 12px 0 0;
  padding: 12px 20px;
  font: 700 1.0625rem/1.2 var(--font-body);
  border-radius: 999px;
  border: 0;
  cursor: pointer;
  text-align: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 120ms var(--step), opacity 120ms var(--step);
}
.button:active {
  transform: translateY(1px) scale(0.98);
}
.primary {
  width: 100%;
  margin: 0;
  background: var(--cta-fill);
  color: var(--cta-label);
}
.primary[disabled] {
  opacity: 0.55;
  cursor: progress;
}
.secondary {
  background: transparent;
  color: var(--text);
  box-shadow: inset 0 0 0 2px var(--text);
}
#record-file:focus-visible + label {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
.file-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.progress {
  min-height: 1.5em;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.9375rem;
}

/* The primary action sits low, in the thumb zone, on a material bar. */
.actionbar {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin: 0 calc(-1 * max(var(--gutter), env(safe-area-inset-left)));
  padding: 12px max(var(--gutter), env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
  background: var(--bar);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  box-shadow: 0 -1px 0 var(--rule);
}

/* Results. */
.empty {
  padding: 18px 16px;
  border-radius: var(--radius-control);
  background: var(--well);
  color: var(--muted);
}
.empty p {
  margin: 0;
}
.empty-title {
  margin-bottom: 4px !important;
  color: var(--text);
  font-weight: 700;
}

.verdict {
  margin: 8px 0 14px;
  padding: 16px 18px;
  font: 400 1.375rem/1.2 var(--font-display);
  border-radius: var(--radius-control);
  border-left: 8px solid var(--text);
  background: var(--well);
}
.verdict[data-verdict="mismatch"] {
  color: var(--bad);
  border-left-color: var(--bad);
}
.verdict[data-verdict="incomplete"] {
  border-left-style: dashed;
}
/* The verdict takes focus by script so screen readers start there; it is not a control, so no ring. */
.verdict:focus {
  outline: none;
}
.fingerprint {
  font-weight: 700;
}
.status-line {
  margin: 0 0 12px;
}

.facts {
  margin: 0;
}
.facts dt {
  margin-top: 12px;
  font: 700 0.75rem/1.3 var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.facts dd {
  margin: 4px 0 0;
}
.mono,
code {
  font-family: var(--font-mono);
  font-variant-ligatures: none;
  font-size: 0.875rem;
}

/* A value you can tap to copy: hashes, keys, codes. */
.copy {
  display: block;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 10px 12px;
  text-align: left;
  font: 400 0.875rem/1.45 var(--font-mono);
  font-variant-ligatures: none;
  color: var(--text);
  background: var(--well);
  border: 0;
  border-radius: 10px;
  cursor: copy;
  overflow-wrap: anywhere;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 120ms var(--step);
}
.copy:active {
  transform: scale(0.99);
}

.note {
  margin: 14px 0 0;
  padding: 14px 16px;
  border-radius: var(--radius-control);
  background: var(--well);
}
.note p {
  margin: 0;
}

.calls,
.checks {
  margin: 0;
  padding: 0;
  list-style: none;
}
.call {
  margin: 0 0 12px;
  padding: 14px 14px 12px;
  border-radius: var(--radius-control);
  background: var(--well);
}
.call-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 12px;
  margin: 0 0 8px;
}
.call-title {
  margin: 0;
  font: 700 1rem/1.3 var(--font-body);
}
.call-title .mono {
  font-size: 0.9375rem;
}
.badge {
  display: inline-block;
  padding: 3px 10px;
  font: 700 0.75rem/1.4 var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1.5px currentColor;
}
.badge[data-tone="bad"] {
  color: var(--bad);
}
.call dl {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px 16px;
  margin: 0;
}
.call dt {
  margin-top: 8px;
  font: 700 0.6875rem/1.3 var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.call dd {
  margin: 2px 0 0;
}
.code-chip {
  font: 700 1.25rem/1.2 var(--font-mono);
  letter-spacing: 0.12em;
}
.call .note-line {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}
.call[data-match="false"] {
  box-shadow: inset 4px 0 0 var(--bad);
}

.checks li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  align-items: start;
  padding: 10px 0;
  border-top: 1px solid var(--rule);
}
.checks li:first-child {
  border-top: 0;
}
.check-label {
  font-weight: 600;
}
.check-detail {
  grid-column: 2;
  color: var(--muted);
  font-size: 0.9375rem;
}
.status-tag {
  min-width: 5.5rem;
  padding: 2px 8px;
  font: 700 0.6875rem/1.6 var(--font-mono);
  letter-spacing: 0.04em;
  text-align: center;
  text-transform: uppercase;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1.5px currentColor;
}
.status-tag[data-status="fail"] {
  color: var(--bad);
}
.status-tag[data-status="skip"] {
  color: var(--muted);
}

.warnings {
  margin: 12px 0 0;
  padding-left: 1.2rem;
  color: var(--bad);
}
.warnings:empty {
  display: none;
}

form .button {
  width: 100%;
}
.entry-result {
  min-height: 1.5em;
  margin: 12px 0 0;
}

.relays {
  margin: 0;
  padding: 0;
  list-style: none;
}
.relays li {
  margin: 0;
}
.relays a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

.how summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  font: 400 1.25rem/1.2 var(--font-display);
  cursor: pointer;
  list-style: none;
}
.how summary::-webkit-details-marker {
  display: none;
}
.how summary::after {
  content: "+";
  margin-left: auto;
  font: 700 1.5rem/1 var(--font-mono);
}
.how[open] summary::after {
  content: "\2212";
}
.how ol {
  margin: 8px 0 0;
  padding-left: 1.25rem;
}
.how li {
  margin: 8px 0;
}

.footer {
  padding: 8px 0 24px;
  color: var(--muted);
  font-size: 0.875rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom));
  z-index: 4;
  margin: 0;
  padding: 10px 16px;
  font-weight: 700;
  color: var(--bg);
  background: var(--text);
  border-radius: 999px;
  transform: translate(-50%, 12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms var(--step), transform 160ms var(--step);
}
.toast[data-show="true"] {
  opacity: 1;
  transform: translate(-50%, 0);
}

.noscript {
  margin: 0 var(--gutter) 24px;
}

/* Wider screens: the same column with more air; the action bar stays, its button sized to its label. */
@media (min-width: 700px) {
  :root {
    --gutter: 24px;
  }
  h1 {
    font-size: 2.75rem;
  }
  .panel {
    padding: 24px var(--gutter);
  }
  .call dl {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .primary {
    width: auto;
    min-width: 16rem;
  }
  form .button {
    width: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0ms !important;
  }
  .button:active,
  .copy:active {
    transform: none;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .actionbar {
    background: var(--bg);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}
