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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    color: #ffffff;
    min-height: 100vh;          /* fallback */
    min-height: 100svh;         /* exclude mobile browser UI bars from the height */
    overflow-x: hidden;
    cursor: none; /* Hide cursor for kiosk mode */
}

/* Hide cursor on all elements for kiosk */
* {
    cursor: none !important;
}

.dashboard {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    gap: 0;
    padding: 0;
    height: 100vh;              /* fallback */
    height: 100svh;             /* fit the visible viewport — mobile nav bars not counted */
    overflow: hidden;
}

/* --- Minimum usable size: below 320px wide or 450px tall, stop
   shrinking and let the page scroll instead of cramming the UI.
   min-width/min-height only "bite" once the viewport drops below them,
   so larger screens are unaffected. --- */
@media (max-width: 320px), (max-height: 450px) {
    body { overflow: auto; }
    .dashboard {
        min-width: 320px;
        min-height: 450px;
    }
}


/* Radar Map - Takes top 80% */
.radar-section {
    position: relative;
    grid-row: 1;
    padding: 0;
    border-radius: 0;
    background: transparent;
    border: none;
}

#radar-map {
    height: 100%;
    width: 100%;
    border-radius: 0;
    overflow: hidden;
}

/* CSS Custom Properties (defaults - overridden by URL params) */
:root {
    --bar-padding: 30px 40px;
    --bar-gap: 35px;
    --temp-main-size: 5rem;
    --weather-icon-size: 100px;
    --hour-icon-size: 60px;
    --hour-item-padding: 15px 20px;
    --hour-item-min: 100px;
    --time-size: 4rem;
    --info-icon-size: 1.8rem;
    --info-value-size: 1.4rem;
}

/* Bottom info bar */
.bottom-bar {
    grid-row: 2;
    display: flex;
    align-items: center;
    gap: var(--bar-gap);
    padding: var(--bar-padding);
    background: linear-gradient(180deg, rgba(0,0,0,0.9) 0%, rgba(15,52,96,0.95) 100%);
    overflow: hidden;
}

/* Current weather */
.current-compact {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px 30px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    flex-shrink: 0;
}

.current-compact .temp-main {
    font-size: var(--temp-main-size);
    font-weight: 200;
    line-height: 1;
}

.current-compact .weather-icon img {
    width: var(--weather-icon-size);
    height: var(--weather-icon-size);
}

.current-compact .weather-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 1.2rem;
    opacity: 0.8;
}

/* Hourly forecast */
.hourly-compact {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
    overflow-x: auto;
    padding: 5px 0;
    scrollbar-width: none;
}

.hourly-compact::-webkit-scrollbar {
    display: none;
}

.hour-item-compact {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--hour-item-padding);
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    flex-shrink: 0;
    min-width: var(--hour-item-min);
}

.hour-item-compact.now {
    background: linear-gradient(135deg, #e94560 0%, #0f3460 100%);
}

.hour-item-compact .time {
    font-size: 1.1rem;
    opacity: 0.7;
}

.hour-item-compact .icon img {
    width: var(--hour-icon-size);
    height: var(--hour-icon-size);
}

.hour-item-compact .temp {
    font-size: 1.5rem;
    font-weight: 500;
}

/* Extra weather info */
.extra-info {
    display: flex;
    gap: 20px;
    flex-shrink: 0;
    padding: 0 25px;
    border-left: 1px solid rgba(255,255,255,0.15);
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    min-width: 90px;
}

.info-item .icon {
    font-size: var(--info-icon-size);
    margin-bottom: 8px;
}

.info-item .value {
    font-size: var(--info-value-size);
    font-weight: 500;
}

.info-item .label {
    font-size: 0.85rem;
    opacity: 0.6;
    text-transform: uppercase;
}

/* Time display */
.time-display {
    text-align: right;
    flex-shrink: 0;
    padding-left: 30px;
    border-left: 1px solid rgba(255,255,255,0.2);
}

.time-display .time {
    font-size: var(--time-size);
    font-weight: 200;
    line-height: 1;
}

.time-display .date {
    font-size: 1.2rem;
    opacity: 0.7;
}

/* Refresh indicator */
.refresh-indicator {
    position: fixed;
    bottom: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.6);
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
    opacity: 0.7;
    z-index: 1000;
}

.refresh-indicator .refresh-icon {
    color: #4fc3f7;
}

.radar-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.7);
    padding: 10px 20px;
    border-radius: 25px;
}

.radar-controls button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 8px 15px;
    border-radius: 15px;
    cursor: pointer;
    transition: background 0.3s;
}

.radar-controls button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.radar-controls button.active {
    background: #e94560;
}

.radar-timestamp {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    padding: 12px 30px;
    border-radius: 25px;
    z-index: 1000;
    font-size: 1.3rem;
    font-weight: 500;
    white-space: nowrap;
}

/* Location label on map */
.location-label {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(0, 0, 0, 0.8);
    padding: 12px 20px;
    border-radius: 15px;
    z-index: 1000;
    font-size: 1.2rem;
    font-weight: 400;
}

/* Weather Alert Banner */
.alert-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #ff6b00, #ff9500);
    color: white;
    padding: 15px 25px;
    z-index: 10000;
    display: none;
    animation: alertPulse 3s ease-in-out infinite;
}

.alert-banner.show {
    display: block;
}

.alert-banner.severe {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
}

.alert-banner.warning {
    background: linear-gradient(135deg, #ff6b00, #ff9500);
}

.alert-banner.watch {
    background: linear-gradient(135deg, #eab308, #ca8a04);
}

.alert-banner.advisory {
    background: linear-gradient(135deg, #0284c7, #0369a1);
}

@keyframes alertPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}

.alert-banner .alert-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    max-width: 1400px;
    margin: 0 auto;
    transition: opacity 0.3s ease;
}

.alert-banner .alert-content.fade {
    opacity: 0;
}

.alert-banner .alert-icon {
    font-size: 1.8rem;
    flex-shrink: 0;
}

.alert-banner .alert-text {
    flex: 1;
}

.alert-banner .alert-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.alert-banner .alert-description {
    font-size: 1rem;
    opacity: 0.95;
    line-height: 1.4;
}

.alert-banner .alert-time {
    font-size: 0.85rem;
    opacity: 0.8;
    margin-top: 4px;
}

.alert-banner .alert-source {
    font-size: 0.75rem;
    opacity: 0.7;
    position: absolute;
    bottom: 5px;
    right: 15px;
}

.alert-banner .alert-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
}

.alert-banner .alert-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transition: all 0.3s ease;
}

.alert-banner .alert-dot.active {
    background: white;
    transform: scale(1.3);
}

/* Error banner */
.error-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #e94560, #c0392b);
    color: white;
    padding: 15px 20px;
    text-align: center;
    z-index: 9999;
    font-size: 1rem;
    display: none;
}

.error-banner.show {
    display: block;
}

.error-banner code {
    background: rgba(0,0,0,0.3);
    padding: 2px 8px;
    border-radius: 4px;
    margin: 0 5px;
}

/* Error state for cards */
.error-message {
    text-align: center;
    padding: 40px 20px;
    color: #e94560;
}

.error-message .error-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.error-message .error-text {
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.error-message .error-detail {
    font-size: 0.85rem;
    opacity: 0.7;
}

/* Loading state */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #e94560;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

/* Leaflet dark mode overrides */
.leaflet-container {
    background: #1a1a2e;
}


.leaflet-control-zoom a {
    background: rgba(0, 0, 0, 0.7) !important;
    color: white !important;
    border: none !important;
}

.leaflet-control-attribution {
    background: rgba(0, 0, 0, 0.5) !important;
    color: rgba(255, 255, 255, 0.5) !important;
}

.leaflet-control-attribution a {
    color: rgba(255, 255, 255, 0.7) !important;
}

/* Radar Legend */
.radar-legend {
    position: absolute;
    bottom: 20px;
    left: 20px;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.8);
    padding: 12px 15px;
    border-radius: 12px;
    font-size: 0.85rem;
}

.radar-legend .legend-title {
    font-weight: 600;
    margin-bottom: 8px;
    opacity: 0.9;
}

.radar-legend .legend-scale {
    display: flex;
    align-items: center;
    gap: 3px;
}

.radar-legend .legend-bar {
    height: 12px;
    width: 20px;
    border-radius: 2px;
}

.radar-legend .legend-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 5px;
    font-size: 0.75rem;
    opacity: 0.7;
}

/* Layer selector */
.layer-selector {
    position: absolute;
    top: 60px;
    left: 20px;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.7);
    padding: 10px;
    border-radius: 10px;
}

.layer-selector select {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
}

.layer-selector select option {
    background: #1a1a2e;
}

/* ============================================================
   MOBILE / RESPONSIVE STYLES
   ------------------------------------------------------------
   Breakpoint ladder (widest -> narrowest):
     >2840  kiosk (original, ?bar= inline vars) — untouched
     <=2840 flex row; shrink current + time to free horizontal room
     <=2500 grid 3-col: current | (extra over hourly) | time
            forecast stacked + minimized vertically; time on the right
     <=1220 grid 2-col: (current over time) | (extra over hourly)
            time moves UNDER current; the em-knob sizing starts here
     <=840  grid 3-row: [current | time] / extra / hourly
            current + time share one row; forecast full-width below
     <=768/600/430/360  step the font-size knob down

   From <=1220 down, sizing uses one "knob": font-size on .bottom-bar
   with every inner size in `em`. Rules override *properties* (not the
   inline ?bar= vars) by cascade order, so no !important is needed and
   the kiosk layout above 1220 stays intact.
   ============================================================ */

/* --- Large displays: shrink current + time (biggest type) so the
   single row holds longer. Fixed sizes (independent of ?bar=). --- */
@media (max-width: 2840px) {
    .current-compact { gap: 14px; padding: 12px 18px; }
    .current-compact .temp-main { font-size: 3rem; }
    .current-compact .weather-icon img { width: 60px; height: 60px; }
    .current-compact .weather-details { font-size: 0.95rem; }
    .time-display { padding-left: 18px; }
    .time-display .time { font-size: 2.8rem; }
    .time-display .date { font-size: 0.9rem; }
}

/* --- <=2500: stack the forecast pair (extra over hourly) via grid;
   current and time stay on the sides. Forecast minimized vertically. --- */
@media (max-width: 2500px) {
    .bottom-bar {
        display: grid;
        grid-template-columns: auto 1fr auto;
        grid-template-rows: auto auto;
        grid-template-areas:
            "current extra time"
            "current hourly time";
        align-items: center;
        gap: 4px 30px;
        padding: 6px 24px;
    }
    .current-compact { grid-area: current; }
    .extra-info      { grid-area: extra; }
    .hourly-compact  { grid-area: hourly; }
    .time-display    { grid-area: time; }

    .hourly-compact { gap: 8px; min-width: 0; justify-content: safe center; overflow-x: auto; }
    .hour-item-compact { padding: 2px 10px; min-width: 62px; border-radius: 10px; }
    .hour-item-compact .time { font-size: 0.8rem; }
    .hour-item-compact .icon img { width: 34px; height: 34px; }
    .hour-item-compact .temp { font-size: 1rem; }

    .extra-info { gap: 8px; min-width: 0; padding: 0; border-left: none; justify-content: safe center; overflow-x: auto; }
    .info-item { padding: 2px 10px; min-width: 70px; border-radius: 10px; }
    .info-item .icon { font-size: 1.3rem; margin-bottom: 1px; }
    .info-item .value { font-size: 1rem; }
    .info-item .label { font-size: 0.68rem; }
}

/* --- <=1220: time moves UNDER current (2-col grid). The em-knob
   sizing starts here: font-size on .bottom-bar drives every em size. --- */
@media (max-width: 1220px) {
    .bottom-bar {
        display: grid;
        grid-template-columns: auto 1fr;
        grid-template-rows: auto auto;
        grid-template-areas:
            "current extra"
            "time    hourly";
        align-items: center;
        font-size: 16px;            /* the knob — scales every em below */
        gap: 6px 1em;
        padding: 0.5em 1em;
    }

    .current-compact {
        grid-area: current;
        gap: 0.6em;
        padding: 0.4em 0.7em;
    }
    .current-compact .temp-main { font-size: 2.6em; }
    .current-compact .weather-icon img { width: 2.8em; height: 2.8em; }
    .current-compact .weather-details { gap: 0.2em; font-size: 0.8em; }

    .time-display {
        grid-area: time;
        padding-left: 0;
        border-left: none;
        text-align: left;
    }
    .time-display .time { font-size: 2.2em; }
    .time-display .date { font-size: 0.8em; }

    .extra-info {
        grid-area: extra;
        gap: 0.5em;
        padding: 0;
        border-left: none;
        min-width: 0;
        justify-content: safe center;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .extra-info::-webkit-scrollbar { display: none; }
    .info-item { padding: 0.25em 0.6em; min-width: 3.6em; border-radius: 0.7em; flex-shrink: 0; }
    .info-item .icon { font-size: 1.3em; margin-bottom: 0.1em; }
    .info-item .value { font-size: 1.05em; }
    .info-item .label { font-size: 0.65em; }

    .hourly-compact {
        grid-area: hourly;
        gap: 0.5em;
        min-width: 0;
        justify-content: safe center;
        overflow-x: auto;
    }
    .hour-item-compact { padding: 0.25em 0.6em; min-width: 3.6em; border-radius: 0.7em; }
    .hour-item-compact .time { font-size: 0.8em; }
    .hour-item-compact .icon img { width: 2.4em; height: 2.4em; }
    .hour-item-compact .temp { font-size: 1.05em; }
}

/* --- Narrow: keep the map labels from colliding (location top-left,
   timestamp top-right) and shrink the map overlays. --- */
@media (max-width: 1024px) {
    .location-label {
        top: 10px;
        left: 10px;
        font-size: 0.9rem;
        padding: 7px 12px;
        max-width: 55%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .radar-timestamp {
        top: 10px;
        left: auto;
        right: 10px;
        transform: none;
        font-size: 0.85rem;
        padding: 7px 12px;
    }
    .radar-legend {
        padding: 8px 10px;
        font-size: 0.75rem;
    }
}

/* --- <=840: current + time share ONE row; extra and hourly drop to
   full-width rows below (3 rows total). --- */
@media (max-width: 840px) {
    .bottom-bar {
        grid-template-columns: auto 1fr;
        grid-template-rows: auto auto auto;
        grid-template-areas:
            "current time"
            "extra   extra"
            "hourly  hourly";
        gap: 6px 1em;
    }
    .current-compact .temp-main { font-size: 1.9em; }
    .current-compact .weather-icon img { width: 2.2em; height: 2.2em; }
    .time-display { text-align: right; }   /* sit at the right end of row 1 */
    .time-display .time { font-size: 1.55em; white-space: nowrap; }
}

/* --- Font-knob steps for smaller screens (layout stays as <=840) --- */
@media (max-width: 768px) { .bottom-bar { font-size: 14px; } }
@media (max-width: 600px) { .bottom-bar { font-size: 13px; } }
@media (max-width: 430px) { .bottom-bar { font-size: 11.5px; } }
@media (max-width: 360px) { .bottom-bar { font-size: 10px; } }
