/* concurrent.quest - Styles */
/* Design Colors: #FFE4C4, #FFF5E6, #E8953A, #C2703E, #C2571A, #3D2B1F, #B8A99A, #FF6B2B, #2A8B7A */
/* Fonts: Nunito (display 800), Nunito Sans (body 400/600), JetBrains Mono (code) */

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

html {
  scroll-snap-type: y proximity;
  scroll-behavior: smooth;
}

body {
  font-family: 'Nunito Sans', sans-serif;
  font-weight: 400;
  color: #3D2B1F;
  background: #FFF5E6;
  overflow-x: hidden;
}

/* CRT Overlay */
.crt-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.03) 0px,
    rgba(0, 0, 0, 0.03) 1px,
    transparent 1px,
    transparent 3px
  );
}

/* Bubble Layer */
.bubble-layer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  overflow: hidden;
}

.floating-bubble {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  will-change: transform;
}

.floating-bubble.warm {
  background: radial-gradient(circle at 35% 35%, rgba(255,107,43,0.15), rgba(194,112,62,0.35));
  box-shadow: inset -4px -4px 8px rgba(194,112,62,0.2), inset 3px 3px 6px rgba(255,229,196,0.4);
}

.floating-bubble.cool {
  background: radial-gradient(circle at 35% 35%, rgba(42,139,122,0.12), rgba(42,139,122,0.3));
  box-shadow: inset -4px -4px 8px rgba(42,139,122,0.15), inset 3px 3px 6px rgba(255,245,230,0.3);
}

.bubble-glint {
  position: absolute;
  top: 18%;
  left: 22%;
  width: 30%;
  height: 20%;
  background: radial-gradient(ellipse, rgba(255,255,255,0.6) 0%, transparent 70%);
  border-radius: 50%;
  transform: rotate(-30deg);
}

/* Sections */
.section {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  scroll-snap-align: start;
  overflow: hidden;
}

.section-content {
  position: relative;
  z-index: 5;
  text-align: center;
  padding: 2rem;
  max-width: 900px;
  width: 100%;
}

/* Section Titles */
.section-title {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  color: #C2703E;
  letter-spacing: 0.15em;
  margin-bottom: 2rem;
  text-transform: uppercase;
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.section.visible .section-title {
  opacity: 1;
  transform: translateY(0);
}

.section-description {
  font-family: 'Nunito Sans', sans-serif;
  font-size: clamp(0.95rem, 2vw, 1.15rem);
  line-height: 1.7;
  color: #3D2B1F;
  max-width: 600px;
  margin: 2rem auto 0;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 1s ease 0.3s, transform 1s ease 0.3s;
}

.section.visible .section-description {
  opacity: 0.85;
  transform: translateY(0);
}

/* ===================== SECTION 1: GENESIS ===================== */
.section-genesis {
  background: radial-gradient(ellipse at 50% 80%, #FFE4C4 0%, #FFF5E6 60%, #FFF5E6 100%);
}

.title-container {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.1em;
  margin-bottom: 1.5rem;
}

.title-letter {
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: clamp(2.5rem, 8vw, 6rem);
  letter-spacing: -0.02em;
  line-height: 0.95;
  color: #3D2B1F;
  display: inline-block;
  opacity: 0;
  transform: scale(0.3) translateY(40px);
  transition: opacity 0.5s ease, transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  background: radial-gradient(circle at 50% 50%, rgba(255,107,43,0.08) 0%, transparent 70%);
  border-radius: 50%;
  padding: 0.05em 0.12em;
}

.title-letter.revealed {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.title-dot {
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: clamp(2.5rem, 8vw, 6rem);
  color: #FF6B2B;
  display: inline-block;
  opacity: 0;
  animation: dotPulse 2s ease-in-out infinite;
  transition: opacity 0.5s ease 0.7s;
}

.title-dot.revealed {
  opacity: 1;
}

@keyframes dotPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); color: #E8953A; }
}

.genesis-subtitle {
  font-family: 'Nunito Sans', sans-serif;
  font-weight: 400;
  font-size: clamp(1rem, 2.5vw, 1.4rem);
  color: #B8A99A;
  margin-bottom: 3rem;
  opacity: 0;
  transition: opacity 1.2s ease 1.5s;
}

.genesis-subtitle.revealed {
  opacity: 1;
}

.scroll-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  opacity: 0;
  transition: opacity 1s ease 2.2s;
}

.scroll-indicator.revealed {
  opacity: 1;
}

.scroll-bubble {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(255,107,43,0.3), #FF6B2B);
  animation: scrollBounce 2s ease-in-out infinite;
}

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

.scroll-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: #B8A99A;
  letter-spacing: 0.1em;
  text-transform: lowercase;
}

/* ===================== SECTION 2: FORK_JOIN ===================== */
.section-fork {
  background: linear-gradient(180deg, #FFF5E6 0%, #FFE4C4 50%, #FFF5E6 100%);
}

.fork-diagram {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  margin: 2rem 0;
}

.process-bubble {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.5s ease;
}

.process-bubble:hover {
  transform: scale(1.1);
}

.source-bubble {
  background: radial-gradient(circle at 35% 35%, #FFE4C4, #E8953A);
  box-shadow: 0 4px 20px rgba(232,149,58,0.4), inset -3px -3px 8px rgba(194,112,62,0.3), inset 2px 2px 6px rgba(255,245,230,0.5);
  width: 120px;
  height: 120px;
}

.join-bubble {
  background: radial-gradient(circle at 35% 35%, #FFE4C4, #2A8B7A);
  box-shadow: 0 4px 20px rgba(42,139,122,0.4), inset -3px -3px 8px rgba(42,100,90,0.3), inset 2px 2px 6px rgba(255,245,230,0.4);
  width: 120px;
  height: 120px;
}

.branch-bubble {
  background: radial-gradient(circle at 35% 35%, #FFE4C4, #C2703E);
  box-shadow: 0 4px 15px rgba(194,112,62,0.35), inset -3px -3px 6px rgba(150,80,40,0.25), inset 2px 2px 5px rgba(255,245,230,0.4);
  opacity: 0;
  transform: scale(0.5) translateY(-20px);
  transition: opacity 0.6s ease, transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.section-fork.visible .branch-bubble[data-branch='0'] {
  opacity: 1; transform: scale(1) translateY(0); transition-delay: 0.3s;
}
.section-fork.visible .branch-bubble[data-branch='1'] {
  opacity: 1; transform: scale(1) translateY(0); transition-delay: 0.5s;
}
.section-fork.visible .branch-bubble[data-branch='2'] {
  opacity: 1; transform: scale(1) translateY(0); transition-delay: 0.7s;
}

.process-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 700;
  color: #FFF5E6;
  text-shadow: 0 1px 3px rgba(61,43,31,0.3);
}

.fork-branches {
  display: flex;
  gap: 2rem;
  align-items: center;
  justify-content: center;
}

.branch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.branch-line {
  width: 3px;
  height: 40px;
  background: linear-gradient(180deg, #E8953A, #C2571A);
  border-radius: 2px;
  opacity: 0;
  transform: scaleY(0);
  transform-origin: top;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.section-fork.visible .branch-line {
  opacity: 0.6;
  transform: scaleY(1);
  transition-delay: 0.2s;
}

.fork-source, .fork-join-point {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.section-fork.visible .fork-source {
  opacity: 1; transform: translateY(0); transition-delay: 0.1s;
}

.section-fork.visible .fork-join-point {
  opacity: 1; transform: translateY(0); transition-delay: 0.9s;
}

/* ===================== SECTION 3: MUTEX_GARDEN ===================== */
.section-mutex {
  background: radial-gradient(ellipse at 50% 50%, #FFE4C4 0%, #FFF5E6 70%);
}

.mutex-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.5rem;
  margin: 2rem 0;
}

.resource-zone {
  position: relative;
}

.critical-section {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  border: 4px dashed #C2703E;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  position: relative;
  transition: border-color 0.5s ease, box-shadow 0.5s ease;
}

.critical-section.locked {
  border-color: #FF6B2B;
  box-shadow: 0 0 30px rgba(255,107,43,0.2);
}

.critical-section.unlocked {
  border-color: #2A8B7A;
  box-shadow: 0 0 30px rgba(42,139,122,0.2);
}

.critical-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: #B8A99A;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.lock-icon svg {
  transition: transform 0.5s ease;
}

.critical-section.unlocked .lock-shackle {
  transform: translateY(-4px) rotate(-20deg);
  transform-origin: right bottom;
  stroke: #2A8B7A;
  transition: all 0.5s ease;
}

.critical-section.unlocked .lock-body {
  fill: #2A8B7A;
  transition: fill 0.5s ease;
}

.mutex-threads {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.mutex-thread {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.thread-bubble {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 0.9rem;
  color: #FFF5E6;
  transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.thread-bubble.waiting {
  background: radial-gradient(circle at 35% 35%, #FFE4C4, #B8A99A);
  box-shadow: 0 3px 12px rgba(184,169,154,0.4);
  animation: threadBob 3s ease-in-out infinite;
}

.thread-bubble.active {
  background: radial-gradient(circle at 35% 35%, #FFE4C4, #FF6B2B);
  box-shadow: 0 4px 20px rgba(255,107,43,0.5);
  animation: none;
  transform: scale(1.15);
}

.thread-bubble.done {
  background: radial-gradient(circle at 35% 35%, #FFE4C4, #2A8B7A);
  box-shadow: 0 3px 15px rgba(42,139,122,0.4);
  animation: none;
}

@keyframes threadBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.thread-status {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  color: #B8A99A;
  letter-spacing: 0.05em;
}

.thread-status.status-active {
  color: #FF6B2B;
}

.thread-status.status-done {
  color: #2A8B7A;
}

/* ===================== SECTION 4: ASYNC_DREAMS ===================== */
.section-async {
  background: linear-gradient(180deg, #FFF5E6 0%, #FFE4C4 40%, #FFF5E6 100%);
}

.async-container {
  margin: 2rem 0;
}

.promise-chain {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.promise-node {
  display: flex;
  align-items: center;
  gap: 1rem;
  opacity: 0;
  transform: translateX(-30px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.section-async.visible .promise-node[data-promise='0'] { opacity: 1; transform: translateX(0); transition-delay: 0.2s; }
.section-async.visible .promise-node[data-promise='1'] { opacity: 1; transform: translateX(0); transition-delay: 0.5s; }
.section-async.visible .promise-node[data-promise='2'] { opacity: 1; transform: translateX(0); transition-delay: 0.8s; }
.section-async.visible .promise-node[data-promise='3'] { opacity: 1; transform: translateX(0); transition-delay: 1.1s; }

.promise-bubble {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.promise-node.pending .promise-bubble {
  background: radial-gradient(circle at 35% 35%, #FFE4C4, #B8A99A);
  box-shadow: 0 3px 12px rgba(184,169,154,0.3);
}

.promise-node.resolving .promise-bubble {
  background: radial-gradient(circle at 35% 35%, #FFE4C4, #E8953A);
  box-shadow: 0 4px 20px rgba(232,149,58,0.5);
  animation: promisePulse 1s ease-in-out infinite;
}

.promise-node.resolved .promise-bubble {
  background: radial-gradient(circle at 35% 35%, #FFE4C4, #2A8B7A);
  box-shadow: 0 4px 20px rgba(42,139,122,0.4);
}

@keyframes promisePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.promise-state {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  font-weight: 700;
  color: #FFF5E6;
  text-shadow: 0 1px 2px rgba(61,43,31,0.3);
  text-transform: uppercase;
}

.promise-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: #C2703E;
  letter-spacing: 0.02em;
}

.promise-connector {
  width: 3px;
  height: 24px;
  background: linear-gradient(180deg, #C2571A, #C2703E);
  border-radius: 2px;
  opacity: 0.4;
}

/* ===================== SECTION 5: RESOLUTION ===================== */
.section-resolution {
  background: radial-gradient(ellipse at 50% 50%, #FFE4C4 0%, #3D2B1F 100%);
}

.resolution-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3rem;
  margin: 2rem 0;
}

.convergence-ring {
  position: relative;
  width: 250px;
  height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ring {
  position: absolute;
  border-radius: 50%;
  border: 3px solid;
  opacity: 0;
  transition: opacity 1s ease, transform 1s ease;
}

.ring-outer {
  width: 250px;
  height: 250px;
  border-color: rgba(255,107,43,0.3);
  animation: ringRotate 20s linear infinite;
}

.ring-middle {
  width: 180px;
  height: 180px;
  border-color: rgba(232,149,58,0.4);
  animation: ringRotate 15s linear infinite reverse;
}

.ring-inner {
  width: 110px;
  height: 110px;
  border-color: rgba(42,139,122,0.5);
  animation: ringRotate 10s linear infinite;
}

.section-resolution.visible .ring {
  opacity: 1;
}

@keyframes ringRotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.ring-center {
  position: relative;
  z-index: 3;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, #FF6B2B, #C2703E);
  box-shadow: 0 0 30px rgba(255,107,43,0.5), 0 0 60px rgba(255,107,43,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 1.2s ease 0.5s, transform 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) 0.5s;
}

.section-resolution.visible .ring-center {
  opacity: 1;
  transform: scale(1);
}

.resolution-symbol {
  font-size: 2rem;
  color: #FFF5E6;
  font-weight: 700;
}

.resolution-message {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 1s ease 1s, transform 1s ease 1s;
}

.section-resolution.visible .resolution-message {
  opacity: 1;
  transform: translateY(0);
}

.resolution-text {
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: clamp(1rem, 2.5vw, 1.3rem);
  line-height: 1.7;
  color: #FFE4C4;
  max-width: 550px;
  text-align: center;
}

.section-resolution .section-title {
  color: #FF6B2B;
}

.crt-scanline {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(255,245,230,0.03) 50%,
    transparent 100%
  );
  background-size: 100% 4px;
  animation: scanlineMove 8s linear infinite;
  opacity: 0.5;
}

@keyframes scanlineMove {
  0% { background-position: 0 0; }
  100% { background-position: 0 100vh; }
}

/* Responsive */
@media (max-width: 768px) {
  .fork-branches {
    gap: 1rem;
  }
  .process-bubble {
    width: 70px;
    height: 70px;
  }
  .source-bubble, .join-bubble {
    width: 90px;
    height: 90px;
  }
  .critical-section {
    width: 150px;
    height: 150px;
  }
  .thread-bubble {
    width: 45px;
    height: 45px;
    font-size: 0.7rem;
  }
  .promise-bubble {
    width: 60px;
    height: 60px;
  }
  .convergence-ring {
    width: 180px;
    height: 180px;
  }
  .ring-outer { width: 180px; height: 180px; }
  .ring-middle { width: 130px; height: 130px; }
  .ring-inner { width: 80px; height: 80px; }
  .mutex-threads {
    gap: 1rem;
  }
}

@media (max-width: 480px) {
  .fork-branches {
    flex-direction: column;
    gap: 0.5rem;
  }
  .branch {
    flex-direction: row;
    gap: 0.5rem;
  }
  .branch-line {
    width: 30px;
    height: 3px;
  }
}
