/* Product stages (inc/scene.php): real products standing in drawn scenes.
   Used by the category banner (preset.css lays out the box) and the homepage hero (home.css).

   .jc-scene          box with the art's aspect ratio (--jc-sw/--jc-sh, phone --jc-msw/--jc-msh);
                      the view sizes it, everything inside is in % of it.
   .jc-piece          one product, exactly the fitted image's box (--x --y --w --h; phone --mx…),
                      standing on its contact line.
     __shadow         its silhouette laid on the floor away from the key light (cast shadow)
     __body           the product as an object: turned by --turn with perspective, with
       __side         a side face (the packaging's edge stretched over its depth --d, in shade),
       __img          the cut-out, unaltered,
       __light        the scene's light on it: key → shade tint, bounce light from the floor,
       __glint        and a light sweep (optional),
                      all masked by the cut-out itself (--m) so they fall on the product only.
   Light values come from the scene (stages.json → --jc-l-*). */

.jc-scene { position: absolute; top: 0; right: 0; height: 100%; aspect-ratio: var(--jc-sw) / var(--jc-sh); container-type: size; }
.jc-scene > picture { position: absolute; inset: 0; z-index: 0; }
.jc-scene > picture img { display: block; width: 100%; height: 100%; max-width: none; }

.jc-scene__pieces { list-style: none; margin: 0 !important; padding: 0; position: absolute; inset: 0; z-index: 2; }
.jc-piece {
	pointer-events: none;   /* halo, occlusion and shadow must not catch a neighbour's pointer; only the link does */
	/* the camera in use (the views switch these to the phone values: --mpo, --mpf…) */
	--_po: var(--po); --_pf: var(--pf); --_tilt: var(--tilt); --_dh: var(--dh);
	position: absolute; margin: 0;
	left: var(--x); bottom: var(--y); width: var(--w); height: var(--h);
	transform: translateX(-50%);
}
/* ambient occlusion: dark, tight, where the product meets the floor */
.jc-piece::before {
	content: ""; position: absolute; z-index: -1;
	left: -12%; right: -16%; bottom: -6%; height: 13%;
	background:
		radial-gradient(50% 50%, var(--jc-l-floor, rgb(0 0 0 / .6)) 0%, var(--jc-l-floor, rgb(0 0 0 / .6)) 55%, transparent 100%);
	filter: blur(1.5px);
}
/* halo: the scene's light glowing behind the product (dark scenes) */
.jc-scene--halo .jc-piece::after {
	content: ""; position: absolute; z-index: -2;
	left: -45%; right: -45%; top: -20%; bottom: 0;
	background: radial-gradient(closest-side, var(--jc-l-halo), transparent);
	opacity: .6;
}
/* The scene's camera: perspective = its focal length (in the scene's own scale: cqh of the
   scene box), seen from its principal point, so faces converge like the drawing's lines. */
.jc-piece__link {
	position: absolute; inset: 0; display: block; border-radius: 4px; pointer-events: auto;
	perspective: calc(var(--_pf, 2) * 100cqh); perspective-origin: var(--_po, 50% 30%);
}
.jc-piece__link:focus-visible { outline: 3px solid var(--jc-p-focus, #fff); outline-offset: 6px; }
/* Price tag (0.7.2, review: the scene's products read as decor): name and price of the product
   under the pointer or keyboard focus, pinned above it like a shelf label. Always in the DOM, so
   it is also the link's accessible name. */
.jc-piece__tag {
	position: absolute; z-index: 1; left: 50%; bottom: calc(100% + 8px);
	display: flex; align-items: baseline; gap: 10px;
	/* 0.7.3: a wrapped name left the box at its full max width (shrink-to-fit doesn't follow
	   balanced lines), so a two-line label ran wide; 300px keeps the gap small. */
	width: max-content; max-width: min(300px, 80vw);
	padding: 6px 10px; border-radius: 8px;
	background: #121316; color: #fff;   /* fixed: presets redefine --jc-ink */
	box-shadow: 0 0 0 1px rgb(255 255 255 / .22), 0 10px 24px rgb(0 0 0 / .32);
	font: 600 13px/1.3 var(--jc-font, system-ui);
	opacity: 0; transform: translate(calc(-50% + var(--jc-tag-dx, 0px)), calc(4px + var(--jc-tag-dy, 0px))); pointer-events: none;
}
/* at most two lines, so the label fits above products standing near the top of a banner and
   still shows what tells similar products apart ("… Starter Deck (Tiana in Bruno)") */
.jc-piece__name { min-width: 0; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; text-wrap: balance; }
.jc-piece__price { white-space: nowrap; }
.jc-piece__price { flex: none; font-weight: 800; font-variant-numeric: tabular-nums; }
.jc-piece__link:hover .jc-piece__tag,
.jc-piece__link:focus-visible .jc-piece__tag { opacity: 1; transform: translate(calc(-50% + var(--jc-tag-dx, 0px)), var(--jc-tag-dy, 0px)); }
/* --jc-tag-dx/dy: set on hover/focus by the footer script (inc/a11y.php) to keep the tag inside the banner's clipped box. */
/* While one is pointed at, the products come in front of the scene's foreground (cabinet frame,
   glass, mist), so its label is never cut by the drawing: the product is "taken off the shelf". */
.jc-scene__pieces:has(.jc-piece__link:hover, .jc-piece__link:focus-visible) { z-index: 4; }
/* …and the pointed-at product above its neighbours, so a neighbour never covers its tag (0.7.24). */
.jc-piece:has(.jc-piece__link:hover, .jc-piece__link:focus-visible) { z-index: 5; }

.jc-piece__shadow,
.jc-piece__light,
.jc-piece__glint {
	position: absolute; pointer-events: none;
	-webkit-mask: var(--m) 50% 100% / 100% 100% no-repeat;
	mask: var(--m) 50% 100% / 100% 100% no-repeat;
}
.jc-piece__shadow {
	inset: 0;
	background: var(--jc-l-cast-color, #000);
	transform-origin: 50% 100%;
	transform: skewX(var(--jc-l-cast, -58deg)) scaleY(var(--jc-l-cast-len, .3));
	filter: blur(2.5px);
	opacity: var(--jc-l-cast-amount, .42);
}
.jc-piece__body {
	position: absolute; inset: 0; display: block;
	transform-style: preserve-3d;
	transform-origin: 50% 100%;
	transform: rotateX(var(--_tilt, 0deg));   /* leans back by the camera's pitch */
}
.jc-piece__img {
	position: absolute; inset: 0;
	display: block; width: 100%; height: 100%; max-width: none;
	object-fit: fill;
	filter: var(--jc-l-grade, none);   /* the scene's air: e.g. a little less contrast in a hazy scene */
}
/* Faces built for a front-on shot (depth --d of its width): the packaging's outermost column
   or row of pixels stretched over the depth, turned back 90°; only the faces the camera can
   see show (backface-visibility). Shaded as if lit from above-left. */
.jc-piece__face {
	position: absolute; pointer-events: none;
	backface-visibility: hidden; -webkit-backface-visibility: hidden;
	background-image: var(--m); background-repeat: no-repeat;
}
.jc-piece__face--r { top: 0; bottom: 0; left: 100%; width: var(--d); background-size: 4000% 100%; background-position: 100% 50%; transform-origin: 0 50%; transform: rotateY(90deg); filter: brightness(.55); }
.jc-piece__face--l { top: 0; bottom: 0; right: 100%; width: var(--d); background-size: 4000% 100%; background-position: 0 50%; transform-origin: 100% 50%; transform: rotateY(-90deg); filter: brightness(.8); }
.jc-piece__face--t { left: 0; right: 0; bottom: 100%; height: var(--_dh); background-size: 100% 4000%; background-position: 50% 0; transform-origin: 50% 100%; transform: rotateX(90deg); filter: brightness(1.12); }
.jc-piece__light {
	inset: 0;
	background:
		linear-gradient(to top, var(--jc-l-bounce, transparent) 0%, transparent 30%),
		linear-gradient(to top, var(--jc-l-shade, #000) 0%, transparent 18%),
		linear-gradient(var(--jc-l-angle, 120deg), var(--jc-l-key, #fff) 0%, transparent 46%, var(--jc-l-shade, #000) 100%);
	mix-blend-mode: soft-light;
	opacity: var(--jc-l-amount, .6);
}
.jc-piece__glint {
	inset: 0;
	background: linear-gradient(105deg, transparent 40%, rgb(255 255 255 / .65) 50%, transparent 60%) 100% 0 / 300% 100% no-repeat;
	mix-blend-mode: screen;
	opacity: 0;
}
/* reflection on a shiny floor */
.jc-scene--gloss .jc-piece__img { -webkit-box-reflect: below 1px linear-gradient(transparent 68%, rgb(0 0 0 / .3)); }

/* photo without a cut-out: on a paper tile, no light layers */
.jc-piece--tile .jc-piece__body { display: flex; align-items: flex-end; justify-content: center; transform: none; }
.jc-piece--tile .jc-piece__img {
	position: static; width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain;
	background: var(--jc-paper, #fff); border-radius: 8px; padding: 6%; box-sizing: border-box;
	box-shadow: 0 14px 28px -12px rgb(0 0 0 / .45);
}

@media (prefers-reduced-motion: no-preference) {
	.jc-piece__link { transition: transform .35s cubic-bezier(.16, 1, .3, 1); }
	.jc-piece__link:hover { transform: translateY(-4px); }
	.jc-piece__tag { transition: opacity .2s ease-out, transform .25s cubic-bezier(.16, 1, .3, 1); }
	.jc-scene--glint-once .jc-piece__glint { animation: jc-glint 4s cubic-bezier(.45, 0, .2, 1) calc(.9s + var(--i, 0) * .3s) 1 both; }
	/* 'loop' scenes used to repeat every 7s; DESIGN.md allows one moment played once (and WCAG
	   2.2.2), so they now sweep once, staggered, like 'once' scenes with a slower cadence. */
	.jc-scene--glint-loop .jc-piece__glint { animation: jc-glint 7s cubic-bezier(.45, 0, .2, 1) calc(.9s + var(--i, 0) * 1.4s) 1 both; }
	.jc-piece__link:hover .jc-piece__glint { animation: jc-glint 1.6s cubic-bezier(.45, 0, .2, 1) 0s 1 both; }
}
@keyframes jc-glint {
	0% { background-position: 100% 0; opacity: 1; }
	28% { background-position: 0 0; opacity: 1; }
	29%, 100% { background-position: 0 0; opacity: 0; }
}

/* foreground over the products (sand drift, floor rim…): part of the drawing, never a target */
.jc-scene > .jc-scene__front { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.jc-scene > .jc-scene__front img { display: block; width: 100%; height: 100%; max-width: none; }

@media (forced-colors: active) {
	.jc-piece__shadow, .jc-piece__face, .jc-piece__light, .jc-piece__glint, .jc-piece::before, .jc-piece::after { display: none; }
}
