/* Book-Inspired Custom Components */

/* 1. Breathline - Horizontal pulse that expands/contracts with reading */
.breathline {
  position: fixed;
  top: 60px;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, 
    transparent, 
    var(--accent) 20%, 
    var(--highlight) 50%, 
    var(--accent) 80%, 
    transparent);
  transform: scaleX(0.3);
  animation: breathe var(--timing-breath) var(--ease-breath) infinite;
  z-index: 100;
  opacity: 0.6;
}

@keyframes breathe {
  0%, 100% { 
    transform: scaleX(0.3);
    opacity: 0.6;
  }
  50% { 
    transform: scaleX(1);
    opacity: 1;
  }
}

/* 2. Thread of Fate - Vertical thread with interactive nodes */
.thread-of-fate {
  position: fixed;
  right: 2rem;
  top: 20%;
  height: 60%;
  width: 2px;
  z-index: 50;
}

.thread-line {
  position: absolute;
  width: 2px;
  height: 100%;
  background: linear-gradient(180deg, 
    transparent, 
    var(--samsara) 20%, 
    var(--memory) 50%, 
    var(--samsara) 80%, 
    transparent);
  opacity: 0.3;
}

.thread-nodes {
  position: relative;
  height: 100%;
}

.thread-node {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--base1);
  cursor: pointer;
  transform: translateX(-7px);
  transition: all var(--timing-standard) var(--ease-enter);
}

.thread-node:nth-child(1) { top: 20%; }
.thread-node:nth-child(2) { top: 50%; }
.thread-node:nth-child(3) { top: 80%; }

.thread-node:hover {
  transform: translateX(-7px) scale(1.5);
  background: var(--highlight);
  box-shadow: 0 0 20px var(--highlight);
}

.thread-node.active::after {
  content: attr(data-note-text);
  position: absolute;
  right: 30px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--base2);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-soft);
  white-space: nowrap;
  max-width: 300px;
  font-size: 0.9rem;
  box-shadow: 0 4px 12px var(--shadow);
}

/* 3. Motif Rain - Drifting symbols across hero */
.motif-rain {
  position: absolute;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}

.motif-rain::before,
.motif-rain::after {
  content: '⌬ ◗ ∞ ✻ ↻ ◊ ～ ⊡ ॐ';
  position: absolute;
  font-size: 2rem;
  color: var(--accent);
  opacity: 0.05;
  animation: drift 20s linear infinite;
}

.motif-rain::after {
  animation-delay: -10s;
  left: 50%;
}

/* 4. Quote Loom - Quotes weave in from sides */
.quote-loom {
  position: relative;
  min-height: 400px;
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  padding: var(--space-xl) 0;
}

.quote-thread {
  position: relative;
  padding: var(--space-lg);
  background: var(--base2);
  border-radius: var(--radius-round);
  opacity: 0;
  animation: weaveIn 1s var(--ease-enter) forwards;
  cursor: pointer;
  transition: all var(--timing-standard) var(--ease-enter);
}

.quote-thread:nth-child(even) {
  animation-name: weaveInLeft;
  margin-left: var(--space-xl);
}

.quote-thread:nth-child(odd) {
  animation-name: weaveInRight;
  margin-right: var(--space-xl);
}

@keyframes weaveInLeft {
  from {
    opacity: 0;
    transform: translateX(-100px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes weaveInRight {
  from {
    opacity: 0;
    transform: translateX(100px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.quote-thread:hover {
  transform: scale(1.02);
  box-shadow: 0 8px 24px var(--shadow);
}

.quote-text {
  font-size: 1.2rem;
  line-height: 1.6;
  font-style: italic;
  margin-bottom: var(--space-sm);
}

.quote-source {
  font-size: 0.9rem;
  opacity: 0.7;
}

/* 5. Lens Switcher - Apply interpretive lenses */
.lens-switcher {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  flex-wrap: wrap;
  margin: var(--space-lg) 0;
}

.lens-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-md);
  background: var(--base2);
  border: 2px solid transparent;
  border-radius: var(--radius-round);
  cursor: pointer;
  transition: all var(--timing-standard) var(--ease-enter);
}

.lens-btn:hover,
.lens-btn.active {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: 0 8px 16px var(--shadow);
}

.lens-icon {
  font-size: 2rem;
}

/* 6. Kinship Constellations - Star field of entities */
.kinship-constellation {
  position: relative;
  width: 100%;
  height: 500px;
  background: radial-gradient(ellipse at center, 
    transparent, 
    var(--base1) 70%);
  border-radius: var(--radius-round);
  overflow: hidden;
}

.constellation-star {
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--timing-standard) var(--ease-enter);
  animation: twinkle 3s ease-in-out infinite;
}

.constellation-star:hover {
  transform: scale(2);
  box-shadow: 0 0 20px var(--highlight);
}

@keyframes twinkle {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.constellation-connection {
  position: absolute;
  height: 1px;
  background: linear-gradient(90deg, 
    transparent, 
    var(--muted), 
    transparent);
  opacity: 0;
  transition: opacity var(--timing-standard) var(--ease-enter);
}

.constellation-star:hover ~ .constellation-connection {
  opacity: 0.3;
}

/* 7. Mood Thermocline - Chapter emotional temperature */
.mood-thermocline {
  width: 100%;
  height: 40px;
  background: var(--base2);
  border-radius: var(--radius-soft);
  position: relative;
  overflow: hidden;
  margin: var(--space-md) 0;
}

.thermocline-gradient {
  position: absolute;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg,
    var(--west) 0%,
    var(--memory) 25%,
    var(--samsara) 50%,
    var(--recursion) 75%,
    var(--east) 100%);
  opacity: 0.6;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 10'%3E%3Cpath d='M0,5 Q10,2 20,5 T40,5 T60,5 T80,5 T100,5' stroke='white' fill='none' stroke-width='3'/%3E%3C/svg%3E");
  mask-size: 100% 100%;
  mask-repeat: no-repeat;
}

/* 8. Glossary Fireflies - Glowing terms */
.glossary-term {
  position: relative;
  display: inline-block;
  border-bottom: 1px dotted var(--accent);
  cursor: help;
  animation: firefly-glow 4s ease-in-out infinite;
}

@keyframes firefly-glow {
  0%, 100% { 
    text-shadow: 0 0 2px var(--accent);
    border-bottom-color: var(--accent);
  }
  50% { 
    text-shadow: 0 0 8px var(--highlight);
    border-bottom-color: var(--highlight);
  }
}

.glossary-term:hover::after {
  content: attr(data-definition);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--base2);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-soft);
  white-space: nowrap;
  max-width: 300px;
  font-size: 0.9rem;
  box-shadow: 0 4px 12px var(--shadow);
  z-index: 100;
}

/* 9. Map of Echoes - Recurring phrases visualization */
.echo-map {
  position: relative;
  width: 100%;
  height: 300px;
  background: var(--base2);
  border-radius: var(--radius-round);
  overflow: hidden;
}

.echo-point {
  position: absolute;
  width: 20px;
  height: 20px;
  background: radial-gradient(circle, var(--accent), transparent);
  border-radius: 50%;
  cursor: pointer;
  animation: echo-pulse 2s ease-in-out infinite;
}

@keyframes echo-pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.6;
  }
  50% {
    transform: scale(1.5);
    opacity: 1;
  }
}

/* 10. Paradox Cards - Flipping two-sided cards */
.paradox-card {
  position: relative;
  height: 200px;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform var(--timing-slow) var(--ease-enter);
}

.paradox-card:hover,
.paradox-card:focus {
  transform: rotateY(180deg);
}

.card-front,
.card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  background: var(--base2);
  border-radius: var(--radius-round);
  text-align: center;
}

.card-back {
  transform: rotateY(180deg);
  background: linear-gradient(135deg, var(--base2), var(--accent));
  color: var(--base1);
}

/* 11. Pathways - Alternative reading orders */
.pathways-selector {
  margin: var(--space-lg) 0;
  text-align: center;
}

.pathway-select {
  padding: var(--space-sm) var(--space-md);
  background: var(--base2);
  border: 2px solid var(--accent);
  border-radius: var(--radius-soft);
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  cursor: pointer;
}

/* 12. Silhouette Theatre - Animated silhouettes */
.silhouette-theatre {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 150px;
  pointer-events: none;
  z-index: 10;
  opacity: 0.1;
}

.silhouette {
  position: absolute;
  bottom: 0;
  animation: silhouette-walk 20s linear infinite;
}

@keyframes silhouette-walk {
  from { transform: translateX(-100px); }
  to { transform: translateX(calc(100vw + 100px)); }
}

/* 13. Ouroboros Timeline - Circular timeline */
.ouroboros-timeline {
  position: relative;
  width: 400px;
  height: 400px;
  margin: var(--space-xl) auto;
}

.ouroboros-circle {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 2px solid var(--accent);
  border-radius: 50%;
  animation: rotate 60s linear infinite;
}

.ouroboros-segment {
  position: absolute;
  width: 50px;
  height: 50px;
  background: var(--base2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--timing-standard) var(--ease-enter);
}

.ouroboros-segment:hover {
  transform: scale(1.2);
  background: var(--accent);
  color: var(--base1);
}

/* 14. Whispered Footnotes - Faint annotations */
.whispered-footnote {
  opacity: 0.3;
  font-size: 0.85rem;
  font-style: italic;
  transition: opacity var(--timing-standard) var(--ease-enter);
  cursor: help;
}

.whispered-footnote:hover,
.whispered-footnote:focus {
  opacity: 1;
}

/* 15. Question Constellation */
.question-constellation {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
  padding: var(--space-lg);
}

.question-star {
  padding: var(--space-md);
  background: var(--base2);
  border-radius: var(--radius-round);
  text-align: center;
  cursor: pointer;
  transition: all var(--timing-standard) var(--ease-enter);
  position: relative;
}

.question-star:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 24px var(--shadow);
}

.question-star::before {
  content: '?';
  position: absolute;
  top: -10px;
  right: -10px;
  width: 30px;
  height: 30px;
  background: var(--accent);
  color: var(--base1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

/* 16. Dilemma Dial */
.dilemma-dial {
  position: relative;
  width: 300px;
  height: 300px;
  margin: var(--space-xl) auto;
}

.dial-face {
  width: 100%;
  height: 100%;
  border: 4px solid var(--accent);
  border-radius: 50%;
  position: relative;
  background: var(--base2);
}

.dial-pointer {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 40%;
  background: var(--samsara);
  transform-origin: center bottom;
  transform: translate(-50%, -100%) rotate(0deg);
  transition: transform var(--timing-slow) var(--ease-rotate);
  cursor: pointer;
}

.dial-pointer:hover {
  transform: translate(-50%, -100%) rotate(360deg);
}

/* 17. Character Pulse */
.character-pulse {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: var(--base2);
  border-radius: var(--radius-soft);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background: var(--samsara);
  border-radius: 50%;
  animation: pulse-beat 1s ease-in-out infinite;
}

@keyframes pulse-beat {
  0%, 100% {
    transform: scale(1);
    opacity: 0.6;
  }
  50% {
    transform: scale(1.5);
    opacity: 1;
  }
}

/* 18. Ritual Scroll */
.ritual-scroll {
  text-align: center;
  padding: var(--space-breath) var(--space-xl);
  background: linear-gradient(180deg, transparent, var(--base2), transparent);
  border-radius: var(--radius-round);
  margin: var(--space-xxl) 0;
}

.ritual-text {
  font-size: 1.5rem;
  font-style: italic;
  margin-bottom: var(--space-lg);
  opacity: 0;
  animation: fadeIn var(--timing-slow) var(--ease-enter) forwards;
}

.ritual-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  opacity: 0;
  animation: fadeIn var(--timing-slow) var(--ease-enter) 1s forwards;
}

/* Header and Navigation */
.site-header {
  position: sticky;
  top: 0;
  background: var(--base1);
  border-bottom: 1px solid var(--base2);
  z-index: 100;
  backdrop-filter: blur(10px);
}

.main-nav {
  padding: var(--space-md) 0;
}

.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 1.25rem;
  font-weight: bold;
  color: var(--text);
}

.nav-controls {
  display: flex;
  gap: var(--space-lg);
  align-items: center;
}

.mode-switcher {
  display: flex;
  gap: var(--space-xs);
  background: var(--base2);
  border-radius: var(--radius-soft);
  padding: var(--space-xs);
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: transparent;
  border: none;
  border-radius: var(--radius-subtle);
  cursor: pointer;
  transition: all var(--timing-swift) var(--ease-enter);
  color: var(--text);
  font-family: inherit;
}

.mode-btn.active {
  background: var(--accent);
  color: var(--base1);
}

.accessibility-controls {
  display: flex;
  gap: var(--space-sm);
}

.accessibility-controls button {
  padding: var(--space-xs) var(--space-sm);
  background: var(--base2);
  border: 1px solid var(--accent);
  border-radius: var(--radius-subtle);
  cursor: pointer;
  transition: all var(--timing-swift) var(--ease-enter);
  color: var(--text);
  font-family: inherit;
}

.accessibility-controls button:hover {
  background: var(--accent);
  color: var(--base1);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .thread-of-fate {
    display: none;
  }
  
  .mode-switcher {
    flex-wrap: wrap;
  }
  
  .mode-btn span:last-child {
    display: none;
  }
  
  .lens-switcher {
    flex-direction: column;
  }
  
  .ouroboros-timeline {
    width: 300px;
    height: 300px;
  }
  
  .dilemma-dial {
    width: 250px;
    height: 250px;
  }
}