/* DojoStack production cinematic runtime styles.
   Cinema underneath / systems on top / product at the end. */

:root {
  --cin-bg: #090807;
  --cin-warm: #ffb36b;
  --cin-red: #9b2d2f;
  --cin-blue: #78a9c4;
  --cin-text: #f2efe9;
  --cin-beat-font: "Barlow Semi Condensed", "Segoe UI", system-ui, sans-serif;
}

/* ---- Renderer gating: greybox stays recoverable, never default ---- */

html[data-renderer='cinematic'] #greybox-story,
html[data-renderer='cinematic'] .gate-boundary,
html[data-renderer='cinematic'] .gate-chip {
  display: none !important;
}

html[data-renderer='greybox'] #cinematic-story {
  display: none;
}

/* ---- Stage ---- */

.cinematic-story {
  position: relative;
  background: var(--cin-bg);
}

.cinematic-pin {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100svh;
  min-height: 560px;
  overflow: hidden;
  background: var(--cin-bg);
}

/* ---- Media layer: cinematic plates ---- */

.cinematic-media-layer {
  position: absolute;
  inset: 0;
}

.cin-plate {
  position: absolute;
  inset: 0;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  will-change: transform, opacity;
  transform: translate3d(0, 0, 0);
}

.cin-plate img {
  position: absolute;
  max-width: none;
  user-select: none;
  pointer-events: none;
}

/* Media failure: remain a credible dark dojo atmosphere, never broken. */
.cin-plate.is-fallback {
  background:
    radial-gradient(120% 90% at 50% 30%, #17130f 0%, #0b0908 55%, #060505 100%);
}

.cin-plate.is-fallback img {
  display: none;
}

.cin-plate.is-fallback::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 34%;
  width: 34vmin;
  height: 34vmin;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(155, 45, 47, 0.35);
  border-radius: 50%;
  filter: blur(1px);
}

/* ---- Matched-screen product overlay (B5 monitor surface) ---- */

.cin-screen-match {
  position: absolute;
  z-index: 3;
  overflow: hidden;
  border-radius: 3px;
  background: #0d1117;
  transform: perspective(1400px) rotateY(3deg) rotateX(1deg);
  will-change: transform;
  pointer-events: none;
  box-shadow: 0 0 22px rgba(120, 169, 196, 0.14);
}

.cin-screen-match img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 0%;
  filter: brightness(0.6) saturate(0.86);
}

.cin-screen-match__glass {
  /* Room light on the glass while the screen is still part of the scene;
     lifts off as the camera enters. */
  position: absolute;
  inset: 0;
  background:
    linear-gradient(112deg, rgba(255, 210, 161, 0.1) 0%, rgba(255, 255, 255, 0) 38%),
    radial-gradient(120% 90% at 50% 110%, rgba(9, 8, 7, 0.28) 0%, rgba(9, 8, 7, 0) 55%);
  pointer-events: none;
}

/* ---- Signal layer ---- */

.cin-signal-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 8;
  pointer-events: none;
  overflow: visible;
}

.cin-signal {
  filter: drop-shadow(0 0 6px currentColor);
}

.sig-pulse {
  animation: cin-sig-pulse 1.6s ease-out infinite;
  transform-origin: center;
  transform-box: fill-box;
}

.sig-pulse--outer {
  animation-delay: 0.55s;
}

.cin-signal.is-frozen .sig-pulse {
  animation: none;
  opacity: 0.65;
}

@keyframes cin-sig-pulse {
  0% { transform: scale(0.55); opacity: 0.9; }
  100% { transform: scale(1.25); opacity: 0; }
}

.cin-owner-node {
  filter: drop-shadow(0 0 8px rgba(120, 169, 196, 0.8));
}

/* ---- Light layer ---- */

.cinematic-light-layer {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.cin-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    120% 95% at 50% 44%,
    rgba(6, 5, 4, 0) 42%,
    rgba(6, 5, 4, 0.42) 74%,
    rgba(6, 5, 4, 0.88) 100%
  );
  opacity: 0.9;
}

.cin-pressure-wash {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to left, rgba(155, 45, 47, 0.5) 0%, rgba(155, 45, 47, 0.14) 34%, rgba(155, 45, 47, 0) 62%),
    radial-gradient(60% 70% at 96% 55%, rgba(224, 90, 66, 0.32) 0%, rgba(224, 90, 66, 0) 70%);
  opacity: 0;
  mix-blend-mode: screen;
}

.cin-system-calm {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    70% 62% at 30% 60%,
    rgba(120, 169, 196, 0.3) 0%,
    rgba(120, 169, 196, 0.08) 48%,
    rgba(120, 169, 196, 0) 76%
  );
  opacity: 0;
  mix-blend-mode: screen;
}

.cin-grain {
  position: absolute;
  inset: 0;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
}

.cin-letterbox {
  position: absolute;
  left: 0;
  right: 0;
  height: 7.5vh;
  transition: opacity 0.6s ease;
  opacity: 0;
}

.cin-letterbox--top {
  top: 0;
  background: linear-gradient(to bottom, rgba(4, 3, 3, 0.92), rgba(4, 3, 3, 0));
}

.cin-letterbox--bottom {
  bottom: 0;
  background: linear-gradient(to top, rgba(4, 3, 3, 0.92), rgba(4, 3, 3, 0));
}

.immersive-active .cin-letterbox {
  opacity: 1;
}

/* ---- Narrative layer ---- */

.cin-narrative-layer {
  position: absolute;
  inset: 0;
  z-index: 12;
  pointer-events: none;
  font-family: var(--cin-beat-font);
  color: var(--cin-text);
}

.cin-threshold-beat {
  position: absolute;
  left: 50%;
  top: 21%;
  transform: translateX(-50%);
  margin: 0;
  width: min(88vw, 760px);
  text-align: center;
  font-size: clamp(28px, 4.6vw, 56px);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: none;
  opacity: 0;
  text-shadow: 0 2px 26px rgba(0, 0, 0, 0.85);
}

.cin-threshold-beat[data-cin-threshold='built-for-mats'] {
  font-size: clamp(34px, 6vw, 74px);
  letter-spacing: 0.06em;
}

.cin-beat {
  position: absolute;
  margin: 0;
  font-weight: 700;
  line-height: 1.04;
  opacity: 0;
  text-shadow: 0 2px 30px rgba(0, 0, 0, 0.9);
}

/* Freeze: dominant, confrontational, the scene stops for it. */
.cin-beat--freeze {
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  width: min(92vw, 900px);
  text-align: center;
  font-size: clamp(38px, 7.2vw, 92px);
  letter-spacing: 0.05em;
  color: #f6f1ea;
}

/* Your place: negative space lower-left, supports the class frame. */
.cin-beat--your-place {
  left: clamp(20px, 6vw, 90px);
  bottom: 16%;
  width: min(70vw, 560px);
  font-size: clamp(30px, 4.8vw, 62px);
  letter-spacing: 0.045em;
}

/* Our place: lower-right, guides the eye toward desk and monitor. */
.cin-beat--our-place {
  right: clamp(20px, 6vw, 90px);
  bottom: 15%;
  width: min(70vw, 560px);
  text-align: right;
  font-size: clamp(30px, 4.8vw, 62px);
  letter-spacing: 0.045em;
  color: #dcebf4;
}

.cin-scroll-cue {
  position: absolute;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  font-size: 11px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: rgba(242, 239, 233, 0.66);
  transition: opacity 0.5s ease;
  animation: cin-cue-drift 2.6s ease-in-out infinite;
}

/* The opening earns attention immediately, before asking for scroll. */
.cin-opening-promise {
  position: absolute;
  z-index: 44;
  top: clamp(150px, 24vh, 250px);
  left: clamp(24px, 7vw, 112px);
  width: min(580px, calc(100vw - 48px));
  color: #f4f0ea;
  pointer-events: auto;
  opacity: 1;
  transform: translateY(0);
  transition: opacity .55s ease, transform .55s ease, visibility .55s ease;
  text-shadow: 0 2px 28px rgba(0, 0, 0, .86);
}

.cin-opening-promise.is-dismissed {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-12px);
}

.cin-opening-promise__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: Inter, system-ui, sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: rgba(244, 240, 234, .72);
}

.cin-opening-promise__eyebrow::before {
  content: '';
  width: 28px;
  height: 1px;
  background: #e8253a;
  box-shadow: 0 0 14px rgba(232, 37, 58, .5);
}

.cin-opening-promise__title {
  margin: 18px 0 16px;
  font-family: var(--cin-beat-font);
  font-size: clamp(42px, 5.2vw, 72px);
  font-weight: 700;
  line-height: .92;
  letter-spacing: -.025em;
  text-transform: uppercase;
}

.cin-opening-promise__title strong {
  color: #e8253a;
  font-weight: inherit;
}

.cin-opening-promise__body {
  max-width: 470px;
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  font-size: clamp(14px, 1.2vw, 17px);
  line-height: 1.55;
  color: rgba(244, 240, 234, .76);
}

.cin-opening-promise__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 11px;
  margin-top: 26px;
}

.cin-opening-promise__actions a {
  min-height: 43px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  border: 1px solid rgba(244, 240, 234, .25);
  font-family: Inter, system-ui, sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  text-decoration: none;
  transition: color .2s ease, background .2s ease, border-color .2s ease, transform .2s ease;
}

.cin-opening-promise__actions a:hover {
  transform: translateY(-2px);
}

.cin-opening-promise__primary {
  background: #f4f0ea;
  border-color: #f4f0ea !important;
  color: #111;
}

.cin-opening-promise__secondary {
  background: rgba(8, 8, 9, .38);
  color: #f4f0ea;
  backdrop-filter: blur(10px);
}

/* Scroll distance through the pinned cinematic (raw scrub progress). */
.cin-scroll-progress {
  position: absolute;
  left: clamp(16px, 4vw, 32px);
  right: clamp(16px, 4vw, 32px);
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  z-index: 48;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.cin-scroll-progress.is-exited {
  opacity: 0;
  transform: translateY(6px);
}

.cin-scroll-progress.is-fading {
  opacity: 0.35;
}

.cin-scroll-progress__track {
  flex: 1;
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.cin-scroll-progress__fill {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  transform: scaleX(0);
  transform-origin: left center;
  background: linear-gradient(
    90deg,
    var(--cin-red, #9b2d2f) 0%,
    #ffb36b 55%,
    var(--cin-blue, #78a9c4) 100%
  );
  box-shadow: 0 0 12px rgba(155, 45, 47, 0.45);
  will-change: transform;
}

.cin-scroll-progress__pct {
  flex: 0 0 auto;
  min-width: 2.6em;
  font-family: var(--cin-beat-font);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-align: right;
  color: rgba(242, 239, 233, 0.72);
  font-variant-numeric: tabular-nums;
}

.reduced-motion .cin-scroll-progress {
  display: none;
}

@media (max-width: 800px) {
  .cin-scroll-progress {
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }

  .cin-scroll-progress__pct {
    font-size: 10px;
  }
}

@keyframes cin-cue-drift {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, 6px); }
}

.reduced-motion .cin-scroll-cue {
  animation: none;
}

/* ---- Product handoff layer ---- */

.cin-handoff-layer {
  position: absolute;
  inset: 0;
  z-index: 40;
  opacity: 0;
  visibility: hidden;
  background: #0d1117;
  will-change: opacity;
}

.cin-handoff-layer img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 0%;
}

.cin-handoff-layer::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    130% 110% at 50% 45%,
    rgba(9, 8, 7, 0) 62%,
    rgba(9, 8, 7, 0.34) 100%
  );
  transition: opacity 0.8s ease;
}

.cin-handoff-layer.is-live::after {
  opacity: 0;
}

/* ---- Optional cinematic sound ---- */

.cin-sound-choice {
  position: absolute;
  left: 50%;
  bottom: 74px;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  gap: 12px;
  transition: opacity 0.7s ease, visibility 0.7s ease;
}

.cin-sound-choice.is-dismissed {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.cin-sound-choice button {
  padding: 11px 22px;
  border-radius: 999px;
  font-family: Inter, system-ui, sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

.cin-sound-choice__enter {
  border: 1px solid rgba(242, 239, 233, 0.85);
  background: rgba(242, 239, 233, 0.92);
  color: #14110e;
}

.cin-sound-choice__enter:hover {
  background: #fff;
}

.cin-sound-choice__silent {
  border: 1px solid rgba(242, 239, 233, 0.35);
  background: rgba(9, 8, 7, 0.45);
  color: rgba(242, 239, 233, 0.82);
}

.cin-sound-choice__silent:hover {
  border-color: rgba(242, 239, 233, 0.7);
  color: #f2efe9;
}

.cin-sound-toggle {
  position: absolute;
  right: 22px;
  bottom: 22px;
  z-index: 50;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(242, 239, 233, 0.3);
  background: rgba(9, 8, 7, 0.55);
  color: rgba(242, 239, 233, 0.85);
  cursor: pointer;
  transition: border-color 0.25s ease, color 0.25s ease;
}

.cin-sound-toggle:hover {
  border-color: rgba(242, 239, 233, 0.65);
  color: #fff;
}

.cin-sound-toggle svg {
  width: 21px;
  height: 21px;
}

.cin-sound-toggle .cin-sound-toggle__slash {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.cin-sound-toggle.is-muted .cin-sound-toggle__slash {
  opacity: 1;
}

.cin-sound-toggle.is-muted .cin-sound-toggle__waves {
  opacity: 0.25;
}

/* Reduced motion: the choice and toggle accompany the static sequence. */
.cin-sound-static .cin-sound-choice {
  position: static;
  transform: none;
  justify-content: center;
  padding: 26px 20px 4px;
  background: var(--cin-bg);
}

.cin-sound-static .cin-sound-choice.is-dismissed {
  display: none;
}

.cin-sound-static .cin-sound-toggle {
  position: fixed;
}

/* ---- Debug ---- */

.cin-progress-readout {
  display: none;
  position: absolute;
  top: 72px;
  left: 16px;
  z-index: 60;
  padding: 6px 10px;
  background: rgba(9, 11, 13, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11px;
  color: #eceff1;
}

.cin-debug .cin-progress-readout {
  display: block;
}

/* ---- Reduced motion: static editorial sequence ---- */

.cin-reduced-sequence {
  display: none;
}

.reduced-motion #cinematic-story .cinematic-pin {
  display: none;
}

.reduced-motion .cin-reduced-sequence {
  display: block;
  background: var(--cin-bg);
  color: var(--cin-text);
}

.cin-reduced-frame {
  position: relative;
  overflow: hidden;
  min-height: 72svh;
  display: flex;
  align-items: flex-end;
}

.cin-reduced-frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.78);
}

.cin-reduced-frame figcaption {
  position: relative;
  z-index: 2;
  width: 100%;
  padding: 8vh clamp(20px, 7vw, 110px);
  background: linear-gradient(to top, rgba(6, 5, 4, 0.92), rgba(6, 5, 4, 0));
  font-family: var(--cin-beat-font);
  font-size: clamp(26px, 4.4vw, 52px);
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.1;
}

.cin-reduced-frame figcaption small {
  display: block;
  margin-top: 10px;
  font-family: Inter, system-ui, sans-serif;
  font-size: clamp(14px, 1.6vw, 17px);
  font-weight: 400;
  letter-spacing: 0.01em;
  color: rgba(242, 239, 233, 0.78);
  max-width: 560px;
}

.cin-reduced-frame--entry img { object-position: 30% 45%; }
.cin-reduced-frame--teaching img { object-position: 22% 40%; }
.cin-reduced-frame--product img { object-position: 50% 0%; filter: none; }

/* ---- Mobile composition ---- */

@media (max-width: 800px) and (orientation: portrait) {
  .cin-opening-promise {
    top: max(108px, 15vh);
    left: 20px;
    width: calc(100vw - 40px);
  }

  .cin-opening-promise__title {
    margin-top: 14px;
    font-size: clamp(34px, 10.5vw, 48px);
  }

  .cin-opening-promise__body {
    max-width: 350px;
    font-size: 13px;
  }

  .cin-opening-promise__actions {
    margin-top: 18px;
  }

  .cin-opening-promise__actions a {
    min-height: 40px;
    padding: 0 15px;
    font-size: 9px;
  }

  .cin-threshold-beat {
    top: 17%;
    font-size: clamp(26px, 8vw, 40px);
  }

  .cin-threshold-beat[data-cin-threshold='built-for-mats'] {
    font-size: clamp(32px, 10vw, 48px);
  }

  .cin-beat--freeze {
    top: 40%;
    font-size: clamp(34px, 11vw, 54px);
  }

  .cin-beat--your-place {
    left: 20px;
    right: 20px;
    bottom: 19%;
    width: auto;
    font-size: clamp(28px, 8.6vw, 42px);
  }

  .cin-beat--our-place {
    left: 20px;
    right: 20px;
    bottom: 18%;
    width: auto;
    font-size: clamp(28px, 8.6vw, 42px);
  }

  .cin-letterbox {
    height: 6vh;
  }

  /* Portrait product handoff: present the full product frame rather than
     a blind cover-crop of a landscape screenshot. */
  .cin-handoff-layer img {
    object-fit: contain;
    object-position: 50% 30%;
  }
}
