/* FLUXNET Data viewer — visual chrome.
   Dash auto-serves any *.css under /assets/.  Keep the rules minimal
   so we don't fight Plotly's defaults inside the map. */

:root {
    --header-h:    72px;
    --footer-h:    56px;
    --brand:       #3768B8;     /* header / footer background */
    --brand-fg:    #ffffff;     /* text on the brand colour */
    --brand-fg-soft: #d8e3f4;   /* secondary text on brand bg (less prominent) */
    --muted:       #555;
    --bg-strip:    #f4f6f9;
}

html, body, .app-root {
    margin: 0;
    padding: 0;
    background: white;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
                 Roboto, Oxygen, Ubuntu, "Helvetica Neue", Arial, sans-serif;
    color: #222;
}

.app-root {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-main {
    flex: 1;
    padding: 8px 16px;
}

/* ── Header ─────────────────────────────────────────────────────── */

.app-header {
    height: var(--header-h);
    background: var(--brand);
    color: var(--brand-fg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    gap: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-logo {
    height: 58px;       /* +20 % over the original 48 px */
    width: auto;
    display: block;
    /* The bundled FLUXNET PNG (cropped-Fluxnet_logo_trans.png) ships
       with its own colour palette designed to read on a dark
       backdrop, so no white inset needed. */
}

.brand-title {
    margin: 0;
    font-size: 18px;
    color: var(--brand-fg);
    font-weight: 600;
    letter-spacing: 0.2px;
}

/* Single-line, fits the header bar; ellipsis if too long.  Hovering
   the truncated text shows the full string via the `title` attr set
   in app.py header_bar(). */
.latest-strip {
    font-size: 13px;
    color: var(--brand-fg);
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex: 1;
    min-width: 0;          /* allow shrink inside flex */
    justify-content: flex-end;
    line-height: 1.3;
}

.latest-label {
    font-weight: 500;
    color: var(--brand-fg-soft);
    flex: 0 0 auto;
    white-space: nowrap;
}

.latest-value {
    color: var(--brand-fg);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 0 1 auto;
    min-width: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12.5px;
}

/* The site_id + name in the latest-update banner is a link that opens
   the same landing page as clicking the marker on the map. */
.latest-link {
    color: var(--brand-fg);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12.5px;
    text-decoration: underline;
    text-decoration-color: rgba(255, 255, 255, 0.5);
    text-underline-offset: 2px;
    white-space: nowrap;
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}
.latest-link:hover { text-decoration-color: var(--brand-fg); }

/* ── First-use consent modal ───────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 30, 50, 0.55);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal {
    background: white;
    border-radius: 8px;
    padding: 24px 26px 20px;
    max-width: 540px;
    width: 90vw;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
    color: #222;
}

.modal-title {
    margin: 0 0 6px;
    color: var(--brand);
    font-size: 18px;
}

.modal-intro { margin: 0 0 12px; color: #444; font-size: 14px; }

.consent-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 8px 0 18px;
}

.consent-label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
    font-size: 13.5px;
    color: #222;
    line-height: 1.4;
}

.consent-checkbox {
    margin-top: 3px;
    cursor: pointer;
    flex-shrink: 0;
}

.consent-label a {
    color: var(--brand);
    text-decoration: underline;
}

.modal .dl-button:disabled {
    background: #b6c6df;
    color: #f4f6f9;
    cursor: not-allowed;
    box-shadow: none;
}

/* ── Load-error banner ─────────────────────────────────────────── */

.load-error-banner {
    background: #fff3cd;
    border: 1px solid #ffe69c;
    border-radius: 6px;
    padding: 10px 14px;
    margin-bottom: 8px;
    font-size: 13px;
    color: #664d03;
    line-height: 1.4;
}

.load-error-banner strong { color: #5b3d00; }

/* ── Controls strip ────────────────────────────────────────────── */

.controls-strip {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 4px;
    background: var(--bg-strip);
    border-radius: 6px;
    margin-bottom: 6px;
}

.ctrl-label    { font-weight: 500; }
.counts        { font-size: 13px; color: var(--muted); }
.counts-extra  { font-size: 13px; color: var(--brand); font-weight: 600; }
.store-cfg     { margin-left: auto; font-size: 12px; color: #888;
                 font-family: ui-monospace, SFMono-Regular, Menlo,
                              Consolas, monospace; }

/* ── Map area + right-rail network legend ──────────────────────── */

.map-area {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.map-graph { flex: 1; min-width: 0; }   /* let the map shrink */

/* Rail that stacks the three filter widgets (networks / years /
   ecosystems) on the right side of the map. */
.legend-rail {
    flex: 0 0 220px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 720px;
    overflow-y: auto;
}

.network-legend,
.year-filter,
.ecosystem-legend {
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 13px;
}

/* Networks now sits inside the rail; bound it to the rail's width. */
.network-legend { flex: 0 0 auto; }

.year-filter   { flex: 0 0 auto; }
.ecosystem-legend { flex: 1 1 auto; min-height: 0; }

/* The on-toggle sits in the year header (small, like a chip). */
.year-toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--brand);
    cursor: pointer;
    user-select: none;
}

/* Year filter: two compact number inputs (from / until) side by
   side; replaces the RangeSlider that didn't fit the rail's width.
   Layout uses display:flex set by the toggle callback so the on
   state lays the row out and the off state hides it entirely. */
.year-inputs-wrap {
    padding: 6px 0 0;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.year-input {
    width: 54px;
    padding: 3px 5px;
    font-size: 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    color: #222;
    font-variant-numeric: tabular-nums;
    -moz-appearance: textfield;       /* hide Firefox spinner — too cramped */
}
.year-input::-webkit-outer-spin-button,
.year-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.year-input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 2px rgba(55, 104, 184, 0.18);
}

.year-input-label {
    font-size: 11px;
    color: #666;
}

/* Ecosystem list: max-height ≈ seven rows tall, then scroll the
   rest.  Each row is ~24 px; 7 * 24 = 168 px plus a little
   breathing room. */
.ecosystem-list-wrap {
    max-height: 185px;
    overflow-y: auto;
    padding-right: 4px;          /* breathing room next to the scrollbar */
}

/* One-line ecosystem row: label first, count flush-right, ellipsis on
   the label when the network name + label collide with the count. */
.eco-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
}
.eco-row .legend-text {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.eco-count {
    flex: 0 0 auto;
    font-size: 11px;
    color: #666;
    font-variant-numeric: tabular-nums;
}

.legend-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #eee;
    padding-bottom: 6px;
    margin-bottom: 6px;
}

.legend-title {
    font-weight: 600;
    color: var(--brand);
    font-size: 13px;
}

.legend-bulk { display: inline-flex; gap: 4px; }

.legend-btn {
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 11px;
    color: var(--brand);
    cursor: pointer;
    line-height: 1.3;
}

.legend-btn:hover { background: #f0f4fa; border-color: #aac; }
.legend-btn:active { background: #e0eaf5; }

.legend-list { display: flex; flex-direction: column; gap: 2px; }

.legend-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 2px 0;
    user-select: none;
}

.legend-checkbox { margin-right: 0; cursor: pointer; }

.legend-row { display: inline-flex; align-items: center; gap: 6px; }

.legend-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid #1f1f1f;
}

.legend-text {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    color: #222;
}

/* When the checkbox is OFF, fade the swatch + line-through the text.
   Two selectors for robustness across browsers:
   - :has() — modern Chromium / Firefox 121+ / Safari 15.4+
   - adjacent-sibling — universal CSS-3 fallback (works since IE7)
   Dash's Checklist renders <input ...> as a sibling of the option-
   label <span>, so the ~ combinator catches both layouts.            */
.legend-label:has(.legend-checkbox:not(:checked)) .legend-swatch,
.legend-checkbox:not(:checked) ~ * .legend-swatch {
    background: #cccccc !important;
    border-color: #aaa;
}
.legend-label:has(.legend-checkbox:not(:checked)) .legend-text,
.legend-checkbox:not(:checked) ~ * .legend-text {
    color: #999;
    text-decoration: line-through;
}

/* ── Site landing page ─────────────────────────────────────────── */

.nee-preview {
    margin: 12px 0 16px;
    border: 1px solid #e3e3e3;
    border-radius: 6px;
    padding: 4px 4px 0;
    background: white;
}

.nee-preview-empty {
    padding: 16px;
    text-align: center;
}
.nee-preview-empty .muted { color: #777; margin: 0; }

/* ── Code snippet "harmonica" ──────────────────────────────────── */

.code-acc {
    margin: 4px 0 14px;
}

.code-acc summary {
    cursor: pointer;
    padding: 6px 10px;
    color: var(--brand);
    background: #f0f4fb;
    border: 1px solid #cdd9ec;
    border-radius: 4px;
    font-size: 13px;
    user-select: none;
}

.code-acc summary:hover { background: #e7eef9; }

.code-block {
    margin: 6px 0 0;
    padding: 10px 12px;
    background: #1f2733;
    color: #e3eaf3;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12.5px;
    line-height: 1.5;
    overflow-x: auto;
    white-space: pre;
}

/* ── Citation / license / download ─────────────────────────────── */

.citation-block {
    margin: 16px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.citation-row {
    font-size: 13px;
    line-height: 1.45;
    color: #222;
    background: #f6f9fd;
    border-left: 3px solid var(--brand);
    padding: 8px 12px;
    border-radius: 0 4px 4px 0;
}
.citation-row .cite-text { color: #222; }
.citation-row .doi-link {
    color: var(--brand);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12.5px;
    word-break: break-all;
}
.citation-row .doi-link:hover { text-decoration: underline; }

.download-row {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.dl-button {
    display: inline-block;
    background: var(--brand);     /* #3768B8 */
    color: var(--brand-fg);       /* white */
    padding: 10px 18px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    border: none;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
    transition: background 120ms ease;
}
.dl-button:hover  { background: #2b5499; color: white; }
.dl-button:active { background: #234582; }

.dl-filename {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    color: #555;
    word-break: break-all;
}

.license-row { font-size: 13px; color: #333; }
.license-row .muted { color: #777; }

.ack-acc summary {
    cursor: pointer;
    padding: 4px 8px;
    color: var(--brand);
    font-size: 12.5px;
    user-select: none;
    border-radius: 3px;
}
.ack-acc summary:hover { background: #f0f4fb; }

.ack-text {
    font-size: 12px;
    color: #444;
    line-height: 1.5;
    padding: 6px 8px;
    background: #f8f9fb;
    border-left: 3px solid var(--brand);
    margin: 6px 0;
}

/* ── Full BADM viewer ──────────────────────────────────────────── */

.badm-section { margin-top: 18px; }
.badm-section h3 { margin-bottom: 2px; color: var(--brand); }
.badm-section .small { font-size: 12px; }

.badm-list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }

.badm-acc {
    border: 1px solid #e3e3e3;
    border-radius: 4px;
    background: white;
}

.badm-acc summary {
    cursor: pointer;
    padding: 6px 10px;
    font-size: 13px;
    user-select: none;
}
.badm-acc summary:hover { background: #f7f8fa; }
.badm-acc summary strong {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: #1f2733;
}
.badm-acc[open] { background: #fbfcfe; }
.badm-acc .muted { color: #777; }

.badm-body {
    margin: 0;
    padding: 8px 12px 12px;
    background: #1f2733;
    color: #d8e0ec;
    border-radius: 0 0 4px 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    line-height: 1.4;
    max-height: 360px;
    overflow: auto;
    white-space: pre;
}


.page-site {
    max-width: 820px;
    margin: 24px auto;
    padding: 0 8px;
}

.page-site h2 {
    color: var(--brand);
    margin-bottom: 4px;
}

.back-link {
    display: inline-block;
    margin-bottom: 12px;
    color: var(--brand);
    text-decoration: none;
}

.back-link:hover { text-decoration: underline; }

.kv-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    font-size: 14px;
}

.kv-table td {
    padding: 6px 12px;
    border-bottom: 1px solid #eee;
    vertical-align: top;
}

.kv-label  { color: var(--muted); width: 170px; }
.kv-value  { color: #222; }

.page-site-error h2 { color: #a33; }

/* ── Footer ────────────────────────────────────────────────────── */

.app-footer {
    height: var(--footer-h);
    background: var(--brand);
    color: var(--brand-fg);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 14px;
    padding: 0 16px;
    font-size: 13px;
}

.footer-logo-link {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
}

.footer-text {
    flex: 1 1 auto;
    line-height: 1.4;
    color: var(--brand-fg);
}

.footer-logo {
    height: 36px;
    width: auto;
    display: block;
    /* No background inset — the SVG's grey was recoloured to light
       grey at copy-time so it reads cleanly directly on the brand
       blue.  Cyan + magenta accents stay vivid as-is. */
}
