/* webkit/native.css v1 (kit, LUAT 67) — shared mechanics only: easings, scroll-driven art helpers, popover/toast entry-exit, text-wrap classes. Vietnamese kit comments stripped for the English-only site. */
:where(:root) {
  --ease-out-soft: cubic-bezier(.2, .8, .2, 1);
  --ease-in-soft: cubic-bezier(.4, 0, 1, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --ease-bounce: cubic-bezier(.34, 1.56, .64, 1);
}
@supports (transition-timing-function: linear(0, 1)) {
  :where(:root) {
    /* soft spring: one overshoot (~16 %) then settles — buttons, cards, toasts */
    --ease-spring: linear(0, 0.009, 0.035 2.1%, 0.141, 0.281 6.7%, 0.723 12.9%, 0.938 16.7%, 1.017, 1.077, 1.121, 1.149 24.3%, 1.159, 1.163, 1.161, 1.154 29.9%, 1.129 32.8%, 1.051 39.6%, 1.017 43.1%, 0.991, 0.977 51%, 0.974 53.8%, 0.975 57.1%, 0.997 69.8%, 1.003 76.9%, 1.004 83.8%, 1);
    /* bounce: lands, bounces twice — stamps, drops, counters that "hit" */
    --ease-bounce: linear(0, 0.214 14.7%, 0.386 23.7%, 0.598 31.9%, 0.999 44.7%, 0.807 52.6%, 0.762 56%, 0.747 59.4%, 0.758 62.4%, 0.793 65.6%, 0.999 77.4%, 0.961 81.2%, 0.949 84.8%, 0.956 88%, 0.993 95.5%, 1);
  }
}

/* 2. TYPE — opt-in only (guide visual-design/improve-text-layout-and-legibility). pretty = no orphan word on the last line of a
   paragraph (Chrome/Safari; Firefox ignores it). Suggested in app.css: main p, main li { text-wrap: pretty } */
.tw-pretty { text-wrap: pretty; }
.tw-balance { text-wrap: balance; }

/* 3. ROUTE CHANGE — router v3 injects the defaults (260 ms plus-lighter cross-fade, the new page slides 18px in the travel
   direction; fixed/sticky header/rail and [data-rt-keep] stay still). Override in app.css, e.g.:
     :root { --rt-nudge: 40px; --rt-dur: 360ms } html[data-rt-dir=back] { --rt-nudge: -40px }
   Keep old and new on the same duration + easing (that is what --rt-dur does): unequal fades dim the page mid-way.
   Direction: html[data-rt-dir=forward|back] during the transition (+ :active-view-transition-type(forward|back) where supported).
   Morph one element across routes (guide ui-behaviors/same-document-transitions): give ONE element per page a unique
   view-transition-name in app.css (e.g. the route title { view-transition-name: page-title }). Window.__ROUTER_VT__ = false = off. */

/* 4. SCROLL-DRIVEN — Baseline newly 2026-10-27 ⇒ always behind @supports, transform only (guides ui-behaviors/parallax-scroll-effects,
   scroll-entry-exit-effects, ui-atoms/scroll-progress-indicator). Without support nothing moves and everything stays visible. */
@media (prefers-reduced-motion: no-preference) {
  @supports ((animation-timeline: view()) and (animation-range: entry)) {
    /* parallax drift of an art plate/object while it crosses the viewport: --sd-from / --sd-to (default -40px → 40px) */
    .sd-parallax { animation: sd-drift linear both; animation-timeline: view(); animation-range: cover; }
    @keyframes sd-drift { from { translate: 0 var(--sd-from, -40px); } to { translate: 0 var(--sd-to, 40px); } }
    /* slow tilt of a hero object while it is on screen: --sd-tilt-from / --sd-tilt-to (default -3deg → 3deg) */
    .sd-tilt { animation: sd-tilt linear both; animation-timeline: view(); animation-range: cover; }
    @keyframes sd-tilt { from { rotate: var(--sd-tilt-from, -3deg); } to { rotate: var(--sd-tilt-to, 3deg); } }
    /* grows to full size as it enters (never below --sd-zoom-from, default .94 — it stays readable even mid-entry) */
    .sd-zoom { animation: sd-zoom linear both; animation-timeline: view(); animation-range: entry 0% entry 100%; }
    @keyframes sd-zoom { from { scale: var(--sd-zoom-from, .94); } to { scale: 1; } }
    /* page reading progress: put <div class="sd-progress" aria-hidden="true"></div> once in the shell (outside <main>) */
    .sd-progress { position: fixed; inset: 0 0 auto 0; height: var(--sd-progress-h, 3px); background: var(--sd-progress-color, currentColor);
      transform-origin: 0 50%; transform: scaleX(0); z-index: 60; pointer-events: none;
      animation: sd-progress linear both; animation-timeline: scroll(root block); }
    @keyframes sd-progress { to { transform: scaleX(1); } }
  }
}

/* 5. THINGS THAT APPEAR — popover / dialog / toast entry + exit with @starting-style (Baseline newly 2024-08; guides
   ui-behaviors/animate-element-entry-exit, ui-components/dialog, ui-components/persistent-toast-notifications). Add class .ui-pop
   to a [popover] or <dialog>, .ui-toast to an element shown/hidden with the hidden attribute. */
@media (prefers-reduced-motion: no-preference) {
  [popover].ui-pop, dialog.ui-pop {
    transition: opacity .2s var(--ease-out-soft), translate .24s var(--ease-out-soft), overlay .24s, display .24s;
    transition-behavior: allow-discrete;
  }
  [popover].ui-pop:popover-open, dialog.ui-pop[open] { opacity: 1; translate: 0 0; }
  [popover].ui-pop:not(:popover-open), dialog.ui-pop:not([open]) { opacity: 0; translate: 0 var(--pop-rise, 8px); }
  @starting-style { [popover].ui-pop:popover-open, dialog.ui-pop[open] { opacity: 0; translate: 0 var(--pop-rise, 8px); } }
  dialog.ui-pop::backdrop { background-color: rgb(0 0 0 / 0); transition: background-color .24s, overlay .24s, display .24s; transition-behavior: allow-discrete; }
  dialog.ui-pop[open]::backdrop { background-color: var(--pop-backdrop, rgb(0 0 0 / .45)); }
  @starting-style { dialog.ui-pop[open]::backdrop { background-color: rgb(0 0 0 / 0); } }
  .ui-toast { transition: opacity .2s var(--ease-out-soft), translate .3s var(--ease-spring), display .3s; transition-behavior: allow-discrete; }
  .ui-toast[hidden] { display: none; opacity: 0; translate: 0 12px; }
  @starting-style { .ui-toast { opacity: 0; translate: 0 12px; } }
}

/* 6. NATIVE CONTROLS take the brand only when the shell sets the variables (no variable ⇒ browser default, nothing changes).
   Specificity 0 (:where) ⇒ any rule in app.css wins. Dark page ground: web_harden.py already adds <meta name="color-scheme" content="dark"> (scrollbars, select/date popups go dark). */
:where(:root) { accent-color: var(--native-accent, auto); scrollbar-color: var(--native-scroll-thumb, auto) var(--native-scroll-track, auto); }
