/* Kostoway — shared additions on top of the Kosto design system.
   Load order on every page:
     /static/assets/kosto/fonts.css
     /static/assets/kosto/base.css        (tokens, light + dark, buttons, shell, panels)
     /static/assets/kosto/<page css>      (docs.css | saas-site.css | saas-auth.css | saas-app.css ...)
     /static/assets/theme.css             (this file: small shared helpers only)
   Design language (from getkosto.com): warm paper ground, ink, ONE orange (--primary),
   1px borders instead of shadows, 8px radius, Bricolage Grotesque display + Hanken Grotesk text.
   Theme: <html data-theme="dark|light">, stored in localStorage "sp.theme" (common.js applies it). */

/* toast (prefixed so it never collides with Kosto's .toast) */
.sp-toast-host { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 100; max-width: min(440px, calc(100vw - 32px)); }
.sp-toast { padding: 10px 14px; border-radius: 6px; background: var(--ink); color: var(--bg); font: 600 13px/1.4 var(--font); animation: sp-toast-in .3s var(--ease); }
.sp-toast--err { background: var(--bad); color: #fff; }
@keyframes sp-toast-in { from { opacity: 0; transform: translateY(10px); } }

/* status dot + text */
.sp-status { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-size: 13px; white-space: nowrap; }
.sp-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.sp-status--ok { color: var(--v-ok); }
.sp-status--warn { color: var(--vi-warn); }
.sp-status--bad { color: var(--v-spam); }
.sp-status--idle { color: var(--muted); }

/* JSON highlight tokens used by SP.highlightJSON */
.tok-key { color: var(--c2-ink); } .tok-str { color: var(--c4-ink); } .tok-num { color: var(--primary-ink); } .tok-com { color: var(--muted); }

/* reveal helper (content stays visible without JS) */
.js .reveal { opacity: 0; transform: translateY(16px); transition: opacity .6s var(--ease), transform .6s var(--ease); transition-delay: var(--d, 0ms); }
.js .reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .js .reveal { opacity: 1; transform: none; transition: none; } }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- contrast fix (visual QA): white on orange failed WCAG AA ---- */
:root:not([data-theme="dark"]) { --primary: #c2410c; --primary-hover: #a8380a; --primary-ink: #9a3412; }
:root[data-theme="dark"] { --on-primary: #1a120b; }

/* ---- landing burger: no hover tilt; becomes an X when open ---- */
.sh-burger:hover svg, .sh-burger svg { transform: none !important; }

/* ---- room for the floating Telegram button ---- */
body.has-tg { padding-bottom: 88px; }
@media (max-width: 560px) { body.has-tg { padding-bottom: 76px; } }

/* =====================================================================
   Motion layer (shared). Transform + opacity only; everything is visible
   without JS and everything is disabled under prefers-reduced-motion.
   ===================================================================== */

/* -- 1. cross-page transitions (View Transitions API, same-origin MPA) -- */
@view-transition { navigation: auto; }
header.sh, header.au-head, header.dx-top { view-transition-name: site-header; }
main#main { view-transition-name: page; }
::view-transition-old(page) { animation: sp-page-out .22s cubic-bezier(.4, 0, 1, 1) both; }
::view-transition-new(page) { animation: sp-page-in .42s cubic-bezier(.16, 1, .3, 1) both; }
::view-transition-old(site-header), ::view-transition-new(site-header) { animation-duration: .3s; }
@keyframes sp-page-out { to { opacity: 0; transform: translateY(-10px); } }
@keyframes sp-page-in { from { opacity: 0; transform: translateY(14px); } }

/* fallback for browsers without cross-document view transitions (set by common.js) */
.sp-vt-fallback body { animation: sp-body-in .38s cubic-bezier(.16, 1, .3, 1) both; }
.sp-vt-fallback.sp-leaving body { opacity: 0; transform: translateY(-6px); transition: opacity .18s ease-in, transform .18s ease-in; }
@keyframes sp-body-in { from { opacity: 0; transform: translateY(8px); } }

/* -- 2. scroll reveal (common.js tags below-the-fold blocks) -- */
.js .sp-rv { opacity: 0; transform: translateY(22px); transition: opacity .7s cubic-bezier(.16, 1, .3, 1), transform .7s cubic-bezier(.16, 1, .3, 1); transition-delay: var(--rv-d, 0ms); }
.js .sp-rv.sp-in { opacity: 1; transform: none; }

/* reading progress bar (long pages) */
.sp-progress { position: fixed; inset: 0 0 auto 0; height: 2px; z-index: 120; background: var(--primary); transform-origin: 0 50%; transform: scaleX(0); pointer-events: none; }
@supports (animation-timeline: scroll()) {
  .sp-progress { animation: sp-progress linear both; animation-timeline: scroll(root); }
  @keyframes sp-progress { to { transform: scaleX(1); } }
}

/* -- 3. open / close -- */
dialog[open] { animation: sp-dlg-in .26s cubic-bezier(.16, 1, .3, 1); }
dialog[open]::backdrop { animation: sp-fade-in .26s ease-out; }
dialog.sp-closing { animation: sp-dlg-out .16s ease-in forwards; }
dialog.sp-closing::backdrop { animation: sp-fade-out .16s ease-in forwards; }
@keyframes sp-dlg-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }
@keyframes sp-dlg-out { to { opacity: 0; transform: translateY(6px) scale(.98); } }
@keyframes sp-fade-in { from { opacity: 0; } }
@keyframes sp-fade-out { to { opacity: 0; } }

/* accordions (FAQ, collapsible cards): smooth height where supported */
:root { interpolate-size: allow-keywords; }
details::details-content { block-size: 0; overflow: clip; transition: block-size .32s cubic-bezier(.16, 1, .3, 1), content-visibility .32s allow-discrete; }
details[open]::details-content { block-size: auto; }
details > summary { transition: color .15s; }

/* popovers / menus */
[popover]:popover-open { animation: sp-pop-in .18s cubic-bezier(.16, 1, .3, 1); }
@keyframes sp-pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

/* toast already animates in; animate out too */
.sp-toast.sp-out { opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; }

/* -- 4. micro-interactions -- */
.btn, button, .sp-tg { -webkit-tap-highlight-color: transparent; }
.btn:active, button:active:not(:disabled) { transform: translateY(1px) scale(.985); }
a, .btn, button { transition-property: color, background-color, border-color, transform, opacity, box-shadow; transition-duration: .18s; }
html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
  .js .sp-rv { opacity: 1 !important; transform: none !important; transition: none !important; }
  .sp-vt-fallback body, dialog[open], dialog[open]::backdrop, [popover]:popover-open { animation: none !important; }
  .sp-progress { display: none; }
  details::details-content { transition: none; }
  html { scroll-behavior: auto; }
}
