/* ==========================================================================
   PULL THE THREAD - DESIGN SYSTEM & STYLES
   Minimalist Editorial Facade -> 3D Torn Seam -> Cyberpunk Hidden Reality
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,600;1,400&family=JetBrains+Mono:wght@300;400;500;700&family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

:root {
  --pull-progress: 0;
  --white-bg: #faf9f6;
  --white-surface: #ffffff;
  --white-text-main: #141414;
  --white-text-muted: #737373;
  --white-border: #e8e6e1;
  --crimson-thread: #ff204e;
  
  --void-bg: #07090e;
  --void-surface: rgba(18, 24, 38, 0.7);
  --void-cyan: #00f3ff;
  --void-magenta: #ff0077;
  --void-gold: #ffb800;
  --void-border: rgba(0, 243, 255, 0.2);
}

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--void-bg);
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

/* Base Stage Container */
#viewport {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* ==========================================================================
   LAYER 0: THE SECRET WEBSITE (THE OTHER SIDE / LAMP SCENE)
   ========================================================================== */
#secret-world {
  position: absolute;
  inset: 0;
  z-index: 1;
  background-color: #080706;
  background-image: 
    radial-gradient(circle at 50% 25%, #1c150c 0%, #0d0a07 55%, #050403 100%);
  color: #ede8e1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0.99;
  transition: background 0.6s ease;
}

#secret-world.lamp-off {
  background-color: #020202;
  background-image: radial-gradient(circle at 50% 25%, #080706 0%, #020202 80%);
}

/* Subtle secret header */
.secret-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 40px;
}

.secret-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #8c8275;
}

.brand-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ffb443;
  box-shadow: 0 0 10px #ffb443;
}

.secret-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Reweave / Mend Button */
.btn-reweave {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #d1c7bc;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.25s ease;
  backdrop-filter: blur(8px);
}

.btn-reweave:hover {
  background: rgba(255, 32, 78, 0.15);
  border-color: rgba(255, 32, 78, 0.4);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(255, 32, 78, 0.25);
}

.btn-reweave-primary {
  padding: 12px 28px;
  font-size: 13px;
  font-weight: 600;
  background: linear-gradient(135deg, #e63946, #b5172e);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  box-shadow: 0 6px 22px rgba(230, 57, 70, 0.35);
}

.btn-reweave-primary:hover {
  background: linear-gradient(135deg, #ff4d5e, #c91833);
  box-shadow: 0 8px 26px rgba(230, 57, 70, 0.5);
}

/* ==========================================================================
   THE LAMP SCENE
   ========================================================================== */
.lamp-scene {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 24px;
}

/* Hanging Lamp Assembly */
.lamp-assembly {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 10;
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  transform-origin: center top;
}

.lamp-assembly:hover {
  animation: lampSway 3s ease-in-out infinite;
}

@keyframes lampSway {
  0%, 100% { transform: translateX(-50%) rotate(0deg); }
  25% { transform: translateX(-50%) rotate(1.4deg); }
  75% { transform: translateX(-50%) rotate(-1.4deg); }
}

/* Twisted Wire Cord */
.lamp-cord-wire {
  width: 2px;
  height: 160px;
  background: linear-gradient(to bottom, #111111, #242220 70%, #151311);
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

/* Brass Socket */
.lamp-socket {
  width: 18px;
  height: 20px;
  background: linear-gradient(135deg, #b8860b, #d4af37 40%, #8b6508);
  border-radius: 3px 3px 0 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

/* Minimalist Cone Shade */
.lamp-shade {
  width: 90px;
  height: 38px;
  background: linear-gradient(to bottom, #1a1918 0%, #0d0c0b 100%);
  clip-path: polygon(25% 0%, 75% 0%, 100% 100%, 0% 100%);
  border-bottom: 2px solid #b8860b;
  position: relative;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
}

/* Filament Bulb */
.lamp-bulb {
  position: relative;
  width: 32px;
  height: 42px;
  margin-top: -6px;
  border-radius: 50% 50% 40% 40%;
  background: rgba(255, 240, 200, 0.15);
  border: 1px solid rgba(255, 220, 150, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.4s ease;
  z-index: 5;
}

.bulb-filament {
  width: 6px;
  height: 14px;
  border: 1px solid #735327;
  border-radius: 3px;
  transition: all 0.4s ease;
}

/* LAMP ON STATE: Glowing Warm Incandescence */
#secret-world.lamp-on .lamp-bulb {
  background: radial-gradient(circle at 50% 40%, #ffffff 10%, #ffe39f 40%, #ff9e2c 85%);
  box-shadow:
    0 0 20px #ffbb44,
    0 0 50px rgba(255, 170, 50, 0.8),
    0 0 90px rgba(255, 140, 20, 0.45);
  border-color: rgba(255, 255, 255, 0.8);
}

#secret-world.lamp-on .bulb-filament {
  background: #ffffff;
  box-shadow: 0 0 10px #ffffff, 0 0 18px #ffb443;
  border-color: #ffffff;
}

/* Hanging Pull-Chain with Bead */
.lamp-pull-chain {
  position: absolute;
  top: 195px;
  right: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  padding: 6px;
  z-index: 12;
  transition: transform 0.15s ease;
}

.lamp-pull-chain:active {
  transform: translateY(12px);
}

.chain-cord {
  width: 1px;
  height: 70px;
  background: repeating-linear-gradient(
    to bottom,
    #c49a45 0px,
    #c49a45 3px,
    transparent 3px,
    transparent 5px
  );
}

.chain-bead {
  width: 6px;
  height: 10px;
  border-radius: 3px;
  background: linear-gradient(135deg, #d4af37, #8b6508);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
}

/* Volumetric Light Cone */
.lamp-light-cone {
  position: absolute;
  top: 175px;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 750px;
  pointer-events: none;
  background: radial-gradient(
    ellipse at 50% 0%,
    rgba(255, 210, 130, 0.28) 0%,
    rgba(255, 180, 80, 0.16) 30%,
    rgba(255, 150, 50, 0.06) 60%,
    transparent 78%
  );
  clip-path: polygon(42% 0%, 58% 0%, 100% 100%, 0% 100%);
  opacity: 0;
  transition: opacity 0.5s ease;
  z-index: 2;
}

#secret-world.lamp-on .lamp-light-cone {
  opacity: 1;
}

/* The Revelation Content */
.revelation-box {
  position: relative;
  z-index: 15;
  text-align: center;
  max-width: 680px;
  margin-top: 140px;
  padding: 0 20px;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

#secret-world.lamp-off .revelation-box {
  opacity: 0.18;
  transform: translateY(6px);
}

.revelation-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: #ffaa33;
  margin-bottom: 20px;
  display: inline-block;
  opacity: 0.9;
}

.revelation-heading {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: clamp(38px, 5.5vw, 68px);
  font-weight: 300;
  line-height: 1.1;
  letter-spacing: -0.5px;
  color: #fff9f0;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.8), 0 0 40px rgba(255, 190, 100, 0.25);
  margin-bottom: 24px;
}

.revelation-text {
  font-size: 16px;
  line-height: 1.85;
  color: #c9bfb3;
  font-weight: 300;
  margin-bottom: 36px;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.7);
}

.revelation-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.lamp-hint {
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: #786f64;
  letter-spacing: 0.5px;
}

/* ==========================================================================
   LAYER 1: THE TORN WHITE FACADE (SPLIT LEFT & RIGHT FLAPS)
   ========================================================================== */
#facade-layer {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: auto;
  perspective: 1400px;
  overflow: hidden;
  transform-style: preserve-3d;
  transition: opacity 0.4s ease;
}

#facade-layer.ripped {
  pointer-events: none;
}

/* Left & Right Flaps */
.facade-flap {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50vw;
  height: 100vh;
  overflow: hidden;
  background: var(--white-bg);
  transform-style: preserve-3d;
  will-change: transform, filter;
  transition: box-shadow 0.2s ease;
}

#flap-left {
  left: 0;
  transform-origin: left center;
  box-shadow: 1px 0 0 rgba(0, 0, 0, 0.04);
}

#flap-right {
  left: 50vw;
  transform-origin: right center;
  box-shadow: -1px 0 0 rgba(0, 0, 0, 0.04);
}

/* Inner contents of both flaps: exactly 100vw wide, perfectly aligned */
.flap-inner {
  position: absolute;
  top: 0;
  width: 100vw;
  height: 100vh;
  overflow-y: hidden;
  background: var(--white-bg);
  color: var(--white-text-main);
  display: flex;
  flex-direction: column;
}

#flap-left .flap-inner {
  left: 0;
}

#flap-right .flap-inner {
  left: -50vw; /* Exact coordinate offset so there is NO seam before pull */
}

/* Texture overlay for wallpaper on white website */
.wallpaper-texture {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 10%, rgba(0, 0, 0, 0.015), transparent 60%),
    repeating-linear-gradient(0deg, transparent, transparent 48px, rgba(0, 0, 0, 0.018) 48px, rgba(0, 0, 0, 0.018) 49px),
    repeating-linear-gradient(90deg, transparent, transparent 48px, rgba(0, 0, 0, 0.018) 48px, rgba(0, 0, 0, 0.018) 49px);
  pointer-events: none;
  z-index: 1;
  transform-origin: center top;
  will-change: transform, filter;
}

/* ==========================================================================
   WHITE EDITORIAL WEBSITE CONTENT
   ========================================================================== */
.editorial-container {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* Editorial Header */
.editorial-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--white-border);
  transition: transform 0.2s ease;
}

.editorial-brand {
  font-family: 'Cormorant Garamond', serif;
  font-size: 20px;
  letter-spacing: 5px;
  text-transform: uppercase;
  font-weight: 600;
}

.editorial-nav {
  display: flex;
  align-items: center;
  gap: 32px;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--white-text-muted);
}

.editorial-nav span:hover {
  color: var(--white-text-main);
  cursor: pointer;
}

.editorial-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: #16a34a;
  background: #f0fdf4;
  padding: 4px 10px;
  border-radius: 9999px;
  border: 1px solid #bbf7d0;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #16a34a;
}

/* Editorial Hero */
.editorial-hero {
  padding: 85px 0 24px 0;
  text-align: center;
}

.editorial-overline {
  font-size: 11px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--white-text-muted);
  margin-bottom: 18px;
  font-family: 'JetBrains Mono', monospace;
}

.editorial-headline {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(38px, 6vw, 72px);
  font-weight: 300;
  line-height: 1.05;
  letter-spacing: -1px;
  color: #111111;
  margin-bottom: 22px;
  transition: transform 0.2s ease;
}

.editorial-subhead {
  max-width: 580px;
  margin: 0 auto;
  font-size: 16px;
  line-height: 1.7;
  color: var(--white-text-muted);
  font-weight: 300;
}

/* Editorial Grid */
.editorial-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
  margin-top: 10px;
  padding-bottom: 20px;
}

.editorial-card {
  border-top: 1px solid var(--white-text-main);
  padding-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.2s ease;
}

.card-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--white-text-muted);
  letter-spacing: 2px;
}

.card-heading {
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px;
  font-weight: 400;
}

.card-text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--white-text-muted);
}

/* Editorial Footer */
.editorial-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 20px;
  border-top: 1px solid var(--white-border);
  font-size: 11px;
  color: var(--white-text-muted);
  letter-spacing: 1px;
}

/* ==========================================================================
   LAYER 2: PHYSICS & FX CANVAS (RED THREAD + RAGGED SEAM + PARTICLES)
   ========================================================================== */
#fx-canvas {
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none;
}

/* ==========================================================================
   INTERACTIVE THREAD HITBOX & PULL HINT
   ========================================================================== */
#thread-handle {
  position: absolute;
  top: 0;
  left: 50%;
  width: 90px;
  height: 240px;
  transform: translateX(-50%);
  z-index: 40;
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
}

#thread-handle:active {
  cursor: grabbing;
}

/* Floating Hint: "Pull." */
#pull-hint {
  position: absolute;
  top: 175px;
  left: calc(50% + 22px);
  z-index: 35;
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  animation: hintFloat 2.5s infinite ease-in-out;
}

.hint-text {
  font-family: 'Cormorant Garamond', serif;
  font-size: 26px;
  font-style: italic;
  letter-spacing: 1.5px;
  color: #1a1a1a;
  font-weight: 400;
}

.hint-arrow {
  color: var(--crimson-thread);
  font-size: 18px;
  animation: hintBounce 1.5s infinite ease-in-out;
}

@keyframes hintFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(5px); }
}

@keyframes hintBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(4px); }
}

/* Tension Meter Floating Pill */
#tension-meter {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 35;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(0, 0, 0, 0.08);
  padding: 6px 14px;
  border-radius: 9999px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 1px;
  color: #555;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

#tension-meter.active {
  opacity: 1;
}

.meter-fill-track {
  width: 60px;
  height: 4px;
  background: #e2e8f0;
  border-radius: 2px;
  overflow: hidden;
}

.meter-fill-bar {
  height: 100%;
  width: 0%;
  background: var(--crimson-thread);
  transition: width 0.08s ease;
}

/* Sound Button floating top right */
#sound-toggle {
  position: absolute;
  top: 24px;
  right: 28px;
  z-index: 50;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(0, 0, 0, 0.1);
  padding: 8px 12px;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: #333;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
  transition: all 0.2s ease;
}

#sound-toggle:hover {
  background: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

/* Flash of light on 100% rip */
#rip-flash {
  position: absolute;
  inset: 0;
  z-index: 99;
  background: radial-gradient(circle at 50% 50%, #ffffff, rgba(0, 243, 255, 0.8), transparent 75%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s cubic-bezier(0.1, 0.9, 0.2, 1);
}

#rip-flash.flash {
  opacity: 0.95;
  transition: opacity 0.05s ease;
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .editorial-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .card-quantum, .card-terminal, .card-metrics, .card-audio, .card-lore {
    grid-column: span 12;
  }
  .editorial-nav {
    display: none;
  }
}
