.map-page {
    overflow: hidden;
}

.map-main {
    height: calc(100vh - 56px);
    height: calc(100dvh - 56px);
}

.map-layout {
    position: relative;
    height: 100%;
    min-height: 0;
}

.map-stack {
    position: relative;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.map-stack.is-loading .map-container {
    filter: blur(10px) saturate(0.85);
    transform: scale(1.015);
    transition: filter 0.5s ease, transform 0.5s ease;
}

.map-container {
    height: 100%;
    width: 100%;
    min-height: 0;
    transition: filter 0.5s ease, transform 0.5s ease;
}

.map-loading-overlay {
    position: absolute;
    inset: 0;
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 20, 25, 0.45);
    backdrop-filter: blur(2px);
    opacity: 1;
    visibility: visible;
    transition: opacity 0.45s ease, visibility 0.45s ease;
    pointer-events: none;
}

.map-loading-overlay.is-hidden {
    opacity: 0;
    visibility: hidden;
}

.map-loading-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 1.75rem 2.25rem;
    border-radius: 16px;
    background: rgba(26, 35, 50, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.map-loader {
    position: relative;
    width: 72px;
    height: 72px;
}

.map-loader-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid transparent;
    border-top-color: var(--powlette-accent);
    border-right-color: rgba(232, 168, 56, 0.25);
    animation: map-loader-spin 1.1s cubic-bezier(0.55, 0.15, 0.45, 0.85) infinite;
}

.map-loader-ring--delayed {
    inset: 10px;
    border-top-color: rgba(232, 168, 56, 0.55);
    border-right-color: transparent;
    border-bottom-color: rgba(232, 168, 56, 0.15);
    animation-duration: 0.85s;
    animation-direction: reverse;
}

.map-loader-pin {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 14px;
    height: 14px;
    margin: -14px 0 0 -7px;
    background: var(--powlette-accent);
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    box-shadow: 0 0 12px rgba(232, 168, 56, 0.65);
    animation: map-loader-pulse 1.4s ease-in-out infinite;
}

.map-loader-pin::after {
    content: '';
    position: absolute;
    width: 6px;
    height: 6px;
    left: 4px;
    top: 4px;
    background: #1a1200;
    border-radius: 50%;
}

.map-loading-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--powlette-text);
    letter-spacing: 0.02em;
}

.map-loading-subtitle {
    margin: 0;
    font-size: 0.85rem;
    color: var(--powlette-muted);
}

.map-loading-dots::after {
    content: '';
    animation: map-loading-ellipsis 1.4s steps(4, end) infinite;
}

@keyframes map-loader-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes map-loader-pulse {
    0%, 100% {
        transform: rotate(-45deg) scale(1);
        opacity: 1;
    }
    50% {
        transform: rotate(-45deg) scale(0.88);
        opacity: 0.75;
    }
}

@keyframes map-loading-ellipsis {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}

.map-style-control {
    position: absolute;
    left: 0.75rem;
    bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    z-index: 1000;
    display: inline-flex;
    padding: 0.2rem;
    border-radius: 999px;
    background: var(--powlette-surface);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    pointer-events: auto;
}

.map-style-thumb {
    position: absolute;
    top: 0.2rem;
    left: 0;
    height: calc(100% - 0.4rem);
    border-radius: 999px;
    background: rgba(232, 168, 56, 0.22);
    box-shadow: inset 0 0 0 1px rgba(232, 168, 56, 0.35);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), width 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.map-style-option {
    position: relative;
    z-index: 1;
    padding: 0.4rem 0.85rem;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--powlette-muted);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: color 0.15s ease;
}

.map-style-option:hover,
.map-style-option:focus-visible {
    color: var(--powlette-text);
    outline: none;
}

.map-style-option.is-active {
    color: var(--powlette-text);
}

.map-filters-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--powlette-surface) !important;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
    pointer-events: auto;
    border-radius: 0 0 12px 12px;
    overflow: hidden;
}

.map-filters-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    min-height: 2.75rem;
}

.map-filters-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
    padding: 0.35rem 0.65rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--powlette-text);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.map-filters-toggle:hover,
.map-filters-toggle:focus-visible {
    border-color: rgba(232, 168, 56, 0.55);
    background: rgba(232, 168, 56, 0.1);
    outline: none;
}

.map-filters-chevron {
    transition: transform 0.2s ease;
}

.map-filters-overlay.is-expanded .map-filters-chevron {
    transform: rotate(180deg);
}

.map-filters-summary {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: right;
}

.map-filters-body {
    padding: 0 1rem 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.map-filters-overlay.is-collapsed .map-filters-body {
    display: none;
}

.map-filters-overlay.is-expanded .map-filters-body {
    display: block;
}

.map-filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
}

.filter-field {
    flex: 1 1 140px;
    min-width: 120px;
    margin-bottom: 0;
}

.filter-field--trip {
    flex: 2 1 220px;
    min-width: 180px;
}

.filter-field .form-label {
    margin-bottom: 0.25rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--powlette-muted);
}

.filter-actions {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: flex-end;
}

.leaflet-popup-content-wrapper {
    border-radius: 8px;
    background: var(--powlette-surface);
    color: var(--powlette-text);
}

.leaflet-popup-tip {
    background: var(--powlette-surface);
}

.popup-thumb {
    width: 100%;
    max-width: 240px;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    cursor: pointer;
}

.popup-meta {
    font-size: 0.85rem;
    color: var(--powlette-muted);
    margin: 0;
}

.popup-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.photo-pin-marker {
    background: transparent;
    border: none;
}

.photo-pin {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(26, 35, 50, 0.9);
    border: 2.5px solid #fff;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.45);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.photo-pin:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 16px rgba(0, 0, 0, 0.5);
}

.photo-pin img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.photo-pin-fallback {
    display: block;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(232, 168, 56, 0.35), rgba(26, 35, 50, 0.85));
}

.photo-pin-badge {
    position: absolute;
    left: 4px;
    bottom: 4px;
    min-width: 1.35rem;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    pointer-events: none;
}

.photo-grid-view {
    position: fixed;
    inset: 0;
    z-index: 1800;
    display: flex;
    flex-direction: column;
    background: var(--powlette-bg);
}

.photo-grid-view[hidden] {
    display: none !important;
}

.photo-grid-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
    padding: calc(0.75rem + env(safe-area-inset-top, 0px)) 1rem 0.75rem;
    background: var(--powlette-surface);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.photo-grid-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    color: var(--powlette-text);
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease;
}

.photo-grid-back:hover,
.photo-grid-back:focus-visible {
    background: rgba(232, 168, 56, 0.15);
    outline: none;
}

.photo-grid-heading {
    min-width: 0;
}

.photo-grid-title {
    color: var(--powlette-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.photo-grid-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.photo-grid-track {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
    gap: 2px;
    padding: 2px;
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
}

.photo-grid-item {
    aspect-ratio: 1;
    padding: 0;
    border: none;
    background: rgba(255, 255, 255, 0.04);
    cursor: pointer;
    overflow: hidden;
}

.photo-grid-item:focus-visible {
    outline: 2px solid var(--powlette-accent);
    outline-offset: -2px;
}

.photo-grid-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

body.photo-grid-open {
    overflow: hidden;
}

.photo-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: rgba(0, 0, 0, 0.88);
    cursor: zoom-out;
}

.photo-lightbox[hidden] {
    display: none !important;
}

.photo-lightbox-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.75rem;
    max-width: min(96vw, 1400px);
    max-height: 92vh;
}

.photo-lightbox-download {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.875rem;
    border-radius: 999px;
    background: rgba(26, 35, 50, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--powlette-text);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
}

.photo-lightbox-download:hover,
.photo-lightbox-download:focus-visible {
    color: #1a1200;
    background: var(--powlette-accent);
    border-color: var(--powlette-accent);
    outline: none;
}

.photo-lightbox-download[hidden] {
    display: none !important;
}

.photo-lightbox-image {
    max-width: min(96vw, 1400px);
    max-height: calc(92vh - 3rem);
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.45);
    pointer-events: none;
    cursor: default;
}

body.lightbox-open,
body.modal-open {
    overflow: hidden;
}

.map-modal {
    position: fixed;
    inset: 0;
    z-index: 2100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.map-modal[hidden] {
    display: none !important;
}

.map-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
}

.map-modal-panel {
    position: relative;
    width: min(100%, 560px);
    max-height: min(80vh, 720px);
    display: flex;
    flex-direction: column;
    background: var(--powlette-surface);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
    overflow: hidden;
}

.map-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.map-modal-title {
    color: var(--powlette-text);
}

.map-modal-body {
    padding: 1rem 1.25rem 1.25rem;
    overflow-y: auto;
}

.timeline-list {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.timeline-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    width: 100%;
    padding: 0.875rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--powlette-text);
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.timeline-item:hover,
.timeline-item:focus-visible {
    border-color: rgba(232, 168, 56, 0.55);
    background: rgba(232, 168, 56, 0.08);
    outline: none;
}

.timeline-item-main {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
    align-items: baseline;
}

.timeline-country {
    font-weight: 600;
}

.timeline-dates {
    color: var(--powlette-muted);
    font-size: 0.9rem;
}

.timeline-meta {
    font-size: 0.8rem;
    color: var(--powlette-muted);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
}

.stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 1.25rem 0.75rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--powlette-accent);
    line-height: 1;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--powlette-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

@media (max-width: 768px) {
    .map-filters-overlay {
        top: 0.5rem;
        left: 0.5rem;
        right: 0.5rem;
        border-radius: 12px;
    }

    .map-filters-bar {
        padding: 0.5rem 0.75rem;
    }

    .map-filters-body {
        padding: 0 0.75rem 0.75rem;
    }

    .filter-field {
        flex: 1 1 calc(50% - 0.75rem);
    }

    .filter-actions {
        flex: 1 1 100%;
    }

    .filter-actions .btn {
        width: 100%;
    }

    .photo-grid-track {
        grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    }

    .map-style-control {
        left: 0.5rem;
        bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
    }

    .map-style-option {
        padding: 0.35rem 0.7rem;
        font-size: 0.75rem;
    }
}
