/* SILACOD polish layer — shared UI/UX "feel" upgrades loaded last on every page (homepage, agent, studio, dashboard, login, signup).
   It adds behaviour, not a new look: SILACOD colours, fonts and layouts stay as they are.
   Sources: Chrome web-UI notes (linear() springs, @starting-style, view transitions), Emil Kowalski's design-engineering
   numbers (press .97, ~160 ms, strong ease-out, enter from .95 not 0), Rauno Freiberg's interface guidelines, WCAG focus rules. */
:root {
  --sp-ease: cubic-bezier(.23, 1, .32, 1);                       /* strong ease-out for UI (the built-in "ease" is too weak) */
  --sp-spring: linear(0, .071, .234, .432, .625, .79, .917, 1.003, 1.055, 1.079, 1.083, 1.075, 1.06, 1.043, 1.028, 1.015, 1.005, .998, .995, .993, .993, .994, .995, .997, .998, .999, 1);   /* damped spring ζ .62 */
  --sp-snap: linear(0, .097, .298, .514, .7, .839, .933, .989, 1.017, 1.027, 1.028, 1.023, 1.017, 1.011, 1.006, 1.003, 1.001, 1);                                                        /* stiffer spring ζ .75 */
  --sp-ring: #f06343;
}

/* 1 · typography details */
h1, h2, h3, h4 { text-wrap: balance; }                           /* no lonely last word in headlines */
p, li, summary, small { text-wrap: pretty; }
.kpi b, .kpi em, .ax-t td, .au-stats b, .st-stats b, .lat, [data-num] { font-variant-numeric: tabular-nums; }   /* digits don't jitter while counting */
::selection { background: rgba(240, 99, 67, .28); color: inherit; }

/* 2 · touch: no grey flash, no 300 ms double-tap delay, no accidental text selection on controls */
a, button, summary, label, select, [role="button"], [role="switch"], [role="tab"] { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button, .btn, [role="switch"], [role="tab"], .seg, .chip, .tb-it, nav a { -webkit-user-select: none; user-select: none; }

/* 3 · keyboard focus: a clear coral ring for keyboard users only (mouse clicks show nothing) */
:focus-visible { outline: 2px solid var(--sp-ring) !important; outline-offset: 3px; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline-offset: 1px; }
.ap-search:focus-within, .st-comp:focus-within, .inp:focus-within, .ag-in:focus-within { box-shadow: 0 0 0 2px rgba(240, 99, 67, .55), 0 0 0 6px rgba(240, 99, 67, .12); }
.ax-in:focus, .ag-in input:focus { border-color: var(--sp-ring); box-shadow: 0 0 0 4px rgba(240, 99, 67, .14); }

/* 4 · things that appear now enter instead of popping (@starting-style; older browsers just show them) */
.modal.on { transition: opacity .22s var(--sp-ease); }
.modal.on > * { transition: scale .42s var(--sp-snap), opacity .22s var(--sp-ease); transform-origin: 50% 60%; }
@starting-style { .modal.on { opacity: 0; } .modal.on > * { scale: .95; opacity: 0; } }
.toast { transition: opacity .22s var(--sp-ease), transform .5s var(--sp-spring) !important; }
nav.top .lang ul, .ap-lang + ul { transform-origin: top; }

/* 5 · FAQ / accordions: the answer fades and slides in when opened (sila-polish.js); the arrow turns on a spring.
   No height animation, so an answer can never be left clipped if the browser pauses frames. */
summary::after { transition: rotate .35s var(--sp-snap); }
details[open] summary::after { rotate: 180deg; }

/* 6 · switches and segmented tabs move on a spring */
.sw::after { transition: inset-inline-start .45s var(--sp-snap), inset-inline-end .45s var(--sp-snap), background-color .2s !important; }
.sw { transition: background-color .3s var(--sp-ease); }
.seg button { transition: background-color .25s var(--sp-ease), color .25s var(--sp-ease); }

/* 7 · dashboard cards: a soft coral light follows the pointer along the border (mouse / pen only) */
@media (hover: hover) and (pointer: fine) {
  .ap .card { position: relative; }
  .ap .card::after { content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none; opacity: 0; transition: opacity .35s var(--sp-ease);
    background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 50%), rgba(240, 99, 67, .55), rgba(139, 108, 255, .25) 45%, transparent 70%);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; }
  .ap .card.sp-lit::after { opacity: 1; }
}

/* 8 · page-to-page: a short cross-fade + lift instead of a white flash (Chrome/Edge 126+, Safari 18.2+; others navigate normally) */
@view-transition { navigation: auto; }
nav.top { view-transition-name: sila-nav; }
::view-transition-old(root) { animation: spOut .22s var(--sp-ease) both; }
::view-transition-new(root) { animation: spIn .42s var(--sp-ease) both; }
@keyframes spOut { to { opacity: 0; transform: translateY(-8px); } }
@keyframes spIn { from { opacity: 0; transform: translateY(14px); } }

/* 9 · reduced motion: keep every state change, drop the movement */
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
  .modal.on > *, .toast, .sw::after, summary::after { transition-duration: 0s !important; }
}
/* inputs that sit inside a field box which already draws its own rounded focus ring: no second, square outline on the input itself */
:is(.inp, .sva-comp, .ap-search, .st-comp, .ag-in, .row) > input:focus-visible { outline: none !important; }
.sva-comp:focus-within { border-color: rgba(240,99,67,.6); }

/* phone menu (sila-polish.js §5): the top bar hides its links below 1180 px, this button brings them back */
.sm-btn { display: none; width: 44px; height: 44px; flex: none; place-items: center; border-radius: 50%; border: 1px solid rgba(255,255,255,.16); background: transparent; color: inherit; cursor: pointer; }
.sm-btn span { display: grid; gap: 5px; width: 18px; }
.sm-btn i { display: block; height: 2px; border-radius: 2px; background: currentColor; transition: transform .2s ease; }
.sm-btn[aria-expanded="true"] i:first-child { transform: translateY(3.5px) rotate(45deg); }
.sm-btn[aria-expanded="true"] i:last-child { transform: translateY(-3.5px) rotate(-45deg); }
.sm-panel { position: absolute; top: calc(100% + 10px); inset-inline: 0; display: grid; gap: 2px; padding: 8px; border-radius: 22px; border: 1px solid rgba(255,255,255,.12); background: #0c0e30; color: #fff; box-shadow: 0 24px 60px -20px rgba(0,0,0,.7); }
.sm-panel[hidden] { display: none; }
.sm-panel a, .sm-panel button { display: flex; align-items: center; width: 100%; min-height: 48px; padding: 0 16px; border: 0; border-radius: 14px; background: transparent; color: inherit; font: inherit; font-size: 16px; font-weight: 700; text-align: start; cursor: pointer; transition: background .15s ease; }
.sm-panel a:hover, .sm-panel button:hover, .sm-panel a.on { background: rgba(255,255,255,.08); }
html[data-theme="light"] .sm-btn { border-color: rgba(15,23,42,.14); }
html[data-theme="light"] .sm-panel { background: #fff; color: #0f172a; border-color: rgba(15,23,42,.08); box-shadow: 0 24px 60px -24px rgba(17,19,68,.35); }
html[data-theme="light"] .sm-panel a:hover, html[data-theme="light"] .sm-panel button:hover, html[data-theme="light"] .sm-panel a.on { background: rgba(35,40,99,.07); }
@media (max-width: 1180px) { .sm-btn { display: grid; } }
@media (prefers-reduced-motion: reduce) { .sm-btn i, .sm-panel a, .sm-panel button { transition: none; } }

/* Appearance control sits opposite the page's playback controls. */
html .theme-btn.floating-theme {
  --theme-safe-start: env(safe-area-inset-left, 0px);
  position: fixed;
  z-index: 50;
  inset-inline-start: calc(14px + var(--theme-safe-start));
  inset-block-end: calc(14px + env(safe-area-inset-bottom, 0px));
  padding: 0;
  border: 1px solid #666b9c;
  background: #1a1e46;
  color: #f3f1ff;
}
html[dir="rtl"] .theme-btn.floating-theme { --theme-safe-start: env(safe-area-inset-right, 0px); }
html .theme-btn.floating-theme:hover { background: #2a2f5b; }
html[data-theme="light"] .theme-btn.floating-theme { border-color: #b3b7d4; background: #f8f8ff; color: #1a1e46; }
html[data-theme="light"] .theme-btn.floating-theme:hover { background: #e9eafb; }
.floating-theme:focus-visible { outline: 2px solid #7782cf; outline-offset: 3px; }
@media (max-width: 600px) {
  html .theme-btn.floating-theme { inset-block-end: calc(40px + env(safe-area-inset-bottom, 0px)); }
}
