/* ============================================================
   DASHBOARD.CSS - TV full-screen dashboard layout
   Always dark (body.night-mode applied at page load).
   Links styles.css for shared CSS variables and @font-face rules.
   ============================================================ */

/* --- FULL-SCREEN WRAPPER --- */

body.night-mode {
    overflow: hidden;
}

.dash-wrapper {
    height: 100vh;
    padding: 2.5vh 4vw;
    box-sizing: border-box;
    display: grid;
    grid-template-rows: auto 1fr auto auto auto;
    gap: 1vh;
    overflow: hidden;
    position: relative;
}

/* --- HEADER --- */

.dash-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

/* Override h1 centering and size from styles.css */
.dash-title {
    font-family: 'Cinzel', Georgia, serif;
    font-size: clamp(28px, 3.2vw, 9999px);
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--color-accent);
    text-align: left;
    margin: 0;
    text-shadow: 1px 2px 10px rgba(0, 0, 0, 0.7);
}

.dash-clock {
    text-align: right;
    flex-shrink: 0;
    margin-left: 20px;
}

.dash-time {
    font-size: clamp(28px, 3.2vw, 9999px);
    font-weight: 300;
    color: var(--color-text);
    line-height: 1;
    letter-spacing: 0.02em;
}

.dash-date {
    font-size: clamp(14px, 1.5vw, 9999px);
    font-weight: 400;
    color: var(--color-muted);
    margin-top: 4px;
}

/* --- THREE-PANEL GRID --- */

.dash-panels {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.8vw;
    min-height: 0;
}

.dash-panel {
    background: rgba(8, 18, 38, 0.6);
    border: 1px solid var(--color-glass-border);
    border-radius: 10px;
    padding: clamp(10px, 1.4vh, 9999px) clamp(16px, 1.8vw, 9999px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

/* Panel headings - Raleway required (no global h2/h3 rule covers these) */
.dash-panel-heading {
    font-family: 'Raleway', 'Segoe UI', sans-serif;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-accent);
    font-size: clamp(13px, 1.4vw, 9999px);
    margin: 0 0 clamp(8px, 1vh, 9999px) 0;
    padding-bottom: clamp(6px, 0.8vh, 9999px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

/* --- LEFT PANEL --- */

.dash-conditions {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.dash-temp-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

#dash-icon {
    flex-shrink: 0;
    width: clamp(40px, min(6vw, 8vh), 9999px);
    height: clamp(40px, min(6vw, 8vh), 9999px);
}

.dash-temp {
    font-size: clamp(44px, min(7vw, 9vh), 9999px);
    font-weight: 200;
    line-height: 1;
    color: var(--color-text);
    letter-spacing: -0.02em;
}

.dash-description {
    font-size: clamp(14px, 1.6vw, 9999px);
    font-style: italic;
    opacity: 0.8;
    margin-top: 4px;
    flex-shrink: 0;
}

.dash-feels {
    font-size: clamp(12px, 1.3vw, 9999px);
    color: var(--color-muted);
    flex-shrink: 0;
}

.dash-since-dawn {
    font-size: clamp(12px, 1.3vw, 9999px);
    color: var(--color-muted);
    margin-top: 2px;
    flex-shrink: 0;
}

.dash-divider {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin: clamp(8px, 1vh, 9999px) 0;
    flex-shrink: 0;
}

.dash-detail-grid {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.dash-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 3px 0;
    font-size: clamp(12px, 1.35vw, 9999px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.dash-detail-row:last-child {
    border-bottom: none;
}

.dash-detail-label {
    color: var(--color-muted);
    flex-shrink: 0;
    margin-right: 12px;
}

/* --- CENTER PANEL --- */

.dash-compass-container {
    display: flex;
    justify-content: center;
    flex-shrink: 0;
    margin-bottom: 8px;
}

.dash-compass-svg {
    width: clamp(70px, min(9vw, 14vh), 9999px);
    height: clamp(70px, min(9vw, 14vh), 9999px);
    display: block;
}

.dash-wind-readout {
    text-align: center;
    flex-shrink: 0;
    margin-bottom: 4px;
}

.dash-wind-speed {
    font-size: clamp(26px, 3.2vw, 9999px);
    font-weight: 700;
    color: var(--color-text);
    line-height: 1;
}

.dash-wind-dir {
    font-size: clamp(16px, 1.8vw, 9999px);
    color: var(--color-accent);
    font-weight: 500;
    margin-top: 2px;
}

.dash-wind-gusts {
    font-size: clamp(11px, 1.2vw, 9999px);
    color: var(--color-muted);
    margin-top: 3px;
    min-height: 1.4em;
}

.dash-sparkline-label {
    font-family: 'Raleway', 'Segoe UI', sans-serif;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-muted);
    font-size: clamp(10px, 1vw, 9999px);
    margin-bottom: 6px;
    flex-shrink: 0;
}

#dash-sparkline {
    flex-shrink: 0;
}

/* Override inline height set by JS so the sparkline scales with viewport */
#dash-sparkline svg {
    height: clamp(30px, 5vh, 9999px) !important;
}

.dash-pressure-label {
    font-size: clamp(11px, 1.1vw, 9999px);
    color: var(--color-muted);
    margin-top: 4px;
}

.dash-lightning-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: clamp(6px, 0.8vh, 9999px);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-size: clamp(11px, 1.2vw, 9999px);
    flex-shrink: 0;
}

.dash-lightning-label {
    font-family: 'Raleway', 'Segoe UI', sans-serif;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-muted);
    font-size: clamp(10px, 1vw, 9999px);
}

/* --- RIGHT PANEL --- */

.dash-scores {
    display: flex;
    flex-direction: column;
    gap: clamp(10px, 1.6vh, 9999px);
    flex: 1;
    min-height: 0;
    overflow: hidden;
    justify-content: center;
}

.dash-score-item {
    display: flex;
    flex-direction: column;
    gap: clamp(5px, 0.6vh, 9999px);
}

.dash-score-label {
    font-family: 'Raleway', 'Segoe UI', sans-serif;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-size: clamp(12px, 1.3vw, 9999px);
    color: var(--color-accent);
}

.dash-score-bar-row {
    display: flex;
    align-items: center;
    gap: clamp(8px, 1vw, 9999px);
}

.dash-score-bar {
    flex: 1;
    height: clamp(8px, 1.1vh, 9999px);
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    overflow: hidden;
}

.dash-score-bar-fill {
    height: 100%;
    border-radius: 8px;
    transition: width 0.6s ease;
}

.dash-score-number {
    font-size: clamp(28px, 3.2vw, 9999px);
    font-weight: 700;
    line-height: 1;
    min-width: clamp(44px, 4.5vw, 9999px);
    text-align: right;
}

.dash-lake-status {
    margin-top: auto;
    padding-top: clamp(6px, 0.8vh, 9999px);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-size: clamp(11px, 1.2vw, 9999px);
    color: var(--color-muted);
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
}

/* --- DAYLIGHT POSITION BAR --- */

.dash-daylight-section {
    flex-shrink: 0;
}

.dash-daylight-bar-container {
    position: relative;
    height: clamp(6px, 0.9vh, 9999px);
    border-radius: 5px;
    overflow: hidden;
    background: rgba(5, 5, 15, 0.95);
    margin-bottom: clamp(6px, 0.8vh, 9999px);
}

.dash-daylight-bar {
    position: relative;
    width: 100%;
    height: 100%;
}

.dash-daylight-bar .daylight-seg {
    position: absolute;
    top: 0;
    height: 100%;
}

.dash-sun-marker {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: clamp(10px, 1.2vh, 9999px);
    height: clamp(10px, 1.2vh, 9999px);
    background: #FFD700;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.7), 0 0 16px rgba(255, 215, 0, 0.3);
    z-index: 2;
    transition: left 1s linear;
}

.dash-daylight-meta {
    display: flex;
    align-items: center;
    gap: clamp(12px, 2vw, 9999px);
    flex-wrap: wrap;
    font-size: clamp(12px, 1.3vw, 9999px);
    color: var(--color-muted);
}

.dash-daylight-item {
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.dash-daylight-countdown {
    color: var(--color-text);
    font-weight: 500;
}

/* --- 5-DAY FORECAST STRIP --- */

.dash-forecast-strip {
    display: flex;
    gap: clamp(6px, 0.8vw, 9999px);
    flex-shrink: 0;
}

.dash-forecast-day {
    flex: 1;
    text-align: center;
    padding: clamp(6px, 0.8vh, 9999px) clamp(4px, 0.5vw, 9999px);
    border-radius: 8px;
    background: rgba(8, 18, 38, 0.5);
    border: 1px solid var(--color-glass-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.dash-forecast-day.dash-forecast-best {
    border-color: var(--color-best-border);
    background: var(--color-best-bg);
}

.dash-forecast-day-name {
    font-size: clamp(12px, 1.3vw, 9999px);
    font-weight: 500;
    color: var(--color-muted);
}

.dash-forecast-day.dash-forecast-best .dash-forecast-day-name {
    color: var(--color-accent);
}

.dash-forecast-day img {
    width: clamp(28px, 3vw, 9999px);
    height: clamp(28px, 3vw, 9999px);
}

.dash-forecast-hilo {
    font-size: clamp(14px, 1.5vw, 9999px);
    font-weight: 500;
    color: var(--color-text);
}

.dash-forecast-best-label {
    font-size: clamp(10px, 1vw, 9999px);
    color: var(--color-accent);
    font-weight: 600;
}

/* --- FOOTER --- */

.dash-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: clamp(12px, 1.3vw, 9999px);
    color: var(--color-muted);
    position: relative;
    flex-shrink: 0;
}

.dash-exit {
    color: var(--color-muted);
    text-decoration: none;
    opacity: 0.6;
    font-size: clamp(12px, 1.2vw, 9999px);
    transition: opacity 0.2s;
}

.dash-exit:hover {
    opacity: 1;
    text-decoration: underline;
}

/* Lightning banner: absolutely overlays the footer row */
.dash-lightning-banner {
    position: absolute;
    inset: -8px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: clamp(14px, 1.6vw, 9999px);
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 0 20px;
    z-index: 10;
}

.dash-lightning-banner[hidden] {
    display: none;
}

.dash-lightning-banner.warn-red {
    background: rgba(180, 20, 20, 0.92);
    color: #fff;
    box-shadow: 0 0 20px rgba(220, 50, 50, 0.4);
}

.dash-lightning-banner.warn-amber {
    background: rgba(180, 100, 10, 0.92);
    color: #fff;
    box-shadow: 0 0 20px rgba(200, 130, 30, 0.4);
}

/* --- LIGHTNING FLASH OVERLAY (Phase B) --- */

.dash-flash-overlay {
    position: fixed;
    inset: 0;
    background: white;
    opacity: 0;
    pointer-events: none;
    z-index: 9999;
    will-change: opacity;
}

@keyframes lightning-flash {
    0%   { opacity: 0; }
    15%  { opacity: 0.12; }
    100% { opacity: 0; }
}

.dash-flash-overlay.flashing {
    animation: lightning-flash 0.4s ease-out forwards;
}

/* --- AUTO-DIM --- */

body.auto-dim {
    filter: brightness(0.55);
    transition: filter 2s ease;
}

body {
    transition: filter 2s ease, background-color 0.5s ease;
}

/* --- SHARED UTILITIES --- */

.dash-muted {
    color: var(--color-muted);
}

/* --- TIGHT LAYOUT: reduce spacing when viewport height <= 800px (720p) --- */

@media (max-height: 800px) {
    .dash-wrapper {
        padding: 1.5vh 4vw;
        gap: 0.7vh;
    }

    .dash-panel {
        padding: clamp(8px, 1vh, 9999px) clamp(16px, 1.8vw, 9999px);
    }

    .dash-panel-heading {
        margin: 0 0 clamp(6px, 0.7vh, 9999px) 0;
        padding-bottom: clamp(4px, 0.5vh, 9999px);
    }

    .dash-divider {
        margin: clamp(6px, 0.7vh, 9999px) 0;
    }

    .dash-detail-row {
        padding: 2px 0;
    }

    .dash-description {
        margin-top: 2px;
    }
}

/* --- RESPONSIVE: single column below 768px --- */

@media (max-width: 768px) {
    body.night-mode {
        overflow-y: auto;
    }

    .dash-wrapper {
        height: auto;
        overflow: visible;
        padding: 4% 4%;
        grid-template-rows: auto auto auto auto auto;
        gap: 12px;
    }

    .dash-panels {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .dash-panel {
        min-height: auto;
    }

    .dash-scores {
        overflow: visible;
    }

    .dash-forecast-strip {
        flex-wrap: wrap;
    }

    .dash-forecast-day {
        flex: 1 1 30%;
        min-width: 0;
    }
}
