/* Shared look of the web apps: the controls the package leaves open, dialogs, toasts.
   Colours, Type Levels, Spacing Roles, radii and the native controls (button, input, select, dialog) come from the
   Design Language package; only roles are used here. */

html, body { height: 100%; margin: 0; }

body {
    background: var(--background);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; }

a { color: var(--signal); }

.muted { color: var(--text-secondary); }
[hidden] { display: none !important; }

/* Controls: button, input, select and textarea are styled by the package. These are the class hooks the apps use. */

/* .button: a link that looks like the package's button (a download, which stays a link): on fill with a
   transparent 1 px border, so the height stays; pressed, fill mixed toward text (PLC-5). */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-pair);
    min-block-size: var(--hit);
    padding-inline: var(--space-element);
    border: 1px solid transparent;
    border-radius: var(--radius-control);
    background: var(--fill);
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
}
.button:active { background: color-mix(in oklab, var(--fill), var(--text) 15%); }

/* Hooks the package leaves open. data-main, data-destructive and data-icon-only are the package's:
   a Destructive Action is labelled in error on fill, never on a red surface, also in its confirmation (PLC-5). */
/* data-quiet: a text button without border, for actions that sit in a bar or beside a list */
button[data-quiet] { border-color: transparent; background: transparent; }
button[data-quiet]:disabled { border-color: transparent; }

textarea { width: 100%; resize: vertical; min-block-size: calc(4 * var(--hit)); }
input:not([type="checkbox"], [type="radio"], [type="range"]) { width: 100%; }

/* .field-label: the name of a group of inputs (no single input to point at), looks like a label.
   A Segmented Control's options are labels too: they keep the package's look, so this unlayered rule skips them.
   :where() keeps the specificity of a bare label, so a class such as .check-row still overrides it. */
label:where(:not(fieldset[data-segmented] label)), .field-label { display: block; margin-block-end: var(--space-pair); color: var(--text-secondary); }

/* Dialogs (web/shared/ui.js): Web Presentations; surface, radius and padding come from the package, no shadow (RAD-2).
   A panel dialog keeps the inner padding Element of a dialog in its header and body, concentric to its radius. */

dialog { width: min(var(--column-inspector), calc(100vw - 2 * var(--margin))); }
dialog form { display: grid; gap: var(--space-group); }
dialog p { margin: 0; }
dialog .actions { display: flex; justify-content: flex-end; gap: var(--space-element); }
/* PLC-5: a Destructive Action comes last, set off by Group instead of Element (the gap already adds Element) */
.actions [data-destructive]:not(:first-child), .entries li [data-destructive]:not(:first-child) { margin-inline-start: calc(var(--space-group) - var(--space-element)); }

.panel-dialog { width: min(var(--measure), calc(100vw - 2 * var(--margin))); max-height: calc(100vh - 2 * var(--margin)); padding: 0; }
.panel-dialog > header { display: flex; align-items: center; gap: var(--space-element); padding: var(--space-element); }
.panel-dialog > header[data-line="flush"] { border-block-end: 1px solid var(--separator); }
.panel-dialog > header h2 { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.panel-dialog .body { display: grid; gap: var(--space-group); padding: var(--space-element); }
.panel-dialog section { display: grid; gap: var(--space-element); }
/* A Segmented Control placed directly in a section keeps its own width (inline-flex in the package), the grid would stretch it */
.panel-dialog section > fieldset[data-segmented] { justify-self: start; }
.panel-dialog form .actions { justify-content: flex-start; }

/* Settings (web/shared/categories.js): the list of categories beside the content, as the package's sidebar list (text only,
   the active entry in signal-tint, a hairline to the content). The dialog is wider by the list; only the content scrolls.
   All contents sit in one grid cell and the hidden ones keep their space, so the height is the largest one's.
   Below the width where the content would be narrower than the measure, the list is a row above it. */
.panel-dialog.settings { --category-list: 9em; width: min(calc(var(--measure) + var(--category-list)), calc(100vw - 2 * var(--margin))); }
.panel-dialog.settings[open] { display: flex; flex-direction: column; }
.panel-dialog.settings .body { display: block; flex: 1; min-height: 0; padding: 0; container-type: inline-size; }
.categories { display: grid; grid-template-columns: var(--category-list) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); block-size: 100%; }
.category-list { display: flex; flex-direction: column; padding: var(--space-element); border-inline-end: var(--hairline) solid var(--separator); }
.category-list button[role="tab"] { justify-content: flex-start; text-align: start; }
.category-list button[role="tab"][aria-selected="true"] { background: var(--signal-tint); }
.category-content { display: grid; overflow-y: auto; align-content: start; }
.category-content > [role="tabpanel"] { grid-area: 1 / 1; display: grid; gap: var(--space-group); align-content: start; padding: var(--space-element); }
.category-content > [data-shown="false"] { visibility: hidden; }
@container (width < 49em) { /* the measure (40em) and --category-list */
    .categories { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
    .category-list { flex-direction: row; flex-wrap: wrap; border-inline-end: none; border-block-end: var(--hairline) solid var(--separator); }
}

/* Lists with one entry per row and an action at the end: shares, logins, rides */
.entries { display: grid; margin: 0; padding: 0; list-style: none; }
.entries li { display: flex; align-items: center; gap: var(--space-element); padding-block: var(--space-element); }
.entries[data-line="sequence"] li { border-block-end: 1px solid var(--separator); }
.entries[data-line="sequence"] li:last-child { border-block-end: 0; }
.entries .main { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.entries .sub { display: block; color: var(--text-secondary); font-size: var(--type-compact-size); line-height: var(--type-compact-line); }

/* .error-notice (web/shared/ui.js, `errorNotice`): an error as a Notice in the content, the Icon Error in error and
   the text in text (COL-13 (5), ICN-4 (3)); the field it concerns has the package's error border (aria-invalid). */
.error-notice { display: flex; gap: var(--space-pair); margin: 0; color: var(--text); }
.error-notice > .icon { flex: none; color: var(--error); }

/* Toasts (web/shared/ui.js, `toast`): a message that floats at the bottom, drawn like a Web Presentation (surface,
   --radius-notice, padding Element, RAD-2). It floats, unlike the Glossary's Notice, which stands in the content where
   it applies: these messages belong to actions with no common place in the content. LAY-1 (only system elements
   float) is an Apple Rule, so floating breaks no Rule on the web. The text is in text; the kind sets only the colour
   of its Icon (COL-13, ICN-4 (3)). */

.toasts {
    position: fixed;
    inset-block-end: var(--space-group);
    inset-inline: 0;
    margin-inline: auto;
    display: grid;
    gap: var(--space-element);
    z-index: 10;
    width: min(var(--column-inspector), calc(100vw - 2 * var(--margin)));
}
.toast {
    display: flex;
    gap: var(--space-pair);
    padding: var(--space-element);
    border-radius: var(--radius-notice);
    background: var(--surface);
    color: var(--text);
}
.toast > .icon { flex: none; }
.toast.error > .icon { color: var(--error); }
.toast.warning > .icon { color: var(--warning); }
.toast.success > .icon { color: var(--success); }

/* Elevation profile (web/shared/elevation-chart.js): the chart's own text and line weights are Type Levels and roles */

.elevation-chart { display: block; font-size: var(--type-caption-size); line-height: var(--type-caption-line); user-select: none; }  /* the axis values: Caption (CHT-4) */
.elevation-chart .grid line { stroke: var(--separator); stroke-width: 1; }
.elevation-chart .grid text { fill: var(--text-secondary); font-variant-numeric: tabular-nums; }
.elevation-chart .area { opacity: 0.85; }
.elevation-chart .outline { fill: none; stroke: var(--text); stroke-opacity: 0.55; stroke-width: 1.2; stroke-linejoin: round; }
.elevation-chart .peak { fill: var(--text); }
.elevation-chart .peak-label { fill: var(--text); font-size: var(--type-compact-size); line-height: var(--type-compact-line); }
/* places on the line: the Data Colour of their category (roles of the Colour Map, DAT-2) with its symbol in the -icon role (DAT-4) */
.elevation-chart .stop circle { fill: var(--stop); stroke: var(--surface); stroke-width: var(--number-badge-ring); }
.elevation-chart .stop .glyph { fill: none; stroke: var(--stop-icon); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.elevation-chart .hit line { stroke: var(--stop); stroke-width: var(--number-badge-ring); stroke-linecap: round; }
.elevation-chart.stop-chosen .stop, .elevation-chart.stop-chosen .hit { opacity: 0.45; }
.elevation-chart.stop-chosen .stop.highlight, .elevation-chart.stop-chosen .hit.highlight { opacity: 1; }
.elevation-chart .hit.highlight line { stroke-width: 5; }
.elevation-chart .stop.highlight circle { stroke: var(--text); }
.elevation-chart .cursor line { stroke: var(--text); stroke-width: 1; }
.elevation-chart .cursor circle { fill: var(--surface); stroke: var(--text); stroke-width: 2; }
/* the tooltip's corners come from here, not from the SVG attribute: a token can only be a CSS property (RAD-1) */
.elevation-chart .tip rect { fill: var(--text); rx: var(--radius-tooltip); }
.elevation-chart .tip text { fill: var(--background); font-size: var(--type-compact-size); line-height: var(--type-compact-line); font-variant-numeric: tabular-nums; }
.elevation-chart .hit { fill: transparent; cursor: crosshair; }
.elevation-chart.selecting rect.hit { touch-action: pan-y; }  /* a stretch is dragged sideways (#563); up and down still scrolls */
.elevation-chart .fade rect { fill: var(--surface); fill-opacity: 0.7; }
.elevation-chart .climb-lines line { stroke: var(--text-secondary); stroke-width: 1; stroke-dasharray: 3 3; }  /* neutral, stronger than the grid's separator */
.elevation-chart .climb-label circle { fill: var(--background); stroke: var(--grade); stroke-width: var(--number-badge-ring); }
.elevation-chart .climb-label text { fill: var(--text); font-size: var(--type-caption-size); line-height: var(--type-caption-line); }
/* a Mini Chart: only the shape, its area opaque with the Contour of the Suite's charts (CHT-10, docs/design/route-charts.md);
   its height is the Product's (CHT-4), set as --climb-chart-height in the app's CSS */
.mini-chart { display: block; width: 100%; height: var(--climb-chart-height); }
.elevation-chart .surface-ground { fill: var(--fill); }
.surface-strip { position: relative; height: 8px; border-radius: var(--radius-swatch); background: var(--fill); overflow: hidden; }
.surface-strip span { position: absolute; top: 0; bottom: 0; }
.surface-strip.swatch { display: inline-block; flex: none; width: 22px; vertical-align: middle; }
/* no Contour in dark mode (DAT-3) */
.mini-chart .outline { fill: none; stroke: light-dark(var(--contour), transparent); stroke-width: var(--contour-area); stroke-linejoin: round; }
