@import './theme.css';

/* ================================
   STORYTELLING PAGE WRAPPER
   NOTE: All styles in this file are scoped to .storytelling-wrapper
   to prevent conflicts with other pages like LandingPage
================================ */

/* Wrapper - only affects elements with this class */
.storytelling-wrapper {
  min-height: 100vh;
  background: linear-gradient(135deg, #4F8EF7 0%, #5BA3FF 50%, #74B4FF 100%);
  padding: 24px;
  font-family: var(--body-font);
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Main content container for consistent alignment - only direct children that are sections */
.storytelling-wrapper>.current-level-session,
.storytelling-wrapper>.lesson-header,
.storytelling-wrapper>.lesson-grid {
  max-width: 800px;
  width: 100%;
  box-sizing: border-box;
}

/* HEADER */
.storytelling-wrapper .lesson-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.95);
  padding: 20px 24px;
  border-radius: 20px;
  margin-bottom: 20px;
  box-shadow: 0 8px 24px rgba(79, 142, 247, 0.2);
  width: 100%;
  max-width: 800px;
  box-sizing: border-box;
  border: 2px solid rgba(255, 255, 255, 0.8);
}

.storytelling-wrapper .lesson-header h4 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  color: #2563eb;
}

.storytelling-wrapper .lesson-header a {
  color: #4F8EF7;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  font-weight: 600;
}

.storytelling-wrapper .lesson-header a:hover {
  color: #2563eb;
  transform: scale(1.05);
}

.storytelling-wrapper .lesson-header small {
  font-size: 12px;
  color: #5BA3FF;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
}

.storytelling-wrapper .lesson-header span {
  font-size: 13px;
  color: #2563eb;
  font-weight: 600;
  background: linear-gradient(135deg, #E3F2FD, #BBDEFB);
  padding: 8px 16px;
  border-radius: 12px;
  border: 2px solid rgba(79, 142, 247, 0.3);
}

/* CURRENT LEVEL SESSION */
.storytelling-wrapper .current-level-session {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 20px;
  padding: 24px 28px;
  margin-bottom: 20px;
  box-shadow: 0 8px 24px rgba(79, 142, 247, 0.2);
  width: 100%;
  max-width: 800px;
  display: flex;
  gap: 32px;
  align-items: center;
  box-sizing: border-box;
  border: 2px solid rgba(255, 255, 255, 0.8);
}

.storytelling-wrapper .current-level-session h4 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  color: #2563eb;
}

.storytelling-wrapper .current-level-session h5 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  color: #4F8EF7;
}

/* GRID */
.storytelling-wrapper .lesson-grid {
  display: flex;
  justify-content: center;
  align-items: start;
  gap: 0;
  max-width: 800px;
  width: 100%;
  margin: 0;
  box-sizing: border-box;
}

/* LEFT PANEL */
.storytelling-wrapper .left-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* RIGHT PANEL */
.storytelling-wrapper .right-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 800px;
  width: 100%;
}

.storytelling-wrapper .right-panel.full-width {
  max-width: 800px;
  width: 100%;
  margin: 0;
  box-sizing: border-box;
}

/* CARD */
.storytelling-wrapper .card {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 8px 24px rgba(79, 142, 247, 0.2);
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  transition: all 0.3s ease;
  box-sizing: border-box;
  border: 2px solid rgba(255, 255, 255, 0.8);
}

.storytelling-wrapper .card:hover {
  box-shadow: 0 12px 32px rgba(79, 142, 247, 0.3);
  transform: translateY(-2px);
}

.storytelling-wrapper .card h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 8px 0;
  color: #2563eb;
}

.storytelling-wrapper .card p {
  font-size: 15px;
  line-height: 1.7;
  color: #1e3a8a;
  margin: 0;
}

/* VIDEO CARD */
.storytelling-wrapper .video-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.storytelling-wrapper .video-media {
  position: relative;
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  background: #1e3a8a;
  box-shadow: 0 8px 24px rgba(79, 142, 247, 0.3);
}

.storytelling-wrapper .video-media--placeholder {
  height: 0;
  padding-bottom: 56.25%;
  /* 16:9 placeholder area for spinner while session loads */
}

.storytelling-wrapper .video-media__player {
  display: block;
  width: 100%;
  height: auto;
}

.storytelling-wrapper .video-loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 58, 138, 0.4);
  pointer-events: none;
}

.storytelling-wrapper .video-loading-container {
  position: relative;
  width: 100%;
  height: 300px;
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(79, 142, 247, 0.3);
}

.storytelling-wrapper .video-loading-spinner {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 5px solid rgba(255, 255, 255, 0.4);
  border-top-color: #FFD700;
  animation: videoSpin 0.9s linear infinite;
  filter: drop-shadow(0 6px 18px rgba(255, 215, 0, 0.4));
}

@keyframes videoSpin {
  to {
    transform: rotate(360deg);
  }
}

.storytelling-wrapper .video-card video {
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 16px;
  background: #1e3a8a;
  box-shadow: 0 8px 24px rgba(79, 142, 247, 0.3);
}

.storytelling-wrapper .video-placeholder {
  height: 200px;
  background: linear-gradient(135deg, #E3F2FD, #BBDEFB, #90CAF9);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  font-size: 14px;
  color: #1e3a8a;
  text-align: center;
  padding: 24px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(79, 142, 247, 0.2);
}

.storytelling-wrapper .video-placeholder p {
  text-align: center;
  margin: 0;
  color: #2563eb;
  font-weight: 600;
}

.storytelling-wrapper .audio-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #2563eb;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
}

.storytelling-wrapper .audio-btn:hover {
  color: #1e40af;
  transform: scale(1.05);
}

/* QUIZ */
.storytelling-wrapper .quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 3px solid #BBDEFB;
}

.storytelling-wrapper .quiz-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: #2563eb;
  margin: 0;
}

.storytelling-wrapper .score-badge {
  background: linear-gradient(135deg, #FFD700, #FFA500);
  color: white;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 24px;
  box-shadow: 0 4px 16px rgba(255, 165, 0, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.5);
}

/* OPTIONS */
.storytelling-wrapper .option-btn {
  width: 100%;
  background: linear-gradient(135deg, #E3F2FD, #BBDEFB);
  border: 3px solid #90CAF9;
  border-radius: 16px;
  padding: 16px 20px;
  margin: 10px 0;
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.3s ease;
  color: #1e3a8a;
  box-shadow: 0 4px 12px rgba(79, 142, 247, 0.15);
}

.storytelling-wrapper .option-btn:hover {
  border-color: #4F8EF7;
  background: linear-gradient(135deg, #BBDEFB, #90CAF9);
  transform: translateX(8px) scale(1.02);
  box-shadow: 0 6px 20px rgba(79, 142, 247, 0.3);
}

.storytelling-wrapper .option-btn.selected {
  background: linear-gradient(135deg, #4F8EF7, #2563eb);
  border-color: #1e40af;
  color: white;
  font-weight: 700;
  box-shadow: 0 6px 24px rgba(79, 142, 247, 0.5);
  transform: scale(1.03);
}

/* FEEDBACK */
.storytelling-wrapper .feedback {
  margin-top: 16px;
  padding: 16px 20px;
  border-radius: 16px;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.storytelling-wrapper .feedback.correct {
  background: linear-gradient(135deg, #C8E6C9, #A5D6A7);
  border: 3px solid #66BB6A;
  color: #1B5E20;
}

.storytelling-wrapper .feedback.wrong {
  background: linear-gradient(135deg, #FFCDD2, #EF9A9A);
  border: 3px solid #EF5350;
  color: #B71C1C;
}

/* BUTTONS */
.storytelling-wrapper .btn-primary {
  width: 100%;
  background: linear-gradient(135deg, #4F8EF7, #2563eb);
  border: none;
  padding: 16px 28px;
  font-size: 16px;
  font-weight: 700;
  color: white;
  border-radius: 16px;
  margin-top: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 6px 20px rgba(79, 142, 247, 0.4);
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
  font-family: inherit;
  line-height: 1.5;
  text-decoration: none;
  display: block;
  text-align: center;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.storytelling-wrapper .btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 0.5s;
}

.storytelling-wrapper .btn-primary:hover::before {
  left: 100%;
}

.storytelling-wrapper .btn-primary:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 10px 30px rgba(79, 142, 247, 0.5);
  background: linear-gradient(135deg, #2563eb, #1e40af);
}

.storytelling-wrapper .btn-primary:active {
  transform: translateY(-1px) scale(1.01);
}

.storytelling-wrapper .btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Result card specific button styles */
.storytelling-wrapper .result-card .btn-primary {
  margin-top: 0;
  padding: 18px 28px;
  font-size: 17px;
  width: 100%;
  text-align: center;
  display: block;
  box-sizing: border-box;
  text-decoration: none;
  font-family: inherit;
  line-height: 1.5;
  margin-left: 0;
  margin-right: 0;
}

.storytelling-wrapper .result-card .btn-primary,
.storytelling-wrapper .result-card .btn-primary:link,
.storytelling-wrapper .result-card .btn-primary:visited {
  color: white;
  text-decoration: none;
}

.storytelling-wrapper .result-card a.btn-primary {
  display: block;
  width: 100%;
  box-sizing: border-box;
}

.storytelling-wrapper .btn-secondary {
  width: 100%;
  padding: 12px 20px;
  border-radius: 14px;
  border: 3px solid #90CAF9;
  background: linear-gradient(135deg, #E3F2FD, #BBDEFB);
  color: #1e3a8a;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(79, 142, 247, 0.2);
}

.storytelling-wrapper .btn-secondary:hover {
  background: linear-gradient(135deg, #BBDEFB, #90CAF9);
  border-color: #4F8EF7;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(79, 142, 247, 0.3);
}

.storytelling-wrapper .btn-outline {
  width: 100%;
  padding: 12px 20px;
  border-radius: 14px;
  border: 3px solid #90CAF9;
  background: transparent;
  color: #2563eb;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.storytelling-wrapper .btn-outline:hover {
  background: linear-gradient(135deg, #E3F2FD, #BBDEFB);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(79, 142, 247, 0.2);
}

/* Utility classes */
.storytelling-wrapper .mt-4 {
  margin-top: 16px;
}

.storytelling-wrapper .btn-primary.active {
  opacity: 1;
  cursor: pointer;
}

.storytelling-wrapper .btn-primary.inactive {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Error handling */
.storytelling-wrapper .error-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 100vh;
  padding: 40px 20px;
}

.storytelling-wrapper .error-wrapper .error-message {
  max-width: 500px;
  margin-bottom: 20px;
  text-align: center;
  color: #B71C1C;
  padding: 20px;
  background: linear-gradient(135deg, #FFCDD2, #EF9A9A);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 600;
  border: 3px solid #EF5350;
  box-shadow: 0 4px 16px rgba(239, 83, 80, 0.3);
}

.storytelling-wrapper .error-message {
  text-align: center;
  color: #B71C1C;
  padding: 20px;
  background: linear-gradient(135deg, #FFCDD2, #EF9A9A);
  border-radius: 16px;
  margin: 16px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 600;
  border: 3px solid #EF5350;
  box-shadow: 0 4px 16px rgba(239, 83, 80, 0.3);
}

/* RESULT PAGE */
.storytelling-wrapper .result-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #4F8EF7 0%, #5BA3FF 50%, #74B4FF 100%);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.storytelling-wrapper .result-wrapper::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 215, 0, 0.15) 0%, transparent 70%);
  animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {

  0%,
  100% {
    transform: scale(1);
    opacity: 0.6;
  }

  50% {
    transform: scale(1.15);
    opacity: 1;
  }
}

.storytelling-wrapper .result-card {
  background: rgba(255, 255, 255, 0.98);
  padding: 48px 40px;
  border-radius: 28px;
  text-align: center;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  box-shadow: 0 20px 60px rgba(79, 142, 247, 0.3), 0 0 0 3px rgba(255, 255, 255, 0.9);
  margin: 0 auto;
  position: relative;
  z-index: 1;
  animation: slideUp 0.6s ease-out;
  border: 3px solid rgba(255, 215, 0, 0.3);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(40px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.storytelling-wrapper .result-card h2 {
  font-size: 32px;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #4F8EF7, #2563eb);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 800;
}

.storytelling-wrapper .result-card p {
  font-size: 16px;
  color: #1e3a8a;
  line-height: 1.7;
  font-weight: 500;
}

.storytelling-wrapper .result-card svg {
  width: 90px;
  height: 90px;
  margin: 0 auto 16px;
  color: #FFD700;
  filter: drop-shadow(0 6px 20px rgba(255, 215, 0, 0.5));
  animation: bounce 1.2s ease-in-out infinite;
}

@keyframes bounce {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-15px);
  }
}

.storytelling-wrapper .trophy {
  width: 90px;
  height: 90px;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, #FFD700, #FFA500);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 10px 30px rgba(255, 165, 0, 0.5);
  animation: bounce 1.2s ease-in-out infinite;
  border: 3px solid rgba(255, 255, 255, 0.8);
}

/* STATS */
.storytelling-wrapper .stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 20px 0;
}

.storytelling-wrapper .stat-box {
  padding: 16px 12px;
  background: linear-gradient(135deg, #E3F2FD, #BBDEFB);
  border-radius: 16px;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 2px solid #90CAF9;
  box-shadow: 0 4px 12px rgba(79, 142, 247, 0.2);
  color: #1e3a8a;
}

.storytelling-wrapper .stat-box span {
  font-size: 12px;
  margin-top: 4px;
  color: #4F8EF7;
  font-weight: 600;
}

/* ACTIONS */
.storytelling-wrapper .actions {
  display: flex;
  gap: 12px;
  flex-direction: column;
}

/* Responsive Design */
@media (max-width: 768px) {

  .storytelling-wrapper .current-level-session,
  .storytelling-wrapper .lesson-header {
    max-width: 100%;
    padding: 18px;
  }

  .storytelling-wrapper .lesson-grid {
    flex-direction: column;
    align-items: center;
    max-width: 100%;
  }

  .storytelling-wrapper .left-panel,
  .storytelling-wrapper .right-panel,
  .storytelling-wrapper .right-panel.full-width {
    max-width: 100%;
  }

  .storytelling-wrapper .result-card {
    padding: 36px 28px;
    max-width: 100%;
  }

  .storytelling-wrapper .result-card h2 {
    font-size: 28px;
  }

  .storytelling-wrapper .option-btn {
    padding: 14px 18px;
    font-size: 14px;
  }

  .storytelling-wrapper .card {
    padding: 24px;
  }
}