/* Churches Worldwide — layout: search band on top, list + map split below, then browse / add / about. */
:root {
  --bg: #F2F4F8;
  --surface: #FFFFFF;
  --ink: #141B2E;
  --muted: #586178;
  --line: #DCE1EA;
  --soft: #E8ECF5;
  --accent: #22357A;
  --accent-ink: #FFFFFF;
  --gold: #A77A1F;
  --band: #18265A;
  --band-ink: #F3F5FB;
  --band-muted: #B7C1E0;
  --danger: #B42318;

  --f-display: "Young Serif", Georgia, "Times New Roman", serif;
  --f-body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 27, 46, .06), 0 8px 24px rgba(20, 27, 46, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0D1220;
    --surface: #141B2D;
    --ink: #E8ECF5;
    --muted: #9CA6BD;
    --line: #283149;
    --soft: #1B2440;
    --accent: #93A8F2;
    --accent-ink: #0D1220;
    --gold: #E0B656;
    --band: #111A36;
    --band-ink: #EEF1F9;
    --band-muted: #9DA9CF;
    --danger: #F97066;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { animation: none !important; transition: none !important; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--f-body);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
[hidden] { display: none !important; }
a { color: var(--accent); }
h1, h2, h3 { text-wrap: balance; margin: 0; }
h2 { font: 400 clamp(1.6rem, 3vw, 2.1rem)/1.2 var(--f-display); letter-spacing: -.01em; }
h3 { font: 600 1.1rem/1.3 var(--f-body); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 4px; }

.wrap {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* Header */
.site-header { background: var(--band); color: var(--band-ink); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 14px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand-name { font: 400 1.3rem/1 var(--f-display); }
.mark {
  width: 28px; height: 28px; border-radius: 7px; background: #E0B656; position: relative; flex: none;
}
.mark::before, .mark::after { content: ""; position: absolute; background: var(--band); }
.mark::before { left: 12px; top: 5px; width: 4px; height: 18px; }
.mark::after { left: 7px; top: 10px; width: 14px; height: 4px; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { color: var(--band-muted); text-decoration: none; padding: 6px 10px; border-radius: 6px; font-weight: 500; font-size: .95rem; }
.nav a:hover { color: var(--band-ink); background: rgba(255, 255, 255, .08); }

/* Search band */
.search-band {
  background:
    radial-gradient(ellipse 60% 120% at 92% 0%, rgba(224, 182, 86, .22), transparent 60%),
    var(--band);
  color: var(--band-ink);
  padding-block: clamp(28px, 6vw, 64px) clamp(28px, 5vw, 52px);
}
.eyebrow { margin: 0 0 10px; color: #E0B656; text-transform: uppercase; letter-spacing: .12em; font-size: .78rem; font-weight: 600; }
.search-band h1 { font: 400 clamp(2rem, 5vw, 3.4rem)/1.08 var(--f-display); max-width: 18ch; letter-spacing: -.015em; }
.search {
  margin-top: clamp(20px, 4vw, 32px);
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  background: var(--surface);
  color: var(--ink);
  padding: 10px;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
  max-width: 980px;
}
.field { display: flex; flex-direction: column; gap: 2px; padding: 6px 12px; border-radius: 8px; background: var(--soft); min-width: 0; }
.field span { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.field input { border: 0; background: transparent; font: 500 1.02rem/1.4 var(--f-body); color: var(--ink); padding: 2px 0; width: 100%; min-width: 0; }
.field input:focus { outline: none; }
.field:focus-within { box-shadow: inset 0 0 0 2px var(--accent); }
.search-actions { display: flex; gap: 8px; }
.hint { margin: 12px 0 0; color: var(--band-muted); font-size: .92rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 600 .98rem/1 var(--f-body); padding: 12px 18px; border-radius: 8px;
  border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--accent); border-color: var(--line); }
.btn.ghost:hover { background: var(--soft); }
.btn[disabled] { opacity: .6; cursor: progress; }

/* Explorer */
.explorer { padding-block: 24px 8px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.status { margin: 0; font-weight: 500; color: var(--ink); min-width: 0; }
.status small { display: block; color: var(--muted); font-weight: 400; }
.status.error { color: var(--danger); }
.view-toggle { display: none; background: var(--soft); border-radius: 8px; padding: 3px; flex: none; }
.view-toggle button { border: 0; background: transparent; color: var(--muted); font: 600 .9rem var(--f-body); padding: 7px 14px; border-radius: 6px; cursor: pointer; }
.view-toggle button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.families { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: 500 .85rem/1 var(--f-body); padding: 7px 11px; border-radius: 999px; cursor: pointer;
}
.chip .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--soft); box-shadow: inset 0 0 0 1px var(--accent); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--muted)); flex: none; }

.split {
  display: grid;
  grid-template-columns: minmax(300px, 400px) 1fr;
  height: clamp(520px, 74vh, 820px);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.list-pane { position: relative; overflow: hidden; border-right: 1px solid var(--line); min-width: 0; }
.results { list-style: none; margin: 0; padding: 6px; height: 100%; overflow-y: auto; }
.results li + li { border-top: 1px solid var(--line); }
.row {
  display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left;
  border: 0; background: transparent; color: inherit; padding: 12px 10px; border-radius: 8px; cursor: pointer; font: inherit;
}
.row:hover, .row.active { background: var(--soft); }
.row .dot { margin-top: 7px; }
.row-main { display: flex; flex-direction: column; min-width: 0; }
.row-name { font-weight: 600; overflow-wrap: anywhere; }
.row-name.unnamed { font-weight: 500; color: var(--muted); font-style: italic; }
.row-meta { color: var(--muted); font-size: .88rem; }
.empty { padding: 28px 18px; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: 6px; }
.skeleton { height: 54px; margin: 6px 4px; border-radius: 8px; background: linear-gradient(90deg, var(--soft), var(--line), var(--soft)); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.map-pane { position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: var(--soft); }
.area-btn { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 500; background: var(--surface); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow); }
.area-btn:active { transform: translateX(-50%) translateY(1px); }
.loading {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 500;
  display: flex; align-items: center; gap: 10px; background: var(--surface); color: var(--ink);
  padding: 10px 16px; border-radius: 999px; box-shadow: var(--shadow); font-weight: 500; font-size: .92rem;
}
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Map markers */
.cw-pin { background: transparent; border: 0; }
.cw-pin span {
  display: block; width: 16px; height: 16px; border-radius: 50%;
  background: var(--c); border: 2.5px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .45);
}
.cw-pin.selected span { width: 24px; height: 24px; margin: -4px; border-width: 3px; box-shadow: 0 0 0 6px rgba(224, 182, 86, .55), 0 2px 6px rgba(0, 0, 0, .5); }
.cw-cluster { background: transparent; border: 0; }
.cw-cluster span {
  display: grid; place-items: center; width: 100%; height: 100%; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font: 700 13px/1 var(--f-body);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 28%, transparent), 0 2px 6px rgba(0, 0, 0, .3);
  font-variant-numeric: tabular-nums;
}
.leaflet-container { font-family: var(--f-body); }
.leaflet-control-attribution { font-size: 11px; }
.leaflet-tooltip { font: 600 .82rem var(--f-body); }

/* Detail */
.detail { position: absolute; inset: 0; overflow-y: auto; background: var(--surface); padding: 16px 20px 28px; z-index: 2; }
.detail:focus { outline: none; }
.back { border: 0; background: transparent; color: var(--accent); font: 600 .92rem var(--f-body); padding: 6px 0; cursor: pointer; }
.detail-family { display: flex; align-items: center; gap: 8px; margin: 14px 0 6px; font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.detail h2 { font-size: clamp(1.5rem, 2.6vw, 1.9rem); overflow-wrap: anywhere; }
.detail .den { margin: 6px 0 0; color: var(--muted); }
.facts { margin: 20px 0 0; display: grid; gap: 14px; }
.facts div { display: grid; gap: 2px; }
.facts dt { font-size: .74rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; white-space: pre-line; }
.mono { font-family: var(--f-mono); font-size: .9rem; font-variant-numeric: tabular-nums; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.actions .btn { padding: 10px 14px; font-size: .9rem; }
.fix { margin-top: 22px; padding: 14px; border-radius: var(--radius); background: var(--soft); font-size: .92rem; }
.fix p { margin: 0 0 6px; font-weight: 600; }
.fix a { margin-right: 14px; font-weight: 500; }

/* Countries */
.countries, .add, .about { padding-block: clamp(40px, 7vw, 72px) 0; }
.lede { color: var(--muted); max-width: 65ch; margin: 10px 0 0; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 22px 0 14px; }
.tab { border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: 600 .92rem var(--f-body); padding: 9px 14px; border-radius: 8px; cursor: pointer; }
.tab[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.country-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; }
.country {
  display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  text-align: left; font: 500 .95rem var(--f-body); padding: 10px 12px; border-radius: 8px; cursor: pointer; min-width: 0;
}
.country:hover { border-color: var(--accent); background: var(--soft); }
.country .flag { font-size: 1.2rem; line-height: 1; flex: none; }
.country .cname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* Add */
.add-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 24px; }
.add-card { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 24px; border: 1px solid var(--line); background: var(--surface); border-radius: 14px; min-width: 0; }
.add-card p { margin: 0; color: var(--muted); }
.add-card small { color: var(--muted); }
.step { font-size: .74rem; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--gold); }
.table-wrap { width: 100%; overflow-x: auto; }
.tags { border-collapse: collapse; width: 100%; font-size: .9rem; }
.tags th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 6px 10px; border-bottom: 1px solid var(--line); }
.tags td { padding: 7px 10px; border-bottom: 1px solid var(--line); font-family: var(--f-mono); font-size: .86rem; }
.tags td:first-child { color: var(--accent); white-space: nowrap; }

/* About + footer */
.about-grid { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 28px; }
.about-grid p { color: var(--muted); max-width: 60ch; }
.about-grid h3 { margin-top: 6px; }
.site-footer { margin-top: clamp(48px, 8vw, 88px); border-top: 1px solid var(--line); color: var(--muted); font-size: .88rem; }
.footer-inner { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-block: 22px calc(22px + env(safe-area-inset-bottom, 0px)); }

/* Narrow screens */
@media (max-width: 860px) {
  .search { grid-template-columns: 1fr; }
  .search-actions .btn { flex: 1; }
  .view-toggle { display: inline-flex; }
  .split { grid-template-columns: 1fr; height: 72vh; min-height: 460px; }
  .list-pane { border-right: 0; }
  .split[data-view="list"] .map-pane { display: none; }
  .split[data-view="map"] .list-pane { display: none; }
  .add-grid, .about-grid { grid-template-columns: 1fr; }
}
