/* ==========================================================================
   Ledger & Sum — design system
   Token-based (CSS variables), "ledger" visual language: serif headlines,
   monospace figures for anything calculated, hairline rules instead of
   card shadows. One shared stylesheet — no per-page styles.
   ========================================================================== */

:root {
  /* Color */
  --color-bg: #fbf9f4;
  --color-surface: #ffffff;
  --color-text: #24211c;
  --color-text-muted: #635c4e;
  --color-accent: #2c4a3e;
  --color-accent-contrast: #ffffff;
  --color-rule: #d8d2c4;
  --color-focus: #a15c2c;

  /* Type */
  --font-serif: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  --font-size-base: 1rem;
  --font-size-small: 0.875rem;
  --font-size-h1: 2rem;
  --font-size-h2: 1.375rem;
  --line-height-base: 1.6;

  /* Spacing scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 1rem;
  --space-4: 1.5rem;
  --space-5: 2.5rem;

  /* Layout */
  --content-width: 40rem;
  --radius: 2px;

  /* Ad slot reserved space — set here so it's easy to tune once ads go live */
  --ad-slot-height: 90px;
}

/* ---- Reset ---- */

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

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
}

img {
  max-width: 100%;
}

/* ---- Typography ---- */

h1, h2, h3 {
  font-family: var(--font-serif);
  font-weight: 700;
  line-height: 1.25;
  margin: var(--space-4) 0 var(--space-2);
}

h1 {
  font-size: var(--font-size-h1);
  margin-top: 0;
}

h2 {
  font-size: var(--font-size-h2);
  border-top: 1px solid var(--color-rule);
  padding-top: var(--space-3);
}

p {
  margin: 0 0 var(--space-3);
}

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

a:hover {
  text-decoration-thickness: 2px;
}

/* Anything calculated — currency, rates, schedules — reads as ledger figures */
.figure,
output,
td.figure,
.calc-result {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ---- Focus states (visible everywhere, not just :focus) ---- */

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

/* ---- Layout ---- */

.site-header {
  border-bottom: 1px solid var(--color-rule);
  background: var(--color-surface);
}

.site-nav {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: var(--space-3);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
}

.site-brand {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.125rem;
  text-decoration: none;
  color: var(--color-text);
}

.nav-links a {
  margin-left: var(--space-3);
  text-decoration: none;
  color: var(--color-text-muted);
  font-size: var(--font-size-small);
}

.nav-links a:hover,
.nav-links a:focus-visible {
  color: var(--color-accent);
}

main {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: var(--space-4) var(--space-3);
}

.site-footer {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: var(--space-4) var(--space-3) var(--space-5);
  border-top: 1px solid var(--color-rule);
  color: var(--color-text-muted);
  font-size: var(--font-size-small);
}

.disclaimer {
  margin-bottom: var(--space-2);
}

.footer-links a {
  color: var(--color-text-muted);
}

/* ---- Reserved ad slot ----
   Present on every page from Phase 2 onward so wiring in real ad units in
   Phase 8 causes zero layout shift. Empty/inert until then. */

.ad-slot {
  max-width: var(--content-width);
  min-height: var(--ad-slot-height);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- Forms (calculators land in Phase 3, but shared control styling lives here) ---- */

label {
  display: block;
  font-size: var(--font-size-small);
  color: var(--color-text-muted);
  margin-top: var(--space-3);
}

input, select {
  width: 100%;
  padding: var(--space-2);
  margin-top: var(--space-1);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--font-size-base);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-3) 0;
}

th, td {
  text-align: left;
  padding: var(--space-2);
  border-bottom: 1px solid var(--color-rule);
}

/* ---- Responsive: verified down to 375px ---- */

@media (max-width: 480px) {
  :root {
    --font-size-h1: 1.5rem;
    --font-size-h2: 1.125rem;
  }

  .site-nav {
    flex-direction: column;
    align-items: flex-start;
  }

  .nav-links a {
    margin-left: 0;
    margin-right: var(--space-3);
  }
}

/* ---- Reduced motion ---- */

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