/* ==========================================================================
   Base Styles & Reset
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-color: #08090d;
  --surface-color: #11141b;
  --surface-border: rgba(255, 255, 255, 0.08);
  --accent-cyan: #38bdf8;
  --accent-purple: #a855f7;
  --accent-glow: rgba(56, 189, 248, 0.18);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --stage-width: 720px;
}

/* ==========================================================================
   Hero Scroll Section & Sticky Stage
   --------------------------------------------------------------------------
   Mobile fixes:
   - svh units: 100vh on mobile = the LARGEST viewport (address bar hidden),
     so the sticky stage was taller than the visible screen and the whole
     section jumped every time the address bar collapsed/expanded.
   - No `perspective`, no 80px blur filter, no blend/mask on the wrapper
     on touch devices — each of those forced a full-stage recomposite on
     every scrolled pixel.
   ========================================================================== */
.hero-scroll-track {
  position: relative;
  height: 300vh;
  height: 300svh;
  background: #f0e7cf;
  contain: layout style;
}

.hero-scroll-track::after {
  content: " ";
  position: absolute;
  top: -70px;
  left: 0;
  width: 100%;
  height: 70px;
  background-image: url(../images/shap.png);
  pointer-events: none;
}

.hero-scroll-track::before {
  content: " ";
  position: absolute;
  bottom: -70px;
  left: 0;
  width: 100%;
  height: 70px;
  background-image: url(../images/shap.png);
  transform: rotate(180deg);
  pointer-events: none;
}

.hero-sticky-stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  isolation: isolate;
}

/* Ambient glow — plain gradient, no filter: blur() (that was the single most
   expensive thing on the page: an 800px element re-blurred every frame). */
.ambient-glow {
  position: absolute;
  width: 800px;
  height: 800px;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(56, 189, 248, 0.10) 0%,
    rgba(168, 85, 247, 0.05) 35%,
    transparent 65%);
  pointer-events: none;
  z-index: 0;
}

/* ==========================================================================
   Strict 720px Container
   ========================================================================== */
.hero-720-wrapper {
  width: 100%;
  max-width: var(--stage-width);
  padding: 0 16px;
  z-index: 10;
  display: flex;
  justify-content: center;
  -webkit-mask-image: linear-gradient(to right, transparent, #fff 20%, #fff 80%, transparent), linear-gradient(to bottom, transparent, #fff 20%, #fff 80%, transparent);
    -webkit-mask-composite: intersect;
    mask-composite: intersect;
}

/* Desktop-only decoration. The blend + double-gradient mask are kept for
   pointer devices; touch devices get the plain canvas (see media query). */
@media (hover: hover) and (pointer: fine) {
  .hero-720-wrapper {
  mix-blend-mode: color-burn;
  -webkit-mask-image:
    linear-gradient(to right, transparent, #fff 20%, #fff 80%, transparent),
    linear-gradient(to bottom, transparent, #fff 20%, #fff 80%, transparent);
  mask-image:
    linear-gradient(to right, transparent, #fff 20%, #fff 80%, transparent),
    linear-gradient(to bottom, transparent, #fff 20%, #fff 80%, transparent);
  -webkit-mask-composite: source-in;
  mask-composite: intersect;
}
}

.hero-720-container {
  width: 100%;
  max-width: var(--stage-width);
  aspect-ratio: 16 / 9;
  position: relative;
  background: #fef7e7;
  border-radius: 0;
  overflow: hidden;
  transform: translateZ(0);
}

#heroCanvas {
  width: 100%;
  height: 100%;
  display: block;
  background: #f0e5d1;
  border: none;
  /* Needed only while frames have a black background. Once the frames are
     re-exported with #f5f3eb baked in, delete this line and set
     CONFIG.background = '#f5f3eb' in framing.js. */
  will-change: transform;
}

/* ==========================================================================
   Loading Overlay
   ========================================================================== */
.canvas-loader {
  position: absolute;
  inset: 0;
  background: rgb(254 247 232);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 30;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.canvas-loader.loaded {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(0, 0, 0, 0.08);
  border-top-color: #7a454b;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loader-status {
  display: flex;
  gap: 12px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.loader-percent {
  font-family: 'JetBrains Mono', monospace;
  color: #7a454b;
  font-weight: 600;
}

.loader-bar-bg {
  width: 200px;
  height: 4px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 99px;
  overflow: hidden;
}

.loader-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #7a454b, var(--accent-purple));
  transition: width 0.15s ease-out;
}

/* ==========================================================================
   Overlaid Captions (Fade in/out on scroll)
   ========================================================================== */
.hero-captions-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  display: none;
}

.caption-item {
  position: absolute;
  bottom: 36px;
  left: 36px;
  right: 36px;
  background: rgba(13, 16, 23, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  padding: 24px 28px;
  opacity: 0;
  transform: translateY(20px) scale(0.97);
  transition: opacity 0.25s ease-out, transform 0.25s ease-out;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.caption-item.active {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.caption-tag {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--accent-cyan);
  margin-bottom: 6px;
}

.caption-item h2 {
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 6px;
  color: #fff;
}

.caption-item p {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.caption-item code {
  font-family: 'JetBrains Mono', monospace;
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent-cyan);
  font-size: 0.85em;
}

/* ==========================================================================
   Frame Stats Badge
   ========================================================================== */
.frame-stats-badge {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(9, 11, 16, 0.8);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 6px 14px;
  border-radius: 99px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: none;
}

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

.fps-tag {
  background: rgba(56, 189, 248, 0.15);
  color: #79454b;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}

/* ==========================================================================
   Scroll Prompt
   ========================================================================== */
.scroll-prompt {
  position: absolute;
  bottom: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 10;
}

.scroll-chevron {
  width: 14px;
  height: 14px;
  border-right: 2px solid var(--accent-cyan);
  border-bottom: 2px solid var(--accent-cyan);
  transform: rotate(45deg);
  animation: bounce 1.6s infinite ease-in-out;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0) rotate(45deg); opacity: 0.4; }
  50% { transform: translateY(6px) rotate(45deg); opacity: 1; }
}

/* ==========================================================================
   Content Section & Cards
   ========================================================================== */
.content-section {
  position: relative;
  background: var(--bg-color);
  padding: 100px 24px;
  border-top: 1px solid var(--surface-border);
  z-index: 20;
}

.content-container {
  max-width: 900px;
  margin: 0 auto;
}

.section-badge {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.2);
  padding: 4px 12px;
  border-radius: 99px;
  margin-bottom: 16px;
}

.section-title {
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #fff;
  margin-bottom: 12px;
}

.section-subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin-bottom: 48px;
}

.grid-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin-bottom: 48px;
}

.step-card {
  background: var(--surface-color);
  border: 1px solid var(--surface-border);
  border-radius: 18px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.step-card:hover {
  transform: translateY(-4px);
  border-color: rgba(56, 189, 248, 0.3);
}

.step-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.75rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.15);
  margin-bottom: 12px;
}

.step-card h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: #fff;
}

.step-card h3 code {
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent-cyan);
}

.step-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
  flex-grow: 1;
}

.code-snippet {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 10px 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--accent-cyan);
  line-height: 1.5;
}

/* ==========================================================================
   Interactive Controls Card
   ========================================================================== */
.interactive-controls-card {
  background: var(--surface-color);
  border: 1px solid var(--surface-border);
  border-radius: 20px;
  padding: 28px 32px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.card-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
}

.pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  padding: 4px 10px;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-radius: 99px;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.controls-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 28px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.control-group label {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
}

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
  outline: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-cyan);
  cursor: pointer;
  box-shadow: 0 0 10px var(--accent-cyan);
  transition: transform 0.1s;
}

.slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* ==========================================================================
   Footer
   ========================================================================== */
.footer {
  text-align: center;
  padding: 40px 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--surface-border);
}

/* ==========================================================================
   Mobile Responsive Adjustments
   ========================================================================== */
@media (max-width: 768px) {
  /* Shorter scroll distance: with ~128 frames this is still ~8px per frame,
     and the section no longer feels like an endless pin. */
  .hero-scroll-track {
    height: 220vh;
    height: 220svh;
  }

  .ambient-glow {
    display: none;
  }

  .hero-720-wrapper {
    padding: 0 12px;
  }

  .caption-item {
    bottom: 20px;
    left: 20px;
    right: 20px;
    padding: 18px 20px;
  }

  .caption-item h2 {
    font-size: 1.2rem;
  }

  .caption-item p {
    font-size: 0.85rem;
  }

  .section-title {
    font-size: 1.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-scroll-track {
    height: auto;
    padding: 60px 0;
  }
  .hero-sticky-stage {
    position: static;
    height: auto;
  }
}