/* The parts nobody drew (scrollbars, selection, focus): from the prototype's craft layer (craft.mjs), as every page carries it. */
/* ---- browser surfaces: the parts nobody drew still belong to the palette ---- */
/* the scrollbar's room is kept even when a page is too short to scroll, so filtering a list never shifts the page
   sideways (John, 2026-11-22: "why do the rows jump ... when we switch between these tabs?") */
html{ scrollbar-gutter:stable; }
/* a phone keeps no room: its scrollbar lies over the page and shows only while scrolling */
@media (max-width: 767px){ html{ scrollbar-gutter:auto; } }
html{ -webkit-font-smoothing:antialiased; -moz-osx-font-smoothing:grayscale; text-rendering:optimizeLegibility;
  -webkit-tap-highlight-color:transparent; accent-color:var(--tomato); caret-color:var(--tomato); }
::selection{ background:color-mix(in srgb,var(--tomato) 26%,transparent); color:inherit; }
:where(h1,h2,h3){ text-wrap:balance; }
:where(p,li,small){ text-wrap:pretty; }

/* ---- press feedback: every pressable answers the press ----
   Uses the standalone 'scale' property so it composes with any transform a
   screen already sets (hover lifts, centring). --tm-press is set per element
   by CRAFT_JS so a wide button shrinks by a few pixels, not by 3% of its width. */
:root:root :is(button,[role="button"],.tmsh-nav a,.tmsh-mark):not(:disabled,[aria-disabled="true"]){
  transition-property:scale,translate,transform,background-color,color,border-color,box-shadow,opacity,outline-color;
  transition-duration:var(--dur-fast,160ms);
  transition-timing-function:var(--ease-out,cubic-bezier(.23,1,.32,1));
}
:root:root :is(button,[role="button"],.tmsh-nav a,.tmsh-mark):not(:disabled,[aria-disabled="true"]):active{
  scale:var(--tm-press,.97); transition-duration:var(--dur-press,140ms);
}

/* ---- menus and popovers: grow from the trigger, enter only ----
   The exit stays instant on purpose: closing a menu is the user moving on. */
.tmsh-menu{ transform-origin:top right; }
.proj-menu,.cmenu,.dep-menu{ transform-origin:top left; }
:is(.tmsh-menu:not([hidden]),.proj-menu:not([hidden]),.cmenu.on,.dep-menu.on){
  transition:opacity var(--dur-pop,180ms) var(--ease-out), scale var(--dur-pop,180ms) var(--ease-out), translate var(--dur-pop,180ms) var(--ease-out);
}
@starting-style{
  :is(.tmsh-menu:not([hidden]),.proj-menu:not([hidden]),.cmenu.on,.dep-menu.on){ opacity:0; scale:.96; translate:0 -4px; }
}

/* ---- menu rows arrive one after another (Rapport's popover rows: 8px rise, 35ms apart) ---- */
@keyframes tm-rise{ from{ opacity:0; translate:0 8px; } }
.tmsh-menu:not([hidden]) > *{ animation:tm-rise var(--dur-panel,280ms) var(--ease-out) backwards; }
.tmsh-menu:not([hidden]) > :nth-child(2){ animation-delay:35ms; }
.tmsh-menu:not([hidden]) > :nth-child(3){ animation-delay:70ms; }
.tmsh-menu:not([hidden]) > :nth-child(4){ animation-delay:105ms; }
.tmsh-menu:not([hidden]) > :nth-child(n+5){ animation-delay:140ms; }

/* ---- the dock: hover intent + labels that arrive with the width ----
   A 70ms delay on open stops the dock flying out when the pointer only passes
   over it; closing has no delay. Labels slide 4px as they fade in. */
.tmsh-rail{ transition:width 240ms var(--ease-out); view-transition-name:tmsh-dock; }
.tmsh-rail:hover{ transition-delay:70ms; }
body.tmsh-pinned .tmsh-rail{ transition-delay:0s; }
.tmsh-name,.tmsh-t,.tmsh-count,.tmsh-who,.tmsh-lab{ translate:-4px 0;
  transition:opacity var(--dur-exit) var(--ease-out), translate var(--dur-pop) var(--ease-out); }
.tmsh-rail:hover :is(.tmsh-name,.tmsh-t,.tmsh-count,.tmsh-who,.tmsh-lab),
body.tmsh-pinned :is(.tmsh-name,.tmsh-t,.tmsh-count,.tmsh-who,.tmsh-lab){ translate:0 0;
  transition:opacity var(--dur-pop) var(--ease-out) 90ms, translate var(--dur-panel) var(--ease-out) 90ms; }
body.tmsh-pinned :is(.tmsh-name,.tmsh-t,.tmsh-count,.tmsh-who,.tmsh-lab){ transition-delay:0s; }

/* ---- page to page: no white flash, the dock holds still ----
   Cross-document view transition (Chromium, same origin). A 140ms cross-fade
   only: navigation is the most frequent action in the app, so it gets
   continuity, not choreography. Browsers without support just navigate. */
@view-transition{ navigation:auto; }
::view-transition-old(root),::view-transition-new(root){ animation-duration:140ms; animation-timing-function:ease; }
::view-transition-group(tmsh-dock){ animation-duration:220ms; animation-timing-function:var(--ease-out,cubic-bezier(.23,1,.32,1)); }

/* ---- focus: one ring everywhere. Ink = focus; tomato stays reserved for selected / active ---- */
:root:root :focus-visible{ outline:2px solid var(--ink); outline-offset:2px; }

/* ---- segmented controls: the travelling pill (driven by CRAFT_JS) ---- */
.tm-seg-ghost{ position:absolute; pointer-events:none; z-index:-1; }

/* ---- reduced motion: keep colour and opacity, remove movement ----
   The one rule for every page (the screens carry the same line for when they open on their own): transitions keep
   colour and opacity only; keyframes jump to their end. The undo ring and a busy spinner keep running, they say something. */
@media (prefers-reduced-motion:reduce){*:not(.ui-toast-ring > rect,.toast-ring > rect),*::before,*:not([aria-busy="true"])::after{transition-property:color,background-color,border-color,opacity,box-shadow,outline-color,fill,stroke!important;animation-duration:1ms!important;animation-iteration-count:1!important;animation-delay:0s!important;scroll-behavior:auto!important}}
@media (prefers-reduced-motion:reduce){
  :root:root :is(button,[role="button"],.tmsh-nav a,.tmsh-mark):active{ scale:1; }
  .tmsh-rail,.tmsh-rail:hover{ transition:none; }
  .tmsh-name,.tmsh-t,.tmsh-count,.tmsh-who,.tmsh-lab{ translate:0 0 !important; }
  @starting-style{
    :is(.tmsh-menu:not([hidden]),.proj-menu:not([hidden]),.cmenu.on,.dep-menu.on){ scale:1; translate:0 0; }
  }
  .tmsh-menu:not([hidden]) > *{ animation:none; }
  ::view-transition-group(*),::view-transition-old(*),::view-transition-new(*){ animation:none !important; }
}
