/* --- Theme variables --- */
:root {
    color-scheme: light dark;

    /* Light theme (default) */
    --bg: #f5f7fa;
    --text: #1a1a1a;
    --text-muted: #6b7280;
    --text-secondary: #374151;
    --card-bg: white;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.06);
    --border: #d1d5db;
    --border-light: #f3f4f6;
    --border-medium: #e5e7eb;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --input-bg: white;
    --btn-hover-bg: #f3f4f6;
    --alert-bg: #fef2f2;
    --alert-border: #dc2626;
    --alert-text: #991b1b;
    --chart-axis-bg: white;
    --temp-high: #dc2626;
    --temp-low: #3b82f6;
}

[data-theme="dark"] {
    --bg: #111827;
    --text: #f3f4f6;
    --text-muted: #9ca3af;
    --text-secondary: #d1d5db;
    --card-bg: #1f2937;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.3);
    --border: #374151;
    --border-light: #2d3748;
    --border-medium: #374151;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --input-bg: #1f2937;
    --btn-hover-bg: #374151;
    --alert-bg: #451a1a;
    --alert-border: #dc2626;
    --alert-text: #fca5a5;
    --chart-axis-bg: #1f2937;
    --temp-high: #f87171;
    --temp-low: #60a5fa;
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    transition: background 0.3s, color 0.3s;
}

.view {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
}

/* Home View */
.home-header {
    text-align: center;
    padding: 20vh 0 2rem;
}

.home-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent);
}

.tagline {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* Search */
.search-container {
    max-width: 500px;
    margin: 0 auto;
}

#search-form {
    display: flex;
    gap: 0.5rem;
}

#search-input {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    outline: none;
    background: var(--input-bg);
    color: var(--text);
    transition: border-color 0.2s;
}

#search-input:focus {
    border-color: var(--accent);
}

#search-form button {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

#search-form button:hover {
    background: var(--accent-hover);
}

.error {
    color: #dc2626;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

/* Theme toggle */
#theme-toggle {
    position: fixed;
    bottom: 1.5rem;
    left: 1.5rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 1000;
    transition: background 0.2s;
}

#theme-toggle:hover {
    background: var(--btn-hover-bg);
}

/* Floating donate button */
#donate-btn {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: #ff5e5b;
    color: white;
    text-decoration: none;
    padding: 0.6rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: background 0.2s, transform 0.2s;
    z-index: 1000;
}

#donate-btn:hover {
    background: #e04e4b;
    transform: translateY(-1px);
}

/* Privacy link (shared style) */
.privacy-link {
    display: block;
    margin: 0 auto;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.privacy-link:hover {
    color: var(--text);
}

/* Fixed to bottom of screen (home page) */
.privacy-link-fixed {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
}

/* In-flow spacer (weather page) */
.bottom-spacer {
    height: 4rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Privacy panel (popup) */
#privacy-panel {
    position: fixed;
    bottom: 3rem;
    left: 50%;
    transform: translateX(-50%);
    max-width: 500px;
    width: 90%;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    max-height: 60vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 1001;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text);
}

#privacy-close {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    padding: 0.25rem;
}

#privacy-close:hover {
    color: var(--text);
}

#privacy-panel p {
    margin-bottom: 0.75rem;
}

#privacy-panel ul {
    margin: 0 0 0.75rem 1.25rem;
}

#privacy-panel li {
    margin-bottom: 0.25rem;
}

/* Weather View */
.weather-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0;
    flex-wrap: wrap;
}

.weather-toggles {
    margin-left: auto;
    display: flex;
    gap: 0.25rem;
}

#back-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.4rem 0.8rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

#back-btn:hover {
    background: var(--btn-hover-bg);
}

/* Units toggle */
.units-toggle {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.3rem 0.6rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    transition: background 0.2s;
}


.units-toggle:hover {
    background: var(--btn-hover-bg);
}

/* Section controls (drag handle + minimize) */
.section-controls {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: flex;
    gap: 0.3rem;
    z-index: 5;
    opacity: 0.4;
    transition: opacity 0.2s;
}

section:hover .section-controls,
#current-details-row:hover > .section-controls,
#sun-moon-row:hover > .section-controls {
    opacity: 1;
}

.section-drag-handle {
    cursor: grab;
    font-size: 1rem;
    color: var(--text-muted);
    user-select: none;
    touch-action: none;
    padding: 0.1rem 0.3rem;
}

.section-drag-handle:active {
    cursor: grabbing;
}

.section-min-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-muted);
    padding: 0.1rem 0.3rem;
    line-height: 1;
}

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

/* Minimized section */
.section-minimized > *:not(.section-controls) {
    display: none !important;
}

.section-minimized {
    padding: 0.75rem 1.25rem;
    cursor: pointer;
    min-height: 0;
}

.section-minimized::after {
    content: attr(data-section-name);
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Drag placeholder */
.drag-placeholder {
    background: var(--border-light);
    border: 2px dashed var(--border);
    border-radius: 12px;
    margin-bottom: 1rem;
}

.section-dragging {
    opacity: 0.85;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    border-radius: 12px;
}

/* Hidden sections bar */
#hidden-sections-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.show-section-btn {
    background: var(--card-bg);
    border: 1px dashed var(--border);
    border-radius: 6px;
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.2s;
}

.show-section-btn:hover {
    background: var(--btn-hover-bg);
    color: var(--text);
}

/* Restore defaults button */
#restore-defaults {
    position: fixed;
    bottom: 1.5rem;
    left: 4.5rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 1000;
    transition: background 0.2s;
}

#restore-defaults:hover {
    background: var(--btn-hover-bg);
}

/* Weather sections */
section {
    position: relative;
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--card-shadow);
    transition: background 0.3s;
}

#current-details-row,
#sun-moon-row {
    position: relative;
}

section h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

/* Alerts */
#alerts-section {
    background: var(--alert-bg);
    border: 2px solid var(--alert-border);
    color: var(--alert-text);
}

/* Weather summary */
#weather-summary {
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 0.75rem;
    padding: 0 0.25rem;
    line-height: 1.4;
}

#weather-summary:empty {
    display: none;
}

/* Current + Details row */
#current-details-row {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

#current-details-row #current-section {
    flex: 1;
}

#current-details-row #details-section {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.current-main {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.current-icon-block {
    text-align: center;
}

.current-icon-block .icon {
    font-size: 2.5rem;
    line-height: 1;
}

.current-icon-block .condition {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.current-temp-block .temp {
    font-size: 2rem;
    font-weight: 700;
}

.current-temp-block .feels-like {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

/* Current conditions detail grid (2 columns) */
.current-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem 1.5rem;
    margin-top: 0.75rem;
    font-size: 0.85rem;
}

/* Pollen button */
.pollen-btn {
    text-transform: none;
    font-weight: 400;
    font-size: 0.75rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.2rem 0.5rem;
    cursor: pointer;
    margin-left: 0.5rem;
    vertical-align: middle;
    transition: background 0.2s;
}

.pollen-btn:hover {
    background: var(--accent-hover);
}

.pollen-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

/* Pollen scroll */
.pollen-scroll {
    display: grid;
    grid-auto-flow: column;
    grid-template-rows: 1fr 1fr;
    gap: 0.5rem 1rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    cursor: grab;
}

.pollen-item {
    text-align: center;
    min-width: 70px;
}

/* Fewer pollen items — single row, bigger text */
.pollen-few {
    grid-template-rows: 1fr;
    justify-content: center;
}

.pollen-few .pollen-item {
    min-width: 90px;
}

.pollen-few .detail-label {
    font-size: 1.05rem;
}

.pollen-few .detail-value {
    font-size: 1.3rem;
}

.current-detail-col {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.current-detail-col .detail-item {
    display: flex;
    flex-direction: column;
}

.current-detail-col .detail-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.current-detail-col .detail-value {
    font-weight: 600;
}

@media (max-width: 600px) {
    #current-details-row {
        flex-direction: column;
    }
}

/* Hourly scroll */
.hourly-scroll {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    cursor: grab;
}

.hourly-scroll.dragging {
    cursor: grabbing;
}

.hourly-item {
    text-align: center;
    min-width: 50px;
    font-size: 0.85rem;
    flex-shrink: 0;
}

/* Daily forecast - unified scroll */
.forecast-scroll-outer {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.forecast-header {
    display: flex;
    border-bottom: 1px solid var(--border-medium);
    padding-bottom: 0.5rem;
}

.forecast-day {
    text-align: center;
    padding: 0.5rem 0.25rem;
    border-right: 1px solid var(--border-light);
    flex-shrink: 0;
}

.forecast-day:last-child {
    border-right: none;
}

.forecast-date {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.forecast-temps {
    margin: 0.25rem 0;
}

.temp-high {
    color: var(--temp-high);
    font-weight: 700;
    font-size: 0.9rem;
}

.temp-low {
    color: var(--temp-low);
    font-weight: 600;
    font-size: 0.85rem;
    margin-left: 0.25rem;
}

.forecast-icon {
    font-size: 1.5rem;
    line-height: 1;
    margin: 0.25rem 0;
}

.forecast-condition {
    font-size: 0.65rem;
    color: var(--text-muted);
    line-height: 1.2;
}

.forecast-precip {
    font-size: 0.7rem;
    color: var(--temp-low);
    margin-top: 0.25rem;
    min-height: 1em;
}

/* Chart rows */
.chart-row {
    border-top: 1px solid var(--border-light);
    margin-top: 0.5rem;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 0.5rem 0 0.25rem;
    position: sticky;
    left: 0;
    width: fit-content;
    align-items: center;
}

.chart-drag-handle {
    cursor: grab;
    color: var(--text-muted);
    opacity: 0.4;
    transition: opacity 0.2s;
    user-select: none;
    touch-action: none;
    font-size: 0.85rem;
}

.chart-row:hover .chart-drag-handle {
    opacity: 1;
}

.chart-drag-handle:active {
    cursor: grabbing;
}

.chart-row-inner {
    position: relative;
    display: flex;
    align-items: stretch;
}

.chart-axis {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-size: 0.65rem;
    padding: 4px 0;
    width: 40px;
    min-width: 40px;
    flex-shrink: 0;
    background: var(--chart-axis-bg);
    z-index: 2;
}

.chart-axis-left {
    position: sticky;
    left: 0;
    text-align: right;
    padding-right: 6px;
}

.chart-axis-right {
    position: sticky;
    right: 0;
    text-align: left;
    padding-left: 6px;
}

/* Forecast footer (bottom day labels) */
.forecast-footer {
    display: flex;
    border-top: 1px solid var(--border-medium);
    padding-top: 0.5rem;
}

.forecast-footer-day {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
}

/* Radar */
#radar-section img {
    width: 100%;
    border-radius: 8px;
}

/* Sun & Moon row */
#sun-moon-row {
    display: flex;
    gap: 1rem;
}

#sun-moon-row section {
    flex: 1;
}

.astro-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.astro-item {
    text-align: center;
}

.astro-item .label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.astro-item .value {
    font-size: 1.1rem;
    font-weight: 600;
}

@media (max-width: 600px) {
    #sun-moon-row {
        flex-direction: column;
    }
}

/* Loading state */
.loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 600px) {
    .home-header {
        padding: 15vh 0 2rem;
    }

    .home-header h1 {
        font-size: 2rem;
    }

    #search-form {
        flex-direction: column;
    }
}
