/* Map-specific styles (MapLibre GL) */

.map-shell { position: relative; }
#map, .map-canvas {
    width: 100%;
    height: 70vh;
    min-height: 380px;
    background: #dfe9e6;
}
/* Map screen (map.php): topbar + filter bar stack above a tall map, all inside a
   rounded contained panel. Height is generous but bounded by both a vh target
   and hard min/max so it never collapses thin on short windows nor gets absurd
   on huge ones. The panel lives in a .section wrapper (see map.php) which gives
   the breathing room above the footer. */
.map-full .map-shell {
    display: flex; flex-direction: column; background: #eef4f1;
    border: 1px solid var(--color-border); border-radius: var(--radius);
    overflow: hidden; box-shadow: var(--shadow);
}
.map-full #map, .map-full .map-canvas {
    height: clamp(600px, 80vh, 900px); min-height: 600px; flex: none;
}
/* Migration replay map (migration.php): same tall, contained treatment.
   #map-qualified to beat the base `#map { height:70vh }`. */
#map.mig-map {
    height: clamp(600px, 80vh, 900px); min-height: 600px;
    border: 1px solid var(--color-border); border-radius: var(--radius); overflow: hidden;
}

/* Filter bar */
.map-filters {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: end;
    padding: 12px 16px; background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}
.map-filters .filter { display: flex; flex-direction: column; gap: 4px; }
.map-filters label { font-size: .78rem; font-weight: 600; color: var(--color-muted); }
.map-filters select, .map-filters input {
    padding: .5em .7em; border: 1px solid var(--color-border);
    border-radius: var(--radius-sm); font: inherit; background: #fff;
}
.map-filters .filter-check { flex-direction: row; align-items: center; gap: 6px; padding-bottom: 6px; }
.map-filters .filter-check label { font-size: .9rem; color: var(--color-text); }
.map-status { margin-left: auto; align-self: center; font-size: .85rem; color: var(--color-muted); }

/* Legend */
.map-legend {
    position: absolute; bottom: 16px; left: 16px; z-index: 5;
    background: rgba(255,255,255,.94); border: 1px solid var(--color-border);
    border-radius: var(--radius-sm); padding: 10px 12px; box-shadow: var(--shadow);
    font-size: .8rem;
}
.map-legend .row { display: flex; align-items: center; gap: 8px; margin: 3px 0; }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.15); }
.dot-green  { background: #16a34a; }
.dot-blue   { background: #2563eb; }
.dot-yellow { background: #d97706; }
.dot-gray   { background: #6b7280; }

/* Custom markers */
.hb-marker {
    width: 16px; height: 16px; border-radius: 50%; border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,.4); cursor: pointer;
}
.hb-marker.has-photo { width: 20px; height: 20px; }
.hb-marker.status-verified  { background: #16a34a; }
.hb-marker.status-community  { background: #2563eb; }
.hb-marker.status-probable   { background: #d97706; }
.hb-marker.status-rejected, .hb-marker.status-historical { background: #6b7280; }

/* Cluster bubbles */
.hb-cluster {
    display: flex; align-items: center; justify-content: center;
    background: rgba(15,118,110,.92); color: #fff; font-weight: 700;
    border-radius: 50%; border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.35);
    cursor: pointer;
}

/* Popup / detail card (shared between desktop popup and mobile sheet) */
.sighting-card { font-family: var(--font); max-width: 260px; }
.sighting-card .sc-species { font-weight: 800; font-size: 1.05rem; margin: 0 0 2px; }
.sighting-card .sc-meta { color: var(--color-muted); font-size: .85rem; margin: 0 0 8px; }
.sighting-card .sc-thumb { width: 100%; height: 130px; object-fit: cover; border-radius: 8px; margin-bottom: 8px; background: #eef2f0; }
.sighting-card .sc-notes { font-size: .9rem; margin: 6px 0; }
.sighting-card .sc-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.sighting-card .sc-actions a, .sighting-card .sc-actions button {
    font-size: .82rem; padding: .4em .7em; border-radius: 6px; border: 1px solid var(--color-border);
    background: #fff; cursor: pointer; color: var(--color-text); text-decoration: none;
}
.sighting-card .sc-actions .primary { background: var(--color-primary); color: #fff; border-color: transparent; }

/* Mobile bottom sheet */
.sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
    background: #fff; border-radius: 16px 16px 0 0; box-shadow: var(--shadow-lg);
    transform: translateY(110%); transition: transform .25s ease; padding: 16px 16px 24px;
    max-height: 70vh; overflow-y: auto;
}
.sheet.open { transform: translateY(0); }
.sheet .sheet-close { position: absolute; top: 10px; right: 12px; background: none; border: 0; font-size: 1.4rem; cursor: pointer; }

/* Migration timeline control */
.timeline {
    position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
    z-index: 6; background: rgba(255,255,255,.96); border: 1px solid var(--color-border);
    border-radius: 999px; padding: 8px 14px; display: flex; align-items: center; gap: 12px;
    box-shadow: var(--shadow); width: min(560px, calc(100% - 32px));
}
.timeline input[type=range] { flex: 1; }
.timeline .tl-play { border: 0; background: var(--color-primary); color: #fff; border-radius: 50%; width: 34px; height: 34px; cursor: pointer; font-size: 1rem; }
.timeline .tl-date { font-size: .82rem; font-weight: 600; min-width: 84px; text-align: center; }

@media (max-width: 820px) {
    #map, .map-canvas { height: 62vh; }
    .map-legend { font-size: .72rem; bottom: 84px; }
}

/* ============================================================
   Bespoke page chrome (map / near-me / migration / sighting)
   Appended last so these rules win over the shared rules above.
   NOTE: the 128px below matches .header-inner in style.css —
   keep the two in sync if the header height changes.
   ============================================================ */

/* ---------- Live map screen (map.php) ----------
   (flex layout for .map-full lives with the base map rules above) */
.map-topbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px 24px; flex-wrap: wrap; padding: 14px 20px;
    background: var(--color-surface); border-bottom: 1px solid var(--color-border);
}
.map-topbar .mt-title { display: flex; align-items: center; gap: 12px; }
.map-topbar h1 { font-size: 1.2rem; margin: 0; letter-spacing: -.02em; }
.map-topbar .mt-sub { font-size: .82rem; color: var(--color-muted); margin: 2px 0 0; }
.map-topbar .mt-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.live-dot {
    width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto;
    background: var(--color-primary); animation: livePulse 2.2s infinite;
}
@keyframes livePulse {
    0%   { box-shadow: 0 0 0 0 rgba(11,139,79,.5); }
    70%  { box-shadow: 0 0 0 9px rgba(11,139,79,0); }
    100% { box-shadow: 0 0 0 0 rgba(11,139,79,0); }
}
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }

/* ---------- Near Me (near-me.php) ---------- */
.nm-layout {
    display: grid; grid-template-columns: minmax(0, 1fr) 340px;
    gap: 24px; align-items: start; margin-top: 24px;
}
.nm-main { min-width: 0; }
.nm-controls {
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
    margin-bottom: 14px; padding: 12px 16px; background: var(--color-surface);
    border: 1px solid var(--color-border); border-radius: var(--radius);
}
.nm-controls .filter { display: flex; flex-direction: column; gap: 4px; }
.nm-controls label { font-size: .78rem; font-weight: 600; color: var(--color-muted); }
.nm-controls select {
    padding: .5em .7em; border: 1px solid var(--color-border);
    border-radius: var(--radius-sm); font: inherit; background: #fff;
}
/* #map-qualified so it beats the base `#map { height:70vh }` rule (ID specificity). */
#map.nm-map { height: 440px; min-height: 0; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.nm-side h2 { font-size: 1.15rem; margin: 0 0 12px; }
.nm-side .sighting-list { max-height: 452px; overflow-y: auto; padding-right: 4px; }
@media (max-width: 900px) {
    .nm-layout { grid-template-columns: 1fr; }
    #map.nm-map { height: 340px; }
    .nm-side .sighting-list { max-height: none; }
}

/* ---------- Sighting detail (sighting.php) ---------- */
.detail-head { margin-bottom: 16px; }
.detail-head h1 { margin: 0 0 8px; }
.detail-sub { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0; font-size: .92rem; }
.sighting-hero-photo {
    width: 100%; max-height: 420px; object-fit: cover;
    border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 24px;
}
.detail-main { min-width: 0; }
/* #map-qualified so it beats the base `#map { height:70vh }` rule (ID specificity). */
#map.detail-map { height: 320px; min-height: 0; border-radius: var(--radius-sm); overflow: hidden; }
.detail-meta { list-style: none; margin: 0; padding: 0; }
.detail-meta li {
    display: flex; justify-content: space-between; gap: 16px;
    padding: 9px 0; border-bottom: 1px solid var(--color-border); font-size: 14px;
}
.detail-meta li:last-child { border-bottom: 0; }
.detail-meta li > span:first-child { color: var(--color-muted); flex: 0 0 auto; }
.detail-meta li > span:last-child { font-weight: 600; text-align: right; }
