@import url('./apple-design-system.css');
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@500;600;700;800&family=Noto+Sans+Sinhala:wght@500;600;700;800&display=swap');

/* ==========================================================================
   Apple Cupertino Theme Mobile Frame & Custom Tokens
   ========================================================================== */
:root {
  --ios-canvas: #F5F5F7;
  --ios-card: #FFFFFF;
  --ios-text: #1D1D1F;
  --ios-subtext: #86868B;
  --ios-border: rgba(0, 0, 0, 0.08);
  --ios-blue: #0071E3;
  --ios-blue-active: #0077ED;
  --ios-green: #34C759;
  --ios-red: #FF3B30;
  --ios-orange: #FF9500;
  --ios-shadow-card: 0 4px 20px rgba(0, 0, 0, 0.04);
  --ios-radius-card: 22px;
  --font-sinhala: 'Noto Sans Sinhala', -apple-system, sans-serif;
}

body {
  background-color: #E5E5EA; /* Darker backdrop to center and frame phone */
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Plus Jakarta Sans", sans-serif;
  color: var(--ios-text);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  -webkit-font-smoothing: antialiased;
}

/* Standalone Full Mobile View Frame */
.mobile-device-frame {
  width: 100%;
  max-width: 430px; /* iPhone 15/16 Pro Max Dimensions */
  min-height: 100vh;
  background-color: var(--ios-canvas);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 20px 50px rgba(0,0,0,0.12);
  border-left: 1px solid rgba(0,0,0,0.06);
  border-right: 1px solid rgba(0,0,0,0.06);
  overflow-x: hidden;
}

@media (max-width: 480px) {
  body {
    background-color: var(--ios-canvas);
  }
  .mobile-device-frame {
    box-shadow: none;
    border: none;
  }
}

/* 1. Top Navigation Bar (Branded & Lesson Selector) */
.top-nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px 8px 16px;
  background-color: var(--ios-canvas);
  position: sticky;
  top: 0;
  z-index: 45;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  object-fit: contain;
}

.brand-text {
  font-size: 14px;
  font-weight: 800;
  color: #1D1D1F;
  letter-spacing: -0.02em;
}

.btn-lesson-selector {
  background-color: #FFFFFF;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 9999px;
  padding: 5px 12px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ios-blue);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-lesson-selector:active {
  transform: scale(0.96);
}

/* 2. Step Progress Segment Bar */
.step-progress-wrapper {
  padding: 6px 16px 10px 16px;
  background-color: var(--ios-canvas);
  position: sticky;
  top: 48px;
  z-index: 40;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.step-indicator-text {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--ios-subtext);
  margin-bottom: 6px;
}

.step-segments {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
}

.step-segment {
  height: 6px;
  border-radius: 9999px;
  background-color: rgba(0, 0, 0, 0.08);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.step-segment.locked {
  opacity: 0.35;
}

.step-segment.active {
  background-color: var(--ios-blue);
  box-shadow: 0 0 8px rgba(0, 113, 227, 0.5);
  transform: scaleY(1.3);
}

.step-segment.completed {
  background-color: var(--ios-green);
}

/* Content Container */
.mobile-content {
  padding: 10px 16px 30px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Video Card Container */
.video-card-container {
  border-radius: 20px;
  overflow: hidden;
  background-color: #000000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(0, 0, 0, 0.08);
  position: relative;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-element {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-overlay-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #FFFFFF;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 5px;
}

.video-speed-pill {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #FFFFFF;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.15);
  transition: all 0.2s;
}

.video-speed-pill:active {
  transform: scale(0.95);
}

/* Subtitle & Sinhala Meaning Box */
.subtitles-card {
  background-color: var(--ios-card);
  border-radius: var(--ios-radius-card);
  border: 1px solid var(--ios-border);
  box-shadow: var(--ios-shadow-card);
  padding: 18px 18px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.english-sentence-box {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--ios-text);
  letter-spacing: -0.02em;
}

/* Dynamic Shadowing Word Highlighting */
.word-token {
  display: inline-block;
  padding: 1px 4px;
  margin: 1px 0;
  border-radius: 6px;
  transition: background-color 0.12s ease, color 0.12s ease, transform 0.12s ease;
}

.word-token.highlighted {
  background-color: #0071E3;
  color: #FFFFFF;
  transform: translateY(-1px) scale(1.04);
  box-shadow: 0 2px 8px rgba(0, 113, 227, 0.35);
}

.word-token.stressed {
  border-bottom: 2px dashed #0071E3;
}

/* Sinhala Translation Box */
.sinhala-meaning-box {
  background-color: rgba(52, 199, 89, 0.08);
  border-left: 3.5px solid var(--ios-green);
  border-radius: 0 12px 12px 0;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sinhala-meaning-label {
  font-size: 10px;
  font-weight: 800;
  color: #248A3D;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sinhala-meaning-text {
  font-family: var(--font-sinhala);
  font-size: 14px;
  font-weight: 600;
  color: #196C2E;
  line-height: 1.45;
}

/* Speech Context & Leadership Insight Box */
.context-insight-box {
  background-color: rgba(0, 113, 227, 0.06);
  border: 1px solid rgba(0, 113, 227, 0.15);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #0071E3;
  font-family: var(--font-sinhala);
  line-height: 1.4;
}

/* Phonetic & Intonation Tip */
.tip-box {
  background-color: #F8F9FA;
  border: 1px dashed rgba(0, 0, 0, 0.12);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 12px;
  color: #4A4A4F;
  font-family: var(--font-sinhala);
  line-height: 1.4;
}

/* Controls Action Panel */
.controls-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Play Original Button */
.btn-listen-original {
  background-color: var(--ios-card);
  color: var(--ios-text) !important;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 9999px;
  padding: 13px 20px;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.03);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-listen-original:active {
  transform: scale(0.97);
  background-color: #EAEAEA;
}

.btn-listen-original.playing {
  background-color: rgba(0, 113, 227, 0.08);
  border-color: var(--ios-blue);
  color: var(--ios-blue) !important;
}

/* Prominent Record / Stop Button */
.btn-shadow-record {
  background-color: var(--ios-blue);
  color: #FFFFFF !important;
  border: none;
  border-radius: 9999px;
  padding: 16px 24px;
  font-size: 16px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 113, 227, 0.35);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.btn-shadow-record:active {
  transform: scale(0.97);
}

.btn-shadow-record.recording {
  background-color: var(--ios-red) !important;
  box-shadow: 0 6px 20px rgba(255, 59, 48, 0.45);
  animation: pulseRecording 1.4s infinite cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes pulseRecording {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.45); }
  50% { box-shadow: 0 0 0 12px rgba(255, 59, 48, 0); }
}

/* User Playback Bar (Visible after record) */
.user-playback-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  background-color: #FFFFFF;
  border: 1px solid var(--ios-border);
  border-radius: 16px;
  padding: 8px 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}

.btn-mini-playback {
  background: rgba(0, 0, 0, 0.05);
  border: none;
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ios-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Feedback & Retry Toast */
.feedback-toast {
  display: none;
  border-radius: 16px;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  font-family: var(--font-sinhala);
  line-height: 1.4;
  animation: slideInUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.feedback-toast.error {
  background-color: #FFF0F0;
  color: #D32F2F;
  border: 1px solid #FFCDD2;
}

.feedback-toast.success {
  background-color: #F0FDF4;
  color: #166534;
  border: 1px solid #BBF7D0;
}

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

/* Celebration Overlay Modal */
.celebration-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.celebration-card {
  width: 100%;
  max-width: 340px;
  background: #FFFFFF;
  border-radius: 28px;
  padding: 28px 24px 24px 24px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.8);
  animation: popScale 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

@keyframes popScale {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.celebration-icon {
  width: 68px;
  height: 68px;
  border-radius: 9999px;
  background: #E8F5E9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  box-shadow: 0 4px 14px rgba(76, 175, 80, 0.2);
}

.celebration-title {
  font-size: 22px;
  font-weight: 800;
  color: #1D1D1F;
  letter-spacing: -0.02em;
}

.celebration-subtitle {
  font-size: 13.5px;
  color: #4A4A4F;
  font-family: var(--font-sinhala);
  line-height: 1.45;
}

/* Lesson Selector Modal / Sheet */
.lesson-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
}

.lesson-sheet {
  width: 100%;
  max-width: 430px;
  background: #FFFFFF;
  border-radius: 28px 28px 0 0;
  padding: 20px 20px 34px 20px;
  box-shadow: 0 -10px 40px rgba(0,0,0,0.15);
  animation: slideUpSheet 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

@keyframes slideUpSheet {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.lesson-sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  padding-bottom: 12px;
}

.lesson-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 60vh;
  overflow-y: auto;
}

.lesson-item-btn {
  background: #F5F5F7;
  border: 1.5px solid transparent;
  border-radius: 16px;
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s;
}

.lesson-item-btn.active {
  background: #EFF6FF;
  border-color: #0071E3;
}

.lesson-item-btn.locked {
  opacity: 0.65;
  background: #FAFAFA;
  border-style: dashed;
  border-color: #E5E5EA;
  cursor: not-allowed;
}

.lesson-item-btn.locked:active {
  transform: none;
}

.lock-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 9999px;
  background: #E5E5EA;
  color: #8E8E93;
}

.unlocked-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 9999px;
  background: #E1F8EB;
  color: #107C41;
}

/* Full Completion Screen */
.completion-screen {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 30px 20px;
  gap: 16px;
  animation: slideInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.trophy-badge {
  font-size: 56px;
  margin-bottom: 4px;
}

.next-lesson-cta-btn {
  background-color: #0071E3;
  color: #FFFFFF !important;
  border: none;
  border-radius: 9999px;
  padding: 14px 20px;
  font-size: 14.5px;
  font-weight: 800;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 6px 18px rgba(0, 113, 227, 0.35);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  width: 100%;
  box-sizing: border-box;
}

.next-lesson-cta-btn:active {
  transform: scale(0.98);
}

.pdf-download-action-btn {
  background-color: #1D1D1F;
  color: #FFFFFF !important;
  border-radius: 9999px;
  padding: 12px 20px;
  font-size: 13.5px;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  box-sizing: border-box;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.whatsapp-cta-btn {
  background-color: #25D366;
  color: #FFFFFF !important;
  border-radius: 9999px;
  padding: 14px 24px;
  font-size: 15px;
  font-weight: 800;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 6px 18px rgba(37, 211, 102, 0.35);
  margin-top: 6px;
}

.pdf-cta-btn {
  background-color: #FFFFFF;
  color: #1D1D1F !important;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 9999px;
  padding: 12px 20px;
  font-size: 13.5px;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Canvas Confetti */
#confettiCanvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
}
