@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Playfair+Display:wght@400;500;600&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-bg: #0b0c10;
  --secondary-bg: #1f2937;
  --text-primary: #e5e5e5;
  --text-secondary: #9ca3af;
  --accent-color: #6366f1;
  --accent-secondary: #8b5cf6;
  --gradient-start: #1e1b4b;
  --gradient-end: #0f172a;
  --shadow-color: rgba(0, 0, 0, 0.3);
  --border-color: rgba(255, 255, 255, 0.1);
}

/* Light theme variables */
body.light-theme {
  --primary-bg: #f8fafc;
  --secondary-bg: #ffffff;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --accent-color: #3b82f6;
  --accent-secondary: #8b5cf6;
  --gradient-start: #e0e7ff;
  --gradient-end: #f1f5f9;
  --shadow-color: rgba(0, 0, 0, 0.1);
  --border-color: rgba(0, 0, 0, 0.1);
}

body {
  background: var(--primary-bg);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  line-height: 1.6;
  height: 100vh;
  overflow: hidden;
  transition: all 0.3s ease;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Animated background particles */
.particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--accent-color);
  border-radius: 50%;
  opacity: 0.3;
  animation: floatParticle 8s infinite linear;
}

.particle:nth-child(2n) {
  background: var(--accent-secondary);
  animation-duration: 12s;
  animation-delay: -2s;
}

.particle:nth-child(3n) {
  width: 2px;
  height: 2px;
  animation-duration: 15s;
  animation-delay: -4s;
}

@keyframes floatParticle {
  0% {
    transform: translateY(100vh) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 0.3;
  }
  90% {
    opacity: 0.3;
  }
  100% {
    transform: translateY(-100px) rotate(360deg);
    opacity: 0;
  }
}

/* Gradient overlay */
.gradient-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    135deg,
    var(--gradient-start) 0%,
    transparent 50%,
    var(--gradient-end) 100%
  );
  pointer-events: none;
  z-index: 2;
  opacity: 0.7;
}

.container {
  max-width: 800px;
  width: 100%;
  padding: 2rem;
  position: relative;
  z-index: 10;
  text-align: center;
}

/* Header styles */
.poem-header {
  text-align: center;
  margin-bottom: 2rem;
  padding: 1rem 0;
}

.subtitle-wrapper {
  position: relative;
  display: inline-block;
}

.subtitle {
  font-size: 1.1rem;
  font-weight: 300;
  color: var(--text-secondary);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  animation: subtitleFade 2s ease-in-out 0.5s both;
}

.underline {
  position: absolute;
  bottom: -8px;
  left: 50%;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-color), var(--accent-secondary));
  transform: translateX(-50%);
  animation: underlineExpand 1.5s ease-out 1s both;
}

@keyframes subtitleFade {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes underlineExpand {
  to {
    width: 100%;
  }
}

/* Progress indicator */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--border-color);
  z-index: 1000;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-color), var(--accent-secondary));
  transition: width 0.3s ease;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

@keyframes progressFill {
  0% { width: 0%; }
  100% { width: 100%; }
}

/* Main content */
.poem-content {
  position: relative;
  height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.poem {
  width: 100%;
  max-width: 600px;
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stanza {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: calc(100% - 0.5rem);
  max-width: 1000px;
  padding: 3rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  backdrop-filter: blur(10px);
  opacity: 0;
  cursor: pointer;
  transition: opacity 0.8s ease-in-out;
  overflow: hidden;
  box-shadow: 0 8px 25px var(--shadow-color);
}

.stanza::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(139, 92, 246, 0.05));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.stanza:hover::before {
  opacity: 1;
}

.stanza:hover {
  transform: translate(-50%, -50%) scale(1.02);
  box-shadow: 0 15px 40px var(--shadow-color);
  border-color: var(--accent-color);
}

.stanza.highlighted {
  border-color: var(--accent-color);
  box-shadow: 0 0 25px rgba(99, 102, 241, 0.4);
}

.stanza p {
  font-size: clamp(1.2rem, 3vw, 1.6rem);
  line-height: 1.9;
  color: var(--text-primary);
  font-weight: 400;
  letter-spacing: 0.02em;
  margin: 0;
  position: relative;
  text-align: center;
}

/* Interactive controls */
.controls {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 1rem;
  z-index: 1000;
}

.control-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.8rem 1.2rem;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  position: relative;
  overflow: hidden;
}

.control-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transition: left 0.5s ease;
}

.control-btn:hover::before {
  left: 100%;
}

.control-btn:hover {
  background: var(--accent-color);
  border-color: var(--accent-color);
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(99, 102, 241, 0.3);
}

.control-btn:active {
  transform: translateY(0);
}

.play-icon,
.pause-icon {
  transition: opacity 0.3s ease;
}

.control-btn.paused .play-icon {
  opacity: 0;
}

.control-btn.paused .pause-icon {
  opacity: 1;
}

.control-btn:not(.paused) .play-icon {
  opacity: 1;
}

.control-btn:not(.paused) .pause-icon {
  opacity: 0;
}

/* Footer */
.poem-footer {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  padding: 1rem;
  z-index: 1000;
}

.author-note {
  font-style: italic;
  color: var(--text-secondary);
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  opacity: 0.7;
}

/* Sparkle effects */
.sparkle {
  position: fixed;
  width: 6px;
  height: 6px;
  background: var(--accent-color);
  border-radius: 50%;
  pointer-events: none;
  z-index: 5;
  animation: sparkleFloat 3s ease-out forwards;
}

@keyframes sparkleFloat {
  0% {
    opacity: 0;
    transform: scale(0) rotate(0deg);
  }
  50% {
    opacity: 1;
    transform: scale(1) rotate(180deg);
  }
  100% {
    opacity: 0;
    transform: scale(0) rotate(360deg);
  }
}

/* Responsive design */
@media (max-width: 768px) {
  .container {
    padding: 1rem;
  }
  
  .poem-content {
    height: 50vh;
  }
  
  .stanza {
    width: calc(100% - 2rem);
    padding: 2rem;
  }
  
  .stanza p {
    font-size: clamp(1rem, 4vw, 1.3rem);
  }
  
  .controls {
    bottom: 4rem;
    gap: 0.8rem;
  }
  
  .control-btn {
    padding: 0.7rem 1rem;
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0.8rem;
  }
  
  .poem-content {
    height: 45vh;
  }
  
  .stanza {
    width: calc(100% - 1rem);
    padding: 1.5rem;
  }
  
  .stanza p {
    font-size: clamp(0.9rem, 4.5vw, 1.2rem);
    line-height: 1.7;
  }
  
  .controls {
    bottom: 3rem;
  }
}

/* Print styles */
@media print {
  body {
    background: white;
    color: black;
  }
  
  .particles,
  .gradient-overlay,
  .controls,
  .reading-progress {
    display: none;
  }
  
  .stanza {
    background: none;
    border: 1px solid #ccc;
    break-inside: avoid;
  }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .particles {
    display: none;
  }
}

/* Focus styles for accessibility */
.control-btn:focus {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border-color: rgba(255, 255, 255, 0.3);
  }
  
  .stanza {
    border-width: 2px;
  }
}
