/* ─────────────────────────────────────────────────────────────────────────────
   Standard Group — motion layer (v52)

   Additive only. This file changes no colour, type, spacing or layout: it adds
   timing and depth on top of the approved design. Load it AFTER site.css and
   theme.css:
       <link rel="stylesheet" href="assets/motion.css">

   Every effect is off under prefers-reduced-motion. site.css already kills
   transitions and animations globally in that mode; view transitions and
   scroll-driven timelines are not covered by that rule, so they are switched
   off explicitly at the end of this file.
   ───────────────────────────────────────────────────────────────────────────── */

/* ── 1. Cross-page transitions ───────────────────────────────────────────────
   The site is multi-page, so each link click is a full navigation and lands
   as a hard cut. A short cross-fade makes the pages feel like one product.
   Browsers without the feature simply navigate as before. */
@view-transition { navigation: auto; }

@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(root) { animation: sg-vt-out .20s cubic-bezier(.4,0,1,1) both; }
  ::view-transition-new(root) { animation: sg-vt-in  .26s cubic-bezier(0,0,.2,1) both; }

  /* The header and footer are identical between pages, so they are held still
     while the body cross-fades. Without this they fade with everything else
     and the chrome appears to flicker on every click. */
  #site-header { view-transition-name: sg-header; }
  #site-footer { view-transition-name: sg-footer; }
  ::view-transition-group(sg-header),
  ::view-transition-group(sg-footer) { animation-duration: .01s; }
}

@keyframes sg-vt-out { from { opacity: 1 } to { opacity: 0 } }
@keyframes sg-vt-in  { from { opacity: 0; transform: translateY(6px) } to { opacity: 1; transform: none } }


/* ── 2. Reveal, refined ──────────────────────────────────────────────────────
   site.css already fades panels in on scroll. This sharpens the curve and adds
   a trace of scale so the movement reads as depth rather than a slide. */
@media (prefers-reduced-motion: no-preference) {
  .reveal {
    transition:
      opacity .55s cubic-bezier(.22,.61,.36,1),
      transform .66s cubic-bezier(.22,1,.30,1);
    will-change: opacity, transform;
  }
  .reveal:not(.in) { transform: translateY(16px) scale(.992); }
  .reveal.in { will-change: auto; }

  /* Cards drawn from the database arrive without a data-delay, so they all
     appeared at once. Stagger them from the markup instead. */
  .sg-stagger > * { transition-delay: calc(var(--sg-i, 0) * 70ms); }
}


/* ── 3. Depth on the hero art ────────────────────────────────────────────────
   The generated mesh behind the cover drifts a little slower than the page as
   it scrolls away. Scroll-driven, so it costs no JavaScript and cannot jitter
   against the scroll. Applied only where the browser supports it. */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) and (min-width: 880px) {
    .cover::before {
      animation: sg-drift linear both;
      animation-timeline: view();
      animation-range: entry 0% exit 100%;
    }
  }
}
@keyframes sg-drift {
  from { transform: translateY(-2.2%) scale(1.035) }
  to   { transform: translateY(3.4%)  scale(1.035) }
}


/* ── 4. Micro-interactions ───────────────────────────────────────────────────
   Pressed feedback on the things people actually click. Touch devices get the
   press state; it is the only affordance they have, since there is no hover. */
@media (prefers-reduced-motion: no-preference) {
  .btn, .quick-item, .pcard, .inst-card, .course-card, .icard, .pil {
    transition-timing-function: cubic-bezier(.2,.7,.2,1);
  }
  .btn:active, .quick-item:active, .pcard:active,
  .inst-card:active, .course-card:active, .icard:active { transform: scale(.985); }

  /* The arrow already shifts on hover; carry it through on keyboard focus so
     the two states match. */
  .btn:focus-visible .arr { transform: translateX(3px); }
}


/* ── 5. Reduced motion ──────────────────────────────────────────────────────
   site.css disables transitions and animations; these two are separate
   mechanisms and have to be named. */
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  .reveal, .reveal:not(.in) { opacity: 1; transform: none; transition: none; }
  .sg-stagger > * { transition-delay: 0s; }
  .cover::before { animation: none; }
}

/* Language control for portal screens that never had one. Sits clear of the
   page's own toolbars, and out of the way of the print layout. */
.sg-lang-fab{position:fixed;right:16px;bottom:16px;z-index:60;
  min-width:52px;min-height:44px;padding:10px 16px;
  font:inherit;font-size:.85rem;font-weight:700;line-height:1;cursor:pointer;
  color:var(--sg-neutral-0,#fff);background:var(--sg-teal-700,#136464);
  border:1px solid rgba(255,255,255,.22);border-radius:999px;
  box-shadow:0 6px 20px rgba(19,100,100,.28)}
.sg-lang-fab:hover{background:var(--sg-teal-500,#209C9C)}
.sg-lang-fab:focus-visible{outline:3px solid var(--focus,#FC803C);outline-offset:3px}
@media print{.sg-lang-fab{display:none}}
