/* Chrome around the 3D viewport: a control bar, a stats card and the
   attribution the CC BY licence requires. Dark, so the relief carries the page. */

:root {
    --bg: #12181c;
    --panel: rgba(18, 24, 28, 0.86);
    --line: #2a353c;
    --text: #e8eef1;
    --muted: #93a4ae;
    --accent: #62d0c0;
    color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
}

body {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 18px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
    background: #0e1418;
}

/* The logo links out to the parent site; it is the only thing in the bar that
   leaves the page, so it gets the hover treatment rather than a label. */
.brand-logo {
    display: flex;
    align-items: center;
    padding: 2px;
    border-radius: 8px;
    line-height: 0;
    opacity: 0.9;
}
.brand-logo:hover { opacity: 1; background: #172026; }
.brand-logo img { display: block; width: 34px; height: 34px; }

.brand { display: grid; gap: 1px; margin-right: 4px; }
.brand strong { font-size: 15px; letter-spacing: 0.01em; }
.eyebrow { color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; }

.places { display: flex; flex-wrap: wrap; gap: 6px; }
.places button {
    padding: 7px 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #172026;
    color: var(--text);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.places button:hover { border-color: var(--accent); color: var(--accent); }

.bar-end { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.bar-button {
    padding: 7px 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #172026;
    color: var(--text);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.bar-button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.bar-button:disabled { opacity: 0.4; cursor: default; }

/* The only thing that says "still arriving". It holds its slot whether or not
   it is spinning, so the bar next to it never shifts — the same reason the
   readout panel below no longer changes size. */
.busy {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(98, 208, 192, 0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.25s ease;
    animation: busy-spin 0.9s linear infinite;
}
.busy.is-busy { opacity: 1; }
@keyframes busy-spin { to { transform: rotate(360deg); } }
/* Reduced motion still needs the signal, so it becomes a steady dot rather
   than nothing at all. */
@media (prefers-reduced-motion: reduce) {
    .busy { animation: none; border-color: var(--accent); background: rgba(98, 208, 192, 0.35); }
}

.info-button {
    width: 28px;
    height: 28px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: #172026;
    color: var(--accent);
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    font-style: italic;
    line-height: 1;
    cursor: pointer;
}
.info-button:hover { border-color: var(--accent); }

.info-dialog {
    max-width: 460px;
    padding: 20px 22px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #0e1418;
    color: var(--text);
}
.info-dialog::backdrop { background: rgba(6, 10, 12, 0.65); }
.info-dialog h2 { margin: 0 0 10px; font-size: 15px; }
.info-dialog p { margin: 0 0 12px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.info-dialog p:last-of-type { margin-bottom: 16px; }
.info-dialog a { color: var(--accent); }
.info-dialog strong { color: var(--text); }
.info-dialog button {
    padding: 7px 14px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #172026;
    color: var(--text);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.info-dialog button:hover { border-color: var(--accent); color: var(--accent); }

#viewport {
    position: relative;
    flex: 1;
    min-height: 0;
}
#viewport canvas { display: block; width: 100%; height: 100%; }

.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 10px 16px;
    border-radius: 8px;
    background: var(--panel);
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}
.hidden { display: none; }

/* One left column: the stats card with the tools stacked directly under it,
   sharing a width so they read as a single panel rather than two floating
   boxes. Stacking in flow, not by absolute offsets, keeps them together when
   the stats card grows a line. */
.left-column {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 300px;
    display: grid;
    gap: 10px;
    align-content: start;
    max-height: calc(100% - 24px);
    overflow-y: auto;
    /* Reserve the scrollbar's width whether or not it is showing. Without it a
       card that grows past the column height gains a scrollbar, the scrollbar
       takes ~15 px off the cards, and every value inside them reflows — a
       width change nobody asked for, triggered by a number changing. */
    scrollbar-gutter: stable;
}

.stats {
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
    backdrop-filter: blur(8px);
    font-size: 12px;
}
/* Either panel collapses to just its header row. The row stays a button so the
   whole strip is the hit target — a chevron alone is a 12 px target on a panel
   that is 300 px wide. */
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin: -2px 0 8px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--muted);
    font: inherit;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
}
.panel-head:hover { color: var(--accent); }
.panel-chevron { font-size: 11px; letter-spacing: 0; transition: transform 0.15s ease; }
.is-collapsed .panel-chevron { transform: rotate(-90deg); }
.is-collapsed .panel-head { margin-bottom: 0; }
.is-collapsed > :not(.panel-head) { display: none; }

.stats dl { display: grid; gap: 5px; margin: 0; }
.stats dl > div { display: grid; grid-template-columns: 96px 1fr; gap: 8px; }
.stats dt { color: var(--muted); font-weight: 600; }
.stats dd { margin: 0; font-variant-numeric: tabular-nums; }
/* One line, always. src/stats-format.js keeps every value inside the column,
   and this is the backstop: a value that somehow overran would be clipped
   rather than allowed to wrap and change the card's height. */
.stats dt, .stats dd { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats dd.is-warning { color: #f3a26a; }

/* Tools sit directly under the stats card and share its width, so the left
   column reads as one stack rather than two floating boxes. */
.tools {
    display: grid;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
    backdrop-filter: blur(8px);
    font-size: 12px;
}
.tool-field { display: grid; gap: 5px; color: var(--muted); font-weight: 600; }
.tool-field output { color: var(--text); font-variant-numeric: tabular-nums; }
.tool-field input[type="range"] { width: 100%; accent-color: var(--accent); }
.tool-check { display: flex; align-items: center; gap: 7px; color: var(--muted); font-weight: 600; }
.tool-check input { accent-color: var(--accent); }
.tool-check input:disabled + span { opacity: 0.45; }
.tool-check.is-unavailable span { opacity: 0.5; }
.tool-check.is-unavailable input { accent-color: var(--muted); }
.tool-group { display: grid; gap: 5px; padding-top: 8px; border-top: 1px solid var(--line); }
.tool-group-title { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.tool-note { margin: 2px 0 0; color: var(--accent); font-size: 10px; font-weight: 600; opacity: 0.8; }

/* What the proposal's colours mean. The swatch colour is set from the palette
   in JS rather than repeated here, because two copies of a colour drift and
   this one has to match the planner's profile strip exactly. */
/* The loaded proposals, named, each linking back to the planner that owns it. */
.project-links { display: grid; gap: 3px; margin: 3px 0 0; padding: 0 0 0 22px; list-style: none; }
.project-links a { color: var(--accent); font-size: 11px; font-weight: 600; text-decoration: none; }
.project-links a:hover { text-decoration: underline; }
.regime-legend { display: grid; gap: 3px; margin: 3px 0 0; padding: 0 0 0 22px; list-style: none; }
.regime-legend li { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 600; }
.regime-legend i { width: 14px; height: 4px; border-radius: 2px; flex: none; background: currentColor; }
/* Drawn broken on the relief, so the swatch is broken too. */
.regime-legend li.is-dashed i {
    background: repeating-linear-gradient(to right, currentColor 0 5px, transparent 5px 8px);
    border-radius: 0;
}

/* Centred at the bottom: it is guidance, not a status readout. */
.help {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    padding: 7px 13px;
    border-radius: 8px;
    background: var(--panel);
    color: var(--muted);
    font-size: 11px;
    white-space: nowrap;
}

/* Bottom right, out of the way of the help line — but never hidden, because it
   is the licence condition for showing the tiles at all. */
.attribution {
    position: absolute;
    right: 12px;
    bottom: 12px;
    margin: 0;
    padding: 5px 10px;
    border-radius: 7px;
    background: var(--panel);
    color: var(--muted);
    font-size: 10px;
}
.attribution a { color: var(--muted); }
.attribution[hidden] { display: none; }

@media (max-width: 720px) {
    .left-column { width: 210px; }
    .stats { font-size: 11px; }
    .stats dl > div { grid-template-columns: 78px 1fr; }
    .tools { font-size: 11px; }
    .help { display: none; }
    .places button { padding: 6px 9px; font-size: 11px; }
}
