/* AI&I Ledger guide: editorial, Caribbean palette. Mobile-first; all sizes in rem. */

:root {
  --font-head: "Fraunces", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --font-body: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --radius: 1rem;
}

html[data-font-size="sm"] { font-size: 93.75%; }
html[data-font-size="md"] { font-size: 106.25%; }
html[data-font-size="lg"] { font-size: 118.75%; }
html[data-font-size="xl"] { font-size: 131.25%; }

html[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --band: #effaf9;
  --band-grad: linear-gradient(180deg, #f2fbfa 0%, #e6f6f7 100%);
  --hero-grad: linear-gradient(160deg, #e0f7f6 0%, #f4fbff 55%, #ffffff 100%);
  --text: #0b2545;
  --muted: #3d5a73;
  --line: rgba(11, 37, 69, 0.14);
  --surface: #ffffff;
  --accent: #0b6e78;
  --accent-strong: #08545c;
  --accent-soft: rgba(20, 184, 166, 0.14);
  --btn-text: #ffffff;
  --btn-bg-flat: #0b6e78;
  --btn-bg: linear-gradient(135deg, #0b6e78, #0e5a8a);
  --coral: #b93a24;
  --shadow: 0 0.75rem 2rem rgba(11, 37, 69, 0.08);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #061a2b;
  --band: #08233a;
  --band-grad: linear-gradient(180deg, #082339 0%, #0a2a44 100%);
  --hero-grad: linear-gradient(160deg, #0b3346 0%, #08243a 55%, #061a2b 100%);
  --text: #e8f6f7;
  --muted: #a9c6d3;
  --line: rgba(160, 230, 230, 0.18);
  --surface: #0b2840;
  --accent: #5eead4;
  --accent-strong: #99f6e4;
  --accent-soft: rgba(94, 234, 212, 0.14);
  --btn-text: #04212b;
  --btn-bg-flat: #5eead4;
  --btn-bg: linear-gradient(135deg, #5eead4, #67e8f9);
  --coral: #ff9b85;
  --shadow: 0 0.75rem 2rem rgba(0, 0, 0, 0.35);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
h1, h2, h3 { font-family: var(--font-head); line-height: 1.15; margin: 0; font-weight: 700; }
p { margin: 0; }
a { color: var(--accent); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 0.18rem solid var(--accent); outline-offset: 0.15rem; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 1rem; top: -4rem; z-index: 100;
  background: var(--surface); color: var(--text); padding: 0.5rem 0.9rem; border-radius: 0.6rem;
}
.skip:focus { top: calc(0.75rem + env(safe-area-inset-top)); }

/* ---------- nav ---------- */
.nav {
  position: relative;
  top: 0;
  z-index: 20;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  padding: calc(0.5rem + env(safe-area-inset-top)) calc(1rem + env(safe-area-inset-right)) 0.5rem calc(1rem + env(safe-area-inset-left));
}
.nav-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 1.25rem;
}
.brand { display: inline-flex; align-items: center; gap: 0.6rem; color: var(--text); text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 2.3rem; height: 2.3rem; border-radius: 0.7rem;
  background: #0e7490; background: linear-gradient(135deg, #0e7490, #0f766e);
  color: #ffffff; font-weight: 700; font-size: 0.8rem; flex: none;
}
.brand-name { display: flex; flex-direction: column; line-height: 1.1; text-align: left; }
.brand-name strong { font-family: var(--font-head); font-size: 1.1rem; }
.brand-name span { font-size: 0.75rem; color: var(--muted); }
.nav-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.25rem; }
.nav-links a { color: var(--text); text-decoration: none; font-weight: 500; font-size: 0.9rem; padding: 0.35rem 0.7rem; border-radius: 999px; }
.nav-links a:hover, .nav-links a[aria-current="page"] { background: var(--accent-soft); }
.prefs { display: flex; align-items: center; gap: 0.5rem; }
.size-group { display: inline-flex; align-items: flex-end; border: 1px solid var(--line); border-radius: 999px; padding: 0.15rem; }
.size-btn { border: 0; background: transparent; border-radius: 999px; min-width: 2rem; height: 2rem; font-weight: 700; line-height: 1; font-family: var(--font-head); }
.size-btn[data-size="sm"] { font-size: 0.75rem; }
.size-btn[data-size="md"] { font-size: 0.9rem; }
.size-btn[data-size="lg"] { font-size: 1.05rem; }
.size-btn[data-size="xl"] { font-size: 1.2rem; }
.size-btn[aria-pressed="true"] { background: var(--btn-bg-flat); color: var(--btn-text); }
.theme-btn { display: grid; place-items: center; width: 2.3rem; height: 2.3rem; border-radius: 999px; border: 1px solid var(--line); background: transparent; }
.theme-btn svg { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.theme-btn .icon-moon { fill: currentColor; stroke: none; }
html[data-theme="dark"] .theme-btn .icon-sun { display: none; }
html[data-theme="light"] .theme-btn .icon-moon { display: none; }

/* ---------- hero ---------- */
.hero {
  background: var(--hero-grad);
  padding: 2.5rem 1rem 2.25rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
}
.kicker { text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.75rem; font-weight: 700; color: var(--accent); }
.hero h1 { font-size: clamp(2rem, 1.4rem + 3vw, 3.6rem); max-width: 60rem; }
.lede { color: var(--muted); font-size: 1.05rem; max-width: 52rem; }
.hero-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem; margin-top: 0.3rem; }
.btn {
  display: inline-block;
  padding: 0.65rem 1.25rem;
  border-radius: 999px;
  font-weight: 700;
  text-decoration: none;
  color: var(--btn-text);
  background: var(--btn-bg-flat);
  background: var(--btn-bg);
  box-shadow: var(--shadow);
}
.btn.quiet { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); box-shadow: none; }

/* ---------- finder ---------- */
.finder {
  padding: 1.5rem 1rem 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}
.search { display: flex; gap: 0.5rem; width: min(100%, 44rem); }
.search input {
  flex: 1 1 auto;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 0.7rem 1.1rem;
  box-shadow: var(--shadow);
}
.search input::placeholder { color: var(--muted); opacity: 1; }
.mic-btn {
  display: grid; place-items: center; width: 2.9rem; height: 2.9rem; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); flex: none;
}
.mic-btn svg { width: 1.2rem; height: 1.2rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.mic-btn[aria-pressed="true"] { background: var(--btn-bg-flat); color: var(--btn-text); border-color: transparent; box-shadow: 0 0 0 0.25rem var(--accent-soft); }
.voice-status { color: var(--muted); font-size: 0.85rem; text-align: center; }
.voice-error { color: var(--coral); font-size: 0.85rem; font-weight: 600; text-align: center; max-width: 44rem; }
.tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.4rem; max-width: 70rem; }
.tag {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
  font-size: 0.82rem;
  font-weight: 600;
}
.tag[aria-pressed="true"] { background: var(--btn-bg-flat); color: var(--btn-text); border-color: transparent; }
.result-count { color: var(--muted); font-size: 0.85rem; }

/* ---------- topic cards ---------- */
.topics { padding: 1rem 1rem 2rem; }
.cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
  gap: 1rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}
.card-link { display: flex; flex-direction: column; gap: 0.4rem; padding: 1.1rem 1.2rem 1.2rem; color: var(--text); text-decoration: none; height: 100%; text-align: center; }
.card-link:hover h3 { color: var(--accent); }
.card-num { font-family: var(--font-head); color: var(--accent); font-weight: 700; font-size: 0.95rem; }
.card-link h3 { font-size: 1.2rem; }
.card-link p { color: var(--muted); font-size: 0.92rem; }

/* ---------- articles ---------- */
.article { padding: 2.5rem 1rem; outline: none; }
.article:nth-child(odd) { background: var(--band); background: var(--band-grad); }
.article-head { display: flex; flex-direction: column; gap: 0.5rem; text-align: center; align-items: center; margin-bottom: 1.25rem; }
.article-tags { letter-spacing: 0.04em; font-size: 0.72rem; font-weight: 700; color: var(--accent); }
.article h2 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.4rem); }
.article-summary { font-size: 1.08rem; color: var(--muted); max-width: 60rem; }
.article-cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
.article-body { display: flex; flex-direction: column; gap: 0.85rem; text-align: center; }
.article-body ul { text-align: left; margin: 0; padding-left: 1.25rem; display: flex; flex-direction: column; gap: 0.35rem; }
.facts { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow); min-width: 0; align-self: start; }
.facts h3 { font-size: 1.1rem; margin-bottom: 0.5rem; text-align: center; }
.facts dl { margin: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.facts dl div { border-top: 1px solid var(--line); padding-top: 0.5rem; display: flex; flex-direction: column; gap: 0.1rem; }
.facts dt { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.facts dd { margin: 0; font-weight: 600; }
.article-foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem 1.25rem; margin-top: 1.25rem; font-weight: 600; font-size: 0.92rem; }

.closing { padding: 3rem 1rem; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 0.8rem; background: var(--hero-grad); }
.closing h2 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.4rem); }
.closing p { color: var(--muted); max-width: 44rem; }
.foot { padding: 1.5rem 1rem calc(2rem + env(safe-area-inset-bottom)); text-align: center; color: var(--muted); font-size: 0.82rem; display: flex; flex-direction: column; gap: 0.35rem; border-top: 1px solid var(--line); }

/* ---------- larger screens ---------- */
@media (min-width: 768px) {
  .nav { position: sticky; }
  .topics, .article { scroll-margin-top: 5.5rem; }
  .hero { padding: 3.5rem 2rem 3rem; }
  .topics, .finder { padding-left: 2rem; padding-right: 2rem; }
  .card-link { text-align: left; }
  .article { padding: 3rem 2rem; }
  .article-head { text-align: left; align-items: flex-start; }
  .article-body { text-align: left; }
  .facts h3 { text-align: left; }
  .facts dl div { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 0.75rem; }
  .article-foot { justify-content: flex-start; }
}
@media (min-width: 1024px) {
  .article-cols { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 2.5rem; }
  .facts dl div { display: flex; flex-direction: column; gap: 0.1rem; }
  .article, .topics, .finder, .hero { padding-left: 3rem; padding-right: 3rem; }
}
@media (min-width: 1440px) {
  .article, .topics, .finder, .hero { padding-left: 5rem; padding-right: 5rem; }
  .facts dl div { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 0.75rem; }
}
