/* TGI motion layer (24 November 2026). Loaded after polish.css.
   Calm, purposeful motion: an entrance for the hero, staggered reveals,
   small hover cues, and the DICI / Solution Stack previews "coming alive".
   Only transform and opacity are animated on scroll so scrolling stays
   smooth, and everything is switched off for prefers-reduced-motion. */

/* Header gains a soft edge once the page scrolls (animate.js sets the class). */
.site-header { transition: box-shadow .3s ease; }
.site-header.is-scrolled { box-shadow: 0 8px 20px -16px rgba(30, 43, 69, .45); }

@media (prefers-reduced-motion: no-preference) {

  /* ---------- 1. Hero entrance (pure CSS, starts with first paint) ---------- */
  .story-hero .eyebrow,
  .story-hero h1,
  .story-hero .hero-support,
  .story-hero .hero-actions { animation: tgi-rise .8s cubic-bezier(.2, .7, .2, 1) both; }
  .story-hero h1 { animation-delay: .06s; }
  .story-hero .hero-support { animation-delay: .18s; }
  .story-hero .hero-actions { animation-delay: .3s; }

  /* The district unrolls from the village to the Collectorate. The left of the
     panorama is visible from the first frame, so nothing blinks. */
  .hero-world .world-panorama { animation: tgi-unroll 1.9s cubic-bezier(.45, .05, .2, 1) .1s both; }

  /* Reading progress along the bottom of the header (supporting browsers only). */
  @supports (animation-timeline: scroll()) {
    .site-header::after {
      content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
      background: var(--turmeric, #D69A2D); transform-origin: 0 50%; transform: scaleX(0);
      animation: tgi-progress linear both; animation-timeline: scroll(root); pointer-events: none;
    }
  }

  /* ---------- 2. Staggered reveals (motion.js adds .pre / .in) ---------- */
  .transfer-strip figure:nth-child(2).reveal.in,
  .success-grid article:nth-child(2).reveal.in,
  .three-doors a:nth-child(2).reveal.in,
  .part-card.part-1.reveal.in { transition-delay: .09s; transition-duration: .7s; }
  .transfer-strip figure:nth-child(3).reveal.in,
  .success-grid article:nth-child(3).reveal.in,
  .three-doors a:nth-child(3).reveal.in,
  .part-card.part-2.reveal.in { transition-delay: .18s; transition-duration: .7s; }

  /* ---------- 3. Hover cues ---------- */
  .button span[aria-hidden],
  .text-link span[aria-hidden],
  .part-link span[aria-hidden],
  .door-arrow { display: inline-block; transition: transform .25s cubic-bezier(.2, .7, .2, 1); }
  .button:hover span[aria-hidden], .button:focus-visible span[aria-hidden],
  .text-link:hover span[aria-hidden], .text-link:focus-visible span[aria-hidden],
  .part-link:hover span[aria-hidden],
  .product-card:hover .part-link span[aria-hidden],
  .three-doors a:hover .door-arrow, .three-doors a:focus-visible .door-arrow { transform: translate(3px, -3px); }

  .part-card .part-figure img { transition: transform .6s cubic-bezier(.2, .7, .2, 1); }
  .part-card:hover .part-figure img { transform: translateY(-6px); }
  .tool-chip { transition: transform .2s ease, border-color .2s ease, color .2s ease; }
  .tool-chip:hover { transform: translateY(-1px); }
  .product-card .screen { transition: transform .5s cubic-bezier(.2, .7, .2, 1); }
  .product-card:hover .screen { transform: translateY(-6px); }

  @media (min-width: 851px) {
    .nav-links a:not(.button) {
      background: linear-gradient(currentColor, currentColor) 0 100% / 0 1.5px no-repeat;
      transition: background-size .3s ease, color .2s ease;
    }
    .nav-links a:not(.button):hover, .nav-links a:not(.button):focus-visible { background-size: 100% 1.5px; }
  }

  /* ---------- 4. The Action Lab story ---------- */
  .pinned-figure > img { transform: scale(.975); transition: opacity .55s ease, transform 1.1s cubic-bezier(.2, .7, .2, 1); }
  .pinned-figure > img.is-active { transform: none; }

  /* ---------- 5. Any priority: tabs swap with a short slide; the cycle turns ---------- */
  .priority-content [role="tabpanel"]:not([hidden]) img { animation: tgi-swap .55s cubic-bezier(.2, .7, .2, 1) both; }
  .priority-content [role="tabpanel"]:not([hidden]) .priority-caption { animation: tgi-rise .5s cubic-bezier(.2, .7, .2, 1) .08s both; }
  .priority-method .ring-progress { transform-origin: 75px 75px; animation: tgi-orbit 14s linear infinite; }

  /* ---------- 6. Learning that travels: a thread from DICI to the Solution Stack ---------- */
  .stays-arrow span:before {
    content: ''; position: absolute; left: 0; top: -3px; width: 8px; height: 8px; border-radius: 50%;
    background: var(--turmeric, #D69A2D); animation: tgi-flow-x 2.8s cubic-bezier(.45, 0, .55, 1) infinite;
  }

  /* ---------- 7. Screen previews come alive once seen (animate.js sets .is-live) ---------- */
  .tgi-anim .screen:not(.is-live) .scr-progress .bar i,
  .tgi-anim .screen:not(.is-live) .scr-prob .tiers i { transform: scaleX(0); }
  .tgi-anim .screen .scr-progress .bar i,
  .tgi-anim .screen .scr-prob .tiers i { transform-origin: 0 50%; transition: transform .9s cubic-bezier(.2, .7, .2, 1) .25s; }
  .tgi-anim .screen .scr-progress .bar i:nth-child(2) { transition-delay: .4s; }
  .tgi-anim .screen .scr-progress .bar i:nth-child(3) { transition-delay: .55s; }
  .tgi-anim .screen .scr-progress .bar i:nth-child(4) { transition-delay: .7s; }

  .tgi-anim .screen:not(.is-live) .scr-tile,
  .tgi-anim .screen:not(.is-live) .scr-signal,
  .tgi-anim .screen:not(.is-live) .scr-prob,
  .tgi-anim .screen:not(.is-live) .scr-record { opacity: 0; transform: translateY(10px); }
  .tgi-anim .screen .scr-tile,
  .tgi-anim .screen .scr-signal,
  .tgi-anim .screen .scr-prob,
  .tgi-anim .screen .scr-record { transition: opacity .6s ease, transform .6s cubic-bezier(.2, .7, .2, 1); }
  .tgi-anim .screen .scr-tile:nth-child(1), .tgi-anim .screen .scr-prob:nth-child(1) { transition-delay: .2s; }
  .tgi-anim .screen .scr-tile:nth-child(2), .tgi-anim .screen .scr-prob:nth-child(2) { transition-delay: .28s; }
  .tgi-anim .screen .scr-tile:nth-child(3), .tgi-anim .screen .scr-prob:nth-child(3) { transition-delay: .36s; }
  .tgi-anim .screen .scr-tile:nth-child(4), .tgi-anim .screen .scr-prob:nth-child(4) { transition-delay: .44s; }
  .tgi-anim .screen .scr-prob:nth-child(5) { transition-delay: .52s; }
  .tgi-anim .screen .scr-prob:nth-child(6) { transition-delay: .6s; }
  .tgi-anim .screen .scr-signal:nth-of-type(1) { transition-delay: .5s; }
  .tgi-anim .screen .scr-signal:nth-of-type(2) { transition-delay: .64s; }
  .tgi-anim .screen .scr-record { transition-delay: .5s; }

  .screen.is-live .scr-map circle { transform-box: fill-box; transform-origin: center; animation: tgi-ping 2.6s ease-in-out infinite; }
  .screen.is-live .scr-map circle:nth-child(2) { animation-delay: .5s; }
  .screen.is-live .scr-map circle:nth-child(3) { animation-delay: 1s; }
  .screen.is-live .scr-assist .scr-spark { animation: tgi-glow 3.2s ease-in-out 1s infinite; }
  .screen.is-live .scr-search:after {
    content: ''; display: inline-block; width: 1px; height: 1.05em; margin-left: .25em; vertical-align: -.18em;
    background: currentColor; animation: tgi-caret 1.1s steps(1) infinite;
  }

  /* ---------- 8. Inner pages: flows and stages draw in ---------- */
  .tgi-anim .gc-flow:before { transform-origin: 0 50%; transition: transform 1.2s cubic-bezier(.2, .7, .2, 1) .1s; }
  .tgi-anim .gc-flow:not(.is-live):before { transform: scaleX(0); }
  .tgi-anim .gc-flow .flow-index { transition: transform .5s cubic-bezier(.3, 1.4, .5, 1), opacity .4s ease; }
  .tgi-anim .gc-flow:not(.is-live) .flow-index { transform: scale(.4); opacity: 0; }
  .tgi-anim .gc-flow li:nth-child(2) .flow-index { transition-delay: .3s; }
  .tgi-anim .gc-flow li:nth-child(3) .flow-index { transition-delay: .6s; }
  .tgi-anim .gc-flow li:nth-child(4) .flow-index { transition-delay: .9s; }

  .tgi-anim .tools-stages li,
  .tgi-anim .connect-chain li { transition: opacity .55s ease, transform .55s cubic-bezier(.2, .7, .2, 1); }
  .tgi-anim .tools-stages:not(.is-live) li,
  .tgi-anim .connect-chain:not(.is-live) li { opacity: 0; transform: translateX(-12px); }
  .tgi-anim .tools-stages li:nth-child(2), .tgi-anim .connect-chain li:nth-child(2) { transition-delay: .1s; }
  .tgi-anim .tools-stages li:nth-child(3), .tgi-anim .connect-chain li:nth-child(3) { transition-delay: .2s; }
  .tgi-anim .tools-stages li:nth-child(4), .tgi-anim .connect-chain li:nth-child(4) { transition-delay: .3s; }
  .tgi-anim .tools-stages li:nth-child(5), .tgi-anim .connect-chain li:nth-child(5) { transition-delay: .4s; }
}

@media (prefers-reduced-motion: no-preference) and (max-width: 850px) {
  .stays-arrow span:before { left: -3px; top: 0; animation-name: tgi-flow-y; }
}

@keyframes tgi-rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes tgi-unroll {
  from { clip-path: inset(0 58% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}
@keyframes tgi-progress { to { transform: scaleX(1); } }
@keyframes tgi-swap { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
@keyframes tgi-orbit { from { transform: rotate(-90deg); } to { transform: rotate(270deg); } }
@keyframes tgi-flow-x {
  0% { transform: translateX(0); opacity: 0; } 15%, 80% { opacity: 1; }
  100% { transform: translateX(42px); opacity: 0; }
}
@keyframes tgi-flow-y {
  0% { transform: translateY(0); opacity: 0; } 15%, 80% { opacity: 1; }
  100% { transform: translateY(30px); opacity: 0; }
}
@keyframes tgi-ping { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.4); } }
@keyframes tgi-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(214, 154, 45, 0); }
  50% { box-shadow: 0 0 0 .55em rgba(214, 154, 45, .28); }
}
@keyframes tgi-caret { 50% { opacity: 0; } }

/* ---------- 9. Hero: the living village (animate.js builds it; skipped for reduced motion) ----------
   An inline copy of district-world.svg takes over from the picture after the unroll, so the
   people, the rider, the sun and the birds can move. */
.ht-layer { position: absolute; left: 0; overflow: hidden; pointer-events: none; z-index: 1; }
.ht-svg { position: absolute; overflow: visible; }
.ht-world, .ht-actors { opacity: 0; }
.ht-actors { will-change: transform; }
.ht-village .ht-world, .ht-village .ht-actors { opacity: 1; }
.ht-village .world-panorama { visibility: hidden; }
