/* ==========================================================================
   VoraData HITL.md — Precision UI + Paul Fey Story Craft + human-md.ai + Lens
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cormorant:ital,wght@0,500;1,500;1,600&family=Fira+Code:wght@400;500;600&family=Inter:wght@300;400;500;600;700&family=Outfit:wght@500;600;700;800&display=swap');

:root {
  --bg: #02040a;
  --bg-stage: #0B0D13;
  --fg: #E2E8F0;
  --pending: #334155;
  --muted: #64748B;
  --ink: #151515;
  --card-paper: #121723;
  --line: rgba(255, 255, 255, 0.08);
  --grid-major: rgba(244, 142, 36, 0.075);
  --grid-minor: rgba(255, 255, 255, 0.024);
  --accent: #F48E24;
  --accent-studio: #E98525;
  --shadow-hard: rgba(0, 0, 0, 0.72);
  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Fira Code', ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-serif: 'Cormorant', Georgia, serif;
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dec: cubic-bezier(0.23, 1, 0.32, 1);
}

body.paper-era {
  --bg: #F4F2ED;
  --bg-stage: #F4F2ED;
  --fg: #151515;
  --pending: #B9B3A7;
  --muted: #6E685E;
  --ink: #151515;
  --card-paper: #FFFFFF;
  --line: rgba(21, 21, 21, 0.14);
  --grid-major: rgba(23, 59, 108, 0.12);
  --grid-minor: rgba(23, 59, 108, 0.045);
  --accent: #F48E24;
  --shadow-hard: rgba(21, 21, 21, 0.26);
}

body.pitch-black {
  background-color: #000000 !important;
  color: #F8FAFC !important;
}

body.pitch-black .era-bg,
body.pitch-black #top-hud,
body.pitch-black #bottom-hud {
  opacity: 0 !important;
  pointer-events: none !important;
}

body.intro-emerging {
  background-color: #0B0D13 !important;
  color: #F8FAFC !important;
}

body.intro-emerging .era-bg {
  opacity: 0.75 !important;
}

body.intro-emerging #top-hud,
body.intro-emerging #bottom-hud {
  opacity: 0 !important;
  pointer-events: none !important;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background-color: var(--bg-stage);
  color: var(--fg);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.65s ease, color 0.45s ease;
  overflow-x: hidden;
}

.heading-font { font-family: var(--font-heading); }
.mono { font-family: var(--font-mono); }
.serif-it { font-family: var(--font-serif); font-style: italic; font-weight: 500; }

/* Subtle VoraData + human-md.ai film grain */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  opacity: 0.03;
  background-image: url('data:image/svg+xml,<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><filter id="n"><feTurbulence type="fractalNoise" baseFrequency="0.75" numOctaves="3" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23n)"/></svg>');
}

/* Evolving Era Canvas Backgrounds (paulfey.me/story) */
.era-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  transition: opacity 0.75s ease;
}

.era-paper-grid {
  background-image:
    linear-gradient(to right, var(--grid-major) 0 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-major) 0 1px, transparent 1px);
  background-size: 22vw 22vw;
  background-position: calc(50% + 0.5px) 0;
}

.era-blueprint {
  background-image:
    linear-gradient(to right, var(--grid-major) 0 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-major) 0 1px, transparent 1px),
    linear-gradient(to right, var(--grid-minor) 0 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-minor) 0 1px, transparent 1px);
  background-size: 80px 80px, 80px 80px, 16px 16px, 16px 16px;
  background-position: calc(50% + 0.5px) 0;
}

.era-dots {
  background-image: radial-gradient(circle at 1px 1px, var(--grid-major) 1.25px, transparent 1.5px);
  background-size: 16px 16px;
}

#top-hud, #bottom-hud {
  transition: opacity 0.55s ease, transform 0.55s var(--dec);
}

/* Laser Scanline Sweep (#scan) */
#scan {
  position: fixed;
  left: 0;
  right: 0;
  top: -6px;
  height: 2px;
  background: var(--accent);
  box-shadow: 0 0 22px 5px rgba(244, 142, 36, 0.45);
  opacity: 0;
  z-index: 55;
  pointer-events: none;
}

@keyframes scanSweep {
  0% { top: -4px; opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

#scan.go {
  animation: scanSweep 0.65s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* ==========================================================================
   PAUL FEY STORY PAGE STYLES (.chead, .ctitle, .sw word reveal, .story-print)
   ========================================================================== */
.story-chead {
  min-height: 74vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 6rem 1.5rem 4rem;
}

.story-ctitle {
  margin: 0;
  color: var(--accent);
  font-size: clamp(44px, 8.8vw, 124px);
  line-height: 0.92;
  text-transform: uppercase;
  letter-spacing: -0.03em;
}

.story-copy-col {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 1.25rem;
  text-align: center;
}

.story-para-row {
  position: relative;
  margin-bottom: 5.5rem;
}

.story-para-text {
  font-size: clamp(20px, 2.4vw, 33px);
  line-height: 1.52;
  letter-spacing: -0.02em;
  font-weight: 300;
}

/* Word-by-word scroll illumination (.sw -> .sw.on) */
.sw {
  color: var(--pending);
  transition: color 0.42s ease;
}

.sw.on {
  color: var(--fg);
}

.story-anchor {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.16em;
  font-weight: 500;
}

/* Tilted Margin Print Cards (.story-print) */
.story-print {
  background: var(--card-paper);
  border: 2.5px solid var(--fg);
  padding: 14px 16px;
  box-shadow: 10px 10px 0 2px var(--shadow-hard);
  text-align: left;
  opacity: 0;
  transform: translateY(22px) rotate(calc(var(--tilt, -3deg) * 2.2)) scale(1.04);
  transition:
    opacity 0.28s linear,
    transform 0.7s var(--spring),
    box-shadow 0.35s var(--dec);
}

.story-print.landed {
  opacity: 1;
  transform: translateY(0) rotate(var(--tilt, -3deg)) scale(1);
}

.story-print.landed:hover {
  transform: translateY(-4px) rotate(0deg) scale(1.02);
  box-shadow: 14px 16px 0 2px var(--shadow-hard);
}

/* Desktop Margin Positioning + Curved SVG Leader Line */
@media (min-width: 1120px) {
  .story-margin-wrap {
    position: absolute;
    top: -10px;
    width: 255px;
  }
  .story-margin-wrap[data-side="L"] {
    right: calc(100% + 36px);
  }
  .story-margin-wrap[data-side="R"] {
    left: calc(100% + 36px);
  }
}

@media (max-width: 1119px) {
  .story-margin-wrap {
    max-width: 310px;
    margin: 1.75rem auto 0;
  }
  .story-lead-svg {
    display: none;
  }
}

/* Paul Fey Tilted Black Navigation Strip */
.tilted-nav-strip {
  background: #151515;
  color: #FFF3D6;
  transform: rotate(1.1deg);
  box-shadow: 5px 4px 0 var(--shadow-hard);
  transition: transform 0.35s var(--spring);
}

.tilted-nav-strip:hover {
  transform: rotate(0deg);
}

/* Pitch-Black Dynamic Intro Choreography */
@keyframes wordPop {
  0% { opacity: 0; transform: translateY(28px) scale(0.92); filter: blur(6px); }
  65% { opacity: 1; transform: translateY(-2px) scale(1.02); filter: blur(0px); }
  100% { opacity: 1; transform: translateY(0) scale(1); filter: blur(0px); }
}

@keyframes stageExit {
  0% { opacity: 1; transform: scale(1) translateY(0); filter: blur(0px); }
  100% { opacity: 0; transform: scale(1.06) translateY(-16px); filter: blur(8px); }
}

@keyframes ringShock {
  0% { transform: translate(-50%, -50%) scale(0.2); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(3.2); opacity: 0; }
}

@keyframes voriPopUp {
  0% { opacity: 0; transform: translateY(45px) scale(0.75) rotate(-12deg); }
  100% { opacity: 1; transform: translateY(0) scale(1) rotate(0deg); }
}

@keyframes caretBlink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.caret {
  display: inline-block;
  width: 2.5px;
  height: 1.05em;
  background: #F48E24;
  vertical-align: -0.15em;
  margin-left: 3px;
  animation: caretBlink 0.9s infinite;
}

.k-word {
  display: inline-block;
  position: relative;
  opacity: 0;
}

.k-word.on {
  animation: wordPop 0.65s var(--spring) forwards;
}

.k-word.on.pulse-hit::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 24px;
  height: 24px;
  border-radius: 9999px;
  border: 2px solid #F48E24;
  pointer-events: none;
  animation: ringShock 0.8s ease-out forwards;
}

/* ==========================================================================
   INTEGRATED CINEMATIC "HITL" STENCIL REVEAL
   1. 0.0s -> 1.3s (0% -> 20%): Pure pitch-black screen hold (calm dark start).
   2. 1.3s -> 6.4s (20% -> 100%): HITL emerges from tiny scale(0.16) & opacity 0,
      expanding with a smooth continuous curve while the dark curtain dissolves
      and the center # HITL.MD · VORADATA.CAT emblem materializes cleanly (never chopped!).
   ========================================================================== */
@keyframes hitlStencilFluidZoom {
  0%, 18% {
    transform: scale(0.16);
    opacity: 0;
  }
  30% {
    opacity: 1;
  }
  100% {
    transform: scale(3.55);
    opacity: 1;
  }
}

@keyframes hitlCurtainFadeOut {
  0%, 64% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

/* The initial pitch-black veil that holds pure black for the first 1.3s before HITL emerges */
@keyframes hitlInitialBlackHold {
  0%, 18% {
    opacity: 1;
  }
  34%, 100% {
    opacity: 0;
  }
}

/* Center # HITL.MD emblem fades in ONLY as the HITL stencil finishes opening (never sliced by the letters!) */
@keyframes hitlCenterEmblemReveal {
  0%, 58% {
    opacity: 0;
    transform: scale(0.92) translateY(8px);
  }
  84%, 100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.hitl-cutout-anim {
  transform-origin: 960px 540px;
  will-change: transform, opacity;
  animation: hitlStencilFluidZoom 6.6s cubic-bezier(0.32, 0.04, 0.24, 1) forwards;
}

.hitl-curtain-svg {
  will-change: opacity;
  animation: hitlCurtainFadeOut 6.6s ease-in-out forwards;
}

.hitl-black-veil {
  will-change: opacity;
  animation: hitlInitialBlackHold 6.6s ease-out forwards;
}

.hitl-emblem-reveal {
  will-change: transform, opacity;
  animation: hitlCenterEmblemReveal 6.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.hitl-fixed-world {
  opacity: 1;
  transform: translateZ(0);
}

/* Deeper Nocturnal Background Illumination drifting Top-Left -> exiting off Bottom-Right */
@keyframes introDiagonalSpotlight {
  0%, 14% {
    transform: translate(-32vw, -30vh);
    opacity: 1;
  }
  82% {
    transform: translate(36vw, 34vh);
    opacity: 0.85;
  }
  100% {
    transform: translate(78vw, 74vh);
    opacity: 0;
  }
}

.intro-diagonal-spot {
  position: absolute;
  inset: -65%;
  pointer-events: none;
  will-change: transform, opacity;
  background:
    radial-gradient(circle 580px at 50% 50%, rgba(203, 213, 225, 0.22) 0%, rgba(71, 85, 105, 0.12) 42%, rgba(15, 23, 42, 0.05) 64%, transparent 80%);
  animation: introDiagonalSpotlight 36s linear forwards;
}

.scene-exit {
  animation: stageExit 0.75s var(--dec) forwards;
}

.vori-entrance {
  animation: voriPopUp 0.6s var(--spring) forwards;
}

.hm-period {
  display: inline-block;
  width: 0.21em;
  height: 0.21em;
  border-radius: 9999px;
  background: #F48E24;
  margin-left: 0.08em;
  vertical-align: baseline;
  box-shadow: 0 0 18px rgba(244, 142, 36, 0.85);
}

/* Figma / CAD Selection Bounding Box (.pf-sel)
   Zero-layout-shift inline variant inside the optical lens so baseHTML and revealHTML
   remain 100% pixel-aligned even across multi-line paragraphs! */
.pf-sel {
  position: relative;
  display: inline;
  padding: 0;
  border: 0;
  color: #F48E24 !important;
  background: rgba(244, 142, 36, 0.22);
  box-shadow: 0 0 0 1.5px #F48E24;
  border-radius: 2px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.pf-sel i {
  position: absolute;
  width: 6px;
  height: 6px;
  background: #FFFFFF;
  border: 1.5px solid #F48E24;
  pointer-events: none;
}

.pf-sel i.tl { top: -4px; left: -4px; }
.pf-sel i.tr { top: -4px; right: -4px; }
.pf-sel i.bl { bottom: -4px; left: -4px; }
.pf-sel i.br { bottom: -4px; right: -4px; }

/* Permanently locked trap highlight once clicked (1/2 -> 2/2 in Mode Complex) */
.pf-sel.trap-caught,
.base-trap-caught {
  color: #10B981 !important;
  background: rgba(16, 185, 129, 0.22) !important;
  box-shadow: 0 0 0 1.5px #10B981 !important;
  border-radius: 2px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

/* Tilted Speech Bubble & Margin Evidence Print */
.vori-bubble {
  background: #FFFFFF;
  color: #151515;
  border: 2.5px solid #151515;
  border-radius: 16px;
  padding: 8px 14px;
  font-weight: 700;
  font-size: 12px;
  line-height: 1.3;
  filter: drop-shadow(5px 5px 0 rgba(0, 0, 0, 0.38));
  transform: rotate(-2.5deg);
  transition: transform 0.35s var(--spring);
}

.vori-bubble:hover {
  transform: rotate(0deg) scale(1.02);
}

.pf-print {
  background: var(--card-paper);
  padding: 16px 18px;
  border: 2.5px solid var(--fg);
  box-shadow: 10px 10px 0 2px var(--shadow-hard);
  opacity: 0;
  transform: translate(-24px, 16px) rotate(-6deg) scale(1.04);
  transition: opacity 0.25s linear, transform 0.65s var(--spring), box-shadow 0.35s var(--dec);
  pointer-events: none;
}

.pf-print.landed {
  opacity: 1;
  transform: translate(0, 0) rotate(-2.2deg) scale(1);
  pointer-events: auto;
}

.pf-print.landed:hover {
  transform: translate(0, -4px) rotate(0deg);
  box-shadow: 14px 16px 0 2px var(--shadow-hard);
}

.lead-path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-dasharray: 220;
  stroke-dashoffset: 220;
  transition: stroke-dashoffset 0.55s var(--dec);
}

.lead-path.drawn {
  stroke-dashoffset: 0;
}

/* The Variable Optical Radar Lens (Hidden until mouse/finger enters so it NEVER pre-reveals the trap!) */
@keyframes radarSweepSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.lens-stage {
  position: relative;
  --mx: -500px;
  --my: -500px;
  --r: 48px;
}

.lens-reveal {
  position: absolute;
  inset: 0;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(circle var(--r) at var(--mx) var(--my), #000 0%, rgba(0, 0, 0, 0.94) 72%, transparent 100%);
  mask-image: radial-gradient(circle var(--r) at var(--mx) var(--my), #000 0%, rgba(0, 0, 0, 0.94) 72%, transparent 100%);
  background: rgba(244, 142, 36, 0.04);
}

.lens-ring {
  position: absolute;
  left: var(--mx);
  top: var(--my);
  width: calc(var(--r) * 2);
  height: calc(var(--r) * 2);
  transform: translate(-50%, -50%);
  border-radius: 9999px;
  border: 1.5px solid var(--accent);
  box-shadow: 0 0 22px rgba(244, 142, 36, 0.25), inset 0 0 16px rgba(244, 142, 36, 0.10);
  pointer-events: none;
  opacity: 0;
  transition: width 0.08s ease-out, height 0.08s ease-out, opacity 0.16s ease;
}

/* Rotating Radar Sweep Cone inside .lens-ring */
.lens-ring::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 9999px;
  background: conic-gradient(from 0deg, transparent 70%, rgba(244, 142, 36, 0.26) 100%);
  animation: radarSweepSpin 2.4s linear infinite;
}

/* Inner Radar Dashed Ring + Crosshairs */
.lens-ring::after {
  content: '';
  position: absolute;
  inset: 22%;
  border-radius: 9999px;
  border: 1px dashed rgba(244, 142, 36, 0.45);
  background:
    linear-gradient(to right, transparent 48.5%, rgba(244, 142, 36, 0.22) 49%, rgba(244, 142, 36, 0.22) 51%, transparent 51.5%),
    linear-gradient(to bottom, transparent 48.5%, rgba(244, 142, 36, 0.22) 49%, rgba(244, 142, 36, 0.22) 51%, transparent 51.5%);
}

.lens-stage:hover .lens-ring,
.lens-stage.radar-active .lens-ring {
  opacity: 1;
}

.lens-hud-label {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--accent);
  border: 1px solid rgba(244, 142, 36, 0.55);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  white-space: nowrap;
  z-index: 2;
}

/* Circular ⓘ Info Button */
.info-i-btn {
  width: 24px;
  height: 24px;
  border-radius: 9999px;
  border: 1.5px solid rgba(244, 142, 36, 0.65);
  background: rgba(244, 142, 36, 0.12);
  color: #F48E24;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s ease;
  flex-shrink: 0;
}

.info-i-btn:hover {
  background: #F48E24;
  color: #151515;
  transform: scale(1.08);
}

/* Floating HUD Pills & Keycaps */
.hud-pill {
  padding: 5px 12px;
  border-radius: 9999px;
  border: 1px solid var(--line);
  background: var(--card-paper);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.hud-pill:hover {
  border-color: var(--accent);
}

.kbd {
  display: inline-flex;
  align-items: center;
  padding: 1px 5px;
  font-size: 10px;
  font-family: var(--font-mono);
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--muted);
}
