/* ======================================================================
 * ts-motion.css — Overlay 187 (C187-3): how things move, and the report frame.
 *
 * Ian, 2026-10-06: "the page jerks when I press Search while scrolled down", and
 * transitions on panels, menus, hover and press; the page must not jump when results
 * arrive. The worst case he named: Registration counts, and any page with a search.
 *
 * ⚠ LINKED from `base_dashboard.html`, never built into `dashboard.css`, so a motion
 * change is one file and the Tailwind build is not re-run for it (the same reason
 * `ts-loader.css` stands alone). `core.tests_overlay128_dashboard_css` reads this
 * sheet as well as the built one when it checks every class is defined.
 *
 * ⚠ Tokens only — no colour value is written here (every colour is a `--ts-` token
 * from ts-tokens.css), and no `!important`. Timing comes from the tokens below — two
 * easings, three durations, and the skeleton's shimmer period; nothing else in the app
 * should invent one (the chart partial reads `--ts-t-slow` too).
 *
 * ⚠ Only `opacity`, `transform` and `grid-template-rows` animate, plus the skeleton's
 * `background-position` shimmer: the fold is the 0fr → 1fr grid technique, so there is
 * no JavaScript height arithmetic and no layout read in a loop.
 * `prefers-reduced-motion: reduce` makes every one of them instant (the block at the end).
 *
 * Overlay 188 applies these tokens app-wide (hover, press, popovers); this round
 * uses them on the two pilot report pages and the saved-views popover only.
 *
 * ⚠⚠ Overlay 188 (C188-6): linked from ALL THREE roots now — `base.html`,
 * `base_public.html` and `base_dashboard.html` — for the app-wide part at the end of
 * this file (hover and press, popovers, swaps fading in, the thin progress line, the
 * reserved scrollbar space, the reports menu's groups opening smoothly). Its classes
 * are read by both roots' class sweeps. Everything stays instant under
 * `prefers-reduced-motion`.
 * ==================================================================== */

:root {
  --ts-ease-out: cubic-bezier(0.22, 0.8, 0.24, 1);     /* things arriving or settling */
  --ts-ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);    /* between two resting places */
  --ts-t-fast: 120ms;   /* hover, press, focus, colour changes */
  --ts-t-base: 200ms;   /* popovers, the panel folding */
  --ts-t-slow: 320ms;   /* results arriving, drawers */
  --ts-t-shimmer: 1.3s; /* one sweep of the loading skeleton's shimmer */
  --ts-t-pulse: 1.4s;   /* one beat of the Ask microphone's ring while it listens (Overlay 202) */
}

/* ---------------------------------------------------------------------
 * The report panel — `internal/_report_panel_*.html`.
 *
 * It is a <details> (the house idiom for a collapse, and on Registration counts the
 * SAME element Overlay 111 made the phone collapse), so with no script it opens and
 * closes natively. With the script, a click on its summary is taken over: the body
 * folds through `.is-folded` FIRST and `open` is dropped only when the fold has
 * finished moving — a <details> that closes at once cannot animate.
 * ------------------------------------------------------------------- */
.ts-report-panel {
  position: relative;
}

.ts-report-panel > details > summary {
  list-style: none;
  cursor: pointer;
}

.ts-report-panel > details > summary::-webkit-details-marker {
  display: none;
}

.ts-fold {
  display: grid;
  grid-template-rows: 1fr;
  opacity: 1;
  transition:
    grid-template-rows var(--ts-t-base) var(--ts-ease-out),
    opacity var(--ts-t-base) var(--ts-ease-out);
}

.ts-fold > .ts-fold-in {
  min-height: 0;
  overflow: hidden;
}

.ts-report-panel.is-folded .ts-fold {
  grid-template-rows: 0fr;
  opacity: 0;
}

/* The head has two layers in one grid cell: what the panel is for (open), and the
   applied filters as chips (folded, once the report has run). They cross-fade. */
.ts-panel-layers {
  display: grid;
  min-width: 0;
  flex: 1 1 auto;
}

.ts-panel-layer {
  grid-area: 1 / 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  transition: opacity var(--ts-t-base) var(--ts-ease-out);
}

.ts-report-panel .ts-panel-sum {
  opacity: 0;
  visibility: hidden;
}

.ts-report-panel.is-folded.has-run .ts-panel-sum {
  opacity: 1;
  visibility: visible;
}

.ts-report-panel.is-folded.has-run .ts-panel-title {
  opacity: 0;
  visibility: hidden;
}

/* "Edit" is the folded panel's way back in; while the panel is open it has nothing
   to say, so it fades out (the summary is still the button either way). */
.ts-panel-edit {
  transition: opacity var(--ts-t-base) var(--ts-ease-out);
}

.ts-report-panel:not(.is-folded) .ts-panel-edit {
  opacity: 0;
}

/* The saved-views bookmark sits over the head row, outside the <details>, so it is
   reachable folded or open and never toggles the panel. */
.ts-panel-tools {
  position: absolute;
  top: 0.5rem;
  inset-inline-end: 0.5rem;
  z-index: 20;
}

/* One applied filter, as the folded head shows it: the field's own label, then the
   chosen value. Built by the panel script from the form's labels (no per-report code). */
.ts-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  min-height: 1.75rem;
  padding: 0 0.625rem;
  border-radius: var(--ts-radius-pill);
  background: var(--ts-surface);
  box-shadow: inset 0 0 0 1px var(--ts-border);
  font-size: var(--ts-text-sm);
  color: var(--ts-ink-muted);
  /* ⚠ Overlay 187 browser pass: at 390 px "Show Attendees, Guests, Exhibitors" is wider
     than the row, and a chip that may not wrap ran UNDER the Edit button. A chip is at
     most the row's width and wraps inside itself. */
  max-width: 100%;
  padding-block: 0.125rem;
  white-space: normal;
}

.ts-chip b {
  color: var(--ts-ink);
  font-weight: 600;
}

/* ---------------------------------------------------------------------
 * The results area while a Search is in flight. The area keeps the height it had
 * (the script pins `min-height`) and a skeleton of the same height sits over it, so
 * nothing collapses and re-grows; the old results are kept, invisible, underneath.
 * ------------------------------------------------------------------- */
.ts-report-results {
  position: relative;
}

/* ⚠ Overlay 93's rule (C93-4, `registration.tests_overlay93_wizard_polish`): an htmx swap
   target whose whole subtree is replaced turns Chrome's SCROLL ANCHORING off, or Chrome
   anchors to a node the swap destroys and throws the reader somewhere else — the jump Ian
   named. That rule lives in `ts-utilities.css`, which this root does not load, so the
   report frame's one swap target carries it here. An id, never a global switch.
   ⚠ Overlay 281 (backlog C-31): the public wizard's and the exhibitor portal's three
   targets are here too. Overlays 140/144 moved those pages onto `base_public.html`, which
   links THIS sheet and not `ts-utilities.css`, so the rule Ian asked for (2026-09-16:
   "click Add and the page jumps") had silently stopped reaching them — and the Overlay 93
   test stayed green because it read the file, not the root that links it. All three roots
   (`base.html`, `base_public.html`, `base_dashboard.html`) link this sheet;
   `ts-utilities.css` keeps its copy for `base.html`'s pages. */
#report-results-body,
#form-body,
#exhibitor-products,
#exhibitor-review-pay {
  overflow-anchor: none;
}

.ts-report-results.is-loading > :not(.ts-skeleton) {
  visibility: hidden;
}

.ts-skeleton {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow: hidden;
}

.ts-skeleton-block {
  flex: 0 0 auto;
  border-radius: var(--ts-radius);
  border: 1px solid var(--ts-border-soft);
  background: linear-gradient(
    90deg,
    var(--ts-border-soft) 0%,
    var(--ts-surface) 40%,
    var(--ts-border-soft) 80%
  );
  background-size: 200% 100%;
  animation: ts-shimmer var(--ts-t-shimmer) linear infinite;
}

/* Results arrive by rising 8px and fading in, once. */
.ts-reveal {
  animation: ts-rise var(--ts-t-slow) var(--ts-ease-out) both;
}

@keyframes ts-rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@keyframes ts-shimmer {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

/* The saved-views popover eases in rather than cutting (daisyUI positions it). */
.ts-popover[open] > .ts-popover-panel {
  animation: ts-pop var(--ts-t-fast) var(--ts-ease-out) both;
}

@keyframes ts-pop {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.ts-report-chart {
  width: 100%;
  min-width: 0;
}

/* =====================================================================
 * Overlay 188 (C188-6) — motion app-wide.
 * ================================================================== */

/* Hover and press: buttons settle their colour instead of cutting, and give a
   1px press. Rows of a data table take a soft hover so the eye can follow a
   line across a wide table. */
.btn {
  transition:
    background-color var(--ts-t-fast) var(--ts-ease-out),
    border-color var(--ts-t-fast) var(--ts-ease-out),
    color var(--ts-t-fast) var(--ts-ease-out),
    box-shadow var(--ts-t-fast) var(--ts-ease-out),
    transform var(--ts-t-fast) var(--ts-ease-out);
}

.btn:active:not(:disabled):not([aria-disabled="true"]) {
  transform: translateY(1px);
}

.ts-reports-shell .table tbody tr,
.ts-organizer-shell .table tbody tr {
  transition: background-color var(--ts-t-fast) var(--ts-ease-out);
}

.ts-reports-shell .table tbody tr:hover,
.ts-organizer-shell .table tbody tr:hover {
  background-color: var(--ts-surface-sunken);
}

/* Popovers ease in: every daisyUI dropdown that is a <details>, as the saved
   views' already did. */
details.dropdown[open] > .dropdown-content {
  animation: ts-pop var(--ts-t-fast) var(--ts-ease-out) both;
}

/* htmx swaps fade in. htmx marks new content `htmx-added` until it settles;
   the swap targets fade it in over one base step. ⚠ The report frame's
   `#report-results-body` is NOT here — it has its own rise (`ts-reveal`). Every
   target named is one `registration.tests_overlay93_wizard_polish` watches, and
   none loses its `overflow-anchor` rule: opacity is all that moves. */
#form-body,
#form-body > *,
#exhibitor-products,
#exhibitor-products > *,
#exhibitor-review-pay,
#exhibitor-review-pay > * {
  transition: opacity var(--ts-t-base) var(--ts-ease-out);
}

#form-body.htmx-added,
#form-body > .htmx-added,
#exhibitor-products.htmx-added,
#exhibitor-products > .htmx-added,
#exhibitor-review-pay.htmx-added,
#exhibitor-review-pay > .htmx-added {
  opacity: 0;
}

/* The loader's thin line (`partials/_request_loader.html`): an in-page htmx
   request shows a 3px line across the top in place of the full-screen veil,
   which stays for real page changes and payments (a form submit). */
.ts-progress-line {
  position: fixed;
  inset-block-start: 0;
  inset-inline: 0;
  z-index: 1041;
  height: 3px;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--ts-t-fast) var(--ts-ease-out);
}

.ts-progress-line::after {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 40%;
  background: var(--ts-theme-primary, var(--ts-accent));
  animation: ts-progress-run 1.1s var(--ts-ease-in-out) infinite;
}

.ts-progress-line.ts-progress-on {
  opacity: 1;
}

@keyframes ts-progress-run {
  from { transform: translateX(-100%); }
  to { transform: translateX(250%); }
}

/* Ian, 2026-10-06 (item 12): "it appears to jump when the text in a dropdown
   option is longer because a scrollbar appears … yes fix it." A scrollbar that
   appears takes its width out of the page (or the reports menu) and everything
   beside it shifts. The space is reserved, so a scrollbar arriving moves nothing. */
html {
  scrollbar-gutter: stable;
}

.ts-reports-shell .drawer-side {
  scrollbar-gutter: stable;
}

/* Item 13 — "great do it": the reports menu's groups open and close with a short
   height change instead of a cut. Chromium's `::details-content` and
   `interpolate-size` (Chrome-family is the supported browser); elsewhere they
   simply open and close as before. The remembered-collapsed script and every hook
   are untouched — this is CSS on the same <details>. */
.ts-reports-shell details[data-report-nav-category-details] {
  interpolate-size: allow-keywords;
}

.ts-reports-shell details[data-report-nav-category-details]::details-content {
  block-size: 0;
  overflow: clip;
  transition:
    block-size var(--ts-t-base) var(--ts-ease-out),
    content-visibility var(--ts-t-base) allow-discrete;
}

.ts-reports-shell details[data-report-nav-category-details][open]::details-content {
  block-size: auto;
}

/* ---------------------------------------------------------------------
 * Overlay 202 (C202-3): the Ask microphone, alive. Ian: "if there is anyway to make
 * this voice part feel a little more interactive." The page's script sets
 * `data-voice-state` on the mic (`idle | starting | listening | failed`); while it
 * LISTENS a ring pulses out from it, and while it is STARTING (tapped, the browser
 * has not answered yet) the button dims a little so the tap visibly registered.
 * Only `transform` and `opacity` move. Under reduced motion the ring stays, still.
 * ------------------------------------------------------------------- */
.ts-voice-mic {
  position: relative;
}

/* ⚠ Overlay 202 review LOW-1: "Or tap one" draws its own chevron. `list-style: none`
   (the summary's `list-none`) does not reach WebKit's marker, so on an iPhone — the
   device Ask is for — a native triangle would sit beside it. The house pairing, as
   `.ts-report-panel > details > summary` above. */
[data-voice-saved-views-toggle]::-webkit-details-marker {
  display: none;
}

.ts-voice-mic[data-voice-state="starting"] {
  opacity: 0.7;
}

.ts-voice-mic[data-voice-state="listening"]::after {
  content: "";
  position: absolute;
  inset: -0.375rem;
  border-radius: 9999px;
  border: 3px solid rgba(var(--ts-danger-rgb), 0.55);
  pointer-events: none;
  animation: ts-voice-pulse var(--ts-t-pulse) var(--ts-ease-out) infinite;
}

@keyframes ts-voice-pulse {
  from {
    opacity: 1;
    transform: scale(0.92);
  }

  to {
    opacity: 0;
    transform: scale(1.4);
  }
}

/* ---------------------------------------------------------------------
 * Overlay 239 (C239-4) — a report's graph waits for *Show graph*. The chart partial's
 * script marks <html> before any fallback is parsed, so with a script on a fallback
 * never shows early; it shows on the click only when ECharts cannot draw
 * (`data-report-graph-shown`). The reports hub's cards draw at once
 * (`data-report-graph-now`). With no script nothing is marked: the fallback is the page.
 * ------------------------------------------------------------------- */
.ts-graphs-wait [data-report-chart-fallback]:not([data-report-graph-now]):not([data-report-graph-shown]) {
  display: none;
}

/* Overlay 239 (C239-3, Ian: "Layout A") — the panel's folded *Advanced* section and
   the headline row under it. */
.ts-report-advanced {
  border-top: 1px dashed var(--ts-border);
  padding-top: 0.75rem;
}

.ts-report-advanced > summary {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  cursor: pointer;
  list-style: none;
  color: var(--ts-accent);
  font-weight: 600;
}

.ts-report-advanced > summary::-webkit-details-marker {
  display: none;
}

.ts-report-advanced > summary::before {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  border-inline-end: 2px solid currentColor;
  border-block-end: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform var(--ts-t-base) var(--ts-ease-out);
}

.ts-report-advanced[open] > summary::before {
  transform: rotate(45deg);
}

.ts-report-advanced > summary:focus-visible {
  outline: 2px solid var(--ts-focus);
  outline-offset: 2px;
  border-radius: var(--ts-radius-sm);
}

/* Layout A's first row: a page that marks its main fields `.ts-report-main` gets them
   in one row with Search and Reset (`.ts-report-buttons`) beside them; everything else
   in the form (the key checkboxes, *Advanced*, the notes) runs full width below. The
   fields' container is `display: contents`, so the row is laid out by the FORM while
   htmx still swaps that one container on each Search. A page that marks nothing is
   untouched. Below 48rem the buttons drop under the main fields. */
form[data-report-form]:has(.ts-report-main) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 1rem;
  row-gap: 0.75rem;
  align-items: end;
}

form[data-report-form]:has(.ts-report-main) > [data-report-filter-fields] {
  display: contents;
}

form[data-report-form]:has(.ts-report-main) > *,
form[data-report-form]:has(.ts-report-main) > [data-report-filter-fields] > * {
  grid-column: 1 / -1;
}

form[data-report-form]:has(.ts-report-main) > [data-report-filter-fields] > .ts-report-main {
  grid-column: 1;
  grid-row: 1;
}

form[data-report-form]:has(.ts-report-main) > .ts-report-buttons {
  grid-column: 2;
  grid-row: 1;
  margin-top: 0;
  padding-bottom: 0.125rem;
}

@media (max-width: 47.99rem) {
  form[data-report-form]:has(.ts-report-main) > [data-report-filter-fields] > .ts-report-main {
    grid-column: 1 / -1;
  }

  form[data-report-form]:has(.ts-report-main) > .ts-report-buttons {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

.ts-report-headline {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 1.125rem;
  padding: 0.875rem 1rem;
  border: 1px solid var(--ts-border);
  border-radius: var(--ts-radius);
  background: var(--ts-surface);
  font-variant-numeric: tabular-nums;
}

.ts-report-headline-number {
  font-size: var(--ts-text-3xl);
  font-weight: 700;
  line-height: 1.15;
  color: var(--ts-ink);
}

.ts-report-headline-unit {
  margin-inline-start: 0.25rem;
  font-size: var(--ts-text-md);
  font-weight: 500;
  color: var(--ts-ink-muted);
}

.ts-report-headline-side {
  color: var(--ts-ink-secondary);
}

/* ---------------------------------------------------------------------
 * Reduced motion: everything above is instant. Same selectors, later in the sheet,
 * so no `!important` is needed to win.
 * ------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .ts-fold,
  .ts-panel-layer,
  .ts-panel-edit,
  .ts-report-advanced > summary::before {
    transition: none;
  }

  .ts-reveal,
  .ts-skeleton-block,
  .ts-popover[open] > .ts-popover-panel {
    animation: none;
  }

  /* Overlay 188 (C188-6). The progress line still SHOWS under reduced motion —
     it is how a reader knows a request is in flight — but it stands still. */
  .btn,
  .ts-reports-shell .table tbody tr,
  .ts-organizer-shell .table tbody tr,
  #form-body,
  #form-body > *,
  #exhibitor-products,
  #exhibitor-products > *,
  #exhibitor-review-pay,
  #exhibitor-review-pay > *,
  .ts-progress-line,
  .ts-reports-shell details[data-report-nav-category-details]::details-content {
    transition: none;
  }

  .btn:active:not(:disabled):not([aria-disabled="true"]) {
    transform: none;
  }

  details.dropdown[open] > .dropdown-content {
    animation: none;
  }

  .ts-progress-line::after {
    animation: none;
    width: 100%;
  }

  /* Overlay 202 (C202-3): the ring still SHOWS the mic is listening; it stands still. */
  .ts-voice-mic[data-voice-state="listening"]::after {
    animation: none;
  }
}

/* -------------------------------------------------------------------
 * Overlay 319 (C319-8) — a report table's search box and its sorting heads
 * (`templates/partials/_report_table_tools.html`, the one script). Ian: "can we make
 * the results tables always searchable and sortable by headers?"
 *
 * The bar sits above the table inside its card. A head that sorts is a button that
 * looks like the head it replaced — same font, same alignment — with a small mark
 * that says which way the column runs. A row the search leaves out is hidden by its
 * OWN attribute, never `hidden`, which other scripts set and clear (the Sales
 * report's price points).
 * ------------------------------------------------------------------- */
.ts-table-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.625rem 1rem;
  border-bottom: 1px solid var(--ts-border-soft);
}

.ts-table-search {
  flex: 0 1 18rem;
}

.ts-table-search > input {
  width: 100%;
}

.ts-table-count,
.ts-table-cap {
  font-size: var(--ts-text-sm);
  color: var(--ts-ink-muted);
}

.ts-sort {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: inherit;
  text-decoration: none;
  cursor: pointer;
}

/* The whole head sorts (the script presses its button on a click anywhere in the cell). */
th[aria-sort] {
  cursor: pointer;
}

.ts-sort:focus-visible {
  outline: 2px solid var(--ts-focus);
  outline-offset: 2px;
  border-radius: var(--ts-radius-sm);
}

.ts-sort-arrow::before {
  content: "\2195";
  color: var(--ts-ink-muted);
}

th[aria-sort="ascending"] .ts-sort-arrow::before {
  content: "\25B2";
  color: var(--ts-accent);
}

th[aria-sort="descending"] .ts-sort-arrow::before {
  content: "\25BC";
  color: var(--ts-accent);
}

[data-report-search-hidden] {
  display: none;
}
