@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Telugu:wght@400;700&display=swap');

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

:root {
  --bg-primary: #0d0d0d;
  --bg-secondary: #1a1a2e;
  --bg-card: #16213e;
  --bg-hover: #1f3460;
  --accent: #e94560;
  --accent-glow: rgba(233, 69, 96, 0.3);
  --text-primary: #eee;
  --text-secondary: #aaa;
  --text-muted: #666;
  --success: #4ecca3;
  --error: #ff6b6b;
  --border: #2a2a4a;
  --radius: 12px;
  --radius-sm: 8px;
  --font-telugu: 'Noto Sans Telugu', sans-serif;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ===== Layout ===== */
#app {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 80px;
}

.page { display: none; }
.page.active { display: block; animation: fadeIn 0.3s ease; }

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

/* ===== Header ===== */
header {
  margin-bottom: 24px;
}

header h1 {
  font-size: 2rem;
  background: linear-gradient(135deg, var(--accent), #ff8a5c);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 4px;
}

header h2 {
  font-size: 1.3rem;
  color: var(--text-primary);
}

/* ===== Back Button ===== */
.btn-back {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 1rem;
  cursor: pointer;
  padding: 8px 0;
  margin-bottom: 8px;
  display: inline-block;
}

.btn-back:hover { opacity: 0.8; }

/* ===== Lesson Grid ===== */
.lesson-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.lesson-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.lesson-card:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-glow);
}

.lesson-card .lesson-info h3 {
  font-size: 1.1rem;
  margin-bottom: 4px;
}

.lesson-card .lesson-info p {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.lesson-card .lesson-arrow {
  color: var(--text-muted);
  font-size: 1.2rem;
}

/* ===== Exercise Picker ===== */
.exercise-options {
  display: grid;
  gap: 16px;
}

.exercise-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  color: var(--text-primary);
  font-family: inherit;
}

.exercise-card:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-glow);
}

.exercise-icon { font-size: 2.5rem; }
.exercise-name { font-size: 1.1rem; font-weight: 600; }
.exercise-desc { font-size: 0.85rem; color: var(--text-secondary); }

/* ===== Word Display ===== */
.word-display {
  text-align: center;
  padding: 24px 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.telugu-word {
  font-family: var(--font-telugu);
  font-size: 2.2rem;
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.4;
}

.transliteration {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-style: italic;
  margin-bottom: 4px;
}

.english-meaning {
  color: var(--text-secondary);
  font-size: 1rem;
}

.hints-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

.hint-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}

.hint-btn:hover { background: var(--bg-hover); border-color: var(--accent); }

.hint-btn.revealed {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
  cursor: default;
  pointer-events: none;
  font-style: italic;
}

.progress-badge {
  background: var(--bg-card);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  float: right;
  margin-top: -28px;
}

/* ===== GIF Gallery (Snap Mode) ===== */
.gif-gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.gif-item {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 1;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s ease;
}

.gif-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gif-item.discarded::after {
  content: '✕';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--error);
}

.gif-item.locked {
  border-color: var(--success);
  box-shadow: 0 0 12px rgba(78, 204, 163, 0.4);
}

/* Post-evaluation overlays */
.gif-item.result-correct {
  border-color: var(--success);
}
.gif-item.result-correct::after {
  content: '✓';
  position: absolute;
  inset: 0;
  background: rgba(78, 204, 163, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.5rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}

.gif-item.result-wrong {
  border-color: var(--error);
}
.gif-item.result-wrong::after {
  content: 'Wrong';
  position: absolute;
  inset: 0;
  background: rgba(255, 107, 107, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}

.gif-item.result-missed {
  border-color: #f59e0b;
}
.gif-item.result-missed::after {
  content: 'Missed';
  position: absolute;
  inset: 0;
  background: rgba(245, 158, 11, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}

.gif-item.result-skipped {
  filter: brightness(0.35);
}

.gif-item.locked::after {
  content: '✓';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  background: var(--success);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: #000;
  font-weight: bold;
}

/* ===== Locked Area ===== */
.locked-area {
  min-height: 0;
  margin-bottom: 8px;
}

.locked-area:not(:empty) {
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-bottom: 12px;
}

.locked-area .gif-item {
  width: 80px;
  height: 80px;
  display: inline-block;
  margin: 4px;
}

/* ===== Navigation ===== */
.word-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
}

.btn-nav {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-nav:hover { background: var(--bg-hover); border-color: var(--accent); }
.btn-nav:disabled { opacity: 0.3; cursor: default; }

.word-counter {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ===== Results Overlay ===== */
.results-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.results-overlay.hidden { display: none; }

.results-content {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 32px 24px;
  max-width: 400px;
  width: 100%;
  text-align: center;
}

.results-content h2 {
  font-size: 1.5rem;
  margin-bottom: 20px;
}

.result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  background: var(--bg-card);
}

.result-item.correct { border-left: 3px solid var(--success); }
.result-item.incorrect { border-left: 3px solid var(--error); }
.result-item.wrong { border-left: 3px solid var(--error); }
.result-item.missed { border-left: 3px solid #eab308; }
.result-item.rightly-skipped { border-left: 3px solid var(--text-muted); opacity: 0.6; }

.result-item img {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
}

.result-item .result-text {
  text-align: left;
  font-size: 0.9rem;
}

.result-item .result-word {
  font-weight: 600;
}

.result-item .result-status {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.btn-primary {
  background: var(--accent);
  border: none;
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1rem;
  margin-top: 16px;
  font-family: inherit;
  transition: opacity 0.2s;
}

.btn-primary:hover { opacity: 0.9; }

.btn-next-round {
  display: block;
  width: 100%;
  margin-top: 12px;
}

/* ===== Fill in the Blanks ===== */
.blank-sentence {
  text-align: center;
  margin: 18px 0;
  line-height: 1.5;
  font-family: var(--font-telugu), -apple-system, sans-serif;
  font-size: 1.5rem;
  color: var(--text-primary);
}
.blank-marker {
  display: inline-block;
  min-width: 70px;
  border-bottom: 2px solid var(--accent);
  margin: 0 4px;
  vertical-align: bottom;
}
.blank-answer {
  color: var(--accent);
  font-weight: 700;
}

/* ===== Recall Mode ===== */
.recall-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.recall-gif {
  position: relative;
  width: 100%;
  max-width: 400px;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  border: 2px solid var(--border);
  transition: border-color 0.2s;
}

.recall-gif img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.recall-reveal {
  position: absolute;
  inset: 0;
  background: rgba(13, 13, 13, 0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  backdrop-filter: blur(4px);
}

.recall-reveal.hidden { display: none; }

.recall-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}

/* ===== Utilities ===== */
.hidden { display: none !important; }

/* ===== Touch & Mobile ===== */
@media (max-width: 480px) {
  #app { padding: 12px; }
  .telugu-word { font-size: 1.8rem; }
  .gif-gallery { gap: 8px; }
  .btn-nav { padding: 8px 14px; font-size: 0.85rem; }
}

/* ===== Swipe hint ===== */
@media (pointer: coarse) {
  .word-nav::after {
    content: 'Swipe to navigate';
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--text-muted);
    font-size: 0.7rem;
    opacity: 0;
    animation: fadeHint 3s ease 1s forwards;
  }
  .word-nav { position: relative; }
}

@keyframes fadeHint {
  0%, 80% { opacity: 0.6; }
  100% { opacity: 0; }
}
