/* 
   Stability-Focused Weather Styles
   Objective: Prevent Layout Shift, strictly enforce container widths.
*/

:root {
    --bg-dark: #0f172a;
    --accent: #38bdf8;
    --accent-grad: linear-gradient(135deg, #38bdf8, #2563eb);
    --glass: rgba(255, 255, 255, 0.08);
    --glass-high: rgba(15, 23, 42, 0.95);
    /* For mobile menu */
    --border: rgba(255, 255, 255, 0.12);
    --text-main: #fff;
    --text-dim: #94a3b8;
    --radius: 16px;
    --max-w: 1200px;
}

/* --- Resets & Global Safety --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    /* Native smooth scroll */
    scroll-padding-top: 80px;
    /* Offset for sticky header */
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    background-color: var(--bg-dark);
    overflow-x: hidden;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

img,
svg {
    max-width: 100%;
    display: block;
}

button {
    font-family: inherit;
}

/* --- Backgrounds --- */
.app-background {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -2;
    background: linear-gradient(to bottom right, #1e3a8a, #0e7490);
    transition: background 1s ease;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    background: rgba(15, 23, 42, 0.4);
}

/* --- Layout Utility --- */
.container {
    width: 100%;
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 20px;
}

/* --- Ticker --- */
.ticker-wrapper {
    height: 32px;
    background: #020617;
    border-bottom: 1px solid var(--border);
    overflow: hidden;
    display: flex;
    align-items: center;
}

.ticker-track {
    white-space: nowrap;
    animation: scroll 60s linear infinite;
    padding-left: 100%;
    font-size: 0.8rem;
    color: var(--text-dim);
}

.ticker-item {
    margin-right: 40px;
    display: inline-block;
}

@keyframes scroll {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-100%);
    }
}

/* --- Header --- */
.site-header {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-inner {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

/* Logo */
.logo-area {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    cursor: pointer;
    transition: opacity 0.2s;
}

.logo-area:hover {
    opacity: 0.8;
}

.logo-icon {
    font-size: 1.5rem;
}

.logo-text h1 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
    line-height: 1;
}

.badge {
    font-size: 0.6rem;
    background: var(--accent-grad);
    padding: 2px 6px;
    border-radius: 4px;
    vertical-align: middle;
}

/* Search */
.search-area {
    flex: 1;
    max-width: 400px;
}

.search-input-wrap {
    display: flex;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px;
}

.search-input-wrap input {
    flex: 1;
    background: transparent;
    border: none;
    color: #fff;
    padding: 6px 10px;
    font-size: 0.9rem;
    min-width: 0;
    outline: none;
}

.search-input-wrap button {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0 8px;
    font-size: 1rem;
    transition: transform 0.2s;
}

.search-input-wrap button:hover {
    transform: scale(1.1);
    color: var(--accent);
}

/* Nav */
.main-nav {
    display: flex;
    gap: 30px;
    flex-shrink: 0;
}

.nav-link {
    color: var(--text-dim);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    position: relative;
    padding: 5px 0;
    transition: color 0.2s;
}

.nav-link:hover,
.nav-link.active {
    color: #fff;
}

/* Animated Underline */
.nav-link::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: 0;
    left: 0;
    background-color: var(--accent);
    transition: width 0.3s ease;
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

/* Mobile Toggle */
#mobile-toggle {
    display: none;
    /* Desktop default */
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
}

/* --- Main Grid --- */
.main-wrapper {
    margin-top: 30px;
    margin-bottom: 60px;
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 30px;
    align-items: start;
}

/* --- Components --- */
.glass-panel {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius);
    padding: 24px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    width: 100%;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.glass-panel:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.4);
}

h3 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    font-weight: 600;
}

/* AI Insight */
.ai-panel {
    background: linear-gradient(90deg, rgba(56, 189, 248, 0.1), rgba(37, 99, 235, 0.1));
    border-color: rgba(56, 189, 248, 0.3);
    padding: 16px 20px;
    margin-bottom: 24px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: normal;
}

/* Current Weather */
.current-weather-panel {
    margin-bottom: 30px;
}

.cw-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.cw-loc h2 {
    font-size: 1.8rem;
    line-height: 1.2;
    word-break: break-word;
}

.tag {
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
}

.cw-body {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.cw-icon-area .weather-icon-lg {
    font-size: 4rem;
}

.cw-temp-area {
    display: flex;
    align-items: center;
    gap: 15px;
}

.main-temp {
    font-size: 4rem;
    font-weight: 700;
    line-height: 1;
}

.condition-area p {
    font-size: 1.2rem;
    font-weight: 600;
    text-transform: capitalize;
}

.condition-area .feels-like {
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--text-dim);
}

.cw-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 15px;
    border-top: 1px solid var(--border);
    padding-top: 20px;
}

.stat-box {
    display: flex;
    flex-direction: column;
}

.stat-box label {
    font-size: 0.7rem;
    color: var(--text-dim);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.stat-box span {
    font-weight: 600;
    font-size: 1rem;
}

/* Hourly */
.section-block {
    margin-bottom: 30px;
    scroll-margin-top: 100px;
    /* Offset anchor */
}

.hourly-scroller {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding-bottom: 10px;
    scrollbar-width: thin;
    white-space: nowrap;
}

.hourly-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 60px;
}

/* Radar */
.radar-view {
    height: 300px;
    background: #0f172a;
    border-radius: 12px;
    margin-bottom: 15px;
    z-index: 10;
    position: relative;
}

.radar-tools {
    display: flex;
    gap: 10px;
}

.radar-tools button {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
}

.radar-tools button:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Lifestyle */
.lifestyle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 15px;
}

.ls-card {
    text-align: center;
    padding: 15px;
}

.ls-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 8px;
}

.ls-val {
    font-weight: 700;
    display: block;
}

.ls-good {
    color: #4ade80;
}

.ls-mod {
    color: #facc15;
}

/* Sidebar */
.daily-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.daily-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.daily-row:last-child {
    border: none;
}

.btn-full {
    width: 100%;
    padding: 10px;
    margin-top: 15px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    border-radius: 8px;
    cursor: pointer;
}

/* News */
.news-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.news-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.news-item:last-child {
    border: none;
    padding-bottom: 0;
}

.news-title {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.4;
    color: #fff;
    text-decoration: none;
}

.news-title:hover {
    color: var(--accent);
    text-decoration: underline;
}

.news-meta {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.astro-row {
    display: flex;
    justify-content: space-around;
    text-align: center;
}

.astro-bit span {
    display: block;
    color: var(--text-dim);
    font-size: 0.8rem;
    margin-bottom: 4px;
}

.poll-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.poll-opt {
    padding: 10px;
    border: 1px solid var(--border);
    background: transparent;
    color: #fff;
    border-radius: 8px;
    text-align: left;
    cursor: pointer;
}

.poll-opt:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent);
}

.hidden {
    display: none;
}

#poll-res {
    color: #4ade80;
    font-weight: 600;
    margin-top: 10px;
}

/* Footer */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 40px 0;
    margin-top: auto;
    background: rgba(2, 6, 23, 0.5);
}

.footer-inner {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 30px;
}

.f-col h4 {
    font-size: 1rem;
    margin-bottom: 8px;
}

.block-links a {
    display: block;
    color: var(--text-dim);
    text-decoration: none;
    margin-bottom: 8px;
}

.f-copy {
    width: 100%;
    border-top: 1px solid var(--border);
    margin-top: 20px;
    padding-top: 20px;
    color: var(--text-dim);
    font-size: 0.8rem;
    text-align: center;
}

/* Mobile & Premium Responsiveness */
@media (max-width: 900px) {
    .content-grid {
        grid-template-columns: minmax(0, 1fr);
    }
    .primary-col, .col-sidebar {
        min-width: 0;
    }
    .search-area {
        max-width: 300px;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 0 15px;
    }

    .header-inner {
        flex-wrap: wrap;
        padding: 15px 0;
        height: auto;
        justify-content: flex-start;
    }

    #mobile-toggle {
        display: block;
        order: 2;
        margin-left: auto;
    }

    .logo-area {
        order: 1;
        flex: 1;
    }

    .logo-text h1 {
        font-size: 1.1rem;
    }

    /* Premium Mobile Menu */
    .main-nav {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: rgba(15, 23, 42, 0.95);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        padding: 0;
        gap: 0;
        border-bottom: 1px solid var(--border);
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
        z-index: 999;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.4s cubic-bezier(0.16, 1, 0.3, 1), padding 0.4s ease;
    }

    .main-nav.open {
        max-height: 400px;
        padding: 20px 0;
    }

    .nav-link {
        font-size: 1.1rem;
        padding: 15px 20px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        text-align: center;
        opacity: 0;
        transform: translateY(-10px);
        transition: opacity 0.3s ease, transform 0.3s ease;
    }

    .main-nav.open .nav-link {
        opacity: 1;
        transform: translateY(0);
    }
    
    .main-nav.open .nav-link:nth-child(1) { transition-delay: 0.1s; }
    .main-nav.open .nav-link:nth-child(2) { transition-delay: 0.15s; }
    .main-nav.open .nav-link:nth-child(3) { transition-delay: 0.2s; }

    .search-area {
        order: 3;
        flex: 0 0 100%;
        width: 100%;
        max-width: 100%;
        margin-top: 15px;
        display: block;
    }

    .search-input-wrap {
        padding: 8px 12px;
        border-radius: 12px;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.1);
        display: flex;
        align-items: center;
        width: 100%;
    }

    .search-input-wrap input {
        font-size: 1rem;
        width: 100%;
    }

    /* Adjust main content spacing */
    .main-wrapper {
        margin-top: 15px;
    }
    
    .glass-panel {
        padding: 20px 15px;
    }

    .ai-panel {
        font-size: 0.95rem;
        line-height: 1.5;
    }
    
    .cw-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        margin-bottom: 15px;
    }
    
    .cw-badges {
        display: flex;
        gap: 8px;
    }
    
    .cw-loc h2 {
        font-size: 1.4rem;
    }
    
    .cw-body {
        gap: 15px;
    }
    
    .main-temp {
        font-size: 3rem;
    }
    
    .cw-icon-area .weather-icon-lg {
        font-size: 3rem;
    }
    
    .condition-area p {
        font-size: 1.1rem;
    }
    
    /* Force stats grid to wrap perfectly on iPhone */
    .cw-stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
        padding-top: 15px;
    }
    
    .hourly-item {
        min-width: 55px;
    }
    
    .radar-view {
        height: 200px;
    }
}

/* Skeleton */
.loading-pulse,
.loading-pulse-text {
    animation: pulse 1.5s infinite ease-in-out;
    color: transparent !important;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

@keyframes pulse {
    0% {
        opacity: 0.5;
    }

    50% {
        opacity: 0.8;
    }

    100% {
        opacity: 0.5;
    }
}

.skeleton-box {
    height: 100px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.skeleton-hourly {
    width: 60px;
    height: 80px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    flex-shrink: 0;
}

.skeleton-row {
    height: 40px;
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.skeleton-text-block {
    height: 60px;
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

.modal-card {
    max-width: 350px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    transform: scale(1);
    transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.modal-card h3 {
    margin-bottom: 10px;
    color: var(--accent);
}

.modal-card p {
    font-size: 1.1rem;
    margin-bottom: 25px;
    line-height: 1.5;
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.btn-modal {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    font-size: 1rem;
    transition: all 0.2s;
}

.btn-modal:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.yes {
    background: #4ade80;
    color: #064e3b;
}

.yes:hover {
    background: #22c55e;
}

.no {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
}

.no:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: white;
}