/* ambient.css: the light and motion layer for every inner page (9 Nov 2026). Script: /g/ambient.js. Linked last in
   <head> by tools/postbuild.mjs step 5. Everything that hides content waits for html.amb-on (set by the script), so a
   page without the script reads exactly as before. Grammar: runs/catalog-01/GRAMMAR.md (one low warm key, objects cast
   shadows, magma only in transitions). */

:root { --amb-ease: cubic-bezier(.2, .8, .2, 1); --amb-settle: cubic-bezier(.16, 1, .3, 1); }
html { background: #140907; }

/* ------------------------------------------------------------ 1. the ground */
.amb-ground { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.amb-ground.amb-own { z-index: -1; }
/* old pages (body.g-one): the opaque section grounds step back so the lit floor shows through */
body.g-one { background: transparent !important; }
body.g-one :is(.t1, .t5, .pg-body, .lmain, .ltabs, .lhero) { background: transparent !important; }
body.g-one :is(.t2, .t3, .t4, .t6) { background: rgba(28, 12, 7, .5) !important; }
body.g-page { background: transparent; }

.amb-gl { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 1.2s var(--amb-ease); }
.amb-ground.is-live .amb-gl { opacity: 1; }
/* CSS ground (phones, no WebGL): the raking beam and a slow warm drift. Under the canvas when it runs. */
.amb-css { position: absolute; inset: -20%; opacity: .9;
  background:
    linear-gradient(174deg, rgba(8, 3, 2, .34) 0%, rgba(8, 3, 2, .2) 34%, rgba(255, 196, 140, .07) 46%, rgba(255, 204, 150, .09) 52%, rgba(8, 3, 2, .2) 64%, rgba(8, 3, 2, .34) 100%),
    radial-gradient(60% 45% at 30% 30%, rgba(255, 120, 50, .07), transparent 70%),
    radial-gradient(130% 70% at 50% 115%, #1c0c07 0%, transparent 62%);
  animation: amb-drift 28s ease-in-out infinite alternate; }
.amb-ground.is-live .amb-css { display: none; }
@keyframes amb-drift { from { transform: translate3d(-3%, -2%, 0) rotate(-1.5deg); } to { transform: translate3d(3%, 3%, 0) rotate(1.5deg); } }
/* grain over the ground, stepped (a smooth grain reads as noise) */
.amb-ground::after { content: ""; position: absolute; inset: -64px; opacity: .06; pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .9 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: amb-grain 1s steps(12) infinite; }
@keyframes amb-grain { 0% { transform: translate(0, 0); } 25% { transform: translate(-31px, 17px); } 50% { transform: translate(23px, -29px); } 75% { transform: translate(-13px, -41px); } 100% { transform: translate(37px, 11px); } }

/* ------------------------------------------------------------ 2. reveals (only once the script runs) */
.amb-on .amb-rise { opacity: 0; transform: translate3d(0, 22px, 0); }
.amb-on .amb-rise.amb-in { opacity: 1; transform: none;
  transition: opacity .9s var(--amb-ease) var(--d, 0ms), transform 1.1s var(--amb-settle) var(--d, 0ms); }
.amb-on .amb-pic { opacity: 0; clip-path: inset(18% 0 0 0 round 12px); transform: translate3d(0, 30px, 0) scale(.985); }
.amb-on .amb-pic.amb-in { opacity: 1; clip-path: inset(0 0 0 0 round 0); transform: none;
  transition: opacity .7s var(--amb-ease) var(--d, 0ms), clip-path 1.25s var(--amb-settle) var(--d, 0ms), transform 1.25s var(--amb-settle) var(--d, 0ms); }
.amb-w { display: inline-block; overflow: clip; overflow-clip-margin: .18em; vertical-align: top; padding-bottom: .06em; margin-bottom: -.06em; }
.amb-w > span { display: inline-block; }
.amb-on .amb-split .amb-w > span { transform: translate3d(0, 105%, 0) rotate(2deg); opacity: 0; }
.amb-on .amb-split.amb-in .amb-w > span { transform: none; opacity: 1;
  transition: transform 1.05s var(--amb-settle), opacity .6s var(--amb-ease);
  transition-delay: calc(var(--d, 0ms) + var(--i, 0) * 55ms); }
.amb-on .amb-now, .amb-on .amb-now * { transition: none !important; }

/* ------------------------------------------------------------ 3. objects in the light */
/* standing headlines: a lit top face and a shadow cast on the floor below */
:is(body.g-page, body.g-one) :is(h1, .g-h1) { text-shadow: 0 -1px 0 rgba(255, 214, 170, .12), 0 3px 2px rgba(0, 0, 0, .35); }
:is(body.g-page, body.g-one) h2 { text-shadow: 0 2px 2px rgba(0, 0, 0, .3); }
/* plates: a lit top edge and a soft cast shadow, deeper when lifted */
.amb-lit { isolation: isolate; }
:is(.w-card, .g-pn a, details.amb-lit, .g-strip .g-wrap.amb-lit) { box-shadow: inset 0 1px 0 rgba(255, 214, 170, .07), 0 28px 50px -30px rgba(0, 0, 0, .8);
  transition: box-shadow .5s var(--amb-ease), transform .5s var(--amb-settle), background .2s, border-color .2s; }
:is(.w-card, .g-pn a):hover { box-shadow: inset 0 1px 0 rgba(255, 214, 170, .12), 0 40px 70px -32px rgba(0, 0, 0, .9); transform: translateY(-4px); }
.g-thumb, .w-shot, .g-laptop, .g-phone { box-shadow: 0 30px 60px -28px rgba(0, 0, 0, .85), 0 0 0 1px rgba(255, 214, 170, .04); }
.amb-lit::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 1; opacity: 0;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), rgba(255, 190, 130, .10), rgba(255, 120, 50, .04) 40%, transparent 70%);
  transition: opacity .45s var(--amb-ease); }
.amb-lit:hover::after { opacity: 1; }
.g-row.amb-lit::after { background: radial-gradient(600px circle at var(--mx, 50%) var(--my, 50%), rgba(255, 190, 130, .09), transparent 65%); }
/* images inside thumbs and shots drift up a touch on hover, as if lifted toward the key */
.g-thumb img, .w-shot img { transition: transform 1.1s var(--amb-settle), filter .6s var(--amb-ease); }
.w-card:hover .w-shot img { transform: scale(1.035); filter: brightness(1.06) saturate(1.05); }
/* tilt toward the pointer */
.amb-tilt { transform: perspective(1100px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform .9s var(--amb-settle); will-change: transform; }
/* buttons lean */
.amb-lean { transition: translate .5s var(--amb-settle), background .2s, border-color .2s, color .2s, transform .12s; }
/* link underlines draw in from the left on body copy */
:is(body.g-page, body.g-one) :is(p, li) > a:not([class]) { text-decoration: none; background: linear-gradient(currentColor, currentColor) 0 100% / 100% 1px no-repeat;
  transition: background-size .45s var(--amb-ease), color .2s; padding-bottom: 1px; }
:is(body.g-page, body.g-one) :is(p, li) > a:not([class]):hover { background-size: 0 1px; background-position: 100% 100%; color: #ffb48a; }

/* ------------------------------------------------------------ 4. /work: the floating cover */
.amb-cover { position: fixed; left: 0; top: 0; z-index: 30; width: 340px; aspect-ratio: 16 / 10; margin: -110px 0 0 28px; pointer-events: none;
  border-radius: 12px; overflow: hidden; background: #0c0b0d; opacity: 0; scale: .86;
  box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .9), 0 0 0 1px rgba(255, 214, 170, .08);
  transition: opacity .35s var(--amb-ease), scale .5s var(--amb-settle); }
.amb-cover.show { opacity: 1; scale: 1; }
.amb-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transform: scale(1.12);
  transition: opacity .35s var(--amb-ease), transform .9s var(--amb-settle); }
.amb-cover img.on { opacity: 1; transform: none; }
@media (min-width: 821px) { .amb-has-cover .g-row .g-thumb { opacity: .55; transition: opacity .3s; } .amb-has-cover .g-row:hover .g-thumb { opacity: 1; } }

/* ------------------------------------------------------------ 5. scroll hairline + page change */
.amb-progress { position: fixed; left: 0; right: 0; top: 0; height: 2px; z-index: 60; pointer-events: none; transform-origin: 0 50%; transform: scaleX(0);
  background: linear-gradient(90deg, rgba(255, 90, 31, 0), #ff5a1f 40%, #ffb070); opacity: .85; }

@view-transition { navigation: auto; }
.g-head { view-transition-name: amb-head; }
::view-transition-group(amb-head) { animation-duration: 0s; }
::view-transition-old(root) { animation: amb-sink .8s var(--amb-ease) both; }
::view-transition-new(root) { animation: amb-wipe .8s var(--amb-settle) both; }
@keyframes amb-sink { to { transform: translate3d(0, -4%, 0) scale(.975); filter: brightness(.3) saturate(.8); } }
@keyframes amb-wipe { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0 0 0 0); } }
/* the molten lip: drawn on the incoming page at the wipe's leading edge, same curve and length, then gone.
   Magma appears here and nowhere else on the page. */
html:active-view-transition::after { content: ""; position: fixed; left: 0; right: 0; top: 0; height: 150px; z-index: 2147483647; pointer-events: none;
  background:
    linear-gradient(180deg, #ffd29a 0, #ff8a3d 2px, rgba(255, 90, 31, .85) 6px, rgba(255, 90, 31, 0) 100%),
    url("/g/a/liquid-512.webp") 50% 0 / 100% 100% no-repeat;
  background-blend-mode: screen;
  -webkit-mask-image: linear-gradient(180deg, #000 0, #000 8px, rgba(0, 0, 0, .55) 30px, transparent 100%);
          mask-image: linear-gradient(180deg, #000 0, #000 8px, rgba(0, 0, 0, .55) 30px, transparent 100%);
  animation: amb-lip .8s var(--amb-settle) both; }
@keyframes amb-lip { 0% { transform: translate3d(0, 100vh, 0); opacity: 1; } 85% { opacity: 1; } 100% { transform: translate3d(0, 0, 0); opacity: 0; } }

/* ------------------------------------------------------------ reduced motion and print */
@media (prefers-reduced-motion: reduce) {
  .amb-css, .amb-ground::after { animation: none; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
  html:active-view-transition::after { display: none; }
  .amb-tilt { transform: none; }
}
@media print { .amb-ground, .amb-progress, .amb-cover { display: none !important; } .amb-on .amb-rise, .amb-on .amb-pic, .amb-on .amb-split .amb-w > span { opacity: 1 !important; transform: none !important; clip-path: none !important; } }
