/* =========================================
   1. CSS VARIABLES & RESET
   ========================================= */
:root {
    /* --- Colors: Backgrounds --- */
    --bg-body: #121212;
    --bg-header: rgba(18, 18, 18, 0.95);
    --bg-panel: rgba(20, 20, 20, 0.95);
    --bg-card: #222222;
    --bg-card-hover: #2a2a2a;
    --bg-stat: #252525;

    /* --- Colors: Text --- */
    --text-main: #ffffff;
    --text-muted: #aaaaaa;
    --text-dim: #666666;

    /* --- Colors: Brand & UI --- */
    --color-primary: #007bff;
    --color-primary-hover: #0056b3;
    --border-color: #333333;
    --shadow-soft: 0 4px 15px rgba(0, 0, 0, 0.5);
    --shadow-deep: -5px 0 25px rgba(0, 0, 0, 0.8);

    /* --- Colors: Trail Difficulties --- */
    --diff-green: #00cc66;
    --diff-blue: #007bff;
    --diff-black: #aaaaaa;
    --diff-double: #d9534f;

    /* --- Colors: Status Lines --- */
    --status-open: #00ff00;
    --status-closed: #ff0000;
    --status-hold: #ffff00;
    --status-partial: #ffcc00;
    --status-school: #ffa500;
    --status-unknown: #999999;
    --lift-open: #002aff;
    /* Cyan/Blue for Open Lifts */
    --lift-closed: #5a0876;
    /* Purple for Closed Lifts */

    /* --- Dimensions --- */
    --header-height: auto;
    --panel-width: 350px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background-color: var(--bg-body);
    background: url(images/wp-alpenglow.jpg) top center no-repeat;
    background-size: cover;
    color: var(--text-main);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    height: 100vh;
    overflow: visible;
    /* App-like feel */
    display: flex;
    flex-direction: column;
}

/* Utility Classes for JS Toggling */
.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

/* =========================================
   2. RESORT MENU (Landing Page)
   ========================================= */
#resort-menu {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    overflow-y: auto;
}

.menu-container {
    text-align: center;
    padding-bottom: 40px;
}

.menu-title {
    font-size: 3rem;
    margin-bottom: 40px;
    letter-spacing: 1px;
}

#resort-list {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    padding: 0 20px;
}

.resort-card {
    display: block;
    background-color: var(--bg-card);
    width: 280px;
    padding: 15px;
    text-decoration: none;
    color: var(--text-main);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    transition: transform 0.2s, background-color 0.2s, border-color 0.2s;
    box-shadow: var(--shadow-soft);
}

.resort-card:hover {
    transform: translateY(-5px);
    border-color: var(--color-primary);
    background-color: var(--bg-card-hover);
}

.resort-card h2 {
    margin-top: 0;
    font-size: 1.4rem;
}

/* =========================================
   3. HEADER & HUD
   ========================================= */
.header {
    padding: 10px 20px;
    background-color: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    z-index: 50;
    backdrop-filter: blur(5px);
    flex-shrink: 0;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.page-title {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Buttons & Links */
.back-btn {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: color 0.2s;
}

.back-btn:hover {
    color: var(--text-main);
}

#dashboard-toggle {
    background-color: var(--color-primary);
    color: var(--text-main);
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s;
}

#dashboard-toggle:hover {
    background-color: var(--color-primary-hover);
}

.timestamp {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-align: center;
    margin-bottom: 12px;
    font-style: italic;
}

/* Legend */
.legend {
    font-size: 0.75rem;
    margin-top: 10px;
    color: var(--text-muted);
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
}

.legend span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* HUD Grid */
#hud {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.stat-box {
    background-color: var(--bg-stat);
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 100px;
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-main);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* =========================================
   4. SLIDING DASHBOARD (Glassmorphism)
   ========================================= */
#dashboard-panel {
    position: fixed;
    top: 0;
    right: calc(var(--panel-width) * -1);
    /* Hide off screen */
    width: var(--panel-width);
    height: 100vh;
    background-color: var(--bg-panel);
    backdrop-filter: blur(12px);
    border-left: 1px solid var(--border-color);
    z-index: 200;
    transition: right 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-deep);
}

#dashboard-panel.active {
    right: 0;
}

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

.panel-header h2 {
    margin: 0;
    font-size: 1.2rem;
    letter-spacing: 0.5px;
}

.close-panel {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.8rem;
    cursor: pointer;
    line-height: 1;
}

.close-panel:hover {
    color: var(--text-main);
}

#dashboard-content {
    padding: 25px;
    overflow-y: auto;
    flex-grow: 1;
}

/* Dashboard Internal Components */
.db-section {
    margin-bottom: 35px;
}

.db-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
    margin-bottom: 15px;
    letter-spacing: 1px;
}

.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    font-size: 0.9rem;
}

.stat-item span {
    display: block;
}

.stat-item .val {
    font-weight: bold;
    font-size: 1.1rem;
    margin-top: 4px;
}

/* Difficulty Bars */
.diff-row {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    font-size: 0.85rem;
}

.diff-label {
    width: 70px;
    color: var(--text-muted);
}

.diff-bar-bg {
    flex-grow: 1;
    height: 6px;
    background: var(--border-color);
    border-radius: 10px;
    margin: 0 12px;
    overflow: hidden;
}

.diff-bar-fill {
    height: 100%;
    border-radius: 10px;
}

.diff-val {
    width: 40px;
    text-align: right;
    font-family: monospace;
    font-weight: bold;
}

/* Background Utility Classes */
.bg-green {
    background-color: var(--diff-green);
}

.bg-blue {
    background-color: var(--diff-blue);
}

.bg-black {
    background-color: var(--diff-black);
}

.bg-double {
    background-color: var(--diff-double);
}

/* Forecast Grid */
.forecast-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    text-align: center;
}

.fc-day {
    background-color: var(--bg-stat);
    padding: 8px 4px;
    border-radius: 6px;
    font-size: 0.85rem;
}

.fc-date {
    color: var(--text-muted);
    font-size: 0.7rem;
    margin-bottom: 6px;
    text-transform: uppercase;
}

.fc-icon {
    font-size: 1rem;
    margin-bottom: 6px;
    color: var(--text-main);
}

.fc-temp {
    font-weight: bold;
}

.fc-low {
    font-size: 0.7rem;
    color: var(--text-dim);
}

/* =========================================
   5. MAP & SVG OVERLAY
   ========================================= */
#app {
    position: relative;
    flex-grow: 1;
    /* Take remaining height */
    width: 100%;
    overflow: auto;
    /* Scrollable */
    background-color: #000;
    display: flex;
    justify-content: center;
    /* Center horizontally */
}

/* Shrink Wrap Container */
#map-wrapper {
    position: relative;
    width: 100%;
    max-width: 2000px;
    /* Prevent infinite growth on 4k */
    height: fit-content;
}

#trail-map {
    width: 100%;
    display: block;
    height: auto;
    pointer-events: none;
    /* Let clicks pass to SVG */
}

#status-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

/* Polyline Styles */
polyline {
    pointer-events: stroke;
    /* Only click on the line itself */
    fill: none;
    stroke-width: 5px;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
    transition: stroke-width 0.2s, opacity 0.2s, stroke 0.2s;
    cursor: pointer;
    opacity: 0.6;
}

polyline.type-lift {
    stroke-dasharray: 10, 5;
    opacity: 0.9;
}

polyline:hover {
    stroke-width: 12px;
    opacity: 1;
    z-index: 20;
    filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.9));
}

/* =========================================
   STATUS COLORS
   ========================================= */

/* 1. Default Styles (Trails) */
.status-open {
    stroke: var(--status-open);
}

.status-closed {
    stroke: var(--status-closed);
}

.status-hold {
    stroke: var(--status-hold);
}

.status-partial,
.status-lower_open,
.status-upper_open {
    stroke: var(--status-partial);
}

.status-open_ski_ride_school_only {
    stroke: var(--status-school);
}

.status-unknown {
    stroke: var(--status-unknown);
}

/* 2. Specific Overrides for LIFTS */
/* These rules only apply if the line has BOTH classes */

/* Open Lift -> Blue */
polyline.type-lift.status-open,
polyline.type-lift.status-scheduled {
    stroke: var(--lift-open);
}

/* Closed Lift -> Purple */
polyline.type-lift.status-closed {
    stroke: var(--lift-closed);
}

/* Hold/Partial Lift -> Keep Yellow/Orange (or define new var if you want) */
polyline.type-lift.status-hold {
    stroke: var(--status-hold);
}

/* Tooltip */
#tooltip {
    position: fixed;
    background: rgba(0, 0, 0, 0.95);
    color: var(--text-main);
    padding: 10px 15px;
    border-radius: 6px;
    pointer-events: none;
    display: none;
    z-index: 1000;
    font-size: 0.9rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-soft);
}

/* =========================================
   6. MOBILE & RESPONSIVE
   ========================================= */
@media (max-width: 768px) {

    /* Resort Menu */
    .menu-title {
        font-size: 2rem;
    }

    /* Header Stack */
    .header-top {
        flex-wrap: wrap;
        gap: 10px;
    }

    .page-title {
        order: 1;
        width: 100%;
        text-align: center;
        margin-bottom: 10px;
    }

    .back-btn {
        order: 2;
    }

    #dashboard-toggle {
        order: 3;
        padding: 6px 12px;
    }

    /* HUD on Mobile: Horizontal Scroll */
    #hud {
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 5px;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        /* Smooth scroll iOS */
    }

    .stat-box {
        flex-shrink: 0;
        /* Prevent squishing */
    }

    /* Dashboard Panel: Full Width */
    #dashboard-panel {
        width: 100%;
        right: -100%;
    }

    /* Legend: Simplify */
    .legend {
        font-size: 0.7rem;
        gap: 10px;
    }

    polyline {
        stroke-width: 2px;
    }
}