/* Work constellation: the projects as bodies on three orbits around one centre, each with its own motion.
   Distance, brightness and speed carry the hierarchy: Building now rides the inner ring, brightest and fastest;
   Past projects the middle ring, dimmer and slower; the outer Ideas ring stays faint and empty until there is
   something real to put on it. Positions are plain CSS: each body's angle is its --a plus one registered,
   animated --wk-t, so the orbits need no script and stop with every other animation.
   Every rule is nested under one [data-work-sky] block so nothing leaks into the cards or the chrome; the
   no-script fallbacks sit at the end as plain top-level rules, since a nested selector that opens with a
   type selector is dropped by browsers that only support the early form of nesting. */
@keyframes wk-rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes wk-fade { from { opacity: 0; } }
@keyframes wk-arrive { from { opacity: 0; scale: .5; filter: blur(8px); } }
@keyframes wk-spin { to { transform: rotate(1turn); } }
@keyframes wk-flare { from { height: 7%; } to { height: var(--h); } }
@keyframes wk-ping { 0% { opacity: .9; transform: scale(1); } 100% { opacity: 0; transform: scale(3.2); } }
/* Not inherited, so advancing the angle restyles the body alone, never its scene */
@property --wk-t { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@keyframes wk-orbit { to { --wk-t: 1turn; } }

[data-work-sky] {
  --wk-deep: #040e15;
  --wk-ember: #f77958;
  --wk-hair: #ffffff1f;
  --wk-on: var(--wk-cream, #faf7ed);
  --wk-muted: #b9cbd2;
  --wk-mt: var(--wk-mint, #78cdc6);
  --wk-co: var(--wk-coral, #ec7257);
  --wk-gd: var(--wk-gold, #e5af52);
  --wk-ease: cubic-bezier(.22, .61, .36, 1);
  --wk-sans: var(--font-sans, "Avenir Next", Avenir, "Helvetica Neue", Arial, sans-serif);
  --wk-gutter: clamp(20px, 4vw, 64px);
  --wk-head: 72px;
  position: relative;
  overflow: hidden;
  color: var(--wk-on);
  font-family: var(--wk-sans);
  background: radial-gradient(90% 80% at 70% 46%, #12364a 0%, var(--wk-night, #06141d) 60%, var(--wk-deep) 100%);

  @media (min-width: 1280px) { --wk-head: 88px; }
  &.wk--page { min-height: min(calc(100svh - var(--wk-head)), 960px); display: flex; align-items: center; }
  [data-stage="public"], [data-stage-filter="public"] { --wk-stc: var(--wk-stage-public, #59cb89); }
  [data-stage="preview"], [data-stage-filter="preview"] { --wk-stc: var(--wk-stage-preview, #e5af52); }
  [data-stage="progress"], [data-stage-filter="progress"] { --wk-stc: var(--wk-stage-progress, #78cdc6); }
  [data-stage="past"] { --wk-stc: #93abb5; }
  .wk-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

  .wk__stars {
    position: absolute; inset: -10px; width: calc(100% + 20px); height: calc(100% + 20px); display: block; pointer-events: none;
    translate: calc(var(--wk-px, 0) * -7px) calc(var(--wk-py, 0) * -5px);
  }
  .wk__wrap {
    position: relative; width: 100%; max-width: 90rem; margin: 0 auto; box-sizing: border-box;
    padding: clamp(24px, 3vw, 48px) var(--wk-gutter);
    display: grid; grid-template-columns: minmax(0, clamp(21rem, 33vw, 30rem)) minmax(0, 1fr);
    gap: clamp(24px, 3.4vw, 56px); align-items: center;
  }

  .wk__copy {
    display: grid; grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "eyebrow eyebrow" "title title" "lede lede" "client client" "founders founders" "legend legend" "panel panel";
    gap: 14px 12px; align-items: center; min-width: 0;
  }
  .wk__eyebrow { grid-area: eyebrow; display: flex; align-items: center; gap: 12px; margin: 0; font: 500 13px/1.2 var(--wk-sans); letter-spacing: .02em; color: var(--wk-mt); }
  .wk__eyebrow::before { content: ""; width: 28px; height: 2px; background: var(--wk-co); }
  .wk__title { grid-area: title; margin: 0; font-weight: 600; font-size: clamp(34px, 3.3vw, 48px); line-height: 1.04; letter-spacing: -.03em; text-wrap: balance; color: var(--wk-on); }
  .wk__lede { grid-area: lede; margin: 0; font-size: 15px; line-height: 1.6; color: var(--wk-muted); max-width: 60ch; text-wrap: pretty; }
  .wk__founders { grid-area: founders; list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0 28px; }
  .wk__founders li { display: flex; align-items: baseline; gap: 10px; }
  .wk__who { font-size: 13px; color: var(--wk-muted); }
  .wk__founders a { display: inline-flex; align-items: center; min-height: 40px; color: var(--wk-on); font-weight: 500; font-size: 15px; text-decoration: underline; text-decoration-color: var(--wk-co); text-underline-offset: 5px; }
  .wk__founders a:hover { color: var(--wk-mt); }

  /* Legend: one row per orbit, each a jump to its section below */
  .wk-legend { grid-area: legend; }
  .wk-legend ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
  .wk-legend a { display: grid; grid-template-columns: 14px auto minmax(0, 1fr); align-items: center; gap: 0 10px; min-height: 40px; color: var(--wk-on); text-decoration: none; }
  .wk-legend__name { font-weight: 500; font-size: 15px; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 5px; transition: text-decoration-color .3s; }
  .wk-legend__note { font-size: 13px; color: var(--wk-muted); }
  .wk-legend a:hover .wk-legend__name, .wk-legend a:focus-visible .wk-legend__name { text-decoration-color: var(--wk-co); }
  .wk-legend__dot { justify-self: center; width: 7px; height: 7px; border-radius: 50%; }
  .wk-legend [data-orbit="now"] .wk-legend__dot { width: 10px; height: 10px; background: var(--wk-on); box-shadow: 0 0 10px #faf7edaa; }
  .wk-legend [data-orbit="past"] .wk-legend__dot { background: var(--wk-muted); opacity: .6; }
  .wk-legend [data-orbit="ideas"] .wk-legend__dot { border: 1px dashed var(--wk-muted); opacity: .55; }


  /* The panel reads out whichever body has focus */
  .wk__panel { grid-area: panel; position: relative; border-top: 1px solid var(--wk-hair); padding-top: 16px; display: flex; flex-direction: column; gap: 5px; }
  .wk__panel::before { content: ""; position: absolute; top: -1px; left: 0; width: 56px; height: 1px; background: var(--wk-c, var(--wk-mt)); box-shadow: 0 0 12px var(--wk-c, var(--wk-mt)); transition: background-color .5s, box-shadow .5s; }
  .wk__panel.is-swap > * { animation: wk-rise .45s var(--wk-ease) backwards; }
  .wk__panel.is-swap > :nth-child(2) { animation-delay: .04s; }
  .wk__panel.is-swap > :nth-child(n+3) { animation-delay: .08s; }
  .wk__panel-links { margin: 2px 0 0; display: flex; flex-wrap: wrap; gap: 0 20px; }
  .wk__panel [hidden] { display: none; }

  .wk-st { margin: 0; font: 500 13px/1.3 var(--wk-sans); color: var(--wk-muted); display: flex; align-items: center; gap: 8px; }
  .wk-st::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--wk-stc, var(--wk-mt)); box-shadow: 0 0 8px var(--wk-stc, var(--wk-mt)); }
  .wk-name { margin: 0; font-weight: 500; font-size: 26px; line-height: 1.15; letter-spacing: -.015em; color: var(--wk-on); }
  .wk-line { margin: 0; font-size: 16px; line-height: 1.4; color: var(--wk-on); max-width: 56ch; }
  .wk-desc { margin: 0; font-size: 14px; line-height: 1.5; color: var(--wk-muted); max-width: 54ch; }
  .wk-from { margin: 0; font-size: 13px; color: var(--wk-muted); }
  .wk-link, .wk-ext, .wk-card-link { display: inline-flex; align-items: center; min-height: 44px; color: var(--wk-on); text-decoration: none; font-weight: 500; font-size: 15px; }
  .wk-ext, .wk-card-link { color: var(--wk-muted); font-size: 14px; }
  .wk-link span { border-bottom: 1px solid var(--wk-co); padding-bottom: 2px; }
  :is(.wk-link, .wk-ext, .wk-card-link):hover { color: var(--wk-co); }
  :is(a, button):focus-visible { outline: 2px solid var(--wk-co); outline-offset: 4px; }

  /* ---------- Sky ---------- */
  .wk__skywrap { position: relative; min-width: 0; margin-right: calc(-.6 * var(--wk-gutter)); }
  /* The list only positions the bodies; clicks between them fall through to the rings */
  .wk__sky { position: relative; container-type: inline-size; aspect-ratio: 1000 / 680; width: 100%; list-style: none; margin: 0; padding: 0; pointer-events: none; }
  .wk-body { pointer-events: auto; }

  /* Rings: radii in percent of the sky, matching each orbit's --rx/--ry below */
  .wk__orbits { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; animation: wk-fade 1.6s .6s backwards; }
  .wk-ring { fill: none; stroke: var(--wk-muted); stroke-width: 1; vector-effect: non-scaling-stroke; transition: stroke-opacity .4s, stroke .4s; }
  .wk__orbits [data-orbit="now"] .wk-ring { stroke: var(--wk-on); stroke-opacity: .28; }
  .wk__orbits [data-orbit="past"] .wk-ring { stroke-opacity: .17; }
  .wk__orbits [data-orbit="ideas"] .wk-ring { stroke-opacity: .2; stroke-dasharray: 1 6; }
  .wk-ring-hit { fill: none; stroke: transparent; stroke-width: 18; vector-effect: non-scaling-stroke; pointer-events: stroke; cursor: pointer; }
  .wk-ring-label {
    position: absolute; left: 50%; transform: translate(-50%, -50%); padding: 1px 7px; border-radius: 999px;
    background: #06141db3; font: 500 10.5px/1.2 var(--wk-sans); letter-spacing: .1em; text-transform: uppercase; white-space: nowrap;
    z-index: 0; color: var(--wk-muted); text-decoration: none; transition: color .3s; animation: wk-fade 1.6s .9s backwards;
  }
  /* Only the empty Ideas ring is named in the sky (bodies never reach it); the legend names the other two */
  .wk-ring-label[data-orbit="ideas"] { top: calc(50% - 45%); opacity: .6; }
  /* Pointing at an orbit (ring or legend row) lights the ring and its bodies */
  &:has(a[data-orbit="now"]:is(:hover, :focus-visible)) .wk__orbits [data-orbit="now"] .wk-ring,
  &:has(a[data-orbit="past"]:is(:hover, :focus-visible)) .wk__orbits [data-orbit="past"] .wk-ring,
  &:has(a[data-orbit="ideas"]:is(:hover, :focus-visible)) :is(.wk__orbits [data-orbit="ideas"] .wk-ring, .wk-ring-label[data-orbit="ideas"]) { stroke: var(--wk-co); stroke-opacity: .85; color: var(--wk-co); opacity: 1; }
  &:has(a[data-orbit="past"]:is(:hover, :focus-visible)) .wk-body[data-orbit="past"] .wk-scene,
  &:has(a[data-orbit="now"]:is(:hover, :focus-visible)) .wk-body[data-orbit="now"] .wk-scene { opacity: 1; filter: none; }

  /* The studio sits at the centre */
  .wk-sun {
    position: absolute; left: 50%; top: 50%; width: 6%; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; pointer-events: none; z-index: 0;
    background: radial-gradient(circle, #fffaf0 0 18%, #f3c77a 34%, #f7795855 56%, #f7795800 70%);
    animation: wk-fade 1.2s backwards;
  }

  /* Each orbit: radii (percent of the sky's width and height), body size (cqw) and one lap's duration */
  .wk-body[data-orbit="now"] { --rx: 22%; --ry: 16%; --s: 20; --wk-lap: 120s; --wk-in: 150ms; }
  .wk-body[data-orbit="past"] { --rx: 40%; --ry: 33%; --s: 15; --wk-lap: 600s; --wk-in: 480ms; }
  /* The rings are seen from above and in front: a body at the back of its ring (top) sits a little smaller and
     passes behind nearer bodies; at the front (bottom) it is full size and passes in front. The centre, rings and
     ring labels stay beneath every body. */
  .wk__skywrap { isolation: isolate; }
  .wk-body {
    /* Without @property support the angle never animates; declaring it keeps a still, correctly placed sky */
    --wk-t: 0deg;
    position: absolute; width: calc(var(--s) * 1cqw);
    --wk-depth: sin(var(--a) + var(--wk-t));
    left: calc(50% + var(--rx) * cos(var(--a) + var(--wk-t)));
    top: calc(50% + var(--ry) * sin(var(--a) + var(--wk-t)));
    scale: calc(.88 + .12 * var(--wk-depth));
    z-index: calc(11 + 10 * var(--wk-depth));
    transform: translate(-50%, -50%);
    translate: calc(var(--wk-px, 0) * var(--s) * .7px) calc(var(--wk-py, 0) * var(--s) * .5px);
    transition: opacity .5s var(--wk-ease), filter .5s;
    /* Inner bodies arrive first, then the middle ring; both keep circling until a pointer or focus holds them */
    animation: wk-arrive 1.1s var(--wk-ease) backwards, wk-orbit var(--wk-lap) linear infinite;
    animation-delay: var(--wk-in), 0s;
  }
  /* Hold only the orbit; the arrival keeps running so a pointer resting here at load never leaves bodies hidden */
  .wk__skywrap:hover .wk-body, .wk__sky:focus-within .wk-body { animation-play-state: running, paused; }
  .wk-hit { all: unset; cursor: pointer; display: block; width: 100%; position: relative; border-radius: 50%; }
  .wk-hit::before { content: ""; position: absolute; inset: -28%; border-radius: 50%; pointer-events: none; background: radial-gradient(closest-side, color-mix(in srgb, var(--wk-c, #78cdc6) 30%, transparent), transparent); opacity: 0; scale: .8; transition: opacity .7s var(--wk-ease), scale .7s var(--wk-ease); }
  .wk-body[data-orbit="now"] .wk-hit::before { opacity: .55; scale: .95; }
  .wk-body.is-on .wk-hit::before { opacity: 1; scale: 1; }
  .wk-hit:focus-visible { outline-offset: 8px; }
  .wk-scene { display: block; position: relative; width: 100%; aspect-ratio: 1; container-type: inline-size; transition: transform .6s var(--wk-ease), opacity .5s var(--wk-ease), filter .5s; }
  /* Names stay readable at rest: only the scene of an unselected body dims, never its label */
  /* Names keep one size at any depth */
  .wk-tag { position: absolute; left: 50%; top: 100%; transform: translate(-50%, 6px); scale: calc(1 / (.88 + .12 * var(--wk-depth, 1))); transform-origin: 50% 0; white-space: nowrap; pointer-events: none; font: 500 13px/1 var(--wk-sans); letter-spacing: .02em; color: var(--wk-muted); opacity: .9; text-shadow: 0 0 6px var(--wk-deep), 0 0 2px var(--wk-deep); transition: opacity .4s, color .4s; }
  /* Past projects rest dim and wake when chosen */
  .wk-body[data-orbit="past"] .wk-scene { opacity: .62; filter: saturate(.6) brightness(.92); }
  .wk-body[data-orbit="past"]:is(.is-on, :hover) .wk-scene { opacity: .95; filter: none; }
  .wk-body[data-orbit="past"] .wk-tag { opacity: .75; }
  @media (min-width: 761px) { .wk__sky.is-focused .wk-body[data-orbit="now"]:not(.is-on, .is-filtered) .wk-scene { opacity: .82; } }
  .wk__sky .wk-body.is-filtered { opacity: .2; filter: saturate(.4); }
  .wk-body.is-on .wk-scene { transform: scale(1.07); }
  [data-k="formic"] .wk-tag { transform: translate(-50%, 18px); }
  .wk-body.is-on .wk-tag { opacity: 1; color: var(--wk-on); }
  .wk-cap { display: none; }

  .wk-core { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: block; height: auto; }
  .wk-scene svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }

  /* PO'DEX: three moons hold one orbit */
  .wk-podex .wk-core { width: 56%; }
  .wk-orbit { position: absolute; inset: 4%; border-radius: 50%; border: 1px dashed #ffffff33; animation: wk-spin 22s linear infinite; }
  .wk-orbit i { position: absolute; left: 50%; top: 50%; width: 11%; aspect-ratio: 1; margin: -5.5% 0 0 -5.5%; border-radius: 50%; background: var(--mc); box-shadow: 0 0 10px var(--mg); transform: rotate(var(--a)) translateY(-46cqw); }

  /* BurnBar: a corona of spend bars */
  .wk-burn .wk-core { width: 46%; filter: drop-shadow(0 0 18px #f7795866); }
  .wk-corona { position: absolute; inset: 0; }
  .wk-corona i { position: absolute; left: 50%; top: 50%; width: 2.6%; margin-left: -1.3%; border-radius: 2px; transform-origin: 50% 0; transform: rotate(var(--a)) translateY(25cqw); background: linear-gradient(var(--wk-gd), var(--wk-ember)); opacity: .85; animation: wk-flare 2.6s var(--wk-ease) infinite alternate; animation-delay: var(--d); }

  /* Formic: the waiting agent pulses */
  .wk-formic .wk-pulse { transform-box: fill-box; transform-origin: center; opacity: 0; }
  .wk-formic .wk-node.is-wait .wk-pulse { animation: wk-ping 1.6s var(--wk-ease) infinite; }
  .wk-formic .wk-node.is-wait .wk-star { fill: #eedfc3; }

  /* JobBored: a Sheet's cells, one next step at a time */
  .wk-jobs .wk-cell { fill: #ffffff14; transition: fill .35s; }
  .wk-jobs .wk-cell.is-lit { fill: #59cb89; }
  .wk-jobs .wk-cell.is-next { fill: #eedfc3; }

  /* CubeLove: a voxel planet with its heart for a moon */
  .wk-cube canvas { position: absolute; inset: 8%; width: 84%; height: 84%; image-rendering: pixelated; }
  .wk-moon { position: absolute; inset: -4%; animation: wk-spin 16s linear infinite reverse; }
  .wk-moon img { position: absolute; width: 19%; height: auto; left: 40.5%; top: -2%; border-radius: 24%; animation: wk-spin 16s linear infinite; filter: drop-shadow(0 0 8px #ff6b8a66); }
  .wk-body[data-orbit="past"] :is(.wk-moon, .wk-moon img) { animation-duration: 30s; }
  .wk-body[data-orbit="past"] .wk-node.is-wait .wk-pulse { animation-duration: 2.6s; }

  /* Trauma scheduling: a still crimson body inside a 24-hour dial, marked at the 7:00 handover */
  .wk-trauma .wk-core { width: 46%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle at 40% 40%, #ffe7c2, #f59e0b 35%, #c6093b 75%); box-shadow: 0 0 18px #f59e0b99, 0 0 36px #c6093b88; }

  /* Off screen the scenes hold still */
  &.is-paused *, &.is-paused *::before { animation-play-state: paused !important; }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
    .wk__stars, .wk-body { translate: none; }
    .wk__orbits, .wk-ring-label { animation: none; }
  }

  /* ---------- Narrow desktop: the sky moves under the copy ---------- */
  @media (max-width: 1023px) and (min-width: 761px) {
    .wk__wrap { grid-template-columns: minmax(0, 1fr); }
    .wk__copy { max-width: 40rem; }
    .wk__skywrap { margin-right: 0; }
  }

  /* ---------- Phone: the same orbits, a taller sky and larger bodies to tap ---------- */
  @media (max-width: 760px) {
    &.wk--page { min-height: 0; display: block; }
    .wk__wrap { grid-template-columns: minmax(0, 1fr); padding-block: 32px 24px; }
    .wk__panel { display: none; }
    .wk__skywrap { margin-inline: calc(-.5 * var(--wk-gutter)); }
    .wk__sky { aspect-ratio: 1000 / 1000; }
    .wk-body[data-orbit="now"] { --s: 25; }
    .wk-body[data-orbit="past"] { --s: 19; }
    .wk-tag { font-size: 12px; }
    .wk-ring-label { font-size: 9.5px; }
    .wk-legend a { min-height: 44px; }
  }
}

/* ---------- Without scripting ---------- */
/* The canvas stays blank, so a quiet tiled field stands in */
html:not(.js) [data-work-sky] .wk__stars {
  background-image: radial-gradient(1px 1px at 22px 34px, #faf7edaa, #0000), radial-gradient(1px 1px at 151px 92px, #78cdc699, #0000), radial-gradient(1.4px 1.4px at 83px 171px, #faf7edcc, #0000), radial-gradient(1px 1px at 214px 223px, #e5af5299, #0000), radial-gradient(1px 1px at 47px 251px, #faf7ed88, #0000), radial-gradient(1.2px 1.2px at 301px 57px, #faf7ed99, #0000);
  background-size: 263px 281px, 373px 331px, 467px 409px, 263px 281px, 373px 331px, 467px 409px;
}
/* CubeLove shows a still frame of its planet */
html:not(.js) [data-work-sky] .wk-cube canvas { background: url("/work/assets/constellation/cubelove-planet.webp") center / 100% no-repeat; }
