/**
 * Ganados Weather - Google Weather Style
 *
 * @package GanadosWeather
 * @since   2.0.0
 */

/* ==========================================================================
   CSS Custom Properties
   ========================================================================== */

:root {
    --gw-primary: #2E7D32;
    --gw-text: #202124;
    --gw-text-secondary: #5f6368;
    --gw-text-light: #9aa0a6;
    --gw-bg: #ffffff;
    --gw-bg-alt: #f8f9fa;
    --gw-border: #dadce0;
    --gw-radius: 16px;
    --gw-shadow: 0 1px 3px rgba(60, 64, 67, 0.15), 0 4px 8px rgba(60, 64, 67, 0.1);
    --gw-graph-warm: #f09819;
    --gw-graph-cool: #6dd5ed;
    --gw-range-warm: #ea8600;
    --gw-range-cool: #4fc3f7;
}

[data-theme="dark"] {
    --gw-text: #e8eaed;
    --gw-text-secondary: #bdc1c6;
    --gw-text-light: #9aa0a6;
    --gw-bg: #202124;
    --gw-bg-alt: #292a2d;
    --gw-border: #3c4043;
    --gw-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* ==========================================================================
   Base Widget Container
   ========================================================================== */

.gw-weather {
    font-family: 'Google Sans', 'Roboto', 'Segoe UI', -apple-system, sans-serif;
    background: var(--gw-bg);
    border-radius: var(--gw-radius);
    box-shadow: var(--gw-shadow);
    overflow: hidden;
    color: var(--gw-text);
    line-height: 1.4;
    position: relative;
}

.gw-weather--error {
    padding: 2rem;
    text-align: center;
    color: var(--gw-text-secondary);
}

.gw-weather--error p {
    margin: 0;
    font-size: 0.9rem;
}

/* ==========================================================================
   Current Weather Section
   ========================================================================== */

.gw-current {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1.5rem 2rem;
    position: relative;
    z-index: 2;
}

.gw-current__left {
    flex: 1;
    min-width: 0;
}

.gw-current__city {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--gw-text-secondary);
    margin-bottom: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gw-current__temp-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.375rem;
}

.gw-current__icon {
    flex-shrink: 0;
    display: block;
}

.gw-current__temp {
    font-size: 3.5rem;
    font-weight: 400;
    line-height: 1;
    letter-spacing: -0.02em;
    color: var(--gw-text);
}

.gw-current__desc {
    font-size: 1rem;
    font-weight: 500;
    color: var(--gw-text);
    text-transform: capitalize;
    margin-bottom: 0.125rem;
}

.gw-current__feels {
    font-size: 0.8rem;
    color: var(--gw-text-secondary);
}

/* Details (right side) */
.gw-current__right {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-top: 0.5rem;
    flex-shrink: 0;
}

.gw-current__detail {
    font-size: 0.8125rem;
    color: var(--gw-text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.gw-current__detail i {
    font-size: 0.75rem;
    width: 1rem;
    text-align: center;
    color: var(--gw-text-light);
}

/* ==========================================================================
   Hourly Temperature Graph
   ========================================================================== */

.gw-graph {
    padding: 1rem 2rem 1.25rem;
    border-top: 1px solid var(--gw-border);
    overflow-x: auto;
    position: relative;
    z-index: 2;
}

.gw-graph__bars {
    display: flex;
    gap: 0;
    min-width: max-content;
}

.gw-graph__bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    flex: 1;
    min-width: 52px;
    padding: 0 0.25rem;
}

.gw-graph__temp {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gw-text);
    line-height: 1;
}

.gw-graph__fill {
    width: 28px;
    border-radius: 14px;
    background: linear-gradient(180deg, var(--gw-graph-warm) 0%, var(--gw-graph-cool) 100%);
    min-height: 8px;

    /*
     * Height is computed from CSS custom properties.
     * --temp: current hour temp
     * --max:  max temp across all hours
     * --min:  min temp across all hours
     *
     * Formula: height = base + ((temp - min) / (max - min)) * range
     * Using calc with clamp for safety.
     */
    height: calc(12px + ((var(--temp) - var(--min)) / (var(--max) - var(--min) + 0.001)) * 48px);
    transition: height 0.4s ease;
}

.gw-graph__bar .gw-current__icon {
    width: 24px;
    height: 24px;
}

.gw-graph__hour {
    font-size: 0.65rem;
    color: var(--gw-text-light);
    line-height: 1;
    white-space: nowrap;
}

/* ==========================================================================
   7-Day Forecast
   ========================================================================== */

.gw-forecast {
    padding: 0.75rem 2rem 1.25rem;
    border-top: 1px solid var(--gw-border);
    display: flex;
    flex-direction: column;
    gap: 0;
    position: relative;
    z-index: 2;
}

.gw-forecast__day {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.gw-forecast__day:last-child {
    border-bottom: none;
}

.gw-forecast__name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--gw-text);
    width: 2.5rem;
    flex-shrink: 0;
    text-transform: capitalize;
}

.gw-forecast__day .gw-current__icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
}

.gw-forecast__high {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gw-text);
    width: 2rem;
    text-align: right;
    flex-shrink: 0;
}

.gw-forecast__low {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--gw-text-light);
    width: 2rem;
    flex-shrink: 0;
}

/* Temperature range bar */
.gw-forecast__range {
    flex: 1;
    height: 6px;
    background: var(--gw-bg-alt);
    border-radius: 3px;
    position: relative;
    overflow: hidden;
    min-width: 60px;
}

.gw-forecast__range-bar {
    position: absolute;
    top: 0;
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--gw-range-cool), var(--gw-range-warm));
    transition: left 0.3s ease, width 0.3s ease;

    /*
     * Position and width computed from CSS custom properties.
     * --low:     this day's low temp
     * --high:    this day's high temp
     * --abs-min: overall minimum across all days
     * --abs-max: overall maximum across all days
     *
     * left  = (low - abs_min) / (abs_max - abs_min) * 100%
     * width = (high - low) / (abs_max - abs_min) * 100%
     */
    left: calc(((var(--low) - var(--abs-min)) / (var(--abs-max) - var(--abs-min) + 0.001)) * 100%);
    width: calc(((var(--high) - var(--low)) / (var(--abs-max) - var(--abs-min) + 0.001)) * 100%);
    min-width: 8px;
}

/* ==========================================================================
   Loading & Spinner
   ========================================================================== */

.gw-weather__loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    color: var(--gw-text-secondary);
    gap: 1rem;
}

.gw-weather__loading p {
    margin: 0;
    font-size: 0.875rem;
}

.gw-weather__spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--gw-border);
    border-top-color: var(--gw-primary);
    border-radius: 50%;
    animation: gw-spin 0.8s linear infinite;
}

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

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 560px) {
    .gw-current {
        flex-direction: column;
        gap: 1rem;
        padding: 1.25rem 1.25rem;
    }

    .gw-current__right {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.5rem 1rem;
        padding-top: 0.5rem;
        border-top: 1px solid var(--gw-border);
        width: 100%;
    }

    .gw-current__temp {
        font-size: 2.75rem;
    }

    .gw-graph {
        padding: 1rem 1.25rem;
    }

    .gw-forecast {
        padding: 0.75rem 1.25rem 1rem;
    }

    .gw-forecast__range {
        min-width: 40px;
    }
}

@media (max-width: 380px) {
    .gw-current__temp {
        font-size: 2.25rem;
    }

    .gw-graph__bar {
        min-width: 44px;
    }

    .gw-forecast__name {
        width: 2rem;
        font-size: 0.75rem;
    }
}

/* ==========================================================================
   Animated Weather Backgrounds
   ========================================================================== */

.gw-animated-bg {
    position: relative;
    overflow: hidden;
    border-radius: var(--gw-radius);
    color: #fff;
}

.gw-animated-bg .gw-current__city,
.gw-animated-bg .gw-current__temp,
.gw-animated-bg .gw-current__desc,
.gw-animated-bg .gw-current__feels,
.gw-animated-bg .gw-current__detail,
.gw-animated-bg .gw-current__detail i,
.gw-animated-bg .gw-graph__temp,
.gw-animated-bg .gw-graph__hour,
.gw-animated-bg .gw-forecast__name,
.gw-animated-bg .gw-forecast__high,
.gw-animated-bg .gw-forecast__low {
    color: #fff;
}

.gw-animated-bg .gw-forecast__low {
    color: rgba(255, 255, 255, 0.7);
}

.gw-animated-bg .gw-current,
.gw-animated-bg .gw-graph,
.gw-animated-bg .gw-forecast {
    position: relative;
    z-index: 2;
}

.gw-animated-bg .gw-graph,
.gw-animated-bg .gw-forecast {
    border-top-color: rgba(255, 255, 255, 0.15);
}

.gw-animated-bg .gw-forecast__day {
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

.gw-animated-bg .gw-forecast__range {
    background: rgba(255, 255, 255, 0.15);
}

.gw-animated-bg .gw-forecast__range-bar {
    background: linear-gradient(90deg, rgba(255,255,255,0.5), rgba(255,255,255,0.9));
}

.gw-animated-bg .gw-graph__fill {
    background: linear-gradient(180deg, rgba(255,255,255,0.9) 0%, rgba(255,255,255,0.3) 100%);
}

/* Base gradient layer */
.gw-bg-layer {
    position: absolute;
    inset: 0;
    z-index: 0;
    transition: background 1s ease;
}

/* ─── Day Clear ──────────────────────────────────────────── */
.gw-bg-01d .gw-bg-layer {
    background: linear-gradient(180deg, #4FC3F7 0%, #0288D1 50%, #01579B 100%);
}

/* ─── Night Clear ────────────────────────────────────────── */
.gw-bg-01n .gw-bg-layer {
    background: linear-gradient(180deg, #0D1B2A 0%, #1B2838 50%, #1A237E 100%);
}

/* ─── Day Few Clouds ─────────────────────────────────────── */
.gw-bg-02d .gw-bg-layer {
    background: linear-gradient(180deg, #81D4FA 0%, #29B6F6 50%, #0277BD 100%);
}

/* ─── Night Few Clouds ───────────────────────────────────── */
.gw-bg-02n .gw-bg-layer {
    background: linear-gradient(180deg, #1A237E 0%, #283593 50%, #1565C0 100%);
}

/* ─── Scattered/Broken Clouds ────────────────────────────── */
.gw-bg-03d .gw-bg-layer, .gw-bg-04d .gw-bg-layer {
    background: linear-gradient(180deg, #90A4AE 0%, #78909C 50%, #546E7A 100%);
}

.gw-bg-03n .gw-bg-layer, .gw-bg-04n .gw-bg-layer {
    background: linear-gradient(180deg, #263238 0%, #37474F 50%, #455A64 100%);
}

/* ─── Rain ───────────────────────────────────────────────── */
.gw-bg-09d .gw-bg-layer, .gw-bg-10d .gw-bg-layer {
    background: linear-gradient(180deg, #546E7A 0%, #455A64 50%, #37474F 100%);
}

.gw-bg-09n .gw-bg-layer, .gw-bg-10n .gw-bg-layer {
    background: linear-gradient(180deg, #1A237E 0%, #0D1B2A 50%, #000 100%);
}

/* ─── Thunderstorm ───────────────────────────────────────── */
.gw-bg-11d .gw-bg-layer, .gw-bg-11n .gw-bg-layer {
    background: linear-gradient(180deg, #263238 0%, #1a1a2e 50%, #0a0a15 100%);
}

/* ─── Snow ───────────────────────────────────────────────── */
.gw-bg-13d .gw-bg-layer {
    background: linear-gradient(180deg, #CFD8DC 0%, #B0BEC5 50%, #90A4AE 100%);
}
.gw-bg-13d .gw-current__city,
.gw-bg-13d .gw-current__detail,
.gw-bg-13d .gw-forecast__name,
.gw-bg-13d .gw-graph__temp {
    color: #37474F;
}

.gw-bg-13n .gw-bg-layer {
    background: linear-gradient(180deg, #37474F 0%, #263238 50%, #1a1a2e 100%);
}

/* ─── Mist/Fog ───────────────────────────────────────────── */
.gw-bg-50d .gw-bg-layer {
    background: linear-gradient(180deg, #CFD8DC 0%, #B0BEC5 100%);
}
.gw-bg-50d .gw-current__city,
.gw-bg-50d .gw-current__detail,
.gw-bg-50d .gw-current__temp,
.gw-bg-50d .gw-current__desc {
    color: #455A64;
}

.gw-bg-50n .gw-bg-layer {
    background: linear-gradient(180deg, #455A64 0%, #263238 100%);
}

/* ─── Rain Animation ─────────────────────────────────────── */
@keyframes gw-rain-fall {
    0%   { transform: translateY(-100%) translateX(0); }
    100% { transform: translateY(100vh) translateX(-20px); }
}

.gw-rain-layer {
    position: absolute;
    inset: 0;
    z-index: 1;
    overflow: hidden;
    pointer-events: none;
}

.gw-rain-layer::before,
.gw-rain-layer::after {
    content: '';
    position: absolute;
    top: -50%;
    left: 0;
    width: 100%;
    height: 200%;
    background-image:
        linear-gradient(transparent 95%, rgba(255,255,255,0.3) 95%, rgba(255,255,255,0.3) 95.5%, transparent 95.5%),
        linear-gradient(transparent 93%, rgba(255,255,255,0.2) 93%, rgba(255,255,255,0.2) 93.3%, transparent 93.3%);
    background-size: 60px 40px, 80px 55px;
    animation: gw-rain-fall 0.8s linear infinite;
    opacity: 0.6;
}

.gw-rain-layer::after {
    background-size: 70px 35px, 90px 50px;
    animation-duration: 0.6s;
    animation-delay: 0.2s;
    opacity: 0.4;
}

/* ─── Snow Animation ─────────────────────────────────────── */
@keyframes gw-snow-fall {
    0%   { transform: translateY(-10%) rotate(0deg); }
    100% { transform: translateY(100%) rotate(360deg); }
}

.gw-snow-layer {
    position: absolute;
    inset: 0;
    z-index: 1;
    overflow: hidden;
    pointer-events: none;
}

.gw-snow-layer::before,
.gw-snow-layer::after {
    content: '';
    position: absolute;
    top: -20%;
    left: 0;
    width: 100%;
    height: 120%;
    background-image:
        radial-gradient(circle 2px at 10% 20%, rgba(255,255,255,0.8) 50%, transparent 50%),
        radial-gradient(circle 3px at 30% 40%, rgba(255,255,255,0.6) 50%, transparent 50%),
        radial-gradient(circle 2px at 50% 10%, rgba(255,255,255,0.7) 50%, transparent 50%),
        radial-gradient(circle 2.5px at 70% 60%, rgba(255,255,255,0.5) 50%, transparent 50%),
        radial-gradient(circle 1.5px at 90% 30%, rgba(255,255,255,0.8) 50%, transparent 50%),
        radial-gradient(circle 2px at 20% 70%, rgba(255,255,255,0.6) 50%, transparent 50%),
        radial-gradient(circle 3px at 60% 80%, rgba(255,255,255,0.4) 50%, transparent 50%),
        radial-gradient(circle 2px at 80% 50%, rgba(255,255,255,0.7) 50%, transparent 50%);
    background-size: 200px 200px;
    animation: gw-snow-fall 8s linear infinite;
}

.gw-snow-layer::after {
    background-size: 150px 150px;
    animation-duration: 12s;
    animation-delay: 2s;
}

/* ─── Stars Animation (night) ────────────────────────────── */
@keyframes gw-twinkle {
    0%, 100% { opacity: 0.3; }
    50%      { opacity: 1; }
}

.gw-stars-layer {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.gw-stars-layer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(circle 1px at 15% 15%, #fff 50%, transparent 50%),
        radial-gradient(circle 1.5px at 35% 8%, #fff 50%, transparent 50%),
        radial-gradient(circle 1px at 55% 20%, #fff 50%, transparent 50%),
        radial-gradient(circle 0.5px at 75% 12%, #fff 50%, transparent 50%),
        radial-gradient(circle 1px at 85% 25%, #fff 50%, transparent 50%),
        radial-gradient(circle 1.5px at 25% 30%, #fff 50%, transparent 50%),
        radial-gradient(circle 0.5px at 45% 5%, #fff 50%, transparent 50%),
        radial-gradient(circle 1px at 65% 28%, #fff 50%, transparent 50%),
        radial-gradient(circle 1px at 10% 22%, #fff 50%, transparent 50%),
        radial-gradient(circle 0.5px at 92% 18%, #fff 50%, transparent 50%);
    background-size: 100% 100%;
    animation: gw-twinkle 3s ease-in-out infinite;
}

/* ─── Lightning flash for thunderstorms ──────────────────── */
@keyframes gw-lightning {
    0%, 92%, 94%, 96%, 100% { opacity: 0; }
    93%, 95% { opacity: 0.3; }
}

.gw-bg-11d .gw-bg-layer::after,
.gw-bg-11n .gw-bg-layer::after {
    content: '';
    position: absolute;
    inset: 0;
    background: #fff;
    opacity: 0;
    animation: gw-lightning 4s ease-in-out infinite;
    z-index: 1;
}

/* ==========================================================================
   Legacy compatibility - keep old class selectors working for shortcode
   ========================================================================== */

.gw-weather--card,
.gw-weather--full {
    border-radius: var(--gw-radius);
}

.gw-weather__current {
    position: relative;
    z-index: 2;
}

.gw-weather__forecast {
    position: relative;
    z-index: 2;
}
