@tailwind base;
@tailwind components;
@tailwind utilities;

/* Brand tokens — matches the wheres-marin.com landing page */
:root {
    --n-ground: #0b0d0a;
    --n-panel: rgba(13, 16, 11, 0.93);
    --n-surface: #161a12;
    --n-ink: #f2f4ec;
    --n-muted: #99a08f;
    --n-lime: #d4fd1d;
    --n-hairline: rgba(242, 244, 236, 0.14);
    --n-disp: 'Barlow Condensed', 'Arial Narrow', sans-serif;
    --n-body: 'Barlow', system-ui, sans-serif;
}

html,
body,
#cesiumContainer {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
}

body {
    font-family: var(--n-body);
    background: var(--n-ground);
}

/* ---------- loading screen ---------- */

#loadingScreen {
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: var(--n-ground);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    transition: opacity 0.5s ease;
}

.loading-mark {
    font-family: var(--n-disp);
    font-weight: 600;
    font-size: 34px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--n-ink);
}

.loading-mark span { color: var(--n-lime); }

.loading-bar {
    width: 190px;
    height: 2px;
    background: var(--n-hairline);
    overflow: hidden;
}

.loading-bar span {
    display: block;
    width: 40%;
    height: 100%;
    background: var(--n-lime);
    animation: loading-scan 1.2s ease-in-out infinite;
}

@keyframes loading-scan {
    0% { transform: translateX(-110%); }
    100% { transform: translateX(360%); }
}

#loadingText {
    font-size: 12px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--n-muted);
}

/* ---------- control panel ---------- */

.toggleContainer {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1;
    background: var(--n-panel);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    color: var(--n-ink);
    padding: 12px;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 190px;
    max-height: 1000px;
    transition: all 0.3s ease;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

.marker-icon {
    width: 20px;
    height: 20px;
    vertical-align: middle;
    margin-right: 5px;
}

.toggleButton {
    width: 130px;
}

.distanceContainer {
    position: relative;
    background: rgba(242, 244, 236, 0.06);
    border-radius: 10px;
    padding: 8px;
    margin-top: 5px;
    transition: max-height 0.3s ease-in-out;
    white-space: nowrap;
    max-height: 1000px;
    overflow: visible;
}

.distanceText {
    white-space: pre-wrap;
    font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    font-size: 14px;
    line-height: 1.5;
    color: var(--n-ink);
}

.minimizeButton {
    position: absolute;
    top: 6px;
    right: 6px;
    padding: 8px;
    cursor: pointer;
    background: rgba(242, 244, 236, 0.1);
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
}

.minimizeButton:hover {
    background: rgba(242, 244, 236, 0.22);
    transform: scale(1.1);
}

.minimizeButton svg {
    width: 16px;
    height: 16px;
    color: var(--n-ink);
}

#controls {
    width: 100%;
    height: 10%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

@media (min-width: 768px) {
    .dropdown {
        width: auto;
    }
}

/* ---------- corner nav buttons ---------- */

.btn-container {
    position: absolute;
    bottom: 20px;
    left: 10px;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
}

.gearBtn {
    padding: 10px 18px;
    border-radius: 25px;
    border: 1px solid var(--n-hairline);
    background: var(--n-panel);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    color: var(--n-ink);
    font-family: var(--n-body);
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.25s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.gearBtn:hover {
    transform: translateY(-2px);
    border-color: var(--n-lime);
    color: var(--n-lime);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.gearBtn--live {
    background: var(--n-lime);
    border-color: var(--n-lime);
    color: #0b0d0a;
}

.gearBtn--live:hover {
    color: #0b0d0a;
    filter: brightness(1.08);
}

.liveDot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #0b0d0a;
    animation: livePulse 2.2s ease-in-out infinite;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ---------- day selector dropdown ---------- */

.dropdown {
    position: relative;
    width: 100%;
    margin-top: 10px;
}

/* extra specificity: these must beat the Tailwind utility classes
   (bg-gray-300, bg-white, text-gray-700) loaded after this file */
.dropdown .dropdown-button {
    width: 100%;
    padding: 8px 12px;
    background-color: var(--n-surface);
    color: var(--n-ink);
    border: 1px solid var(--n-hairline);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dropdown .dropdown-button:hover {
    border-color: var(--n-lime);
}

.dropdown .dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--n-surface);
    color: var(--n-ink);
    border: 1px solid var(--n-hairline);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1001;
    margin-top: 2px;
}

.dropdown .dropdown-menu a {
    display: block;
    padding: 10px 15px;
    color: var(--n-ink);
    text-decoration: none;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid rgba(242, 244, 236, 0.08);
}

.dropdown .dropdown-menu a:hover {
    background-color: rgba(212, 253, 29, 0.12);
}

.dropdown .dropdown-menu a:last-child {
    border-bottom: none;
}

.dropdown-menu::-webkit-scrollbar-track {
    background-color: transparent;
}

.dropdown-menu::-webkit-scrollbar-thumb {
    background-color: rgba(242, 244, 236, 0.25);
    border-radius: 10px;
}

.dropdown-menu::-webkit-scrollbar {
    width: 8px;
    background-color: transparent;
}

.cesium-infoBox-iframe {
    min-height: 300px !important;
    height: auto !important;
}

/* ---------- photo popup ---------- */

#popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 7, 4, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(3px);
}

.popup-content {
    background: white;
    border-radius: 10px;
    max-width: 90%;
    max-height: 90vh;
    overflow: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

@media (max-width: 640px) {
    .popup-content {
        width: 95%;
        max-height: 95vh;
        overflow: scroll;
    }

    .btn-container {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 5px;
    }

    .gearBtn {
        font-size: 12px;
        padding: 8px 12px;
    }

    .toggleContainer {
        max-width: calc(100vw - 20px);
    }

    .loading-mark { font-size: 26px; }
}

.close-button {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: rgba(217, 83, 79, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    padding: 10px;
    transition: all 0.2s ease;
    z-index: 10;
}

.close-button:hover {
    background-color: rgba(217, 83, 79, 1);
    transform: scale(1.1);
}

.fa {
    font-size: 40px !important;
    width: 46px;
    height: 46px;
    text-align: center;
    text-decoration: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    background: var(--n-panel);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid var(--n-hairline);
    color: var(--n-ink);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.fa:hover {
    color: var(--n-lime);
    border-color: var(--n-lime);
    transform: scale(1.08);
}

/* ---------- elevation chart (Chart.js draws dark-on-light, keep it light) ---------- */

#elevationContainer {
    position: fixed;
    bottom: 20px;
    right: 20px;
    min-width: 50%;
    height: 200px;
    background-color: #fdfdfb;
    border: none;
    padding: 10px;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    z-index: 999;
    transition: all 0.3s ease;
}

/* Utility classes */
.hidden {
    display: none !important;
}

.smooth-transition {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Focus styles for accessibility */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--n-lime);
    outline-offset: 2px;
}

/* Custom checkbox styles */
input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    cursor: pointer;
    accent-color: var(--n-lime);
}

/* Info label styling */
.toggleContainer > span:first-of-type {
    font-family: var(--n-disp);
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--n-lime);
    margin-bottom: 5px;
}

/* Marker label improvements */
.toggleContainer label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 4px 0;
    font-size: 14px;
    line-height: 1.4;
    color: var(--n-ink);
    transition: opacity 0.2s ease;
}

.toggleContainer label:hover {
    opacity: 0.8;
}

/* Better spacing for flex items */
.flex.items-center {
    align-items: center;
    gap: 8px;
}

/* Loading state styles */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(242, 244, 236, 0.2);
    border-top: 3px solid var(--n-lime);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ---------- year (trip) selector ---------- */

.year-selector {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 0;
    border-bottom: 1px solid var(--n-hairline);
    margin-bottom: 12px;
}

.year-selector label {
    font-weight: 600;
    color: var(--n-muted);
    font-size: 13px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.year-dropdown {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--n-hairline);
    border-radius: 8px;
    background-color: var(--n-surface);
    color: var(--n-ink);
    font-family: var(--n-body);
    font-size: 14px;
    transition: border-color 0.2s ease;
    cursor: pointer;
}

.year-dropdown:focus {
    outline: none;
    border-color: var(--n-lime);
    box-shadow: 0 0 0 2px rgba(212, 253, 29, 0.2);
}

.year-dropdown:hover {
    border-color: var(--n-lime);
}

@media (prefers-reduced-motion: reduce) {
    .loading-bar span,
    .liveDot,
    .loading::after {
        animation: none;
    }
}
