/* components.css - the few things plain elements cannot express. Still no class names: data-* attributes only. */
/* Author: a2@clacks-bridge.org. Generated/edited with Claude. Copyright: clacks-bridge.org. License: MIT */

/* chip: <button data-chip aria-pressed="true|false"> chooses a state, <span data-chip> is a static tag. A pressed chip
   is not a solid button (that is an action): it uses the selection look of the rest of the framework, the select tint
   with a 2px hi line, like the selected table row and the selected option of a combo box. */
[data-chip] { display: inline-flex; align-items: center; min-height: calc(var(--ctl) * 0.85); padding: 0.1rem 0.85rem;
    font-size: var(--fs-small); color: var(--text); background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius); }
span[data-chip] { min-height: 0; padding: 0.05rem 0.6rem; color: var(--muted); border-color: var(--line);
    cursor: default; }
span[data-chip="tag"] { color: var(--link); }
button[data-chip]:hover { background: var(--panel); }
button[data-chip][aria-pressed="true"] { background: var(--select); color: var(--text); border-color: var(--hi);
    box-shadow: inset 0 0 0 1px var(--hi); }
[role=group] { display: flex; flex-wrap: wrap; gap: var(--gap-s); padding: 0.15rem 0; }

/* badge: a status word. The states that need attention (warn, bad) are solid; ok and info stay plain text. */
[data-badge] { font-size: var(--fs-small); color: var(--ok); }
[data-badge="info"] { color: var(--link); }
[data-badge="warn"], [data-badge="bad"] { padding: 0 0.6em; border-radius: var(--radius); }
/* as on safety signs (ISO 3864, ANSI Z535): black on amber for a warning, white on red for danger */
[data-badge="warn"] { color: var(--on-warn); background: var(--warn-fill); box-shadow: inset 0 0 0 1px var(--warn); }
[data-badge="bad"] { color: var(--on-danger); background: var(--danger-btn); }

/* label (small caps) and mono reference */
[data-k] { font-size: calc(var(--fs-small) * 0.95); letter-spacing: 0.07em; text-transform: uppercase;
    color: var(--label); }
[data-k="warn"] { color: var(--warn); }
[data-ref] { font-family: var(--font-mono); color: var(--ref); }

/* stats line */
[data-stats] { display: flex; flex-wrap: wrap; gap: 0.2rem 1rem; margin: var(--gap-s) 0; color: var(--muted); }
[data-stats] strong { color: var(--strong); }

/* key/value grid: <dl data-grid> with <dt>/<dd> pairs inside */
dl[data-grid] { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 0.9rem; }
dl[data-grid] dt { margin: 0; align-self: baseline; }
dl[data-grid] dt[data-hot], dl[data-grid] dd[data-hot] { color: var(--warn); }

/* dated list: <ul data-dates><li><time>2026-12-01</time> what to do</li></ul> */
ul[data-dates] { list-style: none; padding: 0; }
ul[data-dates] li { display: grid; grid-template-columns: 6.5rem 1fr; gap: var(--gap-s); margin: 0.25rem 0; }
ul[data-dates] time { font-family: var(--font-mono); font-size: 0.9em; color: var(--label); }

/* bars. <aside> is the amber usage notice (content aside from the page). Messages are <p role="status"> (announced
   politely) and <p role="alert"> (announced at once); data-state picks info (default for status), ok, warn, bad
   (default for alert). */
:is(aside, [role=status], [role=alert]) { margin: 0 0 var(--gap); padding: 0.5rem 0.9rem; }
aside { --ground: var(--notice-bg); --border: var(--notice-border); --edge: var(--notice-border);
    color: var(--notice-text); }
[role=status] { --ground: var(--panel); --border: var(--link); --edge: var(--link); color: var(--text); }
[role=alert] { --ground: var(--danger-btn); --border: var(--danger-btn); --edge: var(--danger-btn);
    color: var(--on-danger); }
:is(aside, [role=status], [role=alert])[data-state="info"] {
  --ground: var(--panel); --border: var(--link); --edge: var(--link); color: var(--text); }
:is(aside, [role=status], [role=alert])[data-state="ok"] {
  --ground: var(--panel); --border: var(--ok); --edge: var(--ok); color: var(--ok); }
:is(aside, [role=status], [role=alert])[data-state="warn"] {
  --ground: var(--notice-bg); --border: var(--notice-border); --edge: var(--notice-border);
  color: var(--notice-text); }
:is(aside, [role=status], [role=alert])[data-state="bad"] {
  --ground: var(--danger-btn); --border: var(--danger-btn); --edge: var(--danger-btn);
  color: var(--on-danger); }
:is(aside, [role=status], [role=alert]) a { color: inherit; }

/* toolbar row of chips and a search field */
[data-bar] { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap-s) var(--gap); }
input[type=search] { max-width: 100%; }
/* the focus ring (2px) of the search field must not touch the chips below it */
[data-filters] > input[type=search] { margin-bottom: var(--gap-s); }

/* gallery only: the words of a text with the frame a field gets in that state: span[data-sample=bad|ok|pending] */
[data-sample] { padding: 0 0.35em; border: 1px solid var(--border); border-radius: var(--radius); }
[data-sample="bad"] { border-color: var(--danger); }
[data-sample="ok"] { border-color: var(--ok); }
[data-sample="pending"] { border-style: dashed; border-color: var(--link); }

/* gallery only: colour swatches */
[data-swatches] { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: var(--gap-s); }
[data-swatches] div { font-size: var(--fs-small); color: var(--muted); }
[data-swatches] i { display: block; height: 1.8rem; margin-bottom: 0.2rem; border: 1px solid var(--border);
    border-radius: 0.2rem; }

/* combo-box: <combo-box><input><ul><li data-id>..</li></ul></combo-box> (see js/combo.js). The list follows the
theme. */
combo-box, date-field { position: relative; display: block; }
combo-box > input, date-field > input { padding-right: 2.2rem; }
combo-box:not([data-readonly]) > input { cursor: text; }
combo-box[data-readonly] > input { cursor: pointer; }
combo-box::after, date-field::after { content: ""; position: absolute; right: 0.8rem;
                   top: calc(0.15rem + var(--ctl) / 2 - 0.2rem);
    width: 0; height: 0; pointer-events: none;
                   border-left: 0.3rem solid transparent; border-right: 0.3rem solid transparent;
                       border-top: 0.4rem solid var(--muted); }
ul[role=listbox] { position: absolute; z-index: 30; left: 0; right: 0; top: calc(var(--ctl) + 0.2rem);
    max-height: 15rem; overflow-y: auto;
                   margin: 0; padding: 0.15rem 0; list-style: none; background: var(--surface); color: var(--text);
                       font-size: var(--fs);
                   border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 6px 14px rgba(0, 0, 0,
                       0.3); }
[role=option] { margin: 0; padding: 0.3rem 0.8rem; cursor: pointer; }
[role=option]:hover, [role=option][aria-current=true] { background: color-mix(in srgb, var(--select) 55%,
    var(--surface)); }
[role=option][aria-selected=true] { background: var(--select); box-shadow: inset 4px 0 0 var(--hi); }

/* size ruler (gallery): <p data-px="14"> shows a bar N px high next to text of N px, to judge readable sizes */
[data-px] { margin: 0 0 var(--gap-s); padding: 0 0.4rem; font-size: var(--px); line-height: 1.4; }
/* the rows nearest to the body and the small text in use now (js/gallery.js sets data-use) */
[data-px][data-use] { color: var(--strong); background: var(--select); box-shadow: inset 0 0 0 2px var(--hi); }
[data-px][data-use]::after { content: "  <- " attr(data-use) " text now"; color: var(--label); }
[data-px]::before { content: ""; display: inline-block; width: 2.5rem; height: var(--px); margin-right: 0.7rem;
    background: var(--hi); }
[data-px="10"] { --px: 10px; }
[data-px="12"] { --px: 12px; }
[data-px="13"] { --px: 13px; }
[data-px="14"] { --px: 14px; }
[data-px="15"] { --px: 15px; }
[data-px="16"] { --px: 16px; }
[data-px="17"] { --px: 17px; }
[data-px="18"] { --px: 18px; }
[data-px="19"] { --px: 19px; }
[data-px="20"] { --px: 20px; }

/* close button of a bar: <p role="status"> Saved. <button data-close aria-label="Close">X</button> </p>. It sits in the
   top right corner and takes the colour of the bar; js/dialog.js hides the bar on a click. */
:is(aside, [role=status], [role=alert]):has(> button[data-close]) { position: relative; padding-right: 2.8rem; }
:is(aside, [role=status], [role=alert]) > button[data-close] { position: absolute; top: 0.25rem; right: 0.35rem;
    min-width: 1.9rem; min-height: 1.9rem; padding: 0; color: inherit; background: transparent;
    border: 1px solid transparent; }
:is(aside, [role=status], [role=alert]) > button[data-close]:hover {
    background: transparent; border-color: currentColor; }

/* date-field (js/fields.js): a text field with a calendar below it, framed like the list of a combo box. The chosen day
   uses the selection look of the framework (select tint, hi ring); today has a plain line; weekends are muted. */
[data-calendar] { position: absolute; z-index: 30; left: 0; top: calc(var(--ctl) + 0.2rem); width: 18rem;
    max-width: 100%;
    padding: var(--gap-s); color: var(--text); background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: 0 6px 14px rgba(0, 0, 0, 0.3); }
[data-calendar] button { min-height: calc(var(--ctl) * 0.8); padding: 0; color: var(--text); background: transparent;
    border: 1px solid transparent; }
[data-calendar] button:hover { background: var(--panel); }
[data-head] { display: flex; align-items: center; gap: 0.15rem; margin-bottom: var(--gap-s); }
[data-head] span { flex: 1; text-align: center; color: var(--strong); }
[data-head] button { min-width: calc(var(--ctl) * 0.8); }
[data-grid] { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
[data-grid] [role=columnheader] { padding: 0.2rem 0; text-align: center; color: var(--muted);
    font-size: var(--fs-small); }
[data-grid] button { width: 100%; }
[data-grid] [data-weekend] { color: var(--muted); }
[data-grid] [aria-current=date] { border-color: var(--border); }
[data-grid] [data-active] { box-shadow: inset 0 0 0 1px var(--link); }
[data-grid] [aria-selected=true] { color: var(--text); background: var(--select); border-color: var(--hi);
    box-shadow: inset 0 0 0 1px var(--hi); }
[data-grid] button:disabled { opacity: 0.35; cursor: not-allowed; }
[data-now] { width: 100%; margin-top: var(--gap-s); border-color: var(--border); }

/* the error under a control (js/validate.js) */
output[data-error] { margin: 0.15rem 0 var(--gap-s); color: var(--danger); font-size: var(--fs-small); }

/* a box that scrolls: <section data-scroll> (the sticky header demo; any frame or block works) */
[data-scroll] { max-height: 14rem; overflow-y: auto; }

/* number pad and step buttons (js/keypad.js). Large keys with words on them, calculator-style (7 8 9 on
   top). A key shows a press at once (data-pressed, :active is slow on a bad screen). Disabled keys stay in place, so
   the layout never moves. The right column is CLEAR, BACK, CANCEL, ENTER (cancel and enter together at the bottom).
   With data-delta there is a row of three mode buttons, SET ADD SUB, above the digits (hidden without it). The pad is
   a panel at the bottom of the screen on a narrow window. */
[data-pad] { position: absolute; z-index: 50; display: grid; grid-template-columns: repeat(3, 1fr) 1.45fr;
    gap: var(--gap-s); width: max(16rem, calc(var(--ctl) * 6.2)); max-width: 100vw; padding: var(--gap-s);
    color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.3); }
[data-pad][data-sheet] { position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto;
    border-radius: var(--radius) var(--radius) 0 0; }
[data-pad] [data-screen] { grid-column: 1 / -1; display: grid; grid-template-columns: max-content 1fr;
    gap: 0 var(--gap); grid-template-areas: "old side" "display display" "hint hint"; padding: var(--gap-s) var(--gap);
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); }
/* the whole screen is in the font of the page (the cockpit font draws its decimal point wide: the entry must look like
   the value in the field). Top line: "old: 3000   delta: +250" (mode SET) or "old: 3000   new: 3250" (ADD, SUB), both
   from the left in the same quiet style, so what grows while you type grows to the right and nothing moves; under it,
   large, what is typed; last the range or the reason */
[data-pad][data-wrong] [data-screen] { border-color: var(--danger); }
[data-pad] [data-display] { grid-area: display; display: block; min-height: 1.5em; text-align: right;
    font-size: 1.4em; font-variant-numeric: tabular-nums; color: var(--strong); }
[data-pad] [data-old] { grid-area: old; color: var(--muted); font-variant-numeric: tabular-nums; }
[data-pad] [data-side] { grid-area: side; text-align: left; color: var(--muted);
    font-variant-numeric: tabular-nums; }
[data-pad] [data-hint] { grid-area: hint; text-align: right; color: var(--muted); }
[data-pad][data-wrong] [data-hint] { color: var(--danger); }
/* the modes sit over 7 8 9, as wide as the digits (the same columns), and nothing over CLEAR */
[data-pad] [data-modes] { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr) 1.45fr;
    gap: var(--gap-s); padding: 0; }
/* the modes are in the info colour (blue, "this is about the information, not a digit"), the one that is on has the
   selection look of the framework: select tint and a hi ring */
[data-pad] [data-modes] button { color: var(--link); border-color: var(--link); }
[data-pad] button, [data-steps-group] button { width: 100%; margin: 0; padding: 0; color: var(--text);
    background: var(--bg); border: 1px solid var(--border); }
[data-pad] button { min-height: calc(var(--ctl) * 1.3); font-size: 1.25em; }
[data-pad] [data-key=enter] { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
/* the mode that is on: the selection look of the framework (select tint, hi line), like a pressed chip */
[data-pad] [data-modes] button[aria-pressed=true] { color: var(--text); background: var(--select);
    border-color: var(--hi); box-shadow: inset 0 0 0 2px var(--hi); }
/* the action keys are words in capitals, as on the keys of a cockpit unit: short, easy to tell from the digits at a
   glance, and the size of the label font. The room left and right of the word is kept (a word touching the border of
   a key is hard to read and looks like a mistake). */
[data-pad] :is([data-key=back], [data-key=clear], [data-key=enter], [data-key=cancel], [data-key=set], [data-key=add],
    [data-key=sub]) {
    padding: 0 var(--gap-s); font-size: var(--fs-small); letter-spacing: 0.06em; text-transform: uppercase; }
[data-pad] button[data-pressed], [data-pad] button:active, [data-steps-group] button[data-pressed],
[data-steps-group] button:active { background: var(--select); color: var(--text); border-color: var(--hi);
    box-shadow: inset 0 0 0 2px var(--hi); }
[data-pad] button:disabled { opacity: 0.4; box-shadow: none; }

/* step buttons under a field: [-1000 -100] [+100 +1000], the coarse step outside, a gap between minus and plus */
[data-steps-group] { display: flex; gap: var(--gap-s); margin-top: var(--gap-s); }
[data-steps-group] button { flex: 1 1 0; min-width: 0; min-height: var(--ctl); padding: 0 var(--gap-s); }
[data-steps-group] button[data-step^="-"] + button[data-step^="+"] { margin-left: var(--gap); }
[data-steps-group] button:disabled { opacity: 0.4; box-shadow: none; }

/* gallery: the "Show HTML" button at the right end of a heading, and the markup it shows (js/source.js) */
:is(h2, h3) > button[data-source] { float: right; min-height: 0; padding: 0.05rem 0.7rem; letter-spacing: normal;
    text-transform: none; }
pre[data-source-code] { clear: both; max-height: 26rem; overflow: auto; }
