/* Additional custom styles for Chrome 49 compatibility */

/* ========================================
   SEASONAL THEME SYSTEM
   ======================================== */

/* CSS Variables for theming */
:root {
    --bg-overlay-color: rgba(0, 0, 0, 0.2);
    --frost-color: rgba(255, 255, 255, 0.1);
}

/* Winter theme overrides */
body.winter-theme {
    --bg-overlay-color: rgba(10, 25, 47, 0.4);
    --frost-color: rgba(255, 255, 255, 0.15);
}

/* ========================================
   GLASSMORPHISM CARDS
   ======================================== */

.glass-card {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 24px;
    position: relative;
    overflow: hidden;
}

/* Chrome 49+ backdrop-filter support */
@supports (-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px)) {
    .glass-card {
        -webkit-backdrop-filter: blur(20px);
        backdrop-filter: blur(20px);
        background: rgba(255, 255, 255, 0.1);
    }
}

/* Fallback for browsers without backdrop-filter */
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    .glass-card {
        background: rgba(30, 41, 59, 0.85);
    }
}

/* Glass card inner glow effect */
.glass-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    pointer-events: none;
}

/* ========================================
   SNOWFLAKE ANIMATIONS
   ======================================== */

#snowflakes-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 15;
    overflow: hidden;
}

.snowflake {
    position: absolute;
    top: -20px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 1rem;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
    -webkit-animation: snowfall linear infinite;
    animation: snowfall linear infinite;
    pointer-events: none;
}

.snowflake.large {
    font-size: 1.5rem;
    color: rgba(255, 255, 255, 0.9);
}

.snowflake.small {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.6);
}

@-webkit-keyframes snowfall {
    0% {
        -webkit-transform: translateY(-10px) rotate(0deg) translateX(0);
        transform: translateY(-10px) rotate(0deg) translateX(0);
        opacity: 1;
    }
    50% {
        -webkit-transform: translateY(50vh) rotate(180deg) translateX(20px);
        transform: translateY(50vh) rotate(180deg) translateX(20px);
    }
    100% {
        -webkit-transform: translateY(100vh) rotate(360deg) translateX(-20px);
        transform: translateY(100vh) rotate(360deg) translateX(-20px);
        opacity: 0.3;
    }
}

@keyframes snowfall {
    0% {
        -webkit-transform: translateY(-10px) rotate(0deg) translateX(0);
        transform: translateY(-10px) rotate(0deg) translateX(0);
        opacity: 1;
    }
    50% {
        -webkit-transform: translateY(50vh) rotate(180deg) translateX(20px);
        transform: translateY(50vh) rotate(180deg) translateX(20px);
    }
    100% {
        -webkit-transform: translateY(100vh) rotate(360deg) translateX(-20px);
        transform: translateY(100vh) rotate(360deg) translateX(-20px);
        opacity: 0.3;
    }
}

/* ========================================
   FROST DECORATIONS
   ======================================== */

.frost-decoration {
    position: fixed;
    pointer-events: none;
    z-index: 18;
}

.frost-top-left {
    top: 0;
    left: 0;
    width: 400px;
    height: 300px;
    background:
        radial-gradient(ellipse at top left, rgba(255, 255, 255, 0.15) 0%, transparent 70%),
        linear-gradient(135deg, rgba(173, 216, 230, 0.2) 0%, transparent 50%);
}

.frost-top-right {
    top: 0;
    right: 0;
    width: 400px;
    height: 300px;
    background:
        radial-gradient(ellipse at top right, rgba(255, 255, 255, 0.15) 0%, transparent 70%),
        linear-gradient(225deg, rgba(173, 216, 230, 0.2) 0%, transparent 50%);
}

.frost-bottom {
    bottom: 0;
    left: 0;
    right: 0;
    height: 100px;
    background: linear-gradient(to top, rgba(255, 255, 255, 0.05), transparent);
}

/* Static snowflake icons on cards */
.card-snowflake {
    position: absolute;
    color: rgba(255, 255, 255, 0.15);
    pointer-events: none;
    font-size: 2rem;
}

/* Winter-only elements hidden by default */
.winter-only {
    display: none;
}

body.winter-theme .winter-only {
    display: block;
}

/* ========================================
   SUGGESTION BOX
   ======================================== */

.suggestion-box {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: start;
    -webkit-align-items: flex-start;
    -ms-flex-align: start;
    align-items: flex-start;
    gap: 12px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 16px;
    margin-top: 16px;
}

.suggestion-box img {
    width: 24px;
    height: 24px;
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
    margin-top: 2px;
    /* Invert to white for visibility on colored backgrounds */
    filter: brightness(0) saturate(100%) invert(1);
    -webkit-filter: brightness(0) saturate(100%) invert(1);
}

.suggestion-box span {
    font-size: 1rem;
    line-height: 1.5;
}

/* ========================================
   QR CODE CONTAINER
   ======================================== */

.qr-container {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -webkit-flex-direction: column;
    -ms-flex-direction: column;
    flex-direction: column;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    gap: 8px;
}

.qr-container img {
    width: 112px;
    height: 112px;
}

.qr-label {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.8);
    text-align: center;
    max-width: 120px;
}

/* ========================================
   WEATHER CARD GLASSMORPHISM
   ======================================== */

.weather-card {
    background: rgba(59, 130, 246, 0.7) !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    backdrop-filter: blur(20px) !important;
    box-shadow: 0 25px 50px -12px rgba(59, 130, 246, 0.5), inset 0 0 80px rgba(96, 165, 250, 0.2) !important;
}

/* Weather info rows */
.weather-info-row {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 12px 16px;
}

/* Weather alert banner */
.weather-alert {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    gap: 12px;
    background: rgba(59, 130, 246, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    padding: 14px 18px;
    margin-top: 16px;
    color: white;
    -webkit-animation: alertPulse 2s ease-in-out infinite;
    animation: alertPulse 2s ease-in-out infinite;
}

.weather-alert.rain {
    background: rgba(59, 130, 246, 0.85);
}

.weather-alert.heat {
    background: rgba(249, 115, 22, 0.85);
}

.weather-alert.storm {
    background: rgba(239, 68, 68, 0.85);
}

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

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

/* Ensure weather card text stays white */
.weather-card,
.weather-card .text-white,
.weather-card .text-white\/90,
.weather-card .text-white\/95,
#weather-location,
#temperature-value,
#feels-like {
    color: white !important;
}

/* ========================================
   WINTER BACKGROUND
   ======================================== */

body.winter-theme .winter-bg-overlay {
    display: block;
}

.winter-bg-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: linear-gradient(180deg,
        rgba(15, 23, 42, 0.3) 0%,
        rgba(30, 41, 59, 0.2) 50%,
        rgba(15, 23, 42, 0.4) 100%);
    pointer-events: none;
    z-index: 1;
}

/* ========================================
   TWEMOJI STYLING
   ======================================== */

/* Base Twemoji sizing */
img.emoji {
    height: 1em;
    width: 1em;
    margin: 0 0.05em 0 0.1em;
    vertical-align: -0.1em;
    display: inline-block;
}

/* Weather icon Twemoji size */
#weather-icon img.emoji {
    height: 3.5rem;
    width: 3.5rem;
}

/* AQI emoji Twemoji size */
#aqi-emoji img.emoji {
    height: 4rem;
    width: 4rem;
}

/* Font family fallbacks */
body {
    font-family: 'IBM Plex Sans Thai', 'Noto Sans Thai', Arial, sans-serif;
}

/* Ensure backdrop-filter fallbacks work in older browsers */
.backdrop-blur-sm {
    background-color: rgba(255, 255, 255, 0.2);
}

.backdrop-blur-md {
    background-color: rgba(0, 0, 0, 0.4);
}

/* Large text sizes for AQI and temperature displays */
.text-10xl {
    font-size: 10rem !important;
    line-height: 1 !important;
}

.text-8xl {
    font-size: 8rem !important;
    line-height: 1 !important;
}

/* Support for older webkit browsers */
@supports (-webkit-backdrop-filter: blur(1px)) {
    .backdrop-blur-sm {
        -webkit-backdrop-filter: blur(8px);
        backdrop-filter: blur(8px);
        background-color: rgba(255, 255, 255, 0.15);
    }

    .backdrop-blur-md {
        -webkit-backdrop-filter: blur(16px);
        backdrop-filter: blur(16px);
        background-color: rgba(0, 0, 0, 0.4);
    }
}

/* Enhanced font sizes for 4K displays */
@media (min-width: 2560px) {
    html {
        font-size: 18px; /* Scale up base font size for 4K */
    }

    .text-9xl {
        font-size: 11rem !important;
        line-height: 1;
    }

    .text-8xl {
        font-size: 9rem !important;
        line-height: 1;
    }

    .text-6xl {
        font-size: 5.5rem !important;
        line-height: 1;
    }

    .text-5xl {
        font-size: 4.5rem !important;
        line-height: 1;
    }

    .text-4xl {
        font-size: 3.5rem !important;
        line-height: 1.1;
    }

    .text-3xl {
        font-size: 2.5rem !important;
        line-height: 1.2;
    }

    .text-2xl {
        font-size: 2rem !important;
        line-height: 1.3;
    }

    /* Extra large sizes matching React component */
    .text-10xl {
        font-size: 10rem !important;
        line-height: 1 !important;
    }

    .text-8xl {
        font-size: 8rem !important;
        line-height: 1 !important;
    }
}

/* WebOS specific adjustments */
@media screen and (min-width: 1920px) and (max-width: 3840px) {
    /* Specific adjustments for WebOS displays */
    .drop-shadow-lg {
        filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
    }

    .shadow-2xl {
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
    }
}

/* AQI Card Dynamic Styling Classes - Glassmorphism with colored tint */
/* Base glassmorphism for all AQI cards */
.aqi-card {
    -webkit-backdrop-filter: blur(20px) !important;
    backdrop-filter: blur(20px) !important;
}

.aqi-card.aqi-loading {
    background: rgba(107, 114, 128, 0.65) !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
    box-shadow: 0 25px 50px -12px rgba(107, 114, 128, 0.5), inset 0 0 80px rgba(107, 114, 128, 0.25) !important;
}

.aqi-card.aqi-good {
    background: rgba(74, 222, 128, 0.7) !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    box-shadow: 0 25px 50px -12px rgba(34, 197, 94, 0.5), inset 0 0 80px rgba(74, 222, 128, 0.25) !important;
}

.aqi-card.aqi-moderate {
    background: rgba(245, 195, 80, 0.85) !important;
    border: 1px solid rgba(255, 255, 255, 0.35) !important;
    box-shadow: 0 25px 50px -12px rgba(245, 175, 25, 0.55), inset 0 0 80px rgba(246, 211, 101, 0.35) !important;
}

/* Force white text for header elements regardless of AQI state */
header .text-white,
header p,
header h1,
#current-datetime .text-white,
#date-display,
#time-display {
    color: white !important;
}

/* Force white text for weather card elements */
#feels-like,
#weather-location,
#temperature-value,
.bg-gradient-to-br.from-blue-500 .text-white,
.bg-gradient-to-br.from-blue-500 .text-xl,
.bg-gradient-to-br.from-blue-500 .text-3xl {
    color: white !important;
}

/* Only target specific AQI elements for black text during moderate conditions */
.aqi-card.aqi-moderate #aqi-value,
.aqi-card.aqi-moderate #aqi-level,
.aqi-card.aqi-moderate #aqi-suggestion,
.aqi-card.aqi-moderate #pm25-info,
.aqi-card.aqi-moderate .text-xl.font-bold.tracking-wide,
.aqi-card.aqi-moderate .text-3xl.font-black {
    color: rgb(0, 0, 0) !important;
}

/* Make suggestion box icon dark when AQI is moderate */
.aqi-card.aqi-moderate .suggestion-box img {
    filter: brightness(0) saturate(100%) !important;
    -webkit-filter: brightness(0) saturate(100%) !important;
}

/* Make suggestion box border darker for moderate AQI */
.aqi-card.aqi-moderate .suggestion-box {
    background: rgba(0, 0, 0, 0.1);
    border-color: rgba(0, 0, 0, 0.2);
}

.aqi-card.aqi-unhealthy-sensitive {
    background: rgba(249, 135, 50, 0.75) !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    box-shadow: 0 25px 50px -12px rgba(249, 115, 22, 0.55), inset 0 0 80px rgba(249, 115, 22, 0.25) !important;
}

.aqi-card.aqi-unhealthy {
    background: rgba(239, 90, 90, 0.75) !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
    box-shadow: 0 25px 50px -12px rgba(239, 68, 68, 0.55), inset 0 0 80px rgba(239, 68, 68, 0.25) !important;
}

.aqi-card.aqi-very-unhealthy {
    background: rgba(159, 112, 255, 0.75) !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
    box-shadow: 0 25px 50px -12px rgba(139, 92, 246, 0.55), inset 0 0 80px rgba(139, 92, 246, 0.25) !important;
}

.aqi-card.aqi-hazardous {
    background: rgba(146, 54, 226, 0.8) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    box-shadow: 0 25px 50px -12px rgba(126, 34, 206, 0.6), inset 0 0 80px rgba(126, 34, 206, 0.3) !important;
}

/* Performance optimizations for older browsers */
img, svg {
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* Fallback for backdrop-filter for older browsers */
@supports not (backdrop-filter: blur(8px)) {
    .backdrop-blur-sm {
        background: rgba(255, 255, 255, 0.15) !important;
    }

    .backdrop-blur-md {
        background: rgba(0, 0, 0, 0.6) !important;
    }
}

/* Reduce border opacity for weather cards */
.bg-white\/20 {
    background-color: rgba(255, 255, 255, 0.15) !important;
}

.border-white\/20 {
    border-color: rgba(255, 255, 255, 0.1) !important;
}


/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Smooth transitions */
.transition-all {
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Ensure proper stacking and visibility */
.relative {
    position: relative;
}

.absolute {
    position: absolute;
}

.fixed {
    position: fixed;
}

/* Flexbox fallbacks for older browsers */
.flex {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
}

.flex-col {
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -webkit-flex-direction: column;
    -ms-flex-direction: column;
    flex-direction: column;
}

.justify-center {
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
}

.justify-between {
    -webkit-box-pack: justify;
    -webkit-justify-content: space-between;
    -ms-flex-pack: justify;
    justify-content: space-between;
}

.items-center {
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
}

.items-start {
    -webkit-box-align: start;
    -webkit-align-items: flex-start;
    -ms-flex-align: start;
    align-items: flex-start;
}

/* Grid fallback for very old browsers */
@supports not (display: grid) {
    .grid {
        display: block;
    }

    .grid.grid-cols-2 > div {
        float: left;
        width: 48%;
        margin-right: 2%;
        margin-bottom: 1rem;
    }

    .grid.grid-cols-2 > div:nth-child(even) {
        margin-right: 0;
    }

    /* Clear floats */
    .grid.grid-cols-2::after {
        content: "";
        display: table;
        clear: both;
    }
}

/* Ensure text remains visible during webfont load */
.font-bold,
.font-black,
.font-semibold,
.font-medium {
    font-display: swap;
}

/* SVG icons inherit color from parent */
svg {
    color: inherit;
}

/* Ensure SVG icons in weather cards are white */
.bg-white\/20 svg,
.bg-white\/20 img {
    color: white !important;
    filter: brightness(0) saturate(100%) invert(1) !important;
    -webkit-filter: brightness(0) saturate(100%) invert(1) !important;
}

/* More specific targeting for weather card icons */
.bg-white\/20 img[src*="icons"],
.grid .bg-white\/20 img,
.grid .bg-white\/20 svg {
    filter: brightness(0) saturate(100%) invert(1) !important;
    -webkit-filter: brightness(0) saturate(100%) invert(1) !important;
}

/* Ensure map-pin icon in weather header is white */
.bg-gradient-to-br.from-blue-500 img,
.bg-gradient-to-br.from-blue-500 svg {
    filter: brightness(0) saturate(100%) invert(1);
    -webkit-filter: brightness(0) saturate(100%) invert(1) !important;
}