/**
 * Map Layers - Leaflet.js Specific Styles
 * CSS for the Leaflet map layer in index2.html
 * (General layer styles are inherited from home.css)
 */

/* =============================================
   Layer 3: Leaflet Interactive Map
   ============================================= */

/* Layer 3 background color */
.layer-3 {
    background: #E8F4E8; /* Soft green/nature tone to complement the facility map */
}

#leaflet-map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background: #E8F4E8; /* Match layer background */
}

/* Map Instruction */
.map-instruction {
    position: fixed;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 16px 24px;
    border-radius: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    z-index: 50;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: #666666;
    transition: opacity 0.3s ease;
}

.map-instruction svg {
    color: #F9A01B;
}

.map-instruction.hidden {
    opacity: 0;
    pointer-events: none;
}

/* =============================================
   Detail Panel (Layer 3 Slide-out)
   ============================================= */

.map-detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 480px;
    height: 100vh;
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-left: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px 0 0 20px;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
    z-index: 200;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
}

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

.panel-inner {
    padding: 48px 40px;
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

.panel-close-btn {
    position: absolute;
    top: 24px;
    right: 24px;
    width: 40px;
    height: 40px;
    background: #F5F7FA;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
}

.panel-close-btn svg {
    width: 20px;
    height: 20px;
    color: #666666;
}

.panel-close-btn:hover,
.panel-close-btn:focus {
    background: #E8ECF3;
}

.panel-close-btn:focus {
    outline: 2px solid #F9A01B;
    outline-offset: 2px;
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 32px;
    padding-top: 24px;
}

.panel-icon {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(249, 160, 27, 0.15);
    border-radius: 50%;
}

.panel-icon svg {
    width: 32px;
    height: 32px;
    color: #F9A01B;
}

.panel-title {
    font-family: 'Onest', sans-serif;
    font-size: 28px;
    font-weight: 600;
    color: #041A31;
    line-height: 1.2;
    margin: 0;
}

.panel-desc {
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    line-height: 1.8;
    color: #666666;
    margin: 0 0 32px 0;
}

.panel-features {
    background: #F9FAFB;
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 32px;
}

.features-heading {
    font-family: 'Onest', sans-serif;
    font-size: 16px;
    font-weight: 600;
    color: #041A31;
    margin: 0 0 16px 0;
}

.features-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.features-list li {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: #666666;
    padding-left: 24px;
    position: relative;
}

.features-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px;
    width: 8px;
    height: 8px;
    background: #F9A01B;
    border-radius: 50%;
}

.panel-cta-btn {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 16px 28px;
    background: #F9A01B;
    color: #FFFFFF;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 20px;
    transition: all 0.3s ease;
    margin-top: auto;
    align-self: flex-start;
}

.panel-cta-btn svg {
    width: 18px;
    height: 18px;
    transition: transform 0.3s ease;
}

.panel-cta-btn:hover,
.panel-cta-btn:focus {
    background: #E8890B;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(249, 160, 27, 0.3);
}

.panel-cta-btn:hover svg {
    transform: translateX(4px);
}

.panel-cta-btn:focus {
    outline: 2px solid #041A31;
    outline-offset: 2px;
}

/* =============================================
   Custom Leaflet Markers
   ============================================= */

.leaflet-marker-icon.facility-marker-icon {
    background: transparent;
    border: none;
}

.facility-marker-pin {
    width: 56px;
    height: 56px;
    position: relative;
}

.facility-marker-pin .pin-bg {
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.facility-marker-pin .pin-icon {
    transform: rotate(45deg);
    color: #F9A01B;
    font-size: 24px;
}

.facility-marker-pin:hover .pin-bg,
.facility-marker-pin.active .pin-bg {
    background: #F9A01B;
    transform: rotate(-45deg) scale(1.1);
}

.facility-marker-pin:hover .pin-icon,
.facility-marker-pin.active .pin-icon {
    color: #FFFFFF;
}

/* Pulse Animation */
.facility-marker-pin::before {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 20px;
    background: #F9A01B;
    border-radius: 50%;
    animation: markerPulse 2s ease-in-out infinite;
    z-index: -1;
}

@keyframes markerPulse {
    0%, 100% {
        transform: translateX(-50%) scale(1);
        opacity: 0.6;
    }
    50% {
        transform: translateX(-50%) scale(2);
        opacity: 0;
    }
}

/* Leaflet Popup Customization */
.leaflet-popup-content-wrapper {
    background: rgba(40, 56, 146, 0.95);
    color: #FFFFFF;
    border-radius: 20px;
    padding: 0;
}

.leaflet-popup-content {
    margin: 12px 20px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
}

.leaflet-popup-tip {
    background: rgba(40, 56, 146, 0.95);
}

.leaflet-popup-close-button {
    color: #FFFFFF !important;
}

/* =============================================
   Layer 3 Scroll Controls Position
   ============================================= */

.layer-3-controls {
    position: fixed;
    right: 80px;
    bottom: 60px;
    z-index: 100;
}

/* =============================================
   Close Button (X) for Layer 2
   ============================================= */

.map-close-btn {
    position: fixed;
    top: 100px;
    right: 40px;
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 100;
    transition: all 0.2s ease;
}

.map-close-btn svg {
    width: 24px;
    height: 24px;
    color: #666666;
    transition: color 0.2s ease;
}

.map-close-btn:hover,
.map-close-btn:focus {
    background: #FFFFFF;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
    transform: scale(1.05);
}

.map-close-btn:hover svg,
.map-close-btn:focus svg {
    color: #333333;
}

.map-close-btn:focus {
    outline: 2px solid #F9A01B;
    outline-offset: 2px;
}

/* Facility Zoom Indicator - show when Layer 2 is active */
.facility-zoom-indicator {
    opacity: 0;
    pointer-events: none;
}

.layer-2.active .facility-zoom-indicator {
    opacity: 1;
}

/* Continue Button for Layer 3 */
.continue-btn {
    position: fixed;
    bottom: 120px;
    right: 80px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 24px;
    background: #F9A01B;
    color: #FFFFFF;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    z-index: 100;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(249, 160, 27, 0.3);
}

.continue-btn svg {
    width: 18px;
    height: 18px;
    transition: transform 0.3s ease;
}

.continue-btn:hover,
.continue-btn:focus {
    background: #E8890B;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(249, 160, 27, 0.4);
}

.continue-btn:hover svg {
    transform: translateX(4px);
}

.continue-btn:focus {
    outline: 2px solid #041A31;
    outline-offset: 2px;
}

/* =============================================
   Zoom Level Indicator
   ============================================= */

.zoom-indicator {
    position: fixed;
    left: 40px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.layer-3.active .zoom-indicator,
.zoom-indicator.visible {
    opacity: 1;
}

.zoom-indicator-track {
    width: 6px;
    height: 120px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 3px;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.zoom-indicator-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(to top, #F9A01B, #FFB84D);
    border-radius: 3px;
    transition: height 0.2s ease;
}

.zoom-indicator-thumb {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 16px;
    background: #FFFFFF;
    border: 3px solid #F9A01B;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: bottom 0.2s ease;
}

.zoom-indicator-labels {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 96px;
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    height: 120px;
    justify-content: space-between;
    pointer-events: none;
}

.zoom-label-min,
.zoom-label-max {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: #666666;
    background: rgba(255, 255, 255, 0.9);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

/* =============================================
   Responsive Styles
   ============================================= */

@media (max-width: 1024px) {
    .map-detail-panel {
        max-width: 400px;
    }

    .panel-inner {
        padding: 40px 32px;
    }

    .panel-title {
        font-size: 24px;
    }

    .layer-3-controls {
        right: 40px;
    }

    .continue-btn {
        right: 40px;
    }

    .map-close-btn {
        top: 80px;
        right: 24px;
        width: 44px;
        height: 44px;
    }

    .map-close-btn svg {
        width: 20px;
        height: 20px;
    }
}

@media (max-width: 768px) {
    .map-instruction {
        bottom: 100px;
        padding: 12px 20px;
        font-size: 13px;
    }

    .map-detail-panel {
        max-width: 100%;
        border-radius: 20px 20px 0 0;
        height: auto;
        max-height: 85vh;
        top: auto;
        bottom: 0;
        transform: translateY(100%);
    }

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

    .panel-inner {
        padding: 32px 24px;
    }

    .panel-header {
        padding-top: 16px;
    }

    .panel-icon {
        width: 48px;
        height: 48px;
    }

    .panel-title {
        font-size: 20px;
    }

    .panel-desc {
        font-size: 14px;
    }

    .features-list {
        grid-template-columns: 1fr;
    }

    .layer-3-controls {
        right: 16px;
        bottom: 24px;
    }

    .continue-btn {
        right: 16px;
        bottom: 80px;
        padding: 12px 20px;
        font-size: 13px;
    }

    .zoom-indicator {
        left: 16px;
    }

    .zoom-indicator-track {
        height: 80px;
    }

    .zoom-indicator-labels {
        height: 80px;
        gap: 56px;
    }

    .map-close-btn {
        top: 70px;
        right: 16px;
        width: 40px;
        height: 40px;
    }

    .map-close-btn svg {
        width: 18px;
        height: 18px;
    }
}

/* =============================================
   Leaflet Map Screen Container
   ============================================= */

.leaflet-map-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.leaflet-map-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background: #E8F0F8; /* Light blue background */
}

/* =============================================
   Layer 2: Leaflet Facility Map with Markers
   ============================================= */

.layer-2 .leaflet-map-container {
    background: #FFFFFF; /* White background for facility map */
}

/* Layer 2 Hero Overlay */
.layer-2 .hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1500;
    background: transparent;
    pointer-events: auto; /* Block interaction with map below */
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.layer-2 .hero-overlay .hero-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 20px;
    padding: 48px;
    box-shadow: 0px 2px 8px 0px rgba(0, 0, 0, 0.25);
    pointer-events: auto;
}

.layer-2 .hero-overlay > .scroll-controls {
    position: fixed;
    right: 80px;
    bottom: 60px;
    z-index: 20;
    pointer-events: auto;
}

.layer-2 .hero-overlay.hidden {
    opacity: 0;
    pointer-events: none !important;
}

.layer-2 .hero-overlay.hidden .hero-card,
.layer-2 .hero-overlay.hidden > .scroll-controls {
    pointer-events: none !important;
}

.layer-2 .hero-overlay .dotted-pattern {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.layer-2 .hero-overlay .hero-content-wrapper {
    position: absolute;
    left: 160px;
    top: 50%;
    transform: translateY(-50%);
    width: 720px;
    z-index: 10;
}

/* Layer 2 Info Container */
.layer2-info-container {
    position: absolute;
    top: 104px; /* 60px header + 44px padding */
    left: 86px;
    width: 586px;
    min-height: 207px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0px 2px 8px 0px rgba(0, 0, 0, 0.25);
    z-index: 1000;
    overflow: hidden;
    box-sizing: border-box;
    padding: 32px;
    transition: opacity 0.5s ease 0.2s, transform 0.5s ease 0.2s;
}

.layer2-info-container.hidden {
    opacity: 0;
    transform: translateY(-20px);
    pointer-events: none;
}

.layer2-info-container .info-container-text {
    font-family: 'Onest', sans-serif;
    font-size: 18px;
    font-weight: 400;
    line-height: 30px;
    color: #041A31;
    margin: 0 0 16px 0;
}

.layer2-info-container .info-container-cta {
    font-family: 'Onest', sans-serif;
    font-size: 16px;
    font-weight: 400;
    line-height: 30px;
    color: #041A31;
    margin: 0;
}

/* Layer 2 UI elements animation */
.layer-2 .map-close-btn,
.layer-2 .facility-zoom-indicator,
.layer-2 .continue-btn {
    transition: opacity 0.5s ease 0.2s, transform 0.5s ease 0.2s;
}

.layer-2 .map-close-btn.hidden,
.layer-2 .facility-zoom-indicator.hidden,
.layer-2 .continue-btn.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Custom Facility Marker */
.leaflet-facility-marker {
    background: none !important;
    border: none !important;
}

.leaflet-facility-marker .facility-marker-pin {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease;
    display: none;
}

.leaflet-facility-marker .facility-marker-pin svg {
    width: 40px;
    height: 40px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    transition: all 0.2s ease;
}

.leaflet-facility-marker:hover .facility-marker-pin svg,
.leaflet-facility-marker:focus .facility-marker-pin svg {
    fill: #E8890B;
    transform: scale(1.1);
}

/* Facility Tooltip */
.leaflet-facility-tooltip {
    background: rgba(40, 56, 146, 0.95) !important;
    color: #FFFFFF !important;
    border: none !important;
    border-radius: 12px !important;
    padding: 8px 16px !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
}

.leaflet-facility-tooltip::before {
    border-top-color: rgba(40, 56, 146, 0.95) !important;
}

/* =============================================
   Layer 3: Leaflet Area Map with Animated Bus
   ============================================= */

.layer-3 .leaflet-map-container {
    background: #E8F0F8; /* Blue-ish background for area map */
}

/* Custom Bus Marker for Leaflet */
.leaflet-bus-marker {
    background: none !important;
    border: none !important;
    /* Smooth position transitions - duration matches animation speed */
    transition: transform 0.13s linear !important;
}

.leaflet-bus-marker img {
    width: 50px;
    height: auto;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    transition: transform 0.3s ease;
}

/* Location Pin Markers (SEQU & LRT) */
.leaflet-location-marker {
    background: none !important;
    border: none !important;
}

.location-pin {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: 20px;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.location-pin.sequ-pin {
    background: #F9A01B;
    color: #FFFFFF;
}

.location-pin.lrt-pin {
    background: #283892;
    color: #FFFFFF;
}

/* Bus animation trail effect */
.bus-marker-trail {
    position: absolute;
    width: 8px;
    height: 8px;
    background: rgba(249, 160, 27, 0.4);
    border-radius: 50%;
    animation: trailFade 0.5s ease-out forwards;
}

@keyframes trailFade {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0.5);
    }
}

/* =============================================
   Layer 3: Facility Map with Animated Bus
   ============================================= */

.layer-3 {
    background: #E8F4E8; /* Soft green/nature tone */
}

.facility-map-content {
    position: relative;
    width: 1920px;
    height: 1080px;
}

/* Facility Info Card */
.facility-info-card {
    position: fixed;
    top: 100px;
    left: 40px;
    max-width: 320px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    z-index: 50;
}

.facility-info-text {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    line-height: 1.7;
    color: #666666;
    margin: 0;
}

/* Animated Facility Bus */
.animated-facility-bus {
    position: absolute;
    width: 60px;
    height: 39px;
    z-index: 15;
    pointer-events: none;

    /* Follow the facility road path */
    offset-path: path('M 120,580 Q 200,580 280,550 Q 400,500 500,520 Q 650,550 800,530 Q 950,510 1100,540 Q 1250,570 1400,530 Q 1550,490 1700,520');
    offset-rotate: auto;
    offset-anchor: center;

    opacity: 0;
    animation: facilityBusRoute 18s ease-in-out infinite paused;
    transition: opacity 0.5s ease;
}

/* Only animate bus when Layer 3 is active */
.layer-3.active .animated-facility-bus {
    opacity: 1;
    animation-play-state: running;
}

@keyframes facilityBusRoute {
    0% {
        offset-distance: 0%;
    }
    45% {
        offset-distance: 100%;
    }
    50% {
        offset-distance: 100%;
        /* Brief pause at end */
    }
    95% {
        offset-distance: 0%;
    }
    100% {
        offset-distance: 0%;
        /* Brief pause before next trip */
    }
}

/* Facility Zoom Controls Position */
.facility-zoom-controls {
    position: fixed;
    bottom: 120px;
    right: 40px;
    z-index: 100;
}

/* =============================================
   Layer 3 Responsive Styles
   ============================================= */

@media (max-width: 1024px) {
    .facility-info-card {
        top: 80px;
        left: 24px;
        max-width: 280px;
        padding: 20px;
    }

    .facility-info-text {
        font-size: 13px;
    }

    .animated-facility-bus {
        width: 50px;
        height: 32px;
    }

    .facility-zoom-controls {
        right: 24px;
        bottom: 100px;
    }
}

@media (max-width: 768px) {
    .facility-info-card {
        top: auto;
        bottom: 140px;
        left: 16px;
        right: 16px;
        max-width: none;
    }

    .animated-facility-bus {
        width: 40px;
        height: 26px;
        /* Adjust path for smaller screens */
        offset-path: path('M 120,580 Q 200,580 280,550 Q 400,500 500,520 Q 650,550 800,530 Q 950,510 1100,540 Q 1250,570 1400,530 Q 1550,490 1700,520');
    }

    .facility-zoom-controls {
        right: 16px;
        bottom: 80px;
    }
}
