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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #000;
    overflow: hidden;
}

/* Map */
#map {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
}

.leaflet-control-attribution {
    display: none;
}

/* Loading State */
.loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255,255,255,0.6);
    font-size: 0.9rem;
    z-index: 1000;
}

/* Bottom UI Panel */
.ui-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    z-index: 1000;
    background: rgba(20,20,20,0.7);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-top: 1px solid rgba(255,255,255,0.1);
    transform: translateY(100%);
    opacity: 0;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.ui-panel.visible {
    transform: translateY(0);
    opacity: 1;
}

.sport-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    transition: opacity 0.2s ease;
}

.sport-icon {
    width: 48px;
    height: 48px;
    color: #fff;
    flex-shrink: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sport-icon:hover {
    transform: scale(1.05);
}

.sport-icon svg {
    width: 100%;
    height: 100%;
}

.sport-text {
    flex: 1;
    min-width: 0;
}

.sport-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sport-count {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.6);
    margin-top: 2px;
}

/* Sport Pills */
.sport-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

.sport-pill {
    width: 32px;
    height: 32px;
    padding: 6px;
    background: rgba(255,255,255,0.08);
    backdrop-filter: blur(12px) saturate(150%);
    -webkit-backdrop-filter: blur(12px) saturate(150%);
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.5);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sport-pill svg {
    width: 100%;
    height: 100%;
}

.sport-pill.active {
    background: rgba(255,255,255,0.95);
    border-color: rgba(255,255,255,0.3);
    color: #000;
}

.sport-pill:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.2);
}

.sport-pill.active:hover {
    background: rgba(255,255,255,0.95);
}

/* Map Markers */
.marker-container {
    cursor: pointer;
}

.marker-dot {
    width: 10px;
    height: 10px;
    background: rgba(255,255,255,0.25);
    border-radius: 50%;
    pointer-events: none;
    border: 2px solid transparent;
    box-shadow: none;
    opacity: 0.6;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                margin 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                background 0.3s ease,
                border-color 0.3s ease,
                box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s ease;
}

/* Fade out state - old markers leaving */
.marker-dot.fading-out {
    opacity: 0.3;
    box-shadow: none;
    animation: none;
}

/* Active state - new markers entering */
.marker-dot.active {
    width: 14px;
    height: 14px;
    margin: -2px;
    background: #fff;
    border: 2px solid #089289;
    box-shadow: 0 0 12px rgba(255,255,255,0.9), 0 0 24px rgba(255,255,255,0.5);
    opacity: 1;
    pointer-events: auto;
    cursor: pointer;
    animation: pulse-marker 2.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    animation-delay: var(--pulse-delay, 0s);
}

/* Synced glow animation */
@keyframes pulse-marker {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 12px rgba(255,255,255,0.9), 0 0 24px rgba(255,255,255,0.5);
    }
    50% {
        transform: scale(1.12);
        box-shadow: 0 0 18px rgba(255,255,255,1), 0 0 36px rgba(255,255,255,0.7);
    }
}

/* Detail Card */
.detail-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.detail-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.detail-card {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9) translateY(20px);
    background: rgba(20,20,20,0.95);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 20px;
    padding: 20px;
    z-index: 2000;
    max-width: 320px;
    max-height: 70vh;
    overflow-y: auto;
    width: calc(100% - 40px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.detail-card.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1) translateY(0);
}

.detail-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.detail-card-location {
    color: rgba(255,255,255,0.5);
    font-size: 0.85rem;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.detail-card-courses {
    display: flex;
    flex-direction: column;
}

.detail-card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
}

.detail-card-close {
    width: 28px;
    height: 28px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background 0.2s ease;
}

.detail-card-close:hover {
    background: rgba(255,255,255,0.2);
}

.detail-card-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 0.9rem;
}

.detail-card-row:last-child {
    margin-bottom: 0;
}

.detail-card-label {
    color: rgba(255,255,255,0.5);
    min-width: 50px;
}

.detail-card-value {
    color: #fff;
}

/* Course list in detail card */
.course-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.course-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.course-item:first-child {
    padding-top: 0;
}

.course-time {
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
}

.course-desc {
    color: rgba(255,255,255,0.5);
    font-size: 0.8rem;
}

.course-link {
    display: inline-block;
    margin-top: 12px;
    padding: 8px 16px;
    background: rgba(8, 146, 137, 0.8);
    color: #fff;
    text-decoration: none;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.2s ease;
}

.course-link:hover {
    background: rgba(8, 146, 137, 1);
}

/* ===========================================
   RESPONSIVE DESIGN
   =========================================== */

/* Mobile (default) - up to 767px */
@media (max-width: 767px) {
    .ui-panel {
        padding: 12px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }

    .sport-info {
        gap: 10px;
        margin-bottom: 10px;
    }

    .sport-icon {
        width: 40px;
        height: 40px;
    }

    .sport-name {
        font-size: 1.1rem;
    }

    .sport-count {
        font-size: 0.75rem;
    }

    .sport-pills {
        gap: 5px;
    }

    .sport-pill {
        width: 28px;
        height: 28px;
        padding: 5px;
    }

    .detail-card {
        max-width: 300px;
        padding: 16px;
        border-radius: 16px;
    }

    .detail-card-title {
        font-size: 1rem;
    }
}

/* Tablet - 768px to 1023px */
@media (min-width: 768px) and (max-width: 1023px) {
    .ui-panel {
        left: 50%;
        transform: translateX(-50%) translateY(100%);
        width: auto;
        max-width: 600px;
        border-radius: 20px 20px 0 0;
        padding: 20px 24px;
    }

    .ui-panel.visible {
        transform: translateX(-50%) translateY(0);
    }

    .sport-icon {
        width: 52px;
        height: 52px;
    }

    .sport-name {
        font-size: 1.3rem;
    }

    .sport-pills {
        gap: 8px;
    }

    .sport-pill {
        width: 36px;
        height: 36px;
        padding: 7px;
    }

    .detail-card {
        max-width: 380px;
        padding: 24px;
    }
}

/* Desktop - 1024px and up */
@media (min-width: 1024px) {
    .ui-panel {
        left: 32px;
        right: auto;
        bottom: 32px;
        width: 520px;
        border-radius: 24px;
        padding: 28px;
        padding-bottom: 28px;
    }

    .sport-info {
        gap: 20px;
        margin-bottom: 20px;
    }

    .sport-icon {
        width: 96px;
        height: 96px;
    }

    .sport-name {
        font-size: 1.8rem;
    }

    .sport-count {
        font-size: 1rem;
    }

    .sport-pills {
        gap: 12px;
        justify-content: flex-start;
    }

    .sport-pill {
        width: 52px;
        height: 52px;
        padding: 10px;
    }

    .sport-pill:hover {
        transform: scale(1.1);
    }

    .detail-card {
        max-width: 420px;
        padding: 28px;
        border-radius: 24px;
    }

    .detail-card-title {
        font-size: 1.3rem;
    }

    .marker-dot.active {
        width: 16px;
        height: 16px;
        margin: -3px;
    }
}

/* Large Desktop - 1440px and up */
@media (min-width: 1440px) {
    .ui-panel {
        left: 40px;
        bottom: 40px;
        width: 580px;
        padding: 32px;
    }

    .sport-icon {
        width: 110px;
        height: 110px;
    }

    .sport-name {
        font-size: 2rem;
    }

    .sport-pill {
        width: 58px;
        height: 58px;
        padding: 11px;
    }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .ui-panel {
        padding: 10px 16px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }

    .sport-info {
        margin-bottom: 8px;
    }

    .sport-icon {
        width: 36px;
        height: 36px;
    }

    .sport-name {
        font-size: 1rem;
    }

    .sport-pills {
        gap: 4px;
    }

    .sport-pill {
        width: 26px;
        height: 26px;
        padding: 4px;
    }

    .detail-card {
        max-height: 80vh;
    }
}
