/* ============================================================
   Church website theme — Minimal & Editorial
   Design tokens + Pico variable mapping + shared components.
   Fraunces (headings) + Inter (body) self-hosted below as woff2.
   ============================================================ */

@font-face {
  font-family: "Fraunces";
  src: url("/fonts/fraunces-latin-500-normal.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("/fonts/fraunces-latin-600-normal.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("/fonts/fraunces-latin-500-italic.woff2") format("woff2");
  font-weight: 500;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("/fonts/inter-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("/fonts/inter-latin-600-normal.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg:        #FCFBF8;
  --surface:   #F4F2EC;
  --surface-2: #FBF9F4;
  --ink:       #1A1A18;
  --muted:     #6B6862;
  --border:    #E6E2D8;
  --primary:   #2F4A3C;
  --primary-2: #24382D;
  --accent:    #B5623C;

  --hero-bg:   #2F4A3C;
  --hero-bg-2: #263E31;
  --hero-ink:  #F4F1E7;
  --hero-eyebrow: #B7CBBB;

  --btn-bg:    #2F4A3C;
  --btn-ink:   #F7F5EF;
  --btn-hover: #24382D;

  --tag-bg:    #F0E3D9;
  --tag-ink:   #8F4A2C;

  --link:      #2F4A3C;
  --focus:     #B5623C;

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

  --maxw: 960px;
  --radius: 8px;

  /* Map Pico onto our palette so its components blend in */
  --pico-font-family: var(--font-body);
  --pico-background-color: var(--bg);
  --pico-color: var(--ink);
  --pico-primary: var(--primary);
  --pico-primary-hover: var(--primary-2);
  --pico-primary-background: var(--primary);
  --pico-muted-color: var(--muted);
  --pico-border-color: var(--border);
  --pico-border-radius: var(--radius);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #15130E;
    --surface:   #201D16;
    --surface-2: #1B1812;
    --ink:       #ECE7DC;
    --muted:     #A8A290;
    --border:    #322E24;
    --primary:   #8FB19B;
    --primary-2: #A9C4B2;
    --accent:    #D98A5B;

    --hero-bg:   #223529;
    --hero-bg-2: #1B2B21;
    --hero-ink:  #F0EDE2;
    --hero-eyebrow: #8FA894;

    --btn-bg:    #7FA88E;
    --btn-ink:   #12100B;
    --btn-hover: #93B9A1;

    --tag-bg:    #35271D;
    --tag-ink:   #E3A87F;

    --link:      #A9C4B2;
    --focus:     #D98A5B;
  }
}

/* Explicit theme toggle wins over the media query, both directions */
:root[data-theme="light"] {
  --bg:#FCFBF8; --surface:#F4F2EC; --surface-2:#FBF9F4; --ink:#1A1A18;
  --muted:#6B6862; --border:#E6E2D8; --primary:#2F4A3C; --primary-2:#24382D;
  --accent:#B5623C; --hero-bg:#2F4A3C; --hero-bg-2:#263E31; --hero-ink:#F4F1E7;
  --hero-eyebrow:#B7CBBB; --btn-bg:#2F4A3C; --btn-ink:#F7F5EF; --btn-hover:#24382D;
  --tag-bg:#F0E3D9; --tag-ink:#8F4A2C; --link:#2F4A3C; --focus:#B5623C;
}
:root[data-theme="dark"] {
  --bg:#15130E; --surface:#201D16; --surface-2:#1B1812; --ink:#ECE7DC;
  --muted:#A8A290; --border:#322E24; --primary:#8FB19B; --primary-2:#A9C4B2;
  --accent:#D98A5B; --hero-bg:#223529; --hero-bg-2:#1B2B21; --hero-ink:#F0EDE2;
  --hero-eyebrow:#8FA894; --btn-bg:#7FA88E; --btn-ink:#12100B; --btn-hover:#93B9A1;
  --tag-bg:#35271D; --tag-ink:#E3A87F; --link:#A9C4B2; --focus:#D98A5B;
}

/* ---- base ---- */
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.65;
}
h1, h2, h3, .serif { font-family: var(--font-head); font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; }
a { color: var(--link); text-underline-offset: 3px; }
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.eyebrow { font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; font-weight: 600; color: var(--muted); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

/* ---- header / footer ---- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: saturate(1.2) blur(6px);
  border-bottom: 1px solid var(--border);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; min-height: 64px; gap: 12px 20px; flex-wrap: wrap; padding-top: 6px; padding-bottom: 6px; }
@media (max-width: 420px) {
  .brand .mark { font-size: 18px; }
  nav.main a { padding: 8px 8px; font-size: 14px; }
}
.brand { text-decoration: none; color: var(--ink); }
.brand .mark { font-family: var(--font-head); font-size: 21px; font-weight: 600; }
nav.main { display: flex; gap: 6px; }
nav.main a { color: var(--muted); text-decoration: none; padding: 8px 12px; border-radius: 6px; font-size: 15px; }
nav.main a:hover { color: var(--ink); background: var(--surface); }

.site-footer { border-top: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 14px; margin-top: 8px; }
.site-footer .wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding-top: 26px; padding-bottom: 26px; }

/* ---- hero ---- */
.hero { background: linear-gradient(160deg, var(--hero-bg), var(--hero-bg-2)); color: var(--hero-ink); }
.hero .wrap { padding: 72px 24px; }
.hero .eyebrow { color: var(--hero-eyebrow); }
.verse { font-family: var(--font-head); font-style: italic; font-weight: 500; font-size: clamp(28px, 5vw, 44px); line-height: 1.22; margin: 16px 0 6px; max-width: 20ch; }
.verse-ref { font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--hero-eyebrow); }
.hero .lede { max-width: 46ch; margin: 20px 0 26px; color: color-mix(in srgb, var(--hero-ink) 86%, transparent); }

/* ---- sections ---- */
.block { padding: 56px 0; }
.block + .block { border-top: 1px solid var(--border); }
.block h2 { font-size: 27px; margin: 6px 0 10px; }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; cursor: pointer;
  padding: 11px 18px; border-radius: var(--radius); background: var(--btn-bg); color: var(--btn-ink);
  border: 1px solid transparent; text-decoration: none; }
.btn:hover { background: var(--btn-hover); }
.btn.ghost { background: transparent; color: var(--hero-ink); border-color: color-mix(in srgb, var(--hero-ink) 45%, transparent); }
.btn.ghost:hover { background: color-mix(in srgb, var(--hero-ink) 12%, transparent); }
.btn.outline { background: transparent; color: var(--primary); border-color: var(--border); }
.btn.outline:hover { border-color: var(--primary); background: var(--surface); }

/* ---- hero with optional image ---- */
.hero.has-image { position: relative; background: var(--hero-bg-2); }
.hero.has-image .hero-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero.has-image .hero-scrim { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(20,25,20,.35), rgba(20,25,20,.72)); }
.hero.has-image .wrap { position: relative; }
.hero-ctas { margin-top: 24px; }

/* ---- section heading ---- */
.sec-head { margin-bottom: 26px; }
.sec-head h2 { font-size: 27px; margin: 6px 0; }
.sec-head p { color: var(--muted); margin: 0; max-width: 60ch; }
.sec-head.spread { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }

/* ---- prose ---- */
.prose { max-width: 62ch; }
.prose p { margin: 0 0 16px; }

/* ---- congregation cards ---- */
.cong-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
@media (max-width: 640px) { .cong-grid { grid-template-columns: 1fr; } }
.cong-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; display: flex; flex-direction: column; gap: 6px; }
.cong-card h3 { font-size: 20px; }
.cong-card .loc { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.cong-card .times { color: var(--muted); font-size: 15px; margin-top: 6px; }
.cong-card .desc { font-size: 15px; }
.cong-card .contact { color: var(--muted); font-size: 14px; margin-top: 4px; }
.cong-card .more { margin-top: auto; padding-top: 12px; font-size: 14px; font-weight: 600; }

/* congregation detail photos */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-top: 22px; }
.photo-grid figure { margin: 0; }
.photo-grid img { width: 100%; height: 200px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border); }
.photo-grid figcaption { font-size: 13px; color: var(--muted); margin-top: 6px; }
.contact-list { color: var(--muted); font-size: 15px; display: flex; flex-direction: column; gap: 4px; }

/* ---- statement of faith ---- */
details.sof { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); padding: 4px 22px; }
details.sof summary { list-style: none; cursor: pointer; padding: 18px 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
details.sof summary::-webkit-details-marker { display: none; }
details.sof summary h3 { font-size: 20px; }
details.sof summary .hint { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 8px; }
details.sof .chev { width: 14px; height: 14px; transition: transform .15s ease; color: var(--muted); }
details.sof[open] .chev { transform: rotate(180deg); }
details.sof .sof-body { padding: 4px 0 22px; border-top: 1px solid var(--border); }
details.sof .sof-body p:first-child { margin-top: 18px; }

/* ---- sermon filters ----
   Every control (input, selects, button) shares one 42px height and one radius. */
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; padding: 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 18px; }
.filters .field { display: flex; flex-direction: column; gap: 4px; margin: 0; }
.filters label { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.filters input, .filters select {
  box-sizing: border-box; height: 42px; font-size: 15px; line-height: normal;
  color: var(--ink); background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; padding: 0 11px; margin: 0; min-width: 150px;
}
.filters .search { flex: 1 1 200px; }
.filters .search input { width: 100%; }
.filters .btn {
  box-sizing: border-box; height: 42px; padding: 0 18px; margin: 0;
  border-radius: var(--radius); width: auto;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 26px; }

/* ---- tags / chips ---- */
.tag { font-size: 12.5px; font-weight: 600; letter-spacing: .02em; color: var(--tag-ink); background: var(--tag-bg); padding: 3px 10px; border-radius: 100px; border: 1px solid transparent; text-decoration: none; display: inline-block; }
a.tag:hover { border-color: var(--accent); }
.tag.active { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---- sermon cards ---- */
.sermon-list { display: flex; flex-direction: column; gap: 18px; }
.sermon { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); padding: 22px 24px; display: flex; flex-direction: column; gap: 14px; }
.sermon .top { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.sermon h3 { font-size: 22px; margin-bottom: 6px; }
.sermon h3 a { color: var(--ink); text-decoration: none; }
.sermon h3 a:hover { text-decoration: underline; }
.sermon .meta { color: var(--muted); font-size: 14px; margin: 0; }
.sermon .meta .dot { margin: 0 7px; opacity: .5; }
.badge { display: inline-block; white-space: nowrap; font-size: 12px; font-weight: 600; letter-spacing: .04em; color: var(--primary); border: 1px solid var(--primary); padding: 3px 10px; border-radius: 100px; }
.scriptures { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 15px; }
.scriptures .sk { color: var(--muted); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; margin-right: 6px; font-weight: 600; }
.sermon .desc { font-size: 15.5px; max-width: 66ch; margin: 0; }
.sermon .desc p { margin: 0; }
.sermon .desc p + p { margin-top: 10px; }
.sermon .tags { display: flex; flex-wrap: wrap; gap: 7px; }

/* ---- audio player (native <audio> + track toggle) ----
   Buttons stretch to fill the segment box exactly (no Pico margins/radius inside). */
.player { display: flex; flex-direction: column; gap: 10px; border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; background: var(--bg); }
.player audio { width: 100%; }
.seg { display: inline-flex; align-items: stretch; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; width: fit-content; }
.seg button {
  font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  display: block; width: auto; background: var(--bg); color: var(--muted);
  border: 0; border-radius: 0; margin: 0; padding: 8px 14px; line-height: 1.2;
}
.seg button + button { border-left: 1px solid var(--border); }
.seg button.active { background: var(--primary); color: var(--btn-ink); }

/* ---- recent sermons teaser ---- */
.recent { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 720px) { .recent { grid-template-columns: 1fr; } }
.recent .r { border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; background: var(--surface-2); display: flex; flex-direction: column; gap: 8px; }
.recent .r .rdate { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.recent .r h3 { font-size: 18px; }
.recent .r h3 a { color: var(--ink); text-decoration: none; }
.recent .r .rmeta { font-size: 14px; color: var(--muted); margin-top: auto; }

/* ---- pagination + misc ---- */
.pagination { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 28px; color: var(--muted); font-size: 14px; }
.empty { text-align: center; color: var(--muted); padding: 48px 0; }
.page-head { padding: 44px 0 8px; }
.page-head h1 { font-size: 34px; }
.sub-meta { margin: 6px 0 0; }

/* page-specific layout (CSP forbids inline style attributes) */
.wrap-narrow { max-width: 720px; }
.scriptures-block { margin-bottom: 20px; }
.player-block { margin-bottom: 22px; }
.tags-block { margin-top: 20px; }
.times-block { margin-top: 18px; }
.contact-block { margin-top: 14px; }
.error-wrap { text-align: center; padding: 96px 0; }
.error-title { font-size: 34px; }
.error-lede { margin: 10px 0 24px; }

/* ---- verse popover (the [[ref]] feature) ---- */
.ref { color: var(--link); font-weight: 500; cursor: help; text-decoration: underline dotted; text-underline-offset: 3px; position: relative; white-space: nowrap; }
.ref .pop {
  position: absolute; left: 50%; bottom: calc(100% + 10px); transform: translateX(-50%);
  width: 280px; max-width: 74vw; z-index: 30;
  background: var(--ink); color: var(--bg);
  padding: 12px 14px; border-radius: 8px; font-size: 14px; line-height: 1.5;
  font-weight: 400; white-space: normal; font-family: var(--font-body);
  box-shadow: 0 8px 26px rgba(0,0,0,.28);
  opacity: 0; visibility: hidden;
}
.ref .pop::after { content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); border: 7px solid transparent; border-top-color: var(--ink); }
.ref .pop .pop-ref { display: block; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: color-mix(in srgb, var(--bg) 62%, transparent); margin-bottom: 5px; }
.ref:hover .pop, .ref:focus .pop, .ref:focus-within .pop, .ref.open .pop { opacity: 1; visibility: visible; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
