/* Motion for the docs site.

   Principles (apple-design, emil-design-eng, impeccable animate):
   - This is a reference tool people open many times a day. Routine navigation never animates. There is one authored
     moment (the entrance after sign-in, once per browser tab) and a few quiet state changes.
   - Only transform and opacity move. Entrances decelerate (ease-out), none bounces, nothing is slower than 440 ms.
   - Reduced motion keeps a short cross-fade and drops all movement.
   The gate splash and the "can't reach the sign-in service" message are in overrides/main.html (they must exist before
   any stylesheet has loaded). */

:root {
  --pt-ease-emph: cubic-bezier(0.16, 1, 0.3, 1);   /* confident arrival */
}

/* ── 1. Entrance: the first page shown in a tab (class set by the gate script, removed after 1.2 s) ── */

@keyframes pt-rise { from { opacity: 0; transform: translate3d(0, 10px, 0); } to { opacity: 1; transform: none; } }
@keyframes pt-drop { from { opacity: 0; transform: translate3d(0, -6px, 0); } to { opacity: 1; transform: none; } }
@keyframes pt-fade { from { opacity: 0; } to { opacity: 1; } }

/* Chrome first (it comes from above), then the article from below, then the side lists fade in without moving
   (they are sticky, so they must not shift against the page). Total about 540 ms. */
html.pt-intro .pt-topbar,
html.pt-intro .md-header {
  animation: pt-drop 320ms var(--pt-ease-emph) both;
}

html.pt-intro .md-sidebar--primary { animation: pt-fade 380ms var(--pt-ease-emph) 80ms both; }
html.pt-intro .md-sidebar--secondary { animation: pt-fade 380ms var(--pt-ease-emph) 160ms both; }
html.pt-intro .md-content__inner { animation: pt-rise 440ms var(--pt-ease-emph) 60ms both; }

/* Home has no card: its blocks arrive one after another instead (the intro, the section cards, what's new). */
html.pt-intro .md-content__inner:has(.pt-home-marker) { animation: none; }
html.pt-intro .md-content__inner:has(.pt-home-marker) > * { animation: pt-rise 420ms var(--pt-ease-emph) both; }
html.pt-intro .md-content__inner:has(.pt-home-marker) > :nth-child(2) { animation-delay: 50ms; }
html.pt-intro .md-content__inner:has(.pt-home-marker) > :nth-child(3) { animation-delay: 100ms; }
html.pt-intro .md-content__inner:has(.pt-home-marker) > :nth-child(4) { animation-delay: 150ms; }
html.pt-intro .md-content__inner:has(.pt-home-marker) > :nth-child(5) { animation-delay: 200ms; }
html.pt-intro .md-content__inner:has(.pt-home-marker) > :nth-child(n + 6) { animation-delay: 250ms; }

/* ── 2. "Endpoints at a glance" opens and closes smoothly where the browser can animate <details> (Chromium 131+) ── */

@supports (interpolate-size: allow-keywords) {
  .md-typeset details.pt-endpoint-summary { interpolate-size: allow-keywords; }

  .md-typeset details.pt-endpoint-summary::details-content {
    block-size: 0;
    overflow: clip;
    transition: block-size 220ms var(--pt-ease-out), content-visibility 220ms var(--pt-ease-out) allow-discrete;
  }

  .md-typeset details.pt-endpoint-summary[open]::details-content { block-size: auto; }
}

/* ── 3. Light and dark: the whole page cross-fades once (View Transitions, started by javascripts/motion.js) ── */

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 260ms;
  animation-timing-function: var(--pt-ease-out);
}

/* ── 4. Press feedback on the header controls (on pointer down, not on release) ── */

.md-header__button,
.md-search__icon {
  transition: transform 100ms var(--pt-ease-out), color 120ms var(--pt-ease-out), background-color 120ms var(--pt-ease-out);
}

.md-header__button:active { transform: scale(0.92); }

/* ── 5. Material: once the page has scrolled, the header becomes a translucent layer with the content passing under it ── */

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .md-header { transition: background-color 200ms var(--pt-ease-out); }

  .md-header--shadow {
    background-color: color-mix(in srgb, var(--pt-bg) 82%, transparent);
    -webkit-backdrop-filter: blur(18px) saturate(1.5);
    backdrop-filter: blur(18px) saturate(1.5);
  }

  /* The tab row sits inside the header: let the same material show through it */
  .md-header--shadow .md-tabs { background-color: transparent; }
}

@media (prefers-reduced-transparency: reduce) {
  .md-header--shadow {
    background-color: var(--pt-bg);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

/* ── Reduced motion: a short cross-fade, no movement ── */

@media (prefers-reduced-motion: reduce) {
  html.pt-intro .pt-topbar,
  html.pt-intro .md-header,
  html.pt-intro .md-sidebar--primary,
  html.pt-intro .md-sidebar--secondary,
  html.pt-intro .md-content__inner,
  html.pt-intro .md-content__inner:has(.pt-home-marker) > * {
    animation-name: pt-fade !important;
    animation-duration: 160ms !important;
    animation-delay: 0ms !important;
  }

  .md-header__button:active { transform: none; }
}
