/* ---------- Tokens ---------- */
:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #efece5;
  --text: #13232b;
  --text-muted: #56666e;
  --border: #e1dcd1;
  --primary: #0d6e7d;
  --primary-hover: #0a5967;
  --on-primary: #ffffff;
  --focus: #e8972f;
  --danger-fg: #a3322a;
  --hero-1: #0a2a36;
  --hero-2: #0e5160;
  --hero-3: #198592;
  --hero-text: #f3fbfc;
  --hero-muted: #bfdfe4;
  --check-bg: #def1ee;
  --check-fg: #0b5a52;
  --shadow-sm: 0 1px 2px rgba(16, 35, 43, .06);
  --radius: 14px;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-serif: "Fraunces", Georgia, "Times New Roman", serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1317;
    --surface: #131c21;
    --surface-2: #1a252b;
    --text: #e6eef0;
    --text-muted: #9bb0b8;
    --border: #25333a;
    --primary: #3db4c4;
    --primary-hover: #5cc5d3;
    --on-primary: #05222a;
    --danger-fg: #ff9b8f;
    --hero-1: #061a22;
    --hero-2: #0a3843;
    --hero-3: #0f5c66;
    --check-bg: #113a3b;
    --check-fg: #8fe1d6;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0c1317;
  --surface: #131c21;
  --surface-2: #1a252b;
  --text: #e6eef0;
  --text-muted: #9bb0b8;
  --border: #25333a;
  --primary: #3db4c4;
  --primary-hover: #5cc5d3;
  --on-primary: #05222a;
  --danger-fg: #ff9b8f;
  --hero-1: #061a22;
  --hero-2: #0a3843;
  --hero-3: #0f5c66;
  --check-bg: #113a3b;
  --check-fg: #8fe1d6;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3 { line-height: 1.15; margin: 0; }
h1, h2 { font-family: var(--font-serif); font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--primary); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute; left: 16px; top: -48px; z-index: 2000;
  background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: 9px; box-shadow: var(--shadow-sm);
}
.skip-link:focus { top: 12px; }

.icon {
  width: 1.15em; height: 1.15em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}

.muted { color: var(--text-muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: .7em 1.25em;
  font: inherit; font-weight: 600; line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .7; cursor: progress; }
.btn-lg { padding: .9em 1.4em; font-size: 1.04rem; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--text); color: var(--bg); }
.btn-secondary:hover { opacity: .88; }

.spinner {
  width: 1.05em; height: 1.05em; flex: none;
  border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  color: var(--hero-text);
  background: linear-gradient(160deg, var(--hero-1), var(--hero-2));
  background:
    radial-gradient(1200px 500px at 85% -10%, color-mix(in srgb, var(--hero-3) 70%, transparent), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, color-mix(in srgb, var(--hero-3) 45%, transparent), transparent 60%),
    linear-gradient(160deg, var(--hero-1), var(--hero-2));
  padding-bottom: 72px;
}

.site-header {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 16px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: inherit; text-decoration: none;
  font-family: var(--font-serif); font-weight: 600; font-size: 1.25rem; letter-spacing: -.01em;
}
.brand-mark { width: 28px; height: 28px; }
.brand-mark path:first-child { fill: var(--hero-text); }
.brand-mark .brand-shine { fill: none; stroke: var(--hero-2); stroke-width: 2.2; stroke-linecap: round; }
.hero-inner {
  max-width: 760px; margin: 0 auto;
  padding: 40px 16px 8px;
  text-align: center;
}
.eyebrow {
  display: inline-block;
  font-size: .78rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  color: var(--hero-muted);
  margin-bottom: 14px;
}
.eyebrow-note {
  display: block; margin-top: 6px;
  font-size: .82rem; font-weight: 500; letter-spacing: 0; text-transform: none;
}
.eyebrow-dark { color: var(--primary); }
.hero h1 { font-size: clamp(2.1rem, 6vw, 3.6rem); }
.video { margin: 36px auto 0; max-width: 640px; }
.video-facade, .video iframe {
  position: relative; display: block; width: 100%; aspect-ratio: 16 / 9;
  border: 0; border-radius: var(--radius); overflow: hidden;
  background: #000; box-shadow: 0 20px 50px rgba(3, 20, 26, .35);
}
.video-facade img { width: 100%; height: 100%; object-fit: cover; display: block; transition: opacity .15s; }
.video-facade:hover img { opacity: .85; }
.video-play { position: absolute; inset: 0; display: grid; place-items: center; }
.video-play svg { width: 68px; height: 48px; filter: drop-shadow(0 2px 6px rgba(0,0,0,.4)); }
.video figcaption { margin-top: 10px; font-size: .85rem; color: var(--hero-muted); }
.verses {
  margin: 40px auto 0; max-width: 640px; display: grid; gap: 22px;
  padding-top: 28px; border-top: 1px solid color-mix(in srgb, var(--hero-muted) 30%, transparent);
}
.verse { margin: 0; }
.verse p {
  font-family: var(--font-serif); font-style: italic; font-weight: 500;
  font-size: clamp(1rem, 2.4vw, 1.18rem); line-height: 1.5;
  color: var(--hero-text);
}
.verse cite {
  display: block; margin-top: 4px;
  font-style: normal; font-size: .82rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--hero-muted);
}

.search-card {
  margin: 32px auto 0; max-width: 560px;
  background: var(--surface); color: var(--text);
  border-radius: 22px;
  padding: 20px;
  box-shadow: 0 20px 50px rgba(3, 20, 26, .35);
  text-align: left;
}
.search-card #locate-btn { width: 100%; }
.or {
  display: flex; align-items: center; gap: 12px;
  margin: 14px 0; color: var(--text-muted); font-size: .85rem;
}
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.search-form { position: relative; display: flex; gap: 8px; }
.search-form .search-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
}
.search-form input {
  flex: 1; min-width: 0;
  font: inherit; color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .7em 1em .7em 2.6em;
}
.search-form input::placeholder { color: var(--text-muted); }
.search-form input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }

.hero-message { margin-top: 12px; font-size: .92rem; color: var(--danger-fg); }

.privacy-note {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 18px;
  font-size: .85rem; color: var(--hero-muted);
}

.wave { position: absolute; left: 0; right: 0; bottom: -1px; width: 100%; height: 56px; }
.wave path { fill: var(--bg); }

/* Compact hero once a search is showing */
body.has-searched .hero { padding-bottom: 52px; }
body.has-searched .hero-inner { padding-top: 12px; }
body.has-searched .hero .eyebrow,
body.has-searched .hero .verses,
body.has-searched .hero h1,
body.has-searched .privacy-note,
body.has-searched .hero .video { display: none; }
body.has-searched .search-card { margin-top: 8px; padding: 14px; }
body.has-searched .search-card #locate-btn { padding: .7em 1.2em; font-size: 1rem; }
body.has-searched .or { margin: 8px 0; }

@media (min-width: 640px) {
  body.has-searched .search-card {
    max-width: 880px;
    display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 14px;
  }
  body.has-searched .search-card #locate-btn { width: auto; }
  body.has-searched .or { margin: 0; }
  body.has-searched .or::before, body.has-searched .or::after { display: none; }
  body.has-searched .hero-message { grid-column: 1 / -1; margin-top: 0; }
}

/* ---------- Results ---------- */
.results {
  max-width: 1200px; margin: 0 auto;
  padding: 8px 16px 32px;
  scroll-margin-top: 8px;
}
/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 16px 40px;
  max-width: 1200px; margin: 0 auto;
  font-size: .85rem; color: var(--text-muted);
  display: grid; gap: 8px;
}
.noscript { text-align: center; padding: 16px; }


/* ---------- Results list + map ---------- */
.results { max-width: 1280px; }
.results-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; margin-bottom: 12px; }
.results-heading { min-width: 0; flex: 1 1 320px; }
.results-heading h2 { font-size: clamp(1.5rem, 3.5vw, 2rem); overflow-wrap: anywhere; }
.place-label { margin-top: 6px; color: var(--text-muted); overflow-wrap: anywhere; }
.alt-places { margin-top: 6px; font-size: .88rem; color: var(--text-muted); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.alt-places[hidden] { display: none; }
.chip { font: inherit; font-size: .85rem; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 999px; padding: .25em .75em; cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip:hover { border-color: var(--primary); color: var(--primary); }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.control { display: inline-flex; align-items: center; gap: 8px; font-size: .92rem; color: var(--text-muted); }
.control select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: .4em .6em; }
.segmented { display: inline-flex; padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; }
.segmented button { font: inherit; font-size: .88rem; font-weight: 600; border: 0; background: transparent; color: var(--text-muted); padding: .3em .85em; border-radius: 999px; cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.status { min-height: 1.5em; margin-bottom: 12px; font-size: .95rem; color: var(--text-muted); }
.status .spinner { display: inline-block; vertical-align: -0.15em; margin-right: 8px; color: var(--primary); }
.status strong { color: var(--text); }

.results-body { display: grid; grid-template-columns: minmax(340px, 440px) 1fr; gap: 20px; height: min(calc(100vh - 120px), 880px); min-height: 520px; }
.list-column { display: flex; flex-direction: column; min-height: 0; }
.church-list { flex: 1; min-height: 0; list-style: none; margin: 0; padding: 2px 6px 2px 2px; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 12px; scrollbar-width: thin; }
.source-note { padding-top: 10px; font-size: .8rem; color: var(--text-muted); }
.map-wrap { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow-sm); background: var(--surface-2); }
#map { position: absolute; inset: 0; }
@media (max-width: 899px) {
  .results-body { display: flex; flex-direction: column; height: auto; min-height: 0; }
  .map-wrap { order: -1; height: 46vh; min-height: 280px; max-height: 460px; }
  .church-list { flex: none; overflow: visible; padding: 0; }
}

.church { position: relative; display: grid; grid-template-columns: auto 1fr; gap: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); cursor: pointer; transition: border-color .15s, box-shadow .15s; scroll-margin: 12px; }
.church:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.church.is-active { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent), var(--shadow-sm); }
.church-num { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: .85rem; font-weight: 600; background: var(--primary); color: var(--on-primary); }
.church-main { min-width: 0; }
.church-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.church-name { font-family: var(--font-sans); font-size: 1.05rem; font-weight: 600; overflow-wrap: anywhere; }
.distance { flex: none; font-weight: 600; font-size: .92rem; color: var(--primary); white-space: nowrap; font-variant-numeric: tabular-nums; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.badge { display: inline-block; font-size: .74rem; font-weight: 600; padding: .2em .6em; border-radius: 999px; white-space: nowrap; }
.badge-nondenom { background: var(--check-bg); color: var(--check-fg); }
.badge-evangelical { background: color-mix(in srgb, var(--primary) 12%, var(--surface)); color: var(--text-muted); border: 1px solid var(--border); }
.badge-closed { background: #fbefd9; color: #85540c; }
.church-meta li[hidden] { display: none; }
.action[aria-busy="true"] { opacity: .6; }
.action-icon { padding: .38em .6em; }
.church-rating { display: flex; align-items: center; gap: 5px; margin-top: 6px; font-size: .88rem; color: var(--text-muted); }
.icon-star { width: 1em; height: 1em; fill: #e5a50a; stroke: #e5a50a; stroke-width: 1; }
.church-meta { margin: 10px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: .9rem; color: var(--text-muted); }
.church-meta li { display: flex; gap: 8px; align-items: flex-start; overflow-wrap: anywhere; }
.church-meta .icon { margin-top: .2em; width: 1em; height: 1em; }
.church-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.action { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: .85rem; font-weight: 600; color: var(--text); text-decoration: none; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: .38em .85em; cursor: pointer; max-width: 100%; }
.action span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.action:hover { border-color: var(--primary); color: var(--primary); }
.action-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.action-primary:hover { background: var(--primary-hover); color: var(--on-primary); }
.action .icon { width: 1em; height: 1em; }
.church-skeleton { cursor: default; }
.church-skeleton .bone { border-radius: 6px; height: 12px; background: linear-gradient(90deg, var(--surface-2) 0%, var(--border) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.3s ease-in-out infinite; }
.church-skeleton .bone + .bone { margin-top: 10px; }
.church-skeleton .church-num { background: var(--surface-2); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.empty-state { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: 22px; color: var(--text-muted); }
.empty-state h3 { font-family: var(--font-serif); font-size: 1.25rem; color: var(--text); margin-bottom: 8px; }
.empty-state ul { margin: 10px 0 0; padding-left: 1.2em; display: grid; gap: 6px; }
.empty-state .btn { margin-top: 14px; }

.marker { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font: 600 12px/1 var(--font-sans); background: var(--primary); color: var(--on-primary); border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3); transition: transform .15s; }
.marker.is-active, .marker.is-hover { transform: scale(1.25); }
.marker.is-active { background: var(--focus); color: #1d1205; }
.user-dot { width: 18px; height: 18px; border-radius: 50%; background: #2f7bf6; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.popup { font-family: var(--font-sans); font-size: .9rem; line-height: 1.45; max-width: 240px; color: #13232b; }
.popup-name { font-weight: 600; }
.popup-meta { opacity: .75; margin-top: 2px; }
.popup-link { display: inline-block; margin-top: 8px; font-weight: 600; color: #0d6e7d; }

/* Notice shown when a search starts in a country where baptism is restricted */
.notice[hidden] { display: none; }
.notice {
  margin-top: 12px; max-width: 760px;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--focus);
  border-radius: var(--radius); padding: 14px 16px;
  font-size: .93rem; color: var(--text-muted); display: grid; gap: 8px;
}
.notice strong { color: var(--text); }
.notice-options { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
