/* ============================================================
   OrokoLand Interactive Map Plugin — olmap.css v1.3.0
   OCA-USA | stage.orokousa.org
   
   Font sizes use clamp(min, fluid-vw, max) throughout so text
   scales fluidly from mobile (~320px) to large desktop.
   Formula: fluid = (desktop_px / 1200) * 100vw  ≈ proportional
   ============================================================ */

/* ── Base Reset ──────────────────────────────────────────── */
.olmap-wrapper * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.olmap-wrapper {
    font-family: 'Georgia', 'Times New Roman', serif;
    color: #2c1810;
    background: #faf7f2;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 32px rgba(0,0,0,0.12);
    margin: 2rem 0;
    /* Base font: scales from 13px (mobile) → 16px (desktop) */
    font-size: clamp(13px, 1.3vw, 16px);
}

/* ── Stats Bar ───────────────────────────────────────────── */
.olmap-stats-bar {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: linear-gradient(135deg, #2c1810 0%, #5c3317 50%, #2c1810 100%);
    padding: clamp(8px, 1.2vw, 14px) clamp(10px, 1.5vw, 20px);
    gap: 4px;
    flex-wrap: wrap;
}

.olmap-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px clamp(6px, 1vw, 12px);
    border-right: 1px solid rgba(255,255,255,0.15);
}
.olmap-stat:last-child { border-right: none; }

.olmap-stat-num {
    /* Scales from 15px (320px viewport) up to 22px (desktop) */
    font-size: clamp(15px, 1.85vw, 22px);
    font-weight: 700;
    color: #f5d08a;
    line-height: 1.1;
}
.olmap-stat-lbl {
    /* Scales from 9px → 11px */
    font-size: clamp(9px, 0.95vw, 11px);
    color: rgba(255,255,255,0.65);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-family: Arial, sans-serif;
    margin-top: 2px;
}

/* ── Map Header ──────────────────────────────────────────── */
.olmap-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: clamp(10px, 1.3vw, 16px) clamp(12px, 1.6vw, 20px) clamp(8px, 1vw, 12px);
    background: #fff;
    border-bottom: 2px solid #e8d5b7;
    flex-wrap: wrap;
    gap: 10px;
}

.olmap-title {
    /* Scales from 15px → 19px */
    font-size: clamp(15px, 1.6vw, 19px);
    color: #2c1810;
    font-weight: 700;
}
.olmap-subtitle {
    /* Scales from 10px → 12px */
    font-size: clamp(10px, 1vw, 12px);
    color: #7a5c3a;
    font-family: Arial, sans-serif;
    margin-top: 2px;
}

.olmap-controls {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.olmap-ctrl-btn {
    background: #f5f0e8;
    border: 1px solid #c8a96a;
    color: #5c3317;
    padding: clamp(4px, 0.5vw, 6px) clamp(8px, 1vw, 12px);
    border-radius: 20px;
    /* Scales from 10px → 12px */
    font-size: clamp(10px, 1vw, 12px);
    font-family: Arial, sans-serif;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.olmap-ctrl-btn:hover,
.olmap-ctrl-btn.active {
    background: #5c3317;
    color: #f5d08a;
    border-color: #5c3317;
}
.olmap-ctrl-reset {
    background: #fff0e0;
    border-color: #e07b39;
    color: #c0521a;
}
.olmap-ctrl-reset:hover {
    background: #c0521a;
    color: #fff;
    border-color: #c0521a;
}

/* ── Main Layout ─────────────────────────────────────────── */
.olmap-main {
    display: flex;
    position: relative;
}

.olmap-map-col {
    flex: 1 1 60%;
    position: relative;
    min-width: 0;
}

.olmap-map-container {
    width: 100%;
    background: #d4e8f0;
}

/* ── Leaflet Map Overrides ───────────────────────────────── */
.olmap-map-container .leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    font-family: Arial, sans-serif;
}
.olmap-map-container .leaflet-popup-content {
    /* Scales from 11px → 13px */
    font-size: clamp(11px, 1.1vw, 13px);
    line-height: 1.5;
}
.olmap-popup-name {
    font-size: clamp(12px, 1.25vw, 15px);
    font-weight: 700;
    color: #2c1810;
    margin-bottom: 4px;
}
.olmap-popup-dialect {
    font-size: clamp(10px, 1vw, 12px);
    color: #7a5c3a;
    margin-bottom: 4px;
}
.olmap-popup-villages {
    font-size: clamp(10px, 1vw, 12px);
    color: #5c3317;
    font-weight: 600;
}
.olmap-popup-btn {
    display: inline-block;
    margin-top: 8px;
    background: #5c3317;
    color: #f5d08a !important;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: clamp(10px, 0.95vw, 11px);
    text-decoration: none;
    font-weight: 600;
}
.olmap-popup-btn:hover { background: #3d1f0a; }

/* ── Legend ──────────────────────────────────────────────── */
.olmap-legend {
    position: absolute;
    bottom: 16px;
    left: 16px;
    background: rgba(255,255,255,0.95);
    border: 1px solid #e8d5b7;
    border-radius: 8px;
    padding: clamp(6px, 0.8vw, 10px) clamp(8px, 1.1vw, 14px);
    z-index: 1000;
    font-family: Arial, sans-serif;
    /* Scales from 9px → 11px */
    font-size: clamp(9px, 0.95vw, 11px);
    min-width: 120px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.olmap-legend-title {
    font-weight: 700;
    font-size: clamp(10px, 1vw, 12px);
    color: #2c1810;
    margin-bottom: 8px;
    border-bottom: 1px solid #e8d5b7;
    padding-bottom: 4px;
}
.olmap-legend-row {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 5px;
    color: #5c3317;
}
.olmap-legend-dot {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
}
.olmap-legend-marker { font-size: 13px; line-height: 1; }

/* ── Info Panel ──────────────────────────────────────────── */
.olmap-info-col {
    width: clamp(240px, 26vw, 320px);
    flex-shrink: 0;
    background: #fff;
    border-left: 2px solid #e8d5b7;
    overflow-y: auto;
    padding: clamp(12px, 1.5vw, 20px) clamp(10px, 1.4vw, 18px);
    font-family: Arial, sans-serif;
}

.olmap-panel-default { text-align: center; }
.olmap-panel-icon {
    font-size: clamp(32px, 4vw, 48px);
    margin-bottom: 12px;
}
.olmap-panel-default h3 {
    font-size: clamp(14px, 1.4vw, 17px);
    color: #2c1810;
    margin-bottom: 10px;
    font-family: Georgia, serif;
}
.olmap-panel-default p {
    font-size: clamp(11px, 1.1vw, 13px);
    color: #666;
    line-height: 1.6;
    margin-bottom: 16px;
}
.olmap-panel-hint {
    background: #fdf6ec;
    border: 1px solid #e8d5b7;
    border-radius: 8px;
    padding: clamp(8px, 1vw, 12px) clamp(10px, 1.1vw, 14px);
    font-size: clamp(11px, 1vw, 12px);
    color: #5c3317;
    line-height: 1.6;
    text-align: left;
    margin-bottom: 16px;
}
.olmap-division-legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.olmap-div-badge {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: clamp(6px, 0.7vw, 8px) clamp(8px, 1vw, 12px);
    border-radius: 6px;
    font-size: clamp(11px, 1.1vw, 12px);
    font-weight: 600;
}
.olmap-div-badge.ndian  { background: #e8f4e8; color: #1B4332; border: 1px solid #40916C; }
.olmap-div-badge.meme   { background: #fce8e0; color: #7a1e00; border: 1px solid #D8572A; }
.olmap-div-badge.both   { background: #f0eeff; color: #3c2270; border: 1px solid #7c3aed; }
.olmap-div-badge span   { font-weight: 400; font-size: clamp(10px, 0.95vw, 11px); }

/* Detail Panel */
.olmap-back-btn {
    background: none;
    border: none;
    color: #7a5c3a;
    font-size: clamp(10px, 1vw, 12px);
    cursor: pointer;
    padding: 0 0 12px 0;
    display: block;
    font-family: Arial, sans-serif;
    text-decoration: underline;
}
.olmap-back-btn:hover { color: #2c1810; }

.olmap-clan-badge {
    width: clamp(36px, 4vw, 48px);
    height: clamp(36px, 4vw, 48px);
    border-radius: 50%;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(16px, 1.8vw, 22px);
}
.olmap-detail-name {
    font-size: clamp(16px, 1.8vw, 22px);
    color: #2c1810;
    margin-bottom: 4px;
    font-family: Georgia, serif;
}
.olmap-detail-trait {
    font-size: clamp(10px, 1vw, 12px);
    color: #7a5c3a;
    font-style: italic;
    margin-bottom: 14px;
}
.olmap-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 14px;
}
.olmap-detail-item {
    background: #faf7f2;
    border: 1px solid #e8d5b7;
    border-radius: 6px;
    padding: clamp(6px, 0.7vw, 8px) clamp(7px, 0.8vw, 10px);
}
.olmap-detail-lbl {
    display: block;
    font-size: clamp(9px, 0.85vw, 10px);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9a7a55;
    margin-bottom: 2px;
}
.olmap-detail-val {
    display: block;
    font-size: clamp(11px, 1.1vw, 13px);
    color: #2c1810;
    font-weight: 600;
}
.olmap-detail-desc {
    font-size: clamp(11px, 1.1vw, 12.5px);
    color: #4a3520;
    line-height: 1.7;
    margin-bottom: 14px;
}
.olmap-villages-section h4 {
    font-size: clamp(10px, 1vw, 12px);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #7a5c3a;
    margin-bottom: 8px;
}
.olmap-village-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 16px;
}
.olmap-village-tag {
    background: #f0e8d8;
    border: 1px solid #c8a96a;
    color: #5c3317;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: clamp(10px, 0.95vw, 11px);
}
.olmap-profile-link {
    display: block;
    background: #5c3317;
    color: #f5d08a !important;
    text-align: center;
    padding: clamp(7px, 0.8vw, 10px);
    border-radius: 8px;
    font-size: clamp(11px, 1.1vw, 13px);
    font-weight: 600;
    text-decoration: none !important;
    transition: background 0.2s;
}
.olmap-profile-link:hover { background: #3d1f0a; }

/* ── Clan Cards Grid ─────────────────────────────────────── */
.olmap-cards-section {
    padding: clamp(12px, 1.5vw, 20px);
    background: #f5f0e8;
    border-top: 2px solid #e8d5b7;
}
.olmap-cards-title {
    /* Scales from 13px → 16px */
    font-size: clamp(13px, 1.35vw, 16px);
    color: #2c1810;
    margin-bottom: 14px;
    font-family: Georgia, serif;
    text-align: center;
}
.olmap-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(clamp(140px, 18vw, 200px), 1fr));
    gap: clamp(6px, 0.8vw, 10px);
}
.olmap-card {
    background: #fff;
    border: 1px solid #e8d5b7;
    border-radius: 8px;
    padding: clamp(8px, 1vw, 12px) clamp(10px, 1.1vw, 14px);
    cursor: pointer;
    transition: all 0.2s;
    border-left: 4px solid transparent;
}
.olmap-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}
.olmap-card.active {
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    transform: translateY(-2px);
}
.olmap-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.olmap-card-icon {
    font-size: clamp(14px, 1.5vw, 18px);
}
.olmap-card-name {
    /* Scales from 11px → 13px */
    font-size: clamp(11px, 1.1vw, 13px);
    font-weight: 700;
    color: #2c1810;
    font-family: Georgia, serif;
}
.olmap-card-dialect {
    /* Scales from 9px → 11px */
    font-size: clamp(9px, 0.95vw, 11px);
    color: #9a7a55;
    margin-bottom: 4px;
    font-style: italic;
}
.olmap-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.olmap-card-villages {
    /* Scales from 10px → 11px */
    font-size: clamp(10px, 0.95vw, 11px);
    font-weight: 700;
    color: #5c3317;
}
.olmap-card-div {
    font-size: clamp(9px, 0.9vw, 10px);
    padding: 2px 6px;
    border-radius: 8px;
    font-weight: 600;
}
.olmap-card-div.ndian { background: #e8f4e8; color: #1B4332; }
.olmap-card-div.meme  { background: #fce8e0; color: #7a1e00; }
.olmap-card-div.both  { background: #f0eeff; color: #3c2270; }

/* ── Mobile Layout ───────────────────────────────────────── */
/* clamp() handles font scaling — breakpoints handle LAYOUT only */
@media (max-width: 768px) {
    .olmap-main {
        flex-direction: column;
    }
    .olmap-info-col {
        width: 100%;
        border-left: none;
        border-top: 2px solid #e8d5b7;
        max-height: 440px;
    }
    .olmap-map-container {
        height: 360px !important;
    }
    .olmap-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .olmap-controls {
        width: 100%;
    }
    .olmap-legend {
        bottom: 8px;
        left: 8px;
    }
    /* On mobile, stats wrap into 2 rows — reduce padding to fit */
    .olmap-stat {
        padding: 4px 8px;
    }
}

@media (max-width: 480px) {
    .olmap-stats-bar {
        justify-content: flex-start;
    }
    /* Ensure cards never go below 2-col on small phones */
    .olmap-cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    /* Panel detail grid: single column on tiny screens */
    .olmap-detail-grid {
        grid-template-columns: 1fr;
    }
}
