/* Backline guide. Editorial magazine feel, Caribbean palette. All sizes in rem. */

:root {
  --page: #f2fafa;
  --section: #ffffff;
  --text: #0b2545;
  --muted: #34536b;
  --line: #cfe6e8;
  --accent: #0b7285;
  --accent-strong: #075e6d;
  --kicker: #075e6d;
  --accent-text-on: #ffffff;
  --aqua: #6fd6d9;
  --seafoam: #c9f1e1;
  --ocean: #1565a8;
  --chip: #e3f5f5;
  --chip-text: #07505c;
  --field: #ffffff;
  --coral: #c43c2f;
  --focus: #1565a8;
  --hero-a: #e6fbf8;
  --hero-b: #d4f1fb;
  --hero-c: #ffffff;
  --card-shadow: 0 0.75rem 2rem rgba(11, 37, 69, 0.08), 0 0.125rem 0.375rem rgba(11, 37, 69, 0.06);
  --target: #6fd6d9;

  --font-head: 'Fraunces', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Times New Roman', serif;
  --font-body: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --gutter: 1rem;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --page: #04192a;
  --section: #0a2438;
  --text: #e7f6f7;
  --muted: #a9c9d4;
  --line: #1d4660;
  --accent: #6fd6d9;
  --accent-strong: #9be6e8;
  --kicker: #6fd6d9;
  --accent-text-on: #04192a;
  --chip: #0f3550;
  --chip-text: #bdeff0;
  --field: #071e31;
  --coral: #ff9d8f;
  --focus: #9be6e8;
  --hero-a: #07314a;
  --hero-b: #0a2d45;
  --hero-c: #04192a;
  --card-shadow: 0 0.75rem 2rem rgba(0, 0, 0, 0.35);
  --target: #6fd6d9;
  color-scheme: dark;
}

html { font-size: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html[data-font-size="md"] { font-size: 112.5%; }
html[data-font-size="lg"] { font-size: 125%; }
html[data-font-size="xl"] { font-size: 137.5%; }

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

body {
  margin: 0;
  background: var(--page);
  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); font-weight: 700; margin: 0; line-height: 1.15; }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 0.15em; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 0.1875rem solid var(--focus); outline-offset: 0.125rem; border-radius: 0.375rem; }

.skip { position: absolute; left: 1rem; top: -4rem; z-index: 100; padding: 0.5rem 0.875rem; border-radius: 0.5rem; background: var(--section); color: var(--text); }
.skip:focus { top: calc(0.5rem + var(--safe-top)); }

/* ---------- Nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 20;
  padding: calc(0.5rem + var(--safe-top)) calc(var(--gutter) + var(--safe-right)) 0.5rem calc(var(--gutter) + var(--safe-left));
  background: var(--section);
  background: color-mix(in srgb, var(--section) 88%, transparent);
  -webkit-backdrop-filter: blur(0.875rem) saturate(1.3);
  backdrop-filter: blur(0.875rem) saturate(1.3);
  border-bottom: 1px solid var(--line);
}
.nav-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.5rem 1rem; }
.brand { display: inline-flex; align-items: center; gap: 0.625rem; color: var(--text); text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: 0.75rem; color: #fff;
  background: linear-gradient(135deg, #0b7285, #1565a8);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-family: var(--font-head); font-size: 1.1rem; }
.brand-text span { font-size: 0.75rem; color: var(--muted); }
.nav-links { display: flex; gap: 0.25rem; }
.nav-links a { padding: 0.375rem 0.75rem; border-radius: 999px; color: var(--text); text-decoration: none; font-weight: 500; font-size: 0.9375rem; }
.nav-links a[aria-current="page"] { background: var(--chip); color: var(--chip-text); }
.nav-links a:hover { background: var(--chip); }
.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.125rem; }
.size-btn { min-width: 2rem; height: 2rem; padding: 0 0.375rem; border: 0; border-radius: 999px; background: transparent; color: var(--text); font-family: var(--font-head); font-weight: 700; line-height: 1; }
.size-btn.s1 { font-size: 0.8rem; }
.size-btn.s2 { font-size: 0.95rem; }
.size-btn.s3 { font-size: 1.1rem; }
.size-btn.s4 { font-size: 1.25rem; }
.size-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-text-on); }
.theme-btn { display: inline-flex; align-items: center; gap: 0.375rem; height: 2.25rem; padding: 0 0.75rem; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--text); font-size: 0.875rem; font-weight: 500; }
:root[data-theme="dark"] .theme-btn .i-sun, :root:not([data-theme="dark"]) .theme-btn .i-moon { display: none; }

/* ---------- Hero ---------- */
.hero {
  background: var(--hero-c);
  background: radial-gradient(60rem 26rem at 10% 0%, var(--hero-a), transparent 70%), radial-gradient(50rem 24rem at 95% 10%, var(--hero-b), transparent 70%), var(--hero-c);
  border-bottom: 1px solid var(--line);
  padding: 2.25rem calc(var(--gutter) + var(--safe-right)) 2rem calc(var(--gutter) + var(--safe-left));
}
.hero-inner { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 0.75rem; }
.kicker { text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.75rem; font-weight: 600; color: var(--kicker); }
.hero h1 { font-size: clamp(2rem, 1.4rem + 2.6vw, 3.5rem); }
.lede { font-size: 1.0625rem; color: var(--muted); max-width: 52rem; }
.checked { font-size: 0.875rem; color: var(--muted); }
.cta { display: inline-flex; align-items: center; min-height: 2.75rem; padding: 0.5rem 1.25rem; border-radius: 999px; background: var(--accent); color: var(--accent-text-on); text-decoration: none; font-weight: 600; box-shadow: 0 0.5rem 1.25rem rgba(11, 114, 133, 0.25); }
.cta:hover { background: var(--accent-strong); }

/* ---------- Tools ---------- */
.tools { background: var(--section); border-bottom: 1px solid var(--line); padding: 1.25rem calc(var(--gutter) + var(--safe-right)) 1.25rem calc(var(--gutter) + var(--safe-left)); }
.tools-inner { display: flex; flex-direction: column; gap: 1rem; align-items: center; text-align: center; }
.search { width: 100%; max-width: 40rem; display: flex; flex-direction: column; gap: 0.375rem; }
.search label { font-weight: 600; font-size: 0.9375rem; }
.search-row { display: flex; gap: 0.5rem; align-items: center; }
.search input { flex: 1 1 auto; min-width: 0; height: 2.75rem; padding: 0 1rem; border-radius: 999px; border: 1px solid var(--line); background: var(--field); color: var(--text); font-size: 1rem; }
.search input::placeholder { color: var(--muted); opacity: 1; }
.mic-btn { display: inline-grid; place-items: center; width: 2.75rem; height: 2.75rem; flex: 0 0 auto; border-radius: 50%; border: 1px solid var(--line); background: var(--field); color: var(--text); }
.mic-btn[hidden] { display: none; }
.mic-btn.is-listening { background: var(--accent); border-color: var(--accent); color: var(--accent-text-on); }
.voice-error { color: var(--coral); font-size: 0.8125rem; }
.voice-error[hidden] { display: none; }
.note { color: var(--muted); font-size: 0.75rem; }
.filters { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; }
.filter { min-height: 2.25rem; padding: 0.25rem 0.875rem; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--text); font-size: 0.875rem; font-weight: 500; }
.filter[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text-on); }

/* ---------- Entries ---------- */
.entries-wrap { padding: 1.5rem calc(var(--gutter) + var(--safe-right)) 2.5rem calc(var(--gutter) + var(--safe-left)); }
.result-count { text-align: center; color: var(--muted); font-size: 0.875rem; margin-bottom: 1rem; }
.entries { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 21rem), 1fr)); gap: 1rem; align-items: start; }
.entries:focus { outline: none; }
.entry {
  min-width: 0;
  background: var(--section);
  border: 1px solid var(--line);
  border-radius: 1.125rem;
  box-shadow: var(--card-shadow);
  padding: 1.25rem;
  display: flex; flex-direction: column; gap: 0.5rem;
  text-align: center;
  scroll-margin-top: 6rem;
}
.entry[hidden] { display: none; }
.entry.is-target { border-color: var(--target); box-shadow: 0 0 0 0.1875rem var(--target), var(--card-shadow); }
.entry-kind { text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.6875rem; font-weight: 600; color: var(--kicker); }
.entry-title { font-size: 1.375rem; }
.entry-title a { color: var(--text); text-decoration: none; }
.entry-title a:hover { text-decoration: underline; }
.entry-summary { color: var(--muted); }
.entry-key { display: inline-block; align-self: center; padding: 0.25rem 0.75rem; border-radius: 999px; background: var(--chip); color: var(--chip-text); font-weight: 600; font-size: 0.875rem; }
.entry-more { margin-top: 0.25rem; }
.entry-more summary { cursor: pointer; font-weight: 600; color: var(--accent); list-style-position: inside; }
.entry-body { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 0.75rem; text-align: left; }
.fields { margin: 0; display: flex; flex-direction: column; gap: 0.375rem; }
.fields div { padding: 0.5rem 0.75rem; border-radius: 0.625rem; background: var(--chip); }
.fields dt { font-size: 0.75rem; font-weight: 600; color: var(--muted); }
.fields dd { margin: 0; font-size: 0.9375rem; }
.next { padding: 0.75rem; border-radius: 0.75rem; border-left: 0.25rem solid var(--accent); background: var(--page); }
.next h3 { font-size: 1rem; margin-bottom: 0.25rem; }
.links { margin: 0; padding-left: 1.25rem; display: flex; flex-direction: column; gap: 0.25rem; }
.updated { font-size: 0.8125rem; color: var(--muted); }
.no-results { text-align: center; color: var(--muted); padding: 2rem 0; }
.no-results[hidden] { display: none; }

.foot { border-top: 1px solid var(--line); background: var(--section); padding: 1.5rem calc(var(--gutter) + var(--safe-right)) calc(1.5rem + var(--safe-bottom)) calc(var(--gutter) + var(--safe-left)); text-align: center; color: var(--muted); font-size: 0.875rem; display: flex; flex-direction: column; gap: 0.375rem; }

/* ---------- Tablet and up: normal editorial alignment ---------- */
@media (min-width: 48em) {
  :root { --gutter: 2rem; }
  .nav-row { justify-content: space-between; }
  .hero { padding-top: 3.5rem; padding-bottom: 3rem; }
  .hero-inner { align-items: flex-start; text-align: left; }
  .tools-inner { flex-direction: row; align-items: flex-end; justify-content: space-between; text-align: left; }
  .filters { justify-content: flex-end; }
  .result-count { text-align: left; }
  .entry { text-align: left; }
  .entry-key { align-self: flex-start; }
}
@media (min-width: 90em) {
  :root { --gutter: 3rem; }
}
