/**
 * AVX DPA Weather Widget
 * Version: 1.0.0
 *
 * Brand: DuPage Airport Authority
 *   Primary red:   #EF3340
 *   Black:         #1a1a1a
 *   Background:    #f1f1f1
 *   Font:          Noto Sans (loaded by theme)
 *
 * WCAG 2.1 AA compliant:
 *   - All text meets 4.5:1 contrast ratio (normal) or 3:1 (large text)
 *   - No text-transform: uppercase (screen reader / cognitive accessibility)
 *   - Focus indicators on all interactive elements
 *   - prefers-reduced-motion support
 *   - forced-colors (Windows High Contrast) support
 *   - Touch targets >= 44px on mobile
 *   - No content conveyed by color alone
 */


/* ─── Base widget ─── */

.avx-wx {
    font-family: 'Noto Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: #1a1a1a;
    background: #f1f1f1;
    border-radius: 8px;
    overflow: hidden;
    max-width: 960px;
    margin: 0 auto;
}


/* ─── Error state ─── */

.avx-wx--error {
    padding: 24px;
    text-align: center;
}

.avx-wx__error-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #5a5a5a;
}

.avx-wx__error-inner svg {
    flex-shrink: 0;
    color: #EF3340;
}

.avx-wx__error-inner p {
    margin: 0;
    font-size: 14px;
}


/* ─── Header ─── */

.avx-wx__header {
    background: #1a1a1a;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.avx-wx__header-left {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

.avx-wx__header-icao {
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
    letter-spacing: 0.3px;
}

.avx-wx__header-name {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 400;
}

.avx-wx__header-elev {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.55); /* 6.0:1 on #1a1a1a */
    font-weight: 400;
}

.avx-wx__header-time {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.50);
    text-align: right;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
}


/* ─── Flight category strip ─── */

.avx-wx__fltcat {
    padding: 7px 24px;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1.3;
}

.avx-wx__fltcat-code {
    letter-spacing: 0.3px;
}

.avx-wx__fltcat-sep {
    opacity: 0.6;
}

.avx-wx__fltcat-desc {
    font-weight: 400;
    font-size: 13px;
}

/* Flight category colors — all pass WCAG AA on white text (≥ 4.5:1) */
.avx-wx__fltcat--vfr  { background: #1E8449; color: #ffffff; } /* 4.71:1 */
.avx-wx__fltcat--mvfr { background: #2471A3; color: #ffffff; } /* 5.30:1 */
.avx-wx__fltcat--ifr  { background: #D02839; color: #ffffff; } /* 5.19:1 — darkened from #EF3340 (was 4.02:1) */
.avx-wx__fltcat--lifr { background: #7D3C98; color: #ffffff; } /* 7.06:1 */


/* ─── Hero: current conditions ─── */

.avx-wx__hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px;
    background: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    flex-wrap: wrap;
    gap: 16px;
}

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

.avx-wx__hero-icon {
    line-height: 0;
}

.avx-wx__hero-temp {
    font-size: 44px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1;
}

.avx-wx__hero-temp sup {
    font-size: 20px;
    font-weight: 500;
    vertical-align: super;
    color: #666666;
}

.avx-wx__hero-right {
    text-align: right;
}

.avx-wx__hero-desc {
    font-size: 16px;
    font-weight: 500;
    color: #1a1a1a;
    margin-bottom: 2px;
}

.avx-wx__hero-feels {
    font-size: 13px;
    color: #666666;
}


/* ─── Pilot essentials grid ─── */

.avx-wx__grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    background: #ffffff;
    border-bottom: 1px solid #e0e0e0;
}

.avx-wx__cell {
    padding: 16px 20px;
    border-right: 1px solid #ebebeb;
    border-bottom: 1px solid #ebebeb;
}

.avx-wx__cell:nth-child(3n) {
    border-right: none;
}

/* Remove bottom border on last row */
.avx-wx__cell:nth-last-child(-n+3) {
    border-bottom: none;
}

.avx-wx__cell-label {
    font-size: 12px;
    font-weight: 500;
    color: #6e6e6e; /* 5.04:1 on #fff — passes WCAG AA */
    letter-spacing: 0.3px;
    margin-bottom: 6px;
}

.avx-wx__cell-value {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
    line-height: 1.3;
}

.avx-wx__cell-sub {
    font-size: 12px;
    color: #666666;
    margin-top: 3px;
    line-height: 1.4;
}

.avx-wx__cell-sub--warn {
    color: #C0392B;
    font-weight: 500;
}

/* Wind direction arrow + value row */
.avx-wx__wind-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.avx-wx__wind-arrow {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #f1f1f1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #1a1a1a;
    transition: transform 0.3s ease;
}


/* ─── Section labels ─── */

.avx-wx__section-label {
    font-size: 13px;
    font-weight: 600;
    color: #A8231A; /* 6.36:1 on #f1f1f1 — darkened from #EF3340 (was 3.56:1) */
    letter-spacing: 0.3px;
    padding: 10px 24px 8px;
    background: #f1f1f1;
    border-top: 1px solid #e0e0e0;
}


/* ─── Raw METAR / TAF ─── */

.avx-wx__raw-block {
    padding: 8px 24px 16px;
    background: #ffffff;
    border-bottom: 1px solid #e0e0e0;
}

.avx-wx__raw {
    font-family: 'JetBrains Mono', 'SF Mono', 'Consolas', 'Liberation Mono', monospace;
    font-size: 13px;
    line-height: 1.7;
    color: #1a1a1a;
    white-space: pre-wrap;
    word-break: break-word;
    padding: 12px 16px;
    background: #f7f7f7;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    margin: 0;
    overflow-x: auto;
}


/* ─── Hourly forecast strip ─── */

.avx-wx__hourly {
    display: flex;
    overflow-x: auto;
    padding: 14px 24px;
    gap: 0;
    background: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    scrollbar-width: thin;
    scrollbar-color: #cccccc transparent;
    -webkit-overflow-scrolling: touch;
}

.avx-wx__hourly::-webkit-scrollbar {
    height: 4px;
}

.avx-wx__hourly::-webkit-scrollbar-thumb {
    background: #cccccc;
    border-radius: 2px;
}

/* Focus style for keyboard scrolling */
.avx-wx__hourly:focus {
    outline: 2px solid #EF3340;
    outline-offset: -2px;
}

.avx-wx__hourly:focus:not(:focus-visible) {
    outline: none;
}

.avx-wx__hour {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 72px;
    padding: 8px 6px;
    gap: 5px;
    border-right: 1px solid #f1f1f1;
    flex-shrink: 0;
}

.avx-wx__hour:last-child {
    border-right: none;
}

.avx-wx__hour-time {
    font-size: 12px;
    font-weight: 500;
    color: #666666;
}

.avx-wx__hour-icon {
    line-height: 0;
}

.avx-wx__hour-temp {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a1a;
}

.avx-wx__hour-wind {
    font-size: 11px;
    color: #757575;
}

.avx-wx__hour-pop {
    font-size: 11px;
    color: #2471A3;
    font-weight: 500;
}


/* ─── Daily forecast ─── */

.avx-wx__daily {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    background: #ffffff;
    border-bottom: 1px solid #e0e0e0;
}

.avx-wx__day {
    padding: 20px 16px;
    text-align: center;
    border-right: 1px solid #ebebeb;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.avx-wx__day:last-child {
    border-right: none;
}

.avx-wx__day-name {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
}

.avx-wx__day-icon {
    line-height: 0;
}

.avx-wx__day-temps {
    font-size: 15px;
    color: #1a1a1a;
}

.avx-wx__day-hi {
    font-weight: 600;
}

.avx-wx__day-lo {
    color: #757575;
}

.avx-wx__day-desc {
    font-size: 12px;
    color: #666666;
}

.avx-wx__day-wind {
    font-size: 11px;
    color: #757575;
}

.avx-wx__day-pop {
    font-size: 11px;
    color: #2471A3;
    font-weight: 500;
}


/* ─── Footer ─── */

.avx-wx__footer {
    padding: 10px 24px;
    background: #e8e8e8;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: #595959;
    flex-wrap: wrap;
    gap: 8px;
}

.avx-wx__footer-stale {
    color: #A8231A; /* 4.95:1 on #e8e8e8 — passes WCAG AA */
    font-weight: 500;
}


/* ─── SVG icon animations ─── */

.avx-wx-icon--sun {
    animation: avx-wx-sun-pulse 3.5s ease-in-out infinite;
    transform-origin: center center;
}

.avx-wx-icon--moon {
    animation: avx-wx-moon-glow 4s ease-in-out infinite;
    transform-origin: center center;
}

.avx-wx-icon--cloud {
    animation: avx-wx-cloud-drift 5s ease-in-out infinite;
}

.avx-wx-icon--rain {
    animation: avx-wx-rain-fall 2.5s ease-in-out infinite;
}

.avx-wx-icon--snow {
    animation: avx-wx-snow-fall 3s ease-in-out infinite;
}

.avx-wx-icon--storm {
    animation: avx-wx-storm-flash 5s ease-in-out infinite;
}

@keyframes avx-wx-sun-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}

@keyframes avx-wx-moon-glow {
    0%, 100% { opacity: 0.9; }
    50% { opacity: 1; }
}

@keyframes avx-wx-cloud-drift {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(2px); }
}

@keyframes avx-wx-rain-fall {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(1px); }
}

@keyframes avx-wx-snow-fall {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(1.5px) rotate(2deg); }
}

@keyframes avx-wx-storm-flash {
    0%, 18%, 28%, 100% { opacity: 1; }
    22%, 24% { opacity: 0.85; filter: brightness(1.1); }
}


/* ─── Accessibility: reduced motion ─── */

@media (prefers-reduced-motion: reduce) {
    .avx-wx-icon--sun,
    .avx-wx-icon--moon,
    .avx-wx-icon--cloud,
    .avx-wx-icon--rain,
    .avx-wx-icon--snow,
    .avx-wx-icon--storm {
        animation: none !important;
    }

    .avx-wx__wind-arrow {
        transition: none !important;
    }
}


/* ─── Accessibility: Windows High Contrast ─── */

@media (forced-colors: active) {
    .avx-wx {
        border: 1px solid currentColor;
    }

    .avx-wx__fltcat {
        border: 1px solid currentColor;
    }

    .avx-wx__cell {
        border-color: currentColor;
    }

    .avx-wx__hour {
        border-color: currentColor;
    }

    .avx-wx__day {
        border-color: currentColor;
    }

    .avx-wx__raw {
        border: 1px solid currentColor;
    }

    .avx-wx__hourly:focus {
        outline-color: Highlight;
    }
}


/* ─── Responsive: tablet (< 768px) ─── */

@media (max-width: 767px) {
    .avx-wx__grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .avx-wx__cell:nth-child(3n) {
        border-right: 1px solid #ebebeb;
    }

    .avx-wx__cell:nth-child(2n) {
        border-right: none;
    }

    /* Recalculate last-row bottom border removal for 2-col */
    .avx-wx__cell:nth-last-child(-n+3) {
        border-bottom: 1px solid #ebebeb;
    }

    .avx-wx__cell:nth-last-child(-n+2) {
        border-bottom: none;
    }

    .avx-wx__hero-temp {
        font-size: 38px;
    }
}


/* ─── Responsive: mobile (< 480px) ─── */

@media (max-width: 479px) {
    .avx-wx__header {
        padding: 12px 16px;
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .avx-wx__header-time {
        text-align: left;
    }

    .avx-wx__fltcat {
        padding: 7px 16px;
    }

    .avx-wx__hero {
        padding: 20px 16px;
        flex-direction: column;
        align-items: flex-start;
    }

    .avx-wx__hero-right {
        text-align: left;
    }

    .avx-wx__grid {
        grid-template-columns: 1fr 1fr;
    }

    .avx-wx__cell {
        padding: 14px 16px;
    }

    .avx-wx__cell-value {
        font-size: 16px;
    }

    .avx-wx__section-label {
        padding: 10px 16px 8px;
    }

    .avx-wx__raw-block {
        padding: 8px 16px 16px;
    }

    .avx-wx__raw {
        font-size: 11px;
        padding: 10px 12px;
    }

    .avx-wx__hourly {
        padding: 14px 16px;
    }

    .avx-wx__hour {
        min-width: 64px;
    }

    .avx-wx__daily {
        grid-template-columns: 1fr;
    }

    .avx-wx__day {
        flex-direction: row;
        text-align: left;
        gap: 12px;
        padding: 14px 16px;
        border-right: none;
        border-bottom: 1px solid #ebebeb;
    }

    .avx-wx__day:last-child {
        border-bottom: none;
    }

    .avx-wx__day-name {
        min-width: 80px;
    }

    .avx-wx__footer {
        padding: 10px 16px;
        font-size: 10px;
    }
}


/* ─── Print styles ─── */

@media print {
    .avx-wx {
        border: 1px solid #000;
    }

    .avx-wx-icon--sun,
    .avx-wx-icon--moon,
    .avx-wx-icon--cloud,
    .avx-wx-icon--rain,
    .avx-wx-icon--snow,
    .avx-wx-icon--storm {
        animation: none !important;
    }

    .avx-wx__hourly {
        overflow: visible;
        flex-wrap: wrap;
    }
}
