/**
 * Wadjemup Rottnest Bathymetry Visualization
 * Styles for the interactive depth map
 */

/* ============================================
   Reset & Base
   ============================================ */

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

body {
    font-family: 'JetBrains Mono', monospace;
    background: #f5f5f0;
    color: #1a1a1a;
    overflow: hidden;
}

/* ============================================
   Map Container
   ============================================ */

#map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* ============================================
   Overlay System
   ============================================ */

.overlay {
    position: absolute;
    z-index: 100;
    pointer-events: none;
}

/* ============================================
   Back Link
   ============================================ */

.back-link {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 101;
    font-size: 0.75rem;
    color: rgba(0, 0, 0, 0.5);
    text-decoration: none;
    transition: color 0.2s ease;
}

.back-link:hover {
    color: #2563eb;
}

/* ============================================
   Header & Title Card
   ============================================ */

.header {
    top: 50px;
    left: 20px;
    right: 20px;
    z-index: 600;
    /* Above POIs (500) */
}

.title-card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    padding: 20px 24px;
    display: inline-block;
    pointer-events: auto;
}

.title-card h1 {
    font-family: 'Instrument Serif', serif;
    font-size: 1.8rem;
    font-weight: 400;
    margin-bottom: 4px;
    color: #1e40af;
}

.title-card .subtitle {
    font-size: 0.75rem;
    color: rgba(0, 0, 0, 0.5);
    font-weight: 300;
}

.methods-link {
    display: inline-block;
    margin-top: 8px;
    font-size: 0.65rem;
    color: rgba(0, 0, 0, 0.4);
    text-decoration: none;
    transition: color 0.2s ease;
}

.methods-link:hover {
    color: #1e40af;
}

/* ============================================
   Location Button
   ============================================ */

.location-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 601;
    /* Above POIs and header */
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(0, 0, 0, 0.6);
    transition: all 0.2s ease;
}

.location-btn:hover {
    background: rgba(255, 255, 255, 1);
    color: #1e40af;
}

.location-btn.active {
    color: #1e40af;
    border-color: rgba(30, 64, 175, 0.3);
}

/* User location marker */
.user-location-marker {
    position: relative;
    width: 24px;
    height: 24px;
}

.location-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    background: #1e40af;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* Viewing cone indicator (Google Maps style) */
.location-heading {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60px;
    height: 60px;
    background: conic-gradient(from -30deg,
            transparent 0deg,
            rgba(30, 64, 175, 0.25) 0deg,
            rgba(30, 64, 175, 0.15) 30deg,
            rgba(30, 64, 175, 0.25) 60deg,
            transparent 60deg);
    border-radius: 50%;
    transform-origin: center center;
    transform: translate(-50%, -50%) rotate(-90deg);
    display: none;
    pointer-events: none;
}

/* ============================================
   Legend
   ============================================ */

.legend {
    bottom: 30px;
    left: 20px;
    z-index: 600;
    /* Ensure above POIs (500) */
}

.legend-card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    padding: 16px 20px;
    pointer-events: auto;
}

.legend-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(0, 0, 0, 0.5);
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    margin-bottom: 10px;
}

.legend-bar {
    width: 200px;
    height: 16px;
    border-radius: 4px;
    margin-bottom: 6px;
}

.legend-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: rgba(0, 0, 0, 0.7);
}

/* ============================================
   Cursor Depth (in Legend)
   ============================================ */

.cursor-depth-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.cursor-depth-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(0, 0, 0, 0.5);
}

.cursor-depth-value {
    font-size: 1.4rem;
    font-weight: 300;
    background: linear-gradient(135deg, #1e40af, #047857);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.cursor-depth-unit {
    font-size: 0.75rem;
    color: rgba(0, 0, 0, 0.5);
}

.cursor-coords {
    font-size: 0.6rem;
    color: rgba(0, 0, 0, 0.45);
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
}

/* ============================================
   Click Marker
   ============================================ */

.click-marker {
    width: 14px;
    height: 14px;
    background: #1e40af;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 1000;
}

.click-marker:active {
    transform: scale(0.9);
}

/* POI markers */
.poi-marker {
    pointer-events: none;
    z-index: 500;
}

.poi-label {
    font-family: 'Instrument Serif', serif;
    font-style: italic;
    font-size: 0.85rem;
    color: rgba(30, 64, 175, 0.7);
    white-space: nowrap;
    text-shadow:
        0 0 4px rgba(255, 255, 255, 0.9),
        0 0 8px rgba(255, 255, 255, 0.6);
}

/* ============================================
   MapLibre Popup Styles
   ============================================ */

.maplibregl-popup {
    z-index: 1000 !important;
}

.maplibregl-popup-content {
    background: #ffffff !important;
    border-radius: 8px !important;
    padding: 12px 16px !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2) !important;
    font-family: 'JetBrains Mono', monospace;
}

.maplibregl-popup-close-button {
    font-size: 16px;
    color: rgba(0, 0, 0, 0.4);
    padding: 4px 8px;
}

.popup-depth {
    font-size: 1.3rem;
    font-weight: 300;
    background: linear-gradient(135deg, #1e40af, #047857);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.popup-unit {
    font-size: 0.8rem;
}

.popup-coords {
    font-size: 0.7rem;
    color: #1e40af;
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
}

.popup-coords-dm {
    font-size: 0.6rem;
    color: rgba(0, 0, 0, 0.5);
    margin-top: 2px;
}

.popup-share-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding: 6px 12px;
    background: rgba(30, 64, 175, 0.1);
    border: 1px solid rgba(30, 64, 175, 0.2);
    border-radius: 6px;
    color: #1e40af;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.popup-share-btn:hover {
    background: rgba(30, 64, 175, 0.2);
}

.popup-share-btn svg {
    flex-shrink: 0;
}

/* ============================================
   Copyable Elements
   ============================================ */

.copyable {
    cursor: pointer;
    user-select: all;
    transition: background 0.2s ease;
    padding: 1px 4px;
    margin: -1px -4px;
    border-radius: 3px;
}

.copyable:hover {
    background: rgba(30, 64, 175, 0.1);
}

/* ============================================
   Loading Status (Floating Text)
   ============================================ */

.loading-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    /* No background/box */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

.loading-overlay.hidden {
    opacity: 0;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(30, 64, 175, 0.2);
    border-top-color: #1e40af;
    border-radius: 50%;
    animation: spin 1s cubic-bezier(0.55, 0.055, 0.675, 0.19) infinite;
    margin-bottom: 16px;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.loading-text {
    font-family: 'Instrument Serif', serif;
    font-style: italic;
    font-size: 1.5rem;
    font-weight: 400;
    color: #1e40af;
    text-shadow:
        0 0 20px rgba(255, 255, 255, 0.9),
        0 0 10px rgba(255, 255, 255, 0.8);
    white-space: nowrap;
    letter-spacing: 0.02em;
}

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

/* ============================================
   Mobile Responsive & Info Toggle
   ============================================ */

.info-btn {
    display: none;
    /* Hidden by default (Desktop) */
    position: absolute;
    top: 66px;
    /* Below location button */
    right: 20px;
    width: 36px;
    height: 36px;
    z-index: 101;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    color: #1e40af;
    font-family: 'Instrument Serif', serif;
    font-style: italic;
    font-size: 1.2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

@media (max-width: 768px) {

    /* Hide the info button - not needed */
    .info-btn {
        display: none;
    }

    /* Force MapLibre attribution to always be collapsed on mobile */
    .maplibregl-ctrl-attrib.maplibregl-compact {
        display: block;
    }

    .maplibregl-ctrl-attrib.maplibregl-compact::after {
        content: '';
        display: block;
    }

    .maplibregl-ctrl-attrib-inner {
        display: none;
    }

    .maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-inner {
        display: block;
    }

    /* Mobile Typography Adjustments */
    .title-card h1 {
        font-size: 1.2rem;
    }

    .title-card {
        padding: 14px 18px;
    }

    /* Hide "At cursor" section on mobile (users tap instead of hover) */
    .cursor-depth {
        display: none;
    }

    /* Remove the border separator since cursor section is hidden */
    .legend-title {
        margin-top: 0;
        padding-top: 0;
        border-top: none;
    }

    .legend-card {
        padding: 12px 16px;
    }

    .legend-bar {
        width: 150px;
    }
}

/* ============================================
   MapLibre Attribution - Force Compact
   ============================================ */

/* Force attribution to always be in compact mode */
.maplibregl-ctrl-attrib {
    display: none !important;
}

.maplibregl-ctrl-attrib.maplibregl-compact {
    display: block !important;
    min-height: 20px;
    background-color: rgba(255, 255, 255, 0.5);
    border-radius: 12px;
}

.maplibregl-ctrl-attrib-button {
    display: block !important;
}

/* Hide the inner text by default */
.maplibregl-ctrl-attrib:not(.maplibregl-compact-show) .maplibregl-ctrl-attrib-inner {
    display: none;
}

/* ============================================
   Context Menu (Right Click)
   ============================================ */

.context-menu {
    position: absolute;
    z-index: 2000;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    padding: 6px 0;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    min-width: 180px;
    font-size: 0.8rem;
    color: #1a1a1a;
    pointer-events: auto;
}

.context-menu-item {
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.context-menu-item:hover {
    background: rgba(30, 64, 175, 0.1);
    color: #1e40af;
}

.context-menu-separator {
    height: 1px;
    background: rgba(0, 0, 0, 0.1);
    margin: 4px 0;
}