/* Strateon UI 3 — motion and interaction states (hover, focus, open/close).
   Load AFTER tokens.css and strateon-ui.css. Character: "motion like a drafting table":
   calm, precise, reversible. Only horizontal or vertical movement; no rotation, bounce,
   scaling or blur. One thing moves at a time. Short distances: 4 / 12 / 24 px.
   On the platforms there are NO scroll-triggered reveals; only the content area fades on view change. */

:root {
  --motion-1: 120ms;  /* tone, colour, border, row background — always linear */
  --motion-2: 240ms;  /* hover wipe, underline, arrow nudge, small states, any exit */
  --motion-3: 400ms;  /* panels, menus, sheets, tab underline, toast, theme change */
  --motion-4: 640ms;  /* block appearing, progress */
  --motion-5: 960ms;  /* line drawing (rare on platforms) */
  --ease-arrive: cubic-bezier(0.22, 1, 0.36, 1);   /* default: fast start, long quiet end */
  --ease-move: cubic-bezier(0.65, 0, 0.35, 1);     /* from one place to another */
  --ease-leave: cubic-bezier(0.55, 0, 0.75, 0.2);  /* exits only */
  --stagger: 60ms;
  --dist-1: 4px; --dist-2: 12px; --dist-3: 24px;
}
@media (prefers-reduced-motion: reduce) {
  :root { --motion-2: 1ms; --motion-3: 1ms; --motion-4: 120ms; --motion-5: 120ms; --dist-1: 0px; --dist-2: 0px; --dist-3: 0px; --stagger: 0ms; }
}

/* ---------- Buttons ---------- */

/* Primary: tone darkens (120 ms linear), arrow nudges 4 px (240 ms arrive) */
.st-btn--primary { transition: background-color var(--motion-1) linear; }
.st-arrow { display: inline-block; transition: transform var(--motion-2) var(--ease-arrive); }
.st-btn:hover .st-arrow, .st-btn:focus-visible .st-arrow, a.st-row:hover .st-arrow { transform: translateX(var(--dist-1)); }

/* Secondary (outlined): the fill WIPES in from the left and back out to the left (240 ms arrive).
   Wrap the label in <span> so the text colour flips exactly at the fill edge:
   <button class="st-btn st-btn--secondary"><span>Võta ühendust</span></button> */
.st-btn--secondary {
  --p: 100%;
  border-color: var(--action);
  background-color: transparent;
  background-image: linear-gradient(90deg, transparent 33.34%, var(--action) 33.34% 66.66%, transparent 66.66%);
  background-size: 300% 100%; background-repeat: no-repeat; background-position: var(--p) 0;
  transition: background-position var(--motion-2) var(--ease-arrive);
}
.st-btn--secondary > span {
  display: inline-flex; align-items: center; gap: var(--space-2);
  background-image: linear-gradient(90deg, var(--ink) 33.34%, var(--on-action) 33.34% 66.66%, var(--ink) 66.66%);
  background-size: 300% 100%; background-repeat: no-repeat; background-position: var(--p) 0;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  transition: background-position var(--motion-2) var(--ease-arrive);
}
.st-btn--secondary:hover, .st-btn--secondary:focus-visible { --p: 50%; background-color: transparent; }
/* Without a <span> the text still flips, just as a plain colour change */
.st-btn--secondary:not(:has(> span)) { transition: background-position var(--motion-2) var(--ease-arrive), color var(--motion-2) linear; }
.st-btn--secondary:not(:has(> span)):hover, .st-btn--secondary:not(:has(> span)):focus-visible { color: var(--on-action); }
.st-btn--secondary svg { stroke: currentColor; }

/* Quiet button and inline links: underline colour/weight change (120 ms) */
.st-btn--quiet, .st-link { transition: text-decoration-color var(--motion-1) linear, color var(--motion-1) linear; }

/* ---------- Lines: navigation links and card titles draw a 1 px line from the left ---------- */
.st-topbar__link { position: relative; transition: color var(--motion-1) linear; }
.st-topbar__link:not([aria-current])::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 18px; height: 1px; background: currentColor;
  transform: scaleX(0); transform-origin: left; transition: transform var(--motion-2) var(--ease-arrive);
}
.st-topbar__link:not([aria-current]):hover::after, .st-topbar__link:not([aria-current]):focus-visible::after { transform: scaleX(1); }

.st-card__title { position: relative; display: inline; background-image: linear-gradient(currentColor, currentColor); background-size: 0% 1px; background-position: 0 100%; background-repeat: no-repeat; transition: background-size var(--motion-2) var(--ease-arrive); }
.st-card:hover .st-card__title, .st-card:focus-visible .st-card__title { text-decoration: none; background-size: 100% 1px; }
.st-card__media img { transition: none; } /* photos never zoom */

/* ---------- Surfaces change only their tone (120 ms linear) ---------- */
a.st-row { transition: background-color var(--motion-1) linear; }
a.st-row:hover { background-color: var(--bg-sunk); }
a.st-row:hover .st-row__title { text-decoration: none; }
a.st-row > svg:last-child, a.st-row > .st-icon:last-child { transition: transform var(--motion-2) var(--ease-arrive), color var(--motion-1) linear; color: var(--ink-3); }
a.st-row:hover > svg:last-child, a.st-row:hover > .st-icon:last-child { transform: translateX(var(--dist-1)); color: var(--ink); }

.st-sidenav__item, .st-table td, .st-vote__btn, .st-tag, .st-tab, .st-themeswitch__opt,
.st-tabbar__item, .st-setting, .st-avatar { transition: background-color var(--motion-1) linear, color var(--motion-1) linear, border-color var(--motion-1) linear; }
.st-input { transition: border-color var(--motion-1) linear, box-shadow var(--motion-1) linear; }
.st-input:hover:not(:focus) { border-color: var(--ink-3); }
a.st-setting:hover, button.st-setting:hover { color: var(--action); }

/* ---------- Tabs: the 2 px line SLIDES to the new tab (400 ms move). strateon-motion.js adds the indicator. ---------- */
.st-tabs { position: relative; }
.st-tabs.has-ind .st-tab[aria-selected="true"] { border-bottom-color: transparent; }
.st-tabs__ind { position: absolute; left: 0; bottom: -1px; height: 2px; width: 100px; background: var(--action); transform-origin: left; pointer-events: none; transition: transform var(--motion-3) var(--ease-move); }

/* ---------- Disclosure: details opening under a row / timeline step (400 ms move) ---------- */
.st-disclosure { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--motion-3) var(--ease-move); }
.st-disclosure > * { overflow: hidden; min-height: 0; opacity: 0; transition: opacity var(--motion-2) linear; }
.st-disclosure.is-open { grid-template-rows: 1fr; }
.st-disclosure.is-open > * { opacity: 1; transition-delay: 80ms; }
.st-plus { position: relative; width: 12px; height: 12px; display: inline-block; }
.st-plus::before, .st-plus::after { content: ""; position: absolute; background: currentColor; }
.st-plus::before { left: 0; right: 0; top: 5.5px; height: 1px; }
.st-plus::after { top: 0; bottom: 0; left: 5.5px; width: 1px; transition: transform var(--motion-2) var(--ease-move); }
[aria-expanded="true"] .st-plus::after { transform: scaleY(0); }

/* ---------- Floating layers: arrive with arrive-curve, leave ⅓ faster with leave-curve ---------- */
/* Menu (avatar menu, dropdowns): fades in and drops 4 px */
.st-menu { transition: opacity var(--motion-2) var(--ease-arrive), transform var(--motion-2) var(--ease-arrive), display var(--motion-2) allow-discrete; }
@starting-style { .st-menu { opacity: 0; transform: translateY(calc(var(--dist-1) * -1)); } }
.st-menu.is-closing { opacity: 0; transform: translateY(calc(var(--dist-1) * -1)); transition-duration: var(--motion-1); transition-timing-function: var(--ease-leave); }

/* Bottom sheet: slides up 400 ms move, down 240 ms leave. Scrim fades. */
.st-sheet { transition: transform var(--motion-3) var(--ease-move); }
@starting-style { .st-sheet { transform: translateY(100%); } }
.st-sheet.is-closing { transform: translateY(100%); transition: transform var(--motion-2) var(--ease-leave); }
.st-scrim { transition: opacity var(--motion-2) linear; }
@starting-style { .st-scrim { opacity: 0; } }
.st-scrim.is-closing { opacity: 0; }

/* Toast: rises 12 px (400 ms arrive), leaves 4 px (240 ms leave) */
.st-toast { transition: opacity var(--motion-3) var(--ease-arrive), transform var(--motion-3) var(--ease-arrive); }
@starting-style { .st-toast { opacity: 0; transform: translateY(var(--dist-2)); } }
.st-toast.is-closing { opacity: 0; transform: translateY(var(--dist-1)); transition-duration: var(--motion-2); transition-timing-function: var(--ease-leave); }

/* ---------- Progress fills smoothly (640 ms move) ---------- */
.st-progress__fill { transition: width var(--motion-4) var(--ease-move); }

/* ---------- Checkbox tick draws itself (240 ms arrive, 60 ms delay) ---------- */
.st-check { display: inline-flex; align-items: center; gap: var(--space-3); cursor: pointer; }
.st-check__box { width: 20px; height: 20px; border: 1px solid var(--line-strong); display: inline-flex; align-items: center; justify-content: center; transition: background-color var(--motion-1) linear, border-color var(--motion-1) linear; }
.st-check__box svg { width: 14px; height: 14px; fill: none; stroke: var(--on-action); stroke-width: 1.5; stroke-dasharray: 20; stroke-dashoffset: 20; transition: stroke-dashoffset var(--motion-2) var(--ease-arrive); }
.st-check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.st-check input:checked + .st-check__box { background: var(--action); border-color: var(--action); }
.st-check input:checked + .st-check__box svg { stroke-dashoffset: 0; transition-delay: 60ms; }
.st-check input:focus-visible + .st-check__box { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- Loading: a travelling 1 px line, never a spinning wheel ---------- */
.st-loading { position: relative; height: 1px; background: var(--line); overflow: hidden; }
.st-loading::after { content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 25%; background: var(--action); animation: st-travel 1200ms var(--ease-move) infinite; }
@keyframes st-travel { from { transform: translateX(-100%); } to { transform: translateX(400%); } }
@media (prefers-reduced-motion: reduce) { .st-loading::after { animation: none; width: 100%; opacity: 0.5; } }

/* ---------- View change on the platform: only the content area fades (240 ms). No scroll reveals. ---------- */
.st-view { animation: st-fade var(--motion-2) linear both; }
@keyframes st-fade { from { opacity: 0; } }

/* ---------- Theme change: whole page cross-fades 400 ms ---------- */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 400ms; animation-timing-function: var(--ease-move); }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: 120ms; animation-timing-function: linear; }
}

/* ---------- Touch screens: no sticky hover tones ---------- */
@media (hover: none) {
  a.st-row:hover { background-color: transparent; }
  .st-btn--secondary:hover { --p: 100%; }
  .st-btn--secondary:active { --p: 50%; }
  a.st-row:active { background-color: var(--bg-sunk); }
}
