/* Night mode. Day colors stay in the style-*.css :root blocks.
   html[data-theme="dark"] wins on specificity, so one palette covers
   style 1, 2, and 3. Chart images are not filtered. */

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.header-top h1 {
    flex: 1 1 auto;
    min-width: 0;
    margin-bottom: 0;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    padding: 0;
    border-radius: 999px;
    border: 1px solid rgba(12, 36, 64, 0.18);
    background: rgba(255, 255, 255, 0.94);
    color: inherit;
    line-height: 0;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(12, 36, 64, 0.08);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.theme-toggle:hover {
    background: rgba(12, 36, 64, 0.06);
}

.theme-toggle:focus-visible {
    outline: 2px solid #3d8fd4;
    outline-offset: 2px;
}

.theme-toggle:active {
    transform: scale(0.98);
}

.theme-toggle-when-day,
.theme-toggle-when-night {
    display: block;
    width: 22px;
    height: 22px;
}

.theme-toggle-when-night {
    display: none;
}

html[data-theme="dark"] .theme-toggle {
    border-color: rgba(186, 214, 242, 0.32);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: none;
}

html[data-theme="dark"] .theme-toggle:hover {
    background: rgba(255, 255, 255, 0.14);
}

html[data-theme="dark"] .theme-toggle-when-day {
    display: none;
}

html[data-theme="dark"] .theme-toggle-when-night {
    display: block;
}

/* Replaces inline legend colors so night mode can restyle them.
   Day values match the previous inline styles. */
.legend-note {
    font-size: 12px;
    color: #7f8c8d;
    margin-top: 10px;
    text-align: center;
}

.legend-subtitle {
    font-size: 16px;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 10px;
}

.fronts-error a {
    color: #667eea;
}

html[data-theme="dark"] {
    color-scheme: dark;
    background-color: #0b1524;
    --foreground: #e8f1fb;
    --card: #132033;
    --card-foreground: #e8f1fb;
    --primary: #0b5cab;
    --primary-foreground: #f5fbff;
    --secondary: #1c3a56;
    --muted: #1a3046;
    --muted-foreground: #a9c0d6;
    --border: rgba(168, 198, 230, 0.22);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 18px 40px rgba(0, 0, 0, 0.45);
    --page-background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.18), transparent 26%),
        radial-gradient(circle at top right, rgba(14, 165, 233, 0.12), transparent 22%),
        linear-gradient(180deg, #0b1524 0%, #0e1c2e 48%, #0a121c 100%);
    --tabs-background: #102033;
    --tab-active-border: rgba(255, 255, 255, 0.16);
    --current-gradient: linear-gradient(180deg, #1a6fbf 0%, #0b5cab 100%);
    --current-foreground: #f5fbff;
    --current-border: rgba(126, 186, 232, 0.7);
    --interactive-border: rgba(126, 184, 232, 0.5);
    --old-bg: #3d3114;
    --old-fg: #ffe08a;
    --old-border: #8a6d2e;
    --forecast-bg: #10283d;
    --forecast-border: #2f5f8a;
    --unavailable-bg: #101923;
    --unavailable-fg: #c5d4e4;
    --status-default-bg: rgba(80, 164, 224, 0.18);
    --status-default-border: rgba(80, 164, 224, 0.32);
    --status-default-fg: #9ed0ff;
    --status-old-bg: rgba(255, 208, 120, 0.16);
    --status-old-border: rgba(255, 208, 120, 0.32);
    --status-old-fg: #ffe08a;
    --status-accent-bg: rgba(56, 189, 248, 0.16);
    --status-accent-border: rgba(56, 189, 248, 0.32);
    --status-accent-fg: #8fd4ff;
    --status-current-bg: rgba(0, 0, 0, 0.22);
    --status-current-border: rgba(255, 255, 255, 0.24);
    --status-unavailable-bg: rgba(197, 212, 228, 0.14);
    --status-unavailable-border: rgba(197, 212, 228, 0.28);
    --status-unavailable-fg: #d5e2ef;
    --danger: #ff8fab;
    --loading-bg: rgba(16, 28, 42, 0.9);
    --table-hover: rgba(255, 255, 255, 0.06);
    --error-bg: #3d1524;
    --error-fg: #ffc0cc;
    --error-border: rgba(255, 176, 190, 0.4);
}

html[data-theme="dark"] .legend-note {
    color: var(--muted-foreground);
}

html[data-theme="dark"] .legend-subtitle,
html[data-theme="dark"] .fronts-error a {
    color: #b9d0ff;
}

/* Secondary text on the current card is translucent in day mode.
   On the night gradient that drops below readable contrast. */
html[data-theme="dark"] .chart-card.current .chart-date,
html[data-theme="dark"] .chart-card.current .availability-info,
html[data-theme="dark"] .chart-card.current .tap-hint {
    opacity: 1;
}

html[data-theme="dark"] .chart-card.unavailable {
    opacity: 1;
}

html[data-theme="dark"] header::after {
    background: radial-gradient(circle, rgba(140, 176, 204, 0.14), transparent 60%);
}
