/* PreDealCheck — static site stylesheet */

:root {
  /* type scale, ratio 1.25 */
  --fs-xs: 0.8rem;
  --fs-sm: 0.9rem;
  --fs-base: 1.0625rem;
  --fs-md: 1.25rem;
  --fs-lg: 1.5625rem;
  --fs-xl: 1.953rem;
  --fs-2xl: 2.441rem;
  --fs-hero: clamp(2.6rem, 5.5vw, 4rem);

  /* spacing, 8px base */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 16px;
  --sp-4: 24px;
  --sp-5: 32px;
  --sp-6: 48px;
  --sp-7: 64px;
  --sp-8: 80px;

  /* border radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* max-widths */
  --measure: 66ch;
  --content: 1080px;

  /* dark is the default ground */
  --bg: #0c1116;
  --surface: #151d24;
  --border: #263139;
  --text: #e7eef4;
  --muted: #94a7b4;
  --accent: #3ddc9a;
  --accent-ink: #06231a;
  --supported: #62d3a4;
  --contradicted: #ff8f77;
  --mismatch: #f0c674;
  --unverified: #94a7b4;
}

/* Base styles */
body {
  background: var(--bg);
  color: var(--text);
  font: var(--fs-base) / 1.65 system-ui, sans-serif;
  margin: 0;
  padding: 0;
}

h1 {
  font-size: var(--fs-2xl);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0;
}

h2 {
  font-size: var(--fs-xl);
  line-height: 1.2;
  margin: var(--sp-6) 0 var(--sp-4) 0;
}

h3 {
  font-size: var(--fs-lg);
  margin: var(--sp-4) 0 var(--sp-2) 0;
}

p {
  margin: var(--sp-2) 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Layout: shell, prose, section */
.shell {
  max-width: var(--content);
  margin: 0 auto;
  padding: 0 var(--sp-3);
  box-sizing: border-box;
}

.prose {
  max-width: var(--measure);
}

.section {
  margin: var(--sp-7) 0;
}

/* Hero */
.hero {
  margin-bottom: var(--sp-7);
}

.hero h1 {
  font-size: var(--fs-hero);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 var(--sp-4) 0;
}

.hero .lede {
  font-size: var(--fs-md);
  color: var(--muted);
  margin: 0;
}

/* Actions */
.cta-row {
  display: flex;
  gap: var(--sp-3);
  margin: var(--sp-4) 0;
  flex-wrap: wrap;
}

.btn {
  border-radius: var(--radius-md);
  padding: 12px 20px;
  font-weight: 600;
  text-decoration: none;
  display: inline-block;
  cursor: pointer;
  border: none;
  transition: opacity 0.2s ease;
  font-size: var(--fs-base);
}

.btn:hover {
  opacity: 0.85;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

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

/* Cards and grids */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--sp-4);
}

@media (max-width: 719px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
}

/* State pills */
.pill {
  display: inline-block;
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: var(--fs-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.pill--supported {
  background: var(--supported);
  color: #000;
}

.pill--contradicted {
  background: var(--contradicted);
  color: #000;
}

.pill--mismatch {
  background: var(--mismatch);
  color: #000;
}

.pill--unverified {
  background: var(--unverified);
  color: #000;
}

/* Demo widget */
.demo {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
}

.demo__inputs {
  margin-bottom: var(--sp-4);
}

.demo__output {
  margin-top: var(--sp-4);
}

.field {
  margin-bottom: var(--sp-3);
}

.field label {
  display: block;
  font-size: var(--fs-sm);
  margin-bottom: var(--sp-1);
  font-weight: 600;
}

textarea.src {
  font-family: monospace;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: var(--sp-2);
  border-radius: var(--radius-md);
  width: 100%;
  box-sizing: border-box;
  font-size: var(--fs-sm);
  resize: vertical;
  min-height: 120px;
}

textarea.src:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input[type="text"],
input[type="number"] {
  font-family: system-ui, sans-serif;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: var(--sp-2);
  border-radius: var(--radius-md);
  width: 100%;
  box-sizing: border-box;
  font-size: var(--fs-base);
}

input[type="text"]:focus-visible,
input[type="number"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.finding {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
  margin: var(--sp-3) 0;
}

.finding__head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}

.finding__math {
  background: var(--bg);
  border-radius: var(--radius-md);
  padding: var(--sp-2);
  font-family: monospace;
  font-size: var(--fs-sm);
  overflow-x: auto;
}

.evidence {
  margin: var(--sp-3) 0 0 0;
}

.evidence summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  user-select: none;
}

.evidence summary:hover {
  text-decoration: underline;
}

.evidence > * {
  margin-top: var(--sp-2);
}

/* Utility classes */
.skip-link {
  position: absolute;
  top: -40px;
  left: -40px;
  background: var(--accent);
  color: var(--accent-ink);
  padding: var(--sp-2) var(--sp-3);
  text-decoration: none;
  border-radius: var(--radius-md);
  z-index: 1000;
}

.skip-link:focus {
  top: var(--sp-3);
  left: var(--sp-3);
}

.muted {
  color: var(--muted);
}

.small {
  font-size: var(--fs-sm);
}

.mono {
  font-family: monospace;
  font-size: var(--fs-sm);
}

.anchor-note {
  font-size: var(--fs-xs);
  color: var(--muted);
}

/* Table responsiveness */
.table-wrap {
  overflow-x: auto;
  margin: var(--sp-4) 0;
  border-radius: var(--radius-md);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 100%;
}

table th,
table td {
  padding: var(--sp-2);
  text-align: left;
  border: 1px solid var(--border);
}

table th {
  background: var(--surface);
  font-weight: 600;
  font-size: var(--fs-sm);
}

table tr:hover {
  background: var(--surface);
}

/* Navigation */
.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav .shell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3);
}

.nav__brand {
  font-weight: 700;
  font-size: var(--fs-md);
  color: var(--text);
  text-decoration: none;
  margin-right: var(--sp-6);
}

.nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: var(--sp-4);
}

.nav li {
  margin: 0;
}

.nav a {
  font-weight: 500;
  font-size: var(--fs-sm);
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.nav a:hover,
.nav a[aria-current="page"] {
  color: var(--accent);
}

/* Footer */
.footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  margin-top: var(--sp-7);
  padding: var(--sp-6) 0;
}

.footer .shell {
  padding: var(--sp-3);
}

.footer p {
  margin: 0;
}

.footer a {
  color: var(--accent);
}

/* Light mode */
@media (prefers-color-scheme: light) {
  :root {
    --bg: #ffffff;
    --surface: #f5f7f9;
    --border: #d0d5da;
    --text: #0d1117;
    --muted: #636e7a;
    --accent: #0d8c6b;
    --accent-ink: #ffffff;
    --supported: #2da76f;
    --contradicted: #cf442e;
    --mismatch: #b08500;
    --unverified: #636e7a;
  }

  body {
    background: var(--bg);
    color: var(--text);
  }

  a {
    color: var(--accent);
  }

  textarea.src,
  input[type="text"],
  input[type="number"] {
    background: var(--bg);
    border-color: var(--border);
    color: var(--text);
  }
}

/* Print */
@media print {
  body {
    background: white;
    color: black;
    margin: 0;
    padding: 0;
  }

  .nav {
    display: none;
  }

  .footer {
    display: none;
  }

  .card,
  .demo,
  .finding {
    background: white;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  a {
    color: inherit;
    text-decoration: underline;
  }

  .muted {
    color: #555;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto !important;
  }
}

/* Responsive: 400px minimum with 16px side gutter */
@media (max-width: 479px) {
  .shell {
    padding: 0 var(--sp-3);
  }

  h2 {
    font-size: var(--fs-lg);
  }

  .cta-row {
    flex-direction: column;
  }

  .btn {
    width: 100%;
    text-align: center;
  }

  .nav .shell {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-2);
  }

  .nav__brand {
    margin-right: 0;
  }

  .nav ul {
    flex-direction: column;
    gap: var(--sp-2);
  }
}
