/* --ink, --flesh, --pit, --bruise, --cream-text are brand hues and stay
   fixed across themes — the header/footer band is always --ink, and
   --pit/--flesh/--cream-text badges (info-icon, download-button) are
   self-contained and already validated against --ink. The tokens below
   are theme-*dependent* surface/text roles: light values here on the
   bare :root, dark overrides further down (issue #45). */
:root {
    --ink: #1F1710;
    --parchment: #F6F1E4;
    --flesh: #7C8F3E;
    --pit: #8B5A2B;
    --bruise: #B4432E;
    --cream-text: #EDE6D6;
    --card-bg: #FFFFFF;
    --text: var(--ink);
    --text-muted: rgba(31, 23, 16, 0.65);
    --heading-accent: var(--pit);
    --summary-up-color: #5C7A2E;
    --summary-down-color: var(--bruise);
    --font-display: "Fraunces", serif;
    --font-body: "Inter", sans-serif;
    --font-mono: "IBM Plex Mono", monospace;
}

/* Dark mode (issue #45): --ink stays the header/footer band in both
   themes; --parchment becomes a near-black page background and
   --card-bg a slightly lighter elevated surface above it. Text-role
   tokens (--text, --text-muted, --heading-accent, --summary-*-color)
   get lighter counterparts re-validated for 4.5:1 AA contrast against
   the new dark surfaces (see specs/accessibility-dark-mode.md).
   Precedence: an explicit data-theme attribute (set by the theme
   toggle, via JS on <html>) always wins over the OS preference. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --parchment: #241C13;
        --card-bg: #332818;
        --text: var(--cream-text);
        --text-muted: rgba(237, 230, 214, 0.65);
        --heading-accent: #C99B5E;
        --summary-up-color: #9CBF5E;
        --summary-down-color: #E67A63;
    }
}

:root[data-theme="dark"] {
    --parchment: #241C13;
    --card-bg: #332818;
    --text: var(--cream-text);
    --text-muted: rgba(237, 230, 214, 0.65);
    --heading-accent: #C99B5E;
    --summary-up-color: #9CBF5E;
    --summary-down-color: #E67A63;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    margin: 0;
    background-color: var(--parchment);
}

.header {
    background-color: var(--ink);
    height: 288px;
    padding: 16px 0 0 0;
    position: relative;
}

.theme-toggle {
    position: absolute;
    top: 16px;
    right: 140px;
    display: flex;
    align-items: center;
}

.theme-toggle label {
    color: var(--cream-text);
    font-size: 16px;
    cursor: pointer;
    margin-right: 8px;
}

.theme-toggle input[type="radio"] {
    margin-right: 2px;
    cursor: pointer;
    accent-color: var(--flesh);
}

.language-toggle {
    position: absolute;
    top: 16px;
    right: 24px;
    display: flex;
    align-items: center;
}

.language-toggle label {
    color: var(--cream-text);
    font-weight: bold;
    font-size: 13px;
    cursor: pointer;
    margin-right: 12px;
}

.language-toggle input[type="radio"] {
    margin-right: 4px;
    cursor: pointer;
    accent-color: var(--flesh);
}

.header-mark {
    display: flex;
    justify-content: center;
    margin: 0 auto;
}

.header-title {
    color: var(--cream-text);
    font-family: var(--font-display);
    font-size: 48px;
    font-weight: bold;
    text-align: center;
    margin: 0 auto;
}

.header-subtitle {
    color: var(--flesh);
    font-size: 18px;
    font-weight: bold;
    text-align: center;
    margin: 10px auto 20px auto;
}

.header-link {
    color: var(--flesh);
    text-decoration: none;
    font-weight: bold;
}

.header-link:hover {
    /* --pit on --ink is only 3.03:1 (fails WCAG AA 4.5:1) — this lighter
       tan clears 7.01:1 while staying in the same warm palette. */
    color: #C99B5E;
    text-decoration: underline;
}

.header-description {
    color: var(--cream-text);
    margin: 4px auto;
    text-align: center;
    max-width: 384px;
}

.wrapper {
    margin-right: auto;
    margin-left: auto;
    max-width: 1024px;
    padding-right: 10px;
    padding-left: 10px;
    margin-top: 32px;
}

.card {
    margin-bottom: 24px;
    box-shadow: 0 4px 6px 0 rgba(0, 0, 0, 0.18);
}

.menu {
    width: 100%;
    max-width: 960px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    padding: 24px 10px;
    margin: 0 auto;
    background-color: var(--parchment);
}

.menu > div {
    flex: 1 1 220px;
    padding: 0 32px;
    border-left: 1px solid var(--heading-accent);
}

.menu > div:first-child {
    border-left: none;
}

/* Known limitation (dark mode, issue #45): the dcc.Dropdown popover and
   dcc.DatePickerRange calendar are third-party react-select/react-dates
   internals this repo doesn't fully theme (same category of upstream
   limitation already documented for axe-core in issue #44) — they keep
   their default light styling in dark mode. */
.Select-control {
    width: 100%;
    height: 48px;
}

@media (max-width: 768px) {
    .menu {
        flex-direction: column;
    }

    .menu > div {
        flex: none;
        border-left: none;
        width: 100%;
    }
}

.Select--single>.Select-control .Select-value,
.Select-placeholder {
    line-height: 48px;
}

.Select--multi .Select-value-label {
    line-height: 32px;
}

.menu-title {
    margin-bottom: 6px;
    font-weight: bold;
    color: var(--heading-accent);
    display: flex;
    align-items: center;
    gap: 6px;
}

.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: var(--pit);
    color: var(--cream-text);
    font-family: Georgia, serif;
    font-size: 11px;
    font-weight: bold;
    font-style: italic;
    line-height: 1;
    cursor: help;
}

.export-section {
    margin: 24px auto 0 auto;
    max-width: 1024px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.download-button {
    background-color: var(--pit);
    color: var(--cream-text);
    border: none;
    border-radius: 4px;
    padding: 10px 20px;
    font-family: var(--font-body);
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 4px 6px 0 rgba(0, 0, 0, 0.18);
}

.download-button:disabled {
    background-color: rgba(139, 90, 43, 0.35);
    cursor: not-allowed;
}

.download-status {
    color: var(--text-muted);
    font-style: italic;
    font-size: 13px;
}

.summary-panel {
    margin: 24px auto 0 auto;
    max-width: 1024px;
    padding: 0 10px;
}

.summary-stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-evenly;
    gap: 16px;
    background-color: var(--card-bg);
    box-shadow: 0 4px 6px 0 rgba(0, 0, 0, 0.18);
    padding: 20px;
}

.summary-stat {
    text-align: center;
    min-width: 160px;
}

.summary-stat-label {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 6px;
}

.summary-stat-value {
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 24px;
    font-weight: bold;
}

.summary-stat-up {
    color: var(--summary-up-color);
}

.summary-stat-down {
    color: var(--summary-down-color);
}

.summary-empty {
    background-color: var(--card-bg);
    box-shadow: 0 4px 6px 0 rgba(0, 0, 0, 0.18);
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
}

.footer {
    background-color: var(--ink);
    padding: 20px 0;
    margin-top: 40px;
    text-align: center;
}

.footer-text {
    color: var(--cream-text);
    margin: 0;
    font-size: 14px;
}

.footer-link {
    color: var(--flesh);
    text-decoration: none;
    font-weight: bold;
}

.footer-link:hover {
    /* --pit on --ink is only 3.03:1 (fails WCAG AA 4.5:1) — same fix as
       .header-link:hover. */
    color: #C99B5E;
    text-decoration: underline;
}