/* Ventoux: header, three resizable columns, tree, drop zone, details.
   Only roles of the Design Language package (vendor/design-language-*): Colour Roles, Type Levels, Spacing Roles,
   radius tokens, the one motion. The map's own controls and the weather parts are further down. */

/* the Header Bar's height, measured by sidebar.js; the sidebar overlay starts below it */
:root { --bar-height: calc(var(--hit) + 2 * var(--space-element) + 1px); }
/* the height of a climb's Mini Chart in the climbs list, Ventoux's value (CHT-4 leaves it to the Product) */
:root { --climb-chart-height: 56px; }

body { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; overflow: hidden; }

.bar {
    display: flex;
    align-items: center;
    gap: var(--space-element);
    padding: var(--space-element) var(--margin);
    min-height: calc(var(--hit) + 2 * var(--space-element));
    background: var(--background);
    /* Component App bar: the Header Bar stays on top when the page scrolls; never a bar at the bottom */
    position: sticky;
    top: 0;
    z-index: 10;
}
/* Component Sidebar toggle: the Sidebar toggle exists only while the sidebar is an overlay (media queries at the end) */
.sidebar-toggle { display: none; flex: none; }
.scrim { display: none; }
.sidebar-toggle[aria-expanded="true"] { background: var(--signal-tint); }
/* SPC-6 flush: the Header Bar abuts the columns */
.bar[data-line="flush"] { border-bottom: 1px solid var(--separator); }
.brand { flex: 1 0 auto; font-size: var(--type-title-size); line-height: var(--type-title-line); font-weight: var(--type-title-weight); color: var(--text); }
/* Component Account menu: the one account button; a long address is cut, also when the bar is stacked */
.account { min-width: 0; max-width: 100%; }
.account span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu { position: fixed; left: auto; bottom: auto; min-width: 12rem; max-width: calc(100vw - 2 * var(--margin)); }
.menu:popover-open { display: grid; }
.menu button { justify-content: flex-start; }
.menu hr { border: 0; border-top: 1px solid var(--separator); margin: var(--space-pair) 0; }

/* the sidebar and the inspector can be resized with the splitters and the widths are remembered per browser; the defaults are the widths of the package */
.columns {
    --left: var(--column-sidebar);
    --right: var(--column-inspector);
    display: grid;
    /* the widths set with the splitters give way when the window is narrower: the content keeps its minimum */
    grid-template-columns:
        minmax(min(var(--left), var(--column-sidebar)), var(--left)) var(--space-element)
        minmax(var(--column-content), 1fr) var(--space-element)
        minmax(min(var(--right), var(--column-inspector)), var(--right));
    min-height: 0;
}

/* SPC-6 flush: the columns abut each other; the splitter is the line, 1px wide in the middle of its hit area */
.splitter[data-line="flush"] {
    cursor: col-resize;
    background: var(--separator);
    background-clip: content-box;
    padding: 0 calc(var(--space-element) / 2 - var(--hairline) / 2);
    touch-action: none;
}
/* hovered, the line is three hairlines wide */
.splitter:hover { background-color: var(--signal); padding: 0 calc(var(--space-element) / 2 - 3 * var(--hairline) / 2); }

#sidebar, #detail { min-width: 0; min-height: 0; overflow: auto; }
#center { min-width: 0; min-height: 0; }
/* the tree scrolls for itself, the upload panel stays below it */
#sidebar { display: flex; flex-direction: column; overflow: hidden; }
#detail { padding: var(--space-group); }

/* Tree */

#tree { flex: 1; min-height: 0; overflow: auto; padding: var(--space-element) var(--space-element) var(--space-group); }
#tree section + section { margin-top: var(--space-group); }
#tree h3 { padding: var(--space-pair) var(--space-element); color: var(--text-secondary); }
#tree ul { list-style: none; margin: 0; padding: 0; }
/* the name's place: twisty, tick and icon (--tree-lead together) and their gaps */
#tree { --tree-lead: 2.875lh; }
#tree .empty {
    padding: var(--space-pair) var(--space-element) var(--space-pair)
        calc(var(--space-pair) + (var(--depth, 0)) * var(--space-group) + var(--tree-lead) + 3 * var(--space-element));
    font-size: var(--type-compact-size);
    line-height: var(--type-compact-line);
}

/* the name's line (twisty, tick, icon, name, shared mark) is at least --hit high; the meta text is a second line under the name (DET-3, USE-1) */
.row {
    display: grid;
    grid-template-columns: auto auto auto minmax(0, 1fr);
    grid-template-rows: minmax(var(--hit), auto);
    align-items: center;
    column-gap: var(--space-element);
    padding: 0 var(--space-element) 0 calc(var(--space-pair) + var(--depth) * var(--space-group));
    border-radius: var(--radius-control);
    cursor: default;
    user-select: none;
    white-space: nowrap;
}
.row:hover { background: var(--fill); }
.row.selected { background: var(--signal-tint); }
.row.drop { outline: 2px solid var(--signal); outline-offset: -2px; background: var(--signal-tint); }
.row.dragging { opacity: 0.5; }
.row:focus-visible { outline: 2px solid var(--signal); outline-offset: -2px; }

.twisty { display: flex; width: 1lh; color: var(--text-secondary); cursor: pointer; }
.twisty .icon { transition: transform var(--motion); }
/* Disclosure: Expand at 0° closed, 90° open (Component Disclosure) */
.twisty.open .icon { transform: rotate(90deg); }
/* the kind of the entry (ICN-6), text-secondary as type Icons in lists (ICN-4) */
.row > .icon { color: var(--text-secondary); }

/* ticks: what is on the map, in the route's colour */
.check {
    appearance: none;
    width: 0.875lh;
    height: 0.875lh;
    margin: 0;
    padding: 0;
    border: 1px solid var(--control-border);
    border-radius: var(--radius-checkbox);
    background: transparent;
    cursor: pointer;
}
.check:checked { border-color: var(--color); background: var(--color); box-shadow: inset 0 0 0 2px var(--background); }
.check:indeterminate { border-color: var(--color); background: linear-gradient(var(--color), var(--color)) center / 60% 2px no-repeat; }
.row.selected .check:checked { box-shadow: inset 0 0 0 2px var(--signal-tint); }
.row.root { font-size: var(--type-heading-size); line-height: var(--type-heading-line); font-weight: var(--type-heading-weight); --icon-stroke: var(--type-heading-stroke); }
.name { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.meta { color: var(--text-secondary); font-size: var(--type-compact-size); line-height: var(--type-compact-line); }
.row > .meta { grid-column: 4; grid-row: 2; overflow: hidden; text-overflow: ellipsis; padding-bottom: var(--space-pair); }
.row > .meta:empty { display: none; }
.shared-mark { display: flex; grid-column: 5; grid-row: 1; color: var(--text-secondary); }

/* Centre: map, profile, drop overlay */

#center {
    position: relative;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto auto;
    grid-template-columns: minmax(0, 1fr);  /* the read-out of the weather mustn't widen it */
    overflow: hidden;
}
.map { min-height: 15em; }
.profile { box-sizing: content-box; height: calc(var(--chart-min-height) + var(--chart-surround, 0px)); }  /* CHT-4: the plot is the Chart minimum height; elevation-chart.js sets what surrounds it; content-box, so the line on top isn't taken from the plot */
/* SPC-6 flush: the profile abuts the map */
.profile[data-line="flush"] { border-top: 1px solid var(--separator); }

.map-status {
    position: absolute;
    top: var(--space-group);
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    /* a Notice: inner padding Element, concentric (RAD-2) */
    padding: var(--space-element);
    border-radius: var(--radius-notice);
    background: var(--background);
    pointer-events: none;
}

/* Component Map library controls, type (TYP-1, #649): the library sets `font: 12px/20px "Helvetica Neue", Arial` on
   `.maplibregl-map` and `font-size: 10px` on its scale, unlayered, which beats the Design Language's Type Levels
   (they are in a layer, so even `.type-text` loses). The map takes the font of the page (Primary Typeface, Text);
   each control carries its Type Level as a class (`map-controls.js`), the scale needs its size set here. */
.maplibregl-map { font: inherit; }
.maplibregl-ctrl-scale { font-size: var(--type-caption-size); line-height: var(--type-caption-line); }

/* Map Buttons (LAY-7, LAY-9): groups top right, `group` apart and from the edge, zoom first, then the
   map view (Fit map), then the map display (Map layers); each group on `background` with a hairline
   `separator` line around it and the control radius, no shadow or dividers; a pressed button on `fill`,
   an active one a `signal` cell inside the line, concentric to it */
.maplibregl-ctrl-top-right .maplibregl-ctrl { margin: var(--space-group) var(--space-group) 0 0; }
.maplibregl-ctrl-group:not(:empty) { background: var(--background); border: var(--hairline) solid var(--separator); border-radius: var(--radius-control); box-shadow: none; }
.maplibregl-ctrl-group button + button { border-top: 0; }
.maplibregl-ctrl-group > button { border-radius: calc(var(--radius-control) - var(--hairline)); }
.maplibregl-ctrl-group > button:active { background: var(--fill); }
.maplibregl-ctrl-group > button[aria-pressed="true"] { background: var(--signal); }
.maplibregl-ctrl-group > button[aria-pressed="true"] > .icon { color: var(--on-signal); }
/* the menu of Map layers (shared/map.js StyleControl) */
.style-control { position: relative; }
/* a Map Button's symbol is text, as it lies over the map (ICN-4, LAY-9) */
.maplibregl-ctrl-group > button > .icon { display: block; margin: auto; color: var(--text); }
/* the attribution is no Map Button: an Icon without text is text-secondary (ICN-4) */
.maplibregl-ctrl-attrib-button > .icon { display: block; margin: auto; color: var(--text-secondary); }
/* Component Map library controls: zoom and attribution show Icons of the Icon Map (shared/map.js), not the library's data-URI ones */
.maplibregl-ctrl-attrib-button,
.maplibregl-ctrl-attrib.maplibregl-compact:after { background-image: none; }
/* the bubble stays 24px with the Icon centred in it; the hit area is var(--hit) (SPC-5), an invisible
   pseudo-element centred on it, so it grows beyond the bubble without moving it */
.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-button { display: grid; place-items: center; width: 24px; height: 24px; }
/* the open attribution: its Caption line is centred on the 24px bubble, not sitting at the top of the library's min-height */
.maplibregl-ctrl-attrib.maplibregl-compact-show { display: flex; align-items: center; }
.maplibregl-ctrl-attrib-button::before { content: ""; position: absolute; top: 50%; left: 50%; width: var(--hit); height: var(--hit); transform: translate(-50%, -50%); }
.maplibregl-ctrl-group button { width: var(--hit); height: var(--hit); }
.style-menu {
    position: absolute;
    top: 0;
    right: calc(100% + var(--space-element));
    display: grid;
    min-width: 12em;
    padding: var(--space-pair);
    border-radius: var(--radius-menu);
    background: var(--background);
    color: var(--text);
}
.maplibregl-ctrl-group .style-menu button {
    width: auto;
    height: auto;
    padding: var(--space-pair) var(--space-element);
    border: 0;
    border-radius: var(--radius-control);
    text-align: left;
    font: inherit;
    color: var(--text);
    white-space: nowrap;
}
.maplibregl-ctrl-group .style-menu button.current { background: var(--fill); }
.style-menu .overlay {
    display: flex;
    align-items: center;
    gap: var(--space-pair);
    margin: 0;
    padding: var(--space-pair) var(--space-element);
    color: var(--text);
    white-space: nowrap;
    cursor: pointer;
}
/* SPC-6 sequence: the overlays follow the styles as a second list */
.style-menu .overlay.first { margin-top: var(--space-pair); border-top: 1px solid var(--separator); }
.style-menu .overlay input { width: auto; margin: 0; }
.style-menu .overlay:has(input:disabled) { color: var(--text-disabled); cursor: default; }

/* markers sit on the line: the pointer must reach the map beneath them */
.maplibregl-marker.map-label, .point-marker { pointer-events: none; }
.point-marker {
    width: 16px;
    height: 16px;
    border: var(--number-badge-ring) solid var(--surface);
    border-radius: 50%;
    background: var(--text);
    box-shadow: 0 0 0 1px var(--separator);
}
/* the number of a route on the map, a number badge in the colour of the route (DAT-4, DAT-5) */
.route-label {
    display: grid;
    place-items: center;
    width: 1.5lh;
    height: 1.5lh;
    border: var(--number-badge-ring) solid var(--route);
    border-radius: 50%;
    background: var(--background);
    color: var(--text);
    font-size: var(--type-compact-size);
    line-height: var(--type-compact-line);
    pointer-events: none;
}

/* LAY-10, LAY-9: the Drop Target covers the area that takes the files, flush with its edges, the map shows through the tint; its text stands on an opaque plate */
.dropzone {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: grid;
    place-content: center;
    border: var(--hairline) dashed var(--signal);
    background: var(--signal-tint-clear);
    text-align: center;
}
.dropzone div {
    padding: var(--space-group);
    border: var(--hairline) solid var(--separator);
    border-radius: var(--radius-control);
    background: var(--background);
    color: var(--text);
    font-size: var(--type-text-size);
    line-height: var(--type-text-line);
    pointer-events: none;
}
.dropzone p { margin: var(--space-pair) 0; pointer-events: none; }
.dropzone-title { font-size: var(--type-heading-size); line-height: var(--type-heading-line); font-weight: var(--type-heading-weight); }
.dropzone.disabled { border-color: var(--text-secondary); background: none; }

/* LAY-2, RAD-4: the panel is a surface of the sidebar, flush with its edges, opaque, the line above it; the tree ends above it */
.upload-panel {
    flex: none;
    max-height: 40%;
    display: flex;
    flex-direction: column;
    background: var(--background);
}
/* display: flex would override the attribute */
.upload-panel[hidden] { display: none; }
.upload-panel[data-line="flush"] { border-top: 1px solid var(--separator); }
.upload-panel header { display: flex; align-items: center; gap: var(--space-element); padding: var(--space-element) var(--space-element) var(--space-element) var(--space-group); }
/* SPC-6 flush: the header abuts the list */
.upload-panel header[data-line="flush"] { border-bottom: 1px solid var(--separator); }
.upload-panel header span { flex: 1; font-size: var(--type-heading-size); line-height: var(--type-heading-line); font-weight: var(--type-heading-weight); }
.uploads { list-style: none; margin: 0; padding: 0 var(--space-group); overflow: auto; min-height: 0; }
.upload {
    display: grid;
    /* in the sidebar, however narrow: name and status on a line, the target below */
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0 var(--space-element);
    padding: var(--space-pair) 0;
}
.upload .state { grid-column: 2; grid-row: 1; text-align: end; }
.upload .muted { grid-column: 1 / -1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* SPC-6 sequence: many similar rows */
.upload[data-line="sequence"]:not(:last-child) { border-bottom: 1px solid var(--separator); }
.upload .name { grid-column: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* the state's text in text-secondary, its Icon alone in success or error (COL-13 (6), ICN-4) */
.upload .state { color: var(--text-secondary); display: flex; gap: var(--space-pair); justify-content: end; }
.upload .state .icon { flex: none; }
.upload.done .state .icon { color: var(--success); }
.upload.failed .state .icon { color: var(--error); }
/* an error message can be long: it gets the full row below the name. Its lines start at one edge beside the Icon,
   so the text-align: end of the state beside the name does not apply (AES-1) */
.upload.failed .state { grid-column: 1 / -1; grid-row: auto; justify-content: start; text-align: start; overflow-wrap: anywhere; }

/* Details */

#detail { display: flex; flex-direction: column; gap: var(--space-group); }
#detail p { margin: 0; }
.title { font-size: var(--type-title-size); line-height: var(--type-title-line); font-weight: var(--type-title-weight); }
input.title {
    padding: var(--space-pair) var(--space-element);
    margin-inline: calc(-1 * var(--space-element) - var(--hairline));
    width: calc(100% + 2 * var(--space-element) + 2 * var(--hairline));
    border-color: transparent;
    background: transparent;
}
input.title:hover { border-color: var(--control-border); }
input.title:focus { border-color: var(--signal); background: var(--background); }
h2.title { overflow-wrap: anywhere; }

/* term/value list: column gap Group, row gap Element (SPC-2) */
.stats { display: grid; grid-template-columns: auto 1fr; gap: var(--space-element) var(--space-group); margin: 0; }
.stats dt { color: var(--text-secondary); }
.stats dd { margin: 0; overflow-wrap: anywhere; }
.link a { overflow-wrap: anywhere; }
#detail .actions { display: flex; flex-wrap: wrap; gap: var(--space-element); }

/* Tabs of a route: Info and Anstiege (underline, no radius) */

.tabs { display: flex; gap: var(--space-group); }
/* SPC-6 flush: the tab bar abuts its panel */
.tabs[data-line="flush"] { border-bottom: 1px solid var(--separator); }
.tabs button {
    margin-bottom: calc(-1 * var(--hairline));
    min-height: var(--hit);
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--text-secondary);
}
.tabs button[aria-selected="true"] { box-shadow: inset 0 -2px 0 var(--signal); color: var(--text); }
#detail .panel { display: flex; flex-direction: column; gap: var(--space-group); }
#detail .panel[hidden] { display: none; }

/* climb list: a sequence; the number badge carries the grade colour (data-colour.md) */
.climbs { display: grid; margin: 0; padding: 0; list-style: none; }
.climb { display: grid; gap: var(--space-pair); padding: var(--space-element) 0; cursor: pointer; }
/* SPC-6 sequence: many similar rows */
.climb[data-line="sequence"]:not(:last-child) { border-bottom: 1px solid var(--separator); }
.climb:hover { background: var(--fill); }
.climb.chosen { background: var(--signal-tint); }
.climb:focus-visible { outline: 2px solid var(--signal); outline-offset: -2px; }
.climb-head { display: flex; align-items: center; gap: var(--space-element); }
.climb .number {
    display: grid;
    place-items: center;
    flex: none;
    width: 1.5lh;
    height: 1.5lh;
    border: var(--number-badge-ring) solid var(--grade);
    border-radius: 50%;
    background: var(--background);
    color: var(--text);
    font-size: var(--type-compact-size);
    line-height: var(--type-compact-line);
}
.climb .range { flex: 1; min-width: 0; font-size: var(--type-heading-size); line-height: var(--type-heading-line); font-weight: var(--type-heading-weight); overflow-wrap: anywhere; }
.climb .range small { display: block; color: var(--text-secondary); font-size: var(--type-compact-size); line-height: var(--type-compact-line); font-weight: var(--type-text-weight); }
.climb .figures { color: var(--text-secondary); }

/* stops list (#559): a sequence like the climbs; the badge is the category's Data Colour with its symbol in the -icon role (DAT-4, DAT-5) */
.stop-list { display: grid; margin: 0; padding: 0; list-style: none; }
/* the search of the tab "Stopps" and its hits (#561) */
.stops { display: grid; gap: var(--space-group); }
.stops-search { display: grid; gap: var(--space-element); justify-items: start; }
.stops-search fieldset { margin: 0; }
.stretch-field { display: flex; align-items: center; gap: var(--space-element); color: var(--text); font-size: var(--type-text-size); line-height: var(--type-text-line); }
.stops-place { display: grid; gap: var(--space-element); justify-items: start; }
.stops-place p { margin: 0; }
/* the mode "Freien Stopp setzen" (#562): the cursor on map and profile says it */
.placing, .placing .maplibregl-canvas, .placing .elevation-chart .hit { cursor: crosshair; }
.stop-marker.movable { pointer-events: auto; cursor: grab; }
.stop-marker.movable:active { cursor: grabbing; }
.stops-hits { display: grid; gap: var(--space-element); }
.stops-heading, .stops-heading-row { color: var(--text-secondary); }
.stops-heading-row { display: flex; align-items: center; justify-content: space-between; }
.stop[data-line="sequence"]:not(:last-child) { border-bottom: 1px solid var(--separator); }
.stop:hover { background: var(--fill); }
.stop-head { display: flex; align-items: center; gap: var(--space-element); padding: var(--space-element) 0; cursor: pointer; }
.stop-head:focus-visible { outline: 2px solid var(--signal); outline-offset: -2px; }
/* the stop's badge, a mark; details and mark below a stop start after it */
:root { --stop-badge: 1.5lh; }
.stop-badge, .stop-marker {
    display: grid;
    place-items: center;
    flex: none;
    width: var(--stop-badge);
    height: var(--stop-badge);
    border-radius: 50%;
    background: var(--stop);
    color: var(--stop-icon);
}
.stop-badge .place-symbol, .stop-marker .place-symbol { width: 1lh; height: 1lh; }
.place-symbol { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.stop-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.stop-text small { display: block; color: var(--text-secondary); font-size: var(--type-compact-size); line-height: var(--type-compact-line); }
.stop-details { display: grid; gap: var(--space-element); padding: 0 0 var(--space-element) calc(var(--stop-badge) + var(--space-element)); }
.stop-mark { padding: 0 0 var(--space-element) calc(var(--stop-badge) + var(--space-element)); }
.stop-links { display: flex; flex-wrap: wrap; gap: var(--space-element) var(--space-group); margin: 0; }
.stop-edit { display: grid; gap: var(--space-element); }
.stop-edit textarea { min-height: 3lh; }
.stop-note { margin: 0; color: var(--text-secondary); overflow-wrap: anywhere; }
/* on the map (class map-content: the roles stay light): the ring sets the Data Colour off the map ground (DAT-3) */
.stop-marker { width: 1.5lh; height: 1.5lh; border: var(--number-badge-ring) solid var(--contour); box-sizing: content-box; pointer-events: none; }
.stop-chosen .stop-marker, .stop-chosen .hit-marker { opacity: 0.45; }
.stop-chosen .stop-marker.highlight, .stop-chosen .hit-marker.highlight { opacity: 1; z-index: 1; }
/* a hit of the POI search (#561): smaller than a stop, on the map ground with a ring in the category's Data Colour */
.hit-marker {
    display: grid;
    place-items: center;
    width: 1.1lh;
    height: 1.1lh;
    border-radius: 50%;
    border: var(--number-badge-ring) solid var(--stop);
    background: var(--surface);
    color: var(--text);
    box-sizing: content-box;
    pointer-events: none;
}
.hit-marker .place-symbol { width: 0.75lh; height: 0.75lh; }

.rides { display: grid; gap: var(--space-element); }
.ride-form { display: flex; flex-wrap: wrap; gap: var(--space-element); }
.ride-form input[type="date"] { width: auto; }
.ride-form input:not([type]) { flex: 1; min-width: 8em; width: auto; }
.rides .entries li { padding: var(--space-pair) 0; }

.surface-list h3 { margin: 0 0 var(--space-element); color: var(--text-secondary); }
.surface-list ul { display: grid; gap: var(--space-pair); margin: 0; padding: 0; list-style: none; }
.surface-list li { display: flex; align-items: center; gap: var(--space-element); }
.surface-list .name { flex: 1; }
.surface-list .meta { color: var(--text-secondary); }
.surface-legend { display: flex; flex-wrap: wrap; gap: var(--space-pair) var(--space-group); color: var(--text-secondary); font-size: var(--type-compact-size); line-height: var(--type-compact-line); }
.surface-legend span { display: inline-flex; align-items: center; gap: var(--space-pair); }

.legend { list-style: none; margin: var(--space-element) 0 0; padding: 0; }
.legend li { display: flex; align-items: center; gap: var(--space-element); }
.legend input {
    appearance: none;
    flex: none;
    width: 1lh;
    height: 1lh;
    min-height: 0;
    padding: 0;
    border: 2px solid var(--color);
    border-radius: var(--radius-checkbox);
    background: transparent;
    cursor: pointer;
}
.legend input:checked { background: var(--color); box-shadow: inset 0 0 0 2px var(--background); }
.legend .name { flex: 1; min-width: 0; padding: var(--space-pair); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.legend .meta { color: var(--text-secondary); }

/* The weather (#139): the tab, the charts between map and profile, the map's marks and button.
   Everything around the data is a role of the Design Language package; the data colours (models, wind,
   symbols, night, no forecast) are roles of the Data Colour Map. */

:root {
    --axis-inset: 52px;  /* the left margin of the profile's axis (elevation-chart.js MARGIN.left) */
}

.weather { display: flex; flex-direction: column; gap: var(--space-group); }
.weather-form { display: grid; gap: var(--space-element); }
.weather-form .field { display: flex; align-items: center; gap: var(--space-element); flex-wrap: wrap; }
.weather-form .field label { width: 5em; margin: 0; }
.weather-form .field input { width: auto; padding: var(--space-pair) var(--space-element); }
.weather-form input[type="number"] { width: 6em; }
.weather-form h3 { margin-top: var(--space-element); }
.weather-form .actions { align-items: center; margin-top: var(--space-pair); }
.weather-form .field input[type="number"], .pace-fields input[type="number"] { width: 6em; }
.pace-note { display: flex; align-items: center; gap: var(--space-element); flex-wrap: wrap; font-size: var(--type-text-size); line-height: var(--type-text-line); }
.pace-note button { padding: var(--space-pair) var(--space-element); font-size: var(--type-text-size); line-height: var(--type-text-line); }
.pace-fields { display: grid; gap: var(--space-element); }
.pace-fields .field { display: flex; align-items: center; gap: var(--space-element); }
.pace-fields .field label { width: 5em; margin: 0; }
.panel-dialog section > button { justify-self: start; }
.poi-categories { display: grid; gap: var(--space-element); margin-block: var(--space-element); }
.check-row { display: flex; align-items: center; gap: var(--space-element); margin: 0; color: var(--text); font-size: var(--type-text-size); line-height: var(--type-text-line); }
.check-row input { width: auto; margin: 0; }
.weather-result { display: grid; gap: var(--space-group); }
.weather-result.outdated { opacity: 0.5; }
.weather-hints { display: grid; gap: var(--space-element); margin: 0; padding: 0; list-style: none; }
/* each hint a Notice: inner padding Element, concentric (RAD-2); the warning's statement is its default
   Icon in warning, the text stays text (COL-1, COL-13, ICN-4 (3)) */
.weather-hints li { display: grid; grid-template-columns: 1lh 1fr; gap: var(--space-element); padding: var(--space-element); border-radius: var(--radius-notice); font-size: var(--type-text-size); line-height: var(--type-text-line); }
.weather-hints .warn { background: var(--surface); color: var(--text); }
.weather-hints .warn .hint-mark { color: var(--warning); }
.weather-hints .info { background: var(--fill); color: var(--text-secondary); }
/* the mark before a hint: a Data Symbol or plain character for an info hint (ICN-8), the Icon Warning for a warning */
.hint-mark { width: 1lh; height: 1lh; color: var(--text-secondary); }
.hint-mark svg { width: 100%; height: 100%; display: block; }
.table-scroll { overflow-x: auto; }
.weather-table { width: 100%; border-collapse: collapse; font-size: var(--type-text-size); line-height: var(--type-text-line); font-variant-numeric: tabular-nums; }
.weather-table th { padding: var(--space-pair); color: var(--text-secondary); font-size: var(--type-caption-size); line-height: var(--type-caption-line); text-align: right; }  /* table heads: Caption */
.weather-table td { padding: var(--space-pair); border-top: 1px solid var(--separator); text-align: right; white-space: nowrap; }  /* SPC-6 sequence */
.weather-table th:first-child, .weather-table td:first-child { text-align: left; }
.weather-table td .wx-icon { display: block; margin-left: auto; }
.weather-table tr.none td { color: var(--text-secondary); }
.weather-table tbody tr:hover, .weather-table tbody tr.current { background: var(--signal-tint); }
.wind-arrow { vertical-align: -1px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* the choice of the chart under the map, on a phone only (#644, chart-slot.js; the narrow-width rules at the end show it) */
.slot-switch { display: none; padding: var(--space-pair) var(--space-element); border-top: 1px solid var(--separator); background: var(--surface); }
.weather-charts { border-top: 1px solid var(--separator); background: var(--surface); }  /* SPC-6 flush: the charts abut the map above them */
.weather-head { display: flex; align-items: center; gap: var(--space-element); padding: 0 var(--space-element) 0 var(--axis-inset); }
.weather-readout {
    flex: 1;
    min-width: 0;
    min-height: 1lh;  /* keeps its height while empty, so the charts don't jump with the pointer */
    overflow: hidden;
    color: var(--text-secondary);
    font-size: var(--type-compact-size);
    line-height: var(--type-compact-line);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.weather-readout b { color: var(--text); }
.weather-chart { display: block; font-size: var(--type-caption-size); line-height: var(--type-caption-line); user-select: none; }  /* the axis values: Caption (CHT-4) */
.weather-chart .grid line { stroke: var(--separator); stroke-width: 1; }
.weather-chart text { fill: var(--text-secondary); font-variant-numeric: tabular-nums; }
.weather-chart .strip-title { fill: var(--text); font-size: var(--type-heading-size); line-height: var(--type-heading-line); font-weight: var(--type-heading-weight); }
.weather-chart .strip-key { font-size: var(--type-compact-size); line-height: var(--type-compact-line); }
.weather-chart .strip-key-ground { fill: var(--background); }  /* under a key that a shaded area reaches (DAT-4) */
.weather-chart .night { fill: var(--night); fill-opacity: 0.15; }
.weather-chart .night-label { fill: var(--text); font-size: var(--type-compact-size); line-height: var(--type-compact-line); }
.weather-chart .no-forecast { fill: url(#no-forecast); }
.weather-chart .no-forecast-ground { fill: var(--no-forecast); fill-opacity: 0.12; }
.weather-chart .no-forecast-line { stroke: var(--no-forecast); stroke-width: 0.8; }  /* part of the hatching, not a data line: thin at full colour instead of stroke-opacity (#642) */
.weather-chart .no-forecast-label { fill: var(--text); font-size: var(--type-compact-size); line-height: var(--type-compact-line); }
.weather-chart .series { fill: none; stroke-width: 2; stroke-linejoin: round; }
.weather-chart .series.second { stroke-width: 1.4; stroke-dasharray: 4 3; }
.weather-chart .series.probability { stroke-width: 1.5; stroke-dasharray: 1 3; }
.weather-chart .series { stroke: var(--model-1-line); }
.weather-chart .bar { fill: var(--model-1); fill-opacity: 0.75; stroke: none; }
.weather-chart .freezing { stroke: var(--freezing-line); stroke-dasharray: 2 3; }
.weather-chart .cursor { stroke: var(--text); stroke-width: 1; }
.weather-chart .hit { fill: transparent; cursor: crosshair; }
.arrow { fill: var(--wind-none); }  /* the colour of an arrow is set where it is drawn (weather-chart.js, windColour) */

.wx-sun { fill: var(--wx-sun); }
.wx-ray { fill: none; stroke: var(--wx-sun); stroke-width: 1.5; stroke-linecap: round; }
.wx-moon { fill: var(--wx-moon); }
.wx-cloud { fill: var(--wx-cloud); }
.wx-fog { fill: none; stroke: var(--wx-cloud); stroke-width: 1.8; stroke-linecap: round; }
.wx-drop circle { fill: var(--wx-rain); }
.wx-rain { fill: none; stroke: var(--wx-rain); stroke-width: 1.6; stroke-linecap: round; }
.wx-bolt { fill: var(--wx-bolt); }
.wx-star { fill: var(--wx-moon); }
.wx-rain.heavy { stroke-width: 1.8; }
.wx-flakes { fill: none; stroke: var(--wx-snow); stroke-width: 1.1; stroke-linecap: round; }
.wx-hail circle { fill: var(--surface); stroke: var(--wx-snow); stroke-width: 1; }

/* While "m" is held (map-hide.js) the markers are hidden; the map's controls stay. */
.content-hidden .maplibregl-marker { visibility: hidden; }

/* The weather mark is a Map Label of the package (LAY-9); only what it adds: the space between icon and temperature, and the icon at the Caption's size (icons.md, Size and stroke) */
.weather-mark { gap: var(--space-pair); }
.weather-mark .wx-icon { width: 1lh; height: 1lh; flex: none; }
.weather-colour { display: grid; gap: var(--space-element); padding: var(--space-pair); border-radius: var(--radius-menu); background: var(--background); border: var(--hairline) solid var(--separator); color: var(--text); font-family: var(--font-stack); font-size: var(--type-compact-size); line-height: var(--type-compact-line); }
.weather-colour[hidden] { display: none; }
.weather-colour .field-label { margin: 0; padding-inline: var(--space-element); }
/* in a narrow map window the four segments wrap; the package's inline-flex does not */
.weather-colour fieldset[data-segmented] { flex-wrap: wrap; justify-self: start; }
.weather-colour .legend-ramp { display: grid; gap: var(--space-pair); padding: 0 var(--space-element) var(--space-pair); }
.weather-colour .ramp { height: 8px; border-radius: var(--radius-swatch); }
.weather-colour .ends { display: flex; justify-content: space-between; color: var(--text-secondary); }
.weather-colour .muted { color: var(--text-secondary); }

/* Narrow windows (Components Sidebar toggle and App bar, SPC-4): three states by the width of the window, in em (the --column-* Tokens
   cannot be used in a media query, so these are their sums; the splitter is --space-element = 0.5em):
   - from 65em: sidebar 20em + content 20em + inspector 24em + two splitters, three columns;
   - below it: the sidebar is an overlay on the content (sidebar overlay, not the map's overlays);
   - below 44.5em: content 20em + inspector 24em + one splitter no longer fit side by side, so they stack. */

@media (width < 65em) {
    .sidebar-toggle { display: inline-flex; }
    .columns {
        grid-template-columns: minmax(var(--column-content), 1fr) var(--space-element) minmax(min(var(--right), var(--column-inspector)), var(--right));
    }
    .splitter[data-side="left"] { display: none; }

    #sidebar {
        position: fixed;
        top: var(--bar-height);
        bottom: 0;
        left: 0;
        z-index: 20;
        width: min(var(--column-sidebar), 100% - 3em);
        background: var(--background);
        border-right: 1px solid var(--separator);
        translate: -100% 0;
        visibility: hidden;
    }
    #sidebar[data-open="true"] { translate: 0 0; visibility: visible; }

    .scrim {
        display: block;
        position: fixed;
        inset: var(--bar-height) 0 0 0;
        z-index: 15;
        background: var(--text);
        opacity: 0;
        pointer-events: none;
    }
    #sidebar[data-open="true"] + .scrim { opacity: 0.3; pointer-events: auto; }

    /* Component Sidebar: it glides only after a toggle (data-open), a change of width never animates,
       and it is visible from the first frame on opening (to take the focus), until the end when closing */
    #sidebar[data-open="true"] { transition: translate var(--motion); }
    #sidebar[data-open="false"] { transition: translate var(--motion), visibility 0s var(--motion-duration); }
    #sidebar[data-open] + .scrim { transition: opacity var(--motion); }
}

@media (width < 44.5em) {
    /* the page scrolls itself, below the sticky Header Bar */
    body { display: block; overflow: visible; }
    .columns { display: block; }
    .splitter { display: none; }
    #detail { overflow: visible; }
    /* #644: the centre grows with what stands under the map. The map is as high as with the profile alone
       (75vh minus the profile, view.js sets --profile-space), whichever chart the place shows. */
    #center { height: auto; grid-template-rows: none; grid-auto-rows: auto; }
    .map { height: calc(75vh - var(--profile-space, 0px)); }
    /* with a forecast and its charts, the place under the map shows one chart, chosen in its own row */
    .slot-switch:not([hidden]) { display: block; }
    #center[data-slot="weather"] .profile, #center[data-slot="profile"] .weather-charts { display: none; }
    /* SPC-6 flush: the detail abuts the map area above it */
    #detail[data-line="flush"] { border-top: 1px solid var(--separator); }
}
