:root {
  /* Israel365 / The Israel Bible brand palette (from theisraelbible.com global colors) */
  --navy: #051D42;
  --blue: #0038B8;
  --sky: #1084DE;
  --bg: #F2F2F2;
  --surface: #ffffff;
  --ink: #131313;
  --muted: #5f6673;
  --line: #e2e4e8;
  --green: #0038B8;      /* primary accent (brand blue) */
  --green-soft: #EAF6FF;
  --gold: #C99A51;
  --gold-ink: #8B5E12;   /* accessible gold for text: 5.66:1 on white */
  --gold-soft: #FAF6EC;
  --easy: #2f7d4a;
  --moderate: #9A5F12;
  --hard: #b23a3a;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 4px 16px rgba(20, 30, 25, .06);
  --serif: "Playfair Display", "Frank Ruhl Libre", Georgia, serif;
  --sans: Figtree, system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; height: 100dvh; -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 var(--sans); overflow: hidden; }
a { color: var(--green); }
button { font: inherit; }

/* header */
.top { height: 64px; display: flex; align-items: center; gap: 20px; padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--line); position: relative; z-index: 1000; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--navy); text-decoration: none; white-space: nowrap; }
.brand img { height: 30px; width: auto; flex: none; display: block; }
.brand .sep { width: 1px; height: 28px; background: var(--line); }
.brand .app { font: 600 20px var(--serif); color: var(--gold); letter-spacing: .01em; }
.top::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: linear-gradient(90deg, var(--navy) 0 60%, var(--gold) 60% 100%); }
.search { flex: 1; max-width: 560px; display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 0 16px; color: var(--muted); }
.search input { flex: 1; border: 0; background: none; height: 40px; font: inherit; color: var(--ink); outline: none; min-width: 0; }
.search:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.powered { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.powered img { height: 16px; width: auto; flex: none; display: block; }

/* layout */
.layout { display: flex; height: calc(100% - 64px); }
.panel { width: 440px; flex: none; scroll-behavior: smooth; -webkit-overflow-scrolling: touch; background: var(--surface); border-right: 1px solid var(--line); overflow-y: auto; position: relative; z-index: 500; }
/* a small pre-rendered picture of the default view, so the map area shows the real
   place on the first paint while Leaflet's tiles load over it */
#map { flex: 1; background: #e8e4dc url('img/map-default.webp') center/cover no-repeat; }
.grab { display: none; }

/* filters */
.filters { position: sticky; top: 0; background: var(--surface); padding: 14px 16px 10px; border-bottom: 1px solid var(--line); z-index: 2; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; transition: background-color .18s ease, border-color .18s ease, color .18s ease; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 5px 12px; border-radius: 999px; font-size: 13px; cursor: pointer; }
.chip:hover { border-color: var(--green); }
.chip[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip.js { border-color: var(--gold); }
.chip.js[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row select { height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 0 8px; font: inherit; font-size: 13px; color: var(--ink); }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; user-select: none; }
.toggle input { accent-color: var(--green); width: 16px; height: 16px; margin: 0; }
.toggle.small { font-size: 12px; color: var(--muted); margin-left: auto; }
.where { margin: 10px 0 0; font-size: 13px; color: var(--muted); min-height: 40px; }
.where b { color: var(--navy); font: 600 15px/1.3 var(--serif); display: block; }
.where span { display: block; margin-top: 1px; }
.where .link { border: 0; background: none; padding: 0; margin-top: 2px; color: var(--blue); font: 600 13px var(--sans); cursor: pointer; text-decoration: underline; }
.where .link.busy { opacity: .5; }
.me { width: 18px; height: 18px; border-radius: 50%; background: #0038B8; border: 3px solid #fff; box-shadow: 0 1px 5px rgba(0,0,0,.4); }
.meta { margin-top: 8px; font-size: 13px; color: var(--muted); min-height: 20px; }

/* cards */
.cards { list-style: none; margin: 0; padding: 8px 12px 40px; }
.card { display: flex; gap: 12px; padding: 10px; border-radius: 12px; cursor: pointer; text-decoration: none; color: inherit;
  content-visibility: auto; contain-intrinsic-size: auto 108px;
  transition: background-color .18s ease, transform .18s ease; }
.card:active { transform: scale(.985); }
.card:focus-visible { outline: 3px solid var(--blue); outline-offset: -3px; }
.chip:focus-visible, .btn:focus-visible, .wgo:focus-visible, .back:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.card:hover, .card.hover { background: var(--bg); }
.thumb { width: 118px; height: 88px; flex: none; border-radius: 10px; background: var(--green-soft) center/cover; position: relative; overflow: hidden; }
.thumb.ph { display: grid; place-items: center; color: var(--sky); background: linear-gradient(140deg, var(--green-soft), #dce9f6); }
.thumb:not(.ph) svg { display: none; }
.thumb .badge { position: absolute; left: 6px; bottom: 6px; background: rgba(255,255,255,.95); color: var(--gold-ink); font-size: 10px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; padding: 2px 6px; border-radius: 5px; }
.card h2 { margin: 0 0 2px; font-size: 15px; line-height: 1.25; color: var(--navy); }
.card .he { font-size: 13px; color: var(--muted); direction: rtl; text-align: left; unicode-bidi: plaintext; }
.card .stats { font-size: 13px; color: var(--muted); margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .6; }
.diff { font-weight: 600; }
.diff.Easy { color: var(--easy); } .diff.Moderate { color: var(--moderate); } .diff.Hard { color: var(--hard); }
.card .near { font-size: 12px; color: var(--gold-ink); margin-top: 3px; font-weight: 500; }
.empty { color: var(--muted); padding: 30px 16px; text-align: center; }

/* detail */
.detail .hero { height: 220px; background: var(--green-soft) center/cover; position: relative; }
.detail .hero.ph { display: grid; place-items: center; color: var(--sky); background: linear-gradient(140deg, var(--green-soft), #dce9f6); }
.detail .hero:not(.ph) > svg { display: none; }
.detail .hero .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 20px 14px 8px; font-size: 11px; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.55)); }
.back { position: absolute; top: 12px; left: 12px; z-index: 2; border: 0; background: rgba(255,255,255,.95); border-radius: 999px; padding: 6px 14px 6px 10px; cursor: pointer; box-shadow: var(--shadow); font-size: 13px; font-weight: 600; }
.detail .body { padding: 16px 18px 40px; }
.detail h2 { margin: 0; font: 700 26px/1.2 var(--serif); color: var(--navy); }
.detail .he-title { font: 500 18px var(--serif); color: var(--muted); direction: rtl; unicode-bidi: plaintext; text-align: left; margin-top: 2px; }
.detail .sub { color: var(--muted); font-size: 13px; margin-top: 6px; }
.statgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin: 16px 0; }
.statgrid div { background: var(--surface); padding: 10px 12px; }
.statgrid b { display: block; font-size: 17px; }
.statgrid span { font-size: 12px; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; font-size: 13px; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn { transition: filter .18s ease, transform .18s ease; }
.btn:hover { filter: brightness(.97); }
.btn:active { transform: scale(.97); }
.sec { margin: 22px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.elev svg { width: 100%; height: 120px; display: block; }
.elev .axis { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; }
.desc { font-size: 14px; color: var(--ink); }

/* biblical site block */
.site { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; margin-bottom: 14px; background: var(--surface); }
.site .gallery { display: flex; gap: 2px; height: 150px; }
.site .gallery .g { flex: 1; background: var(--gold-soft) center/cover; min-width: 0; }
.site .gallery .g:first-child { flex: 2; }
.site .in { padding: 12px 14px 14px; }
.site h4 { margin: 0; font: 700 19px var(--serif); color: var(--navy); display: flex; align-items: baseline; gap: 8px; }
.site h4 small { font: 500 12px var(--sans); color: var(--gold-ink); }
.site .about { font-size: 14px; margin: 6px 0 0; }
.verse { border-left: 3px solid var(--gold); background: var(--gold-soft); border-radius: 10px; padding: 10px 12px; margin-top: 10px; font-size: 14px; }
.verse .h { font: 500 19px/1.5 var(--serif); direction: rtl; text-align: right; }
.verse .t { font-style: italic; color: var(--muted); font-size: 13px; margin: 4px 0; }
.verse .r { font-size: 12px; font-weight: 600; margin-top: 4px; }
.verse .r a { color: var(--gold-ink); text-decoration: none; }
.links { margin: 10px 0 0; padding: 0; list-style: none; font-size: 13px; }
.links li { padding: 5px 0; border-top: 1px solid var(--line); }
.links a { text-decoration: none; }
.links a:hover { text-decoration: underline; }
.tiny { font-size: 11px; color: var(--muted); margin-top: 18px; }

/* map bits */
.site-pin { width: 26px; height: 26px; border-radius: 50%; background: var(--navy); border: 2px solid var(--gold); box-shadow: 0 1px 4px rgba(0,0,0,.35); display: grid; place-items: center; color: #fff; }
.z-low .site-pin { transform: scale(.62); }
.z-low .site-pin svg { display: none; }
.leaflet-tooltip.tt { font: 600 12px var(--sans); border-radius: 6px; padding: 3px 8px; }
.leaflet-container { font-family: var(--sans); }
.popup h6 { margin: 0 0 4px; font: 700 15px var(--serif); }
.popup img { width: 100%; height: 90px; object-fit: cover; border-radius: 6px; display: block; margin-bottom: 6px; }
.popup .pbtn { display: inline-block; margin-top: 6px; font-weight: 600; cursor: pointer; color: var(--green); }

/* mobile: map on top, panel as bottom sheet */
@media (max-width: 820px) {
  .top { gap: 10px; padding: 0 12px; height: 56px; padding-top: env(safe-area-inset-top); box-sizing: content-box; }
  .layout { height: calc(100% - 56px - env(safe-area-inset-top)); }
  .search input { font-size: 16px; height: 38px; } /* 16px stops iOS zoom-on-focus */
  .chip { padding: 8px 14px; font-size: 14px; }
  .row select { height: 38px; font-size: 13px; flex: 1 1 0; min-width: 0; padding: 0 4px; }
  .row .toggle { flex: 0 0 auto; }
  .filters { padding: 2px 14px 8px; }
  .where { margin-top: 8px; min-height: 38px; }
  .where b { font-size: 14px; }
  .meta { margin-top: 6px; font-size: 12px; }
  .toggle { min-height: 40px; }
  .toggle.small { margin-left: 0; }
  .cards { padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
  .detail .body { padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
  .btn { padding: 10px 16px; }
  .back { top: 36px; }
  .statgrid b { font-size: 16px; }
  .site .gallery { height: 130px; }
  .leaflet-control-layers-toggle { width: 40px; height: 40px; }

  .brand .sep, .brand .app, .powered { display: none; }
  .brand img { height: 22px; }
  .search { max-width: none; }
  .layout { display: block; position: relative; }
  #map { position: absolute; inset: 0; }
  .panel { position: absolute; left: 0; right: 0; top: 6%; bottom: 0; width: auto; height: 94%; border-right: 0;
    border-top-left-radius: 18px; border-top-right-radius: 18px; box-shadow: 0 -4px 22px rgba(5,29,66,.16);
    transform: translate3d(0, 45%, 0); transition: transform .34s cubic-bezier(.22,.61,.36,1);
    backface-visibility: hidden; }
  .panel { overscroll-behavior: contain; }
  .grab { display: block; position: sticky; top: 0; height: 30px; touch-action: none; background: var(--surface); z-index: 3; cursor: grab; }
  .grab::after { content: ""; position: absolute; left: 50%; top: 8px; width: 40px; height: 5px; margin-left: -20px; border-radius: 3px; background: var(--line); }
  .filters { top: 30px; padding-top: 2px; }
  .thumb { width: 96px; height: 76px; }
  .detail .hero { height: 170px; }
}

.ib-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--gold-ink); margin: 0 0 8px; }
.ib-tag img { height: 12px; opacity: .85; }
.foot-brand { display: flex; align-items: center; gap: 10px; margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line); }
.foot-brand img { height: 18px; }

.leaflet-control-attribution { font-size: 10px; background: rgba(255,255,255,.72); }

/* ---------- welcome / signup gate ---------- */
.welcome { position: fixed; inset: 0; z-index: 3000; background: rgba(5, 29, 66, .55); backdrop-filter: blur(6px); display: grid; place-items: center; padding: 18px; overflow: auto; }
.welcome.out { opacity: 0; transition: opacity .35s; pointer-events: none; }
.welcome-card { width: min(960px, 100%); background: var(--surface); border-radius: 20px; overflow: hidden; box-shadow: 0 24px 70px rgba(5, 29, 66, .45); display: grid; grid-template-columns: 1.05fr 1fr; }
.welcome-art { background-image: url('img/welcome-wide.webp'), url('data:image/webp;base64,UklGRmoAAABXRUJQVlA4IF4AAAAQBACdASoUAA0APu1mqk4ppaOiMAgBMB2JZACdMoMxgEmL6dmi7iLbAAD+56iIaEFbPLCV2Eq+Dt3mztQWyeU4FuTd2J4RlOvTrpDPaVo9JGAvAA5WLwslrqNFAAAA'); background-size: cover, cover; background-position: center, center; position: relative; min-height: 460px; }
.welcome-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, rgba(5,29,66,.14), rgba(5,29,66,0) 55%); }
.welcome-body { padding: 34px 34px 26px; display: flex; flex-direction: column; }
.wlogo { height: 34px; width: auto; align-self: flex-start; flex: none; margin-bottom: 18px; }
.welcome h1 { margin: 0; font: 700 30px/1.15 var(--serif); color: var(--navy); }
.wsub { margin: 10px 0 0; color: var(--muted); font-size: 14px; }
.wfree { margin: 20px 0 12px; font-size: 14px; color: var(--ink); }
.wfree b { color: var(--gold-ink); }
.field { display: block; margin-bottom: 10px; }
.field span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.field input { width: 100%; height: 46px; border: 1px solid var(--line); border-radius: 10px; padding: 0 14px; font: 16px var(--sans); color: var(--ink); background: var(--surface); }
.field input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--green-soft); }
.werr { margin: 2px 0 6px; color: var(--hard); font-size: 13px; }
.wgo { width: 100%; height: 50px; margin-top: 6px; border: 0; border-radius: 999px; background: var(--navy); color: #fff; font: 600 16px var(--sans); cursor: pointer; }
.wgo:hover { background: var(--blue); }
.wgo[disabled] { opacity: .6; cursor: default; }
.wfine { margin: 10px 0 0; font-size: 11px; color: var(--muted); }
.wpower { margin-top: auto; padding-top: 18px; align-self: flex-start; display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--muted); text-decoration: none; }
.wpower img { height: 15px; width: auto; flex: none; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; top: 76px; transform: translateX(-50%); z-index: 2500; max-width: min(460px, calc(100% - 24px)); display: flex; gap: 12px; align-items: flex-start; background: var(--navy); color: #fff; border-left: 4px solid var(--gold); border-radius: 12px; padding: 12px 14px; box-shadow: 0 12px 30px rgba(5,29,66,.35); animation: drop .35s cubic-bezier(.22,.61,.36,1); }
.toast.out { opacity: 0; transform: translate(-50%, -8px); transition: all .3s; }
.toast b { display: block; font: 600 14px/1.3 var(--sans); }
.toast span { display: block; margin-top: 3px; font-size: 12px; opacity: .85; }
.toast button { border: 0; background: none; color: #fff; font-size: 20px; line-height: 1; cursor: pointer; opacity: .7; padding: 0 2px; }
@keyframes drop { from { opacity: 0; transform: translate(-50%, -12px); } }

@media (max-width: 820px) {
  .welcome { padding: 0; align-items: stretch; }
  .welcome-card { grid-template-columns: 1fr; grid-template-rows: 34vh auto; border-radius: 0; min-height: 100%; }
  .welcome-art { background-image: url('img/welcome-tall.webp'), url('data:image/webp;base64,UklGRnAAAABXRUJQVlA4IGQAAADwAwCdASoNABQAPu1kqk4ppaQiMAgBMB2JQBOmUABpugUM0zsAtxuAAN5ZP5rO9p2GKx94VDLNnU4gbQWkJAshFbrcfByb4xVhvIRAGzIoZBbpg7RrMxfCPnT4qPufHdz9NAAA'); min-height: 0; }
  .welcome-art::after { background: linear-gradient(180deg, rgba(5,29,66,.1), rgba(255,255,255,.9) 96%); }
  .welcome-body { padding: 18px 20px calc(22px + env(safe-area-inset-bottom)); }
  .wlogo { height: 28px; margin-bottom: 12px; }
  .welcome h1 { font-size: 25px; }
  .wsub { font-size: 13px; }
  .wfree { margin: 14px 0 10px; }
  .toast { top: auto; bottom: calc(12px + env(safe-area-inset-bottom)); }
}

/* honour the OS "reduce motion" setting */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
.sentinel { height: 1px; list-style: none; }
