/* ============================================
   FINTRO — style.css
   Fonts: Syne (UI) + Playfair Display (editorial)
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=Playfair+Display:wght@400;700&display=swap');

/* ── CSS Variables ── */
:root {
  --bg:        #0a0c10;
  --surface:   #12151c;
  --surface2:  #1a1e28;
  --border:    #ffffff12;
  --blue:      #3b82f6;
  --blue-dim:  #1d4ed8;
  --amber:     #f59e0b;
  --amber-dim: #b45309;
  --green:     #22c55e;
  --red:       #ef4444;
  --text:      #f1f5f9;
  --muted:     #64748b;
  --radius:    12px;
  --radius-lg: 20px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Syne', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 3px; }

/* ── Typography ── */
h1, h2, h3, h4 { font-family: 'Playfair Display', serif; line-height: 1.2; }
h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
h3 { font-size: 1.2rem; }
h4 { font-size: 1rem; }
p  { color: #94a3b8; font-size: 0.95rem; }

/* ── Utility ── */
.hidden { display: none !important; }
.flex   { display: flex; }
.gap-2  { gap: 0.5rem; }
.gap-4  { gap: 1rem; }

/* ══════════════════════════════════════
   SCREENS
══════════════════════════════════════ */
.screen {
  display: none;
  min-height: 100vh;
  padding: 1.5rem;
  max-width: 860px;
  margin: 0 auto;
  animation: fadeIn 0.35s ease;
}
.screen.active { display: block; }

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

/* ══════════════════════════════════════
   HOME SCREEN
══════════════════════════════════════ */
#home-screen {
  display: none;
  padding-top: 2rem;
}
#home-screen.active { display: block; }

/* Header bar */
.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2.5rem;
}
.logo {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.6rem;
  letter-spacing: -0.5px;
}
.logo span { color: var(--amber); }

/* XP Bar */
.xp-bar-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 0.4rem 1rem;
}
.xp-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--amber);
  letter-spacing: 1px;
}
.xp-track {
  width: 120px;
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
}
.xp-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--amber-dim), var(--amber));
  border-radius: 3px;
  transition: width 0.6s ease;
}
.xp-count {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

/* Hero */
.hero {
  margin-bottom: 2.5rem;
}
.hero h1 {
  margin-bottom: 0.75rem;
}
.hero h1 em {
  font-style: normal;
  color: var(--amber);
}
.hero p {
  font-size: 1rem;
  max-width: 540px;
}

/* Stats row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 2.5rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  text-align: center;
}
.stat-card .val {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--blue);
  display: block;
}
.stat-card .lbl {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Unit section */
.unit-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 1rem;
}
.unit-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.3rem;
  color: var(--text);
  margin-bottom: 1.25rem;
}

/* Chapter rows */
.chapter-list { display: flex; flex-direction: column; gap: 0.75rem; }

.chapter-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
  position: relative;
  overflow: hidden;
}
.chapter-row::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--blue);
  opacity: 0;
  transition: opacity 0.2s;
}
.chapter-row:hover {
  border-color: #ffffff25;
  transform: translateX(4px);
}
.chapter-row:hover::before { opacity: 1; }

.chapter-row.locked {
  opacity: 0.45;
  cursor: not-allowed;
}
.chapter-row.locked:hover { transform: none; }
.chapter-row.locked:hover::before { opacity: 0; }

.chapter-row.completed::before {
  background: var(--green);
  opacity: 1;
}

.ch-num {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 1px;
  min-width: 28px;
}
.ch-info { flex: 1; }
.ch-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}
.ch-sub {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
}
.ch-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  background: var(--surface2);
  color: var(--muted);
  white-space: nowrap;
}
.ch-badge.done {
  background: #22c55e18;
  color: var(--green);
}
.ch-badge.active {
  background: #3b82f618;
  color: var(--blue);
}

/* ══════════════════════════════════════
   CHAPTER SCREEN
══════════════════════════════════════ */
.chapter-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
}
.btn-back {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Syne', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.2s;
}
.btn-back:hover { background: var(--surface2); }

.chapter-meta {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* Tabs */
.tab-bar {
  display: flex;
  gap: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.3rem;
  margin-bottom: 2rem;
  width: fit-content;
}
.tab-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-family: 'Syne', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.45rem 1rem;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.5px;
}
.tab-btn.active {
  background: var(--blue);
  color: #fff;
}
.tab-btn:not(.active):hover { color: var(--text); }

/* Tab panels */
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.25s ease; }

/* Lesson content */
.lesson-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-bottom: 1.5rem;
}
.lesson-content h2 {
  margin-bottom: 1rem;
  color: var(--text);
}
.lesson-content p {
  margin-bottom: 1rem;
  line-height: 1.75;
}
.lesson-content .highlight {
  background: #3b82f612;
  border-left: 3px solid var(--blue);
  padding: 0.75rem 1rem;
  border-radius: 0 8px 8px 0;
  margin: 1rem 0;
  color: var(--text);
  font-size: 0.9rem;
}

/* ══════════════════════════════════════
   VOCABULARY CARDS
══════════════════════════════════════ */
.vocab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.vocab-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
  perspective: 600px;
}
.vocab-card:hover {
  border-color: var(--blue);
  transform: translateY(-3px);
}
.vocab-card .term {
  font-weight: 700;
  font-size: 1rem;
  color: var(--blue);
  margin-bottom: 0.5rem;
}
.vocab-card .def {
  font-size: 0.85rem;
  color: #94a3b8;
  line-height: 1.5;
}
.vocab-hint {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.75rem;
  color: var(--muted);
}

/* ══════════════════════════════════════
   QUIZ
══════════════════════════════════════ */
.quiz-wrap { max-width: 620px; }

.quiz-progress {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.quiz-dots {
  display: flex;
  gap: 6px;
}
.quiz-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--surface2);
  transition: background 0.3s;
}
.quiz-dot.done { background: var(--green); }
.quiz-dot.current { background: var(--blue); }

.quiz-question-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 1rem;
}
.quiz-q-num {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}
.quiz-q-text {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.5;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.quiz-option {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  cursor: pointer;
  font-family: 'Syne', sans-serif;
  font-size: 0.9rem;
  color: var(--text);
  text-align: left;
  transition: border-color 0.2s, background 0.2s;
}
.quiz-option:hover:not(:disabled) {
  border-color: var(--blue);
  background: #3b82f610;
}
.quiz-option.correct {
  border-color: var(--green);
  background: #22c55e15;
  color: var(--green);
}
.quiz-option.wrong {
  border-color: var(--red);
  background: #ef444415;
  color: var(--red);
}
.quiz-option:disabled { cursor: default; }

.quiz-feedback {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 1rem;
}
.quiz-feedback.correct {
  background: #22c55e15;
  color: var(--green);
  border: 1px solid #22c55e30;
}
.quiz-feedback.wrong {
  background: #ef444415;
  color: var(--red);
  border: 1px solid #ef444430;
}

.btn-primary {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 0.75rem 1.5rem;
  font-family: 'Syne', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  letter-spacing: 0.5px;
}
.btn-primary:hover { background: var(--blue-dim); }
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.4; cursor: default; }

.quiz-result {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  text-align: center;
}
.quiz-result .score-big {
  font-size: 3rem;
  font-weight: 800;
  color: var(--amber);
  display: block;
  margin-bottom: 0.5rem;
}
.quiz-result p { margin-bottom: 1.25rem; }

/* ══════════════════════════════════════
   GAME SCENARIO HIGHLIGHT
══════════════════════════════════════ */
.game-scenario {
  background: rgba(245,158,11,.07);
  border-left: 3px solid var(--amber);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}
.game-scenario-label {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: .5rem;
}
.game-scenario-text {
  font-size: .9rem;
  color: var(--text);
  line-height: 1.75;
}

/* ══════════════════════════════════════
   GAMES — shared
══════════════════════════════════════ */
.game-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
}
.game-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.3rem;
  color: var(--text);
  margin-bottom: 0.4rem;
}
.game-desc {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
}
.game-score {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface2);
  border-radius: 50px;
  padding: 0.3rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--amber);
  margin-bottom: 1.25rem;
}

/* Barter Market game */
.barter-board {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.25rem;
}
.barter-col { display: flex; flex-direction: column; gap: 0.5rem; }
.barter-col h4 {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}
.barter-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  cursor: pointer;
  font-size: 0.85rem;
  transition: border-color 0.2s;
}
.barter-item:hover { border-color: var(--blue); }
.barter-item.selected { border-color: var(--amber); background: #f59e0b12; }
.barter-arrow { font-size: 1.5rem; color: var(--muted); text-align: center; }
.barter-log {
  background: var(--bg);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  color: var(--muted);
  min-height: 60px;
  line-height: 1.6;
}

/* Time Machine (compound interest chart) */
.tm-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.tm-control label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 0.35rem;
  letter-spacing: 0.5px;
}
.tm-control input[type="range"] {
  width: 100%;
  accent-color: var(--blue);
}
.tm-val {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--blue);
}
.tm-chart {
  width: 100%;
  height: 200px;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1rem;
}
.tm-summary {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.tm-stat {
  background: var(--surface2);
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  font-size: 0.8rem;
}
.tm-stat span {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
}
.tm-stat strong { color: var(--green); }

/* Income Streams */
.income-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.income-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
  text-align: center;
}
.income-card:hover { border-color: var(--blue); transform: translateY(-2px); }
.income-card.active { border-color: var(--amber); background: #f59e0b10; }
.income-card .ic-emoji { font-size: 1.75rem; display: block; margin-bottom: 0.5rem; }
.income-card .ic-name { font-size: 0.8rem; font-weight: 700; color: var(--text); }
.income-card .ic-earn {
  font-size: 0.7rem;
  color: var(--green);
  margin-top: 0.2rem;
}
.income-total {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.income-total .lbl { font-size: 0.8rem; color: var(--muted); }
.income-total .amount {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--amber);
}

/* ══════════════════════════════════════
   XP TOAST
══════════════════════════════════════ */
.xp-toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--surface);
  border: 1px solid var(--amber);
  border-radius: 10px;
  padding: 0.75rem 1.25rem;
  font-weight: 700;
  color: var(--amber);
  font-size: 0.9rem;
  z-index: 1000;
  opacity: 0;
  transform: translateY(12px);
  transition: all 0.35s ease;
  pointer-events: none;
}
.xp-toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ══════════════════════════════════════
   RESPONSIVE — MOBILE FIRST
══════════════════════════════════════ */

/* Tablet */
@media (max-width: 768px) {
  .screen { padding: 1.25rem; }
  .tm-controls { grid-template-columns: 1fr; }
  .income-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Mobile */
@media (max-width: 600px) {
  .screen { padding: 1rem 0.9rem; }

  /* Home header */
  .home-header { flex-direction: column; align-items: flex-start; gap: 1rem; }
  .xp-bar-wrap { width: 100%; justify-content: space-between; }
  .xp-track { flex: 1; }

  /* Hero */
  .hero h1 { font-size: 1.9rem; }
  .hero p { font-size: 0.9rem; }

  /* Stats */
  .stats-row { gap: 0.6rem; }
  .stat-card { padding: 0.75rem 0.5rem; }
  .stat-card .val { font-size: 1.3rem; }
  .stat-card .lbl { font-size: 0.6rem; }

  /* Chapters */
  .chapter-row { padding: 0.85rem 1rem; gap: 0.75rem; }
  .ch-title { font-size: 0.88rem; }
  .ch-sub { font-size: 0.7rem; }
  .ch-xp { display: none; }

  /* Tabs — full width grid */
  .tab-bar { width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); }
  .tab-btn { font-size: 0.65rem; padding: 0.4rem 0.2rem; text-align: center; }

  /* Lesson */
  .lesson-content { padding: 1.25rem; }
  .lesson-content h2 { font-size: 1.3rem; }

  /* Vocab */
  .vocab-grid { grid-template-columns: 1fr; }

  /* Quiz */
  .quiz-wrap { max-width: 100%; }
  .quiz-question-box { padding: 1.25rem; }
  .quiz-q-text { font-size: 0.95rem; }
  .quiz-option { padding: 0.8rem 0.9rem; font-size: 0.83rem; }

  /* Games */
  .game-wrap { padding: 1.25rem; }
  .barter-board { grid-template-columns: 1fr; }
  .barter-arrow { display: none; }
  .tm-controls { grid-template-columns: 1fr; }
  .twin-controls { grid-template-columns: 1fr; }
  .bc-controls { grid-template-columns: 1fr; }
  .income-grid { grid-template-columns: repeat(2, 1fr); }
  
  /* Game buttons - bigger touch targets */
  .game-wrap button { min-height: 44px; font-size: 0.85rem; }
  
  /* Sliders - bigger thumb */
  input[type="range"] { height: 8px; }
  
  /* Phase cards */
  .phase-cards { grid-template-columns: 1fr; }

  /* Unit title */
  .unit-title { font-size: 1.1rem; }
}

/* Very small phones */
@media (max-width: 380px) {
  .hero h1 { font-size: 1.6rem; }
  .hero p { font-size: 0.85rem; }
  .tab-btn { font-size: 0.6rem; padding: 0.35rem 0.15rem; }
  .quiz-q-text { font-size: 0.88rem; }
  .chapter-row { padding: 0.7rem 0.85rem; }
}
