/* Motion and depth, apart from app.css so the look can move without the
   layout file (9 Nov 2026: "look more appealing", "feel more alive").
   Everything that moves sits inside prefers-reduced-motion: no-preference;
   the depth, radius and focus ring below it are static and apply to all.
   The hooks (.mo-row, .mo-in, .mo-skel, html.mo-fresh, --mo-i) are set by
   motion.js, which reads the page and never writes a figure. */

/* a warmer page in light, so white cards stand off it */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) { --mo-sh: none; --mo-sh2: none; --mo-ring: rgba(46, 116, 102, .22); }
}
:root[data-theme="light"] { --mo-sh: none; --mo-sh2: none; --mo-ring: rgba(46, 116, 102, .22); }
:root { --mo-sh: none; --mo-sh2: none; --mo-ring: rgba(79, 174, 155, .28); --mo-ease: cubic-bezier(.2, .8, .2, 1); }

/* depth: one two-step shadow and one radius on every card-shaped thing */
.card, .tile, .hubtile, .vital, .supp, .vcard, .rtile, .gtile, .tstats > div, .tstats > button, .scard, button.scard, .ritem, .cbadge, .stage, .sheet-in { border-radius: var(--r); }
.card, .tile, .hubtile, .vital, .supp, .vcard, .rtile, .gtile, .tstats > div, .tstats > button, .scard, button.scard { box-shadow: var(--mo-sh); }
.tile:hover, .hubtile:hover, .vital:hover, .rtile:hover, .gtile:hover, .scard:hover { box-shadow: var(--mo-sh2); }
.panel-in, .sheet-in { box-shadow: 0 -8px 40px -12px rgba(0, 0, 0, .45); }
@media (min-width: 681px) { header.top { box-shadow: 0 8px 18px -14px rgba(0, 0, 0, .35); } } /* on a phone the header is a transparent overlay of three round buttons; the shadow would float */
.pageback .ico { stroke-width: 1.8; }

/* a soft focus ring in the action teal, so a keyboard user sees the same
   colour a tap would act on */
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--act); outline-offset: 2px; box-shadow: 0 0 0 5px var(--mo-ring); }
.seg button:focus-visible, .tabs button:focus-visible { outline-offset: -2px; box-shadow: none; } /* inside a bar the halo would spill onto the neighbours */

/* a skeleton in the shape of a card, shown while the record loads */
/* zero height in the flow, so the page the app measures (stageFit, chartFit)
   is laid out exactly as it would be with no skeleton on it */
.mo-skel { position: relative; height: 0; margin: 0; overflow: visible; pointer-events: none; }
.mo-skel .in { position: absolute; top: 14px; left: 0; right: 0; display: grid; gap: 10px; }
.mo-skel .sk { background: var(--coal2); border-radius: var(--r); min-height: 72px; }
.mo-skel .sk.tall { min-height: 220px; }
.mo-skel .sk.row { min-height: 52px; border-radius: var(--rs); }
.mo-skel .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mo-skel .two .sk { min-height: 96px; }

@media (prefers-reduced-motion: no-preference) {
  /* a tab, sub-tab or Plan pane rises 6px and fades in each time it is shown;
     a hidden element restarts its animation when display returns, so this
     needs no script */
  [data-panel]:not([hidden]), [data-subpanel]:not([hidden]), [data-ppane]:not([hidden]), .mo-in { animation: mo-fadein .22s var(--mo-ease) both; }
  /* the pane itself only fades: the app measures the stage, the chart and the
     Plan rows against the bar the moment it paints them, and a pane in
     transit would be measured 6px low. The rise is on the rows instead. */
  @keyframes mo-fadein { from { opacity: 0; } to { opacity: 1; } }
  @keyframes mo-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

  /* a pop-up and a sheet ease in rather than appear */
  .panel { animation: mo-dim .2s ease-out both; }
  .panel-in { animation: mo-drop .26s var(--mo-ease) both; }
  .panel.peek .panel-in { animation: mo-up .26s var(--mo-ease) both; }
  .sheet:not([hidden]) { animation: mo-dim .2s ease-out both; }
  .sheet:not([hidden]) .sheet-in { animation: mo-up .28s var(--mo-ease) both; }
  @keyframes mo-dim { from { background-color: transparent; } }
  @keyframes mo-drop { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
  @keyframes mo-up { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

  /* rows stagger 20 ms apart on their first paint (--mo-i from motion.js) */
  .mo-row { animation: mo-rise .24s var(--mo-ease) both; animation-delay: calc(var(--mo-i, 0) * 20ms); }
  .ppane .mo-row { animation-name: mo-fadein; } /* fitPlan measures these rows against the fold as it paints them */

  /* press feedback on anything a finger taps */
  button:active, .chip:active, .tile:active, .hubtile:active, .vital:active, .rtile:active, .gtile:active, .sysbtn:active, .trow:active, .scard:active, nav.bar a:active, nav.main a:active { transform: scale(.98); transition: transform 90ms ease-out; }
  button, .chip, .tile, .hubtile, .vital, .rtile, .gtile, .sysbtn, .trow, .scard, nav.bar a, nav.main a { transition: transform 90ms ease-out, background-color .15s, border-color .15s, box-shadow .2s; }
  .tabs button:active, .seg button:active, .pageback:active, .panel-x:active, .midx:active, .mid:active { transform: none; }


  /* the dose ring sweeps to its value; the gauge rings do the same */
  .dring circle + circle, .ring .fg { transition: stroke-dasharray .6s var(--mo-ease); }

  /* the skeleton shimmers while it waits */
  .mo-skel .sk { background: linear-gradient(100deg, var(--coal2) 30%, var(--coal3) 45%, var(--coal2) 60%); background-size: 300% 100%; animation: mo-shimmer 1.4s linear infinite; }
  @keyframes mo-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
  .mo-skel.mo-out { animation: mo-fade .18s ease-out both; }
  @keyframes mo-fade { to { opacity: 0; } }
}
