/* map css */

/* layout */
.map-page {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.map-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    overflow: hidden;
}

/* map container */
#map {
    flex: 1;
    min-height: 0;
    z-index: 1;
}

#mapLoad {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    text-align: center;
    font-family: var(--font-body);
    color: var(--color-text-muted);
    font-size: 0.95rem;
}

/* region selector */
.region-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xl);
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-xl);
    padding: var(--space-4xl) var(--space-2xl);
    box-shadow: var(--shadow-xl);
    max-width: 95vw;
    width: 860px;
    transition: opacity var(--duration-slow) var(--ease-out),
        transform var(--duration-slow) var(--ease-out);
}

.region-panel.hidden {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.95);
    pointer-events: none;
}

/* background blur */
.map-wrapper::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 18, 6, 0.15);
    z-index: 10;
    opacity: 1;
    transition: opacity var(--duration-slow) var(--ease-out);
    pointer-events: none;
}

.map-wrapper.region-selected::before {
    opacity: 0;
}

.region-panel h2 {
    color: var(--color-text);
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    margin-bottom: var(--space-md);
}

.region-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md);
    width: 100%;
}

.region-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-2xl) var(--space-lg);
    text-align: center;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: all var(--duration-normal) var(--ease-out);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.region-card::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, transparent, rgba(231, 111, 81, 0.03));
    opacity: 0;
    transition: opacity var(--duration-normal) ease;
}

.region-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
    border-color: var(--color-accent);
}

.region-card:hover::after {
    opacity: 1;
}

.region-card h3 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    margin-bottom: var(--space-xs);
}

.region-card p {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.region-card[disabled] {
    opacity: 0.9;
    cursor: not-allowed;
    pointer-events: none;
    border-color: var(--color-border-strong);
}

.region-card[disabled] .card-content {
    opacity: 0.7;
    filter: grayscale(0.2);
}

.wip-badge {
    position: absolute;
    bottom: var(--space-md);
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    background: var(--color-text);
    color: var(--color-bg);
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}

/* filters */
.map-topbar {
    position: absolute;
    top: calc(var(--nav-height) + var(--space-md));
    left: var(--space-md);
    right: var(--space-md);
    z-index: 15;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity var(--duration-normal) var(--ease-out),
        transform var(--duration-normal) var(--ease-out),
        left var(--duration-slow) var(--ease-out);
    pointer-events: none;
    overflow: visible; /* Ensure pills can move up */
}

@media (min-width: 641px) {
    .map-wrapper.detail-open .map-topbar {
        left: calc(340px + var(--space-md));
    }
}

.map-topbar.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    min-height: 66px;
}

.map-btn {
    padding: 0.5rem 1.1rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--duration-fast) ease;
    white-space: nowrap;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.map-btn:hover {
    background: #FFFFFF;
    border-color: var(--color-border-strong);
    color: var(--color-text);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.map-btn-circle {
    width: 38px;
    height: 38px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.map-btn.active {
    background: var(--color-text);
    color: var(--color-bg);
    border-color: var(--color-text);
}

/* filters bar */
.filter-container {
    flex: 1;
    min-width: 0;
    position: relative;
    display: flex;
    align-items: center;
    overflow: visible;
    min-height: 66px;
    /* Permanent gradient with hard 40px stops */
    -webkit-mask-image: linear-gradient(to right, transparent 0, black 40px, black calc(100% - 40px), transparent 100%);
    mask-image: linear-gradient(to right, transparent 0, black 40px, black calc(100% - 40px), transparent 100%);
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    
    /* Use a large height for the mask to prevent Y clipping */
    -webkit-mask-size: calc(100% + 40px) 200%;
    mask-size: calc(100% + 40px) 200%;
    -webkit-mask-position: -40px center;
    mask-position: -40px center;
    
    transition: -webkit-mask-size 0.3s ease, -webkit-mask-position 0.3s ease,
                mask-size 0.3s ease, mask-position 0.3s ease;
}

.filter-container.can-scroll-both {
    -webkit-mask-size: 100% 200%;
    mask-size: 100% 200%;
    -webkit-mask-position: 0 center;
    mask-position: 0 center;
}

.filter-container.can-scroll-left:not(.can-scroll-both) {
    -webkit-mask-size: calc(100% + 40px) 200%;
    mask-size: calc(100% + 40px) 200%;
    -webkit-mask-position: 0 center;
    mask-position: 0 center;
}

.filter-container.no-scroll {
    -webkit-mask-size: calc(100% + 80px) 200%;
    mask-size: calc(100% + 80px) 200%;
    -webkit-mask-position: -40px center;
    mask-position: -40px center;
}

.filter-bar {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    overflow-x: auto;
    overflow-y: visible; /* Prevent Y clipping */
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    width: 100%;
    padding: 15px 40px 15px 0; /* More padding */
    margin: -15px 0;
}

.filter-bar::-webkit-scrollbar {
    display: none;
}

.filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0.45rem 1rem;
    background: var(--color-surface-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all var(--duration-fast) var(--ease-out);
    box-shadow: var(--shadow-xs);
}

.filter-pill:hover {
    border-color: var(--color-accent);
    background: var(--color-surface);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.filter-pill.active {
    background: var(--color-text);
    color: var(--color-bg);
    border-color: var(--color-text);
    box-shadow: var(--shadow-md);
}

.filter-pill .pill-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.filter-pill.active .pill-dot {
    border: 1.5px solid rgba(255, 255, 255, 0.5);
}

/* detail panel */
.detail-panel {
    position: absolute;
    top: var(--nav-height);
    left: 0;
    bottom: 0;
    width: 400px;
    max-width: 90vw;
    background: var(--color-surface-glass);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-right: 1px solid var(--color-border);
    z-index: 25;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform var(--duration-slow) var(--ease-out);
    box-shadow: var(--shadow-xl);
}

.detail-panel.open {
    transform: translateX(0);
}

.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.detail-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 1.2rem;
    line-height: 1;
    color: var(--color-text-muted);
    transition: all var(--duration-fast) ease;
    cursor: pointer;
}

.detail-close:hover {
    color: var(--color-text);
    background-color: rgba(0, 0, 0, 0.05);
}

.detail-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.detail-body h3 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    color: var(--color-text);
}

.detail-row {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    line-height: 1.5;
}

.detail-row-icon {
    flex-shrink: 0;
    width: 20px;
    text-align: center;
    margin-top: 2px;
}

.detail-row a {
    color: var(--color-accent);
    text-decoration: underline;
    text-decoration-color: rgba(231, 111, 81, 0.3);
    text-underline-offset: 2px;
    transition: text-decoration-color var(--duration-fast) ease;
}

.detail-row a:hover {
    text-decoration-color: var(--color-accent);
}

/* map legend */
.map-legend {
    position: absolute;
    bottom: var(--space-md);
    right: var(--space-md);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    z-index: 10;
    display: none;
    box-shadow: var(--shadow-sm);
}

.map-legend.visible {
    display: block;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 0.75rem;
    font-family: var(--font-body);
    color: var(--color-text-secondary);
    line-height: 1;
}

.legend-item:last-child {
    margin-bottom: 0;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}



/* mobile info panel */
@media (max-width: 640px) {
    .detail-panel {
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        max-height: 60vh;
        transform: translateY(100%);
        border-right: none;
        border-top: 1px solid var(--color-border);
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    }

    .detail-panel.open {
        transform: translateY(0);
    }

    .region-card {
        min-width: 130px;
        padding: var(--space-md) var(--space-lg);
    }

    .map-topbar {
        flex-wrap: nowrap;
    }

    .map-legend {
        bottom: var(--space-sm);
        right: var(--space-sm);
        padding: 8px 10px;
    }

    .legend-item {
        font-size: 0.7rem;
    }
}