/* ============================================================
   Interactive master plan — pages/map.php
   Uses the site's theme tokens (style.css). Everything is scoped under .city-map.
   ============================================================ */
.page-map #navbar { background: var(--surface-glass); -webkit-backdrop-filter: blur(24px) saturate(1.8); backdrop-filter: blur(24px) saturate(1.8); box-shadow: 0 1px 0 rgba(201,162,39,0.15), 0 4px 30px rgba(0,0,0,0.25); }

.city-map {
    --map-bg: #0B0A2E;
    --panel-w: 370px;
    position: relative; margin-top: var(--nav-h);
    height: calc(100vh - var(--nav-h)); height: calc(100svh - var(--nav-h)); min-height: 520px;
    background: var(--map-bg); overflow: hidden; isolation: isolate;
}
.city-map.is-full { margin-top: 0; height: 100vh; }
.city-map .map-canvas { position: absolute; inset: 0; background: var(--map-bg); }
.city-map[data-base="osm"] .map-canvas, .city-map[data-base="sat"] .map-canvas { background: #2a2a2a; }

/* ── Side panel ─ */
.map-panel {
    position: absolute; top: 16px; right: 16px; bottom: 16px; z-index: 5; width: var(--panel-w);
    display: flex; flex-direction: column; gap: 14px; overflow-y: auto; overscroll-behavior: contain;
    padding: 20px; border-radius: var(--radius-xl);
    background: var(--surface-glass); border: 1px solid var(--gold-border);
    -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
    box-shadow: var(--shadow-deep); scrollbar-width: thin;
}
.map-panel h1 { font-size: 1.15rem; font-weight: 900; color: var(--white); line-height: 1.5; }
.map-panel h1 span { color: var(--gold); }
.map-panel .lead { font-size: 0.8rem; color: var(--text-muted); line-height: 1.8; margin-top: 2px; }
.map-panel h2 { font-size: 0.78rem; font-weight: 800; color: var(--gold); letter-spacing: 0.02em; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.map-sec { padding-top: 14px; border-top: 1px solid var(--hairline); }

.map-search { position: relative; }
.map-search form { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 8px; border-radius: var(--radius-pill); background: var(--navy-card); border: 1px solid var(--gold-border); transition: border-color var(--transition), box-shadow var(--transition); }
.map-search form:focus-within { border-color: var(--gold); box-shadow: 0 0 0 4px var(--gold-soft); }
.map-search i.fa-magnifying-glass { color: var(--gold); margin-inline-start: 8px; }
.map-search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--white); font-family: var(--font-ar); font-size: 0.92rem; padding: 6px 2px; outline: none; }
.map-search input::placeholder { color: var(--text-muted); }
.map-search button[type=submit] { border: 0; cursor: pointer; padding: 9px 16px; border-radius: var(--radius-pill); background: linear-gradient(135deg, var(--gold), var(--gold-bright)); color: var(--on-gold); font-family: var(--font-ar); font-weight: 800; font-size: 0.82rem; }
.map-results { position: absolute; top: calc(100% + 6px); right: 0; left: 0; z-index: 3; max-height: 320px; overflow-y: auto; list-style: none; margin: 0; padding: 6px; border-radius: var(--radius-lg); background: var(--navy-card); border: 1px solid var(--gold-border); box-shadow: var(--shadow-deep); }
.map-results button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: right; padding: 10px 12px; border: 0; border-radius: var(--radius); background: none; color: var(--white); font-family: var(--font-ar); font-size: 0.86rem; cursor: pointer; }
.map-results button:hover, .map-results button:focus-visible { background: var(--gold-soft); outline: none; }
.map-results i { width: 18px; text-align: center; color: var(--gold); }
.map-results small { margin-inline-start: auto; color: var(--text-muted); }
.map-results .empty { padding: 12px; font-size: 0.8rem; color: var(--text-muted); line-height: 1.8; }
.map-hint { font-size: 0.74rem; color: var(--text-muted); margin-top: 8px; display: flex; gap: 6px; align-items: flex-start; line-height: 1.7; }

.base-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 4px; border-radius: var(--radius-pill); background: var(--gold-soft); border: 1px solid var(--gold-border); }
.base-switch button { border: 0; padding: 8px 6px; border-radius: var(--radius-pill); background: none; color: var(--text-light); font-family: var(--font-ar); font-weight: 700; font-size: 0.8rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: all var(--transition); }
.base-switch button[aria-pressed="true"] { background: linear-gradient(135deg, var(--gold), var(--gold-bright)); color: var(--on-gold); box-shadow: var(--shadow-gold); }

.layer-list { display: grid; gap: 4px; }
.layer-row { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--radius); cursor: pointer; font-size: 0.86rem; color: var(--text-light); transition: background var(--transition); }
.layer-row:hover { background: var(--gold-soft); }
.layer-row .sw { width: 22px; height: 14px; border-radius: 4px; flex-shrink: 0; border: 1px solid var(--hairline); }
.layer-row .lbl { flex: 1; }
.layer-row input { appearance: none; width: 36px; height: 20px; border-radius: 20px; background: var(--hairline); position: relative; cursor: pointer; transition: background var(--transition); flex-shrink: 0; }
.layer-row input::after { content: ''; position: absolute; top: 3px; right: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--text-muted); transition: all var(--transition); }
.layer-row input:checked { background: var(--gold); }
.layer-row input:checked::after { right: 19px; background: #fff; }
.layer-row input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.svc-legend { display: flex; flex-wrap: wrap; gap: 6px; }
.svc-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: var(--radius-pill); border: 1px solid var(--c); background: transparent; color: var(--text-light); font-family: var(--font-ar); font-size: 0.76rem; font-weight: 700; cursor: pointer; opacity: 0.5; transition: all var(--transition); }
.svc-chip i { color: var(--c); }
.svc-chip span { font-weight: 600; opacity: 0.75; }
.svc-chip.is-on { opacity: 1; background: color-mix(in srgb, var(--c) 16%, transparent); }

.map-disclaimer { font-size: 0.72rem; color: var(--text-muted); line-height: 1.8; }
.map-disclaimer a { color: var(--gold); font-weight: 700; }

/* ── Floating toolbar (left side, RTL) & OpenLayers controls ─ */
.map-toolbar { position: absolute; top: 16px; left: 16px; z-index: 4; display: flex; flex-direction: column; gap: 8px; }
.map-tool, .city-map .ol-zoom button {
    width: 44px; height: 44px; border-radius: 14px; border: 1px solid var(--gold-border); cursor: pointer;
    background: var(--surface-glass); color: var(--gold); font-size: 1rem; display: inline-flex; align-items: center; justify-content: center;
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: var(--shadow-card); transition: all var(--transition);
}
.map-tool:hover, .city-map .ol-zoom button:hover { border-color: var(--gold); transform: translateY(-1px); }
.map-tool.is-busy i { animation: mapSpin 1s linear infinite; }
#mapPanelToggle { display: none; }
.city-map .ol-zoom { position: absolute; top: auto; bottom: 110px; left: 16px; right: auto; display: flex; flex-direction: column; gap: 8px; background: none; padding: 0; }
.city-map .ol-zoom button { margin: 0; font-size: 1.3rem; font-weight: 400; font-family: var(--font-ar); }
.city-map .ol-scale-line { left: 16px; bottom: 16px; background: var(--surface-glass); border: 1px solid var(--hairline); border-radius: 10px; padding: 4px 8px; }
.city-map .ol-scale-line-inner { border-color: var(--text-light); color: var(--text-light); font-family: var(--font-ar); font-size: 0.7rem; }
.city-map .ol-attribution { right: auto; left: 16px; bottom: 56px; max-width: calc(100% - var(--panel-w) - 80px); background: var(--surface-glass); border-radius: 10px; font-size: 0.68rem; direction: ltr; }
.city-map .ol-attribution button { background: none; color: var(--gold); }
.city-map .ol-attribution ul { color: var(--text-light); }
.city-map .ol-attribution a { color: var(--gold); }

/* ── Result card ─ */
.map-card {
    position: absolute; z-index: 6; left: 50%; bottom: 22px; width: min(440px, calc(100% - var(--panel-w) - 120px));
    transform: translate(calc(-50% - var(--panel-w) / 2), 20px); opacity: 0;
    padding: 18px 18px 16px; border-radius: var(--radius-xl); background: var(--navy-card); border: 1px solid var(--gold-border);
    box-shadow: var(--shadow-deep); transition: transform 0.35s var(--spring), opacity 0.25s ease;
}
.map-card.is-open { transform: translate(calc(-50% - var(--panel-w) / 2), 0); opacity: 1; }
.map-card-close { position: absolute; top: 12px; left: 12px; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--hairline); background: none; color: var(--text-light); cursor: pointer; }
.map-card-head { display: flex; gap: 14px; align-items: flex-start; padding-left: 36px; }
.map-card-icon { --c: var(--gold); width: 46px; height: 46px; border-radius: 14px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 1.15rem; color: var(--c); background: color-mix(in srgb, var(--c) 16%, transparent); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent); }
.map-card-head small { font-size: 0.74rem; color: var(--text-muted); font-weight: 700; }
.map-card-head h3 { font-size: 1.08rem; font-weight: 900; color: var(--white); line-height: 1.5; }
.map-card-en { font-size: 0.76rem; color: var(--text-muted); text-align: right; }
.map-card-meta { font-size: 0.84rem; color: var(--text-light); margin-top: 10px; display: flex; align-items: center; gap: 8px; }
.map-card-meta i { color: var(--gold); }
.map-card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.map-card-actions .btn-primary { padding: 9px 16px; font-size: 0.84rem; }
.map-card-note { font-size: 0.7rem; color: var(--text-muted); margin-top: 10px; }

/* ── Markers ─ */
.map-pulse { width: 22px; height: 22px; border-radius: 50%; background: #E5BD45; border: 3px solid #fff; box-shadow: 0 0 0 0 rgba(229,189,69,0.7); animation: mapPulse 1.8s ease-out infinite; pointer-events: none; }
.map-me { width: 16px; height: 16px; border-radius: 50%; background: #3B82F6; border: 3px solid #fff; box-shadow: 0 0 0 8px rgba(59,130,246,0.25); pointer-events: none; }
@keyframes mapPulse { 0% { box-shadow: 0 0 0 0 rgba(229,189,69,0.75); } 100% { box-shadow: 0 0 0 26px rgba(229,189,69,0); } }
@keyframes mapSpin { to { transform: rotate(360deg); } }

/* ── Loading ─ */
.map-loading { position: absolute; inset: 0; z-index: 8; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; background: var(--map-bg); color: var(--text-light); font-weight: 700; transition: opacity 0.5s ease, visibility 0.5s ease; }
.map-loading .ring { width: 54px; height: 54px; border-radius: 50%; border: 3px solid var(--gold-border); border-top-color: var(--gold); animation: mapSpin 0.9s linear infinite; }
.map-loading.is-done { opacity: 0; visibility: hidden; }
.map-loading.is-error .ring { display: none; }

/* ── Below the map ─ */
.map-tips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.map-tip { background: var(--navy-card); border: 1px solid var(--hairline); border-radius: var(--radius-xl); padding: 22px; box-shadow: var(--shadow-card); }
.map-tip i { font-size: 1.3rem; color: var(--gold); margin-bottom: 10px; display: block; }
.map-tip h3 { font-size: 0.95rem; font-weight: 800; color: var(--white); margin-bottom: 6px; }
.map-tip p { font-size: 0.82rem; color: var(--text-light); line-height: 1.8; }

/* ── Mobile: panel becomes a bottom sheet ─ */
@media (max-width: 900px) {
    .city-map { --panel-w: 0px; }
    .map-panel { top: auto; right: 10px; left: 10px; bottom: 10px; width: auto; max-height: 64%; transform: translateY(calc(100% - 132px)); transition: transform 0.35s var(--spring); padding: 14px 16px 18px; }
    .map-panel::before { content: ''; width: 44px; height: 4px; border-radius: 4px; background: var(--hairline); margin: -4px auto 4px; flex-shrink: 0; }
    .city-map.panel-open .map-panel { transform: none; }
    .map-panel .lead, .map-panel h1 { display: none; }
    #mapPanelToggle { display: inline-flex; }
    .map-card { width: auto; left: 10px; right: 10px; bottom: 150px; transform: translateY(20px); }
    .map-card.is-open { transform: none; }
    .city-map .ol-zoom { bottom: auto; top: 16px; left: auto; right: 16px; }
    .city-map .ol-scale-line { bottom: 150px; }
    .city-map .ol-attribution { bottom: 150px; left: auto; right: 10px; max-width: 70%; }
    .map-tips { grid-template-columns: 1fr 1fr; }
    .page-map .whatsapp-float { display: none; } /* would cover the bottom sheet's search box */
}
@media (max-width: 520px) { .map-tips { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { .map-pulse { animation: none; } }
