/* glen-charts base stylesheet: the glen-web sidebar shell (map left,
 * full-height resizable panel right). An app re-themes it by overriding the
 * :root tokens (palette, --header-h) in its own stylesheet, loaded after this one. */

:root {
    --primary: #006837;
    --primary-strong: #004d29;
    --primary-wash: rgba(0, 104, 55, 0.08);
    --accent: #39b54a;
    --surface: #f5faf1;
    --backdrop: #e5f1e0;
    --chrome-bg: #fbfdf9;
    --card-bg: #ffffff;
    --text: #22201f;
    --text-2: #4f4a47;
    --text-3: #77706b;
    --line: rgba(30, 40, 30, 0.12);
    --line-strong: rgba(30, 40, 30, 0.22);
    --hover: rgba(0, 0, 0, 0.05);
    --shadow: rgba(0, 0, 0, 0.14);
    --focus: #004d29;
    --danger: #b3261e;

    /* chart roles */
    --series-protected: #1f7a3a;
    --series-other: #9aa59a;
    --series-state: #2b2b2b;
    --grid: rgba(0, 0, 0, 0.08);

    --overlay-bg: rgba(255, 255, 255, .94);   /* map legends and chips */
    --code-bg: #f3f4f2;
    --skeleton-a: #eef2ec;
    --skeleton-b: #f6f9f4;
    --mix-base: white;                         /* tints: color-mix(<colour> 10%, var(--mix-base)) */
    --on-primary: #fff;                        /* text on --primary and on series colours */
    --header-bg: var(--primary);
    --header-fg: #fff;
    --sidebar-width: 50vw;
    --header-h: 52px;
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--backdrop); }
body { font-size: 14px; line-height: 1.4; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ----- header ---------------------------------------------------------- */
#app-header {
    height: var(--header-h);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px;
    background: var(--header-bg);
    color: var(--header-fg);
}
.brand { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.brand h1 { font-size: 17px; margin: 0; font-weight: 650; letter-spacing: .2px; white-space: nowrap; }
.brand-sub { font-size: 13px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark {
    width: 14px; height: 14px; align-self: center; border-radius: 3px;
    background: linear-gradient(135deg, #8fd694, #39b54a);
}
.header-links a { color: inherit; opacity: .85; text-decoration: none; font-size: 13px; }
.header-links a:hover { opacity: 1; text-decoration: underline; }

/* ----- layout ---------------------------------------------------------- */
#layout, .glen-layout {
    position: absolute; top: var(--header-h); left: 0; right: 0; bottom: 0;
    display: flex;
}
#map-wrap { position: relative; flex: 1 1 auto; min-width: 0; }
#map { position: absolute; inset: 0; }

#sidebar {
    position: relative;
    flex: 0 0 var(--sidebar-width);
    width: var(--sidebar-width);
    min-width: 360px;
    container-type: inline-size;
    background: var(--chrome-bg);
    border-left: 1px solid var(--line);
    box-shadow: -2px 0 6px var(--shadow);
    display: flex; flex-direction: column;
    min-height: 0;
}
.sidebar-resize {
    position: absolute; left: -3px; top: 0; bottom: 0; width: 6px;
    cursor: col-resize; z-index: 5;
}
.sidebar-resize:hover { background: rgba(57, 181, 74, .25); }

/* ----- controls -------------------------------------------------------- */
#controls {
    flex: 0 0 auto;
    padding: 12px 16px 10px;
    border-bottom: 1px solid var(--line);
    background: var(--chrome-bg);
    display: grid; gap: 10px;
}
.step-label {
    font-size: 11px; font-weight: 650; letter-spacing: .6px; text-transform: uppercase;
    color: var(--text-3); margin-bottom: 6px; display: flex; align-items: center; gap: 6px;
}
.step-num {
    display: inline-grid; place-items: center;
    width: 17px; height: 17px; border-radius: 50%;
    background: var(--primary); color: var(--on-primary); font-size: 10px; letter-spacing: 0;
}
.step.pending .step-num { background: var(--text-3); }
.step.pending .step-label { opacity: .7; }
.step-help { font-size: 12px; color: var(--text-3); margin-top: 4px; }

.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg button, .chips button {
    border: 1px solid var(--line-strong);
    background: var(--card-bg);
    padding: 5px 11px; border-radius: 999px;
    cursor: pointer; font-size: 13px;
    transition: background 120ms, border-color 120ms;
}
.seg button:hover, .chips button:hover { background: var(--primary-wash); }
.seg button[aria-checked="true"] {
    background: var(--primary); color: var(--on-primary); border-color: var(--primary);
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { display: inline-flex; align-items: center; gap: 6px; }
.chips button .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); opacity: .35; }
.chips button[aria-pressed="true"] {
    border-color: var(--c); background: color-mix(in srgb, var(--c) 10%, var(--mix-base)); font-weight: 600;
}
.chips button[aria-pressed="true"] .dot { opacity: 1; }

.search { position: relative; }
#place-input {
    width: 100%; padding: 8px 10px;
    border: 1px solid var(--line-strong); border-radius: 8px; background: var(--card-bg);
}
#place-input:disabled { background: var(--hover); }
#place-results {
    position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px);
    margin: 0; padding: 4px; list-style: none;
    background: var(--card-bg); border: 1px solid var(--line-strong); border-radius: 8px;
    box-shadow: 0 6px 18px var(--shadow);
    max-height: 300px; overflow-y: auto;
}
#place-results li { padding: 6px 8px; border-radius: 5px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
#place-results li small { color: var(--text-3); }
#place-results li[aria-selected="true"], #place-results li:hover { background: var(--primary-wash); }

/* ----- report ---------------------------------------------------------- */
#report { flex: 1 1 auto; overflow-y: auto; padding: 14px 16px 40px; min-height: 0; }

.intro h2 { font-size: 20px; margin: 6px 0 8px; }
.intro p { color: var(--text-2); margin: 0 0 10px; }
.intro ul { color: var(--text-2); padding-left: 18px; margin: 0 0 10px; }

.report-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.report-head h2 { font-size: 22px; margin: 0; line-height: 1.15; }
.report-head .kind { font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: .6px; }
.head-actions { display: flex; gap: 6px; flex-shrink: 0; }
.ghost-btn {
    border: 1px solid var(--line-strong); background: var(--card-bg);
    border-radius: 6px; padding: 4px 9px; cursor: pointer; font-size: 12px; white-space: nowrap;
}
.ghost-btn:hover { background: var(--hover); }

.card {
    background: var(--card-bg); border: 1px solid var(--line);
    border-radius: 10px; padding: 12px 14px; margin-bottom: 12px;
}
.theme-card { border-top: 3px solid var(--c, var(--primary)); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.card-head h3 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card-head h3 .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.card-blurb { color: var(--text-3); font-size: 12.5px; margin: 0 0 10px; }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 6px; }
.tiles[data-n="4"], .tiles[data-n="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 420px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { padding: 8px 10px; border-radius: 8px; background: var(--surface); min-width: 0; }
.tile-label { font-size: 12px; color: var(--text-2); }
.tile-value { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.15; margin-top: 2px; }
.tile-compare { font-size: 11.5px; color: var(--text-3); margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile-note { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.tile-rank { font-size: 12px; color: var(--text-2); margin-top: 3px; }
.tile-rank b { color: var(--c, var(--primary)); font-variant-numeric: tabular-nums; }

.chart { margin-top: 12px; min-width: 0; }
/* wide panel: four tiles in a row, charts side by side */
@container (min-width: 680px) {
    .tiles[data-n="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .charts .chart.wide { grid-column: 1 / -1; }
    .charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); column-gap: 24px; align-items: start; }
}
.chart h4 { font-size: 13px; margin: 0; font-weight: 600; }
.chart .sub { font-size: 12px; color: var(--text-3); margin: 1px 0 6px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart svg text { font-size: 11.5px; fill: var(--text-2); font-variant-numeric: tabular-nums; }
.chart svg .val { fill: var(--text); }
.legend-row { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--text-2); margin: 2px 0 4px; }
.legend-row span { display: inline-flex; align-items: center; gap: 5px; }
.legend-row i { width: 11px; height: 11px; border-radius: 2px; display: inline-block; }
.legend-row i.tick { width: 2px; height: 12px; border-radius: 0; }

details.method { margin-top: 10px; font-size: 12px; color: var(--text-2); }
details.method summary { cursor: pointer; color: var(--text-3); }
details.method pre {
    background: var(--code-bg); padding: 8px; border-radius: 6px; overflow-x: auto;
    font-size: 11px; line-height: 1.35; max-height: 260px;
}

.skeleton { background: linear-gradient(90deg, var(--skeleton-a) 25%, var(--skeleton-b) 50%, var(--skeleton-a) 75%); background-size: 200% 100%;
    animation: shimmer 1.2s infinite; border-radius: 6px; color: transparent !important; }
.skeleton * { visibility: hidden; }
@keyframes shimmer { to { background-position: -200% 0; } }
.err { color: var(--danger); font-size: 12px; }

.map-btn {
    border: 1px solid var(--line-strong); background: var(--card-bg); color: var(--text-2);
    border-radius: 999px; font-size: 12px; padding: 3px 9px; cursor: pointer; white-space: nowrap;
}
.map-btn[aria-pressed="true"] { background: var(--c); color: var(--on-primary); border-color: var(--c); }

/* ----- map overlays ---------------------------------------------------- */
.map-overlay {
    position: absolute; z-index: 5;
    background: var(--overlay-bg); border: 1px solid var(--line);
    border-radius: 8px; box-shadow: 0 2px 8px var(--shadow);
}
#map-chips { top: 10px; left: 10px; padding: 6px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; max-width: calc(100% - 70px); }
#map-chips .lbl { font-size: 11px; color: var(--text-3); padding: 0 4px; text-transform: uppercase; letter-spacing: .5px; }
#map-legend { left: 10px; bottom: 28px; padding: 8px 10px; font-size: 12px; max-width: 260px; }
.map-legends { left: 10px; bottom: 28px; padding: 0; font-size: 12px; max-width: 260px; background: none; border: 0; box-shadow: none; display: flex; flex-direction: column; gap: 6px; }
.map-legends:not(:has(> :not([hidden]))) { display: none; }
.map-legends > div { position: static; padding: 8px 10px; background: var(--overlay-bg); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 2px 8px var(--shadow); }
.map-legends #map-legend { left: auto; bottom: auto; }
#overlay-legend .title { font-weight: 600; }
#overlay-legend .lg-row { display: flex; align-items: center; gap: 6px; margin-top: 4px; color: var(--text-2); }
#overlay-legend .lg-row i { width: 12px; height: 12px; border-radius: 2px; display: inline-block; flex: none; }
#overlay-legend .lg-row i.snone { box-shadow: inset 0 0 0 1px rgba(0,0,0,.18); }
#overlay-legend .lg-toggle { display: flex; align-items: center; gap: 5px; margin-top: 6px; font-size: 11.5px; color: var(--text-3); cursor: pointer; }
#overlay-legend .ov + .ov { margin-top: 8px; }
#map-legend .ramp { display: flex; height: 10px; border-radius: 2px; overflow: hidden; margin: 5px 0 3px; }
#map-legend .ramp span { flex: 1; }
#map-legend .ends { display: flex; justify-content: space-between; color: var(--text-3); font-variant-numeric: tabular-nums; }
#map-legend .title { font-weight: 600; }
#map-hint { top: 10px; left: 50%; transform: translateX(-50%); padding: 6px 12px; font-size: 13px; }

#tooltip {
    position: fixed; z-index: 60; pointer-events: none;
    background: #1d1f1d; color: #fff; padding: 6px 8px; border-radius: 6px; font-size: 12px;
    max-width: 260px; box-shadow: 0 4px 12px rgba(0,0,0,.25);
}
#tooltip b { font-weight: 600; }

/* ----- narrow screens: map on top, panel below ------------------------- */
@media (max-width: 820px) {
    .brand-sub, .header-links { display: none; }
    .brand h1 { font-size: 16px; }
    #map-legend { bottom: 8px; padding: 6px 8px; max-width: 200px; font-size: 11px; }
    .map-legends { bottom: 6px; max-width: 160px; font-size: 10.5px; }
    .map-legends > div { padding: 5px 7px; }
    #overlay-legend .title, #overlay-legend .lg-toggle, #overlay-legend .lg-long { display: none; }
    .brand h1 { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
    #map-legend .tile-note { display: none; }
    #map-chips .lbl { display: none; }
    #layout, .glen-layout { flex-direction: column; }
    #map-wrap { flex: 0 0 42vh; }
    #sidebar { flex: 1 1 auto; width: auto; min-width: 0; border-left: none; border-top: 1px solid var(--line); }
    .sidebar-resize { display: none; }
}

/* ----- point/isochrone variant ---------------------------------------- */
.step-row { display: flex; flex-wrap: wrap; gap: 10px 22px; }
.header-links { display: flex; gap: 16px; }
.origin-marker {
    width: 16px; height: 16px; border-radius: 50%;
    background: #111; border: 3px solid #fff; box-shadow: 0 0 0 1.5px #111, 0 2px 6px rgba(0,0,0,.35);
}
.band-legend { display: flex; gap: 10px; align-items: center; font-size: 12px; color: var(--text-2); margin-top: 4px; flex-wrap: wrap; }
.band-legend i { display: inline-block; width: 18px; height: 0; border-top: 2.5px solid; margin-right: 4px; vertical-align: middle; }
.band-legend i.dash { border-top-style: dashed; border-top-width: 1.5px; }
.note-card { font-size: 12.5px; color: var(--text-2); }

/* ----- shared additions (area sources, notes, no-data) ------------------ */
.draw-row { display: flex; flex-wrap: wrap; gap: 6px; }
.draw-row .upload { cursor: pointer; }
.live-note { margin: -4px 0 10px; }
.chart svg text.nodata { fill: var(--text-3); font-style: italic; }
#step-params .seg + .step-label { margin-top: 8px; }
#step-params .param-slider + .step-label { margin-top: 8px; }
/* "control": "slider" params: a range input over evenly spaced, clickable stops */
.param-slider { padding: 0 4px; }
.param-slider input[type="range"] { width: calc(100% - 100% / var(--n)); margin: 4px calc(50% / var(--n)) 0; accent-color: var(--primary); cursor: pointer; display: block; }
.param-stops { display: grid; grid-template-columns: repeat(var(--n), 1fr); }
.param-stops button {
    background: none; border: 0; padding: 2px 0; font: inherit; font-size: 12px;
    color: var(--text-3); cursor: pointer; text-align: center;
}
.param-stops button:hover { color: var(--text); }
.param-stops button[aria-pressed="true"] { color: var(--text); font-weight: 600; }
#source-steps:not(:has(> :not([hidden]))) { display: none; }
#source-steps { display: contents; }
