/* =========================================================
   SMARTPREP PUNJABI MASTER STYLESHEET
   Unified Hub & Cinematic TV-Series Conversation App
   ========================================================= */

:root {
  /* Classic SmartPrep Palette */
  --primary: #2563eb;       
  --primary-dark: #1e3a8a;  
  --success: #10b981;       
  --danger: #ef4444;        
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --border-color: #e2e8f0;

  /* Premium Cinematic Palette */
  --bg-page: #f4f0e8;
  --brand-blue: #1e3a8a;
  --brand-gold: #f6b73c;
  --brand-green: #10b981;
  --brand-red: #ef4444;

  --glass-bg: rgba(255, 255, 255, 0.84);
  --glass-border: rgba(255, 255, 255, 0.55);

  --shadow-soft: 0 12px 34px rgba(15, 23, 42, 0.16);
  --shadow-strong: 0 20px 55px rgba(15, 23, 42, 0.26);

  --ease-main: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
}

body {
  margin: 0;
  padding: 0;
  width: 100%; /* Forces the body to span the full screen */
  min-height: 100vh;
  font-family: "Noto Sans Gurmukhi", -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  
  /* Blended Premium Background */
  background:
    radial-gradient(circle at top left, rgba(255, 215, 140, 0.28), transparent 35%),
    linear-gradient(135deg, #fdf7ec 0%, #eef6ff 100%);
  color: var(--text-main);
  
  /* Flex layout to center the Hub elements naturally */
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

.hidden { display: none !important; }

/* =========================================================
   1. MAIN HUB STYLES (index.html, tracing.html, etc.)
   ========================================================= */

/* Classic Solid Header for standard apps */
header:not(.app-header) {
  background-color: var(--primary-dark);
  color: white;
  width: 100%;
  text-align: center;
  padding: 20px 0;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

header:not(.app-header) h1 {
  margin: 0 0 5px 0;
  font-size: 1.8rem;
}

header:not(.app-header) p {
  margin: 0;
  font-size: 1rem;
  opacity: 0.8;
}

/* Hub Grid Layout */
.container {
  max-width: 900px;
  width: 90%;
  margin: 40px auto;
  flex: 1; /* Pushes footer down */
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.card {
  background: white;
  border-radius: 16px;
  padding: 25px;
  text-align: center;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 4px 6px rgba(0,0,0,0.05);
  border: 1px solid var(--border-color);
  transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 15px rgba(0,0,0,0.1);
}

.card .icon {
  font-size: 3rem;
  margin-bottom: 15px;
}

.card h2 {
  margin: 0 0 10px 0;
  font-size: 1.4rem;
  color: var(--text-main);
}

.card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.4;
}

/* =========================================================
   2. CINEMATIC APP HEADER & NAV (converse.html)
   ========================================================= */

.app-header {
  padding: 14px 18px 8px;
  display: flex;
  justify-content: center;
  width: 100%;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.75);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  border-radius: 22px;
  padding: 10px 18px;
  backdrop-filter: blur(12px);
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #fff0bd, #ffd166);
  font-size: 1.35rem;
  box-shadow: 0 8px 20px rgba(246, 183, 60, 0.35);
}

.app-header h1 {
  margin: 0;
  font-size: clamp(1.2rem, 2.5vw, 1.65rem);
  color: var(--brand-blue);
  letter-spacing: -0.03em;
}

.app-header p {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.nav-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 16px 16px;
  width: 100%;
}

.nav-bar select, .nav-bar button, .nav-bar a {
  min-height: 42px;
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 0.95rem;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.10);
}

.nav-bar select { background: white; color: var(--ink-dark); outline: none; }

.start-btn {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(16, 185, 129, 0.32);
}

.hub-btn { background: #4b5563; color: white; text-decoration: none; }

/* =========================================================
   3. CINEMATIC STAGE (converse.html)
   ========================================================= */

.page-shell {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 0 14px 26px;
  flex: 1;
}

.episode-card { width: min(100%, 1180px); }

.module-title {
  margin: 0 auto 12px;
  width: fit-content;
  max-width: 90%;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
  color: var(--brand-blue);
  font-weight: 800;
  text-align: center;
}

.cinematic-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 72vh;
  min-height: 420px;
  isolation: isolate;
  margin-bottom: 40px; 
}

.scene-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transform: scale(1.015);
  filter: saturate(1.03) brightness(1.02);
  border-radius: 34px;
  overflow: hidden;
}

.cinematic-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  border-radius: 34px;
  overflow: hidden;
}

.stage-light {
  position: absolute;
  bottom: 12%;
  width: 30%;
  height: 42%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 224, 170, 0.24), transparent 70%);
  z-index: 2;
  pointer-events: none;
}
.stage-light-left { left: 6%; }
.stage-light-right { right: 6%; }

/* =========================================================
   CHARACTER SPRITES
   ========================================================= */

.character-sprite {
  position: absolute;
  z-index: 4;
  bottom: 9%; 
  width: clamp(260px, 35vw, 480px); 
  height: 75%; 
  max-height: 82%;
  object-fit: contain;
  object-position: bottom center;
  user-select: none;
  pointer-events: none;
  filter: drop-shadow(0 18px 24px rgba(15, 23, 42, 0.20));
  transition: opacity 0.3s var(--ease-main);
}

.char-pos-left { left: 7%; }
.char-pos-right { right: 7%; }

.character-sprite.speaking { opacity: 1; z-index: 6; }
.character-sprite.listening { opacity: 1; z-index: 4; }

.character-sprite.enter { animation: characterEntrance 0.8s var(--ease-main) forwards; }

@keyframes characterEntrance {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   UI LAYER & BUBBLES
   ========================================================= */

.ui-layer {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.hint-bubble {
  position: absolute;
  bottom: 115px; 
  left: 50%;
  transform: translateX(-50%);
  z-index: 20; 
  width: min(88%, 560px);
  padding: 12px 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-soft);
  color: var(--ink-dark);
  font-size: 0.96rem;
  line-height: 1.5;
  pointer-events: auto;
  animation: popInCentered 0.32s var(--ease-main);
}
.hint-bubble strong { color: #92400e; }

/* =========================================================
   DIALOGUE BOX
   ========================================================= */

.dialogue-box {
  position: absolute;
  left: 50%;
  bottom: -35px; 
  transform: translateX(-50%);
  width: min(92%, 900px);
  padding: 14px 24px 12px; 
  border-radius: 28px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow-strong); 
  pointer-events: auto;
  animation: dialogueRise 0.45s var(--ease-main);
}

@keyframes dialogueRise {
  from { opacity: 0; transform: translateX(-50%) translateY(18px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes popInCentered {
  from { opacity: 0; transform: translateX(-50%) translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

.speaker-name {
  margin-bottom: 8px;
  font-size: 0.96rem;
  font-weight: 800;
  color: #9a5b13;
  letter-spacing: 0.02em;
}

.speaker-text {
  min-height: 32px; 
  font-size: clamp(1.35rem, 2.3vw, 2.05rem);
  line-height: 1.55;
  font-weight: 700;
  color: #111827;
  animation: textFade 0.35s ease;
  margin: 0;
}

.subtitle-text {
  margin-top: 6px;
  min-height: 24px;
  font-size: clamp(0.92rem, 1.2vw, 1.06rem);
  line-height: 1.45;
  color: rgba(17, 24, 39, 0.68);
  font-style: italic;
  animation: textFade 0.4s ease;
}

@keyframes textFade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   CONTROLS
   ========================================================= */

.controls-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.action-btn {
  border: none;
  outline: none;
  border-radius: 999px;
  padding: 12px 22px;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.action-btn:hover { transform: translateY(-2px); }
.action-btn:active { transform: scale(0.965); }

.next-btn {
  background: linear-gradient(135deg, #ffd166, #f6a623);
  color: #432818;
  box-shadow: 0 10px 22px rgba(246, 166, 35, 0.32);
}

.speak-btn {
  background: linear-gradient(135deg, #2563eb, #1e40af);
  color: white;
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.32);
}

.speak-btn.listening {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  animation: micPulse 1.2s ease-in-out infinite;
}

@keyframes micPulse {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.42); }
  70% { box-shadow: 0 0 0 14px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* =========================================================
   FEEDBACK & PROGRESS
   ========================================================= */

.feedback {
  margin: 16px auto 0;
  min-height: 34px;
  width: min(92%, 850px);
  text-align: center;
  font-size: 1.14rem;
  font-weight: 800;
}

.progress-bar {
  width: min(94%, 900px);
  height: 12px;
  margin: 12px auto 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  overflow: hidden;
  box-shadow: inset 0 2px 6px rgba(15, 23, 42, 0.12);
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #10b981, #34d399, #f6b73c);
  transition: width 0.45s var(--ease-main);
}

.final-screen-container {
  width: min(94%, 720px);
  margin: 24px auto;
  padding: 34px 24px;
  border-radius: 32px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-soft);
  text-align: center;
  animation: popIn 0.45s var(--ease-main);
}

@keyframes popIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

#visual-focus-box { animation: focusPop 0.32s var(--ease-main); }
@keyframes focusPop {
  from { opacity: 0; transform: translateX(-50%) translateY(-8px) scale(0.94); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* =========================================================
   MOBILE OPTIMISATION & DEVICES
   ========================================================= */

@media (max-width: 768px) and (orientation: portrait) {
  .app-header { padding-top: 10px; }
  .brand-lockup { padding: 8px 12px; border-radius: 18px; }
  .brand-icon { width: 38px; height: 38px; border-radius: 14px; }
  .nav-bar { gap: 8px; padding-bottom: 10px; }
  .nav-bar select, .nav-bar button, .nav-bar a { font-size: 0.82rem; padding: 9px 12px; }
  .page-shell { padding: 0 8px 18px; }
  
  .cinematic-stage { 
    min-height: 380px; 
    max-height: 60vh; 
    aspect-ratio: 4 / 5; 
    border-radius: 24px; 
    margin-bottom: 35px; 
  }
  
  .character-sprite { 
    bottom: 26%; 
    width: clamp(180px, 48vw, 300px); 
    max-height: 60%; 
  }
  .char-pos-left { left: 1%; }
  .char-pos-right { right: 1%; }
  
  #visual-focus-box { top: 18%; } 

  .dialogue-box { 
    bottom: -25px; 
    width: 94%; 
    padding: 12px 18px; 
    border-radius: 22px; 
  }
  .speaker-text { font-size: 1.28rem; line-height: 1.5; min-height: 28px; }
  .subtitle-text { font-size: 0.88rem; }
  .controls-bar { justify-content: center; }
  .action-btn { width: 100%; padding: 12px 18px; }
  .hint-bubble { bottom: 100px; font-size: 0.86rem; }
}

@media (max-height: 500px) and (orientation: landscape) {
  .cinematic-stage { 
    min-height: 280px; 
    max-height: 75vh; 
    margin-bottom: 20px; 
  }
  .character-sprite { 
    width: clamp(140px, 20vw, 220px); 
    bottom: 12%; 
  }
  .dialogue-box { 
    bottom: -15px; 
    padding: 8px 18px; 
    width: 88%; 
  }
  .speaker-text { font-size: 1.15rem; min-height: 24px; margin: 0; }
  .subtitle-text { font-size: 0.85rem; margin-top: 2px; }
  .hint-bubble { bottom: 80px; padding: 6px 12px; }
  #visual-focus-box { top: 5%; font-size: clamp(1.5rem, 3vw, 2rem); }
}

@media (max-height: 650px) and (min-width: 769px) {
  .cinematic-stage { max-height: 68vh; min-height: 360px; }
  .character-sprite { width: clamp(200px, 28vw, 360px); }
  .dialogue-box { padding: 16px 20px; bottom: -20px; }
  .speaker-text { font-size: clamp(1.2rem, 2vw, 1.7rem); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}