/* ===== CSS Variables ===== */
:root {
  /* Color Palette - Parchment & History Theme */
  --parchment-light: #faf7f0;
  --parchment-medium: #f4f1e8;
  --parchment-dark: #e8e2d0;
  --sepia-brown: #8b6914;
  --dark-brown: #5c4511;
  --burgundy: #722f37;
  --dark-blue: #1e3a5f;
  --gold: #d4af37;
  --charcoal: #2c2c2c;
  --warm-white: #fffef8;
  
  /* Typography */
  --font-serif: 'Crimson Text', Georgia, serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  
  /* Spacing for classroom projection */
  --header-height: 80px;
  --sidebar-width: 320px;
  --border-radius: 8px;
  --shadow-soft: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-strong: 0 6px 20px rgba(0,0,0,0.15);
}

/* ===== Reset & Base Styles ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-serif);
  background: linear-gradient(135deg, var(--parchment-light) 0%, var(--parchment-medium) 100%);
  color: var(--charcoal);
  line-height: 1.6;
  min-height: 100vh;
  font-size: 18px; /* Large base font for projection */
}

/* ===== Loading Screen ===== */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--dark-blue);
  color: var(--warm-white);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s ease-out;
}

.loading-content {
  text-align: center;
}

.loading-content h1 {
  font-size: 4rem;
  font-family: var(--font-serif);
  margin-bottom: 1rem;
  color: var(--gold);
}

.loading-content p {
  font-size: 1.5rem;
  margin-bottom: 2rem;
  font-style: italic;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255,255,255,0.3);
  border-left-color: var(--gold);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

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

/* ===== Main Interface ===== */
.main-interface {
  min-height: 100vh;
  display: grid;
  grid-template-rows: var(--header-height) 1fr auto;
  grid-template-columns: 1fr;
  transition: opacity 0.5s ease-in;
}

.hidden {
  display: none !important;
}

/* ===== Header ===== */
.header {
  background: var(--dark-blue);
  color: var(--warm-white);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-strong);
  position: relative;
  z-index: 100;
}

.app-title {
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--gold);
  margin-bottom: 0.2rem;
}

.lesson-indicator {
  font-size: 1rem;
  opacity: 0.9;
}

.progress-indicator {
  margin-left: 1rem;
  font-size: 0.9rem;
  opacity: 0.7;
}

.header-right {
  display: flex;
  gap: 1rem;
}

.control-btn {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--warm-white);
  padding: 0.6rem 1.2rem;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.3s ease;
}

.control-btn:hover {
  background: rgba(255,255,255,0.2);
  transform: translateY(-1px);
}

/* ===== Sidebar ===== */
.sidebar {
  position: fixed;
  top: 0;
  left: -320px;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--parchment-dark);
  box-shadow: var(--shadow-strong);
  z-index: 200;
  transition: left 0.3s ease;
  overflow-y: auto;
}

.sidebar.open {
  left: 0;
}

.sidebar-header {
  padding: 2rem;
  background: var(--sepia-brown);
  color: var(--warm-white);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-header h3 {
  font-size: 1.5rem;
  font-weight: 600;
}

.close-btn {
  background: none;
  border: none;
  color: var(--warm-white);
  font-size: 2rem;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.3s ease;
}

.close-btn:hover {
  background: rgba(255,255,255,0.1);
}

.lessons-list {
  padding: 1rem;
}

.lesson-item {
  padding: 1.5rem;
  border-bottom: 1px solid rgba(139,105,20,0.2);
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: var(--border-radius);
  margin-bottom: 0.5rem;
}

.lesson-item:hover {
  background: var(--parchment-light);
  transform: translateX(5px);
}

.lesson-item.active {
  background: var(--sepia-brown);
  color: var(--warm-white);
}

.lesson-item.stub {
  opacity: 0.6;
  cursor: not-allowed;
}

.lesson-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.lesson-subtitle {
  font-size: 1rem;
  opacity: 0.8;
  font-style: italic;
}

.lesson-status {
  font-size: 0.85rem;
  margin-top: 0.5rem;
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  display: inline-block;
}

.lesson-status.complete {
  background: var(--gold);
  color: var(--dark-brown);
}

.lesson-status.stub {
  background: rgba(139,105,20,0.2);
  color: var(--sepia-brown);
}

/* ===== Main Content ===== */
.main-content {
  padding: 2rem;
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* ===== Slide Base Styles ===== */
.slide {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  animation: slideIn 0.5s ease-out;
}

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

.slide-content {
  background: var(--warm-white);
  padding: 3rem;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-soft);
  border: 2px solid var(--parchment-dark);
}

/* ===== Welcome Slide ===== */
.welcome-slide .slide-content {
  text-align: center;
}

.welcome-slide h1 {
  font-size: 4rem;
  color: var(--dark-blue);
  margin-bottom: 1rem;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.welcome-slide h2 {
  font-size: 2.5rem;
  color: var(--burgundy);
  margin-bottom: 1rem;
  font-style: italic;
}

.welcome-slide .subtitle {
  font-size: 1.5rem;
  color: var(--sepia-brown);
  margin-bottom: 3rem;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  margin-bottom: 3rem;
}

.feature-item {
  padding: 2rem;
  background: var(--parchment-light);
  border-radius: var(--border-radius);
  border: 1px solid var(--parchment-dark);
}

.feature-item h3 {
  font-size: 1.4rem;
  color: var(--dark-blue);
  margin-bottom: 1rem;
}

.feature-item p {
  font-size: 1.1rem;
  color: var(--charcoal);
}

/* ===== Lesson Overview Slide ===== */
.lesson-overview-slide h1 {
  font-size: 3rem;
  color: var(--dark-blue);
  margin-bottom: 0.5rem;
}

.lesson-overview-slide h2 {
  font-size: 1.8rem;
  color: var(--burgundy);
  margin-bottom: 2rem;
  font-style: italic;
}

.lesson-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  margin-bottom: 3rem;
}

.narrative-preview, .figures-preview {
  padding: 2rem;
  background: var(--parchment-light);
  border-radius: var(--border-radius);
  border-left: 4px solid var(--gold);
}

.narrative-preview h3, .figures-preview h3 {
  font-size: 1.4rem;
  color: var(--dark-blue);
  margin-bottom: 1rem;
}

.figures-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.figure-preview {
  padding: 1rem;
  background: var(--warm-white);
  border-radius: var(--border-radius);
  border: 1px solid var(--parchment-dark);
  text-align: center;
}

.figure-preview img {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 0.5rem;
  border: 2px solid var(--gold);
}

.figure-preview-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--dark-blue);
}

.figure-preview-role {
  font-size: 0.9rem;
  color: var(--sepia-brown);
  font-style: italic;
}

/* ===== Narrative Slide ===== */
.narrative-slide h1 {
  font-size: 2.5rem;
  color: var(--dark-blue);
  margin-bottom: 0.5rem;
}

.narrative-slide h2 {
  font-size: 1.5rem;
  color: var(--burgundy);
  margin-bottom: 2rem;
  font-style: italic;
}

.narrative-content {
  background: var(--parchment-light);
  padding: 2.5rem;
  border-radius: var(--border-radius);
  border-left: 6px solid var(--gold);
  margin-bottom: 2rem;
}

.narrative-text {
  font-size: 1.3rem;
  line-height: 1.8;
  color: var(--charcoal);
}

.narrative-text p {
  margin-bottom: 1.5rem;
}

.narrative-text p:last-child {
  margin-bottom: 0;
}

/* ===== Figure Slide ===== */
.figure-header {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 3rem;
  margin-bottom: 3rem;
  align-items: start;
}

.figure-info h1 {
  font-size: 2.5rem;
  color: var(--dark-blue);
  margin-bottom: 1rem;
}

.figure-info p {
  font-size: 1.2rem;
  color: var(--charcoal);
  margin-bottom: 1rem;
}

.figure-role {
  display: inline-block;
  background: var(--gold);
  color: var(--dark-brown);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 1rem;
  font-weight: 600;
}

.figure-portrait {
  text-align: center;
}

.figure-portrait img {
  width: 200px;
  height: 250px;
  border-radius: var(--border-radius);
  object-fit: cover;
  border: 4px solid var(--gold);
  margin-bottom: 1rem;
}

.talking-head-area {
  width: 200px;
  height: 150px;
  background: var(--parchment-medium);
  border: 2px dashed var(--sepia-brown);
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

.ai-placeholder {
  color: var(--sepia-brown);
  font-style: italic;
  text-align: center;
  font-size: 1rem;
}

.interaction-area {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  margin-bottom: 3rem;
}

.questions-section h3, .response-area h3 {
  font-size: 1.4rem;
  color: var(--dark-blue);
  margin-bottom: 1rem;
}

.questions-list {
  margin-bottom: 1.5rem;
}

.question-btn {
  display: block;
  width: 100%;
  padding: 1rem 1.5rem;
  background: var(--parchment-light);
  border: 1px solid var(--parchment-dark);
  border-radius: var(--border-radius);
  color: var(--charcoal);
  cursor: pointer;
  margin-bottom: 0.8rem;
  text-align: left;
  font-size: 1rem;
  transition: all 0.3s ease;
}

.question-btn:hover {
  background: var(--gold);
  color: var(--dark-brown);
  transform: translateX(5px);
}

.question-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.custom-question {
  display: flex;
  gap: 0.5rem;
}

.custom-question input {
  flex: 1;
  padding: 1rem;
  border: 2px solid var(--parchment-dark);
  border-radius: var(--border-radius);
  font-size: 1rem;
  background: var(--warm-white);
}

.custom-question input:focus {
  outline: none;
  border-color: var(--gold);
}

.response-content {
  background: var(--warm-white);
  border: 2px solid var(--parchment-dark);
  border-radius: var(--border-radius);
  padding: 2rem;
  min-height: 200px;
  font-size: 1.1rem;
  line-height: 1.7;
}

.placeholder-text {
  color: var(--sepia-brown);
  font-style: italic;
}

.figure-controls {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.summon-btn {
  background: var(--burgundy);
  color: var(--warm-white);
  border: none;
  padding: 1rem 2rem;
  border-radius: var(--border-radius);
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 600;
}

.summon-btn:hover {
  background: #8b3a42;
  transform: translateY(-2px);
  box-shadow: var(--shadow-strong);
}

.summon-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ===== Reflection Slide ===== */
.reflection-slide h1 {
  font-size: 2.5rem;
  color: var(--dark-blue);
  margin-bottom: 2rem;
  text-align: center;
}

.reflection-content {
  max-width: 800px;
  margin: 0 auto;
}

.reflection-prompt {
  background: var(--parchment-light);
  padding: 2.5rem;
  border-radius: var(--border-radius);
  border-left: 6px solid var(--burgundy);
  margin-bottom: 2rem;
}

.reflection-prompt h3 {
  font-size: 1.4rem;
  color: var(--dark-blue);
  margin-bottom: 1rem;
}

.reflection-prompt p {
  font-size: 1.3rem;
  line-height: 1.8;
  color: var(--charcoal);
}

.reflection-input textarea {
  width: 100%;
  min-height: 150px;
  padding: 1.5rem;
  border: 2px solid var(--parchment-dark);
  border-radius: var(--border-radius);
  font-size: 1.1rem;
  font-family: var(--font-serif);
  background: var(--warm-white);
  resize: vertical;
}

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

/* ===== Buttons ===== */
.primary-btn, .secondary-btn {
  border: none;
  padding: 1rem 2rem;
  border-radius: var(--border-radius);
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 600;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

.primary-btn {
  background: var(--dark-blue);
  color: var(--warm-white);
}

.primary-btn:hover {
  background: #2a4a70;
  transform: translateY(-2px);
  box-shadow: var(--shadow-strong);
}

.secondary-btn {
  background: var(--gold);
  color: var(--dark-brown);
}

.secondary-btn:hover {
  background: #e6c547;
  transform: translateY(-2px);
  box-shadow: var(--shadow-strong);
}

.primary-btn:disabled, .secondary-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ===== Slide Navigation ===== */
.slide-nav {
  background: var(--parchment-medium);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--parchment-dark);
}

.nav-btn {
  background: var(--sepia-brown);
  color: var(--warm-white);
  border: none;
  padding: 0.8rem 1.5rem;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.3s ease;
}

.nav-btn:hover:not(:disabled) {
  background: var(--dark-brown);
  transform: translateY(-1px);
}

.nav-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.slide-progress {
  font-size: 1.1rem;
  color: var(--sepia-brown);
  font-weight: 600;
}

/* ===== Slide Controls ===== */
.slide-controls {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 2rem;
  flex-wrap: wrap;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
  .header {
    padding: 0 1rem;
  }
  
  .app-title {
    font-size: 1.4rem;
  }
  
  .main-content {
    padding: 1rem;
  }
  
  .slide-content {
    padding: 2rem 1.5rem;
  }
  
  .welcome-slide h1 {
    font-size: 2.5rem;
  }
  
  .welcome-slide h2 {
    font-size: 1.8rem;
  }
  
  .lesson-preview {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  
  .figure-header {
    grid-template-columns: 1fr;
    gap: 2rem;
    text-align: center;
  }
  
  .interaction-area {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  
  .feature-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== Fullscreen Mode ===== */
.fullscreen-mode {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  background: var(--parchment-light);
}

.fullscreen-mode .header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10000;
}

.fullscreen-mode .main-content {
  padding-top: calc(var(--header-height) + 2rem);
  height: 100vh;
  overflow-y: auto;
}

/* ===== Animation Classes ===== */
.fade-in {
  animation: fadeIn 0.5s ease-out;
}

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