/* ============================================================
   Istwanou Geoindex — Map Styles
   Version: 1.0.0
   ============================================================ */

:root {
    --igeo-bg-dark: #1a1a1a;
    --igeo-bg-panel: #242424;
    --igeo-bg-card: #2e2e2e;
    --igeo-text: #e8e0d4;
    --igeo-text-sec: #a89f94;
    --igeo-text-muted: #6d655c;
    --igeo-gold: #c9a94e;
    --igeo-red: #a63d40;
    --igeo-blue: #457b9d;
    --igeo-border: #3a3630;
}

/* ── Full-width breakout ──────────────────────────────────
   Forces the map to span the entire viewport regardless of
   whatever max-width container the theme wraps content in.
   Works with Istwanou, Kadence, GeneratePress, Astra, etc.
   ──────────────────────────────────────────────────────── */
.istwanou-geoindex-wrap {
    font-family: 'Source Sans 3', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--igeo-text);
    background: var(--igeo-bg-dark);
    overflow: hidden;

    /* Break out of any parent max-width container */
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;

    /* No rounded corners or border at full width — cleaner */
    border-radius: 0;
    border: none;
    border-top: 1px solid var(--igeo-border);
    border-bottom: 1px solid var(--igeo-border);
}

/* Header */
.igeo-header {
    background: linear-gradient(180deg, #2a2520 0%, #1e1b18 100%);
    border-bottom: 1px solid var(--igeo-border);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}
.igeo-title {
    font-family: 'Playfair Display', 'Georgia', serif;
    font-size: 20px;
    color: var(--igeo-gold);
    margin: 0;
    letter-spacing: 0.5px;
}
.igeo-subtitle {
    font-size: 11px;
    color: var(--igeo-text-muted);
    letter-spacing: 2px;
    text-transform: uppercase;
}
.igeo-stats {
    display: flex;
    gap: 18px;
    font-size: 13px;
    color: var(--igeo-text-sec);
}
.igeo-stats strong {
    color: var(--igeo-gold);
    font-weight: 600;
}

/* Body layout — fills available viewport height */
.igeo-body {
    display: flex;
    overflow: hidden;
    /* Default height; overridden by shortcode attr or this calc.
       Subtract ~160px for WP admin bar + theme header + igeo header. */
    height: calc(100vh - 160px);
    min-height: 500px;
}

/* Sidebar */
.igeo-sidebar {
    width: 300px;
    background: var(--igeo-bg-panel);
    border-right: 1px solid var(--igeo-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.igeo-filter-section {
    padding: 12px 14px;
    border-bottom: 1px solid var(--igeo-border);
}
.igeo-filter-section h3 {
    font-family: 'Playfair Display', serif;
    font-size: 11px;
    color: var(--igeo-gold);
    margin: 0 0 8px;
    letter-spacing: 1px;
    text-transform: uppercase;
}
.igeo-filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.igeo-filter-btn {
    background: var(--igeo-bg-card);
    border: 1px solid var(--igeo-border);
    color: var(--igeo-text-sec);
    font-size: 11px;
    padding: 3px 9px;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    line-height: 1.4;
}
.igeo-filter-btn:hover {
    border-color: var(--igeo-gold);
    color: var(--igeo-text);
}
.igeo-filter-btn.active {
    background: var(--igeo-gold);
    color: #1a1a1a;
    border-color: var(--igeo-gold);
    font-weight: 600;
}

/* Search */
.igeo-search-box {
    padding: 10px 14px;
    border-bottom: 1px solid var(--igeo-border);
}
.igeo-search-box input {
    width: 100%;
    background: var(--igeo-bg-card);
    border: 1px solid var(--igeo-border);
    color: var(--igeo-text);
    padding: 7px 10px;
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
}
.igeo-search-box input::placeholder { color: var(--igeo-text-muted); }
.igeo-search-box input:focus { border-color: var(--igeo-gold); }

/* Location list */
.igeo-location-list {
    flex: 1;
    overflow-y: auto;
}
.igeo-location-list::-webkit-scrollbar { width: 5px; }
.igeo-location-list::-webkit-scrollbar-track { background: var(--igeo-bg-panel); }
.igeo-location-list::-webkit-scrollbar-thumb { background: var(--igeo-border); border-radius: 3px; }

.igeo-loc-item {
    padding: 9px 14px;
    cursor: pointer;
    border-bottom: 1px solid rgba(58,54,48,0.35);
    transition: background 0.15s;
}
.igeo-loc-item:hover { background: rgba(201,169,78,0.07); }
.igeo-loc-item.selected { background: rgba(201,169,78,0.14); border-left: 3px solid var(--igeo-gold); }
.igeo-loc-item .igeo-loc-name {
    font-family: 'Playfair Display', serif;
    font-size: 14px;
    color: var(--igeo-text);
    margin-bottom: 2px;
}
.igeo-loc-item .igeo-loc-meta {
    font-size: 11px;
    color: var(--igeo-text-muted);
    display: flex;
    gap: 10px;
}
.igeo-loc-item .igeo-loc-count {
    color: var(--igeo-gold);
    font-weight: 600;
}
.igeo-period-dots {
    display: flex;
    gap: 3px;
    margin-top: 3px;
}
.igeo-period-dot {
    width: 8px;
    height: 4px;
    border-radius: 1px;
    display: inline-block;
}

/* Map */
.igeo-map-container {
    flex: 1;
    position: relative;
    min-width: 0;
}
#igeo-map {
    width: 100%;
    height: 100%;
    background: #1a1a1a;
}

/* Leaflet popup overrides */
.istwanou-geoindex-wrap .leaflet-popup-content-wrapper {
    background: var(--igeo-bg-panel) !important;
    color: var(--igeo-text) !important;
    border: 1px solid var(--igeo-border) !important;
    border-radius: 6px !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5) !important;
}
.istwanou-geoindex-wrap .leaflet-popup-tip { background: var(--igeo-bg-panel) !important; }
.istwanou-geoindex-wrap .leaflet-popup-content { margin: 0 !important; padding: 0 !important; }
.istwanou-geoindex-wrap .leaflet-popup-close-button { color: var(--igeo-text-muted) !important; font-size: 18px !important; }
.istwanou-geoindex-wrap .leaflet-popup-close-button:hover { color: var(--igeo-gold) !important; }
.istwanou-geoindex-wrap .leaflet-control-attribution { display: none !important; }

/* Popup content */
.igeo-popup {
    padding: 14px;
    max-width: 340px;
    max-height: 380px;
    overflow-y: auto;
}
.igeo-popup::-webkit-scrollbar { width: 4px; }
.igeo-popup::-webkit-scrollbar-thumb { background: var(--igeo-border); border-radius: 2px; }
.igeo-popup h3 {
    font-family: 'Playfair Display', serif;
    color: var(--igeo-gold);
    font-size: 17px;
    margin: 0 0 4px;
}
.igeo-popup .igeo-popup-coords {
    font-size: 11px;
    color: var(--igeo-text-muted);
    margin-bottom: 2px;
    font-variant-numeric: tabular-nums;
}
.igeo-popup .igeo-popup-context {
    font-size: 12px;
    color: var(--igeo-text-sec);
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--igeo-border);
}
.igeo-popup .igeo-entry-list {
    /* No top border needed — context line handles the divider */
}
/* Interactive entry rows inside popup */
.igeo-entry-row {
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid rgba(58,54,48,0.2);
}
.igeo-entry-row:last-child { border-bottom: none; }
.igeo-entry-row:hover,
.igeo-entry-row.igeo-entry-row-active {
    background: rgba(201,169,78,0.12);
}
.igeo-entry-row-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.igeo-entry-num {
    font-size: 11px;
    font-weight: 700;
    color: var(--igeo-gold);
    font-variant-numeric: tabular-nums;
}
.igeo-entry-date {
    font-size: 10px;
    color: var(--igeo-text-muted);
    white-space: nowrap;
}
.igeo-entry-title {
    font-size: 11px;
    color: var(--igeo-text-sec);
    margin-top: 1px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.igeo-entry-more {
    text-align: center;
    color: var(--igeo-gold);
    font-size: 12px;
    font-weight: 600;
    padding: 8px;
    cursor: default;
}

/* ── Floating tooltip (progressive disclosure) ────────── */
.igeo-tooltip {
    position: fixed;
    z-index: 10000;
    background: #1e1b18;
    border: 1px solid var(--igeo-border, #3a3630);
    border-left: 3px solid #c9a94e;
    border-radius: 6px;
    padding: 14px 16px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.6), 0 2px 8px rgba(0,0,0,0.3);
    pointer-events: auto;
    cursor: default;
    font-family: 'Source Sans 3', -apple-system, sans-serif;
    max-width: 360px;
    animation: igeo-tt-in 0.15s ease-out;
}
@keyframes igeo-tt-in {
    from { opacity: 0; transform: translateX(-6px); }
    to   { opacity: 1; transform: translateX(0); }
}
.igeo-tt-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.igeo-tt-num {
    font-size: 13px;
    font-weight: 700;
    color: #c9a94e;
    font-variant-numeric: tabular-nums;
}
.igeo-tt-date {
    font-size: 11px;
    color: #6d655c;
}
.igeo-tt-title {
    font-family: 'Playfair Display', 'Georgia', serif;
    font-size: 14px;
    color: #e8e0d4;
    line-height: 1.35;
    margin-bottom: 8px;
}
.igeo-tt-preview {
    font-size: 12px;
    color: #a89f94;
    line-height: 1.5;
    margin-bottom: 0;
}

/* Legend */
.igeo-legend {
    position: absolute;
    bottom: 16px;
    right: 16px;
    background: rgba(36,36,36,0.92);
    border: 1px solid var(--igeo-border);
    border-radius: 6px;
    padding: 10px 14px;
    z-index: 800;
    backdrop-filter: blur(8px);
}
.igeo-legend h4 {
    font-family: 'Playfair Display', serif;
    font-size: 10px;
    color: var(--igeo-gold);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0 0 6px;
}
.igeo-legend-item {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 11px;
    color: var(--igeo-text-sec);
    padding: 1px 0;
}
.igeo-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Responsive */
@media (max-width: 768px) {
    .igeo-body { flex-direction: column; height: calc(100vh - 120px); }
    .igeo-sidebar { width: 100%; max-height: 180px; flex-direction: row; flex-wrap: wrap; overflow-y: auto; }
    .igeo-filter-section { flex: 1; min-width: 140px; }
    .igeo-location-list { display: none; }
    .igeo-header { padding: 10px 16px; }
    .igeo-title { font-size: 17px; }
    .igeo-legend { display: none; }

    /* Tooltip becomes a bottom sheet on mobile */
    .igeo-tooltip {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 14px 14px 0 0;
        border-left: none;
        border-top: 3px solid #c9a94e;
        padding: 18px 20px 24px;
        max-height: 55vh;
        overflow-y: auto;
        animation: igeo-tt-in-mobile 0.2s ease-out;
        box-shadow: 0 -8px 40px rgba(0,0,0,0.6);
    }
    @keyframes igeo-tt-in-mobile {
        from { opacity: 0; transform: translateY(40px); }
        to   { opacity: 1; transform: translateY(0); }
    }
    .igeo-tooltip .igeo-tt-title {
        font-size: 16px;
        margin-bottom: 10px;
    }
    .igeo-tooltip .igeo-tt-preview {
        font-size: 14px;
        line-height: 1.55;
    }
    .igeo-tooltip .igeo-tt-num {
        font-size: 14px;
    }
    .igeo-tooltip .igeo-tt-date {
        font-size: 12px;
    }

    /* Add a drag handle indicator at top of bottom sheet */
    .igeo-tooltip::before {
        content: '';
        display: block;
        width: 36px;
        height: 4px;
        background: rgba(255,255,255,0.2);
        border-radius: 2px;
        margin: 0 auto 14px;
    }
}

/* ── Theme container overrides ────────────────────────────
   Nuclear specificity to ensure no theme max-width, padding,
   or margin constrains the map. Add selectors as needed.
   ──────────────────────────────────────────────────────── */
.entry-content .istwanou-geoindex-wrap,
.post-content .istwanou-geoindex-wrap,
.page-content .istwanou-geoindex-wrap,
.wp-block-post-content .istwanou-geoindex-wrap,
.site-content .istwanou-geoindex-wrap,
article .istwanou-geoindex-wrap,
main .istwanou-geoindex-wrap,
.content-area .istwanou-geoindex-wrap {
    width: 100vw !important;
    max-width: none !important;
    margin-left: -50vw !important;
    margin-right: -50vw !important;
    position: relative !important;
    left: 50% !important;
    right: 50% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* Hide the page title when the geoindex is displayed —
   the plugin has its own header bar. Opt-in via body class
   or hide the WP-generated title above the shortcode. */
.page-template-default .entry-header:has(+ .entry-content .istwanou-geoindex-wrap),
.page .entry-title:has(~ .entry-content .istwanou-geoindex-wrap) {
    display: none;
}
