@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,600;0,700;1,400&family=Source+Serif+4:wght@400;500;600&family=Inter:wght@400;500;600&display=swap');

:root {
  --aero-sky: #EEF4F9;
  --meadow-mist: #E3EDE6;
  --frosted-pane: #F8FBFD;
  --deep-carbon: #1A2332;
  --slate-annotation: #5A6A78;
  --canopy-teal: #1A8A6E;
  --market-amber: #C4872A;
  --archive-violet: #6B5CA5;
  --aero-shine: #FFFFFF;
  --night-canopy: #0F2218;

  --font-display: 'Playfair Display', serif;
  --font-body: 'Source Serif 4', serif;
  --font-utility: 'Inter', sans-serif;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  color: var(--deep-carbon);
  background: var(--aero-sky);
  overflow-x: hidden;
}

/* Header */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: rgba(245, 250, 255, 0.72);
  backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid rgba(255, 255, 255, 0.5);
  border-top: 1px solid rgba(255, 255, 255, 0.8);
  z-index: 1000;
  display: flex;
  align-items: center;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 0 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

.wordmark {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--deep-carbon);
  letter-spacing: -0.01em;
}

.chapter-nav {
  display: flex;
  gap: 2rem;
  background: none;
  border: none;
}

.chapter-link {
  background: none;
  border: none;
  font-family: var(--font-utility);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--slate-annotation);
  cursor: pointer;
  padding: 0;
  position: relative;
  letter-spacing: 0.01em;
  transition: color 0.3s ease;
}

.chapter-link::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--canopy-teal);
  transition: width 0.3s ease;
}

.chapter-link.active {
  color: var(--canopy-teal);
}

.chapter-link.active::after {
  width: 100%;
}

/* Split Screen */
.split-screen {
  display: flex;
  margin-top: 56px;
  position: relative;
}

.environment-panel {
  flex: 0 0 45%;
  min-height: 100vh;
  position: relative;
  background: var(--meadow-mist);
  overflow: hidden;
}

.knowledge-panel {
  flex: 0 0 55%;
  background: var(--aero-sky);
  padding: 3rem 2rem;
  position: relative;
  z-index: 2;
}

.panel-divider {
  position: absolute;
  left: 45%;
  top: 56px;
  width: 3px;
  height: calc(100vh - 56px);
  background: linear-gradient(180deg, var(--canopy-teal) 0%, rgba(26, 138, 110, 0.1) 100%);
  opacity: 0.6;
  animation: breathe 4s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 0.75; }
}

/* Chapter Images */
.chapter-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 0.8s ease;
  filter: saturate(1.15) brightness(1.05) contrast(0.95);
}

.chapter-image::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(238,244,249,0.15), rgba(26,138,110,0.08));
  pointer-events: none;
}

.chapter-01 {
  opacity: 1;
  background: linear-gradient(135deg, #2D5016 0%, #5A8A3A 100%);
}

.chapter-02 {
  background: linear-gradient(135deg, #8B7355 0%, #D4A574 100%);
}

.chapter-03 {
  background: linear-gradient(135deg, #1A6B5A 0%, #4DA89F 100%);
}

.chapter-04 {
  background: linear-gradient(135deg, #3D5A3D 0%, #7A9B7A 100%);
}

.chapter-05 {
  background: linear-gradient(135deg, #E8A844 0%, #F5C97B 100%);
}

/* Aero Bubbles */
.aero-bubbles {
  position: absolute;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.bubble {
  position: absolute;
  border-radius: 50%;
  mix-blend-mode: screen;
  animation: bubbleFloat linear infinite;
}

@keyframes bubbleFloat {
  0% {
    transform: translateY(0);
    opacity: 0.6;
  }
  100% {
    transform: translateY(-100vh);
    opacity: 0.3;
  }
}

/* Chapters */
.chapter {
  margin-bottom: 4rem;
  animation: chapterFadeIn 0.7s ease-out;
}

.chapter-title {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3.5vw, 2.8rem);
  font-weight: 600;
  color: var(--deep-carbon);
  margin-bottom: 1.5rem;
  line-height: 1.15;
  animation: titleElastic 0.7s cubic-bezier(0.68, -0.15, 0.27, 1.15);
  transform-origin: left;
}

@keyframes titleElastic {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.chapter p {
  font-size: clamp(1rem, 1.15vw, 1.1rem);
  line-height: 1.7;
  color: var(--deep-carbon);
  margin-bottom: 1.3em;
  font-weight: 400;
  letter-spacing: 0.01em;
  animation: paragraphFadeIn 0.5s ease-out;
}

@keyframes paragraphFadeIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chapter p:nth-child(n+2) {
  animation-delay: 0.2s;
}

.chapter p:nth-child(n+3) {
  animation-delay: 0.4s;
}

/* Floating Panels */
.floating-panel {
  background: rgba(248, 251, 253, 0.65);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  padding: 1.5rem;
  margin: 2rem 0;
  box-shadow: 0 4px 24px rgba(0, 40, 80, 0.08), 0 1px 3px rgba(0, 40, 80, 0.04);
  position: relative;
  animation: panelElastic 0.6s cubic-bezier(0.68, -0.15, 0.27, 1.15);
}

.floating-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(to right, rgba(255,255,255,0.9), rgba(255,255,255,0.3));
  border-radius: 8px 8px 0 0;
}

.floating-panel::after {
  content: '';
  position: absolute;
  bottom: -20px;
  left: 0;
  right: 0;
  height: 20px;
  background: linear-gradient(to bottom, rgba(238,244,249,0.3), transparent);
  filter: blur(1px);
  animation: reflectionFadeIn 0.3s ease-in 0.3s both;
}

@keyframes panelElastic {
  0% {
    opacity: 0;
    transform: translateY(18px) scale(0.9);
  }
  40% {
    opacity: 1;
    transform: translateY(-2px) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes reflectionFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.floating-panel h3 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--canopy-teal);
  margin-bottom: 0.8rem;
}

.floating-panel p {
  font-size: 0.95rem;
  margin: 0;
  color: var(--slate-annotation);
}

.citation-panel h3 {
  color: var(--archive-violet);
}

.citation-text::before {
  content: '¶ ';
  color: var(--archive-violet);
  opacity: 0.4;
}

/* Ecosystem Diagram */
.ecosystem-diagram {
  margin: 2rem 0;
  width: 100%;
  max-width: 100%;
  display: flex;
  justify-content: center;
}

.diagram-svg {
  width: 100%;
  max-width: 400px;
  height: auto;
}

.node {
  fill: rgba(248, 251, 253, 0.8);
  stroke: var(--canopy-teal);
  stroke-width: 2;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.1));
  animation: nodeAppear 0.5s cubic-bezier(0.68, -0.15, 0.27, 1.15);
}

.central-node {
  animation-delay: 0s;
}

.satellite-node {
  animation-delay: 0.2s;
}

@keyframes nodeAppear {
  from {
    r: 0;
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.node-label {
  font-family: var(--font-utility);
  font-size: 0.75rem;
  font-weight: 500;
  fill: var(--deep-carbon);
  pointer-events: none;
}

.connection {
  stroke: var(--canopy-teal);
  stroke-width: 2;
  fill: none;
  stroke-dasharray: 200;
  stroke-dashoffset: 200;
  opacity: 0.6;
  animation: drawConnection 0.8s ease-out forwards;
}

@keyframes drawConnection {
  to {
    stroke-dashoffset: 0;
    opacity: 1;
  }
}

/* Endmark */
.endmark {
  text-align: center;
  font-size: 1.5rem;
  color: var(--slate-annotation);
  opacity: 0.5;
  margin-top: 2rem;
}

/* Responsive */
@media (max-width: 1199px) {
  .environment-panel {
    flex: 0 0 40%;
  }

  .knowledge-panel {
    flex: 0 0 60%;
  }

  .panel-divider {
    left: 40%;
  }
}

@media (max-width: 768px) {
  .split-screen {
    flex-direction: column;
  }

  .environment-panel {
    flex: 0 0 50vh;
    width: 100%;
  }

  .knowledge-panel {
    flex: 1;
    width: 100%;
  }

  .panel-divider {
    display: none;
  }

  .chapter-nav {
    gap: 1rem;
    font-size: 0.75rem;
  }

  .header-content {
    padding: 0 1rem;
    flex-direction: column;
    gap: 0.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
