/* Generated by docs/woven.mjs: the woven thread through the documentation site. GGDS tokens only. */

/* Page titles wear the cloth: a short woven strip under each one. */
.ggds-main h1:not([class])::after {
  content: "";
  display: block;
  width: var(--ggds-space-16);
  height: 6px;
  margin-top: var(--ggds-space-3);
  border-radius: 3px;
  background: repeating-linear-gradient(90deg, var(--ggds-color-flag-gold) 0 14px, var(--ggds-color-flag-green) 14px 20px, var(--ggds-color-flag-gold) 20px 34px, var(--ggds-color-flag-red) 34px 40px, var(--ggds-color-flag-black) 40px 44px);
  transform-origin: 0 50%;
}

/* Section headings get a stitch. */
.ggds-main h2:not([class])::after {
  content: "";
  display: block;
  width: var(--ggds-space-8);
  height: 3px;
  margin-top: var(--ggds-space-2);
  border-radius: 2px;
  background: linear-gradient(90deg, var(--ggds-color-flag-red) 0 33%, var(--ggds-color-flag-gold) 33% 66%, var(--ggds-color-flag-green) 66%);
  transform-origin: 0 50%;
}

/* The current page in a section's menu is marked with a woven thread. */
.docs-sidenav__link[aria-current="page"] {
  box-shadow: none;
  background: linear-gradient(var(--ggds-color-flag-gold) 0 33%, var(--ggds-color-flag-red) 33% 66%, var(--ggds-color-flag-green) 66%) left / 4px 100% no-repeat;
}

/* Cards: a woven edge, drawn across the top when people point at one, that bends round the card's corners at the
   same 4px all the way. It is a cap the card's own shape: laid over its border, as tall as its rounding, with the
   card's outer corners, and hollowed out 4px in from the top and sides (the mask), so its inner edge is the same
   curve 4px in. (A 4px-tall strip cannot: its corners are squashed to fit its height and stick out past the
   border.) It is drawn in by uncovering it left to right, so the shape never stretches. */
.ggds-main .ggds-card:not(.ggds-card--institution)::before {
  content: "";
  box-sizing: border-box;
  position: absolute;
  inset: -1px -1px auto;
  height: var(--ggds-radius-lg);
  padding: 4px 4px 0;
  border-radius: var(--ggds-radius-lg) var(--ggds-radius-lg) 0 0;
  background: repeating-linear-gradient(90deg, var(--ggds-color-flag-gold) 0 14px, var(--ggds-color-flag-green) 14px 20px, var(--ggds-color-flag-gold) 20px 34px, var(--ggds-color-flag-red) 34px 40px, var(--ggds-color-flag-black) 40px 44px);
  mask: linear-gradient(var(--ggds-color-text) 0 0) content-box exclude, linear-gradient(var(--ggds-color-text) 0 0);
  pointer-events: none;
  clip-path: inset(0 100% 0 0);
}
.ggds-main .ggds-card:not(.ggds-card--institution):has(.ggds-card__link:is(:hover, :focus-visible))::before { clip-path: inset(0); }
/* Once someone has chosen an institution (docs/theme-pref.js: until they reload), the edge is in its colour. */
:root[data-docs-theme-chosen] .ggds-main .ggds-card:not(.ggds-card--institution)::before { background: var(--ggds-color-institution); }

/* The reading thread: hidden unless the browser can follow the scroll. */
.ggds-header::after { content: none; }

@media (prefers-reduced-motion: no-preference) {
  /* Between pages: the header stays where it is, and the new page settles in. */
  @view-transition { navigation: auto; }
  .ggds-header { view-transition-name: docs-header; }
  ::view-transition-old(root) { animation: woven-page-out var(--ggds-motion-duration-fast) ease-in both; }
  ::view-transition-new(root) { animation: woven-page-in var(--ggds-motion-duration-slow) cubic-bezier(0.16, 1, 0.3, 1) both; }

  /* As a page opens, its title's strip is woven in, left to right. */
  .ggds-main h1:not([class])::after { animation: woven-weave-in 600ms cubic-bezier(0.16, 1, 0.3, 1) 150ms both; }

  .ggds-main .ggds-card:not(.ggds-card--institution)::before { transition: clip-path var(--ggds-motion-duration-base) cubic-bezier(0.16, 1, 0.3, 1); }

  @supports (animation-timeline: view()) {
    /* The reading thread under the header, filling as people read. */
    .ggds-header::after {
      content: "";
      position: absolute;
      inset: auto 0 -3px;
      height: 3px;
      background: repeating-linear-gradient(90deg, var(--ggds-color-flag-gold) 0 14px, var(--ggds-color-flag-green) 14px 20px, var(--ggds-color-flag-gold) 20px 34px, var(--ggds-color-flag-red) 34px 40px, var(--ggds-color-flag-black) 40px 44px);
      transform-origin: 0 50%;
      animation: woven-read linear both;
      animation-timeline: scroll(root);
    }

    /* A heading's stitch draws as the heading comes into view. */
    .ggds-main h2:not([class])::after { animation: woven-weave-in linear both; animation-timeline: view(); animation-range: entry 20% cover 30%; }

    /* Cards arrive in turn. */
    .ggds-main :is(.ggds-card-grid, .docs-themes) > * { animation: woven-rise linear both; animation-timeline: view(); animation-range: entry 0% entry 90%; }
    .ggds-main :is(.ggds-card-grid, .docs-themes) > :nth-child(3n + 2) { animation-range: entry 8% entry 98%; }
    .ggds-main :is(.ggds-card-grid, .docs-themes) > :nth-child(3n) { animation-range: entry 16% cover 30%; }

    /* The footer's woven band unrolls from the middle as it comes into view. */
    .ggds-footer::before { animation: woven-unroll linear both; animation-timeline: view(); animation-range: entry 0% entry 100%; }
  }
}

@keyframes woven-page-out { to { opacity: 0; } }
@keyframes woven-page-in { from { opacity: 0; transform: translateY(var(--ggds-space-2)); } }
@keyframes woven-weave-in { from { transform: scaleX(0); } }
@keyframes woven-read { from { transform: scaleX(0); } }
@keyframes woven-rise { from { transform: translateY(var(--ggds-space-6)); } } /* no fading: a card's words stay at full contrast */
@keyframes woven-unroll { from { transform: scaleX(0.15); } }
