:root {
  --bg: #faf7f1;
  --surface: #ffffff;
  --text: #2a241c;
  --muted: #7a6f60;
  --line: #e7dfd2;
  --accent: #b07a1f;
  --pharaonic-blue: #1f4fa1;
  --ink: #1a150a;     /* brand name on the starting screen */
  --brick: #8a3b20;   /* tagline, from the logo */
  --brick-line: #7d3d24;
  color-scheme: light;
  --radius: 10px;
  --panel-w: 360px;
  font-family: "Inter", "Noto Sans Arabic", system-ui, sans-serif;
}
@font-face { font-family: "Marcellus"; src: url("vendor/fonts/Marcellus-Regular.ttf") format("truetype"); font-display: block; }
@font-face { font-family: "Aref Ruqaa"; src: url("vendor/fonts/ArefRuqaa-Bold.ttf") format("truetype"); font-weight: 700; font-display: block; }
:root[data-theme="dark"] {
  --bg: #16130f;
  --surface: #201b16;
  --text: #efe6d6;
  --muted: #a69a8a;
  --line: #3a3229;
  --accent: #d9a441;
  --ink: #efe6d6;
  --brick: #e0916b;
  --brick-line: #c76a45;
  color-scheme: dark;
}
[dir="rtl"] { font-family: "Noto Sans Arabic", "Inter", system-ui, sans-serif; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }

.app {
  display: flex; height: 100dvh;
  /* keep clear of phone status/navigation bars (Android edge-to-edge, notches) */
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px)
           env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}
#map { flex: 1; height: 100%; }

/* Panel */
.panel {
  width: var(--panel-w); flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--surface); border-inline-end: 1px solid var(--line); z-index: 500;
}
.panel-head { padding: 16px; border-bottom: 1px solid var(--line); display: grid; gap: 12px; position: relative; }
.brand { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand h1 { font-size: 18px; margin: 0; font-weight: 700; }
.brand-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.icon-btn {
  width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; padding: 0;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 999px; cursor: pointer;
}
.brand-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { flex-shrink: 0; display: block; }
.brand-text { display: grid; gap: 5px; justify-items: start; }
/* Gold/blue stripe from the cartouche column, underlining the app name */
.brand-stripe { display: flex; width: 64px; height: 4px; border-radius: 2px; overflow: hidden; }
.brand-stripe i { flex: 1; background: #d4a729; }
.brand-stripe i:nth-child(even) { background: var(--pharaonic-blue); }
.lang-btn {
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
  border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 13px; cursor: pointer;
}
.field { display: grid; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 500; }
select, .search {
  width: 100%; font: inherit; font-size: 14px; color: var(--text);
  padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 13px;
  padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); cursor: pointer;
}
.chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.chip[aria-pressed="true"] { background: color-mix(in srgb, var(--c) 14%, var(--surface)); border-color: var(--c); }
.chip[aria-pressed="false"] .dot { opacity: .35; }
.chip:disabled { cursor: default; opacity: .55; }
.chip .soon { font-size: 11px; color: var(--muted); }

.count { padding: 10px 16px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.privacy-link { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.privacy-link:hover { color: var(--accent); }
.list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.list li {
  padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer;
  display: grid; grid-template-columns: 10px 1fr; gap: 4px 10px; align-items: baseline;
}
.list li:hover, .list li.active { background: var(--bg); }
.list .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); align-self: center; }
.list .name { font-weight: 600; font-size: 14px; }
.list .meta { grid-column: 2; font-size: 12px; color: var(--muted); }
.empty { padding: 24px 16px; color: var(--muted); font-size: 14px; }

/* Markers & popups */
.pin {
  width: 16px; height: 16px; border-radius: 50%; background: var(--c);
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35);
}
.pin.museum { border-radius: 4px; }
.pin-emoji {
  width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
  font-size: 20px; line-height: 1;
  font-family: "Apple Color Emoji", "Noto Color Emoji", "Segoe UI Emoji", sans-serif;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.35));
}
.leaflet-popup-content { margin: 14px 16px; font-family: inherit; }
.pop h3 { margin: 0 0 2px; font-size: 15px; }
.pop .alt { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.pop .place { display: flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; color: var(--accent); margin-bottom: 6px; }
.pop .place svg { flex-shrink: 0; }
.pop .tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.pop .tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); }
.pop p { margin: 0 0 10px; font-size: 13px; line-height: 1.5; }
.pop a { color: var(--accent); font-size: 13px; font-weight: 600; text-decoration: none; }
/* "Open in Google Maps": pharaonic blue button (the blue of the cartouche column) */
.pop a.maps-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 12px 18px; border-radius: 999px; /* pill */
  background: var(--pharaonic-blue); color: #fff; font-size: 14px;
  box-shadow: 0 1px 3px rgba(31, 79, 161, .35);
}
.pop a.maps-btn:hover { background: #1a4389; }
.pop a.maps-btn:active { background: #163a78; }
.pop a.maps-btn svg { flex-shrink: 0; filter: drop-shadow(0 1px 1px rgba(0,0,0,.25)); }
[dir="rtl"] .leaflet-popup-content { direction: rtl; text-align: right; }

.sheet-toggle { display: none; }

/* Phone: panel becomes a bottom sheet */
@media (max-width: 720px) {
  .app { flex-direction: column-reverse; }
  .panel {
    width: 100%; height: 46dvh; border-inline-end: 0; border-top: 1px solid var(--line);
    transition: height .2s ease;
  }
  .panel.collapsed { height: auto; }
  .panel.collapsed .list, .panel.collapsed .count { display: none; }
  .panel-head { padding: 12px 16px; gap: 10px; }
  .sheet-toggle {
    display: block; position: absolute; top: 4px; left: 50%; transform: translateX(-50%);
    width: 44px; height: 14px; border: 0; background: transparent; cursor: pointer;
  }
  .sheet-toggle::after {
    content: ""; display: block; width: 36px; height: 4px; margin: 0 auto;
    border-radius: 2px; background: var(--line);
  }
}

/* Starting screen (logo, name, tagline) shown over the app at launch */
.intro {
  position: fixed; inset: 0; z-index: 3000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 0 16px; background: var(--bg); direction: ltr; /* same colour Android paints behind the status and navigation bars */
  transition: opacity .45s ease, visibility 0s linear .45s;
}
.intro.hide { opacity: 0; visibility: hidden; }
.intro-name {
  display: flex; align-items: center; gap: 14px; margin-top: 34px;
  font-family: "Marcellus", serif; font-size: 23px; letter-spacing: .2em; color: var(--ink); white-space: nowrap;
}
.intro-name::before, .intro-name::after { content: ""; width: 30px; height: 2px; background: var(--brick-line); flex-shrink: 0; }
.intro-name span { margin-inline-end: -.2em; } /* cancel trailing letter-spacing so the name stays centred */
.intro-tag { display: flex; align-items: center; gap: 12px; margin-top: 20px; color: var(--brick); }
.intro-tag .ar { font-family: "Aref Ruqaa", serif; font-weight: 700; font-size: 24px; line-height: 1; position: relative; top: -2px; }
.intro-tag .dot { font-size: 13px; opacity: .85; }
.intro-tag .en { font-family: "Marcellus", serif; font-size: 13px; letter-spacing: .24em; }
@media (prefers-reduced-motion: reduce) { .intro { transition: none; } }

/* Dark mode: map, popups and controls */
.leaflet-container { background: var(--bg); }
:root[data-theme="dark"] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.92) contrast(.88) saturate(.7); }
:root[data-theme="dark"] .leaflet-popup-content-wrapper,
:root[data-theme="dark"] .leaflet-popup-tip { background: var(--surface); color: var(--text); }
:root[data-theme="dark"] .leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
:root[data-theme="dark"] .leaflet-bar a { background: var(--surface); color: var(--text); border-bottom-color: var(--line); }
:root[data-theme="dark"] .leaflet-bar { border-color: var(--line); }
:root[data-theme="dark"] .leaflet-control-attribution { background: rgba(32, 27, 22, .85); color: var(--muted); }
:root[data-theme="dark"] .leaflet-control-attribution a { color: var(--accent); }
:root[data-theme="dark"] .pin { border-color: #f3ead9; }
