/* ═══════════════════════════════════════════════════════════════
   PATC — Home v7 · Cinematic dark opener + 3-D card scroll story
   ═══════════════════════════════════════════════════════════════ */

/* ── Entrance keyframes ───────────────────────────────────────── */
@keyframes storyEnterLeft {
  from { opacity: 0; transform: translateX(-80px) scale(0.97); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes storyEnterRight {
  from { opacity: 0; transform: translateX(100px) scale(0.97); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes twCursorBlink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* Opening story */
.story-hero {
  background: radial-gradient(circle at 50% 30%, rgba(20, 30, 45, 0.8) 0%, var(--bg) 70%);
  overflow: clip;
  position: relative;
}
.story-hero::before {
  background: linear-gradient(180deg, rgba(3, 7, 11, 0), rgba(3, 7, 11, 0.92));
  content: '';
  inset: 0;
  pointer-events: none;
  position: absolute;
}
.story-sticky {
  align-items: start;
  display: grid;
  gap: 44px;
  grid-template-columns: minmax(360px, 0.86fr) minmax(520px, 1.14fr);
  height: auto;
  margin: 0 auto;
  max-width: 1520px;
  padding: 80px 56px 64px;
  position: relative;
  z-index: 1;
}
.story-copy {
  /* No slide-in — text types in character-by-character instead */
  max-width: 660px;
  opacity: 1;
  position: relative;
  z-index: 2;
}
.story-kicker {
  color: var(--accent);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.22em;
  margin-bottom: 20px;
  text-transform: uppercase;
}
.story-copy h1 {
  font-size: clamp(32px, 4.2vw, 58px);
  letter-spacing: -0.02em;
  line-height: 1.06;
  margin-bottom: 20px;
  text-wrap: balance;
}
.story-copy p[data-home-story-copy] {
  color: var(--text-secondary);
  font-size: clamp(15px, 1.3vw, 20px);
  line-height: 1.65;
  max-width: 620px;
  overflow-wrap: break-word;
  word-break: break-word;
}
.story-copy h1,
.story-copy p[data-home-story-copy] {
  animation: storyTextIn 700ms cubic-bezier(.22,1,.36,1) both;
}

/* ── Typewriter cursor ────────────────────────────────────────── */
.tw-cursor {
  animation: twCursorBlink 0.65s step-end infinite;
  color: var(--accent);
  font-weight: 300;
  margin-left: 2px;
}

/* ── Canvas fullscreen button ─────────────────────────────────── */
.canvas-full-btn {
  align-items: center;
  background: rgba(6, 12, 20, 0.82);
  border: 1px solid rgba(232, 236, 244, 0.10);
  border-radius: 8px;
  top: 12px;
  bottom: auto;
  color: var(--text-secondary);
  display: flex;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  gap: 5px;
  padding: 7px 12px;
  position: absolute;
  right: 14px;
  text-decoration: none;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  z-index: 4;
}
.canvas-full-btn:hover {
  background: rgba(var(--accent-rgb), 0.14);
  border-color: rgba(var(--accent-rgb), 0.34);
  color: var(--accent);
}

/* ── 3-D pop cards for sections below hero ────────────────────── */
.cards-container {
  display: flex;
  flex-direction: column;
  gap: 22px;
  margin: 0 auto;
  max-width: 1140px;
  padding: 24px 28px 56px;
}
.pop-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 22px;
  box-shadow: 0 6px 32px rgba(0, 0, 0, 0.22);
  opacity: 0;
  overflow: hidden;
  transform: perspective(1200px) rotateX(10deg) translateY(56px) scale(0.95);
  transform-origin: 50% 100%;
  transition: opacity 0.9s cubic-bezier(0.34, 1.56, 0.64, 1),
              transform 0.9s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.4s ease;
  will-change: transform, opacity;
}
.pop-card.visible {
  box-shadow: 0 16px 60px rgba(0, 0, 0, 0.28);
  opacity: 1;
  transform: perspective(1200px) rotateX(0deg) translateY(0) scale(1);
}
.pop-card:hover {
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
  transform: perspective(1200px) rotateX(-1deg) translateY(-6px) scale(1.003);
}
/* Reset section margins inside pop cards — card handles spacing */
.pop-card > .story-problem,
.pop-card > .story-process,
.pop-card > .section,
.pop-card > .safety-panel,
.pop-card > section {
  margin: 0;
  max-width: none;
}

/* Floating animation for impact-grid + safety-grid cards */
@keyframes cardFloat {
  0%, 100% { transform: translateY(0);   }
  50%       { transform: translateY(-6px); }
}
.impact-grid article.visible {
  animation: cardFloat 3.2s ease-in-out infinite;
}
.impact-grid article.reveal-delay-1.visible { animation-delay: 0s;    }
.impact-grid article.reveal-delay-2.visible { animation-delay: 0.8s;  }
.impact-grid article.reveal-delay-3.visible { animation-delay: 1.6s;  }
.impact-grid article.reveal-delay-4.visible { animation-delay: 2.4s;  }
/* Override site.css hover transform so float animation isn't interrupted */
.impact-grid article:hover {
  border-color: rgba(var(--accent-rgb), 0.3);
  transform: translateY(-8px);
}
.safety-grid p.visible {
  animation: cardFloat 3.6s ease-in-out infinite;
}
.safety-grid p:nth-child(1).visible { animation-delay: 0s;   }
.safety-grid p:nth-child(2).visible { animation-delay: 1.2s; }
.safety-grid p:nth-child(3).visible { animation-delay: 2.4s; }
.safety-grid p:hover {
  transform: translateY(-8px);
}
.story-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 28px;
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.story-pill {
  background: rgba(232, 236, 244, 0.05);
  border: 1px solid rgba(232, 236, 244, 0.09);
  border-radius: 999px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  padding: 8px 12px;
  text-transform: uppercase;
  transition: background 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}
.story-pill.active {
  background: rgba(var(--accent-rgb), 0.12);
  border-color: rgba(var(--accent-rgb), 0.34);
  color: var(--accent);
}
/* No intro-phase hide rules — animation starts directly on fixed phase */
.story-visual {
  /* Hidden until JS triggers canvas-entered after first word typed */
  aspect-ratio: 16 / 10;
  background:
    radial-gradient(circle at 30% 20%, rgba(var(--accent-rgb), 0.16), transparent 30%),
    linear-gradient(145deg, rgba(18, 30, 42, 0.78), rgba(5, 9, 14, 0.96));
  border: 1px solid rgba(var(--accent-rgb), 0.16);
  border-radius: 28px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.34), inset 0 0 0 1px rgba(255,255,255,0.025);
  min-height: 380px;
  opacity: 0;
  overflow: hidden;
  position: relative;
  transform: translateX(110px) scale(0.96);
}
.story-visual.canvas-entered {
  animation: storyEnterRight 1s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
#storyCanvas {
  display: block;
  height: 100%;
  width: 100%;
}
.story-legend {
  align-items: center;
  background: rgba(3, 7, 11, 0.72);
  border: 1px solid rgba(232, 236, 244, 0.08);
  border-radius: 999px;
  bottom: 16px;
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  gap: 12px;
  left: 18px;
  padding: 9px 12px;
  position: absolute;
}
.story-legend span {
  align-items: center;
  display: inline-flex;
  gap: 6px;
}
.story-legend i {
  border-radius: 999px;
  display: inline-block;
  height: 8px;
  width: 8px;
}
.legend-you { background: var(--signal-amber); }
.legend-fixed { background: var(--signal-red); }
.legend-patc { background: var(--signal-green); }
.story-replay-btn {
  background: rgba(3, 7, 11, 0.72);
  border: 1px solid rgba(232, 236, 244, 0.12);
  border-radius: 999px;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  z-index: 3;
  margin-left: auto;
}
.story-replay-btn:hover {
  background: rgba(var(--accent-rgb), 0.14);
  border-color: rgba(var(--accent-rgb), 0.34);
  color: var(--accent);
}
@keyframes storyTextIn {
  from { opacity: 0; transform: translateY(26px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes storyVisualIn {
  from { opacity: 0; transform: translateX(80px) scale(0.96); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

/* Animated background glow — no visible grid lines */
body::before {
  background: radial-gradient(
    ellipse at 50% 30%,
    rgba(61, 191, 176, 0.02),
    transparent 60%
  );
  content: '';
  inset: 0;
  pointer-events: none;
  position: fixed;
  transition: opacity 0.5s ease;
  z-index: -2;
}
body::after {
  content: '';
  display: none;
}

/* Typewriter cursor blink */
.cursor-blink {
  animation: cursorBlink 0.7s step-end infinite;
  color: var(--accent);
  font-weight: 300;
}
@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}
@keyframes gridWave {
  0%   { left: -100%; }
  100% { left: 100%; }
}

/* ═══ ACT 1 — CINEMATIC OPENER ═══════════════════════════════ */
.cinema-opener {
  align-items: center;
  display: grid;
  gap: 48px;
  grid-template-columns: minmax(0, 1.1fr) minmax(380px, 1fr);
  margin: 0 auto;
  max-width: 1400px;
  min-height: 100vh;
  padding: 100px 60px 80px;
  position: relative;
}
.cinema-opener::before {
  background: radial-gradient(
    ellipse at 20% 40%,
    rgba(61, 191, 176, 0.07),
    transparent 50%
  );
  content: '';
  inset: -200px;
  pointer-events: none;
  position: absolute;
  z-index: -1;
}

body:has(.story-hero) .cinema-opener,
body:has(.story-hero) .cinema-canvas-wrap {
  display: none;
}

/* Title */
.cinema-title {
  font-size: clamp(38px, 5vw, 68px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.06;
  margin-bottom: 24px;
}
.accent-glow {
  background: linear-gradient(135deg, #3DBFB0, #34D399);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.text-accent {
  color: var(--accent);
}
.cinema-sub {
  color: var(--text-secondary);
  font-size: 17px;
  line-height: 1.7;
  max-width: 520px;
}

/* Canvas wrap */
.cinema-canvas-wrap {
  aspect-ratio: 16 / 10;
  background: rgba(10, 15, 26, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  overflow: hidden;
  position: relative;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.cinema-canvas-wrap:hover {
  border-color: rgba(var(--accent-rgb), 0.25);
  box-shadow: 0 0 60px rgba(var(--accent-rgb), 0.06);
}
#storyCanvas {
  display: block;
  height: 100%;
  width: 100%;
}
.canvas-legend {
  align-items: center;
  background: rgba(10, 15, 26, 0.8);
  border-radius: 999px;
  bottom: 12px;
  color: var(--text-muted);
  display: flex;
  font-size: 11px;
  font-weight: 600;
  gap: 6px;
  left: 50%;
  padding: 6px 16px;
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
}
.legend-dot {
  border-radius: 50%;
  display: inline-block;
  height: 8px;
  width: 8px;
}

/* ═══ ACT 2 — STORY CHAPTERS ════════════════════════════════ */
.story-chapter {
  border-top: 1px solid var(--border-subtle);
  overflow: hidden;
  position: relative;
}
.story-chapter::before {
  background: radial-gradient(
    ellipse at 80% 50%,
    rgba(61, 191, 176, 0.03),
    transparent 60%
  );
  content: '';
  inset: 0;
  pointer-events: none;
  position: absolute;
}
.story-chapter-highlight {
  background: rgba(52, 211, 153, 0.02);
  border-top-color: rgba(52, 211, 153, 0.15);
}
.chapter-inner {
  align-items: center;
  display: grid;
  gap: 40px;
  grid-template-columns: auto minmax(0, 1fr);
  margin: 0 auto;
  max-width: 1200px;
  padding: 100px 60px;
}
.chapter-number {
  color: var(--border-strong);
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(72px, 10vw, 120px);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  opacity: 0.15;
}
.chapter-number.accent {
  color: var(--accent);
  opacity: 0.25;
}
.chapter-content h2 {
  font-size: clamp(26px, 3.5vw, 44px);
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}
.chapter-content p {
  color: var(--text-secondary);
  font-size: 17px;
  line-height: 1.75;
  max-width: 600px;
}

/* ── Problem section ──────────────────────────────────────────── */
.story-problem {
  margin: 0 auto;
  max-width: 1200px;
  padding: 56px 48px 48px;
}
.problem-head {
  display: grid;
  gap: 32px;
  grid-template-columns: 1fr auto;
  align-items: end;
  margin-bottom: 32px;
}
.big-stat {
  color: var(--signal-red);
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(56px, 7vw, 96px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  text-align: right;
}
.big-stat small {
  color: var(--text-secondary);
  display: block;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  margin-top: 6px;
  text-align: right;
}

/* ── Process section ──────────────────────────────────────────── */
.story-process {
  margin: 0 auto;
  max-width: 1200px;
  padding: 48px 48px 60px;
}

/* ── Junction markers ─────────────────────────────────────────── */
.junction-marker {
  align-items: center;
  display: flex;
  gap: 14px;
  margin: 0 auto;
  max-width: 1200px;
  padding: 0 48px;
}
.junction-marker .dot {
  background: var(--accent);
  border-radius: 50%;
  height: 10px;
  opacity: 0.5;
  width: 10px;
}
.junction-marker .line {
  background: linear-gradient(90deg, rgba(var(--accent-rgb), 0.15), transparent);
  flex: 1;
  height: 1px;
}

/* ── Green tagline ────────────────────────────────────────────── */
.green-tagline {
  align-items: center;
  display: flex;
  gap: 12px;
  margin: 28px 0 0;
}
.green-tagline-text {
  background: linear-gradient(135deg, #34D399 0%, #3DBFB0 60%, #60A5FA 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: clamp(16px, 1.8vw, 22px);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.green-tagline-icon {
  flex-shrink: 0;
  font-size: 18px;
  line-height: 1;
}

/* ═══ TEAM FOOTER ════════════════════════════════════════════ */
.team-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 0;
}
.footer-inner {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 16px 32px;
  margin: 0 auto;
  max-width: 1200px;
  padding: 28px 48px;
}
.footer-brand {
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.footer-inner > p {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 auto 0 0;
}
.footer-team {
  display: flex;
  gap: 28px;
}
.footer-person {
  display: flex;
  align-items: center;
  gap: 10px;
}
.footer-name-link {
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 700;
  transition: color 0.2s ease;
}
.footer-name-link:hover {
  color: var(--accent);
}
.footer-person strong {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
}
.footer-links {
  display: flex;
  gap: 6px;
}
.footer-links a {
  background: var(--accent-faint);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  transition: all 0.2s ease;
}
.footer-links a:hover {
  background: rgba(var(--accent-rgb), 0.15);
  border-color: rgba(var(--accent-rgb), 0.3);
}

/* ── Reduced motion ───────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  body::after { animation: none; }
  .reveal, .reveal-left, .reveal-right, .reveal-scale {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .cinema-opener {
    grid-template-columns: 1fr;
    min-height: auto;
    padding: 80px 20px 48px;
    gap: 32px;
  }
  .cinema-canvas-wrap { max-width: 600px; }
  .chapter-inner {
    grid-template-columns: 1fr;
    padding: 60px 20px;
    gap: 16px;
  }
  .chapter-number { font-size: 56px; }
  .story-problem { padding: 80px 20px 48px; }
  .problem-head { grid-template-columns: 1fr; }
  .big-stat { text-align: left; }
  .story-process { padding: 48px 20px 80px; }
  .junction-marker { padding: 0 20px; }
  .footer-inner { padding: 20px; }
  .footer-team { flex-direction: column; gap: 12px; }
  .footer-person { flex-direction: column; align-items: flex-start; gap: 4px; }
}

/* ── 3D Reveal Overrides for Home Page ────────────────────────── */
.reveal {
  opacity: 0;
  transform: perspective(1200px) rotateX(20deg) translateY(40px) translateZ(-40px);
  transform-style: preserve-3d;
  transition: opacity 0.8s cubic-bezier(0.22, 1, 0.36, 1), transform 0.8s cubic-bezier(0.22, 1, 0.36, 1) !important;
}
.reveal.visible {
  opacity: 1;
  transform: perspective(1200px) rotateX(0deg) translateY(0) translateZ(0);
}
.reveal-scale {
  opacity: 0;
  transform: perspective(1200px) rotateX(15deg) translateY(30px) scale(0.92);
  transform-style: preserve-3d;
  transition: opacity 0.8s cubic-bezier(0.22, 1, 0.36, 1), transform 0.8s cubic-bezier(0.22, 1, 0.36, 1) !important;
}
.reveal-scale.visible {
  opacity: 1;
  transform: perspective(1200px) rotateX(0deg) translateY(0) scale(1);
}
