/*
 * Roof Record shared theme: the landing's (proposal A) design system as
 * global tokens + base/component styles for the whole app.
 *
 * Load order: theme.css, then landing.css (rules scoped to #page-landing),
 * then the page's own <style>. Tokens are lifted verbatim from landing A;
 * the few app-only additions (form borders, red ink, radii, shadows, motion)
 * are derived from values landing.css already uses and are marked "app".
 *
 * Isolation: nothing here styles bare headings/paragraphs, so the landing's
 * scoped rules stay authoritative inside #page-landing. Component classes
 * shared with the landing (.btn, .btn-pull, .btn-claim, .btn-ghost, .btn-sm,
 * .btn-block) carry the same values landing.css gives them.
 */

/* ── Font: self-hosted Inter + metric-matched fallback ─────────────────── */
@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('/fonts/inter-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter Fallback';
  src: local('Arial'), local('Helvetica Neue'), local('Liberation Sans');
  size-adjust: 107.6%;
  ascent-override: 90.2%;
  descent-override: 22.5%;
  line-gap-override: 0%;
}

/* ── Tokens ────────────────────────────────────────────────────────────── */
:root {
  /* Palette (landing A) */
  --navy: #031b35;
  --navy-2: #0a2a50;
  --navy-3: #021327;          /* landing footer */
  --blue-700: #0647a3;        /* royal: primary actions */
  --blue-800: #053a88;        /* royal hover */
  --blue-600: #0765d8;
  --blue-500: #277cdd;        /* accents, focus ring */
  --blue-100: #dbe8fa;
  --blue-50: #f3f7fd;
  --sky: #8fc0ff;             /* accents on dark */
  --ink: #0b2038;
  --muted: #4a5b70;
  --muted-on-dark: #c4d4e8;
  --line: #d9e2ee;
  --line-dark: #1d3f6b;
  --white: #fff;
  --green: #4caf7d;
  --green-ink: #19693f;
  --green-50: #e9f6ef;
  --red: #dc2626;
  --amber-200: #fde68a;
  --amber-ink: #8a4b05;
  --orange: #f08c00;
  --lime: #8fbf5a;

  /* app: derived from the palette above */
  --line-strong: #7d93ae;     /* form borders, >= 3:1 on white */
  --red-ink: #b42318;         /* error text, AA on --red-50 */
  --red-50: #fef3f2;
  --red-100: #fbd5d1;
  --amber-50: #fffaf0;        /* landing .storms tr.used */

  /* Type */
  --font: 'Inter Variable', 'Inter Fallback', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --fs-h1: clamp(2.25rem, 1.4rem + 3.4vw, 3.75rem);
  --fs-h2: clamp(1.75rem, 1.3rem + 1.8vw, 2.75rem);
  --fs-h3: clamp(1.0625rem, 1rem + 0.3vw, 1.25rem);
  --fs-lead: clamp(1.0625rem, 1rem + 0.35vw, 1.25rem);
  --fs-page: clamp(1.75rem, 1.35rem + 1.6vw, 2.5rem); /* app page titles */

  /* Layout */
  --wrap: 76rem;
  --gutter: clamp(1.25rem, 4vw, 2.5rem);
  --section: clamp(4rem, 8vw, 7rem);

  /* Shape (values used by landing.css) */
  --r-sm: 0.5rem;             /* buttons, inputs */
  --r-md: 0.875rem;           /* .lookup panel */
  --r-lg: 1rem;               /* cards, report */
  --shadow-panel: 0 1px 2px rgba(3, 27, 53, 0.04), 0 12px 32px -16px rgba(3, 27, 53, 0.18);
  --shadow-report: 0 2px 4px rgba(3, 27, 53, 0.04), 0 24px 48px -20px rgba(3, 27, 53, 0.28), 0 48px 96px -48px rgba(6, 71, 163, 0.35);

  /* Motion */
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --t-fast: 0.12s;
  --t: 0.15s;
}

/* ── Base ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--white);
  font-feature-settings: 'cv11', 'ss03';
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
.tnum { font-variant-numeric: tabular-nums; }

:focus-visible { outline: 3px solid var(--blue-500); outline-offset: 3px; border-radius: 4px; }
.on-dark :focus-visible, .nav :focus-visible { outline-color: var(--sky); }

/* ── Global nav bar (index.html + methodology.html) ────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  height: 68px; padding: 0 32px;
  background: var(--navy); color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.nav-logo { display: inline-flex; align-items: center; text-decoration: none; }
.nav-logo img, .nav > img { height: 38px; width: auto; display: block; }
.nav-back {
  display: inline-flex; align-items: center; gap: 0.35rem; min-height: 2.75rem;
  color: var(--muted-on-dark); font-size: 0.875rem; font-weight: 550; text-decoration: none; white-space: nowrap;
  transition: color var(--t) var(--ease);
}
.nav-back:hover { color: #fff; }
@media (max-width: 600px) {
  .nav { padding: 0 16px; }
  .nav-logo img, .nav > img { height: 19px; }
}

/* ── Buttons (landing .btn family) ─────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 3rem; padding: 0.75rem 1.4rem; border-radius: var(--r-sm); border: 1.5px solid transparent;
  font: inherit; font-weight: 650; font-size: 1rem; line-height: 1.2; text-decoration: none; cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--t) var(--ease), border-color var(--t) var(--ease), color var(--t) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t) var(--ease);
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-pull, .btn-primary { background: var(--blue-700); color: #fff; }
.btn-pull:hover:not(:disabled), .btn-primary:hover:not(:disabled) { background: var(--blue-800); }
.btn-claim { background: var(--navy); color: #fff; }
.btn-claim:hover:not(:disabled) { background: var(--navy-2); }
.btn-ghost, .btn-outline, .btn-secondary { background: #fff; color: var(--blue-700); border-color: var(--blue-700); }
.btn-ghost:hover:not(:disabled), .btn-outline:hover:not(:disabled), .btn-secondary:hover:not(:disabled) { background: var(--blue-50); }

/* On navy (nav, dark bands): landing .on-dark variants */
.on-dark .btn-pull { background: #fff; color: var(--navy); }
.on-dark .btn-pull:hover:not(:disabled) { background: var(--blue-100); }
.on-dark .btn-claim, .on-dark .btn-ghost { background: transparent; color: #fff; border-color: #6f8db3; }
.on-dark .btn-claim:hover:not(:disabled), .on-dark .btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.08); border-color: #fff; }

.btn-sm { min-height: 2.5rem; padding: 0.5rem 1rem; font-size: 0.9375rem; }
.btn-block { width: 100%; }

/* ── Page header (app pages) ───────────────────────────────────────────── */
.eyebrow { font-size: 0.8125rem; font-weight: 650; letter-spacing: 0.1em; text-transform: uppercase; color: var(--blue-700); margin-bottom: 0.9rem; }
.on-dark .eyebrow { color: var(--sky); }
.section-header { margin-bottom: clamp(1.5rem, 3vw, 2rem); }
.section-header h1 {
  font-size: var(--fs-page); font-weight: 700; letter-spacing: -0.025em; line-height: 1.1;
  color: var(--navy); text-wrap: balance;
}
.section-header p { margin-top: 0.75rem; font-size: 1.0625rem; line-height: 1.55; color: var(--muted); max-width: 40rem; text-wrap: pretty; }

/* ── Panels / cards (landing .lookup + .report treatment) ──────────────── */
.panel {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-md);
  padding: clamp(1.25rem, 3vw, 1.75rem); box-shadow: var(--shadow-panel);
}
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.25rem; }
.card-title { font-weight: 700; color: var(--ink); }
.card-sub { font-size: 0.875rem; color: var(--muted); }
.divider { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }

/* ── Forms ─────────────────────────────────────────────────────────────── */
.field { margin-bottom: 1.25rem; }
.field label { display: block; margin-bottom: 0.4rem; font-size: 0.875rem; font-weight: 600; color: var(--ink); }
.field input, .field select, .field textarea {
  display: block; width: 100%; min-height: 3rem; padding: 0.7rem 0.9rem;
  border: 1.5px solid var(--line-strong); border-radius: var(--r-sm);
  background: #fff; color: var(--ink); font-size: 1rem; line-height: 1.4;
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.field input::placeholder, .field textarea::placeholder { color: #6b7c90; opacity: 1; }
.field input:hover, .field select:hover, .field textarea:hover { border-color: var(--muted); }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--blue-600); box-shadow: 0 0 0 3px rgba(39, 124, 221, 0.35);
}
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible { outline: none; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.field-hint { margin-top: 0.4rem; font-size: 0.8125rem; color: var(--muted); }
/* Native select with a CSS chevron (no data: URIs under the CSP) */
.select-wrap { position: relative; }
.select-wrap select { appearance: none; -webkit-appearance: none; padding-right: 2.5rem; cursor: pointer; }
.select-wrap::after {
  content: ''; position: absolute; right: 1rem; top: 50%; width: 0.5rem; height: 0.5rem; pointer-events: none;
  border-right: 2px solid var(--blue-700); border-bottom: 2px solid var(--blue-700); transform: translateY(-70%) rotate(45deg);
}
@media (max-width: 600px) { .field-row { grid-template-columns: 1fr; } }

/* ── Alerts ────────────────────────────────────────────────────────────── */
.alert {
  display: none; margin-bottom: 1.25rem; padding: 0.8rem 1rem 0.8rem 1.1rem;
  border: 1px solid; border-left-width: 4px; border-radius: var(--r-sm);
  font-size: 0.9375rem; line-height: 1.5; text-wrap: pretty;
}
.alert.show { display: block; }
.alert a { color: inherit; text-underline-offset: 0.18em; }
.alert-error { background: var(--red-50); color: var(--red-ink); border-color: var(--red-100); border-left-color: var(--red); }
.alert-success { background: var(--green-50); color: var(--green-ink); border-color: #bfe3cf; border-left-color: var(--green); }
.alert-info { background: var(--blue-50); color: var(--navy); border-color: var(--blue-100); border-left-color: var(--blue-600); }
.alert-info a { color: var(--blue-700); }
.alert-notice { background: var(--amber-50); color: #5b3a00; border-color: var(--amber-200); border-left-color: #c9a227; }

/* ── Spinner ───────────────────────────────────────────────────────────── */
.spinner {
  display: inline-block; width: 1rem; height: 1rem; flex: none;
  border: 2px solid rgba(255, 255, 255, 0.35); border-top-color: #fff; border-radius: 50%;
  animation: rr-spin 0.7s linear infinite;
}
@keyframes rr-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}
