/* JHWH Atlas – modern, plain, photo-first */
:root {
  --bg: #ffffff;
  --surface: #f5f6f8;
  --surface-2: #eceef2;
  --text: #1b2330;
  --muted: #5a6474;
  --border: #e1e4ea;
  --accent: #1f4e8c;
  --accent-soft: #e7eef8;
  --pin-own: #c2410c;
  --pin-foreign: #2b7bb9;
  --pin-none: #9aa3b0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .06);
  --header-h: 60px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-hebrew: "SBL Hebrew", "Ezra SIL", "Times New Roman", serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--text); background: var(--bg); line-height: 1.55; font-size: 16px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button, input, select { font: inherit; color: inherit; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 20px; }
[dir="rtl"], .hebrew { font-family: var(--font-hebrew); }

/* Header */
.site-header { position: sticky; top: 0; z-index: 30; background: var(--bg); border-bottom: 1px solid var(--border); }
.site-header .wrap { display: flex; align-items: center; gap: 16px; min-height: var(--header-h); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none !important; min-width: 0; }
.brand svg { width: 46px; height: 46px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-name { font-weight: 650; font-size: 17px; letter-spacing: .2px; }
.brand-count { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-spacer { flex: 1; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.badge-new { display: inline-flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-size: 13px; border: 1px solid transparent; cursor: pointer; white-space: nowrap; }
.badge-new .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.badge-new.is-active { border-color: var(--accent); }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); cursor: pointer; font-size: 14px; white-space: nowrap; color: var(--text); text-decoration: none !important; }
.btn:hover { background: var(--surface); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #193f72; }
.nav-link { font-size: 14px; color: var(--text); padding: 7px 8px; }
.lang-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.lang-switch a { padding: 7px 10px; font-size: 13px; line-height: 1.3; color: var(--muted); text-decoration: none; }
.lang-switch a[aria-current="true"] { background: var(--accent); color: #fff; }

/* Filter bar */
.filterbar { border-bottom: 1px solid var(--border); background: var(--bg); }
.filterbar .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 10px; padding-bottom: 10px; }
.search { position: relative; flex: 1 1 220px; max-width: 320px; }
.search input { width: 100%; padding: 8px 12px 8px 34px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.search input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); background: var(--bg); }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.filters { display: contents; }
.select { padding: 8px 30px 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235a6474' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center; appearance: none; cursor: pointer; font-size: 14px; max-width: 220px; }
.select.is-set { border-color: var(--accent); background-color: var(--accent-soft); color: var(--accent); }
.select:disabled { opacity: .45; cursor: default; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; user-select: none; }
.toggle input { accent-color: var(--accent); margin: 0; }
.link-reset { font-size: 14px; background: none; border: 0; color: var(--accent); cursor: pointer; padding: 6px; }
.filter-toggle { display: none; }

/* Map */
.map-outer { padding-top: 16px; }
.map-wrap { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.filterbar { border-bottom: 0; }
#map { height: min(62vh, 640px); min-height: 380px; background: var(--surface); }
.map-legend { position: absolute; left: 12px; bottom: 12px; z-index: 2; display: flex; gap: 12px; padding: 6px 10px; background: rgba(255,255,255,.92); border-radius: 8px; box-shadow: var(--shadow); font-size: 12.5px; color: var(--muted); }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.15); margin-right: 5px; vertical-align: -1px; }
.legend-dot.own { background: var(--pin-own); }
.legend-dot.foreign { background: var(--pin-foreign); }
.legend-dot.none { background: var(--pin-none); }
.maplibregl-popup-content { padding: 0; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); font-family: var(--font); }
.popup { width: 220px; }
.popup img { width: 100%; height: 120px; object-fit: cover; }
.popup-body { padding: 10px 12px 12px; }
.popup-title { font-weight: 600; font-size: 14px; line-height: 1.3; margin: 0 0 2px; }
.popup-meta { font-size: 12.5px; color: var(--muted); margin: 0 0 6px; }
.popup a { font-size: 13.5px; font-weight: 500; }

/* Results */
.results { padding: 14px 0 40px; }
.results-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.results-count { font-size: 14px; color: var(--muted); margin: 0; }
.sheet-handle { display: none; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; list-style: none; margin: 0; padding: 0; }
.tile a { display: block; color: inherit; text-decoration: none !important; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--bg); transition: box-shadow .15s, border-color .15s; }
.tile a:hover, .tile.is-hover a { box-shadow: var(--shadow); border-color: #cfd5de; }
.tile-img { aspect-ratio: 4 / 3; background: var(--surface-2); position: relative; }
.tile-img img { width: 100%; height: 100%; object-fit: cover; }
.tile-img .noimg { position: absolute; inset: 0; display: grid; place-items: center; color: #a3abb8; font-family: var(--font-hebrew); font-size: 34px; }
.tile-body { padding: 10px 12px 12px; }
.tile-title { font-weight: 600; font-size: 15px; line-height: 1.3; margin: 0 0 4px; }
.tile-meta { font-size: 13px; color: var(--muted); margin: 0; display: flex; align-items: center; gap: 6px; }
.empty { padding: 30px; text-align: center; color: var(--muted); background: var(--surface); border-radius: var(--radius); }

/* Detail page */
.detail { padding: 24px 0 60px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; margin-bottom: 14px; }
.detail h1 { font-size: clamp(24px, 3.4vw, 34px); line-height: 1.2; margin: 0 0 6px; font-weight: 680; }
.detail-meta { color: var(--muted); margin: 0 0 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 22px; padding: 0; list-style: none; }
.chip { font-size: 13px; padding: 3px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); }
.chip.photo-own { background: #fdf0e9; border-color: #f4c7b0; color: #9a3412; }
.chip.photo-foreign { background: #e8f1f9; border-color: #b6d3ec; color: #1d5b8c; }
.chip.photo-none { background: var(--surface); color: var(--muted); }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 32px; align-items: start; }
.gallery-main { border-radius: var(--radius); overflow: hidden; background: var(--surface-2); cursor: zoom-in; border: 0; padding: 0; width: 100%; display: block; }
.gallery-main img { width: 100%; max-height: 560px; object-fit: contain; background: #111; }
.gallery-thumbs { display: flex; gap: 8px; margin-top: 8px; overflow-x: auto; padding-bottom: 4px; }
.gallery-thumbs button { border: 2px solid transparent; border-radius: 8px; padding: 0; overflow: hidden; cursor: pointer; flex: none; background: none; }
.gallery-thumbs button[aria-current="true"] { border-color: var(--accent); }
.gallery-thumbs img { width: 84px; height: 64px; object-fit: cover; }
.photo-credit { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; }
.no-photo { padding: 40px 20px; text-align: center; background: var(--surface); border-radius: var(--radius); color: var(--muted); }
.no-photo .hebrew { font-size: 48px; color: #a3abb8; display: block; margin-bottom: 8px; }
.facts { margin: 0 0 24px; }
.facts dt { font-size: 13px; color: var(--muted); margin-top: 14px; }
.facts dd { margin: 2px 0 0; font-size: 16px; }
.prose { max-width: 70ch; }
.prose p { margin: 0 0 1em; }
.mt-note { font-size: 13px; color: var(--muted); font-style: italic; }
.section-title { font-size: 18px; margin: 32px 0 10px; font-weight: 650; }
#minimap { height: 240px; border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.side-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 18px; }
.side-card h2 { font-size: 15px; margin: 0 0 10px; }
.nearby { list-style: none; margin: 0; padding: 0; }
.nearby li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-top: 1px solid var(--border); font-size: 14.5px; }
.nearby li:first-child { border-top: 0; }
.nearby .dist { color: var(--muted); white-space: nowrap; }
.sources { font-size: 14.5px; word-break: break-word; }

/* Lightbox */
dialog.lightbox { border: 0; padding: 0; max-width: 100vw; max-height: 100vh; width: 100vw; height: 100vh; background: rgba(10, 12, 16, .94); color: #fff; }
dialog.lightbox::backdrop { background: rgba(10, 12, 16, .94); }
.lb-inner { position: relative; width: 100%; height: 100%; display: grid; place-items: center; }
.lb-inner img { max-width: 94vw; max-height: 86vh; object-fit: contain; }
.lb-btn { position: absolute; background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 999px; width: 44px; height: 44px; cursor: pointer; font-size: 22px; display: grid; place-items: center; }
.lb-btn:hover { background: rgba(255,255,255,.24); }
.lb-close { top: 16px; right: 16px; }
.lb-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 16px; top: 50%; transform: translateY(-50%); }
.lb-counter { position: absolute; bottom: 18px; left: 0; right: 0; text-align: center; font-size: 14px; opacity: .8; }

/* Static pages */
.page { padding: 32px 0 60px; }
.page h1 { font-size: 30px; margin: 0 0 18px; }
.page h2 { font-size: 20px; margin: 28px 0 8px; }
.placeholder { background: #fff7d6; border: 1px dashed #d8b24a; padding: 2px 6px; border-radius: 4px; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); font-size: 14px; color: var(--muted); }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 18px; padding-top: 18px; padding-bottom: 18px; }
.site-footer a { color: var(--muted); }

/* Tutorial */
.tour-hint { position: fixed; right: 16px; bottom: 16px; z-index: 50; width: 280px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; font-size: 14px; }
.tour-hint p { margin: 0 0 10px; }
.tour-hint .row { display: flex; gap: 8px; justify-content: flex-end; }
.tour-hint .x { position: absolute; top: 6px; right: 8px; background: none; border: 0; font-size: 18px; color: var(--muted); cursor: pointer; }
.tour-focus { position: relative; z-index: 45; outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 8px; }
.tour-shade { position: fixed; inset: 0; background: rgba(15, 20, 30, .35); z-index: 40; }
.tour-bubble { position: fixed; z-index: 60; width: min(320px, calc(100vw - 32px)); background: var(--bg); border-radius: var(--radius); box-shadow: 0 8px 30px rgba(0,0,0,.2); padding: 16px; font-size: 15px; }
.tour-bubble .count { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.tour-bubble p { margin: 0 0 12px; }
.tour-bubble .row { display: flex; justify-content: space-between; gap: 8px; }

/* Mobile */
@media (max-width: 767px) {
  :root { --header-h: 54px; }
  .wrap { padding: 0 16px; }
  .brand svg { width: 38px; height: 38px; }
  .brand-name { white-space: nowrap; font-size: 16px; }
  .brand-count { font-size: 11.5px; }
  .brand { gap: 8px; }
  .header-actions .btn-label { display: none; }
  .header-actions .btn { padding: 6px 7px; }
  .site-header .wrap { gap: 10px; }
  .header-actions { gap: 5px; }
  .badge-new { padding: 6px 7px; }
  .badge-new .dot { display: none; }
  .lang-switch a { padding: 6px 7px; }
  .badge-new { font-size: 12px; }
  .filterbar .wrap { flex-wrap: nowrap; }
  .search { max-width: none; }
  .filter-toggle { display: inline-flex; }
  .filters { display: none; }
  .filters.is-open { display: flex; flex-direction: column; gap: 8px; position: absolute; left: 0; right: 0; top: 100%; background: var(--bg); padding: 12px 16px 16px; border-bottom: 1px solid var(--border); box-shadow: var(--shadow); z-index: 20; }
  .filters.is-open .select { max-width: none; width: 100%; }
  .filterbar { position: relative; }
  body.page-map { overflow: hidden; }
  .page-map #map { height: calc(100dvh - var(--header-h) - 58px); min-height: 0; }
  .map-outer { padding: 0; }
  .map-wrap { border-radius: 0; border: 0; border-top: 1px solid var(--border); }
  .page-map .site-footer { display: none; }
  .page-map .map-legend { bottom: 76px; }
  .page-map .results { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: var(--bg); border-radius: 16px 16px 0 0; box-shadow: 0 -4px 20px rgba(0,0,0,.12); padding: 0 0 12px; max-height: 64px; overflow: hidden; transition: max-height .25s ease; }
  .page-map .results.is-open { max-height: 72dvh; overflow-y: auto; }
  .sheet-handle { display: block; width: 100%; background: none; border: 0; padding: 8px 16px 6px; cursor: pointer; }
  .sheet-handle::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--border); margin: 0 auto 8px; }
  .results-head { margin-bottom: 8px; }
  .tiles { grid-template-columns: 1fr; gap: 10px; }
  .tile a { display: flex; }
  .tile-img { width: 108px; flex: none; aspect-ratio: auto; min-height: 84px; }
  .detail-grid { grid-template-columns: 1fr; gap: 20px; }
  .tour-hint { left: 16px; right: 16px; width: auto; bottom: 80px; }
}
