/* ========================================
   ReiseRadar — Premium UI
   ======================================== */

:root {
    --font-ui: "SF Pro Display", "SF Pro Text", "Helvetica Neue", "Segoe UI", sans-serif;
    --bg-ocean: #dce6ec;
    --bg-ocean-deep: #c9d6de;
    --panel-bg: rgba(255, 255, 255, 0.72);
    --panel-bg-strong: rgba(255, 255, 255, 0.84);
    --panel-stroke: rgba(255, 255, 255, 0.65);
    --panel-shadow: 0 14px 40px rgba(69, 96, 117, 0.16);
    --text-primary: #1f2a33;
    --text-secondary: #4a5966;
    --text-tertiary: #8a98a4;
    --accent: #4c89a8;
    --accent-soft: rgba(76, 137, 168, 0.16);
    --safe: #7fcfa8;
    --partial: #f2b37d;
    --warning: #e98e8a;
    --notice: #f2d68c;
    --home: #a9c5d8;
    --unknown: #e7ecef;
    --radius-lg: 24px;
    --radius-md: 18px;
    --radius-sm: 14px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
}

body {
    font-family: var(--font-ui);
    color: var(--text-primary);
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.8), transparent 36%),
        linear-gradient(180deg, #edf4f7 0%, #d7e2e8 100%);
    overflow: hidden;
}

.glass-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-stroke);
    box-shadow: var(--panel-shadow);
    backdrop-filter: blur(20px) saturate(1.2);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
}

#loading-overlay {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at top, rgba(255, 255, 255, 0.7), transparent 30%),
        linear-gradient(180deg, #edf4f7 0%, #d7e2e8 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.45s ease;
}

#loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(76, 137, 168, 0.12);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    margin-top: 14px;
    color: var(--text-secondary);
    font-size: 14px;
    letter-spacing: 0.01em;
}

#map,
.map-atmosphere,
.app-shell {
    position: fixed;
    inset: 0;
}

#map {
    background: linear-gradient(180deg, var(--bg-ocean) 0%, var(--bg-ocean-deep) 100%);
}

.map-atmosphere {
    pointer-events: none;
    z-index: 360;
    background:
        radial-gradient(circle at top center, rgba(255, 255, 255, 0.26), transparent 28%),
        radial-gradient(circle at left center, rgba(255, 255, 255, 0.16), transparent 24%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0));
}

.app-shell {
    z-index: 500;
    pointer-events: none;
}

.tutorial-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
}

.tutorial-blur-panes {
    position: absolute;
    inset: 0;
}

.tutorial-blur-pane {
    position: absolute;
    background: rgba(220, 230, 236, 0.36);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.tutorial-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(220, 230, 236, 0.18);
    pointer-events: none;
    z-index: 1;
}

.tutorial-demo-country {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.tutorial-highlight {
    position: fixed;
    border-radius: 24px;
    border: 2px solid rgba(76, 137, 168, 0.42);
    box-shadow:
        0 0 0 9999px rgba(220, 230, 236, 0.18),
        0 16px 30px rgba(76, 137, 168, 0.18);
    background: rgba(255, 255, 255, 0.08);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 2;
}

.tutorial-highlight.is-visible {
    opacity: 1;
}

.tutorial-card {
    position: fixed;
    width: min(360px, calc(100vw - 24px));
    padding: 18px 18px 16px;
    border-radius: 24px;
    pointer-events: auto;
    z-index: 3;
}

.tutorial-target-active {
    position: relative;
    z-index: 1250 !important;
}

.tutorial-card__eyebrow {
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(74, 89, 102, 0.78);
}

.tutorial-card__title {
    margin-top: 8px;
    font-size: 26px;
    line-height: 1.05;
    letter-spacing: -0.04em;
}

.tutorial-card__text {
    margin-top: 10px;
    font-size: 14px;
    line-height: 1.65;
    color: var(--text-secondary);
}

.tutorial-card__actions {
    margin-top: 16px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.tutorial-card__primary,
.tutorial-card__secondary {
    border: none;
    border-radius: 999px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease;
}

.tutorial-card__primary {
    background: rgba(76, 137, 168, 0.16);
    color: var(--accent);
}

.tutorial-card__secondary {
    background: rgba(255, 255, 255, 0.56);
    color: var(--text-secondary);
}

.tutorial-card__primary:hover,
.tutorial-card__secondary:hover {
    transform: translateY(-1px);
}

.tutorial-card__secondary[disabled] {
    opacity: 0.45;
    cursor: default;
    transform: none;
}

.tutorial-card__secondary[hidden] {
    display: none;
}

.hero-panel {
    pointer-events: auto;
}

.hero-panel {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: min(560px, calc(100vw - 32px));
    padding: 14px 18px 16px;
    border-radius: 26px;
    text-align: center;
}

.hero-panel__eyebrow,
.detail-panel__eyebrow,
.section-label,
.info-control__eyebrow {
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

.hero-panel__title {
    margin-top: 6px;
    font-size: 24px;
    line-height: 1.1;
    font-weight: 600;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}

.hero-panel__meta {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Hidden on desktop, shown on mobile via media query */
.hero-panel__attribution {
    display: none;
}

/* Hidden on desktop, shown on mobile via media query */
.detail-panel__attribution {
    display: none;
    position: absolute;
    top: 12px;
    right: 40px; /* left of close button */
    font-size: 9px;
    color: var(--text-tertiary);
    opacity: 0.6;
}

.stats-bar {
    margin-top: 14px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.58);
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
}

.stat-pill__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.45);
}

.stat-pill--green .stat-pill__dot { background: var(--safe); }
.stat-pill--orange .stat-pill__dot { background: var(--partial); }
.stat-pill--red .stat-pill__dot { background: var(--warning); }

.detail-panel__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    position: relative;
}

.detail-panel__title-wrap {
    min-width: 0;
}

.detail-panel__title {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 30px;
    line-height: 1.02;
    letter-spacing: -0.04em;
    word-break: break-word;
}

.detail-panel__flag,
.info-control__flag,
.search-result-flag {
    flex-shrink: 0;
}

.detail-panel__flag {
    font-size: 26px;
    line-height: 1;
}

.detail-panel__status-row {
    margin-top: 18px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.detail-panel__summary {
    margin-top: 14px;
    font-size: 14px;
    line-height: 1.65;
    color: var(--text-secondary);
}

.detail-sections-shell {
    margin-top: 18px;
    padding: 12px;
    border-radius: 22px;
    background: rgba(245, 248, 251, 0.82);
    border: 1px solid rgba(214, 223, 230, 0.72);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.detail-panel__sections {
    margin-top: 14px;
    display: grid;
    gap: 14px;
}

.detail-tabs {
    margin-top: 0;
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    padding: 2px 2px 14px;
    border-radius: 0;
    background: transparent;
    border: none;
    position: relative;
    overflow-x: auto;
    scrollbar-width: none;
}

.detail-tabs::-webkit-scrollbar {
    display: none;
}

.detail-tab {
    flex: 1 1 0;
    min-width: 88px;
    position: relative;
    border: 1px solid transparent;
    border-radius: 14px;
    padding: 8px 10px 12px;
    background: transparent;
    color: #718191;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: color 0.2s ease, transform 0.2s ease;
}

.detail-tab:hover {
    transform: translateY(-1px);
}

.detail-tab.is-active {
    color: #2e6f91;
}

.detail-tab::after {
    content: "";
    position: absolute;
    left: 18px;
    right: 18px;
    bottom: -8px;
    height: 3px;
    border-radius: 999px;
    background: transparent;
    transition: background 0.2s ease;
}

.detail-tab.is-active::after {
    background: #2e6f91;
}

.detail-tab__icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 8px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    color: currentColor;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.detail-tab__icon svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    stroke-width: 1.8;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.detail-tab__label {
    display: block;
    white-space: nowrap;
}

.detail-tab.is-active .detail-tab__icon {
    background: rgba(76, 137, 168, 0.18);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.88);
}

.detail-tab:hover .detail-tab__icon {
    background: rgba(255, 255, 255, 0.72);
}

.detail-tab-panel {
    display: none;
}

.detail-tab-panel.is-active {
    display: block;
}

.detail-tab-panel.is-active .detail-card:first-child {
    margin-top: 0;
}

.detail-card {
    padding: 14px 14px 15px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.52);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.detail-card--change {
    background: rgba(76, 137, 168, 0.08);
    border-color: rgba(76, 137, 168, 0.14);
}

.detail-card--history {
    background: rgba(255, 255, 255, 0.44);
    padding: 12px 12px 13px;
}

.detail-card h3 {
    margin-top: 6px;
    font-size: 15px;
    line-height: 1.25;
}

.detail-card__meta {
    margin-top: 10px;
    font-size: 12px;
    line-height: 1.55;
    color: var(--text-tertiary);
}

.detail-card__meta--compact {
    margin-top: 6px;
    line-height: 1.45;
}

.detail-card p,
.detail-card li {
    margin-top: 10px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.detail-card ul {
    list-style: none;
}

.detail-card li + li {
    margin-top: 8px;
}

.detail-card__change-list {
    list-style: none;
    margin-top: 10px;
}

.detail-panel__history-summary {
    margin-top: 14px;
    display: grid;
    gap: 4px;
    padding: 0 2px;
    color: var(--text-secondary);
}

.detail-panel__history-summary strong {
    font-size: 13px;
    color: var(--text-primary);
}

.detail-panel__history-summary span,
.detail-panel__history-summary small {
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-tertiary);
}

.history-timeline {
    list-style: none;
    margin-top: 10px;
    display: grid;
    gap: 10px;
}

.history-timeline__item {
    display: grid;
    grid-template-columns: 12px 1fr;
    gap: 8px;
    align-items: start;
}

.history-timeline__dot {
    width: 8px;
    height: 8px;
    margin-top: 7px;
    border-radius: 50%;
    background: rgba(76, 137, 168, 0.92);
    box-shadow: 0 0 0 3px rgba(76, 137, 168, 0.12);
}

.history-timeline__content {
    min-width: 0;
}

.history-timeline__meta {
    font-size: 12px;
    color: var(--text-tertiary);
    white-space: nowrap;
}

.history-timeline__row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 8px;
    align-items: center;
}

.history-timeline__row .status-badge,
.history-timeline__row .detail-chip {
    padding: 6px 10px;
    font-size: 11px;
}

.history-timeline__row .status-badge::before {
    width: 7px;
    height: 7px;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.34);
}

.detail-panel__footer {
    margin-top: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.detail-panel__source {
    font-size: 12px;
    color: var(--text-tertiary);
}

.detail-panel__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(76, 137, 168, 0.14);
    color: var(--accent);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.2s ease, transform 0.2s ease;
}

.detail-panel__link:hover {
    background: rgba(76, 137, 168, 0.2);
    transform: translateY(-1px);
}

.detail-close {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.62);
    color: var(--text-secondary);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.detail-close:hover {
    background: rgba(255, 255, 255, 0.9);
    transform: scale(1.03);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.status-badge::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.36);
}

.status-badge.red { background: rgba(233, 142, 138, 0.24); }
.status-badge.red::before { background: var(--warning); }
.status-badge.orange { background: rgba(242, 179, 125, 0.24); }
.status-badge.orange::before { background: var(--partial); }
.status-badge.yellow { background: rgba(242, 214, 140, 0.28); }
.status-badge.yellow::before { background: var(--notice); }
.status-badge.green { background: rgba(127, 207, 168, 0.24); }
.status-badge.green::before { background: var(--safe); }
.status-badge.home { background: rgba(169, 197, 216, 0.28); }
.status-badge.home::before { background: var(--home); }
.status-badge.gray { background: rgba(231, 236, 239, 0.78); }
.status-badge.gray::before { background: #b0bac1; }

.detail-chip {
    display: inline-flex;
    align-items: center;
    padding: 7px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.54);
    font-size: 12px;
    color: var(--text-secondary);
}

.country-label {
    font-size: 11px;
    font-weight: 600;
    color: rgba(45, 56, 67, 0.82);
    text-shadow:
        0 1px 0 rgba(255, 255, 255, 0.9),
        0 0 8px rgba(255, 255, 255, 0.95);
    white-space: nowrap;
    text-align: center;
    pointer-events: none;
    background: none !important;
    border: none !important;
    letter-spacing: -0.01em;
}

.info-control,
.legend-control,
.search-control input,
.search-control .search-results,
.leaflet-control-zoom a {
    background: var(--panel-bg-strong) !important;
    border: 1px solid rgba(255, 255, 255, 0.66) !important;
    box-shadow: var(--panel-shadow);
    backdrop-filter: blur(18px) saturate(1.2);
    -webkit-backdrop-filter: blur(18px) saturate(1.2);
}

.info-control,
.legend-control {
    width: 240px;
    padding: 12px 14px;
    border-radius: 20px;
    color: var(--text-primary);
}

.info-control h4 {
    margin-top: 7px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    line-height: 1.15;
    letter-spacing: -0.03em;
}

.info-control__flag {
    font-size: 18px;
    line-height: 1;
}

.info-control:not(.is-expanded) > .status-badge {
    margin-top: 14px;
}

.info-control__change-hint {
    margin-top: 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
}

.info-control__cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 14px;
    padding: 10px 14px;
    border: none;
    border-radius: 999px;
    background: rgba(76, 137, 168, 0.14);
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.info-control__cta:hover {
    background: rgba(76, 137, 168, 0.2);
    transform: translateY(-1px);
}

.info-control.is-expanded {
    width: min(380px, calc(100vw - 40px));
    max-height: calc(100vh - 120px);
    padding: 0;
    border-radius: 28px;
    position: relative;
}

.info-control.is-expanded::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    border-radius: 0 0 28px 28px;
    background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.85));
    pointer-events: none;
    z-index: 1;
    opacity: 1;
    transition: opacity 0.2s;
}

.info-control.is-expanded.scrolled-bottom::after {
    opacity: 0;
}

.info-control.is-expanded .detail-panel__scroll {
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 18px;
    border-radius: 28px;
    -webkit-overflow-scrolling: touch;
}

.info-control.is-expanded .detail-panel__scroll::-webkit-scrollbar {
    width: 6px;
}

.info-control.is-expanded .detail-panel__scroll::-webkit-scrollbar-track {
    background: transparent;
}

.info-control.is-expanded .detail-panel__scroll::-webkit-scrollbar-thumb {
    background: rgba(74, 89, 102, 0.22);
    border-radius: 3px;
}

.info-control.is-expanded .detail-panel__scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(74, 89, 102, 0.36);
}

.info-control.is-expanded h4 {
    margin-top: 0;
    font-size: inherit;
    line-height: inherit;
    letter-spacing: inherit;
    display: block;
}

.info-control p,
.info-control .hint {
    margin-top: 8px;
    font-size: 12px;
    line-height: 1.55;
    color: var(--text-secondary);
}

.legend-control__toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
}

.legend-control__chevron {
    font-size: 11px;
    transition: transform 0.2s ease;
}

.legend-control.is-open .legend-control__chevron {
    transform: rotate(180deg);
}

.legend-control__panel {
    margin-top: 10px;
}

.legend-control__title {
    display: none;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

@media (min-width: 601px) {
    .legend-control {
        max-height: none !important;
        overflow: visible !important;
    }

    .legend-control__toggle {
        display: none;
    }

    .legend-control__panel {
        display: block !important;
        margin-top: 0;
    }

    .legend-control__title {
        display: block;
    }
}

.legend-control__group + .legend-control__group {
    margin-top: 12px;
}

.legend-control__divider {
    margin-top: 12px;
    height: 1px;
    background: rgba(95, 110, 122, 0.14);
}

.legend-control .legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    font-size: 13px;
    color: var(--text-secondary);
}

.legend-control .legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.45);
    flex-shrink: 0;
}

.legend-note {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-tertiary);
}

.legend-note__marker {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(76, 137, 168, 0.96);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.95);
    flex-shrink: 0;
}

.search-control {
    position: relative;
}

.search-control input {
    width: 300px;
    padding: 14px 16px 14px 42px;
    border-radius: 18px;
    font-size: 14px;
    color: var(--text-primary);
    outline: none;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.search-control input:focus {
    box-shadow:
        var(--panel-shadow),
        0 0 0 5px var(--accent-soft);
    transform: translateY(-1px);
}

.search-control input::placeholder {
    color: var(--text-tertiary);
}

.search-control .search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
    display: grid;
    place-items: center;
    width: 18px;
    height: 18px;
    z-index: 1;
    opacity: 0.9;
}

.search-control .search-icon svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 1.8;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.search-control .search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    border-radius: 18px;
    max-height: 280px;
    overflow-y: auto;
    display: none;
    z-index: 1000;
}

.search-control .search-results.visible {
    display: block;
}

.search-control .search-result-item {
    padding: 11px 14px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(95, 110, 122, 0.08);
    transition: background 0.18s ease;
}

.search-result-name {
    min-width: 0;
    flex: 1;
}

.search-control .search-result-item:last-child {
    border-bottom: none;
}

.search-control .search-result-item:hover,
.search-control .search-result-item.active {
    background: rgba(76, 137, 168, 0.08);
}

.search-control .search-result-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.42);
}

.search-result-flag {
    font-size: 15px;
    line-height: 1;
}

.search-result-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 8px;
    border-radius: 999px;
    background: rgba(76, 137, 168, 0.14);
    color: var(--accent);
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}

.search-control .search-no-results {
    padding: 14px;
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
}

.leaflet-control-zoom a {
    width: 40px !important;
    height: 40px !important;
    line-height: 38px !important;
    color: var(--text-primary) !important;
    font-size: 20px !important;
}

.leaflet-control-zoom a:hover {
    background: rgba(255, 255, 255, 0.96) !important;
}

.leaflet-control-zoom {
    border: none !important;
}

.leaflet-top.leaflet-left {
    top: 20px;
    left: 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.leaflet-top.leaflet-left .leaflet-control {
    margin: 0 !important;
}

.leaflet-bar a:first-child {
    border-top-left-radius: 16px !important;
    border-top-right-radius: 16px !important;
}

.leaflet-bar a:last-child {
    border-bottom-left-radius: 16px !important;
    border-bottom-right-radius: 16px !important;
}

.leaflet-container a {
    color: inherit;
}

.leaflet-container .leaflet-control-attribution {
    position: fixed;
    left: 50%;
    bottom: 10px;
    transform: translateX(-50%);
    margin: 0;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.34) !important;
    color: rgba(31, 42, 51, 0.58);
    font-size: 10px;
    line-height: 1.3;
    letter-spacing: 0.01em;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: none;
    border: 1px solid rgba(255, 255, 255, 0.32);
    z-index: 390;
}

.leaflet-container .leaflet-control-attribution a {
    color: rgba(31, 42, 51, 0.72);
    text-decoration: none;
}

.leaflet-container .leaflet-control-attribution a:hover {
    text-decoration: underline;
}

/* ── Large desktop: prevent centered hero from overlapping expanded briefing panel ── */
@media (min-width: 1200px) {
    .hero-panel {
        max-width: min(560px, calc(100vw - 840px));
    }
}

/* ── Small desktop / tablet (768–1199px): left-align hero to free right side for briefing ── */
@media (max-width: 1199px) {
    .hero-panel {
        left: 20px;
        transform: none;
        text-align: left;
        max-width: min(440px, calc(100vw - 420px));
    }

    .stats-bar {
        justify-content: flex-start;
    }
}

@media (max-width: 1100px) {
    .detail-panel {
        width: min(360px, calc(100vw - 32px));
    }

    .info-control,
    .legend-control {
        width: 220px;
    }
}

@media (max-width: 860px) {
    .tutorial-card {
        width: min(340px, calc(100vw - 24px));
        padding: 16px;
    }

    .tutorial-card__title {
        font-size: 24px;
    }

    .leaflet-top.leaflet-left {
        top: 14px;
        left: 12px;
        gap: 10px;
    }

    .hero-panel {
        top: 14px;
        width: calc(100vw - 24px);
        padding: 12px 14px 14px;
    }

    .hero-panel__title {
        font-size: 20px;
    }

    .search-control input {
        width: min(280px, calc(100vw - 96px));
    }

    .detail-panel__title {
        font-size: 26px;
    }

    .info-control,
    .legend-control {
        width: min(220px, calc(100vw - 24px));
    }

    .info-control.is-expanded {
        width: min(360px, calc(100vw - 24px));
        max-height: min(62vh, 520px);
        border-radius: 26px;
    }

    .info-control.is-expanded .detail-panel__scroll {
        max-height: min(62vh, 520px);
        padding: 16px;
    }
}

/* ── Small desktop/tablet (768–1199px): controls below left-aligned hero ── */
/* Placed after the 860px block so it overrides top: 14px for this range */
@media (min-width: 768px) and (max-width: 1199px) {
    .leaflet-top.leaflet-left {
        top: 180px; /* below ~140px hero panel + gap */
        left: 14px;
    }
}

/* ── 768–827px: hero stats wrap to 2 lines → hero is taller (~191px) ── */
@media (min-width: 768px) and (max-width: 827px) {
    .leaflet-top.leaflet-left {
        top: 210px; /* below ~191px hero with wrapped stats + ~20px gap */
        left: 12px;
    }
}

/* ── Mobile (<768px): bottom-bar architecture ── */
@media (max-width: 767px) {

    /* Hero moves to bottom of screen as a fixed bar */
    .hero-panel {
        top: auto !important;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        transform: none;
        border-radius: 20px 20px 0 0;
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
        text-align: center;
    }

    .stats-bar {
        justify-content: center;
    }

    /* Zoom + Search: back to top — no more hero blocking them there */
    .leaflet-top.leaflet-left {
        top: 14px;
        left: 10px;
        gap: 8px;
    }

    /* Attribution: hide Leaflet's own control on mobile — integrated into hero + briefing instead */
    .leaflet-container .leaflet-control-attribution {
        display: none;
    }

    /* Show inline attribution in hero panel on mobile */
    .hero-panel__attribution {
        display: block;
        margin-top: 6px;
        font-size: 9px;
        color: var(--text-tertiary);
        opacity: 0.7;
    }
    .hero-panel__attribution a {
        color: var(--text-tertiary);
        text-decoration: none;
    }

    /* Show inline attribution in briefing header on mobile */
    .detail-panel__attribution {
        display: block;
    }

    /* Legend: lift well above hero bottom-bar (hero ~155px tall incl. attribution line) */
    .leaflet-bottom.leaflet-right {
        bottom: 170px;
        right: 10px;
    }

    /* Compact info state: hidden on mobile — map colors are self-explanatory */
    .info-control:not(.is-expanded) {
        display: none;
    }

    /* Search controls must appear above briefing bottom sheet */
    body.briefing-open .leaflet-top.leaflet-left {
        z-index: 1002;
    }

    /* Briefing open: full-width bottom sheet */
    body.briefing-open .leaflet-top.leaflet-right {
        position: fixed !important;
        top: 10vh !important;
        right: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        float: none !important;
        display: flex !important;
        align-items: flex-end;
    }

    body.briefing-open .leaflet-top.leaflet-right .leaflet-control {
        margin: 0 !important;
        float: none !important;
    }

    body.briefing-open .info-control.is-expanded {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 90vh !important;
        border-radius: 20px 20px 0 0 !important;
        animation: slideUpSheet 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    }

    body.briefing-open .info-control.is-expanded::after {
        border-radius: 0 0 0 0;
    }

    body.briefing-open .info-control.is-expanded .detail-panel__scroll {
        max-height: 90vh !important;
        border-radius: 20px 20px 0 0 !important;
    }

    @keyframes slideUpSheet {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }
}

@media (max-width: 600px) {
    .tutorial-card {
        width: calc(100vw - 20px);
        padding: 14px;
    }

    .tutorial-card__title {
        font-size: 22px;
    }

    /* Note: .leaflet-top.leaflet-left positioning handled by 767px block above */
    .leaflet-top.leaflet-left {
        left: 10px;
        gap: 8px;
    }

    .country-label {
        font-size: 10px;
    }

    .hero-panel {
        padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
    }

    .hero-panel__eyebrow {
        display: none;
    }

    .hero-panel__title {
        margin-top: 0;
        font-size: 17px;
    }

    .hero-panel__meta {
        font-size: 11px;
        margin-top: 4px;
    }

    .stats-bar {
        margin-top: 8px;
        justify-content: center;
        gap: 6px;
    }

    .stat-pill {
        padding: 5px 8px;
        font-size: 11px;
        gap: 5px;
    }

    .stat-pill__dot {
        width: 7px;
        height: 7px;
    }

    .search-control input {
        width: min(250px, calc(100vw - 84px));
        padding: 12px 14px 12px 40px;
        font-size: 13px;
    }

    .info-control,
    .legend-control {
        width: min(210px, calc(100vw - 24px));
        padding: 11px 12px;
    }

    .legend-control {
        max-height: 36px;
        overflow: hidden;
        transition: max-height 0.25s ease;
        padding-top: 8px;
        padding-bottom: 8px;
        min-height: 52px;
    }

    .legend-control.is-open {
        max-height: 320px;
        overflow-y: visible;
        padding-top: 11px;
        padding-bottom: 11px;
    }

    .detail-panel__title {
        font-size: 24px;
    }

    .detail-panel__flag {
        font-size: 22px;
    }

    .info-control.is-expanded {
        width: min(340px, calc(100vw - 20px));
        max-height: min(68vh, 560px);
    }

    .info-control.is-expanded .detail-panel__scroll {
        max-height: min(68vh, 560px);
        padding: 14px;
    }

    /* Legend: moves to directly below the search field (right of zoom buttons) */
    .leaflet-bottom.leaflet-right {
        position: fixed;
        bottom: auto;
        top: 70px;  /* below search row (~14px top + ~44px search height + 12px gap) */
        right: auto;
        left: 62px; /* aligned with search input (after ~40px zoom + margins) */
    }
}

/* When briefing is open, legend hides on all screens (already hidden on mobile via display:none) */
body.briefing-open .legend-control {
    display: none;
}

/* Hero fades out when briefing opens — only on true mobile (<768px) */
body.briefing-open .hero-panel {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

/* On tablet/desktop (≥768px), hero stays visible — no overlap possible since hero is left-aligned */
@media (min-width: 768px) {
    body.briefing-open .hero-panel {
        opacity: 1;
        pointer-events: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
