/* ── VARIABLES ── */
:root {
    --bg: #050a14;
    --surface: #0b1220;
    --card: #0d1526;
    --border: #1a2540;
    --border2: #243050;
    --green: #00e5a0;
    --green-dim: #00e5a022;
    --yellow: #f5c842;
    --red: #ff4f6d;
    --blue: #4f8fff;
    --text: #e8f0ff;
    --muted: #4a5a7a;
    --muted2: #2a3550;
    
    --font-head: 'Syne', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Dynamic variable set by JS for city colors */
    --city-color: var(--green);
}

/* ── RESET ── */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-head);
    min-height: 100vh;
    position: relative;
}

/* ── BACKGROUND ── */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: linear-gradient(rgba(0,229,160,0.03) 1px, transparent 1px),
                      linear-gradient(90deg, rgba(0,229,160,0.03) 1px, transparent 1px);
    background-size: 40px 40px;
    z-index: -1;
    pointer-events: none;
}

/* ── HEADER ── */
header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(5,10,20,0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
    font-size: 1.5rem;
}

.logo-area span {
    color: var(--green);
}

.live-badge {
    background: var(--green-dim);
    color: var(--green);
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    font-family: var(--font-mono);
    display: flex;
    align-items: center;
    gap: 6px;
}

.live-badge::before {
    content: '';
    width: 6px; height: 6px;
    background: var(--green);
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

.search-wrap {
    position: relative;
    width: 300px;
}

.search-input {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 16px;
    border-radius: 999px;
    font-family: var(--font-head);
    font-size: 1rem;
    font-weight: 600;
    outline: none;
    transition: border-color 0.3s ease;
}

.search-input:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 2px var(--green-dim);
}

.city-dropdown {
    position: absolute;
    top: 50px;
    left: 0;
    right: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    max-height: 384px;
    overflow-y: auto;
    display: none;
    flex-direction: column;
    z-index: 2000;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.city-dropdown.open {
    display: flex;
    animation: fadeUp 0.2s ease both;
}

.city-dropdown::-webkit-scrollbar {
    width: 6px;
}
.city-dropdown::-webkit-scrollbar-track {
    background: var(--card);
    border-radius: 12px;
}
.city-dropdown::-webkit-scrollbar-thumb {
    background: var(--border2);
    border-radius: 12px;
}

.dropdown-item {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    font-family: var(--font-head);
    transition: background 0.2s;
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover, .dropdown-item.focused {
    background: var(--border);
}

.dropdown-item-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dropdown-item-name {
    font-weight: 700;
    color: var(--text);
}

.dropdown-item-country {
    font-size: 0.8rem;
    color: var(--muted);
}

.dropdown-score {
    padding: 4px 10px;
    border-radius: 999px;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--card);
}

.selected-city {
    background: var(--border2);
}

main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

/* ── HERO ── */
.hero {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
    animation: fadeUp 0.6s ease both;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    transition: transform 0.2s, border-color 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    border-color: var(--border2);
}

/* ── SCORE RING ── */
.score-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.score-label {
    font-family: var(--font-mono);
    color: var(--muted);
    font-size: 0.8rem;
    letter-spacing: 1px;
    margin-bottom: 1.5rem;
}

.svg-ring-container {
    position: relative;
    width: 150px;
    height: 150px;
    margin-bottom: 1rem;
}

.score-svg {
    transform: rotate(-90deg);
    filter: drop-shadow(0 0 8px var(--city-color));
}

.score-circle-bg {
    fill: none;
    stroke: var(--border);
    stroke-width: 12;
}

.score-circle-fg {
    fill: none;
    stroke: var(--city-color);
    stroke-width: 12;
    stroke-linecap: round;
    stroke-dasharray: 427.26;
    stroke-dashoffset: 427.26;
    transition: stroke-dashoffset 1.4s cubic-bezier(.4,0,.2,1), stroke 0.5s;
}

.score-number {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-mono);
    font-size: 3rem;
    font-weight: 700;
    color: var(--city-color);
    transition: color 0.5s;
}

.score-status {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--city-color);
    transition: color 0.5s;
    margin-bottom: 0.5rem;
}

.aqi-badge {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-family: var(--font-mono);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background 0.3s, border-color 0.3s;
}

.aqi-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    transition: background 0.3s;
}

.aqi-text {
    transition: color 0.3s;
}

/* ── STAT CARDS ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: auto auto;
    gap: 1rem;
}

.stat-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.stat-wide {
    grid-column: span 2;
}

.stat-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.stat-title {
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.stat-val {
    font-size: 1.8rem;
    font-weight: 800;
    font-family: var(--font-mono);
}

.stat-val-blue { color: var(--blue); }
.stat-val-yellow { color: var(--yellow); }
.stat-val-red { color: var(--red); }
.stat-val-green { color: var(--green); }
.stat-val-large { font-size: 1.4rem; }

.stat-sub {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 4px;
}

.stat-flex-between {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
}

.mini-bars {
    display: flex;
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    margin-top: 12px;
    background: var(--border);
}

.mini-bar {
    height: 100%;
    transition: width 1.2s cubic-bezier(.4,0,.2,1), background-color 0.3s;
}

.mini-bar-green { background-color: var(--green); }
.mini-bar-red { background-color: var(--red); }
.mini-bar-blue { background-color: var(--blue); }

.mini-bar-muted-marker {
    background-color: var(--muted);
    width: 47%;
    border-left: 2px solid var(--bg);
}

/* ── TABS ── */
.tabs-header {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
    gap: 1rem;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--muted);
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    padding: 1rem 0;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    color: var(--text);
}

.tab-btn.active {
    color: var(--green);
    border-bottom-color: var(--green);
}

.tab-content {
    display: none;
    animation: fadeUp 0.3s ease both;
}

.tab-content.active {
    display: block;
}

/* ── CHARTS ── */
.overview-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.chart-title {
    margin-bottom: 1rem;
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

.compare-chart-height {
    height: 400px;
}

/* ── SECTORS ── */
.sectors-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.sector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.sector-name {
    font-size: 1.2rem;
    font-weight: 700;
}

.sector-val {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
}

.sector-bar-bg {
    background: var(--border);
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.sector-bar-fg {
    height: 100%;
    border-radius: 4px;
    transition: width 1.2s cubic-bezier(.4,0,.2,1);
    background-color: var(--sector-color, var(--text));
}

.sector-status {
    font-size: 0.8rem;
    color: var(--muted);
    font-family: var(--font-mono);
}

/* ── COMPARE ── */
/* Compare layout handled by .chart-container */

/* ── MAP ── */
.map-card {
    padding: 1rem;
}

#map {
    height: 400px;
    width: 100%;
    border-radius: 12px;
    background: var(--border);
    z-index: 10;
}

.custom-popup .leaflet-popup-content-wrapper {
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: var(--font-head);
}
.custom-popup .leaflet-popup-tip {
    background: var(--card);
    border: 1px solid var(--border);
}

.custom-map-marker {
    background-color: var(--city-color);
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 15px var(--city-color);
    width: 100%;
    height: 100%;
}

/* ── TIPS ── */
.tips-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.tip-card {
    border-left: 3px solid var(--green);
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.tip-num {
    color: var(--green);
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 1.2rem;
}

.tip-text {
    font-size: 1rem;
    line-height: 1.5;
}

/* ── FOOTER ── */
footer {
    margin-top: 4rem;
    padding: 2rem 0;
    text-align: center;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.8rem;
}

/* ── ANIMATIONS ── */
.delay-1 { animation-delay: 0.05s; }
.delay-2 { animation-delay: 0.10s; }
.delay-3 { animation-delay: 0.15s; }
.delay-4 { animation-delay: 0.20s; }
.delay-5 { animation-delay: 0.25s; }

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.5; }
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
