/* gala/square.css — the resting state's placement, and nothing else
 * ===========================================================================
 * THE SQUARE IS A MODE, NOT A LAYOUT. Victor, 3 Nov 2026: "What if we truly
 * treat it like a billboard, meaning it's like NYC Times Square? We have
 * videos and images playing constantly on the whole canvas, and sometimes it
 * has to be a cluster of canvases playing the same video."
 *
 * This file places the moving surfaces. It declares no colour token, no font
 * and no shadow — gala/square.js owns the behaviour and the consuming page
 * owns the look, which is gala/dissolve.js's own division and the reason that
 * module could be adopted by a second surface without an edit.
 *
 * ── THE ONE DECISION THAT MADE EVERYTHING ELSE EASY ───────────────────────
 * A SURFACE IS AN ABSOLUTELY POSITIONED GRID CHILD, so it is placed BY the
 * grid and takes part in none of it. An in-flow grid child spanning two rows
 * and two columns occupies four slots, and the nine canvases are auto-placed
 * by DOM order with no explicit placement of their own — so the auto cursor
 * would step over the occupied slots and every canvas after the span would
 * shift. webmcp/realestate-gala.js already names that hazard in its own
 * words: pinning two seats and leaving seven to auto-placement "depends on
 * how the auto cursor steps over an explicitly placed item, which is not a
 * thing to rest a composition on."
 *
 * An out-of-flow child is exempt. It does not take up space and it does not
 * move anything, and its grid-placement properties still give it the
 * rectangle of the area named — so the clusters get their geometry from the
 * solved tracks for free, the seams between the panels they cover included,
 * and NOT ONE canvas needs to be pinned, inlined or touched. The measured
 * consequence is the thing the mode had to prove: with the square on and off,
 * all nine rectangles are identical.
 *
 * `.vista` therefore needs to be the containing block, which is the only
 * declaration here that reaches an element the shell owns. `position:
 * relative` with no offsets and no `z-index` moves nothing and creates no
 * stacking context, so the three dials at `z-index: 20` in gala/sky.css stay
 * above the square and stay clickable. It is scoped to `[data-square-on]`, so
 * a page that loads this file and never enters the mode gets no declaration
 * at all — gala/grounds.css's additive discipline, for its reason.
 *
 * ── AND IT NEVER HAS TO BEAT THE STACKING RULE, BECAUSE THEY NEVER MEET ───
 * nine/shell.css carries `.vista:not([data-stack="900"]) > .canvas {
 * grid-column: var(--stack-col, 1) !important }` and a sibling for the
 * stacked family — but BOTH ARE INSIDE A `max-width` MEDIA QUERY. Above the
 * breakpoint there is no grid placement on a canvas at all, so a span needs
 * no weight to win; below it, the square does not exist. Every rule here is
 * inside the matching `min-width`, one per family, mirroring that file's own
 * structure rather than inventing a third breakpoint.
 *
 * That is not tidiness. `grid-row` is deliberately NOT reset by those rules
 * — "a page that assigns stacked rows by hand must keep that" — so a span
 * that declared `grid-row` outside a media query would survive into the
 * stacked column and overlap the canvases it used to cover, on a phone, with
 * nothing erroring. The breakpoint is what makes that impossible.
 *
 * ── WHAT A CLUSTER'S ASPECT ACTUALLY IS ───────────────────────────────────
 * Derived from the solved tracks rather than measured off one screen, so the
 * figures hold at every frame width. With the frame at 16:9, the columns at
 * 1 : 3 : 1 and the rows at .3164 : 1 : .2379 and the two seams equal:
 *
 *   one seat   top corner 1.7778 · rail 0.5625 · stage 1.6875 · brow 5.3339
 *              bottom corner 2.3644 · input 7.0907
 *   block      rows 1-2 x two columns   0.7934 x 0.46873  =  1.6926
 *   wide       row 2 x three columns    0.9780 x 0.34772  =  2.8126
 *   marquee    row 1 x three columns    0.9780 x 0.11001  =  8.8899
 *   six        rows 1-2 x three columns 0.9780 x 0.46873  =  2.0865
 *   tower      rows 1-2 x one column    0.1956 x 0.46873  =  0.4173
 *
 * THE BLOCK IS WHY THE CLUSTERS ARE WORTH HAVING. 1.6926 is 4.8% from 16:9,
 * which is the shape of every long film this house holds — so a film in a
 * four-panel block loses 4.8% of its width to the crop and nothing else. The
 * marquee at 8.8899 keeps a FIFTH of a 16:9 frame, so it carries type and
 * stills and must never be given a film; square.js refuses one there rather
 * than leaving it to a reader of this comment.
 *
 * THE TOWERS ARE DECLARED AND DEFAULT OFF. A 9:16 short in 0.4173 loses 26%
 * of its width, and a short's subject is centred and narrow, so the crop
 * takes the thing being shown. The grid is ALREADY right for a short: a rail
 * is 0.5625 exactly. Clustering helps the landscape film and nothing else,
 * which is a finding about the grid rather than a limitation of this file.
 *
 * ── THE SEAMS ARE COVERED AND THAT IS A DECISION, NOT AN OVERSIGHT ────────
 * A cluster is ONE element over the seats it spans, so the gutters inside it
 * are painted over and the cluster reads as one screen. The alternative —
 * each panel showing its own slice, with the frame still visible — reads as a
 * video wall and cannot be had without either N copies of one film, which is
 * the synchronisation problem nobody wins, or a mask rebuilt from the USED
 * track sizes on every resize, because the tracks are `fr` and no stylesheet
 * can know their pixels. Not built, named, and it is a look decision.
 * ======================================================================== */

/* THE CONTAINING BLOCK, and the only thing here that touches the shell's own
   element. Scoped to the mode, so this file is inert until square.js enters
   it. No `z-index`: the rail must stay on top. */
.vista[data-square-on] { position: relative; }

/* ── A SURFACE ────────────────────────────────────────────────────────────
   Out of flow, so it places nothing and moves nothing. `inset: 0` rather
   than relying on the auto offsets resolving to the grid area's padding
   edge — the computed result is the same and the declaration is what makes
   it true rather than inherited from a reading of the specification.

   `--sq-fade` is the crossfade, and it is a CSS transition on purpose.
   requestAnimationFrame does not fire in a hidden tab, so anything that
   WAITED on a frame to finish a dissolve would deadlock the rotation the
   moment somebody switched tabs, and come back to a half-faded panel. A
   transition is the browser's problem and resumes correctly. */
.vista[data-square-on] > .sq {
  position: absolute;
  inset: 0;
  margin: 0;
  overflow: hidden;
  border-radius: var(--radius, 11px);
  background: #000;
  opacity: 0;
  transition: opacity var(--sq-fade, .9s) ease;
  /* Above the canvases without creating a stacking context on .vista. A
     positioned child already paints above its static siblings; the number is
     here so two surfaces in one area have a stated order. */
  z-index: 1;
  /* THE RECORD UNDERNEATH MUST STAY REACHABLE. A surface is decoration over
     a canvas that is still in the document and still in the accessibility
     tree, so it must not swallow a click meant for what it covers, and it is
     aria-hidden in the markup square.js writes. */
  pointer-events: none;
}
.vista[data-square-on] > .sq[data-live="1"] { opacity: 1; }

/* The media fills the surface. `cover` because a billboard has no letterbox
   and the crop figures above are the price, stated. A still from the same
   playback id is the same shape as the film it was cut from, so the two
   crop identically and swapping one for the other does not reframe. */
.vista[data-square-on] > .sq > img,
.vista[data-square-on] > .sq > video {
  display: block; width: 100%; height: 100%;
  object-fit: cover; object-position: center;
  /* A surface that has not decoded yet is BLACK rather than transparent, so
     a cold start never shows a half-dissolved canvas through a surface that
     is on. The parent's own background does that; this keeps the element
     from painting a white box before its first frame. */
  background: #000;
}

/* THE CAPTION, which is the one piece of furniture a billboard needs and the
   one thing a dark rectangle cannot say for itself. It names what is playing
   and which belt asked for it, so a photograph of this page can be told from
   a photograph of a page whose media never loaded — which is the failure this
   whole mode is most likely to ship. */
.vista[data-square-on] > .sq > figcaption {
  position: absolute; inset: auto 0 0 0; margin: 0;
  padding: 10px 14px 12px;
  font: 600 10.5px/1.3 ui-monospace, monospace;
  letter-spacing: .07em; text-transform: uppercase;
  color: #fff;
  background: linear-gradient(0deg, rgba(8, 8, 12, .62), transparent);
  pointer-events: none;
}

/* ── PLACEMENT ────────────────────────────────────────────────────────────
 * EVERY PLACEMENT STATES ALL FOUR LINES, AND THE SINGLE SEATS DID NOT UNTIL
 * 3 Nov 2026. This is the one place the out-of-flow decision above costs
 * something, and it cost it silently. For an ordinary grid child `grid-area:
 * 3 / 1` means row 3, column 1, and the two `auto` end lines mean "span one
 * track". FOR AN ABSOLUTELY POSITIONED GRID CHILD THEY DO NOT: an `auto`
 * grid-placement line resolves to the grid container's PADDING EDGE, so that
 * same declaration meant row 3 from column line 1 all the way to the right
 * of the frame.
 *
 * MEASURED, because it is invisible by reading and worse than invisible on
 * screen. At a 1348px frame the bottom-left surface came back 1348px wide
 * against its seat's 263.67 -- a film across the whole bottom row while the
 * computed `grid-column` read `1`, which is why an inspector agrees with the
 * stylesheet and the picture still spans five seats it was never given.
 *
 * AND FOUR OF THE EIGHT WERE RIGHT BY ACCIDENT, which is what would have made
 * this ship. A seat in the last row or the last column has its own edge AT
 * the padding edge, so the top-right, mid-right and bottom-right surfaces
 * measured exactly correct -- a spot check that happened to land on one of
 * those would have cleared the file. The clusters were all correct already,
 * because a cluster has to state four lines to span anything.
 *
 * So the rule is: state four lines here, always, even for one seat. There is
 * no shorthand that is safe for an out-of-flow child.
 */

/* ── the unstacked family, above nine/shell.css's own 1040 ─────────────── */
@media (min-width: 1041px) {
  .vista:not([data-stack="900"])[data-square-on] > .sq[data-at="ledger"] { grid-area: 1 / 1 / 2 / 2; }
  .vista:not([data-stack="900"])[data-square-on] > .sq[data-at="figure"] { grid-area: 1 / 2 / 2 / 3; }
  .vista:not([data-stack="900"])[data-square-on] > .sq[data-at="main"]   { grid-area: 1 / 3 / 2 / 4; }
  .vista:not([data-stack="900"])[data-square-on] > .sq[data-at="poster"] { grid-area: 2 / 1 / 3 / 2; }
  .vista:not([data-stack="900"])[data-square-on] > .sq[data-at="line"]   { grid-area: 2 / 2 / 3 / 3; }
  .vista:not([data-stack="900"])[data-square-on] > .sq[data-at="still"]  { grid-area: 2 / 3 / 3 / 4; }
  .vista:not([data-stack="900"])[data-square-on] > .sq[data-at="reel"]   { grid-area: 3 / 1 / 4 / 2; }
  .vista:not([data-stack="900"])[data-square-on] > .sq[data-at="setr"]   { grid-area: 3 / 3 / 4 / 4; }

  .vista:not([data-stack="900"])[data-square-on] > .sq[data-at="block-left"]  { grid-area: 1 / 1 / 3 / 3; }
  .vista:not([data-stack="900"])[data-square-on] > .sq[data-at="block-right"] { grid-area: 1 / 2 / 3 / 4; }
  .vista:not([data-stack="900"])[data-square-on] > .sq[data-at="wide"]        { grid-area: 2 / 1 / 3 / 4; }
  .vista:not([data-stack="900"])[data-square-on] > .sq[data-at="marquee"]     { grid-area: 1 / 1 / 2 / 4; }
  .vista:not([data-stack="900"])[data-square-on] > .sq[data-at="six"]         { grid-area: 1 / 1 / 3 / 4; }
  .vista:not([data-stack="900"])[data-square-on] > .sq[data-at="tower-left"]  { grid-area: 1 / 1 / 3 / 2; }
  .vista:not([data-stack="900"])[data-square-on] > .sq[data-at="tower-right"] { grid-area: 1 / 3 / 3 / 4; }
}

/* ── PLACEMENT · the dashboard family, above its own 900 ─────────────────
   A second block rather than one written at `min-width: 901px`, because the
   two families stack at two different widths and one number could not serve
   both — nine/shell.css's own words for why that attribute exists. Between
   901 and 1040 the first family is stacked and this one is not, and each
   selector names its own, so the two can never both apply. */
@media (min-width: 901px) {
  .vista[data-stack="900"][data-square-on] > .sq[data-at="ledger"] { grid-area: 1 / 1 / 2 / 2; }
  .vista[data-stack="900"][data-square-on] > .sq[data-at="figure"] { grid-area: 1 / 2 / 2 / 3; }
  .vista[data-stack="900"][data-square-on] > .sq[data-at="main"]   { grid-area: 1 / 3 / 2 / 4; }
  .vista[data-stack="900"][data-square-on] > .sq[data-at="poster"] { grid-area: 2 / 1 / 3 / 2; }
  .vista[data-stack="900"][data-square-on] > .sq[data-at="line"]   { grid-area: 2 / 2 / 3 / 3; }
  .vista[data-stack="900"][data-square-on] > .sq[data-at="still"]  { grid-area: 2 / 3 / 3 / 4; }
  .vista[data-stack="900"][data-square-on] > .sq[data-at="reel"]   { grid-area: 3 / 1 / 4 / 2; }
  .vista[data-stack="900"][data-square-on] > .sq[data-at="setr"]   { grid-area: 3 / 3 / 4 / 4; }

  .vista[data-stack="900"][data-square-on] > .sq[data-at="block-left"]  { grid-area: 1 / 1 / 3 / 3; }
  .vista[data-stack="900"][data-square-on] > .sq[data-at="block-right"] { grid-area: 1 / 2 / 3 / 4; }
  .vista[data-stack="900"][data-square-on] > .sq[data-at="wide"]        { grid-area: 2 / 1 / 3 / 4; }
  .vista[data-stack="900"][data-square-on] > .sq[data-at="marquee"]     { grid-area: 1 / 1 / 2 / 4; }
  .vista[data-stack="900"][data-square-on] > .sq[data-at="six"]         { grid-area: 1 / 1 / 3 / 4; }
  .vista[data-stack="900"][data-square-on] > .sq[data-at="tower-left"]  { grid-area: 1 / 1 / 3 / 2; }
  .vista[data-stack="900"][data-square-on] > .sq[data-at="tower-right"] { grid-area: 1 / 3 / 3 / 4; }
}

/* ── A LIT SEAT · THE ONE THAT CANNOT BE SWITCHED OFF ─────────────────────
 * ADDED 3 Nov 2026 FOR A SECOND CONSUMER, and it is a different element in a
 * different place rather than a flag on the one above. Victor's instruction
 * for an artist's own stage is that EIGHT of the nine run and the top-left
 * holds the wordmark — which counts the chat in, while gala/dissolve.js
 * refuses to switch that seat off in its own words: "there would be no way
 * left to ask for anything back."
 *
 * BOTH RULES SURVIVE BECAUSE THE FILM GOES BEHIND THE ASK INSTEAD OF OVER
 * IT. A veiling surface is a child of the frame, out of flow, over a seat
 * whose presence went to nothing. A lit surface is a child of THE SEAT,
 * behind that seat's own content, and the seat's presence never moves. The
 * invitation to ask stays legible, reachable and in the reading order, and
 * the one thing a passer-by can always read is the way to speak.
 *
 * WHY NOT `z-index: -1` ON THE SURFACE ABOVE, WHICH IS THE OBVIOUS ONE LINE.
 * A negative index paints below the in-flow backgrounds of the frame's own
 * children, and every seat on a Gala stage carries a glass panel — so the
 * film would be behind that panel and invisible, with nothing erroring and a
 * dark strip where the picture is. Painting order is not opacity: there is no
 * index that is above a sibling's background and below its text, which is
 * exactly why this has to be a descendant instead.
 *
 * The seat becomes the containing block only while it is lit, so this file
 * stays inert on a page that never enters the mode.
 */
.canvas[data-square-lit] { position: relative; }

.canvas[data-square-lit] > .sq[data-under="1"] {
  position: absolute; inset: 0; margin: 0;
  overflow: hidden;
  border-radius: inherit;
  background: #000;
  opacity: 0;
  transition: opacity var(--sq-fade, .9s) ease;
  /* Behind the seat's own content and in front of its glass. No negative
     index, for the reason above. */
  z-index: 0;
  pointer-events: none;
}
.canvas[data-square-lit] > .sq[data-under="1"][data-live="1"] { opacity: 1; }

/* THE SEAT'S OWN CONTENT RIDES ABOVE ITS BACKDROP. Everything the seat
   already held — its clipped label, its form, its text — is lifted by one
   index and nothing else about it changes. A bare `z-index` needs a position,
   and `relative` with no offsets moves nothing. */
.canvas[data-square-lit] > :not(.sq) { position: relative; z-index: 1; }

/* AND IT IS DARKENED UNDER THE TYPE RATHER THAN DIMMED AS A WHOLE, because a
   film at low opacity reads as a fault and a film under a scrim reads as a
   lit sign. The scrim is on the surface, so it fades in and out with it. */
.canvas[data-square-lit] > .sq[data-under="1"]::after {
  content: ''; position: absolute; inset: 0;
  background: rgba(8, 8, 12, .58);
}

/* THE LIT SEAT'S CAPTION HAS TO BE POSITIONED TOO, AND IT WAS NOT. Found by
   measuring rather than by reading: the rule below this one places a caption
   on a veiling surface, the lit surface is a different element in a different
   place and matched none of it, so its caption flowed AFTER a picture that is
   already the full height of the figure and was clipped away by the figure's
   own overflow. Measured at a 1440 frame it sat at y=1071 on an 829px-tall
   page -- off the bottom of the document, painting nothing.

   THAT IS THE ONE FAILURE THIS WHOLE ARRANGEMENT EXISTS TO PREVENT. The
   provenance line is the sentence that stops a generated picture reading as a
   photograph of somebody's product, and a provenance line nobody can see is
   the same as not writing one. Smaller than the veiling caption and pinned to
   the floor of the strip, which is below the ask rather than across it. */
.canvas[data-square-lit] > .sq[data-under="1"] > figcaption {
  position: absolute; inset: auto 0 0 0; margin: 0;
  padding: 5px 14px 6px;
  font: 600 8.5px/1.35 ui-monospace, monospace;
  letter-spacing: .08em; text-transform: uppercase;
  color: #fff; opacity: .85;
  background: linear-gradient(0deg, rgba(8, 8, 12, .55), transparent);
  pointer-events: none;
}

/* ── PROVENANCE, WRITTEN BY THE MODULE AND NEVER BY A PAGE ────────────────
 * The caption's second line says what the picture IS, and square.js writes it
 * from the surface's declared source rather than taking a page's word for it.
 * A generated clip captioned as a real maker's garment is a false claim about
 * that person's work, so the one sentence that must never be forgotten is the
 * one a page cannot author. Quieter than the title, and never hidden. */
.vista[data-square-on] > .sq > figcaption > .sq-src,
.canvas[data-square-lit] > .sq > figcaption > .sq-src {
  display: block; margin-top: 3px;
  font-weight: 500; letter-spacing: .09em; opacity: .82;
}

/* NOTHING MOVES AND NOTHING FADES FOR A READER WHO ASKED FOR THAT. Under
   reduced motion square.js builds stills only and starts no film, so this
   removes the one remaining animation: the crossfade between them. A
   billboard that insists on moving is the one surface on this estate with no
   excuse for ignoring the setting. */
@media (prefers-reduced-motion: reduce) {
  .vista[data-square-on] > .sq,
  .canvas[data-square-lit] > .sq { transition: none; }
}
