/* The hero stage: one flattened plate, the WebGL layer over it, the coded sign and the gulls, all on one stage.
   The stage keeps the art's aspect and anchors to the bottom right, so the shop never leaves the frame. */
/* The framing: the stage is drawn larger than the hero and pushed past its lower right corner, so the shop and the tree
   rise toward the navigation and the copy sits against the scene. Scale is relative to the smallest stage that covers
   the hero; the pushes are fractions of the stage's own width and height. ?frame=original restores the full painting.
   Every layer (plate, canvas, sign, boat, door, maps) is placed in stage fractions, so it moves with the frame. */
.scene { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; container-type: size; }
.scene-stage { position: absolute; --art-ratio: 1.6; --frame-scale: 1.42; --frame-x: .03; --frame-y: .07; aspect-ratio: 1672 / 1045;
  --stage-width: calc(max(100cqw, 100cqh * var(--art-ratio)) * var(--frame-scale));
  width: var(--stage-width); right: calc(var(--stage-width) * var(--frame-x) * -1); bottom: calc(var(--stage-width) / var(--art-ratio) * var(--frame-y) * -1); }
@media (orientation: portrait) { .scene-stage { --art-ratio: .46355; --frame-scale: 1.5; --frame-x: 0; --frame-y: .014; aspect-ratio: 941 / 2030; } }
.scene-frame-original .scene-stage { --frame-scale: 1; --frame-x: 0; --frame-y: 0; }
.scene-stage picture { display: contents; }
.scene-plate { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; object-fit: cover; }
@media (orientation: landscape) { .scene-only-tall { display: none !important; } }
@media (orientation: portrait) { .scene-only-wide { display: none !important; } }
/* The canvas covers only the part of the stage that the hero shows, and CSS places it, so starting the scene moves
   no box (layout shift). The stage's right and bottom edges sit past the hero by the frame pushes; its left and top
   edges are cut wherever the stage is larger than the hero. hero_scene.js reads this box for the shader's view. */
.scene-canvas { position: absolute;
  --shown-width: calc(var(--stage-width) * (1 - var(--frame-x))); --shown-height: calc(var(--stage-width) / var(--art-ratio) * (1 - var(--frame-y)));
  left: max(0px, var(--shown-width) - 100cqw); top: max(0px, var(--shown-height) - 100cqh);
  width: min(var(--shown-width), 100cqw); height: min(var(--shown-height), 100cqh); }

/* the sign: both wrappers share the hinge on the iron arm */
.scene-sign { position: absolute; }
.scene-sign__swing { position: absolute; inset: 0; will-change: transform; }
.scene-sign img { position: absolute; left: 0; top: 0; width: 100%; height: auto; max-width: none; }
.scene-sign__tint { opacity: 0; }
.scene-sign-hit { position: absolute; pointer-events: auto; }
/* The lettering on the board. It is sized from the board's own width and turned to the board's painted slope,
   and it multiplies into the paint so the tree's shadow still falls across it. */
.scene-sign { container-type: inline-size; }
.scene-sign__word { position: absolute; left: 52%; top: 61%; translate: -50% -50%; rotate: 4.9deg; font: 400 22cqw/1 'Gloock', Georgia, serif; letter-spacing: .08em; text-transform: uppercase; color: #5b2a14; mix-blend-mode: multiply; white-space: nowrap; }
.scene-sign--tall .scene-sign__word { rotate: 2.2deg; top: 62%; }
.scene-sign--wide { left: 53.409%; top: 53.164%; width: 7.416%; aspect-ratio: 124 / 103.441; }
.scene-sign--wide, .scene-sign--wide .scene-sign__swing { transform-origin: 13.71% 1.59%; }
.scene-sign-hit--wide { left: 52.931%; top: 52.398%; width: 8.373%; height: 11.43%; }
.scene-sign--tall { left: 45.696%; top: 76.781%; width: 9.245%; aspect-ratio: 87 / 71.344; }
.scene-sign--tall, .scene-sign--tall .scene-sign__swing { transform-origin: 13.79% 3.57%; }
.scene-sign-hit--tall { left: 44.846%; top: 76.387%; width: 10.946%; height: 4.303%; }

/* gulls: position, flip and depth on the bird, wing pose on the sprite */
.scene-gulls { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.scene-gull { position: absolute; left: 0; top: 0; display: block; width: clamp(46px, 4.4vw, 80px); opacity: 0; will-change: transform; }
.scene-gull__clip { display: block; width: 100%; aspect-ratio: 3 / 2; overflow: hidden; }
.scene-gull__sheet { display: block; width: 1200%; max-width: none; height: auto; }

/* leaves that come loose: each one a dab of the paint it fell from */
.scene-leaves { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.scene-leaf { position: absolute; left: 0; top: 0; border-radius: 0 100% 0 100%; opacity: 0; will-change: transform, opacity; }

.scene-wind-debug { position: absolute; right: 12px; top: 76px; z-index: 20; border-radius: 8px; }

/* The one soft patch behind the hero copy, where the painted sky starts to lighten. */
@media (orientation: landscape) {
  .hero::after { content: ''; position: absolute; left: 0; top: 0; z-index: 1; width: 64vw; height: 620px; background: radial-gradient(ellipse 58% 36% at 28% 58%, rgb(14 52 122 / .28), rgb(14 52 122 / .16) 58%, transparent 100%); pointer-events: none; }
}

/* Arrival: the painting is there from the first frame, slightly close, and settles back onto the shop. */
@media (prefers-reduced-motion: no-preference) {
  .scene { transform-origin: 74% 78%; animation: scene-settle 1.8s cubic-bezier(.23, 1, .32, 1) both; }
  @media (orientation: portrait) { .scene { transform-origin: 62% 86%; } }
}
@keyframes scene-settle { from { transform: scale(1.05); } to { transform: none; } }

/* The sailboat is lifted off the painting so it can cross the water. */
.scene-boat { position: absolute; max-width: none; will-change: transform; }
.scene-boat--wide { left: 26.316%; top: 83.673%; width: 2.552%; }
.scene-boat--tall { left: 21.679%; top: 84.926%; width: 5.739%; }
@media (orientation: portrait) and (max-width: 599px) { .scene-boat--tall { display: none; } }   /* a phone shows only a sliver of the water, behind the planters */
/* Painted parts that sit above the canvas dim with the evening. */
.scene-sign, .scene-boat, .scene-gulls, .scene-leaves { filter: brightness(calc(1 - .5 * var(--dusk, 0))) saturate(calc(1 - .2 * var(--dusk, 0))); }

/* The receipt hangs from a ticket rail, the steel bar a restaurant's pass clips its order tickets into. The rail is
   always there, at every size and with motion reduced; on arrival the paper feeds down out of it, and the paper is
   clipped at the rail's lip and nowhere else (clip-path, so the rail and the shadow can reach past the paper's sides).
   Two screw heads, a lit top edge and a dark lip are what make the bar read as a fitting and not as a bar of colour. */
.receipt { position: relative; overflow: visible; }
.receipt__paper { padding-top: 15px; }
.receipt::before { content: ""; position: absolute; z-index: 1; top: -4px; left: -11px; right: -11px; height: 11px; border-radius: 2px; pointer-events: none;
  background:
    radial-gradient(circle at 7px 50%, #fbf7ef 0 .8px, #8a8379 1.4px 2.3px, transparent 2.9px),
    radial-gradient(circle at calc(100% - 7px) 50%, #fbf7ef 0 .8px, #8a8379 1.4px 2.3px, transparent 2.9px),
    repeating-linear-gradient(90deg, rgb(255 255 255 / .08) 0 1px, transparent 1px 5px),
    linear-gradient(#f6f2ea, #d6d0c6 20%, #aaa49a 52%, #c4beb4 76%, #77716a);
  box-shadow: 0 3px 3px -1px rgb(22 14 6 / .42), inset 0 -1.5px 0 rgb(48 34 20 / .5), inset 0 1px 0 rgb(255 255 255 / .7); }
@media (prefers-reduced-motion: no-preference) {
  .receipt { clip-path: inset(-4px -32px -44px -32px); }
}

/* Evening prototype: reserve the receipt space under the rail, then print it the same way when the first table is seated. */
@media (prefers-reduced-motion: no-preference) {
  .scene-receipt-pending .receipt__paper { visibility: hidden; animation: none; transform: translateY(-102%); }
  .scene-receipt-ready .receipt__paper { animation: receipt-print .75s steps(10, end) .15s both; }
}

/* The main button is at full colour from the first frame, so it never reads as disabled: it rises with the copy but
   does not fade in. */
@media (prefers-reduced-motion: no-preference) {
  .hero__actions.rise { animation-name: rise-in-place; }
}
@keyframes rise-in-place { from { transform: translate3d(0, 10px, 0); } to { transform: none; } }

/* The front door (?door=1, hero_scene.js): the leaf turns on its hinge into a painted room, and at evening the open
   door lights the step and the sidewalk. Shut, every part is hidden and the hero is exactly the painting. */
.scene-doorway, .scene-door-light, .scene-door-glow { position: absolute; visibility: hidden; pointer-events: none; }
/* Everything that fades is its own compositor layer, so a fade never repaints the painting under it. */
.scene-door-light, .scene-door-glow, .scene-doorway__guests, .scene-door-evening, .scene-door-leaf__shade, .scene-door-leaf__warm { will-change: opacity; }
.scene-stage.is-door-open .scene-doorway, .scene-stage.is-door-open .scene-door-light, .scene-stage.is-door-open .scene-door-glow { visibility: visible; }
.scene-doorway { overflow: hidden; }
.scene-doorway img, .scene-door-leaf img { position: absolute; left: 0; top: 0; display: block; width: 100%; height: 100%; max-width: none; }
.scene-door-evening { opacity: var(--dusk, 0); }
.scene-doorway__guests { opacity: 0; }
.scene-door-leaf { position: absolute; left: 0; top: 0; width: 100%; height: 100%; transform-origin: 0 0; will-change: transform; }
.scene-door-leaf__shade, .scene-door-leaf__warm { position: absolute; inset: 0; opacity: 0; }
/* The free edge's thickness: the door's green paint wrapping round the edge, in the shade of the jamb, with the
   street's light on the corner it shares with the face. It is drawn on a 10 by 100 box that the script maps onto the face. */
.scene-door-edge { position: absolute; left: 0; top: 0; width: 10px; height: 100px; transform-origin: 0 0; opacity: 0; will-change: transform, opacity;
  background: linear-gradient(90deg, color-mix(in srgb, #2f6a5c calc(100% - var(--dusk, 0) * 70%), #3a1c10) 0 30%, color-mix(in srgb, #173a33 calc(100% - var(--dusk, 0) * 60%), #2a120a)); }
.scene-door-leaf__shade { background: #140f0c; }
.scene-door-leaf__warm { background: #ff9442; mix-blend-mode: soft-light; }
.scene-door-light__ground { position: absolute; inset: 0; background-size: 100% 100%; }
.scene-door-glow { background-size: 100% 100%; }
.scene-door-hit { position: absolute; pointer-events: auto; }

/* Gloock draws the dollar sign's stem as a hairline, so against the painted sky "$40,000" reads as "S40,000".
   Two copies of the sign offset sideways (a faux bold) widen its vertical stem to the weight of the digits' thin
   strokes and leave the curves of the S almost as drawn. ::first-letter selects the "$" alone. */
.hero h1::first-letter { text-shadow: .016em 0 currentColor, -.016em 0 currentColor, .011em 0 currentColor, -.011em 0 currentColor, .0055em 0 currentColor, -.0055em 0 currentColor; }

/* Phones: the dining room is framed directly under the receipt, so the promise and its demonstration read as one group
   (visual grouping, by proximity). The stage is sized from where the receipt ends: the copy's height is known from its
   own rules (padding 12svh, a three-line headline at 9.6vw, then the lede, the button and the railed receipt, about
   233px), and the stage is drawn as large as it can be while the oval of the hanging sign stays clear under the
   receipt. The oval's top sits 21.4% of the painting's height above the hero's foot (78.6% down, with the stage's foot
   1.4% under the hero), so the stage's height is the space left under the receipt divided by .2. The roofline then
   runs behind the receipt. The stage stays between 1.25 times the cover size and 2.1 times the hero's width, past
   which the dining room would be cropped and the paint enlarged too far. Once the stage is wider than the screen, the
   screen starts at 43.5% of the painting, just left of the shop's corner, so the corner, the sign, the door and both
   windows with their tables stay in view. */
@media (orientation: portrait) and (max-width: 599px) {
  .hero__lede { margin-top: 12px; }
  .hero__actions { margin-top: 20px; }
  .receipt { margin-top: 22px; }
  .scene-stage {
    --cover-width: max(100cqw, 100cqh * var(--art-ratio));
    --receipt-bottom: calc(clamp(88px, 12svh, 150px) + 29.4vw + 233px);
    --stage-width: clamp(var(--cover-width) * 1.25, (100cqh - var(--receipt-bottom) - 14px) / .2 * var(--art-ratio), 210cqw);
    --overflow-right: clamp(0px, var(--stage-width) * .565 - 100cqw, var(--stage-width) - 100cqw);
    right: calc(var(--overflow-right) * -1);
  }
  .scene-canvas { --shown-width: calc(var(--stage-width) - var(--overflow-right)); }
  .scene { transform-origin: 50% 74%; }
}
.scene-frame-original .scene-stage { --stage-width: max(100cqw, 100cqh * var(--art-ratio)); --overflow-right: 0px; }
/* Portrait tablets: at the phones' framing the shop rises behind the receipt, so the stage is drawn a little smaller. */
@media (orientation: portrait) and (min-width: 600px) { .scene-stage { --frame-scale: 1.2; } }

@media (max-width: 370px) {
  .receipt__paper { padding-inline: 9px; font-size: .8rem; }
}
