/* ===========================================================================
   Weather — main stylesheet
   A dynamic "sky" theme shifts color (dawn / day / dusk / night) and adds
   subtle weather-driven particle overlays (clouds, rain, snow, fog, storm).
   =========================================================================== */

:root {
    /* Sky gradient stops — overridden inline per-request based on time of day */
    --sky-top: #2E86DE;
    --sky-mid: #5DADE2;
    --sky-bottom: #AED6F1;
    --accent: #FFB454;

    /* Glass chrome */
    --glass-bg: rgba(255, 255, 255, 0.10);
    --glass-bg-strong: rgba(255, 255, 255, 0.16);
    --glass-border: rgba(255, 255, 255, 0.22);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);

    /* Text */
    --text-primary: #F7F9FC;
    --text-secondary: rgba(247, 249, 252, 0.72);
    --text-muted: rgba(247, 249, 252, 0.50);

    /* Type */
    --font-display: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Layout */
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 10px;
    --container: 1180px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    font-family: var(--font-body);
    color: var(--text-primary);
    background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 45%, var(--sky-bottom) 100%);
    background-attachment: fixed;
    transition: background 1.5s ease;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

.container {
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 20px;
}

/* ---------------------------------------------------------------------
   Glass card
   --------------------------------------------------------------------- */
.glass {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
}

.glass-strong {
    background: var(--glass-bg-strong);
}

/* ---------------------------------------------------------------------
   Navigation
   --------------------------------------------------------------------- */
.nav {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 20px;
    background: rgba(10, 14, 28, 0.28);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.25rem;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.nav-brand .wi { color: var(--accent); font-size: 1.4rem; }

.nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.location-switcher select {
    appearance: none;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.92rem;
    padding: 9px 36px 9px 14px;
    border-radius: 999px;
    cursor: pointer;
    max-width: 220px;
    text-overflow: ellipsis;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23F7F9FC' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
}
.location-switcher select option { color: #222; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: 999px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.92rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease;
}
.btn:hover { background: var(--glass-bg-strong); }
.btn:active { transform: scale(0.97); }
.btn-accent {
    background: var(--accent);
    color: #2A1B00;
    border-color: var(--accent);
    font-weight: 600;
}
.btn-accent:hover { background: #ffc370; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { padding: 6px 14px; font-size: 0.82rem; }

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}
.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid var(--glass-border);
    object-fit: cover;
}
.user-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 200px;
    padding: 10px;
    display: none;
    flex-direction: column;
    gap: 4px;
    z-index: 60;
}
.user-dropdown.open { display: flex; }
.user-dropdown .user-name { padding: 8px 12px 4px; font-weight: 600; font-size: 0.9rem; }
.user-dropdown .user-email { padding: 0 12px 8px; font-size: 0.78rem; color: var(--text-muted); }
.user-dropdown a, .user-dropdown button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 0.88rem;
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    font-family: var(--font-body);
}
.user-dropdown a:hover, .user-dropdown button:hover { background: rgba(255,255,255,0.10); }

.fav-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-top: 1px solid var(--glass-border);
    border-bottom: 1px solid var(--glass-border);
    margin: 4px 0;
    padding: 4px 0;
    max-height: 160px;
    overflow-y: auto;
}
.fav-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 7px 12px;
    border-radius: 10px;
    font-size: 0.85rem;
}
.fav-list-item:hover { background: rgba(255,255,255,0.10); }
.fav-list-item a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.remove-favorite-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 6px;
}
.remove-favorite-btn:hover { color: #FF8080; background: rgba(255,255,255,0.08); }

/* Location search popover */
.search-popover-wrap { position: relative; }
.location-search-popover {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 280px;
    padding: 14px;
    display: none;
    flex-direction: column;
    gap: 10px;
    z-index: 60;
}
.location-search-popover.open { display: flex; }
.location-search-popover label {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.location-search-popover input[type=text] {
    width: 100%;
    padding: 9px 12px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    background: rgba(255,255,255,0.08);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9rem;
}
.location-search-popover input[type=text]::placeholder { color: var(--text-muted); }
.search-results {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 220px;
    overflow-y: auto;
}
.search-result {
    text-align: left;
    padding: 9px 10px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.86rem;
    cursor: pointer;
}
.search-result:hover { background: rgba(255,255,255,0.10); }
.search-empty { padding: 8px 10px; font-size: 0.82rem; color: var(--text-muted); }

/* ---------------------------------------------------------------------
   Hero
   --------------------------------------------------------------------- */
.hero {
    position: relative;
    padding: 56px 0 80px;
    overflow: hidden;
}

.hero-particles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.hero-inner {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
}

.hero-location {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.hero-temp-row {
    display: flex;
    align-items: center;
    gap: 22px;
    margin: 6px 0;
}

.hero-temp {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(4.5rem, 14vw, 8rem);
    line-height: 1;
    letter-spacing: -0.02em;
}

.hero-icon {
    font-size: clamp(3rem, 9vw, 5.5rem);
    color: var(--accent);
    filter: drop-shadow(0 6px 18px rgba(0,0,0,0.25));
}

.hero-desc {
    font-size: 1.15rem;
    font-weight: 500;
}

.hero-feels {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

/* Sun / moon arc — signature element */
.sun-arc-wrap {
    width: 100%;
    max-width: 640px;
    margin: 28px auto 6px;
    padding: 0 20px;
}
.sun-arc-wrap svg { width: 100%; height: auto; display: block; overflow: visible; }
.sun-arc-track { fill: none; stroke: rgba(255,255,255,0.22); stroke-width: 2; stroke-dasharray: 4 6; }
.sun-arc-fill { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; opacity: 0.9; }
.sun-arc-marker {
    fill: var(--accent);
    filter: drop-shadow(0 0 8px var(--accent));
    transition: cx 1s linear, cy 1s linear;
}
.sun-arc-marker.is-moon { fill: #E7ECF7; filter: drop-shadow(0 0 6px rgba(231,236,247,0.8)); }
.sun-arc-label {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    fill: var(--text-secondary);
}

/* Current condition stat pills */
.hero-stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 22px;
    max-width: 720px;
}
.stat-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 999px;
    font-size: 0.86rem;
    font-family: var(--font-mono);
}
.stat-pill .wi { color: var(--accent); font-size: 1.1rem; }
.stat-pill .stat-label { color: var(--text-muted); font-family: var(--font-body); margin-right: 2px; }

/* ---------------------------------------------------------------------
   Section headers
   --------------------------------------------------------------------- */
.section { padding: 28px 0; position: relative; z-index: 1; }
.section-title {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0 0 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.section-title .wi { color: var(--accent); }

/* ---------------------------------------------------------------------
   Hourly strip
   --------------------------------------------------------------------- */
.hourly-scroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 6px 4px 14px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
}
.hourly-scroll::-webkit-scrollbar { height: 6px; }
.hourly-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 6px; }

.hour-card {
    flex: 0 0 86px;
    scroll-snap-align: start;
    padding: 14px 8px;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
}
.hour-card.is-now { border-color: var(--accent); background: var(--glass-bg-strong); }
.hour-time { font-size: 0.8rem; color: var(--text-secondary); font-family: var(--font-mono); }
.hour-card .wi { font-size: 1.6rem; color: var(--accent); }
.hour-temp { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; }
.hour-precip { font-size: 0.74rem; color: var(--text-secondary); font-family: var(--font-mono); min-height: 1em; }

/* ---------------------------------------------------------------------
   3-day detailed forecast
   --------------------------------------------------------------------- */
.threeday-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}
.day-card {
    padding: 18px;
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.day-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.day-card-name { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; }
.day-card-date { font-size: 0.78rem; color: var(--text-muted); font-family: var(--font-mono); }
.day-card-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.day-card-main .wi { font-size: 2.4rem; color: var(--accent); }
.day-card-temps { text-align: right; font-family: var(--font-display); }
.day-card-temps .hi { font-size: 1.5rem; font-weight: 600; }
.day-card-temps .lo { font-size: 1rem; color: var(--text-muted); margin-left: 6px; }
.day-card-desc { font-size: 0.9rem; color: var(--text-secondary); }

.day-card-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    font-size: 0.8rem;
    font-family: var(--font-mono);
    color: var(--text-secondary);
}
.day-card-grid div { display: flex; align-items: center; gap: 6px; }
.day-card-grid .wi { color: var(--accent); font-size: 1rem; }

.day-card-toggle {
    align-self: flex-start;
    margin-top: 2px;
}

.hourly-detail {
    display: none;
    flex-direction: column;
    gap: 6px;
    padding-top: 10px;
    border-top: 1px solid var(--glass-border);
    max-height: 280px;
    overflow-y: auto;
}
.hourly-detail.open { display: flex; }
.hourly-detail-row {
    display: grid;
    grid-template-columns: 56px 28px 1fr 60px 60px;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    padding: 4px 0;
}
.hourly-detail-row.is-now { color: var(--accent); font-weight: 600; }
.hourly-detail-row .wi { font-size: 1.1rem; color: var(--accent); text-align: center; }

/* ---------------------------------------------------------------------
   10-day forecast
   --------------------------------------------------------------------- */
.tenday-list {
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.tenday-row {
    display: grid;
    grid-template-columns: 90px 36px 1fr auto;
    align-items: center;
    gap: 14px;
    padding: 12px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.tenday-row:last-child { border-bottom: none; }
.tenday-day { font-weight: 600; font-family: var(--font-display); }
.tenday-row .wi { font-size: 1.4rem; color: var(--accent); text-align: center; }
.tenday-desc { color: var(--text-secondary); font-size: 0.88rem; }
.tenday-precip { font-size: 0.78rem; color: var(--text-muted); font-family: var(--font-mono); margin-left: 8px; }
.tenday-temps {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-mono);
    justify-self: end;
    min-width: 110px;
    justify-content: flex-end;
}
.tenday-temps .lo { color: var(--text-muted); }
.tenday-bar {
    width: 60px;
    height: 4px;
    border-radius: 4px;
    background: rgba(255,255,255,0.12);
    position: relative;
    overflow: hidden;
}
.tenday-bar span {
    position: absolute;
    top: 0; bottom: 0;
    border-radius: 4px;
    background: linear-gradient(90deg, #6FB7FF, var(--accent));
}

/* ---------------------------------------------------------------------
   Radar
   --------------------------------------------------------------------- */
.radar-wrap {
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
}
#radar-map { width: 100%; height: 460px; background: #1a1f33; }
.radar-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    flex-wrap: wrap;
}
.radar-controls .time-label {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-secondary);
    min-width: 130px;
}
.radar-slider { flex: 1; min-width: 120px; }
.radar-slider input[type=range] { width: 100%; }

/* ---------------------------------------------------------------------
   Footer
   --------------------------------------------------------------------- */
.footer {
    padding: 30px 0 50px;
    text-align: center;
    font-size: 0.82rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}
.footer a { text-decoration: underline; }

/* ---------------------------------------------------------------------
   Auth banner / alerts
   --------------------------------------------------------------------- */
.alert {
    padding: 12px 18px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    margin: 16px 0;
}
.alert-error { background: rgba(255, 90, 90, 0.18); border: 1px solid rgba(255,90,90,0.4); }

/* ---------------------------------------------------------------------
   Weather particle effects
   --------------------------------------------------------------------- */
.cloud-shape {
    position: absolute;
    background: rgba(255,255,255,0.35);
    border-radius: 50%;
    filter: blur(6px);
    animation: drift linear infinite;
}
@keyframes drift {
    from { transform: translateX(-20vw); }
    to   { transform: translateX(120vw); }
}

.rain-drop, .snow-flake {
    position: absolute;
    top: -5%;
    pointer-events: none;
}
.rain-drop {
    width: 2px;
    height: 60px;
    background: linear-gradient(180deg, rgba(255,255,255,0), rgba(190,220,255,0.55));
    animation: fall linear infinite;
}
.snow-flake {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255,255,255,0.85);
    animation: fall-drift linear infinite;
}
@keyframes fall {
    from { transform: translateY(-10vh); }
    to   { transform: translateY(110vh); }
}
@keyframes fall-drift {
    0%   { transform: translate(0, -10vh); }
    50%  { transform: translate(20px, 50vh); }
    100% { transform: translate(-10px, 110vh); }
}

.fog-band {
    position: absolute;
    left: -20%;
    width: 140%;
    height: 90px;
    background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,0.25), rgba(255,255,255,0));
    filter: blur(10px);
    animation: drift-slow linear infinite;
}
@keyframes drift-slow {
    from { transform: translateX(-10vw); }
    to   { transform: translateX(10vw); }
}

.lightning-flash {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.65);
    opacity: 0;
    animation: flash 9s ease-in-out infinite;
    pointer-events: none;
}
@keyframes flash {
    0%, 92%, 100% { opacity: 0; }
    93% { opacity: 0.8; }
    94% { opacity: 0.1; }
    95% { opacity: 0.6; }
    96% { opacity: 0; }
}

.stars { position: absolute; inset: 0; }
.star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: #fff;
    border-radius: 50%;
    animation: twinkle 3s ease-in-out infinite;
}
@keyframes twinkle {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .cloud-shape, .rain-drop, .snow-flake, .fog-band, .lightning-flash, .star {
        animation: none !important;
    }
}

/* ---------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------- */
@media (max-width: 860px) {
    .threeday-grid { grid-template-columns: 1fr; }
    .tenday-row { grid-template-columns: 70px 30px 1fr auto; }
    .tenday-desc { display: none; }
    #radar-map { height: 360px; }
}

@media (max-width: 560px) {
    .nav-brand span.brand-text { display: none; }
    .location-switcher select { max-width: 140px; }
    .hero { padding: 36px 0 56px; }
    .hero-temp-row { gap: 12px; }
    .hero-stats { gap: 8px; }
    .stat-pill { font-size: 0.78rem; padding: 8px 12px; }
    .tenday-temps { min-width: 90px; }
    .tenday-bar { width: 40px; }
}
