/* Build mode: glass frames and a labelled cursor crew that assemble each block on scroll.
   Driven by build-mode.js; nothing here hides content unless that script is running. */

main { position: relative; }

.bm-layer {
  position: absolute;
  z-index: 29; /* above page content, below the sticky header (30) */
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  contain: layout paint style;
}

/* Off-screen blocks wait, invisible, for their next build. */
.bm-on [data-bm="staged"] { opacity: 0; }
.bm-on .section__rule { transform-origin: left center; }

/* The hero stays hidden from first paint until build mode takes it over.
   If the script never arrives, this failsafe shows it after 2.5s. */
.bm-boot .hero__frame,
.bm-boot .hero__bottom,
.bm-boot .hero__visual { opacity: 0; animation: bm-failsafe 1ms linear 2.5s forwards; }
@keyframes bm-failsafe { to { opacity: 1; } }

/* ---------- Frames: a Figma-style selection with a layer name and live dimensions ---------- */
.bm-frame {
  position: absolute;
  z-index: 1;
  top: 0;
  left: 0;
  border: 1.5px solid rgba(156, 200, 255, 0.95);
  background:
    linear-gradient(135deg, rgba(232, 208, 202, 0.2), rgba(150, 118, 116, 0.1) 55%, rgba(210, 186, 182, 0.16)),
    rgba(28, 20, 24, 0.28);
  box-shadow:
    0 0 0 1px rgba(8, 10, 18, 0.35),
    0 0 26px rgba(98, 158, 255, 0.24),
    inset 0 0 44px rgba(255, 226, 220, 0.07);
  opacity: 0;
}
.bm-frame__tab,
.bm-frame__dims {
  position: absolute;
  padding: 3px 6px;
  border-radius: 3px;
  color: #fff;
  background: #2f7cf6;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  font: 700 10px/1.25 var(--mono);
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.bm-frame__tab { bottom: 100%; left: -1.5px; margin-bottom: 5px; }
.bm-frame__dims {
  top: 100%;
  left: 50%;
  margin-top: 7px;
  opacity: 0;
  transform: translateX(-50%);
  animation: bm-dims-in 240ms ease-out var(--settle, 0ms) forwards;
}
.bm-frame > i {
  position: absolute;
  width: 8px;
  height: 8px;
  border: 1.5px solid #2f7cf6;
  background: #fff;
  opacity: 0;
  animation: bm-handle-in 220ms ease-out var(--settle, 0ms) forwards;
}
.bm-frame > i:nth-of-type(1) { top: -4.5px; left: -4.5px; }
.bm-frame > i:nth-of-type(2) { top: -4.5px; right: -4.5px; }
.bm-frame > i:nth-of-type(3) { right: -4.5px; bottom: -4.5px; }
.bm-frame > i:nth-of-type(4) { bottom: -4.5px; left: -4.5px; }
@keyframes bm-dims-in {
  from { opacity: 0; transform: translate(-50%, -5px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes bm-handle-in {
  from { opacity: 0; transform: scale(0.3); }
  to { opacity: 1; transform: scale(1); }
}

/* ---------- Cursors: an arrow with a name tag and what it is doing ---------- */
.bm-cursor {
  position: absolute;
  z-index: 2;
  top: 0;
  left: 0;
  color: var(--c);
  opacity: 0;
  transform-origin: 0 0;
}
.bm-cursor svg {
  display: block;
  width: 20px;
  height: 24px;
  margin: -1.5px 0 0 -1.5px;
  overflow: visible;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.55));
}
.bm-cursor path { fill: currentColor; stroke: #120c0e; stroke-width: 2; stroke-linejoin: round; }

/* Shared with the portrait scene's cursors. */
.bm-cursor__tag {
  position: absolute;
  top: 20px;
  left: 14px;
  display: flex;
  gap: 3px;
  font: 800 10px/1 var(--mono);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.bm-cursor__tag b,
.bm-cursor__tag em {
  padding: 4px 6px 3px;
  border-radius: 4px;
}
.bm-cursor__tag b {
  color: #120c0e;
  background: var(--c);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45), 0 0 16px color-mix(in srgb, var(--c) 45%, transparent);
}
.bm-cursor__tag em {
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #efe6e2;
  background: rgba(14, 11, 13, 0.92);
  font-style: normal;
  font-weight: 700;
}
.bm-cursor__tag em:empty { display: none; }

/* ---------- Click sparkle ---------- */
.bm-spark {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 0;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  opacity: 0;
  animation: bm-spark 620ms cubic-bezier(0.2, 0.8, 0.2, 1) var(--at, 0ms) both;
}
.bm-spark::before,
.bm-spark::after { position: absolute; inset: 0; content: ""; }
.bm-spark::before {
  background: var(--c);
  clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%);
  filter: drop-shadow(0 0 6px var(--c));
}
.bm-spark::after {
  border: 1.5px solid var(--c);
  border-radius: 50%;
  opacity: 0.7;
  transform: scale(0.4);
  animation: bm-ring 620ms ease-out var(--at, 0ms) both;
}
@keyframes bm-spark {
  0% { opacity: 0; transform: scale(0.2) rotate(0deg); }
  30% { opacity: 1; transform: scale(1.15) rotate(45deg); }
  100% { opacity: 0; transform: scale(0.5) rotate(110deg); }
}
@keyframes bm-ring {
  0% { opacity: 0.8; transform: scale(0.3); }
  100% { opacity: 0; transform: scale(2.4); }
}

/* ---------- Phones and touch: smaller tags, name only ---------- */
@media (max-width: 600px), (hover: none) and (pointer: coarse) {
  .bm-cursor svg { width: 17px; height: 20px; }
  .bm-cursor__tag { top: 17px; left: 11px; font-size: 9px; }
  .bm-cursor__tag em { display: none; }
  .bm-frame__tab, .bm-frame__dims { font-size: 9px; }
}

@media print {
  .bm-layer { display: none; }
  [data-bm] { opacity: 1 !important; }
}
