/* Motion and finish, as one system for every page (the user's checklist, 2026-11-12). Served and linked like
   site_builds.css. Rules of the system:
     - things arriving ease out; things moving on screen ease in-out; leaving takes 0.8 of arriving
     - menus, dialogs and popovers: 150-250 ms, from scale .95, growing from the side their trigger is on; no bounce
     - a pressed button gives (scale .97); a saved form pulses once
     - rows and cards arrive 30 ms apart (capped), numbers in tables keep their columns (tabular figures)
     - a list that is still loading shows its shape, not the word "Loading"
   The playmat, the hand and the cards on them are left exactly as the game page animates them. Everything here stops
   under the device's reduce-motion setting and the site's own (html[data-motion="reduce"], site_sync.js). */
:root {
  --m-in: 200ms; --m-out: 160ms; --m-fast: 120ms; --m-slow: 320ms; --m-step: 30ms;
  --m-ease-out: cubic-bezier(.16, 1, .3, 1); --m-ease-in-out: cubic-bezier(.65, 0, .35, 1); --m-ease-in: cubic-bezier(.4, 0, 1, 1);
}

/* ---- press */
:where(button, .button, a.button, [role="button"], summary.button):where(:not(:disabled)) { transition: scale var(--m-fast) var(--m-ease-out); }
:where(button, .button, a.button, [role="button"]):where(:not(:disabled)):active { scale: .97; }
/* A page that sets its own `transition` on a button leaves `scale` out of it, and the press snapped. The list of what
   eases is set here for every button off the playmat: the usual state properties plus scale, at the press's speed
   (a page's own colour and border easing carries on, 30 ms quicker at most). */
:is(button, .button, a.button, [role="button"]):not(:disabled):not(.cardimg):not(.card):not(.zone-btn) {
  transition-property: color, background-color, border-color, box-shadow, opacity, outline-color, filter, transform, scale !important;
  transition-duration: var(--m-fast) !important; transition-timing-function: var(--m-ease-out) !important;
}
:is(.field, .hand, #hand, .handgrid, .mullhand, .slot, .cardimg, .mat) :is(button, [role="button"]) { transition-property: revert !important; transition-duration: revert !important; transition-timing-function: revert !important; }
:where(.field, .hand, #hand, .handgrid, .mullhand, .slot, .cardimg) :where(button, [role="button"]):active,
:where(.cardimg, .card):active { scale: none; }

/* ---- dialogs, menus, popovers: in from .95 at the trigger's side, out faster */
/* --m-origin is stamped on the element by /site-motion.js from the trigger that opened it; the side rules below are the fallback */
dialog, [popover] { transform-origin: var(--m-origin, 50% 0); }
[popover]:popover-open { animation: m-pop-in var(--m-in) var(--m-ease-out); }
dialog[open] { animation: m-pop-in var(--m-in) var(--m-ease-out); }
dialog[open]::backdrop { animation: m-fade-in var(--m-in) var(--m-ease-out); }
dialog.mk-menu, dialog#mk-menu, .mk-shell dialog, dialog[class*="menu"] { --m-origin: 100% 0; }
:where([role="menu"], [role="listbox"], .popover, .pop, .menu-panel, .dropdown-panel):where(:not([hidden])) { transform-origin: var(--m-origin, 0 0); animation: m-pop-in var(--m-in) var(--m-ease-out); }
details[open] > :where(:not(summary)) { animation: m-drop-in var(--m-in) var(--m-ease-out); }
@supports (transition-behavior: allow-discrete) {
  dialog { transition: opacity var(--m-out) var(--m-ease-in), scale var(--m-out) var(--m-ease-in), overlay var(--m-out) allow-discrete, display var(--m-out) allow-discrete; }
  dialog:not([open]) { opacity: 0; scale: .97; }
}
@keyframes m-pop-in { from { opacity: 0; scale: .95; } }
@keyframes m-drop-in { from { opacity: 0; translate: 0 -4px; } }
@keyframes m-fade-in { from { opacity: 0; } }

/* ---- rows and cards arrive 30 ms apart */
:where(#table, table.lb, table.stagger, table#decks, table#against, table#levels, table#recent) :where(tr), :where(.mk-saved-grid, .help-grid, .mk-destination-grid, .cards, .tiles) > * {
  animation: m-rise var(--m-in) var(--m-ease-out) backwards;
}
:where(#table, table.lb, table.stagger, table#decks, table#against, table#levels, table#recent) :where(tr):nth-child(2), :where(.mk-saved-grid, .help-grid, .mk-destination-grid, .cards, .tiles) > :nth-child(2) { animation-delay: calc(var(--m-step) * 1); }
:where(#table, table.lb, table.stagger, table#decks, table#against, table#levels, table#recent) :where(tr):nth-child(3), :where(.mk-saved-grid, .help-grid, .mk-destination-grid, .cards, .tiles) > :nth-child(3) { animation-delay: calc(var(--m-step) * 2); }
:where(#table, table.lb, table.stagger, table#decks, table#against, table#levels, table#recent) :where(tr):nth-child(4), :where(.mk-saved-grid, .help-grid, .mk-destination-grid, .cards, .tiles) > :nth-child(4) { animation-delay: calc(var(--m-step) * 3); }
:where(#table, table.lb, table.stagger, table#decks, table#against, table#levels, table#recent) :where(tr):nth-child(5), :where(.mk-saved-grid, .help-grid, .mk-destination-grid, .cards, .tiles) > :nth-child(5) { animation-delay: calc(var(--m-step) * 4); }
:where(#table, table.lb, table.stagger, table#decks, table#against, table#levels, table#recent) :where(tr):nth-child(6), :where(.mk-saved-grid, .help-grid, .mk-destination-grid, .cards, .tiles) > :nth-child(6) { animation-delay: calc(var(--m-step) * 5); }
:where(#table, table.lb, table.stagger, table#decks, table#against, table#levels, table#recent) :where(tr):nth-child(7), :where(.mk-saved-grid, .help-grid, .mk-destination-grid, .cards, .tiles) > :nth-child(7) { animation-delay: calc(var(--m-step) * 6); }
:where(#table, table.lb, table.stagger, table#decks, table#against, table#levels, table#recent) :where(tr):nth-child(n+8), :where(.mk-saved-grid, .help-grid, .mk-destination-grid, .cards, .tiles) > :nth-child(n+8) { animation-delay: calc(var(--m-step) * 7); }
/* (only the league and leaderboard tables and tables marked .stagger: tables that redraw on a timer or on every move stay still) */
@keyframes m-rise { from { opacity: 0; translate: 0 6px; } }

/* ---- a success message pulses once when it appears (.ok lines fill on save; .pulse-ok for anything else) */
.ok:not(:empty), .pulse-ok, [data-saved="1"] { animation: m-pulse 520ms var(--m-ease-in-out); border-radius: 4px; }
@keyframes m-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 45%, transparent); scale: .98; }
  45% { scale: 1.01; }
  100% { box-shadow: 0 0 0 10px transparent; scale: 1; }
}

/* ---- on-screen state changes: colour and border ease in-out */
:where(a, button, .button, input, select, textarea, .chip, .pill, [role="tab"]) { transition-timing-function: var(--m-ease-in-out); }
:where(a, .button, input, select, textarea, .chip, .pill, [role="tab"]) { transition-property: color, background-color, border-color, box-shadow, opacity, scale; transition-duration: var(--m-fast); }

/* ---- icons that swap: cross-fade with scale and blur (.icon-swap > [data-on] / [data-off], or [aria-pressed] icons) */
.icon-swap { display: inline-grid; } .icon-swap > * { grid-area: 1 / 1; transition: opacity var(--m-in) var(--m-ease-in-out), scale var(--m-in) var(--m-ease-in-out), filter var(--m-in) var(--m-ease-in-out); }
.icon-swap > [data-off], .icon-swap.on > [data-on] { opacity: 1; scale: 1; filter: none; }
.icon-swap > [data-on], .icon-swap.on > [data-off] { opacity: 0; scale: .6; filter: blur(4px); }

/* ---- loading: the shape of what is coming */
:where(main) table:empty, .mk-saved-grid:empty, .card-grid[aria-busy="true"], [data-loading="1"] {
  display: block; min-height: 168px; border-radius: 8px; color: transparent !important;
  background:
    linear-gradient(100deg, transparent 30%, color-mix(in srgb, currentColor 0%, rgba(255,255,255,.10)) 50%, transparent 70%) 0 0 / 200% 100%,
    repeating-linear-gradient(to bottom, color-mix(in srgb, var(--mk-text, var(--text, #888)) 9%, transparent) 0 34px, transparent 34px 46px);
  animation: m-shimmer 1.3s linear infinite;
}
.card-grid[aria-busy="true"] > * { visibility: hidden; }
.card-grid[aria-busy="true"] {
  min-height: 560px;
  background:
    linear-gradient(100deg, transparent 30%, rgba(255,255,255,.10) 50%, transparent 70%) 0 0 / 200% 100%,
    repeating-linear-gradient(to right, color-mix(in srgb, var(--mk-text, #888) 9%, transparent) 0 148px, transparent 148px 164px);
  -webkit-mask: repeating-linear-gradient(to bottom, #000 0 250px, transparent 250px 290px); mask: repeating-linear-gradient(to bottom, #000 0 250px, transparent 250px 290px);
}
@keyframes m-shimmer { from { background-position: 200% 0, 0 0; } to { background-position: -200% 0, 0 0; } }

/* ---- figures and headlines */
:where(table, td, th, output, time, meter, progress, .num, .n, .big, .stat, .count, .elo, .rating, .score, .hcount, [class*="count"], [class*="stat-"], [class*="-stat"], [class*="score"], [class*="rating"]) { font-variant-numeric: tabular-nums; }
:where(h1, h2, h3, .intro) { text-wrap: balance; }
:where(p, li) { text-wrap: pretty; }

/* ---- one clear main action: a page's primary button carries the weight, the rest step back */
:where(main, .mk-hub, form) :where(button.primary, .button.primary, button[type="submit"]:not(.quiet):not(.secondary):not(.danger)) { font-weight: 700; }

/* ---- eyebrows that only repeat the page's name are dropped; the mono face is for data */
:where(.mk-eyebrow, .workspace-eyebrow, .portal-eyebrow, .eyebrow):has(+ h1) { display: none; }
:where(.workspace-eyebrow, .eyebrow, .mk-eyebrow) { font-family: inherit; letter-spacing: .08em; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0s !important; transition-duration: .001ms !important; }
  :where(button, .button, [role="button"]):active { scale: none; }
  :where(main) table:empty, .mk-saved-grid:empty, .card-grid[aria-busy="true"], [data-loading="1"] { animation: none; }
}
html[data-motion="reduce"] :where(button, .button, [role="button"]):active { scale: none; }
html[data-motion="reduce"] * { animation-delay: 0s !important; }
