/* =====================================================================
   DIGITAL FLOW — isometric art layer for generated pages
   Loaded only on pages whose manifest entry sets designHeroArt or
   designIcons (drawn by production/design-art.js, inline SVG).

   Motion grammar (Jakub primary, Jhey secondary):
     · the hero page assembles once, then floats a few pixels, out of step;
       a pointer presses the button now and then. Decorative, slow, small.
     · each card's object arrives with its section (the existing .is-in
       reveal), its one moving part doing one thing: lift, rise, separate.
     · transform and opacity only. Paused off screen (data-art="off").
     · prefers-reduced-motion: everything is drawn in its final state.
   ===================================================================== */

/* ------------------------------------------------------- hero layout */
.pg-art { position: relative; width: 100%; max-width: 380px; justify-self: center; margin: var(--sp-2xl, 48px) auto 0; }
.pg-art__svg { position: relative; display: block; width: 100%; height: auto; overflow: visible; }
/* Ambient light behind the page: two soft fields that drift. */
.pg-art__glow {
  position: absolute; inset: -18% -14%; pointer-events: none; border-radius: 50%;
  background:
    radial-gradient(closest-side at 38% 42%, rgba(182, 255, 46, 0.16), transparent 72%),
    radial-gradient(closest-side at 66% 64%, rgba(242, 255, 36, 0.12), transparent 70%);
}

@media (min-width: 1180px) {
  .pg-d--websites .pg-hero,
  .pg-d--systems .pg-hero,
  .pg-d--about .pg-hero,
  .pg-d--field-notes .pg-hero,
  .pg-d--case .pg-hero {
    grid-template-columns: var(--rail) minmax(0, 1fr) minmax(0, 360px);
    grid-template-areas: "crumbs crumbs crumbs" "h1 h1 art" "eyebrow lead art" ". actions art";
  }
  .pg-d--websites .pg-hero h1,
  .pg-d--systems .pg-hero h1,
  .pg-d--about .pg-hero h1,
  .pg-d--field-notes .pg-hero h1,
  .pg-d--case .pg-hero h1 { font-size: clamp(2.6rem, 1rem + 3.3vw, 4.1rem); }
  .pg-d--websites .pg-art,
  .pg-d--systems .pg-art,
  .pg-d--about .pg-art,
  .pg-d--field-notes .pg-art,
  .pg-d--case .pg-art { grid-area: art; align-self: center; margin: 0; max-width: none; }
  /* Keep the founders photograph below the first screen, so the headline stays LCP. */
  .pg-d--about .pg-hero { min-height: calc(100svh - 120px); align-content: start; }
}

/* Keep the about headline eligible as the page's LCP while its decorative
   underline and adjacent illustration settle. */
@media (prefers-reduced-motion: no-preference) {
  .pg-d--about .pg-hero > h1 { animation: none; }
}

/* ------------------------------------------------------------- cards */
.pg-d .pg-s--cards .pg-card--icon { grid-template-columns: 76px minmax(0, 1fr); column-gap: var(--sp-lg, 24px); align-items: start; }
.pg-d .pg-s--cards .pg-card--icon > .pg-icon { grid-row: span 2; }
.pg-icon { display: block; width: 76px; aspect-ratio: 1; }
.pg-icon svg { display: block; width: 100%; height: 100%; overflow: visible; }

@container (min-width: 720px) {
  .pg-d--websites .pg-s--cards .pg-cards,
  .pg-d--systems .pg-s--cards .pg-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: var(--sp-xl, 32px); }
  .pg-d--websites .pg-s--cards .pg-card--icon,
  .pg-d--systems .pg-s--cards .pg-card--icon {
    grid-template-columns: minmax(0, 1fr); row-gap: var(--sp-sm, 12px); align-content: start;
    padding: var(--sp-lg, 24px) 0 var(--sp-xl, 32px);
  }
  .pg-d--websites .pg-s--cards .pg-card--icon > .pg-icon,
  .pg-d--systems .pg-s--cards .pg-card--icon > .pg-icon { grid-row: auto; width: 112px; margin-bottom: var(--sp-xs, 8px); }
  .pg-d--websites .pg-s--cards .pg-card--icon p,
  .pg-d--systems .pg-s--cards .pg-card--icon p { font-size: 1rem; }
  /* Pointing at a card raises its object a little: the only pointer effect. */
  .pg-d--websites .pg-s--cards .pg-card--icon:hover .pg-iso { transform: translateY(-4px); }
  .pg-d--systems .pg-s--cards .pg-card--icon:hover .pg-iso { transform: translateY(-4px); }
}
.pg-iso { transition: transform 0.4s var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1)); }

/* =============================================================== motion */
@media (prefers-reduced-motion: no-preference) {
  /* Hero: the three layers come together from a stack, then breathe. */
  .pg-art__layer { transform-box: view-box; animation: art-assemble 1.1s var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1)) both; }
  .pg-art__layer--base { --from: 0px; animation-delay: 0.25s; }
  .pg-art__layer--structure { --from: 66px; animation-delay: 0.35s; }
  .pg-art__layer--page { --from: 132px; animation-delay: 0.45s; }
  .pg-art__layer--structure { animation: art-assemble 1.1s var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1)) 0.35s both, art-float 9s ease-in-out 1.6s infinite; --amp: 3px; }
  .pg-art__layer--page { animation: art-assemble 1.1s var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1)) 0.45s both, art-float 7s ease-in-out 1.6s infinite; --amp: 5px; }
  .pg-art__button { animation: art-press 6s ease-in-out 2.4s infinite; }
  .pg-art__pointer { animation: art-point 6s ease-in-out 2.4s infinite; opacity: 0; }
  .pg-art__glow { animation: art-glow 16s ease-in-out infinite alternate; }

  /* Cards: each object arrives with its row, then does its one thing. */
  [data-rv~="rows"] > .pg-card--icon .pg-iso { opacity: 0; transform: translateY(14px); transition: opacity 0.5s ease calc(var(--i, 0) * 110ms), transform 0.7s var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1)) calc(var(--i, 0) * 110ms); }
  [data-rv~="rows"].is-in > .pg-card--icon .pg-iso { opacity: 1; transform: none; }
  .pg-p { transform-box: fill-box; transform-origin: 50% 100%; transition: transform 0.7s var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1)) calc(var(--i, 0) * 110ms + 0.35s); }
  [data-rv~="rows"] > .pg-card--icon .pg-p--lift { transform: translateY(6px); }
  [data-rv~="rows"] > .pg-card--icon .pg-p--drop { transform: translateY(-14px); }
  [data-rv~="rows"] > .pg-card--icon .pg-p--l2 { transform: translateY(8px); }
  [data-rv~="rows"] > .pg-card--icon .pg-p--l3 { transform: translateY(16px); }
  [data-rv~="rows"] > .pg-card--icon .pg-p--b1,
  [data-rv~="rows"] > .pg-card--icon .pg-p--b2,
  [data-rv~="rows"] > .pg-card--icon .pg-p--b3 { transform: scaleY(0.2); }
  [data-rv~="rows"] > .pg-card--icon .pg-p--b2 { transition-delay: calc(var(--i, 0) * 110ms + 0.45s); }
  [data-rv~="rows"] > .pg-card--icon .pg-p--b3 { transition-delay: calc(var(--i, 0) * 110ms + 0.55s); }
  [data-rv~="rows"].is-in > .pg-card--icon .pg-p { transform: none; }

  /* Off screen, the hero stops moving. */
  [data-art="off"] .pg-art *, [data-art="off"] .pg-art { animation-play-state: paused; }
}

@keyframes art-assemble { from { opacity: 0; transform: translateY(var(--from, 0px)); } to { opacity: 1; transform: none; } }
@keyframes art-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(calc(var(--amp, 4px) * -1)); } }
@keyframes art-press { 0%, 62%, 74%, 100% { transform: translateY(0); } 66%, 70% { transform: translateY(3px); } }
@keyframes art-point {
  0%, 30% { opacity: 0; transform: translate(26px, 30px); }
  42% { opacity: 1; }
  60% { opacity: 1; transform: translate(0, 0); }
  66%, 70% { opacity: 1; transform: translate(0, 2px) scale(0.92); }
  86% { opacity: 1; transform: translate(0, 0); }
  100% { opacity: 0; transform: translate(10px, 12px); }
}
@keyframes art-glow { from { transform: translate(-3%, 2%) scale(1); } to { transform: translate(4%, -3%) scale(1.06); } }

/* The other heroes share an eight-second cursor score, with page-specific actions. */
.pg-art__cursor, .pg-art__data { opacity: 0; }
@media (prefers-reduced-motion: no-preference) {
  .pg-art__cursor { opacity: 1; animation: art-tour 8s ease-in-out infinite; }
  .pg-art__stage { animation: art-activate 8s ease-in-out var(--beat) infinite; }
  .pg-art__data { animation: art-transfer 8s ease-in-out var(--beat) infinite; }
  .pg-art--field-notes .pg-art__stage { animation: none; }
  .pg-art__note { transform-box: fill-box; transform-origin: center; animation: art-open 8s ease-in-out var(--beat) infinite; }
  .pg-art__highlight { transform-box: fill-box; transform-origin: left; animation: art-highlight 8s ease-in-out var(--beat) infinite both; }
  [data-art="off"] .pg-art :is(.pg-art__cursor, .pg-art__stage, .pg-art__data, .pg-art__note, .pg-art__highlight) { animation-play-state: paused; }
}
@keyframes art-tour {
  0%, 10%, 24%, 100% { transform: var(--p1); }
  14% { transform: var(--p1) translateY(2px) scale(0.92); }
  18% { transform: var(--p1); }
  32%, 40%, 46% { transform: var(--p2); }
  36% { transform: var(--p2) translateY(2px) scale(0.92); }
  54%, 62%, 68% { transform: var(--p3); }
  58% { transform: var(--p3) translateY(2px) scale(0.92); }
  76%, 84%, 90% { transform: var(--p4); }
  80% { transform: var(--p4) translateY(2px) scale(0.92); }
}
@keyframes art-activate {
  0%, 6%, 30%, 100% { opacity: 0.7; transform: translateY(0); }
  10%, 24% { opacity: 1; transform: translateY(-3px); }
  14% { opacity: 1; transform: translateY(1px); }
}
@keyframes art-transfer {
  0%, 14% { opacity: 0; transform: translate(0, 0); }
  16%, 30% { opacity: 1; }
  32%, 100% { opacity: 0; transform: var(--travel); }
}
@keyframes art-open {
  0%, 10%, 48%, 100% { transform: none; }
  18%, 42% { transform: translateY(-6px) scale(1.04); }
}
@keyframes art-highlight {
  0%, 30%, 48%, 100% { transform: scaleX(0); }
  38%, 42% { transform: scaleX(1); }
}
