/*
 * Publication mode — for every visitor; base.html links it on every page.
 * The admin-only parts (brand removal, downloads) are switched by
 * publication-mode.js from the server's configuration.
 *
 * Structure only. Every colour comes from the identity files at runtime
 * (publication-white-v1.json + .page-adapter.json): publication-mode.js
 * writes the site's tokens (--bg-primary, --fg-primary, …) for
 * html[data-publication-mode="on"] and maps literal colours role by role.
 * There is deliberately no filter: invert() anywhere.
 */

:root {
    --pub-font: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

/* ── The page in the white identity ─────────────────────────────────── */

html[data-publication-mode="on"],
html[data-publication-mode="on"] body {
    background: #FFFFFF;
    color: #222222;
    color-scheme: light;
}

html[data-publication-mode="on"] body {
    font-family: var(--pub-font);
    font-variant-numeric: tabular-nums;
}

/* One typeface throughout, as the identity specifies. Icon fonts and code keep theirs. */
html[data-publication-mode="on"] body *:not(i):not(.fa):not(.fas):not(.far):not(.fab):not(.fa-solid):not(.fa-regular):not(.fa-brands):not([class^="fa-"]):not([class*=" fa-"]):not(code):not(pre):not(kbd):not(samp) {
    font-family: var(--pub-font) !important;
}

html[data-publication-mode="on"] .navbar {
    background: #FFFFFF !important;
    border-bottom: 1px solid #DEDEDE;
}

html[data-publication-mode="on"] ::selection {
    background: rgba(229, 138, 22, 0.22);
    color: #222222;
}

html[data-publication-mode="on"] input,
html[data-publication-mode="on"] select,
html[data-publication-mode="on"] textarea {
    color-scheme: light;
}

html[data-publication-mode="on"] .table {
    --bs-table-color: #222222;
    --bs-table-bg: transparent;
    --bs-table-border-color: #DEDEDE;
    --bs-table-striped-color: #222222;
    --bs-table-striped-bg: #F7F7F7;
    --bs-table-hover-color: #222222;
    --bs-table-hover-bg: #F2F2F2;
}

/* Brand marks found by script (inline SVG logos) are hidden with this class. */
html[data-publication-mode="on"] .pub-brand-hidden {
    display: none !important;
}

@media print {
    .pub-dock { display: none !important; }
}

/* ── Dock: the toggle, readable in both modes ───────────────────────── */

.pub-dock {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 1090;
    width: max-content;
    max-width: min(440px, calc(100vw - 32px));
    font: 500 12px/1.35 var(--pub-font) !important;
    color: #222222;
    background: #FFFFFF;
    border: 1px solid #C9C9C9;
    border-radius: 10px;
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.28);
    letter-spacing: 0;
    text-transform: none;
}

html[data-publication-mode="on"] .pub-dock {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.pub-dock * {
    font-family: var(--pub-font) !important;
    box-sizing: border-box;
}

.pub-dock-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
}

.pub-dock-tag {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #FFFFFF;
    background: #5A5A5A;
    border-radius: 4px;
    padding: 2px 6px;
}

.pub-switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 2px 4px;
    border: 0;
    background: transparent;
    color: #222222;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
}

.pub-switch:focus-visible,
.pub-dock button:focus-visible {
    outline: 2px solid #B56B11;
    outline-offset: 2px;
}

.pub-switch-track {
    position: relative;
    width: 34px;
    height: 20px;
    flex: 0 0 34px;
    border-radius: 10px;
    background: #BDBDBD;
    transition: background 0.15s ease;
}

.pub-switch-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #FFFFFF;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
    transition: transform 0.15s ease;
}

.pub-switch[aria-checked="true"] .pub-switch-track {
    background: #B56B11;
}

.pub-switch[aria-checked="true"] .pub-switch-thumb {
    transform: translateX(14px);
}

.pub-switch[aria-busy="true"] {
    opacity: 0.6;
    cursor: progress;
}

.pub-switch-state {
    min-width: 2em;
    font-weight: 500;
    color: #626262;
}

.pub-dock-more {
    margin-left: auto;
    border: 1px solid #C9C9C9;
    border-radius: 6px;
    background: #FFFFFF;
    color: #222222;
    font: inherit;
    padding: 3px 8px;
    cursor: pointer;
}

.pub-dock-panel {
    border-top: 1px solid #E3E3E3;
    padding: 8px 10px 10px;
    max-height: 50vh;
    overflow-y: auto;
}

.pub-dock-panel h2 {
    margin: 0 0 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #626262;
}

.pub-dock-chart {
    padding: 6px 0;
    border-bottom: 1px solid #EFEFEF;
}

.pub-dock-chart:last-child {
    border-bottom: 0;
}

.pub-dock-chart-name {
    font-weight: 600;
    color: #222222;
}

.pub-dock-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.pub-dock button.pub-btn,
.pub-chart-actions button.pub-btn {
    border: 1px solid #C9C9C9;
    border-radius: 5px;
    background: #FFFFFF;
    color: #222222;
    font: 600 11px/1.2 var(--pub-font);
    padding: 4px 9px;
    cursor: pointer;
}

.pub-dock button.pub-btn:hover,
.pub-chart-actions button.pub-btn:hover {
    border-color: #8C8C8C;
}

.pub-dock button.pub-btn[disabled],
.pub-chart-actions button.pub-btn[disabled] {
    opacity: 0.55;
    cursor: progress;
}

.pub-dock a.pub-link {
    color: #8A520D;
    font-weight: 600;
    text-decoration: underline;
}

.pub-dock-job {
    margin-top: 4px;
    color: #626262;
    font-size: 11px;
    overflow-wrap: anywhere;
}

.pub-dock-status {
    padding: 0 10px 7px;
    color: #626262;
    font-size: 11px;
}

.pub-dock-status:empty {
    display: none;
}

.pub-dock-status.is-error {
    color: #A63A37;
}

/* Secondary per-chart download buttons: only in publication mode, outside the chart. */
.pub-chart-actions {
    display: none;
    justify-content: flex-end;
    gap: 6px;
    padding: 6px 0;
    grid-column: 1 / -1;    /* never a grid cell of the chart's own layout */
    flex: 0 0 100%;
}

html[data-publication-mode="on"] .pub-chart-actions {
    display: flex;
}

.pub-chart-actions-label {
    align-self: center;
    margin-right: 2px;
    font: 500 11px/1.2 var(--pub-font);
    color: #626262;
}

@media (max-width: 560px) {
    .pub-dock {
        left: 16px;
        right: 16px;
        bottom: 12px;
        width: auto;
        max-width: none;
    }

    /* The dock spans the bottom edge on phones: keep the page's last lines above it. */
    body:has(#pub-dock) {
        padding-bottom: 72px;
    }
}

@media print {
    .pub-dock,
    .pub-chart-actions {
        display: none !important;
    }
}
