/* Billboard — a digital megalight on a monopole, built in CSS 3D.
   Not part of the scrollcraft engine: the act is a plain data-sc-act="pin",
   billboard.js reads the act's --sc-p every frame and poses the rig.

   Geometry is derived from one width, --bb-w. The LED cabinet is 16:9, its
   depth is 3% of the width (a 4 m panel is ~12 cm deep), the pole is a cross
   of two shaded planes so it keeps its thickness from any angle. */

.bp-board {
  --bb-w: min(56vw, 860px);
  --bb-h: calc(var(--bb-w) * 0.5625);
  --bb-d: calc(var(--bb-w) * 0.03);
  --bb-pole: calc(var(--bb-w) * 0.22);
  --bb-r: calc(var(--bb-w) * 0.006);
  --bb-glow: 242, 242, 242;
  --bb-glow-a: 0;
  background: var(--sc-canvas);
}

.bp-board__frame {
  position: relative;
  height: 100%;
  overflow: hidden;
}

/* ---- heading, the beat before the machine ---- */
.bp-board__head {
  position: absolute; inset: 0 0 auto 0; z-index: 3;
  padding: 120px clamp(20px, 5vw, 48px) 0;
  text-align: center;
  will-change: transform, opacity;
}
.bp-board__kicker {
  font: 500 12px/1 var(--sc-font-text); letter-spacing: .14em; text-transform: uppercase;
  color: var(--sc-ink-soft); margin: 0 0 22px;
}
/* the rows are flaps in capitals; a line longer than the board was drawn for
   shrinks to stay one row (flapboard.js sets --flap-w, and --flap-rows for
   the widest line so both keep one size) instead of wrapping over the
   screen below */
.bp-board__head h2 { margin: 0; container-type: inline-size; }
.bp-board__head h2 [data-flap] { font-size: max(1.2rem, min(clamp(1.9rem, 5.4vw, 4.2rem), 100cqi / var(--flap-rows, var(--flap-w, 1)))); justify-content: center; width: 100%; text-transform: uppercase; }
.bp-board__head h2 [data-flap] + [data-flap] { margin-top: .12em; }
.bp-board__micro { font: 400 clamp(.9rem, 1.1vw, 1.05rem)/1.5 var(--sc-font-text); color: var(--sc-ink-soft); margin: 24px 0 0; }

/* ---- the room: a ground line and the light the screen throws ---- */
.bp-board__ground {
  position: absolute; left: 50%; bottom: -6%; z-index: 0;
  width: min(140vw, 1800px); aspect-ratio: 5 / 1;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at 50% 100%, rgba(255,255,255,.06), transparent 62%);
  pointer-events: none;
}
.bp-board__glow {
  position: absolute; left: 50%; top: 50%; z-index: 0;
  width: calc(var(--bb-w) * 1.35); height: calc(var(--bb-h) * 1.5);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(var(--bb-glow), .42), rgba(var(--bb-glow), .1) 45%, transparent 70%);
  filter: blur(44px);
  opacity: var(--bb-glow-a);
  pointer-events: none;
  will-change: opacity, transform;
}

/* ---- the scene ---- */
.bp-board__scene {
  position: absolute; inset: 0; z-index: 2;
  display: grid; place-items: end center;
  padding-bottom: 0;
  /* A long lens: the cabinet must not splay while it turns. */
  perspective: 2400px;
  perspective-origin: 50% 38%;
  pointer-events: none;
}
.bb-rig {
  position: relative;
  width: var(--bb-w);
  height: calc(var(--bb-h) + var(--bb-pole));
  transform-style: preserve-3d;
  will-change: transform;
}

/* -- cabinet: a shallow box. front = screen, back = shell, four thin sides -- */
.bb-cab {
  position: absolute; left: 0; top: 0;
  width: var(--bb-w); height: var(--bb-h);
  transform-style: preserve-3d;
}
.bb-face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  border-radius: var(--bb-r);
}
.bb-face--front {
  transform: translateZ(calc(var(--bb-d) / 2));
  background: #141316;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.14);
  /* the bezel: LED cabinets carry a slim aluminium lip */
  padding: 1.6%;
  overflow: hidden;
}
.bb-face--back {
  transform: rotateY(180deg) translateZ(calc(var(--bb-d) / 2));
  background: linear-gradient(160deg, #1d1c20, #0f0f11 55%, #161519);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.1);
  display: grid; place-items: center;
}
.bb-face--back img { width: 14%; height: auto; opacity: .35; transform: scaleX(-1); }
/* sides: rendered as flat strips at ±90°, shaded darker than the faces */
.bb-side {
  position: absolute;
  background: linear-gradient(#232226, #0e0e10);
  backface-visibility: hidden;
}
.bb-side--l, .bb-side--r { top: 0; width: var(--bb-d); height: 100%; }
.bb-side--l { left: 0; transform-origin: left center; transform: rotateY(-90deg); }
.bb-side--r { right: 0; transform-origin: right center; transform: rotateY(90deg); }
.bb-side--t, .bb-side--b { left: 0; width: 100%; height: var(--bb-d); background: linear-gradient(90deg, #1a191c, #2a292d 50%, #1a191c); }
.bb-side--t { top: 0; transform-origin: center top; transform: rotateX(90deg); }
.bb-side--b { bottom: 0; transform-origin: center bottom; transform: rotateX(-90deg); background: #0a0a0b; }

/* -- the screen -- */
.bb-screen {
  position: relative; width: 100%; height: 100%;
  background: #050505;
  overflow: hidden;
  border-radius: calc(var(--bb-r) * .6);
  /* powered-off state: the panel is a dark mirror */
  --bb-on: 0;
}
.bb-slots { position: absolute; inset: 0; }
.bb-slot {
  position: absolute; inset: 0; margin: 0;
  display: grid; place-items: center;
  background: #0b0b0c;
  clip-path: inset(0 100% 0 0);
  overflow: hidden;
}
.bb-slot.is-on { clip-path: inset(0 0 0 0); }
.bb-slot img { width: 100%; height: 100%; object-fit: cover; }
.bb-slot--brand { background: #e4e4e6; color: #0b0b0c; }
.bb-slot--brand img.bb-mark { width: 22%; height: auto; }
.bb-slot__copy {
  position: absolute; left: 4.5%; bottom: 7%;
  font: 600 clamp(.9rem, 2.2vw, 2rem)/1.05 var(--sc-font-display);
  text-transform: uppercase; letter-spacing: .02em; text-align: left;
}
.bb-slot--brand .bb-slot__copy { color: #0b0b0c; }
.bb-slot--cta { background: #0b0b0c; color: #f2f2f2; }
.bb-slot--cta .bb-slot__big {
  font: 600 clamp(1.6rem, 6vw, 5.4rem)/.95 var(--sc-font-display);
  text-transform: uppercase; letter-spacing: .01em; text-align: center;
}
.bb-slot--cta .bb-slot__big small {
  display: block; font: 500 clamp(.6rem, 1.2vw, 1rem)/1.4 var(--sc-font-text);
  letter-spacing: .16em; color: var(--sc-ink-soft); margin-top: .8em;
}
/* A real DOOH frame: the photo keeps a client-safe caption strip */
.bb-slot--real figcaption {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 2% 4.5%;
  background: linear-gradient(to top, rgba(0,0,0,.72), transparent);
  font: 500 clamp(.55rem, 1vw, .85rem)/1.3 var(--sc-font-text);
  letter-spacing: .1em; text-transform: uppercase; color: #f2f2f2; text-align: left;
}

/* LED matrix over the picture. Two layers: the dark gaps between pixels and a
   faint bloom so bright pixels bleed into their neighbours like a real wall. */
.bb-led {
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    radial-gradient(circle at 50% 50%, transparent 40%, rgba(0,0,0,.5) 60%);
  background-size: 3px 3px;
  mix-blend-mode: multiply;
  opacity: .55;
}
.bb-bloom {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,.06), transparent 30%, transparent 70%, rgba(255,255,255,.03));
}
/* Power-on: the panel lights row by row. --bb-on (0..1) drives the reveal. */
.bb-power {
  position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background: #050505;
  clip-path: inset(calc(var(--bb-on) * 100%) 0 0 0);
}
.bb-scan {
  position: absolute; left: 0; right: 0; z-index: 3; pointer-events: none;
  top: calc(var(--bb-on) * 100%);
  height: 2px; margin-top: -1px;
  background: #ffffff;
  box-shadow: 0 0 14px 3px rgba(255,255,255,.55), 0 0 40px 10px rgba(255,255,255,.2);
  opacity: 0;
}
.bb-screen.is-booting .bb-scan { opacity: 1; }
/* Glass: a diagonal sheen, sharpest while the panel is still off */
.bb-glass {
  position: absolute; inset: 0; pointer-events: none; z-index: 4;
  background: linear-gradient(112deg, rgba(255,255,255,.10), transparent 32%, transparent 66%, rgba(255,255,255,.04));
}

/* HUD: the loop counter every player carries. Lives on the bezel. */
.bb-hud {
  position: absolute; right: 2.2%; bottom: 0.35%; z-index: 5;
  font: 500 10px/1 var(--sc-font-mono, ui-monospace, monospace);
  letter-spacing: .12em; text-transform: uppercase; color: rgba(242,242,242,.5);
  display: flex; gap: 10px; align-items: center;
  font-variant-numeric: tabular-nums;
}
.bb-hud i { width: 6px; height: 6px; border-radius: 50%; background: #f2f2f2; opacity: .35; }
.bb-screen.is-on ~ .bb-hud i { opacity: 1; box-shadow: 0 0 8px #fff; }

/* -- the pole: two crossed planes under the cabinet, plus a foot on the ground -- */
.bb-pole {
  position: absolute; left: 50%; top: var(--bb-h);
  width: calc(var(--bb-w) * 0.052); height: var(--bb-pole);
  margin-left: calc(var(--bb-w) * -0.026);
  transform-style: preserve-3d;
}
.bb-pole::before, .bb-pole::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, #0c0c0d, #2a292d 42%, #3a393e 50%, #232226 62%, #0b0b0c);
}
.bb-pole::after { transform: rotateY(90deg); background: linear-gradient(90deg, #0a0a0b, #1f1e22 50%, #0a0a0b); }
/* the brace: a short bracket between pole and cabinet */
.bb-brace {
  position: absolute; left: 50%; top: calc(var(--bb-h) - 1px);
  width: calc(var(--bb-w) * 0.16); height: calc(var(--bb-w) * 0.02);
  margin-left: calc(var(--bb-w) * -0.08);
  background: linear-gradient(#1c1b1f, #0d0d0e);
  transform: translateZ(calc(var(--bb-d) * -0.5));
}
.bb-foot {
  position: absolute; left: 50%; top: calc(var(--bb-h) + var(--bb-pole) - 2px);
  width: calc(var(--bb-w) * 0.26); height: calc(var(--bb-w) * 0.05);
  margin-left: calc(var(--bb-w) * -0.13);
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(0,0,0,.85), rgba(0,0,0,.4) 45%, transparent 70%);
  transform: rotateX(90deg) translateZ(calc(var(--bb-w) * -0.02));
}

/* ---- closing copy, keyed to the act's progress by the engine ---- */
.bp-board__copy {
  position: absolute; left: 0; right: 0; bottom: clamp(20px, 5vh, 48px); z-index: 4;
  opacity: 0;   /* billboard.js fades it in as a scroll-triggered state */
  padding: 0 clamp(20px, 5vw, 48px);
  display: flex; justify-content: center; gap: clamp(20px, 4vw, 56px);
  text-align: center;
  /* the pole runs behind this copy: a soft floor keeps the type clean */
  padding-top: 28px;
  background: linear-gradient(to top, var(--sc-canvas) 55%, transparent);
}
.bp-board__copy div { max-width: 24ch; }
.bp-board__copy strong { display: block; font: 600 clamp(1.1rem, 1.9vw, 1.5rem)/1 var(--sc-font-display); text-transform: uppercase; letter-spacing: .04em; color: var(--sc-accent); margin-bottom: 8px; }
.bp-board__copy span { font: 400 13px/1.45 var(--sc-font-text); color: var(--sc-ink-soft); }

/* ---- mobile: same act, tighter composition, gentler turn ---- */
@media (max-width: 760px) {
  .bp-board { --bb-w: 92vw; --bb-pole: calc(var(--bb-w) * 0.34); }
  .bp-board__head { padding-top: 92px; }
  .bp-board__head h2 [data-flap] { font-size: max(1rem, min(clamp(1.4rem, 7.6vw, 2.2rem), 100cqi / var(--flap-rows, var(--flap-w, 1)))); }
  .bp-board__micro { margin-top: 14px; font-size: .82rem; }
  .bp-board__scene { perspective: 1400px; perspective-origin: 50% 42%; }
  .bp-board__copy { flex-direction: column; gap: 14px; bottom: 18px; }
  .bp-board__copy div { max-width: none; }
  .bp-board__copy strong { font-size: 1rem; margin-bottom: 4px; }
  .bp-board__copy span { font-size: 12px; }
  .bb-led { background-size: 2px 2px; opacity: .4; }
  .bb-hud { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  /* the rig never moves here, so it must fit under the heading as-is */
  .bp-board { --bb-w: min(40vw, 600px); }
  .bp-board__copy { bottom: 12px; padding-top: 18px; }
  .bb-scan { display: none; }
  .bb-slot { transition: opacity 240ms ease; }
}
