/* PRX life layer, shared. Link after prx-brand.css (and prx-ui.css where a page has it).
 *
 * What it adds, and only this:
 *   - motion tokens, so every transition in the product speaks at one speed;
 *   - the parts of the browser nobody drew: focus ring, text selection, caret, scrollbars, numerals;
 *   - one icon-tile component, tinted by the screen colours prx-brand.css already defines and already gives a meaning
 *     (work blue, clinical purple, supply teal, owings amber, community green). A tone is a place, not a mood.
 *   - a live dot, a sheet entrance, a press state;
 *   - the reduced-motion path for all of it.
 *
 * What it does not touch: print and label output, the semantic status colours, or any page that has not linked it.
 */

:root {
  /* Exponential ease-out: arrives fast, settles slowly. Nothing in this product bounces. */
  --prx-ease:      cubic-bezier(.16, 1, .3, 1);
  --prx-dur-fast:  120ms;   /* press, toggle: the thing answered you */
  --prx-dur:       200ms;   /* hover, focus, colour */
  --prx-dur-sheet: 280ms;   /* a panel arriving */

  /* Tones: ink for the icon, tint for the tile behind it. Each pair clears 3:1 (graphics) and every ink is already one of
     the product's own screen colours. */
  --tone-work-ink:      var(--prx-screen-work, #1565C0);      --tone-work-tint:      #E4EEFA;
  --tone-clinical-ink:  var(--prx-screen-clinical, #5B21B6);  --tone-clinical-tint:  #EEE7FC;
  --tone-supply-ink:    var(--prx-screen-supply, #0F766E);    --tone-supply-tint:    #D9F2EE;
  --tone-owings-ink:    var(--prx-screen-owings, #B45309);    --tone-owings-tint:    #FDF0D2;
  --tone-community-ink: var(--prx-screen-community, #1B5E20); --tone-community-tint: #DDF3E2;
}

/* ── The parts of the browser nobody drew ─────────────────────────────────── */
:root { accent-color: var(--prx-brand, #005eb8); caret-color: var(--prx-brand, #005eb8); }
::selection { background: var(--prx-brand-100, #d2e6f7); color: #0f172a; }

/* One focus ring for every control: visible on white, on a tinted tile and on a coloured header. Keyboard only, so a
   mouse click never leaves a ring behind. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--prx-brand-500, #0a6fc2);
  outline-offset: 2px;
  border-radius: inherit;
}
:where(input, select, textarea):focus-visible { outline-offset: 0; }

/* Thin scrollbars in the page's own greys instead of the browser's chunky default: mouse-driven screens only. On a touch device the
   browser draws overlay scrollbars; styling ::-webkit-scrollbar there can force classic ones that take layout space. */
@media (hover: hover) and (pointer: fine) {
  * { scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; }
  *::-webkit-scrollbar { width: 10px; height: 10px; }
  *::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
  *::-webkit-scrollbar-thumb:hover { background: #94a3b8; background-clip: content-box; }
}

/* Figures line up in a column, so a quantity or a count reads at a glance. */
:where(table, .num, time) { font-variant-numeric: tabular-nums; }
:where(h1, h2) { text-wrap: balance; }
a, button { -webkit-tap-highlight-color: transparent; }

/* ── Icons ─────────────────────────────────────────────────────────────────── */
.ic { width: 1em; height: 1em; flex: none; display: inline-block; vertical-align: -.125em; }

/* The tile an icon sits on. Sized by its own font-size so it scales with the surface that holds it. */
.prx-tile {
  /* Takes its tone from itself or any ancestor (.tone-*), work blue if nothing sets one. */
  display: inline-grid; place-items: center;
  width: 2.5em; height: 2.5em; font-size: 16px;
  border-radius: 12px;
  background: var(--tone-tint, var(--tone-work-tint));
  color: var(--tone-ink, var(--tone-work-ink));
  transition: transform var(--prx-dur) var(--prx-ease), background-color var(--prx-dur), color var(--prx-dur);
}
.prx-tile .ic { width: 1.5em; height: 1.5em; vertical-align: 0; }
.tone-work      { --tone-ink: var(--tone-work-ink);      --tone-tint: var(--tone-work-tint); }
.tone-clinical  { --tone-ink: var(--tone-clinical-ink);  --tone-tint: var(--tone-clinical-tint); }
.tone-supply    { --tone-ink: var(--tone-supply-ink);    --tone-tint: var(--tone-supply-tint); }
.tone-owings    { --tone-ink: var(--tone-owings-ink);    --tone-tint: var(--tone-owings-tint); }
.tone-community { --tone-ink: var(--tone-community-ink); --tone-tint: var(--tone-community-tint); }

/* ── A live dot: breathes once every few seconds, only while the page is visible ─────────────────────────────────── */
.prx-live { position: relative; }
.prx-live::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; background: inherit;
  opacity: 0; transform: scale(1);
}
@media (prefers-reduced-motion: no-preference) {
  .prx-live::after { animation: prx-breathe 3.2s var(--prx-ease) infinite; }
}
@keyframes prx-breathe { 0% { opacity: .5; transform: scale(1); } 70%, 100% { opacity: 0; transform: scale(2.6); } }

/* ── A panel arriving: fades and settles 8px, once ────────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: no-preference) {
  /* backwards, not both: once it has finished nothing is left applied, so the panel is not left as a transform
     container for any fixed-position child (a full-screen overlay inside it would be trapped at the panel's size). */
  .prx-sheet-in { animation: prx-sheet-in var(--prx-dur-sheet) var(--prx-ease) backwards; }
}
@keyframes prx-sheet-in { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }

/* ── Reduced motion: keep the feedback, drop the movement ─────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
  .prx-tile { transform: none !important; }
}
