/* Project Genesis: The Cognition Quests - Main Styles */
:root {
  --color-bg: #0f172a;
  --color-surface: #1e293b;
  --color-surface-light: #334155;
  --color-primary: #38bdf8;
  --color-primary-dim: #0ea5e9;
  --color-accent: #f59e0b;
  --color-success: #34d399;
  --color-danger: #f87171;
  --color-text: #f8fafc;
  --color-text-muted: #94a3b8;
  --color-aura-vocab: #a78bfa;
  --color-aura-seq: #f472b6;
  --color-aura-inference: #34d399;
  --color-aura-theme: #fbbf24;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --font-display: 'Fredoka', sans-serif;
  --font-body: 'Nunito', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  overflow-x: hidden;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 24px;
  opacity: 0;
  transform: translateY(8px) scale(0.995);
  transition: opacity 280ms ease, transform 280ms ease;
}
.screen.hidden { display: none !important; }
.screen.active:not(.hidden) {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Loading */
.loading-screen {
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
}
.loading-content {
  text-align: center;
  max-width: 400px;
}
.genesis-logo .logo-icon {
  font-size: 4rem;
  color: var(--color-primary);
  display: block;
  animation: pulse 2s ease-in-out infinite;
}
.genesis-logo h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  margin-top: 8px;
  letter-spacing: 0.02em;
}
.genesis-logo p {
  color: var(--color-text-muted);
  font-size: 1rem;
  margin-top: 4px;
}
.loading-bar {
  width: 200px;
  height: 8px;
  background: var(--color-surface);
  border-radius: 4px;
  margin: 24px auto;
  overflow: hidden;
}
.loading-progress {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
  animation: load 2s ease-out forwards;
}
.loading-text {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

@keyframes load { to { width: 100%; } }
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.8; transform: scale(1.05); }
}

/* Welcome */
.welcome-screen {
  justify-content: center;
  align-items: center;
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
}
.welcome-content {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 420px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(148, 163, 184, 0.25);
}
.welcome-header h1 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  margin-bottom: 8px;
}
.welcome-header .subtitle {
  color: var(--color-text-muted);
  font-size: 1rem;
  margin-bottom: 24px;
}
.student-setup label {
  display: block;
  font-size: 0.9rem;
  margin-top: 16px;
  margin-bottom: 6px;
}
.student-setup input,
.student-setup select {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--color-surface-light);
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 1rem;
}
.student-setup input:focus,
.student-setup select:focus {
  outline: none;
  border-color: var(--color-primary);
}
.student-setup .btn-primary {
  margin-top: 24px;
  width: 100%;
}
.avatar-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 6px;
}
.avatar-option {
  border: 2px solid var(--color-surface-light);
  border-radius: 10px;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 1.4rem;
  padding: 8px 0;
  cursor: pointer;
}
.avatar-option.active {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-icon {
  font-family: var(--font-body);
  font-weight: 600;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 1rem;
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dim));
  color: #fff;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(56, 189, 248, 0.4);
}
.btn-secondary {
  background: var(--color-surface-light);
  color: var(--color-text);
}
.btn-secondary:hover {
  background: var(--color-surface);
}
.btn-icon {
  background: transparent;
  color: var(--color-text);
  padding: 8px 16px;
}

/* Prologue */
.prologue-screen {
  justify-content: center;
  align-items: center;
}
.prologue-content {
  max-width: 640px;
  width: 100%;
}
.prologue-narrative {
  font-size: 1.15rem;
  line-height: 1.7;
  margin-bottom: 24px;
  padding: 20px;
  background: var(--color-surface);
  border-radius: var(--radius);
}

/* Hub */
.hub-screen {
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 60%);
}
.hub-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  margin-bottom: 24px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}
.aura-display {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.aura-shard {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  opacity: 0.6;
  transition: opacity 0.2s, transform 0.2s;
}
.aura-shard.earned {
  opacity: 1;
  transform: scale(1.1);
  box-shadow: 0 0 12px currentColor;
}
.player-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.player-info span {
  font-size: 0.9rem;
}
#hub-student-avatar {
  font-size: 1.5rem;
  line-height: 1;
  margin-bottom: 4px;
}
.hub-brand {
  font-size: 0.85rem;
  color: var(--color-primary);
  letter-spacing: 0.15em;
  margin-bottom: 8px;
  font-weight: 600;
}
.hub-main h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin-bottom: 20px;
}
.quest-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}
.quest-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  border: 2px solid transparent;
  position: relative;
  min-height: 180px;
}
.quest-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: var(--color-primary);
}
.quest-card.locked {
  opacity: 0.7;
  cursor: pointer;
}
.quest-card .card-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}
.quest-card h3 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  margin-bottom: 8px;
}
.quest-card p {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  line-height: 1.4;
}
.card-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: linear-gradient(135deg, var(--color-accent), #fb7185);
  color: #fff;
  font-weight: 700;
  font-size: 0.72rem;
  padding: 4px 8px;
  border-radius: 999px;
}

/* Quest */
.quest-screen {
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
}
.quest-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.quest-header h2 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  flex: 1;
}
.quest-difficulty {
  display: flex;
  align-items: center;
  gap: 16px;
}
#path-type {
  font-size: 0.85rem;
  padding: 6px 12px;
  background: var(--color-surface);
  border-radius: var(--radius-sm);
}
.challenge-health {
  display: flex;
  align-items: center;
  gap: 8px;
}
.health-label {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}
.health-bar {
  width: 100px;
  height: 12px;
  background: var(--color-surface);
  border-radius: 6px;
  overflow: hidden;
}
.health-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--color-success), var(--color-primary));
  transition: width 0.3s;
}
.quest-narrative {
  font-size: 1rem;
  line-height: 1.6;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--color-surface);
  border-radius: var(--radius);
}
.challenge-container {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.challenge-passage {
  font-size: 1.1rem;
  line-height: 1.6;
  margin-bottom: 16px;
  color: var(--color-text);
}
.challenge-question {
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--color-primary);
}
.quest-feedback {
  padding: 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}
.quest-feedback.success {
  background: rgba(52, 211, 153, 0.2);
  border: 1px solid var(--color-success);
}
.quest-feedback.error {
  background: rgba(248, 113, 113, 0.2);
  border: 1px solid var(--color-danger);
}
.quest-actions {
  display: flex;
  gap: 12px;
}

/* Cognitive Combat - choice buttons */
.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.choice-btn {
  padding: 16px;
  background: var(--color-surface-light);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 1rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
}
.choice-btn:hover {
  border-color: var(--color-primary);
  background: var(--color-surface);
}
.choice-btn.correct {
  border-color: var(--color-success);
  background: rgba(52, 211, 153, 0.2);
}
.choice-btn.incorrect {
  border-color: var(--color-danger);
  background: rgba(248, 113, 113, 0.2);
}
.choice-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Sequencing - drag items */
.sequence-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sequence-item {
  padding: 12px 16px;
  background: var(--color-surface-light);
  border-radius: var(--radius-sm);
  cursor: grab;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: transform 0.2s;
}
.sequence-item:hover {
  transform: translateX(4px);
}
.sequence-item.dragging {
  opacity: 0.6;
}
.sequence-item .drag-handle {
  color: var(--color-text-muted);
  font-size: 1.2rem;
}

/* IEP Report */
.iep-screen {
  background: var(--color-bg);
}
.iep-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.iep-header h1 {
  font-family: var(--font-display);
  font-size: 1.5rem;
}
.iep-content {
  background: #fff;
  color: #1e293b;
  padding: 32px;
  border-radius: var(--radius);
  margin-bottom: 24px;
  max-width: 800px;
  line-height: 1.7;
}
.iep-content h2 {
  font-size: 1.2rem;
  margin-top: 24px;
  margin-bottom: 12px;
  color: #0f172a;
}
.iep-content h2:first-child { margin-top: 0; }
.iep-content ul {
  margin-left: 20px;
  margin-bottom: 16px;
}
.iep-content p {
  margin-bottom: 12px;
}

/* Consent */
.consent-screen {
  justify-content: center;
  align-items: center;
}
.consent-content {
  max-width: 480px;
  background: var(--color-surface);
  padding: 32px;
  border-radius: var(--radius);
}
.consent-content h1 { font-family: var(--font-display); margin-bottom: 16px; }
.consent-intro { margin-bottom: 16px; line-height: 1.6; }
.consent-text { margin: 20px 0; padding: 16px; background: var(--color-bg); border-radius: var(--radius-sm); font-size: 0.9rem; }
.consent-check { display: flex; align-items: center; gap: 12px; margin: 20px 0; cursor: pointer; }
.consent-check input { width: 20px; height: 20px; }
.consent-skip { margin-top: 16px; font-size: 0.9rem; }
.consent-skip a { color: var(--color-primary); }

/* Platformer */
.platformer-screen {
  padding: 10px 12px 12px;
  height: 100vh;
  overflow: hidden;
}
.platformer-header { margin-bottom: 8px; }
.platformer-header h2 { font-family: var(--font-display); font-size: 1.2rem; }
.platformer-header p { font-size: 0.86rem; color: var(--color-text-muted); margin-top: 2px; }
.platformer-progress {
  margin-top: 6px;
  display: inline-block;
  background: rgba(56, 189, 248, 0.18);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #e0f2fe;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
}
.platformer-canvas-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: radial-gradient(circle at 20% 10%, #2b2f6c, #1a1a2e 55%);
  width: fit-content;
  max-width: 100%;
  max-height: calc(100vh - 170px);
  border: 1px solid rgba(148, 163, 184, 0.2);
  margin: 0 auto;
}
#platformer-canvas {
  display: block;
  width: 100%;
  max-height: calc(100vh - 170px);
}
.platformer-confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 9;
  overflow: hidden;
}
.confetti-piece {
  position: absolute;
  top: -14px;
  width: 10px;
  height: 14px;
  border-radius: 2px;
  opacity: 0.95;
  animation: confetti-fall 900ms ease-out forwards;
}
@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 0.95; }
  100% { transform: translateY(260px) rotate(420deg); opacity: 0; }
}
.platformer-hud {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}
.hud-left, .hud-right {
  display: flex;
  gap: 8px;
}
.hud-item {
  background: rgba(30, 64, 175, 0.75);
  border: 1px solid rgba(191, 219, 254, 0.4);
  color: #eff6ff;
  padding: 9px 14px;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 800;
  backdrop-filter: blur(2px);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.hud-icon {
  width: 18px;
  height: 18px;
  display: inline-block;
  flex: 0 0 18px;
}
.icon-heart {
  width: 16px;
  height: 16px;
  background: linear-gradient(180deg, #fb7185, #dc2626);
  clip-path: path("M8 15 C6.8 13.7,1 10,1 5.8 C1 3.4,2.8 1.6,5.2 1.6 C6.6 1.6,7.6 2.2,8 3 C8.4 2.2,9.4 1.6,10.8 1.6 C13.2 1.6,15 3.4,15 5.8 C15 10,9.2 13.7,8 15 Z");
  filter: drop-shadow(0 1px 0 rgba(255,255,255,0.2));
}
.icon-coin {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fef9c3 0%, #fcd34d 45%, #f59e0b 70%, #b45309 100%);
  border: 1.5px solid #92400e;
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.35), 0 0 0 1px rgba(0, 0, 0, 0.18);
}
.platformer-question {
  position: absolute;
  top: 70px;
  right: 24px;
  background: linear-gradient(180deg, #133668 0%, #102749 100%);
  padding: 24px;
  border-radius: var(--radius);
  width: min(92vw, 390px);
  box-shadow: var(--shadow);
  border: 2px solid rgba(191, 219, 254, 0.45);
  z-index: 8;
}
.platformer-question.hidden { display: none !important; }
.question-title {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 800;
  text-align: center;
  margin-bottom: 10px;
  font-size: 1.15rem;
}
.question-help {
  margin-top: 12px;
  font-size: 0.85rem;
  color: #dbeafe;
  text-align: center;
}
.platformer-question #platformer-q-text {
  font-size: 1.15rem;
  line-height: 1.35;
  text-align: center;
  margin-bottom: 14px;
  color: #f8fafc;
}
.platformer-question .choice-btn {
  background: linear-gradient(180deg, #3a8f2f 0%, #2f7c29 100%);
  border: 2px solid rgba(187, 247, 208, 0.45);
  color: #ecfccb;
  font-weight: 700;
  text-align: center;
}
.platformer-question .choice-btn:hover {
  background: linear-gradient(180deg, #4ea43d 0%, #327f2a 100%);
}
.action-hands {
  position: absolute;
  bottom: -8px;
  left: 0;
  right: 0;
  height: 82px;
  z-index: 4;
  pointer-events: none;
}
.hand {
  position: absolute;
  width: 120px;
  height: 65px;
  border-radius: 30px;
  background: linear-gradient(145deg, #dc2626, #991b1b);
  box-shadow: inset -8px -10px 0 rgba(17, 24, 39, 0.2);
}
.hand.left {
  left: 24px;
  transform: rotate(-16deg);
}
.hand.right {
  right: 24px;
  transform: rotate(16deg);
}

/* Teacher Dashboard */
.teacher-screen { padding: 24px; }
.teacher-header { margin-bottom: 24px; }
.teacher-header h1 { font-family: var(--font-display); font-size: 1.5rem; }
.teacher-header p { color: var(--color-primary); margin: 8px 0; }
.dashboard-summary, .dashboard-teks { margin-bottom: 32px; }
.dashboard-summary h2, .dashboard-teks h2 { font-size: 1.1rem; margin-bottom: 12px; }
.dashboard-card {
  background: var(--color-surface);
  padding: 20px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  border: 1px solid rgba(148, 163, 184, 0.18);
}
.dashboard-teks-grid { display: grid; gap: 12px; }
.dashboard-teks-grid .teks-card {
  background: var(--color-surface);
  padding: 16px;
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--color-primary);
  box-shadow: 0 4px 14px rgba(2, 6, 23, 0.35);
}
.dashboard-teks-grid .teks-card a {
  color: #7dd3fc;
  text-decoration: underline;
}

/* Accessibility */
.accessibility-bar {
  position: fixed;
  top: 8px;
  right: 8px;
  z-index: 9998;
  display: flex;
  gap: 8px;
  align-items: center;
}
.accessibility-bar button {
  min-width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--color-surface-light);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  font-size: 0.9rem;
}
.accessibility-bar button:hover { background: var(--color-surface-light); }
.accessibility-bar button.active { background: var(--color-primary); border-color: var(--color-primary); }
body.high-contrast { --color-bg: #000; --color-surface: #222; --color-text: #fff; --color-text-muted: #ccc; }
body.high-contrast .choice-btn { border: 2px solid #fff; }
.caption-display {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.9);
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  max-width: 90%;
  font-size: 1rem;
}
.iep-actions { display: flex; gap: 12px; margin-top: 16px; flex-wrap: wrap; }

/* Print styles for IEP */
@media print {
  .app .screen:not(#iep-report), #toast {
    display: none !important;
  }
  #iep-report {
    display: flex !important;
    padding: 0;
  }
  .iep-header button, #iep-export {
    display: none !important;
  }
  .iep-content {
    box-shadow: none;
    max-width: 100%;
  }
  body { background: #fff; color: #1e293b; }
}

/* Accessibility */
button:focus, input:focus, select:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Toast */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  padding: 16px 24px;
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  box-shadow: var(--shadow);
  max-width: 90%;
  text-align: center;
  animation: toastIn 0.3s ease;
}
.toast.hidden { display: none; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .screen {
    transition: none;
    transform: none;
    opacity: 1;
  }
  .confetti-piece {
    animation: none;
  }
}

/* Utilities */
.hidden { display: none !important; }

/* Responsive */
@media (max-width: 600px) {
  .choice-grid { grid-template-columns: 1fr; }
  .quest-cards { grid-template-columns: 1fr; }
  .platformer-screen { padding: 8px; }
  .platformer-question {
    right: 50%;
    transform: translateX(50%);
    top: 58px;
    width: calc(100% - 24px);
  }
  .platformer-hud .hud-item {
    font-size: 0.85rem;
    padding: 6px 8px;
  }
}
