/*
 * ui.css - THE ADMIN'S DESIGN STANDARD (agency, 19 Sep 2026)
 * ==========================================================
 * One look for each thing a person touches, on every page: fields, buttons,
 * checkboxes, the segmented switch, badges and rows of buttons. Written
 * here once; the page sheets (store.css, sidebar.css, the rest of app.css)
 * say where things go - width, margins, a grid - and never again what they
 * look like. The why, and the rules for a new page: store/docs/dukes-design-standard.html.
 *
 * It was needed: a survey of the 23 admin pages (19 Sep) found fields at ten
 * heights from 21 to 49px, some with the browser's own grey box (an input
 * with no type= matched none of the old rules), and buttons at thirteen.
 *
 * LOADED ON EVERY PAGE (base.html), after app.css and before the page
 * sheets. The element rules below are as light as a selector gets, so a
 * component that has to differ - the bulk editor's cells, the restock
 * stepper, the top bar's search - still can, with one class.
 *
 * SIZES ARE rem, so Text size (Edit profile) moves them all. One height for
 * fields and buttons, 2.5rem (40px at Standard), so a field and its button
 * line up in a row; 2rem for a small button in a list's row.
 */

/* HIDDEN MEANS HIDDEN. The browser's own [hidden] rule loses to any page
   rule that sets display, so a hidden button or row showed anyway; the page
   sheets had a dozen one-off fixes for it. One rule, for every element. */
[hidden] { display: none !important; }

:root {
  --ctl-h: 2.5rem;                              /* a field's and a button's height */
  /* SQUARE, ALWAYS (the client, 12 Sep 2026). square.css enforces it whatever
     this says; the token is kept at 0 rather than deleted because a dozen
     rules name it, and a var() naming nothing renders as nothing. */
  --ctl-radius: 0;
  --field-line: var(--rule);                    /* a field's edge */
  --field-line-hover: var(--rule-deep);
}

/* ================================================================ fields == */
/* Every box you type in or choose from - text, email, number, date, search,
   a select, a textarea - whatever its type, or none. */
input:where(:not([type="checkbox"], [type="radio"], [type="range"], [type="file"], [type="hidden"],
  [type="color"], [type="submit"], [type="button"], [type="reset"], [type="image"])),
select,
textarea {
  box-sizing: border-box;
  width: 100%;
  min-height: var(--ctl-h);
  margin: 0;
  padding: 0.5rem 0.75rem;
  font: 400 1rem/1.375rem var(--body);
  color: var(--ink);
  background-color: var(--ground);
  border: 1px solid var(--field-line);
  border-radius: var(--ctl-radius);
}
input[type="date"], input[type="time"], input[type="datetime-local"], input[type="month"] { height: var(--ctl-h); }
textarea { min-height: 5.5rem; padding-top: 0.55rem; padding-bottom: 0.55rem; line-height: 1.5; resize: vertical; }

/* One arrow for every select, not each browser's own. */
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2.2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%23111111' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  background-size: 0.7rem;
  cursor: pointer;
}
select[multiple], select[size]:not([size="1"]) { padding-right: 0.75rem; background-image: none; }

input::placeholder, textarea::placeholder { color: var(--steel); opacity: 1; }

input:where(:not([type="checkbox"], [type="radio"], [type="range"], [type="file"])):hover,
select:hover, textarea:hover { border-color: var(--field-line-hover); }

/* Focus is ink, everywhere (the newsletter editor's was gold). */
input:where(:not([type="checkbox"], [type="radio"], [type="range"], [type="file"])):focus,
select:focus, textarea:focus { outline: 2px solid var(--ink); outline-offset: 1px; border-color: var(--ink); }

input:disabled, select:disabled, textarea:disabled,
input[readonly], textarea[readonly] { color: var(--ink-2); background-color: var(--panel); border-color: var(--field-line); }
input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; }
[aria-invalid="true"] { border-color: var(--accent) !important; }

/* SMALL FIELD: a select in a list's row, beside that row's small buttons
   (32px). On a touch screen its text still keeps 16px (app.css). */
.field-sm { min-height: 2rem; padding: 0.3125rem 0.6rem; font-size: 0.875rem; line-height: 1.25rem; }
select.field-sm { padding-right: 1.9rem; background-position: right 0.6rem center; }

/* A TICK AND ITS WORDS (.st-check): as wide as the words, a finger's height,
   and the whole of it clickable. */
.st-check {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  width: auto;
  min-height: 2rem;                             /* a finger-sized row, not a 13px box */
  margin: 0.35rem 0;
  font-size: 0.95rem;
  font-weight: 400;
  letter-spacing: 0;
  cursor: pointer;
}

/* MANY TICKS, SIDE BY SIDE (agency, 19 Sep 2026: "can these checkboxes be
   encapsulated in a container and then be inline instead of per row - might
   save scrolling"). A product's 22 categories ran 22 rows down a phone;
   inline they are six or seven lines. .checks--box puts them in a field's
   box, which scrolls if the list ever outgrows it. */
.checks { display: flex; flex-wrap: wrap; align-items: center; gap: 0 1.1rem; }
.checks .st-check { margin: 0.2rem 0; }
.checks--box {
  max-height: 15rem;
  overflow-y: auto;
  padding: 0.35rem 0.7rem;
  background: var(--ground);
  border: 1px solid var(--field-line);
  border-radius: var(--ctl-radius);
}

/* Ticks and choices: one size, the ink's color. */
:where(input[type="checkbox"], input[type="radio"]) {
  width: 1.125rem;
  height: 1.125rem;
  margin: 0;
  flex: none;
  vertical-align: -0.2em;
  accent-color: var(--ink);
  cursor: pointer;
}

/* =============================================================== buttons == */
/* PRIMARY is the default: ink, square (square.css), 40px. One per form or
   popup, for the thing it is there to do. */
button, .button, input[type="submit"], input[type="button"] {
  display: inline-block;
  box-sizing: border-box;
  width: auto;
  margin-top: 1.2rem;                           /* space above a form's own Save; rows set 0 */
  padding: 0.5625rem 1.1rem;                    /* 20px of line + 18px + the edge: 40px */
  font: 600 0.875rem/1.25rem var(--body);
  letter-spacing: 0.01em;
  color: var(--panel);
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 999px;
  text-align: center;
  text-decoration: none;
  vertical-align: middle;
  cursor: pointer;
}
button:hover, .button:hover { color: var(--panel); background: var(--ink-deep); border-color: var(--ink-deep); }

/* QUIET: the others - Cancel, Duplicate, Copy address, Open. White, with a
   field's edge; the edge goes ink on hover. */
.button-quiet { color: var(--ink); background: var(--ground); border-color: var(--field-line); }
.button-quiet:hover { color: var(--ink); background: var(--ground); border-color: var(--ink); }

/* DANGER: what cannot be taken back - delete, deactivate. */
.button-danger { color: var(--accent); background: var(--ground); border-color: var(--accent); }
.button-danger:hover { color: var(--accent); background: var(--accent-tint); border-color: var(--accent); }

/* PLAIN: a quiet word that is still a button - Remove, Clear. */
.button-plain { color: var(--ink-2); background: transparent; border-color: transparent; }
.button-plain:hover { color: var(--ink); background: transparent; border-color: transparent; text-decoration: underline; }

/* SMALL: a row's own buttons in a list, 32px. */
.button-sm { padding: 0.3125rem 0.8rem; font-size: 0.8125rem; line-height: 1.25rem; white-space: nowrap; }

/* An icon beside the words (the printer on Packing slip). */
.button-icon { display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; }
.button-icon svg { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round; }

/* ================================================================== find == */
/* A SEARCH BOX WITH THE MAGNIFIER IN IT (every list's filter, 20 Sep 2026;
   the top bar has had this shape since 19 Sep). It went through a pill
   saying "Search" beside the box, then an icon-only pill; both were a
   control in the row competing for the width of a 375px phone with the box
   and, on Products, a category dropdown. Inside the box it costs nothing
   and reads as part of the thing it searches.

   THE GLASS IS THE SUBMIT BUTTON, not a decoration. A list's box is a
   filter - Enter narrows the list - and taking the button away would have
   left that with nothing visible to say so, and nothing to press with no
   JavaScript. It is on the left because that is where the top bar's is, and
   these two boxes should not be two different ideas.

       <span class="sg-wrap find">
         <button type="submit" class="find__go" aria-label="Search orders">…</button>
         <input type="search" …>
       </span>
*/
/* ONE WIDTH FOR THE GLASS AND THE ROOM MADE FOR IT, with a floor in pixels.
   The button was 2.6rem and the glyph a fixed 18px, so at the smaller text
   size the box shrank around an icon that did not and the glass came to sit
   against the left edge. The floor holds the gap at about 12px whatever the
   text size, which is where the top bar's has always been, and the input's
   padding reads the same value so the two cannot drift apart. */
.find { --find-w: max(2.6rem, 42px); position: relative; display: block; min-width: 0; }
.find input[type="search"] { padding-left: var(--find-w); }
.find__go {
  position: absolute; left: 0; top: 0; bottom: 0;
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--find-w); margin: 0; padding: 0;
  color: var(--steel); background: transparent; border: 0; border-radius: 999px;
}
.find__go:hover { color: var(--ink); background: transparent; border-color: transparent; }
.find__go svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

button:disabled, .button[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
button:disabled:hover { background: var(--ink); border-color: var(--ink); }
.button-quiet:disabled:hover, .button-danger:disabled:hover { background: var(--ground); }

/* ROWS OF BUTTONS: the ones that go together, side by side (.button-row;
   not .actions, which the People table's cells already are). */
.button-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.button-row :where(button, .button, form) { margin: 0; }

/* ON A PHONE (under 720px): a button alone is full width; a row's buttons
   share their line and fill it (Edit profile, 19 Sep: "standard for
   buttons, maybe full width if alone"). */
@media (max-width: 719px) {
  button, .button, input[type="submit"], input[type="button"] { width: 100%; }
  .button-row > * { flex: 1 1 auto; }
  .button-row > :where(button, .button) { width: auto; }
  .button-row > :where(form, label) > :where(button, .button) { width: 100%; }
}

/* The sign-in pages' card is narrow: its button is always the width of it. */
.centered .card :is(button, .button) { width: 100%; }

/* A PAGE'S OWN BUTTONS, IN THE TOP BAR (the shell's .ts-actions; 19 Sep 2026:
   "avoid the wasted space at the top on desktop"). They sat in a strip of
   their own under the bar, a row holding one button and nothing else. On a
   wide screen they now sit beside the page's title, at the small size so the
   bar keeps its height; narrower than 1200px they are a row again
   (.page-actions, sidebar.css), and on a phone that is where they belong. */
.ts-actions { display: flex; align-items: center; gap: 0.5rem; flex: none; }
.ts-actions form { display: flex; align-items: center; gap: 0.5rem; margin: 0; }
.ts-actions :where(button, .button, input[type="submit"]) {
  width: auto; margin: 0;
  padding: 0.3125rem 0.8rem;
  font-size: 0.8125rem; line-height: 1.25rem;
  white-space: nowrap;
}
.ts-actions select {
  width: auto; min-height: 2rem;
  padding: 0.3125rem 1.9rem 0.3125rem 0.6rem;
  font-size: 0.875rem; line-height: 1.25rem;
  background-position: right 0.6rem center;
}

/* ============================================================ the switch == */
/* ONE SEGMENTED SWITCH (Text size; the quick edit's status; an email
   preview's Phone / Computer): a pill holding its choices, the chosen one
   filled. Buttons with aria-pressed, or labels around a radio. */
.seg { display: inline-grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 3px; padding: 3px;
  max-width: 100%; background: var(--ground); border: 1px solid var(--field-line); border-radius: 999px; }
.seg--fill { display: grid; width: 100%; }
.seg > button, .seg > label {
  display: flex; align-items: center; justify-content: center; position: relative; box-sizing: border-box;
  width: auto; min-height: calc(var(--ctl-h) - 8px); margin: 0; padding: 0 0.9rem;
  font: 500 0.875rem/1.2 var(--body); letter-spacing: 0; color: var(--ink-2); text-align: center;
  background: transparent; border: 0; border-radius: 999px; cursor: pointer;
}
.seg > button:hover, .seg > label:hover { color: var(--ink); background: var(--panel); }
.seg > label > input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.seg > button[aria-pressed="true"], .seg > label:has(input:checked) { color: var(--ground); background: var(--ink); }
.seg > button:focus-visible, .seg > label:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ================================================================ drawer == */
/* A PANEL FROM THE RIGHT (the bulk editor's Filter and Bulk action; 19 Sep
   2026): a <dialog class="drawer"> opened by a button with data-drawer
   (ui.js). It is the browser's own modal, so Escape closes it, the page
   behind it cannot be tabbed into, and it needs no script to be safe. Head,
   a body that scrolls, and a foot that holds the buttons still. */
.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(27rem, 100vw);
  max-width: 100vw;
  height: 100%;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  color: var(--ink);
  background: var(--ground);
  border: 0;
  border-left: 1px solid var(--rule);
  box-shadow: -10px 0 30px rgba(17, 17, 17, 0.14);
  overflow: hidden;
}
.drawer[open] { display: flex; flex-direction: column; }
.drawer::backdrop { background: rgba(17, 17, 17, 0.32); }
.drawer__head {
  display: flex; align-items: center; gap: 0.75rem; flex: none;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--rule);
}
.drawer__head h2 { margin: 0; font: 400 1.15rem/1.3 var(--display); text-transform: none; letter-spacing: 0; }
/* Its own size, even on a phone, where a button is otherwise full width. */
.drawer__close { width: auto; flex: none; margin: 0 0 0 auto; padding: 0.35rem; }
.drawer__close svg { width: 1.1em; height: 1.1em; }
.drawer__body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 1rem 1.1rem 1.4rem; }
.drawer__foot {
  flex: none;
  padding: 0.8rem 1.1rem;
  border-top: 1px solid var(--rule);
  background: var(--ground);
}
.drawer__foot > * { flex: 1 1 auto; }
@media (max-width: 719px) {
  .drawer { width: 100vw; border-left: 0; }
}
@media (prefers-reduced-motion: no-preference) {
  .drawer[open] { animation: drawer-in 0.18s ease-out; }
  @keyframes drawer-in { from { transform: translateX(100%); } }
}

/* ================================================================ tables == */
/* ONE HEADING STYLE for every table's columns: small mono capitals (the
   People table's were 10.9px and the lists' 12.8px). A list is .st-list:
   a white box, a hairline between rows (store.css). */
th { font-size: 0.75rem; letter-spacing: 0.1em; color: var(--steel); }

/* ================================================================ badges == */
/* ONE BADGE (an order's Paid or To ship, a product's Active, a newsletter's
   Draft): small words in a pill. The page sheets give only the tone -
   .st-status-*, .or-pay-*, .nl-pill--ok. */
.badge, .st-status, .nl-pill, .pill {
  display: inline-block;
  padding: 0.125rem 0.55rem;
  font: 500 0.75rem/1.25rem var(--body);
  letter-spacing: 0.01em;
  text-transform: none;
  white-space: nowrap;
  color: var(--ink-2);
  background: var(--panel-2);
  border: 1px solid var(--rule);
  border-radius: 999px;
}
