/* hkf-states.css — the twelve state expressions, once.
 *
 * Added 01/11/2026 (audit 108, plan 107 Phase 0.1). docs/brand.md §State grammar 2.0 is the law; this
 * file is its only implementation. Loaded by every page AFTER hkf-system.css and BEFORE the page's own
 * <style>, so a page delta still wins by source order (the same cascade rule hkf-system.css states).
 *
 * Why this file exists, measured: the one loading affordance was copy-pasted into 11 pages, fired on 4,
 * and guarded by 0 tests; [aria-busy], [aria-invalid], [aria-expanded] and [aria-current] styling
 * measured ZERO across 18 pages; and every page's prefers-reduced-motion block said animation:none, which
 * froze the .is-loading spinner into a static ring and deleted the only progress cue on the button.
 *
 * Rules this file obeys (docs/brand.md):
 *   - 2px radius, hairlines, borders over shadows, no glow, no decorative gradient.
 *   - crimson is state-only and never text on the dark page (3.93:1); --bronze-text is the readable
 *     crimson for words and is used here for every crimson message.
 *   - gold is the single UI accent; it is the focus ring and the "fact, not fault" rule (expired).
 *   - one duration (--duration), one curve (--ease). The only other timing is the 700ms busy pulse,
 *     compositor-only (opacity), sanctioned here by name because a busy control must look alive.
 *   - prefers-reduced-motion SUBSTITUTES, never removes: every state keeps its shape and its words and
 *     loses only the motion.
 *
 * Tests that hold it: tests/state-matrix.test.js (the twelve states exist here, once, and every page
 * links this file), scripts/state-lint.mjs (no page re-implements a state expression).
 */

/* ---------------------------------------------------------------- loading
 * A control that has been clicked and has not answered yet.
 *   .is-loading  — the control goes quiet and shows a progress ring (icon buttons) or a pulse (text).
 *   .hkf-skel    — a block keeps its shape while the content is dry; a spinner over empty space reads
 *                  as "slow", a skeleton reads as "starting".
 * aria-busy="true" must accompany it (hkf-busy.js does that from one place). */
.is-loading{position:relative;color:transparent!important;pointer-events:none}
.is-loading>*{visibility:hidden}
.is-loading::after{content:'';position:absolute;left:50%;top:50%;width:16px;height:16px;margin:-8px 0 0 -8px;border:2px solid var(--line);border-top-color:var(--ink);border-radius:50%;animation:hkfSpin .7s linear infinite}
@keyframes hkfSpin{to{transform:rotate(360deg)}}

.hkf-skel{position:relative;overflow:hidden;background:var(--paper-2);border-radius:2px}
.hkf-skel::after{content:'';position:absolute;inset:0;background:linear-gradient(100deg,transparent 30%,var(--hkf-s3,var(--paper-2)) 50%,transparent 70%);background-size:200% 100%;animation:hkfSkel 1.2s linear infinite}
@keyframes hkfSkel{from{background-position:100% 0}to{background-position:-100% 0}}

/* ------------------------------------------------------------------- busy
 * The control is committed (a request is out). Words change, pointer is gone, the surface stays put.
 * The page sets the words; this file only guarantees the shape stays and the change is visible. */
.is-busy{pointer-events:none;position:relative}
.is-busy::after{content:'';position:absolute;inset:-1px;border:1px solid var(--gold-border);border-radius:2px;opacity:.55;animation:hkfBusy 700ms var(--ease) infinite alternate}
@keyframes hkfBusy{from{opacity:.18}to{opacity:.62}}

/* ------------------------------------------------------------------ error
 * Field-level: the message under the field, tied by aria-describedby, and the field's border moves
 * one step to --danger. Screen-level: the same message inside a ruled block whose LEFT RULE is crimson
 * and whose words are --bronze-text. Crimson at solid 3.93:1 is a rule and a fill, never body text. */
.field-err{font-size:12px;color:var(--bronze-text);margin-top:6px}
.field-err:empty{display:none}
.field-err::before{content:'';display:inline-block;width:2px;height:11px;background:var(--danger);margin-right:7px;vertical-align:-1px}
[aria-invalid="true"].field, [aria-invalid="true"].field input, [aria-invalid="true"].field select,
[aria-invalid="true"].field textarea, .field.is-invalid input, .field.is-invalid select, .field.is-invalid textarea{border-color:var(--danger)}
.err-block{padding:10px 12px;border:1px solid var(--line-2);border-left:2px solid var(--danger);background:var(--paper);border-radius:2px;font-size:13px;line-height:1.55;color:var(--ink)}
.err-block .err-head{display:block;color:var(--bronze-text);font-weight:600;margin-bottom:2px}
.err-block .small,.err-block .muted{color:var(--muted)}

/* ------------------------------------------------------------------ retry
 * The failed control stays exactly where it is and becomes the retry: same payload, speaking word,
 * one tap. Never a new dialog, never a reload, never a toast that hides the control it belongs to. */
.is-retry{cursor:pointer}
.is-retry::before{content:'';display:inline-block;width:11px;height:11px;margin-right:7px;vertical-align:-1px;border:1.5px solid currentColor;border-radius:50%;border-right-color:transparent;transform:rotate(-35deg)}
.is-retry:focus-visible{outline:2px solid var(--gold);outline-offset:3px}

/* ---------------------------------------------------------------- expired
 * A fact, not a fault: gold rule, muted words, and the destination written into the sentence.
 * Yellow is used because the thing did not fail, it finished. */
.is-expired{padding:10px 12px;border:1px solid var(--line-2);border-left:2px solid var(--gold);background:var(--paper);border-radius:2px;font-size:13px;line-height:1.55;color:var(--ink-2)}
.is-expired strong{color:var(--ink)}
.is-expired .when{color:var(--gold);font-variant-numeric:tabular-nums}

/* ---------------------------------------------------------------- offline
 * One line, in the flow, role="status". It says what is kept and what waits. No modal, no toast,
 * no full-page blocker: the studio's phone number must stay reachable. */
.offline-line{display:flex;gap:8px;align-items:flex-start;padding:9px 12px;border:1px solid var(--line-2);border-radius:2px;background:var(--paper);font-size:13px;line-height:1.5;color:var(--ink-2)}
.offline-line::before{content:'';flex:0 0 auto;width:7px;height:7px;border-radius:50%;background:var(--danger);margin-top:6px}
.offline-line strong{color:var(--ink)}

/* ------------------------------------------------------------ countdown
 * The hold is the one number a guest acts on, so it is the one number that carries states.
 *   .is-live          a live hold, tabular figures so the digits do not shuffle as they tick
 *   .is-expired-mark  the hold has lapsed: gold, a fact, not a fault (same colour rule as .is-expired)
 *   .is-offline       the device is offline: the local clock is not the server's
 * The mark never brightens as it counts down (no urgency theatre): it changes colour exactly once,
 * at zero. */
.exp-left{font-variant-numeric:tabular-nums;transition:color var(--duration) var(--ease)}
.exp-left.is-live{color:var(--ink-2)}
.exp-left.is-expired-mark{color:var(--gold)}
.exp-left.is-offline{color:var(--muted)}
@media (prefers-reduced-motion:reduce){.exp-left{transition:none}}

/* --------------------------------------------------------------- done
 * The acknowledgement of a commit that finished in place (a copy, a save) before the state moves on.
 * Gold border, surface one step up, and the control's own words change: "Copied" beats a toast. */
.is-done{border-color:var(--gold-border)!important;background:var(--paper-2)}
@media (prefers-reduced-motion:reduce){.is-done{transition:none}}

/* ------------------------------------------------------ forced colours
 * Measured 03/11/2026 with forcedColors active: colour is dictated by the OS, so every state that
 * was carried by hue alone became indistinguishable. Three collisions, ten of twelve classes:
 *   pill + pill-gold + badge-red      (awaiting transfer looked like normal, red like both)
 *   is-expired + offline-line
 *   field-err + empty-state + is-loading + is-retry + is-offline   (an error looked empty)
 * So each state gets a second channel that the OS does not own: border weight, border style,
 * decoration, weight or opacity. Colour still carries the state when the OS allows it.
 * tests/forced-colors.test.js runs the same probe and fails if any two states collide again. */
@media (forced-colors: active) {
  .field-err, .err-block { border: 2px solid; border-left-width: 6px; font-weight: 700; }
  .badge-red { border: 1px solid; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
  .pill-gold { border-style: double; border-width: 3px; }
  .is-expired { text-decoration: line-through; }
  .offline-line { border-style: dashed; }
  .is-retry { text-decoration: underline; }
  .is-loading { opacity: .55; font-style: italic; }
  .is-offline { font-style: italic; }
  .is-busy { opacity: .62; }
  .is-done { border-style: double; }
  /* the empty state's signal is the ABSENCE of a border: said out loud so a later rule cannot
     quietly give it one and make it read as an error */
  .empty-state { border: 0; }
}

/* ------------------------------------------------- reduced transparency
 * The OS can ask for translucent surfaces to become opaque: macOS "Reduce transparency",
 * and the same preference on every browser that supports the query. Measured 03/11/2026: this
 * tree uses backdrop-filter 33 times across 15 pages and honoured the query nowhere, which means
 * a user who set the preference still got blurred chrome over their content.
 * A broad selector is deliberate here: the preference is about the whole surface, it only applies
 * when the user asked for it, and it removes an effect rather than adding one. */
@media (prefers-reduced-transparency: reduce) {
  *, *::before, *::after { backdrop-filter: none !important; }
}

/* ------------------------------------------------------------- pressed
 * Press feedback for the two controls whose press was previously unexpressed (03/11/2026, registry
 * Phase 1): the step-1 free-window chips (slot chooser) and the ref-code copy button. One pixel of
 * travel, transform only — never a layout property — and no transition: a press is a direct
 * manipulation, so it answers instantly. */
.time-chip:active{transform:translateY(1px)}
[data-bkid]:active{transform:translateY(1px)}
#claimSend:active{transform:translateY(1px)}
#invLines .btn:active{transform:translateY(1px)}
#proofFile:active{transform:translateY(1px)}
/* the conflict sheet's choices and its commit button (03/11/2026) */
[data-cfpick]:active,
.cf-opt:active,
#conflictApply:active{transform:translateY(1px)}

/* --------------------------------------------------------------- busy
 * The one async expression (03/11/2026, registry Phase 1). A region that is reading or writing says
 * so to assistive tech (aria-busy) and dims while it does. aria-busy covers both lifecycle states the
 * catalogue names: loading is the first read filling an empty region, busy is a later read landing on
 * one that already has content. Dim quickly, no transition: a state, not theatre. */
/* 07/11/2026: .62 composited #a3a3a3 down to #6d6d6d on the dark shell, which is 3.56:1 and fails
   AA for body text. .85 keeps the dimming legible (measured: #8d8d8d, 4.9:1) so a loading panel is
   readable while it loads and a stale busy flag can never make copy unreadable. */
[aria-busy="true"], .is-busy{opacity:.85}

/* ------------------------------------------------------------ empty, honest
 * Empty is a state, and it must be true. It is never "no bookings" when the read failed: that sentence
 * belongs to .err-block. One class site-wide. The OS keeps its denser variant as .empty-state--desk. */
.empty-state{text-align:center;padding:30px 18px;color:var(--muted);font-size:14px;line-height:1.6}
.empty-state::before{content:"\25C6";display:block;color:var(--gold);font-size:12px;letter-spacing:.3em;text-indent:.3em;margin-bottom:10px}
.empty-state::after{content:"";display:block;width:56px;height:1px;background:var(--line-2);margin:14px auto 0}
.empty-state strong{display:block;color:var(--ink);font-weight:600;margin-bottom:4px}
.empty-state .btn{min-height:44px} /* 44px target inside an empty state, once, for every page */

/* ------------------------------------------------------- reduced motion
 * Substitute, never remove. Every state above keeps its shape and its words; it loses only motion.
 * The frozen-ring failure audit 108 §3C found was exactly this rule set to animation:none. */
@media (prefers-reduced-motion:reduce){
  .is-loading::after{animation:none;border-top-color:var(--ink);border-right-color:var(--ink)}
  .hkf-skel::after{animation:none;background:none}
  .is-busy::after{animation:none;opacity:.4}
  .is-retry::before{transform:none;border-right-color:currentColor;border-style:dotted}
}