/* Convergence Protocol - Layered Content System Styles */
/* Progressive revelation with cave-like aesthetic */

:root {
  /* Layer colors - deepening intensity */
  --surface-color: #c9b99a;
  --context-color: #b8a88a;
  --parallel-color: #a79779;
  --full-color: #968668;

  /* Accent colors */
  --glow-color: #d4af37;
  --mystery-color: #8b7355;
  --text-light: #f5f0e6;
  --text-dark: #3d3429;
  --shadow-deep: rgba(0, 0, 0, 0.4);

  /* Animation timings */
  --reveal-duration: 600ms;
  --hover-delay: 3000ms;
}

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

body {
  font-family: "Crimson Text", Georgia, serif;
  background: linear-gradient(135deg, #1a1612 0%, #2d2418 50%, #1a1612 100%);
  background-attachment: fixed;
  color: var(--text-light);
  min-height: 100vh;
  padding: 2rem;
}

/* ===== CONCEPT CARDS ===== */

.concepts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

.concept-card {
  position: relative;
  background: linear-gradient(145deg, #2a2420 0%, #1f1a16 100%);
  border-radius: 12px;
  overflow: hidden;
  box-shadow:
    0 4px 20px var(--shadow-deep),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transition:
    transform 0.3s ease,
    box-shadow 0.3s ease;
  cursor: pointer;
  min-height: 280px;
}

.concept-card:hover {
  transform: translateY(-4px);
  box-shadow:
    0 8px 30px var(--shadow-deep),
    0 0 20px rgba(212, 175, 55, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* ===== LAYERS ===== */

.layer {
  position: absolute;
  inset: 0;
  padding: 1.5rem;
  opacity: 0;
  transform: translateY(20px);
  transition: all var(--reveal-duration) cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.layer.surface {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.layer.revealed {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.layer.revealed ~ .layer.surface {
  opacity: 0.3;
  transform: scale(0.9);
}

/* Surface Layer */
.surface h2 {
  font-size: 1.8rem;
  color: var(--surface-color);
  margin-bottom: 1rem;
  text-shadow: 0 2px 4px var(--shadow-deep);
}

.surface .symbol {
  font-size: 4rem;
  opacity: 0.6;
  filter: drop-shadow(0 0 10px rgba(212, 175, 55, 0.3));
}

/* Context Layer */
.layer.context {
  background: linear-gradient(180deg, rgba(40, 35, 30, 0.95) 0%, rgba(30, 25, 20, 0.98) 100%);
}

.context .cultural-origin {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.origin-badge {
  display: inline-block;
  background: var(--mystery-color);
  color: var(--text-light);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 1rem;
  width: fit-content;
}

.context p {
  color: var(--context-color);
  line-height: 1.6;
  font-size: 0.95rem;
}

/* Parallel Layer */
.layer.parallel {
  background: linear-gradient(180deg, rgba(45, 40, 35, 0.95) 0%, rgba(35, 30, 25, 0.98) 100%);
}

.parallel-indicator {
  display: block;
  color: var(--glow-color);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 1rem;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
}

.preview-text {
  color: var(--parallel-color);
  font-style: italic;
  line-height: 1.6;
}

/* Full Layer */
.layer.full {
  background: linear-gradient(180deg, rgba(50, 45, 40, 0.95) 0%, rgba(40, 35, 30, 0.98) 100%);
}

.full-explanation h3 {
  color: var(--glow-color);
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

.full-explanation p {
  color: var(--full-color);
  line-height: 1.7;
}

.mastery-badge {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  background: linear-gradient(135deg, var(--glow-color), #b8941f);
  color: var(--text-dark);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: bold;
  animation: badgeGlow 2s ease-in-out infinite;
}

@keyframes badgeGlow {
  0%,
  100% {
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
  }
  50% {
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.8);
  }
}

/* ===== INTERACTION LAYER ===== */

.interaction-layer {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  gap: 0.5rem;
  z-index: 10;
}

.hint-trigger,
.annotation-trigger {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(201, 185, 154, 0.3);
  background: rgba(0, 0, 0, 0.3);
  color: var(--surface-color);
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.9rem;
}

.hint-trigger:hover,
.annotation-trigger:hover {
  background: rgba(212, 175, 55, 0.2);
  border-color: var(--glow-color);
  transform: scale(1.1);
}

.progress-indicator {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-left: 0.5rem;
}

.layer-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(201, 185, 154, 0.2);
  transition: all 0.3s ease;
}

.layer-dot.unlocked {
  background: var(--glow-color);
  box-shadow: 0 0 6px var(--glow-color);
}

/* ===== ANNOTATIONS LAYER ===== */

.annotations-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.cave-mark {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--glow-color);
  border-radius: 50%;
  opacity: 0.6;
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.3s ease;
  box-shadow: 0 0 10px var(--glow-color);
}

.cave-mark:hover {
  opacity: 1;
  transform: scale(1.5);
}

/* ===== HINT REVEAL ===== */

.hint-reveal {
  position: absolute;
  top: 3rem;
  right: 0;
  background: rgba(20, 18, 15, 0.95);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 8px;
  padding: 1rem;
  min-width: 200px;
  z-index: 100;
  animation: hintAppear 0.3s ease;
}

@keyframes hintAppear {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hint-content .hint-number {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--mystery-color);
  margin-bottom: 0.5rem;
}

.hint-content p {
  font-size: 0.9rem;
  color: var(--context-color);
  line-height: 1.5;
}

.hint-content.level-1 {
  border-left: 2px solid #666;
}
.hint-content.level-2 {
  border-left: 2px solid #888;
}
.hint-content.level-3 {
  border-left: 2px solid #aaa;
}
.hint-content.level-4 {
  border-left: 2px solid var(--glow-color);
}

/* ===== COMPARISON MODAL ===== */

.comparison-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: modalFadeIn 0.3s ease;
}

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

.comparison-content {
  background: linear-gradient(145deg, #2a2420 0%, #1f1a16 100%);
  border-radius: 16px;
  padding: 2rem;
  max-width: 900px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.close-comparison {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--surface-color);
  font-size: 1.5rem;
  cursor: pointer;
  transition: color 0.3s ease;
}

.close-comparison:hover {
  color: var(--glow-color);
}

.comparison-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1.5rem;
  margin: 1.5rem 0;
}

.culture-column {
  padding: 1.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
}

.culture-column h3 {
  color: var(--glow-color);
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.culture-column.english {
  border-left: 3px solid #4a90d9;
}
.culture-column.chinese {
  border-left: 3px solid #d94a4a;
}

.parallel-text {
  color: var(--text-light);
  line-height: 1.7;
  margin-bottom: 1rem;
}

.cultural-context {
  font-size: 0.85rem;
  color: var(--mystery-color);
  font-style: italic;
}

.connection-lines {
  display: flex;
  align-items: center;
  justify-content: center;
}

.parallel-connections {
  width: 60px;
  height: 200px;
}

.connection-line {
  fill: none;
  stroke: var(--glow-color);
  stroke-width: 2;
  opacity: 0.6;
  stroke-dasharray: 5, 5;
  animation: dashFlow 20s linear infinite;
}

@keyframes dashFlow {
  to {
    stroke-dashoffset: -100;
  }
}

.connection-label {
  fill: var(--surface-color);
  font-size: 8px;
  text-anchor: middle;
}

.synthesis-box {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.1), rgba(212, 175, 55, 0.05));
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 8px;
  padding: 1.5rem;
  margin-top: 1rem;
}

.synthesis-box h4 {
  color: var(--glow-color);
  margin-bottom: 0.5rem;
}

.synthesis-box p {
  color: var(--parallel-color);
  line-height: 1.6;
}

/* ===== ANNOTATION PANEL ===== */

.annotation-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 350px;
  background: linear-gradient(180deg, #2a2420 0%, #1f1a16 100%);
  box-shadow: -5px 0 30px rgba(0, 0, 0, 0.5);
  z-index: 1000;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

.annotation-content {
  padding: 1.5rem;
  height: 100%;
  overflow-y: auto;
}

.annotation-content h3 {
  color: var(--glow-color);
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(212, 175, 55, 0.2);
}

.existing-annotations {
  margin-bottom: 1.5rem;
}

.annotation {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.annotation p {
  color: var(--text-light);
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

.annotation-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
}

.annotation-meta .author {
  color: var(--mystery-color);
}

.upvote {
  background: none;
  border: 1px solid rgba(201, 185, 154, 0.3);
  color: var(--surface-color);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.upvote:hover {
  background: rgba(212, 175, 55, 0.2);
  border-color: var(--glow-color);
}

.annotation-input textarea {
  width: 100%;
  min-height: 100px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(201, 185, 154, 0.2);
  border-radius: 8px;
  padding: 0.75rem;
  color: var(--text-light);
  font-family: inherit;
  resize: vertical;
  margin-bottom: 0.75rem;
}

.annotation-input textarea:focus {
  outline: none;
  border-color: var(--glow-color);
}

.submit-annotation {
  width: 100%;
  background: linear-gradient(135deg, var(--glow-color), #b8941f);
  color: var(--text-dark);
  border: none;
  padding: 0.75rem;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
  transition:
    transform 0.3s ease,
    box-shadow 0.3s ease;
}

.submit-annotation:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(212, 175, 55, 0.4);
}

.no-annotations {
  color: var(--mystery-color);
  font-style: italic;
  text-align: center;
  padding: 2rem;
}

/* ===== MASTERY CELEBRATION ===== */

.mastery-achieved {
  animation: masteryPulse 1s ease;
}

@keyframes masteryPulse {
  0%,
  100% {
    box-shadow: 0 0 0 rgba(212, 175, 55, 0);
  }
  50% {
    box-shadow: 0 0 30px rgba(212, 175, 55, 0.5);
  }
}

.mastery-particle {
  position: absolute;
  width: 6px;
  height: 6px;
  background: var(--glow-color);
  border-radius: 50%;
  pointer-events: none;
  animation: particleBurst 1s ease forwards;
}

@keyframes particleBurst {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(
        calc(cos(var(--angle)) * var(--distance)),
        calc(sin(var(--angle)) * var(--distance))
      )
      scale(0);
    opacity: 0;
  }
}

.reveal-ripple {
  position: absolute;
  inset: 0;
  border: 2px solid var(--glow-color);
  border-radius: 12px;
  opacity: 0;
  pointer-events: none;
  animation: rippleOut 1s ease forwards;
}

@keyframes rippleOut {
  0% {
    transform: scale(0.9);
    opacity: 0.5;
  }
  100% {
    transform: scale(1.1);
    opacity: 0;
  }
}

/* ===== RESPONSIVE ===== */

@media (max-width: 768px) {
  .concepts-grid {
    grid-template-columns: 1fr;
  }

  .comparison-grid {
    grid-template-columns: 1fr;
  }

  .connection-lines {
    display: none;
  }

  .annotation-panel {
    width: 100%;
  }
}

/* ===== UTILITY ===== */

.synthesis-unlocked .synthesis-box {
  display: block;
  animation: synthesisGlow 2s ease-in-out infinite;
}

@keyframes synthesisGlow {
  0%,
  100% {
    border-color: rgba(212, 175, 55, 0.3);
  }
  50% {
    border-color: rgba(212, 175, 55, 0.6);
  }
}
