/* UBUI's components: what the face of an app is made of (docs/adr/0006). A component names no colour, typeface or
   type size of its own: its colours are the tokens of the app it stands in, its sizes are on the closed scale. Every
   class here is shown by an exhibit in the gallery (gallery.html); the check fails on one that is not. */

/* ---------- 1 Fields: the user types the value on a keyboard ----------
   The plain field is Rheaface's (app.css, .form): the label above, a box with a thin rule on the raised paper.
   What Rheaface does not have, and is drawn here for the owner to judge: the mark of a required field, the field
   with a fault, the field that is read, the buttons of a number, the currency of an amount, the small labels of
   several values. */
.u-field { position: relative; display: grid; gap: 4px; min-width: 0; align-content: start; }
.u-hid { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }   /* a label not shown: read out, not seen */
.u-label { font-size: 12.5px; line-height: 1.3; color: var(--ink-2); }
.u-req { color: var(--due); margin-left: 3px; }

/* the box: one frame around whatever the field holds, so a number with its buttons is lit as one thing */
.u-box { display: flex; align-items: center; min-width: 0; min-height: 42px; border: 1px solid var(--rule-2); border-radius: 8px; background: var(--sheet); color: var(--ink); }
.u-box:hover { border-color: var(--ink-3); }
.u-box:focus-within, .u-field[data-show="use"] .u-box { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: -2px; }
.u-field.fault .u-box { border-color: var(--due); }
.u-in { flex: 1; min-width: 0; width: 100%; border: 0; outline: 0; border-radius: 8px; background: none; color: inherit; font: inherit; line-height: 1.5; padding: 9px 11px; }
.u-lines { display: block; resize: none; min-height: 86px; overflow: hidden; }

/* a number wears the figures' face, typed and read alike */
.u-fig { font-family: var(--f-fig); font-stretch: var(--fig-stretch); font-size: calc(var(--fig-scale) * 1em); font-variant-numeric: tabular-nums lining-nums; }
.u-step { flex: none; align-self: stretch; display: grid; place-items: center; width: 32px; padding: 0; border: 0; border-left: 1px solid var(--rule); background: none; color: var(--ink-2); cursor: pointer; }
.u-step:last-child { border-radius: 0 7px 7px 0; }
.u-step:hover { background: var(--sunk); color: var(--ink); }
.u-step:disabled { opacity: .45; cursor: default; background: none; color: var(--ink-2); }
.u-step svg { width: 14px; height: 14px; }

/* what stands after the value inside the box: the currency of an amount, fixed or chosen */
.u-unit { position: relative; flex: none; align-self: stretch; display: flex; align-items: center; border-left: 1px solid var(--rule); padding: 0 11px; color: var(--ink-2); font-size: 13px; }
.u-unit select { appearance: none; align-self: stretch; margin: 0 -11px; padding: 0 26px 0 11px; border: 0; outline: 0; border-radius: 0 7px 7px 0; background: none; color: inherit; font: inherit; cursor: pointer; }
.u-unit select:hover { color: var(--ink); }
.u-unit option { background: var(--doc); color: var(--ink); }
.u-unit svg { position: absolute; right: 9px; width: 10px; height: 10px; pointer-events: none; }

/* several values: each a small label that can be removed, and a place to type the next */
.u-many { flex-wrap: wrap; gap: 4px; padding: 6px; }
.u-many .u-in { flex: 1 1 40px; width: auto; padding: 3px 5px; border-radius: 4px; }
.u-token { display: inline-flex; align-items: center; gap: 2px; max-width: 100%; padding: 3px 4px 3px 9px; border: 1px solid var(--rule-2); border-radius: 999px; background: var(--sunk); color: var(--ink); font-size: 12.5px; line-height: 1.3; }
.u-token span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-token button { flex: none; display: grid; place-items: center; width: 18px; height: 18px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--ink-2); cursor: pointer; }
.u-token button:hover { background: var(--rule-2); color: var(--ink); }
.u-token svg { width: 10px; height: 10px; }
.u-token.still { padding: 3px 9px; }

/* read, not typed: a computed variable, or a person with no right to change it. The value stands where the box
   would, so read and typed fields line up in one row */
.u-value { min-height: 42px; padding: 10px 0; line-height: 1.5; color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.u-value a { color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; }
.u-values { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }

/* under the field: what the variable is for, or the engine's refusal in its own words */
.u-hint { font-size: 12px; line-height: 1.35; color: var(--ink-2); }
.u-fault { font-size: 12px; line-height: 1.35; color: var(--due); }

/* ---------- 2 Selectors: the options exist before the person acts ----------
   None of these is in Rheaface; all are drawn here for the owner to judge. A box that is ticked or a button that is
   chosen wears the accent's fill, with the accent's own line around it so that it is seen on every paper. */

/* a dropdown: the field's box, with an arrow; the list that opens is the browser's own */
.u-drop { position: relative; }
.u-select { appearance: none; padding-right: 32px; text-overflow: ellipsis; cursor: pointer; }
.u-select option { background: var(--doc); color: var(--ink); }
.u-drop svg { position: absolute; right: 11px; width: 12px; height: 12px; color: var(--ink-2); pointer-events: none; }

/* a control with its words beside it: a checkbox, a switch, one radio button */
.u-pick { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; cursor: pointer; }
.u-pick-t { line-height: 1.3; color: var(--ink); }
.u-check, .u-radio, .u-switch { appearance: none; flex: none; margin: 0; border: 1px solid var(--rule-2); background: var(--sheet); cursor: pointer; }
.u-check:hover, .u-radio:hover, .u-switch:hover { border-color: var(--ink-3); }
.u-check { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 5px; }
.u-check:checked { border-color: var(--accent); background: var(--accent-fill); }
.u-check:checked::after { content: ""; width: 9px; height: 5px; border: solid var(--on-accent); border-width: 0 0 2px 2px; transform: translateY(-1px) rotate(-45deg); }
.u-radio { width: 18px; height: 18px; border-radius: 50%; }
.u-radio:checked { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 3px var(--sheet); }
.u-switch { position: relative; width: 34px; height: 20px; border-radius: 999px; background: var(--sunk); }
.u-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--ink-2); transition: transform .15s; }
.u-switch:checked { border-color: var(--accent); background: var(--accent-fill); }
.u-switch:checked::after { background: var(--on-accent); transform: translateX(14px); }
/* a yes or no has no label above it: it stands where its neighbours' boxes stand */
.u-inline { padding-top: 20px; }

/* radio buttons: all the options in sight, side by side, wrapping */
.u-opts { display: flex; flex-wrap: wrap; align-content: center; gap: 0 18px; min-height: 42px; }
.u-opts .u-pick { min-height: 30px; }

/* segmented buttons: the options as one row of joined buttons */
.u-seg { display: inline-flex; flex-wrap: wrap; gap: 2px; max-width: 100%; min-height: 42px; padding: 3px; border: 1px solid var(--rule-2); border-radius: 8px; background: var(--sheet); justify-self: start; }
.u-seg-o { position: relative; display: flex; cursor: pointer; }
.u-seg-i { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.u-seg-o span { display: flex; align-items: center; min-height: 34px; padding: 0 12px; border-radius: 6px; color: var(--ink-2); font-size: 14px; }
.u-seg-o span:hover { background: var(--sunk); color: var(--ink); }
.u-seg-i:checked + span { background: var(--accent-fill); color: var(--on-accent); }

/* in use, and with a fault */
.u-check:focus-visible, .u-radio:focus-visible, .u-switch:focus-visible, .u-seg-i:focus-visible + span,
.u-field[data-show="use"] .u-pick:first-child > input, .u-field[data-show="use"] .u-seg-o:first-child > span { outline: 2px solid var(--accent); outline-offset: 2px; }
.u-field.fault .u-check, .u-field.fault .u-radio, .u-field.fault .u-switch, .u-field.fault .u-seg { border-color: var(--due); }

/* ---------- 3 Pickers: the value is picked on a surface of its own ----------
   A date, or a date with the time of day: the field's box. The field inside and the calendar that opens are the
   browser's own, written in the person's language; on a phone it is the phone's own picker. */
.u-date { min-height: 40px; }
.u-date.blank { color: var(--ink-2); }
.u-date::-webkit-calendar-picker-indicator { opacity: .6; cursor: pointer; }
.u-date::-webkit-calendar-picker-indicator:hover { opacity: 1; }

/* ---------- 10 Buttons: pressing it runs an action ----------
   The button is Rheaface's (app.css, .btn): a pill in the accent's fill, and its plain form with a thin rule. The
   two that say yes and no in colour are drawn here for the owner to judge. A button is as high as a field's box
   and stands where its neighbours' boxes stand. */
.u-act { padding-top: 20px; }
.u-btn { width: 100%; min-height: 42px; padding: 0 18px; border: 1px solid var(--accent-fill); border-radius: 999px; background: var(--accent-fill); color: var(--on-accent); font: inherit; font-size: 14px; font-weight: 500; white-space: nowrap; cursor: pointer; }
.u-btn.plain { border-color: var(--rule-2); background: none; color: var(--ink); }
.u-btn.plain:hover { border-color: var(--ink); }
.u-btn.positive { border-color: var(--ok); background: none; color: var(--ok); }
.u-btn.negative { border-color: var(--due); background: none; color: var(--due); }
.u-btn:disabled { opacity: .45; cursor: default; }
.u-btn:focus-visible, .u-field[data-show="use"] .u-btn { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- 25 Layout containers: it holds other components and has no data of its own ----------
   The flow, which a page and a section share: what stands in it fills a line and wraps to the next. A component's
   width is its twelfths of the flow, the gaps taken off first, so two halves always share a line; its least width
   makes the phone, where a line is shared out between the components that stand in it. A flow measures itself, so
   a narrow section wraps as a narrow page does. */
.u-flow { --u-gap: 14px; position: relative; container-type: inline-size; display: flex; flex-wrap: wrap; align-content: flex-start; gap: var(--u-gap); min-width: 0; }
.u-flow[hidden] { display: none; }
.u-cell { flex: 0 0 calc(var(--w) / 12 * (100% + var(--u-gap)) - var(--u-gap)); min-width: min(160px, 100%); }
.u-cell[data-fit] { flex: 0 0 auto; min-width: 0; }   /* as wide as its words: a button */
@container (max-width: 600px) { .u-cell:not([data-fit]) { flex-grow: 1; } }

/* A section: a title, and a flow of its own. The framed one is Rheaface's card (app.css, .person). Its title folds
   it when the face says it may fold. */
.u-sec { display: grid; gap: 10px; min-width: 0; }
.u-sec.framed { padding: 12px 14px 14px; border: 1px solid var(--rule); border-radius: 12px; background: var(--sheet); }
.u-sec-h { display: flex; align-items: center; gap: 6px; justify-self: start; padding: 0; border: 0; background: none; color: var(--ink); font: inherit; text-align: left; }
button.u-sec-h { cursor: pointer; }
.u-sec-h svg { flex: none; width: 12px; height: 12px; color: var(--ink-2); transition: transform .15s; }
.u-sec-h[aria-expanded="false"] svg { transform: rotate(-90deg); }
.u-sec-t { font-size: 14px; font-weight: 600; line-height: 1.3; }

/* Tabs that hold components: a strip of titles, the one in front lit by a line under it, and under the strip the
   flow of that tab. Drawn here for the owner to judge. */
.u-tabs { display: grid; gap: 12px; min-width: 0; }
.u-tabs-s { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--rule); }
.u-tab { margin-bottom: -1px; padding: 8px 12px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--ink-2); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; }
.u-tab:hover { color: var(--ink); }
.u-tab[aria-selected="true"] { border-bottom-color: var(--accent); color: var(--ink); }

/* ---------- 17 Text and headings: fixed words with no frame and no action of their own ----------
   A heading in three sizes, which are the sizes of the frame's own headings; and text, plain or quiet. */
.u-head { margin: 0; color: var(--ink); font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
.u-head.l { font-size: 24px; }
.u-head.m { font-size: 20px; }
.u-head.s { font-size: 17px; }
.u-text { margin: 0; color: var(--ink); line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.u-text.quiet { color: var(--ink-2); font-size: 13px; }

/* The picker of another document (3 Pickers): the field's box, typed in to find. The documents found open in a list
   under it; the list is Rheaface's menu (app.css, .g-pop and .g-menu). */
.u-look > svg { flex: none; width: 14px; height: 14px; margin-right: 11px; color: var(--ink-2); pointer-events: none; }
.u-clear { flex: none; display: grid; place-items: center; width: 22px; height: 22px; margin-right: 4px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--ink-2); cursor: pointer; }
.u-clear:hover { background: var(--sunk); color: var(--ink); }
.u-clear svg { width: 11px; height: 11px; }
.u-clear[hidden] { display: none; }
.u-list { position: fixed; inset: auto; max-height: 300px; margin: 0; padding: 4px; overflow: auto; border: 1px solid var(--rule-2); border-radius: 10px; background: var(--doc); color: var(--ink); box-shadow: var(--doc-shadow); }
.u-list.in { position: static; }   /* drawn on the page itself, where the top layer is not to be had */
.u-list.in[hidden] { display: none; }
.u-opt { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 7px 9px; border-radius: 7px; font-size: 14px; line-height: 1.3; cursor: pointer; }
.u-opt:hover, .u-opt[aria-selected="true"] { background: var(--sunk); }
.u-opt-n { flex: none; color: var(--ink-2); font-size: 12px; }
.u-opt.none { color: var(--ink-2); font-size: 13px; cursor: default; }
.u-opt.none:hover { background: none; }

/* A divider (25 Layout containers): a line across the place it is given. */
.u-rule { width: 100%; height: 0; margin: 8px 0; border: 0; border-top: 1px solid var(--rule-2); }

/* ---------- 12 Grids: rows, the lines of a document ----------
   A small table: a column for each thing the class says a line has, a line added, a line taken off. A cell is the
   field of its type with no frame of its own. Where there is no room for the columns, each line is a card: its
   cells under each other, each under its name. Drawn here for the owner to judge. */
.u-rows { container-type: inline-size; min-width: 0; overflow: hidden; border: 1px solid var(--rule-2); border-radius: 8px; background: var(--sheet); }
.u-field.fault > .u-rows { border-color: var(--due); }
.u-rows-h, .u-rows-r { display: grid; grid-template-columns: var(--u-cols); align-items: center; min-width: 0; }
.u-rows-h { border-bottom: 1px solid var(--rule); background: var(--sunk); }
.u-rows-h .u-rows-c { padding: 7px 11px; color: var(--ink-2); font-size: 12px; }
.u-rows-r + .u-rows-r { border-top: 1px solid var(--rule); }
a.u-rows-r { color: inherit; text-decoration: none; }   /* a line that leads to its document is pressed as a whole */
a.u-rows-r:hover { background: var(--sunk); }
.u-rows-c { min-width: 0; }
.u-field .u-rows .u-box { min-height: 38px; border-color: transparent; border-radius: 0; background: none; }
.u-field .u-rows .u-box:hover { border-color: var(--rule-2); }
.u-field .u-rows .u-box:focus-within, .u-field .u-rows .u-field[data-show="use"] .u-box { border-color: var(--accent); }
.u-rows .u-inline { padding: 0 11px; }
.u-rows .u-value { min-height: 38px; padding: 8px 11px; }
.u-rows-x { display: grid; place-items: center; width: 24px; height: 24px; margin: 0 auto; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--ink-2); cursor: pointer; }
.u-rows-x:hover { background: var(--sunk); color: var(--due); }
.u-rows-x svg { width: 11px; height: 11px; }
.u-rows-none { padding: 11px; color: var(--ink-2); font-size: 13px; }
.u-rows-add { justify-self: start; padding: 2px 0; border: 0; background: none; color: var(--accent-text); font: inherit; font-size: 13px; cursor: pointer; }
.u-rows-add:hover { text-decoration: underline; text-underline-offset: 3px; }
@container (max-width: 520px) {
  .u-rows-h { display: none; }
  .u-rows-r { grid-template-columns: minmax(0, 1fr); padding: 6px 0; }
  .u-rows .u-hid { position: static; width: auto; height: auto; padding: 4px 11px 0; overflow: visible; clip-path: none; white-space: normal; }
}

/* ---------- 20 Status, tags and badges: a small mark that tells a state ----------
   The mark is Rheaface's chip (app.css, .chip): a pill with a thin line in its own colour, and the tones Rheaface
   gives a chip. It stands where its neighbours' boxes stand. */
.u-mark { display: inline-flex; align-items: center; justify-self: start; min-height: 26px; margin: 8px 0; padding: 0 11px; border: 1px solid currentColor; border-radius: 999px; color: var(--ink-2); font-size: 12.5px; line-height: 1; white-space: nowrap; }
.u-mark.ok { color: var(--ok); }
.u-mark.warn { color: var(--warn); }
.u-mark.due { color: var(--due); }
.u-mark.accent { color: var(--accent-text); }

/* 26 Tiles and cards: a tile is the frame's own tile (desk.css), here a component: a title, a line under it, a
   figure. Tiles fill a line and wrap, each at least 220 px wide. A tile that leads somewhere is a link */
.u-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 10px; }
.u-tile { display: grid; gap: 4px; align-content: start; min-width: 0; padding: 12px 14px; border: 1px solid var(--rule); border-radius: 12px; background: var(--sheet); color: var(--ink); text-align: left; text-decoration: none; }
a.u-tile:hover { border-color: var(--rule-2); }
.u-tile b { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.u-tile span { color: var(--ink-3); font-size: 12.5px; overflow-wrap: anywhere; }
.u-tile .u-tile-fig { color: var(--ink); }
.u-none { margin: 0; color: var(--ink-2); font-size: 13px; }

/* 11 Lists: documents under a title, a line for each: its title, the mark of its state, a note at the end */
.u-docs { display: grid; gap: 8px; min-width: 0; }
.u-docs-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 34px; }
.u-docs-t { margin: 0; color: var(--ink); font-size: 15px; font-weight: 600; line-height: 1.3; }
.u-docs-add { display: inline-flex; align-items: center; width: auto; min-height: 34px; padding: 0 14px; text-decoration: none; }
.u-docs-b { display: grid; overflow: hidden; border: 1px solid var(--rule); border-radius: 12px; background: var(--sheet); }
.u-doc { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 2px 14px; border-top: 1px solid var(--rule); color: var(--ink); font-size: 14px; text-decoration: none; }
.u-doc:first-child { border-top: 0; }
a.u-doc:hover { background: var(--sunk); }
.u-doc-t { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-doc .u-act { flex: none; padding-top: 0; }   /* the mark of its state stands on the line, with no label over it */
.u-doc-n { flex: none; color: var(--ink-3); font-size: 12.5px; }
