/* Curtain Reveal V3 — hydration-safe production overlay. */

* { box-sizing: border-box; }

[hidden] { display: none !important; }

/* The real V3 cloth replaces the legacy React intro. Keep the old layer
   retired before the loading veil fades, even if hydration is still settling. */
.cloth-intro,
.cloth-skip,
.cloth-replay { display: none !important; }

html.curtain-v3-standalone,
html.curtain-v3-standalone body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  /* Must match the darkest curtain environment so a sub-frame browser paint can never flash. */
  background: #010302;
  color: #f3f0e9;
  font-family: "Segoe UI", Tahoma, system-ui, -apple-system, sans-serif;
}

html.curtain-v3-lock,
body.curtain-v3-lock {
  overflow: hidden !important;
}

.v3-page {
  position: relative;
  width: 100%;
  height: 100svh;
  min-height: 520px;
  overflow: hidden;
  background: #010302;
  color: #f3f0e9;
  font-family: "Segoe UI", Tahoma, system-ui, -apple-system, sans-serif;
}

/* ---------------------------------------------------------------- stage --- */
/* The revealed scene, mirroring the production trophy composition and assets. */

.stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: radial-gradient(at 50% 73%, #0b241b 0%, #04100c 27%, #010403 67%);
}

.stage-ambient {
  position: absolute;
  inset: 0;
  opacity: .68;
  background:
    radial-gradient(circle at 50% 56%, #23714f33, #0000 34%),
    linear-gradient(90deg, #000000d1, #0000 22% 78%, #000000d1);
}

.stage-beam {
  position: absolute;
  top: -19%;
  left: 50%;
  transform: translateX(-50%);
  transform-origin: 50% 0;
  width: min(60vw, 780px);
  height: 105%;
  opacity: .18;
  clip-path: polygon(47% 0, 53% 0, 91% 100%, 9% 100%);
  filter: blur(13px);
  background: linear-gradient(115deg, #0000 27%, #f5ddb070 49%, #f5ddb01a 56%, #0000 72%);
  mask-image: linear-gradient(#fff 55%, #0000 96%);
  -webkit-mask-image: linear-gradient(#fff 55%, #0000 96%);
  transition: opacity 2.2s cubic-bezier(.3, .5, .3, 1) .4s;
}

.v3-page.is-opening .stage-beam,
.v3-page.is-open .stage-beam { opacity: .62; }

.stage-trophy {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: end;
  width: min(48vw, 610px);
  height: min(82svh, 900px);
}

.stage-trophy::after {
  content: "";
  position: absolute;
  z-index: -1;
  bottom: 4.5%;
  left: 19%;
  width: 62%;
  height: 8%;
  border-radius: 50%;
  background: #000000d6;
  filter: blur(24px);
}

.stage-trophy > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  filter: saturate(.72) contrast(1.08);
  /* The hero render sits on pure black; screen blending melts its rectangle
     into the dark stage so the spotlight beam passes behind the glass case. */
  mix-blend-mode: screen;
}

/* -------------------------------------------------------------- chrome --- */

.v3-header {
  position: absolute;
  inset: 0 0 auto;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 26px clamp(20px, 4vw, 64px);
  color: #efeee9bd;
  font-size: 9px;
  letter-spacing: .15em;
}

.v3-header p {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
}

.v3-header span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #b8874e;
  box-shadow: 0 0 18px #b8874ee6;
}

.v3-header nav { display: flex; gap: 18px; }

.v3-header a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid #cfa3698f;
  padding-bottom: 7px;
}

.v3-header a:hover { color: #d0a66d; }

.v3-status {
  position: absolute;
  bottom: 30px;
  left: 28px;
  z-index: 20;
  margin: 0;
  direction: ltr;
  color: #e1e2dd6e;
  font-size: 8px;
  letter-spacing: .1em;
}

.v3-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 0 17px;
  color: #dedbd3;
  font-size: 10px;
  font-family: inherit;
  letter-spacing: .08em;
  background: #020705c2;
  border: 1px solid #d2a66d6b;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
}

.v3-btn:hover { color: #07100c; background: #d0a66d; }
.v3-btn svg { width: 14px; height: 14px; }

.v3-skip,
.v3-replay { display: none !important; }

/* ------------------------------------------------------- curtain layer --- */

.curtain-layer {
  position: fixed;
  inset: 0;
  z-index: 30;
  overflow: hidden;
  /* Keep the first paint opaque until the genuine closed cloth frame exists. */
  background: #010302;
}

.curtain-layer canvas {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  /* Revealed with no transition once the closed pose has actually been rendered. */
  visibility: hidden;
}

.curtain-layer.is-ready { background: transparent; }
.curtain-layer.is-ready canvas { visibility: visible; }
.curtain-layer.is-finished { display: none; }

/* ------------------------------------------------------------- overlay --- */
/* Integration mode: the curtain plays as a fixed overlay above the real,
   live website — the site itself is the stage revealed behind the fabric. */

.v3-page.v3-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  min-height: 0;
  background: transparent;
  pointer-events: none;
}

.v3-overlay .curtain-layer { pointer-events: none; }
.v3-overlay .v3-btn { pointer-events: auto; }

/* --------------------------------------------------------------- debug --- */

.v3-debug {
  position: fixed;
  z-index: 90;
  top: 60px;
  right: 16px;
  display: grid;
  gap: 8px;
  width: 230px;
  padding: 12px;
  direction: ltr;
  color: #cfe4d6;
  font-size: 10px;
  font-family: ui-monospace, monospace;
  background: #020705d9;
  border: 1px solid #2a4a3a;
}

.v3-debug label { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.v3-debug input[type="range"] { width: 120px; }
.v3-debug .row { display: flex; gap: 6px; }
.v3-debug button {
  flex: 1;
  padding: 4px 6px;
  color: inherit;
  font: inherit;
  background: #0a1a12;
  border: 1px solid #2a4a3a;
  cursor: pointer;
}
.v3-debug button:hover { background: #14311f; }
.v3-debug .stats { white-space: pre; color: #9fc7ac; }

/* ---------------------------------------------------------- responsive --- */

@media (max-width: 760px) {
  .v3-header { align-items: flex-start; gap: 16px; padding-top: 20px; }
  .v3-header nav { flex-direction: column; gap: 10px; align-items: flex-end; }
  .stage-trophy { width: min(88vw, 510px); height: 76svh; }
  .v3-status { display: none; }
  .v3-skip { bottom: 16px; right: 16px; }
  .v3-replay { bottom: 12px; right: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .stage-beam { transition-duration: .01ms; transition-delay: 0s; }
}
