/**
 * Weather Widget Stylesheet (Glassmorphism & GovBR Theme Integration)
 *
 * Implements:
 * - Ultra-premium Glassmorphism cards with backdrop-filter
 * - Layout faithful to reference design (Left current card + Right 5-day forecast card)
 * - Defer rendering via CSS content-visibility: auto (Modern Web Guidance)
 * - High-Contrast Mode overrides (WCAG 2.1 AAA)
 * - Fluid responsive layout down to 320px
 */

.govbr-weather-glass-section {
    /* Performance: Defer off-screen rendering until user scrolls close to footer */
    content-visibility: auto;
    contain-intrinsic-size: auto none auto 480px;

    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 50%, #e2e8f0 100%);
    border-top: 1px solid #e2e8f0;
    padding: 3.5rem 1.5rem 2.5rem;
    position: relative;
    z-index: 5;
    font-family: inherit;
    color: #1e1b4b;
}

.govbr-weather-wrapper {
    max-width: 1140px;
    margin: 0 auto;
}

/* 1. Header */
.govbr-weather-header {
    margin-bottom: 2rem;
}

.govbr-weather-title-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.govbr-weather-header-icon-box {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    color: #1e1b4b;
}

.govbr-weather-header-svg {
    width: 34px;
    height: 34px;
    stroke: #1e1b4b;
}

.govbr-weather-title {
    font-size: 2rem;
    font-weight: 800;
    color: #1e1b4b;
    margin: 0;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.govbr-weather-subtitle {
    font-size: 0.95rem;
    font-style: italic;
    color: #64748b;
    margin: 0.35rem 0 0 0.25rem;
}

/* 2. Dual Cards Grid */
.govbr-weather-cards-grid {
    display: grid;
    grid-template-columns: 1fr 1.15fr;
    gap: 1.75rem;
    align-items: stretch;
}

/* Glassmorphic Card Surface */
.govbr-weather-glass-card {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 2.25rem 2.25rem 2rem;
    box-shadow: 0 12px 32px -4px rgba(30, 27, 75, 0.05), 0 4px 12px -2px rgba(0, 0, 0, 0.03);
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.govbr-weather-glass-card:hover {
    box-shadow: 0 16px 36px -4px rgba(30, 27, 75, 0.08), 0 6px 16px -2px rgba(0, 0, 0, 0.04);
}

/* ----------------------------------------------------
   CARD 1 (LEFT): Clima Atual
   ---------------------------------------------------- */
.govbr-weather-card-current {
    display: flex;
    flex-direction: column;
}

/* Location Header */
.govbr-weather-card-loc {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin-bottom: 1.25rem;
}

.govbr-weather-pin-icon {
    display: flex;
    align-items: center;
    color: #475569;
}

.govbr-pin-svg {
    width: 16px;
    height: 16px;
    fill: #475569;
}

.govbr-weather-loc-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: #475569;
    letter-spacing: 0.06em;
}

/* Hero Weather Block */
.govbr-weather-hero-block {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.75rem;
    padding: 0.5rem 0 1.25rem;
}

.govbr-weather-hero-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 82px;
    height: 82px;
}

.govbr-weather-hero-svg {
    width: 76px;
    height: 76px;
    stroke: #1e1b4b;
    color: #1e1b4b;
}

.govbr-weather-hero-data {
    display: flex;
    flex-direction: column;
}

.govbr-weather-hero-temp {
    font-size: 4rem;
    font-weight: 800;
    line-height: 0.95;
    color: #1e1b4b;
    font-feature-settings: "tnum";
}

.govbr-weather-hero-temp sup {
    font-size: 1.75rem;
    font-weight: 700;
    vertical-align: top;
    margin-left: 2px;
}

.govbr-weather-hero-condition {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1e1b4b;
    margin-top: 0.4rem;
}

.govbr-weather-hero-range {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: #475569;
    margin-top: 0.25rem;
}

.govbr-weather-arrow-up,
.govbr-weather-arrow-down {
    display: inline-flex;
    align-items: center;
}

/* Card Divider */
.govbr-weather-card-divider {
    border: 0;
    height: 1px;
    background: #e2e8f0;
    margin: 1.25rem 0 1.5rem;
    width: 100%;
}

/* Micro-Metrics Grid (3 Columns) */
.govbr-weather-details-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem 0.75rem;
    margin-top: auto;
}

.govbr-weather-detail-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.govbr-weather-detail-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    color: #1e1b4b;
    flex-shrink: 0;
    margin-top: 2px;
}

.govbr-detail-svg {
    width: 20px;
    height: 20px;
    stroke: #1e1b4b;
}

.govbr-weather-detail-info {
    display: flex;
    flex-direction: column;
}

.govbr-weather-detail-label {
    font-size: 0.72rem;
    font-weight: 500;
    color: #64748b;
    line-height: 1.1;
    white-space: nowrap;
}

.govbr-weather-detail-val {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1e1b4b;
    margin-top: 0.15rem;
    line-height: 1.2;
}

.govbr-weather-uv-text {
    font-size: 0.7rem;
    font-weight: 500;
    color: #64748b;
    margin-left: 2px;
}

/* ----------------------------------------------------
   CARD 2 (RIGHT): Previsão dos Próximos 5 Dias
   ---------------------------------------------------- */
.govbr-weather-card-forecast {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.govbr-weather-forecast-list {
    display: flex;
    flex-direction: column;
    height: 100%;
    justify-content: space-between;
}

.govbr-weather-forecast-row {
    display: grid;
    grid-template-columns: 140px 70px 1fr 80px;
    align-items: center;
    padding: 1.15rem 0.5rem;
    border-bottom: 1px solid rgba(226, 232, 240, 0.7);
    transition: background-color 0.15s ease;
}

.govbr-weather-forecast-row:last-child {
    border-bottom: none;
    padding-bottom: 0.25rem;
}

.govbr-weather-forecast-row:first-child {
    padding-top: 0.25rem;
}

/* Day & Date */
.govbr-weather-forecast-day-col {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
}

.govbr-weather-forecast-day-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1e1b4b;
}

.govbr-weather-forecast-date {
    font-size: 0.8rem;
    color: #94a3b8;
    font-weight: 500;
}

/* Icon */
.govbr-weather-forecast-icon-col {
    display: flex;
    align-items: center;
    justify-content: center;
}

.govbr-forecast-row-svg {
    width: 28px;
    height: 28px;
    stroke: #1e1b4b;
}

/* Temperatures */
.govbr-weather-forecast-temp-col {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.5rem;
}

.govbr-weather-forecast-max {
    font-size: 1.25rem;
    font-weight: 800;
    color: #1e1b4b;
    font-feature-settings: "tnum";
}

.govbr-weather-forecast-min {
    font-size: 1rem;
    font-weight: 500;
    color: #94a3b8;
    font-feature-settings: "tnum";
}

/* Rain Probability */
.govbr-weather-forecast-rain-col {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.4rem;
}

.govbr-weather-forecast-umbrella {
    display: flex;
    align-items: center;
    color: #475569;
}

.govbr-umbrella-mini-svg {
    width: 15px;
    height: 15px;
    stroke: #475569;
}

.govbr-weather-forecast-rain-pct {
    font-size: 0.85rem;
    font-weight: 600;
    color: #64748b;
    min-width: 32px;
}

/* 3. Footer Attribution */
.govbr-weather-meta-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 1.25rem;
}

.govbr-weather-meta-content {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: #64748b;
}

.govbr-weather-timestamp {
    font-feature-settings: "tnum";
}

.govbr-weather-stale-badge {
    background: #fef3c7;
    color: #92400e;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    border-radius: 9999px;
    border: 1px solid #fde68a;
}

.govbr-weather-meta-sep {
    color: #cbd5e1;
}

.govbr-weather-credit-url {
    color: #475569;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.govbr-weather-credit-url:hover {
    color: #1e1b4b;
}

/* Utility Screen Reader */
.govbr-weather-glass-section .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ----------------------------------------------------
   RESPONSIVIDADE (Tablets e Mobile)
   ---------------------------------------------------- */
@media (max-width: 991px) {
    .govbr-weather-cards-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .govbr-weather-glass-card {
        padding: 1.75rem;
    }
}

@media (max-width: 640px) {
    .govbr-weather-title {
        font-size: 1.6rem;
    }

    .govbr-weather-hero-block {
        gap: 1.25rem;
    }

    .govbr-weather-hero-temp {
        font-size: 3.25rem;
    }

    .govbr-weather-hero-svg {
        width: 60px;
        height: 60px;
    }

    .govbr-weather-details-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem 0.5rem;
    }

    .govbr-weather-forecast-row {
        grid-template-columns: 110px 50px 1fr 70px;
        padding: 0.9rem 0;
    }
}

@media (max-width: 420px) {
    .govbr-weather-forecast-row {
        grid-template-columns: 95px 40px 1fr 60px;
    }
    
    .govbr-weather-forecast-day-name {
        font-size: 0.95rem;
    }

    .govbr-weather-forecast-date {
        font-size: 0.75rem;
    }
}

/* ----------------------------------------------------
   4. MODO ALTO CONTRASTE (WCAG 2.1 AAA)
   ---------------------------------------------------- */
html.is-contrast-mode .govbr-weather-glass-section,
html.high-contrast .govbr-weather-glass-section {
    background: #000000 !important;
    border-top: 2px solid #ffff00 !important;
    border-bottom: 2px solid #ffff00 !important;
    color: #ffffff !important;
}

html.is-contrast-mode .govbr-weather-title,
html.high-contrast .govbr-weather-title,
html.is-contrast-mode .govbr-weather-hero-temp,
html.high-contrast .govbr-weather-hero-temp,
html.is-contrast-mode .govbr-weather-hero-condition,
html.high-contrast .govbr-weather-hero-condition,
html.is-contrast-mode .govbr-weather-detail-val,
html.high-contrast .govbr-weather-detail-val,
html.is-contrast-mode .govbr-weather-forecast-day-name,
html.high-contrast .govbr-weather-forecast-day-name,
html.is-contrast-mode .govbr-weather-forecast-max,
html.high-contrast .govbr-weather-forecast-max {
    color: #ffff00 !important;
}

html.is-contrast-mode .govbr-weather-subtitle,
html.high-contrast .govbr-weather-subtitle,
html.is-contrast-mode .govbr-weather-loc-name,
html.high-contrast .govbr-weather-loc-name,
html.is-contrast-mode .govbr-weather-hero-range,
html.high-contrast .govbr-weather-hero-range,
html.is-contrast-mode .govbr-weather-detail-label,
html.high-contrast .govbr-weather-detail-label,
html.is-contrast-mode .govbr-weather-forecast-date,
html.high-contrast .govbr-weather-forecast-date,
html.is-contrast-mode .govbr-weather-forecast-min,
html.high-contrast .govbr-weather-forecast-min,
html.is-contrast-mode .govbr-weather-forecast-rain-pct,
html.high-contrast .govbr-weather-forecast-rain-pct,
html.is-contrast-mode .govbr-weather-meta-content,
html.high-contrast .govbr-weather-meta-content {
    color: #ffffff !important;
}

html.is-contrast-mode .govbr-weather-glass-card,
html.high-contrast .govbr-weather-glass-card {
    background: #000000 !important;
    border: 2px solid #ffff00 !important;
    box-shadow: none !important;
}

html.is-contrast-mode .govbr-weather-header-svg,
html.high-contrast .govbr-weather-header-svg,
html.is-contrast-mode .govbr-weather-hero-svg,
html.high-contrast .govbr-weather-hero-svg,
html.is-contrast-mode .govbr-detail-svg,
html.high-contrast .govbr-detail-svg,
html.is-contrast-mode .govbr-forecast-row-svg,
html.high-contrast .govbr-forecast-row-svg,
html.is-contrast-mode .govbr-umbrella-mini-svg,
html.high-contrast .govbr-umbrella-mini-svg {
    stroke: #ffff00 !important;
    color: #ffff00 !important;
}

html.is-contrast-mode .govbr-pin-svg,
html.high-contrast .govbr-pin-svg {
    fill: #ffff00 !important;
}

html.is-contrast-mode .govbr-weather-card-divider,
html.high-contrast .govbr-weather-card-divider,
html.is-contrast-mode .govbr-weather-forecast-row,
html.high-contrast .govbr-weather-forecast-row {
    border-color: #333333 !important;
    background: #333333 !important;
}

html.is-contrast-mode .govbr-weather-credit-url,
html.high-contrast .govbr-weather-credit-url {
    color: #ffff00 !important;
    text-decoration: underline !important;
}
