/* Mobile-first styles. Light palette on :root, dark overrides below.
   Editorial direction: warm paper, dark ink, one deep-green accent,
   serif headings over a system sans-serif body. */
:root {
  /* Colour */
  --bg: #faf8f3;          /* paper */
  --bg-alt: #f3efe6;      /* alternate section paper */
  --surface: #fffefb;     /* cards, table, form */
  --text: #1b1f24;        /* ink */
  --muted: #5b6470;
  --border: #e3ded3;      /* rules */
  --border-strong: #857e72; /* input boundaries, >= 3:1 on all backgrounds */
  --accent: #1f5c4a;      /* deep green */
  --accent-text: #ffffff;
  --accent-soft: #e3eee8;
  --warn-soft: #f8f0dd;
  --warn-border: #d9b86e;
  --error: #b3261e;

  /* Type. Czech diacritics checked in Chrome on macOS for Iowan Old Style, Charter, Georgia and the system sans. */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Iowan Old Style", Charter, Georgia, "Noto Serif", "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Spacing scale */
  --space-xs: .5rem;
  --space-s: .75rem;
  --space-m: 1rem;
  --space-l: 1.5rem;
  --space-xl: 2.5rem;
  --space-2xl: 3.5rem;

  --radius: 12px;
  --radius-s: 6px;        /* comparison table and fund cards */
  --gutter: 1rem;
  --maxw: 68rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a;
    --bg-alt: #191d21;
    --surface: #1e2328;
    --text: #e8e4da;
    --muted: #a7afb8;
    --border: #2c3238;
    --border-strong: #727b84;
    --accent: #7cc4a8;
    --accent-text: #14171a;
    --accent-soft: #1b2e28;
    --warn-soft: #29231a;
    --warn-border: #7a5f28;
    --error: #ff8a7a;
    color-scheme: dark;
  }
}

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

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.6 var(--font-sans);
  -webkit-text-size-adjust: 100%;
}

img { max-width: 100%; height: auto; }
a { color: var(--accent); text-underline-offset: 2px; }
a:focus-visible, button:focus-visible, summary:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
code { font-family: var(--font-mono); font-size: .92em; }

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding-inline: max(var(--gutter), env(safe-area-inset-left, 0px));
}

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: var(--accent-text); padding: .5rem 1rem; z-index: 10;
}
.skip-link:focus { left: 0; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top, 0px);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; min-height: 3.25rem; }
.logo { font-family: var(--font-serif); font-weight: 700; font-size: 1.1rem; letter-spacing: -.005em; }
.header-cta { font-weight: 600; font-size: .95rem; padding: .5rem 0; }

/* Typography */
h1, h2, h3, h4 { font-family: var(--font-serif); font-weight: 700; line-height: 1.2; margin: 0 0 var(--space-s); text-wrap: balance; }
h1 { font-size: clamp(1.65rem, 1.05rem + 3.6vw, 2.9rem); letter-spacing: -.01em; }
h2 { font-size: clamp(1.45rem, 1.15rem + 1.4vw, 2.1rem); }
h3 { font-size: 1.25rem; margin-top: 2rem; }
h4 { font-size: 1.05rem; }
p { margin: 0 0 var(--space-m); }
/* Never below 13px. */
small { color: var(--muted); font-size: max(.85em, .8125rem); }
/* Footnote markers: readable size without stretching the line height. */
sup { font-size: .8125rem; line-height: 0; }

.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .8125rem; font-weight: 700; color: var(--accent); margin-bottom: var(--space-xs); }
.lead { font-size: 1.1rem; color: var(--muted); }
.tag {
  display: inline-block; vertical-align: middle;
  font-family: var(--font-sans); font-size: .8125rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 999px; padding: .15rem .55rem; margin-left: .25rem;
}

/* Sections */
.hero { padding-block: var(--space-l); }
.section { padding-block: 2rem; }
.section-alt { background: var(--bg-alt); }
.section-note { color: var(--muted); }
.group-title { margin-top: 2.5rem; }

/* Buttons */
.hero-actions { display: flex; flex-direction: column; gap: .75rem; margin: var(--space-m) 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 3rem; padding: .75rem 1.25rem;
  border-radius: var(--radius); border: 2px solid var(--accent);
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
}
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-ghost { background: transparent; color: var(--accent); }
.disclaimer-inline { font-size: .85rem; color: var(--muted); margin-bottom: 0; }
/* CTA at the end of a section (after the comparison). Full width on phones. */
.section-cta { margin: var(--space-l) 0 0; }
.section-cta .btn { width: 100%; }
@media (min-width: 40rem) { .section-cta .btn { width: auto; } }
/* Hero teaser: the ad's promise answered with sourced numbers. */
.hero-teaser {
  margin: var(--space-m) 0 .25rem; padding-left: var(--space-s);
  border-left: 3px solid var(--accent);
  font-weight: 600; font-variant-numeric: tabular-nums;
}
.hero-teaser-src { font-size: .8125rem; color: var(--muted); margin: 0 0 0 calc(var(--space-s) + 3px); }

/* Steps */
.steps { padding-left: 1.25rem; margin: 0; }
.steps li { margin-bottom: 1.25rem; }
.steps li:last-child { margin-bottom: 0; }
.steps strong { display: block; }
.src { display: block; font-size: .85rem; margin-top: .25rem; }

/* US table */
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-s); background: var(--surface); margin-bottom: 1rem; }
.data-table { border-collapse: collapse; width: 100%; min-width: 40rem; font-size: .92rem; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { text-align: left; padding: .65rem .75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table thead th { font-size: .8125rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.data-table tbody tr:last-child > * { border-bottom: 0; }

/* Narrow screens: the same table, each fund row stacked into a labelled
   block, so no column is hidden behind horizontal scrolling. Labels come
   from data-label; values and links stay in the original cells. */
@media (max-width: 47.9375rem) {
  .data-table { min-width: 0; }
  .data-table thead {
    /* Visually hidden, still available to assistive technology. */
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap;
  }
  .data-table, .data-table tbody, .data-table tr, .data-table th, .data-table td { display: block; }
  .data-table tbody tr { padding: .75rem; border-bottom: 1px solid var(--border); }
  .data-table tbody tr:last-child { border-bottom: 0; }
  .data-table tbody th { padding: 0 0 .35rem; border-bottom: 0; }
  .data-table td { position: relative; padding: .4rem 0 .4rem 7rem; border-bottom: 0; }
  .data-table tbody tr > td:not(:last-child) { border-bottom: 1px solid var(--border); }
  .data-table td::before {
    content: attr(data-label);
    position: absolute; left: 0; top: .4rem; width: 6.5rem;
    white-space: nowrap; color: var(--muted);
  }
}

/* UCITS fund cards: ticker first, fee and index as key facts, then the
   remaining facts as label/value rows, then source links as tappable rows. */
.cards { display: grid; gap: 1rem; grid-template-columns: 1fr; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 1rem 1rem .25rem;
}
.card h4 { margin-bottom: var(--space-s); }
.card-ticker {
  display: block; margin-bottom: .2rem;
  font-family: var(--font-mono); font-size: 1rem; font-weight: 700; letter-spacing: .04em;
  color: var(--accent);
}
.facts { display: grid; grid-template-columns: 1fr 1fr; column-gap: 1rem; margin: 0 0 .5rem; }
.facts > div { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(6.5rem, 38%) 1fr; gap: .5rem; padding: .4rem 0; border-bottom: 1px solid var(--border); }
.facts > div:last-child { border-bottom: 0; }
.facts dt { color: var(--muted); font-size: .88rem; }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.facts dd small { font-weight: 400; }
/* Key facts: two columns, label above value, fee in large type. */
.facts > .fact-key { grid-column: auto; display: block; padding: .25rem 0 .75rem; border-bottom: 2px solid var(--text); }
.facts > .fact-key dt { font-size: .8125rem; }
.facts > .fact-key dd { font-size: 1.05rem; line-height: 1.3; }
.facts > .fact-key:first-child dd { font-size: 1.6rem; line-height: 1.2; }
/* Source links: full-width rows, at least 44px tall. */
.card-src { list-style: none; margin: 0; padding: 0; font-size: .9rem; }
.card-src li { border-top: 1px solid var(--border); }
.card-src a { display: flex; align-items: center; justify-content: space-between; gap: .5rem; min-height: 2.75rem; padding: .35rem 0; }
/* Decorative arrow, hidden from assistive technology where "/ alt" is supported. */
.card-src a::after { content: "→"; content: "→" / ""; text-decoration: none; flex: none; }

.notes {
  margin-top: 1.5rem; padding: 1rem;
  background: var(--warn-soft); border: 1px solid var(--warn-border); border-radius: var(--radius);
  font-size: .9rem;
}
.notes p:last-child { margin-bottom: 0; }

/* Comparison disclosures. Native <details>; app.js opens them from 48rem. */
.us-funds { margin-top: var(--space-xl); }
.us-funds > summary, .card-more > summary {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  min-height: 2.75rem; cursor: pointer; list-style: none;
}
.us-funds > summary::-webkit-details-marker, .card-more > summary::-webkit-details-marker { display: none; }
/* Open/closed indicator; decorative, hidden from assistive technology where "/ alt" is supported. */
.us-funds > summary::after, .card-more > summary::after {
  content: "+"; content: "+" / ""; flex: none;
  font: 700 1.25rem/1 var(--font-sans); color: var(--accent);
}
.us-funds[open] > summary::after, .card-more[open] > summary::after { content: "−"; content: "−" / ""; }
.us-funds > summary { border-top: 2px solid var(--text); padding-top: var(--space-xs); margin-bottom: var(--space-s); }
.us-funds > summary h3 { margin: 0; text-wrap: wrap; } /* balance pushed this heading + tag to 4 lines */
.card-more { border-top: 1px solid var(--border); }
.card-more > summary { font-size: .9rem; font-weight: 600; color: var(--accent); }
.card-more > .facts { margin-top: 0; }

/* Lead magnet */
.magnet { display: grid; grid-template-columns: 1fr auto; gap: var(--space-m); align-items: start; margin-bottom: var(--space-l); }
.magnet .ticks { margin: 0; }
.magnet-preview {
  width: clamp(5.5rem, 26vw, 11.2rem); height: auto;
  border: 1px solid var(--border); border-radius: 2px; background: #fff;
}
.ticks { list-style: none; padding: 0; margin: 0 0 1.5rem; }
.ticks li { padding-left: 1.75rem; position: relative; margin-bottom: .5rem; }
.ticks li::before { content: "✓"; position: absolute; left: 0; color: var(--accent); font-weight: 800; }

/* FAQ */
#faq details { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .75rem; }
#faq details:last-child { margin-bottom: 0; }
#faq summary { cursor: pointer; font-weight: 600; padding: 1rem; min-height: 3rem; }
#faq details p { padding: 0 1rem 1rem; margin: 0; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); padding-block: 2rem calc(2rem + env(safe-area-inset-bottom, 0px)); font-size: .85rem; color: var(--muted); }

/* Wider screens */
@media (min-width: 40rem) {
  .hero-actions { flex-direction: row; flex-wrap: wrap; }
}
@media (min-width: 48rem) {
  :root { --gutter: 1.5rem; }
  .hero { padding-block: var(--space-2xl) 4rem; }
  .section { padding-block: var(--space-2xl); }
  .cards { grid-template-columns: 1fr 1fr; }
}

/* Lead form */
.lead-form, .lead-success {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  max-width: 32rem;
}
.lead-success:focus { outline: none; }
/* Groups the form controls (disabled until app.js runs); no visual box. */
.lead-fields { border: 0; margin: 0; padding: 0; min-width: 0; }
.demo-banner {
  background: var(--warn-soft); border: 1px solid var(--warn-border);
  border-radius: 8px; padding: .6rem .75rem; font-size: .88rem;
}
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; margin-bottom: .35rem; }
.field input[type="email"], .field input[type="text"] {
  width: 100%; min-height: 3rem; padding: .65rem .8rem;
  font: inherit; font-size: 1rem; /* 16px avoids iOS zoom on focus */
  color: var(--text); background: var(--bg);
  border: 1px solid var(--border-strong); border-radius: 8px;
}
.field input[aria-invalid="true"] { border-color: var(--error); }
.field-check { display: grid; grid-template-columns: auto 1fr; gap: .6rem; align-items: start; }
.field-check input { width: 1.4rem; height: 1.4rem; margin: .15rem 0 0; accent-color: var(--accent); }
.field-check label { font-weight: 400; margin: 0; }
.optional { color: var(--muted); font-weight: 400; font-size: .88em; }
.field-error, .form-error { color: var(--error); font-size: .9rem; margin: .35rem 0 0; }
.form-note { font-size: .85rem; color: var(--muted); margin: .75rem 0 0; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn[aria-busy="true"] { cursor: progress; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Keep anchor targets clear of the sticky header */
section[id], #lead-success { scroll-margin-top: calc(3.25rem + 1px + env(safe-area-inset-top, 0px)); }
.lead-success h3 { margin-top: 0; }

/* ?debug=1 event log */
.debug-panel {
  position: fixed; right: .5rem; bottom: calc(.5rem + env(safe-area-inset-bottom, 0px)); z-index: 20;
  max-width: min(18rem, calc(100% - 1rem)); max-height: 40vh; overflow: auto;
  background: #111; color: #9fef9f; font: 12px/1.4 ui-monospace, Menlo, monospace;
  padding: .5rem .75rem; border-radius: 8px; opacity: .92;
}
.debug-panel ol { margin: .25rem 0 0; padding-left: 1.25rem; }
.debug-panel p { margin: .2rem 0 0; color: #f0d27a; }
