/* Play area styles, all inside #play.
   - No padding above or below: page.css gives every section its one padding.
   - The side air (--g) is the Ending's and Builder's, so the words line up with theirs.
   - The ground is the page's own white (--color-surface) unless data-ground says otherwise.
   - The heading takes the page's heading face, weight, tracking and line height; its size is --size-3xl,
     since the words are a wall the Lumis bounce off.
   - The stage's height fits the page: a little under one screen, so the whole play area shows at once.
   Each Lumi copies the Ending section's nesting: a box the size of its body (the button you grab),
   a squash layer, then the engine's own square canvas, which is its body / 0.56, centred. */
#play {
  --pp-words: inside; --pp-space: bump; --pp-size: medium;   /* read by play.js */
  --g: clamp(var(--space-400), 4cqw, var(--space-900));       /* the Ending's side air */
  --pp-h: clamp(30rem, calc(100svh - 2 * var(--space-800)), 52rem);   /* lint-ok: the stage's own height, no token covers a play area */
  background: var(--color-surface);

  .pp-in { position: relative; box-sizing: border-box; padding-inline: var(--g); }

  /* The words sit inside the stage, as something to bounce off */
  .pp-words {
    position: absolute; z-index: 4; left: var(--g); top: 0;
    max-width: 38rem; margin: 0; pointer-events: none;   /* lint-ok: a measure near 65 characters */
  }
  .pp-h {
    margin: 0 0 var(--space-200);
    font-family: var(--font-display); font-weight: var(--display-weight); letter-spacing: var(--display-tight);
    font-size: var(--size-3xl); line-height: var(--line-display);
    color: var(--color-text-primary);
  }
  .pp-p { margin: 0; font-size: var(--size-lg); line-height: var(--line-snug); color: var(--color-text-secondary); text-wrap: balance; }
  .pp-p > span { display: block; }   /* each sentence on its own line */

  /* The colour ground and the words centred at the top, both set on the section tag. The ground runs
     edge to edge (data-band), so page.css puts the padding inside the colour and doubles the white beside it. */
  &[data-ground="colour"] {
    /* two soft tints of the spectrum tokens that drift through the colours, top left to bottom right;
       the background colour is their mix, which play.js hands to each Lumi as the ground it sees */
    --pp-a: color-mix(in oklab, var(--fx-spectrum-5) 16%, var(--neutral-0));
    --pp-b: color-mix(in oklab, var(--fx-spectrum-6) 16%, var(--neutral-0));
    background-color: color-mix(in oklab, var(--pp-a), var(--pp-b));
    background-image: linear-gradient(135deg, var(--pp-a), var(--pp-b));
    animation: pp-shift 24s linear infinite;
  }
  &[data-ground="colour"][data-off] { animation-play-state: paused; }
  @media (prefers-reduced-motion: reduce) { &[data-ground="colour"] { animation: none; } }

  &[data-words="top"] .pp-words { left: 50%; translate: -50% 0; text-align: center; width: max-content; max-width: calc(100% - 2 * var(--g)); }

  .pp-stage { position: relative; height: var(--pp-h); }

  /* The ground is the site's own pause control: an empty see-through button over the whole stage,
     under the Lumis (design-system.md, Motion pause control). Tap the empty ground: everything stops. */
  .pp-ground {
    position: absolute; inset: 0; z-index: 0; margin: 0; padding: 0; border: 0;
    background: transparent; cursor: pointer; border-radius: var(--radius-lg);
    -webkit-tap-highlight-color: transparent;
  }
  .pp-ground:focus-visible { outline: var(--border-focus); outline-offset: -2px; }

  /* One Lumi: the button is its body (a circle you grab); the canvas hangs round it and takes no pointer */
  .pp-l {
    position: absolute; left: 0; top: 0; z-index: 2;
    width: var(--d, 120px); height: var(--d, 120px);   /* lint-ok: play.js sets --d from the stage size */
    margin: 0; padding: 0; border: 0; background: none; border-radius: 50%;
    cursor: grab; touch-action: none; -webkit-tap-highlight-color: transparent;
  }
  .pp-l[data-held] { cursor: grabbing; }
  .pp-l.pp-main { z-index: 3; }
  &[data-space="bump"] .pp-l.pp-main { z-index: 2; }
  .pp-l:focus-visible { outline: var(--border-focus); outline-offset: var(--space-100); }
  .pp-b { position: absolute; inset: 0; display: block; transform-origin: 50% 50%; }
  .pp-b canvas {
    position: absolute; left: 50%; top: 50%; display: block; pointer-events: none;
    width: calc(var(--d, 120px) / 0.56); height: calc(var(--d, 120px) / 0.56);   /* the engine's own square: the body is 0.56 of it */
    margin: calc(var(--d, 120px) / -1.12) 0 0 calc(var(--d, 120px) / -1.12);
  }

  .pp-sr {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
    overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
  }

  /* A Lumi that could not get a drawing surface is left out, never swapped for a picture */
  .pp-l[hidden] { display: none; }
}
@media (max-width: 767.98px) {
  #play { --pp-h: clamp(28rem, calc(100svh - 2 * var(--space-700)), 46rem); }   /* lint-ok: phone stage height */
}

/* the colour ground's drift: each tint walks the spectrum, a quarter turn apart */
@property --pp-a { syntax: '<color>'; inherits: true; initial-value: white; }
@property --pp-b { syntax: '<color>'; inherits: true; initial-value: white; }
@keyframes pp-shift {
  0%, 100% { --pp-a: color-mix(in oklab, var(--fx-spectrum-5) 16%, var(--neutral-0)); --pp-b: color-mix(in oklab, var(--fx-spectrum-6) 16%, var(--neutral-0)); }
  25% { --pp-a: color-mix(in oklab, var(--fx-spectrum-6) 16%, var(--neutral-0)); --pp-b: color-mix(in oklab, var(--fx-spectrum-1) 16%, var(--neutral-0)); }
  50% { --pp-a: color-mix(in oklab, var(--fx-spectrum-1) 16%, var(--neutral-0)); --pp-b: color-mix(in oklab, var(--fx-spectrum-2) 16%, var(--neutral-0)); }
  75% { --pp-a: color-mix(in oklab, var(--fx-spectrum-4) 16%, var(--neutral-0)); --pp-b: color-mix(in oklab, var(--fx-spectrum-5) 16%, var(--neutral-0)); }
}

/* The whole page fade (case/trip.js): the ground is the page's, and the two drifting tints are one layer
   fixed behind the page (#cs-wash, page.css), so this section paints none and runs no drift of its own. */
html[data-cs-fade="page"] main > #play[data-ground="colour"] { background: none; animation: none; }
