/* ============================================================
   Church website theme — Stone & Candle
   Limestone neutrals, slate primary, single candle-amber accent.
   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:        #F7F7F4;
  --surface:   #EDEDE8;
  --surface-2: #F3F3EF;
  --ink:       #1E2124;
  --muted:     #61676C;
  --border:    #DCDCD4;
  --primary:   #37474F;
  --primary-2: #263238;
  --accent:    #B4762A;

  --hero-bg:   #2C393F;
  --hero-bg-2: #202B30;
  --hero-ink:  #EFEEE7;
  --hero-eyebrow: #D3A15C;

  --btn-bg:    #37474F;
  --btn-ink:   #F2F1EB;
  --btn-hover: #263238;

  --tag-bg:    #F0E4CE;
  --tag-ink:   #7F5417;

  --link:      #37474F;
  --focus:     #B4762A;

  --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: 1200px;
  --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:        #121415;
    --surface:   #1B1E20;
    --surface-2: #17191B;
    --ink:       #E5E4DE;
    --muted:     #9BA0A3;
    --border:    #2C3033;
    --primary:   #9FB4BE;
    --primary-2: #B6C8D0;
    --accent:    #DBA45C;

    --hero-bg:   #232D33;
    --hero-bg-2: #1A2226;
    --hero-ink:  #ECEBE3;
    --hero-eyebrow: #D3A15C;

    --btn-bg:    #A3B8C2;
    --btn-ink:   #101416;
    --btn-hover: #B6C8D0;

    --tag-bg:    #2E2416;
    --tag-ink:   #E0B276;

    --link:      #B6C8D0;
    --focus:     #DBA45C;
  }
}

/* Explicit theme toggle wins over the media query, both directions */
:root[data-theme="light"] {
  --bg:#F7F7F4; --surface:#EDEDE8; --surface-2:#F3F3EF; --ink:#1E2124;
  --muted:#61676C; --border:#DCDCD4; --primary:#37474F; --primary-2:#263238;
  --accent:#B4762A; --hero-bg:#2C393F; --hero-bg-2:#202B30; --hero-ink:#EFEEE7;
  --hero-eyebrow:#D3A15C; --btn-bg:#37474F; --btn-ink:#F2F1EB; --btn-hover:#263238;
  --tag-bg:#F0E4CE; --tag-ink:#7F5417; --link:#37474F; --focus:#B4762A;
}
:root[data-theme="dark"] {
  --bg:#121415; --surface:#1B1E20; --surface-2:#17191B; --ink:#E5E4DE;
  --muted:#9BA0A3; --border:#2C3033; --primary:#9FB4BE; --primary-2:#B6C8D0;
  --accent:#DBA45C; --hero-bg:#232D33; --hero-bg-2:#1A2226; --hero-ink:#ECEBE3;
  --hero-eyebrow:#D3A15C; --btn-bg:#A3B8C2; --btn-ink:#101416; --btn-hover:#B6C8D0;
  --tag-bg:#2E2416; --tag-ink:#E0B276; --link:#B6C8D0; --focus:#DBA45C;
}

/* ---- base ---- */
html { height: 100%; }
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.65;
}
body > main { flex: 1 0 auto; }
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; }
  nav.main { margin-left: -8px; }
}
.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; margin-left: -12px; }
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:first-child { margin-top: calc(-1 * var(--pico-block-spacing-vertical)); }
.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-tight-top { padding-top: 16px; }
.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(18,22,25,.35), rgba(18,22,25,.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; }

/* ---- resources page (/resources) ---- */
.resource-list { display: flex; flex-direction: column; gap: 16px; }
.resource-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.resource-card h3 { font-size: 20px; margin: 0 0 8px; }
.resource-card p { font-size: 15px; margin: 0; }

/* 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; }
.contact-list .contact-lg { font-size: 17px; color: var(--ink); }
/* Services/Address/Addresses/Call-in number/Email headings all match this size+color */
.times { font-size: 17px; color: var(--ink); }
/* 10px on top of the flex gap (4px) matches the 14px gap between Services and Address */
.contact-list > .contact-gap { margin-top: 10px; }
.contact-list > .contact-gap:first-child { margin-top: 0; }
.pre-line { white-space: pre-line; }

/* ---- 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; }
details.sof summary::-webkit-details-marker { display: none; }
details.sof summary::after { display: none; content: none; } /* Pico's own float:right chevron — we render our own .chev */
details.sof summary .summary-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
details.sof summary h3 { font-size: 20px; }
details.sof summary .hint { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 8px; flex-shrink: 0; white-space: nowrap; }
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; }
@media (max-width: 600px) {
  details.sof summary .summary-row { flex-direction: column; align-items: flex-start; gap: 6px; }
}

/* ---- 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; }

/* ---- hymnbook ---- */
.hymn-pdf-link { font-size: 16px; margin: -10px 0 14px; }

/* number-lookup + search, side by side (stacked on mobile) */
.hymn-lookup-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; margin-bottom: 34px; }
.hymn-lookup-row .filters { flex: 1 1 260px; margin-bottom: 0; }
@media (max-width: 600px) {
  .hymn-lookup-row { flex-direction: column; }
  .hymn-lookup-row .filters { flex-basis: auto; width: 100%; }
}
.input-clear { position: relative; }
.input-clear input { padding-right: 32px; }
.clear-x {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
  border-radius: 4px; color: var(--muted); text-decoration: none; font-size: 18px; line-height: 1;
}
.clear-x:hover { color: var(--ink); background: var(--surface-2); }

/* ---- 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; }
.sermon .meta .date { white-space: nowrap; }
@media (max-width: 480px) {
  /* Badge competing for width with the title/meta column is what pushes the date
     onto an awkward second line; stacking gives .meta the full card width. */
  .sermon .top { flex-direction: column; align-items: flex-start; gap: 8px; }
}
.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).
   No outer box here on purpose: an extra bordered/padded wrapper around the audio
   element just eats into the width available to the (already-tiny) native scrubber,
   which matters most on narrow phones. */
.player { display: flex; flex-direction: column; gap: 10px; }
.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); }
.skip { display: inline-flex; gap: 6px; }
.skip button {
  font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  background: var(--bg); color: var(--muted); border: 1px solid var(--border);
  border-radius: 7px; padding: 8px 12px; line-height: 1.2;
}
.skip button:hover { border-color: var(--primary); color: var(--primary); }
/* Base state is display:none (not the [hidden] attribute) so the appear/disappear can itself be
   transitioned via allow-discrete — the row grows in and shrinks away instead of just popping. */
.loading {
  display: none; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted);
  max-height: 0; opacity: 0; overflow: hidden;
  transition: max-height .25s ease, opacity .2s ease, display .25s allow-discrete;
}
.loading.show { display: inline-flex; max-height: 24px; opacity: 1; }
@starting-style {
  .loading.show { max-height: 0; opacity: 0; }
}
.loading .spin {
  width: 13px; height: 13px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid var(--border); border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- 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; }
/* Pico gives any heading after a <p> (the eyebrow, here) a 3rem margin-top, which wins the
   margin-collapse against the eyebrow's own 1rem margin-bottom — a ~48px gap. Kill both so the
   only space left is a deliberate, exact one. Paired with .block-tight-top on these same pages. */
.page-head-tight .eyebrow { margin-bottom: 0; }
.page-head-tight h1 { margin-top: 8px; }
.sub-meta { margin: 6px 0 0; }
.feed-link { font-size: 15px; }

/* page-specific layout (CSP forbids inline style attributes) */
.scriptures-block { margin-bottom: 20px; }
.player-block { margin-bottom: 22px; }
.tags-block { margin-top: 20px; }
.times-block { margin-top: 18px; }
.times-value-block { display: block; margin-top: 4px; }
.contact-block { margin-top: 14px; }
/* These margins separate from the description paragraph above; without one, don't stack on the section's own top padding */
.wrap > .times-block:first-child, .wrap > .contact-block:first-child { margin-top: 0; }
.error-wrap { text-align: center; padding: 96px 0; }
.error-title { font-size: 34px; }
.error-lede { margin: 10px 0 24px; }

/* ---- full-passage reading page (/bible/read) ---- */
.passage { font-size: 16.5px; line-height: 1.7; margin-top: 22px; }
.passage p { margin: 0 0 2px; }
.passage .vn { font-size: 11px; font-weight: 700; color: var(--muted); }
.passage .stanza { white-space: pre-line; margin: 0 0 1.4em; }

/* ---- hymnbook browse index (/hymnbook) ---- */
.hymn-sections { margin-top: 22px; }
.hymn-section + .hymn-section { margin-top: 32px; }
.hymn-section h2 { font-size: 19px; margin: 0 0 10px; }
.hymn-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 4px 20px; }
.hymn-list li::marker { content: none; }
.hymn-list li a { display: flex; gap: 4px; padding: 4px 0; color: inherit; text-decoration: none; }
.hymn-list li a:hover { text-decoration: underline; }
.hymn-list li a span:first-child { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 2em; }

/* ---- 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(calc(-50% + var(--pop-shift, 0px)));
  width: 280px; max-width: 74vw; max-height: 60vh; 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; overflow-y: auto;
}
.ref .pop::after { content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(calc(-50% - var(--pop-shift, 0px))); 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 .pop .vn { font-size: 10px; font-weight: 700; margin-right: 2px; color: color-mix(in srgb, var(--bg) 68%, transparent); }
.ref .pop .pop-more { display: block; margin-top: 8px; color: var(--bg); font-weight: 600; text-decoration: none; }
.ref .pop .pop-more:hover { text-decoration: underline; }
.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; } .loading .spin { animation: none; } }
