/* ================================================
   EMMAVILLE WEATHER STATION - Premium Dark Theme
   ================================================ */

:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: #1a1f35;
    --bg-card-hover: #1f2545;
    --border: rgba(255,255,255,0.06);
    --text-primary: #e8ecf4;
    --text-secondary: #8892a8;
    --text-muted: #5a6478;
    --accent-blue: #00b4d8;
    --accent-orange: #f8961e;
    --accent-red: #e63946;
    --accent-green: #2dc653;
    --accent-purple: #7b2ff7;
    --glow-blue: rgba(0, 180, 216, 0.15);
    --glow-orange: rgba(248, 150, 30, 0.15);
    --needle: #e63946;
    --needle-cap: #2a3050;
    --gauge-bg: rgba(255,255,255,0.06);
    --gauge-track: rgba(255,255,255,0.08);
    --font-display: 'Orbitron', monospace;
    --font-body: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
    --radius: 16px;
    --radius-sm: 10px;
}

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

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 0;
}

/* ---- HEADER ---- */
.station-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-card) 100%);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 16px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.station-name {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 2px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.station-location {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 4px;
}

/* Header weather condition icon */
.header-scene {
    position: relative;
    z-index: 1;
    width: 60px;
    height: 60px;
    flex-shrink: 0;
}

.header-scene img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 0 8px rgba(255,255,255,0.15));
}

.header-right { text-align: right; }

.last-updated {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    justify-content: flex-end;
}

.update-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
    animation: pulse-green 2s ease-in-out infinite;
    transition: background 0.5s;
}

.update-dot.stale-warn {
    background: var(--accent-orange);
    animation: pulse-orange 2s ease-in-out infinite;
}

.update-dot.stale-error {
    background: var(--accent-red);
    animation: pulse-red 1.5s ease-in-out infinite;
}

@keyframes pulse-green {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(45,198,83,0.4); }
    50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(45,198,83,0); }
}

@keyframes pulse-orange {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(248,150,30,0.4); }
    50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(248,150,30,0); }
}

@keyframes pulse-red {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(230,57,70,0.4); }
    50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(230,57,70,0); }
}

.header-date {
    font-family: var(--font-display);
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-top: 4px;
}

@media (max-width: 600px) {
    .header-scene { height: 50px; }
}

/* ---- GAUGE ROW ---- */
.gauge-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    padding: 24px 30px;
}

.gauge-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 30px 16px 16px;
    text-align: center;
    transition: background 0.3s, box-shadow 0.3s;
    position: relative;
}

.gauge-panel:hover {
    background: var(--bg-card-hover);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.gauge-title {
    position: absolute;
    top: -1px;
    left: -1px;
    font-family: var(--font-display);
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius) 0 var(--radius-sm) 0;
    padding: 3px 10px;
    line-height: 1.4;
    z-index: 1;
}

.gauge-wrapper {
    position: relative;
    width: 100%;
    max-width: 200px;
    margin: 0 auto;
}

.gauge-svg { width: 100%; height: auto; display: block; overflow: visible; }

/* Gauge arcs */
.gauge-bg {
    fill: none;
    stroke: var(--gauge-track);
    stroke-width: 12;
    stroke-linecap: round;
}

.gauge-fill-group path {
    /* Individual segment paths — colors set inline by JS */
}

/* Tick marks */
.gauge-ticks line {
    stroke: var(--text-muted);
    stroke-width: 1;
}

.gauge-ticks text {
    fill: var(--text-muted);
    font-size: 8px;
    font-family: var(--font-body);
    text-anchor: middle;
    dominant-baseline: central;
}

.gauge-ticks .gauge-label-outer {
    fill: var(--text-secondary);
    font-size: 7.5px;
    font-family: var(--font-display);
    font-weight: 500;
    letter-spacing: 0.3px;
}

/* Needle */
.needle-line {
    stroke: var(--needle);
    stroke-width: 2.5;
    stroke-linecap: round;
    filter: drop-shadow(0 0 4px rgba(230, 57, 70, 0.5));
    transition: transform 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.needle-cap {
    fill: var(--needle-cap);
    stroke: rgba(255,255,255,0.2);
    stroke-width: 1;
}

.needle-cap-inner {
    fill: var(--accent-red);
    filter: drop-shadow(0 0 4px rgba(230, 57, 70, 0.5));
}

.gauge-needle {
    transform-origin: 100px 100px;
    transition: transform 1.5s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Reading display */
.gauge-reading {
    position: absolute;
    bottom: 22%;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    pointer-events: none;
}

.gauge-value {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.gauge-unit {
    font-family: var(--font-display);
    font-size: 0.65rem;
    color: var(--text-secondary);
    letter-spacing: 1px;
}

#pressGauge ~ .gauge-reading {
    bottom: 18%;
}

.gauge-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 14px;
}

.gauge-subtitle span { color: var(--text-primary); font-weight: 500; }

/* Pressure zone labels */
.press-zone {
    fill: var(--text-muted);
    font-size: 7px;
    font-family: var(--font-body);
    text-anchor: middle;
    dominant-baseline: central;
}

/* ---- COMPASS ---- */
.compass-wrapper { max-width: 220px; }

.compass-ring {
    fill: none;
    stroke: rgba(255,255,255,0.1);
    stroke-width: 2;
}

.compass-ring-inner {
    fill: rgba(0,0,0,0.2);
    stroke: rgba(255,255,255,0.05);
    stroke-width: 1;
}

#compassTicks line {
    stroke: rgba(255,255,255,0.2);
}

#compassTicks line.major-tick {
    stroke: rgba(255,255,255,0.4);
}

.compass-cardinal {
    fill: var(--accent-blue);
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 700;
    text-anchor: middle;
    dominant-baseline: central;
}

.compass-ordinal {
    fill: var(--text-muted);
    font-family: var(--font-body);
    font-size: 7px;
    font-weight: 500;
    text-anchor: middle;
    dominant-baseline: central;
}

.wind-arrow {
    /* No CSS transform — rotation handled by SVG transform attribute + requestAnimationFrame */
}

.arrow-head {
    fill: var(--accent-red);
    filter: drop-shadow(0 0 6px rgba(230, 57, 70, 0.6));
}

.arrow-shaft {
    stroke: var(--accent-red);
    stroke-width: 2.5;
    opacity: 0.6;
}

.arrow-tail {
    fill: rgba(255,255,255,0.15);
}

.compass-hub {
    fill: var(--needle-cap);
    stroke: rgba(255,255,255,0.2);
    stroke-width: 1;
}

.compass-hub-inner {
    fill: var(--accent-red);
    filter: drop-shadow(0 0 4px rgba(230, 57, 70, 0.5));
}

.wind-reading {
    position: absolute;
    bottom: 16%;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
}

.wind-speed-value {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
}

.wind-speed-unit {
    display: block;
    font-family: var(--font-display);
    font-size: 0.55rem;
    color: var(--text-secondary);
    letter-spacing: 1px;
}

/* ---- SECONDARY METRICS ---- */
.metrics-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    padding: 0 30px 24px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 34px 20px 16px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: background 0.3s, box-shadow 0.3s;
    position: relative;
}

.metric-card:hover {
    background: var(--bg-card-hover);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.metric-icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.uv-icon-color { color: var(--accent-orange); background: var(--glow-orange); }
.solar-icon-color { color: #fca311; background: rgba(252,163,17,0.12); }
.rain-icon-color { color: var(--accent-blue); background: var(--glow-blue); }
.heat-icon-color { color: var(--accent-red); background: rgba(230,57,70,0.12); }

.metric-body { flex: 1; min-width: 0; }

.metric-label {
    position: absolute;
    top: -1px;
    left: -1px;
    font-family: var(--font-display);
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius) 0 var(--radius-sm) 0;
    padding: 3px 10px;
    line-height: 1.4;
    z-index: 1;
}

.metric-value-large {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.metric-value-large small {
    font-size: 0.65rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.metric-detail {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.metric-detail span { color: var(--text-primary); font-weight: 500; }

/* UV Bar */
.uv-bar-track {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(90deg, #2dc653 0%, #fca311 27%, #e63946 55%, #7b2ff7 82%, #4a0e78 100%);
    position: relative;
    overflow: visible;
    margin: 4px 0 0;
}

.uv-bar-fill {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: white;
    border: 2px solid var(--bg-card);
    box-shadow: 0 0 8px rgba(255,255,255,0.5);
    transition: left 1s cubic-bezier(0.4, 0, 0.2, 1);
    left: 0%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.uv-bar-number {
    font-family: var(--font-display);
    font-size: 0.55rem;
    font-weight: 700;
    color: var(--bg-primary);
    line-height: 1;
    user-select: none;
}

.uv-bar-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    font-size: 0.6rem;
    color: var(--text-muted);
    font-family: var(--font-display);
    letter-spacing: 0.5px;
}

.uv-risk-label {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--accent-orange);
    margin-bottom: 6px;
}

/* Solar Bar */
.solar-bar-track {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--gauge-track);
    overflow: hidden;
    margin-top: 6px;
}

.solar-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #fca311, #f8961e);
    border-radius: 3px;
    width: 0%;
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- SUMMARY SECTION ---- */
.summary-section, .charts-section, .radar-section {
    padding: 0 30px 24px;
}

.section-title {
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.summary-table-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.summary-table thead th {
    background: rgba(255,255,255,0.04);
    font-family: var(--font-display);
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-secondary);
    padding: 10px 16px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.summary-table thead th:first-child { text-align: left; }

.summary-table tbody td {
    padding: 8px 16px;
    text-align: center;
    color: var(--text-primary);
    font-family: var(--font-display);
    font-size: 0.8rem;
    border-bottom: 1px solid var(--border);
}

.summary-table tbody tr:last-child td { border-bottom: none; }

.summary-table tbody tr:hover { background: rgba(255,255,255,0.02); }

.summary-table .row-label {
    text-align: left;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 0.85rem;
}

.summary-table .row-unit {
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 300;
}

/* ---- CHARTS ---- */
.charts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.charts-header .section-title {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.chart-toggle {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 3px;
}

.toggle-btn {
    font-family: var(--font-display);
    font-size: 0.65rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-btn.active {
    background: var(--accent-blue);
    color: white;
}

.toggle-btn:hover:not(.active) {
    color: var(--text-primary);
    background: rgba(255,255,255,0.05);
}

.charts-section .chart-card {
    margin-bottom: 16px;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.chart-card h3 {
    font-family: var(--font-display);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.chart-wrap {
    position: relative;
    height: 200px;
}

.chart-wrap canvas { width: 100% !important; height: 100% !important; }

/* ---- RADAR ---- */
.radar-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.windy-frame {
    width: 100%;
    height: 500px;
    border: 0;
    display: block;
}

.radar-placeholder {
    width: 100%;
    height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-family: var(--font-display);
    font-size: 0.8rem;
    letter-spacing: 1px;
}

/* ---- FOOTER ---- */
.station-footer {
    text-align: center;
    padding: 24px 30px;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
}

.station-footer a {
    color: var(--accent-blue);
    text-decoration: none;
}

.station-footer a:hover { text-decoration: underline; }

/* ---- RESPONSIVE ---- */
@media (max-width: 1200px) {
    .gauge-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
    .metrics-row { grid-template-columns: repeat(2, 1fr); }
    .charts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .station-header { padding: 16px 18px; }
    .station-name { font-size: 1rem; }
    .gauge-row { grid-template-columns: 1fr 1fr; gap: 12px; padding: 16px 18px; }
    .metrics-row { grid-template-columns: 1fr; gap: 12px; padding: 0 18px 16px; }
    .summary-section, .charts-section, .radar-section { padding: 0 18px 16px; }
    .gauge-value { font-size: 1.3rem; }
}

@media (max-width: 420px) {
    .gauge-row { grid-template-columns: 1fr; }
}
