/* LingoGist — Mobile-first design system */

:root {
  --color-bg: #f8f9fa;
  --color-surface: #ffffff;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-text: #1a1c1e;
  --color-text-secondary: #6b7280;
  --color-text-muted: #9ca3af;
  --color-border: #e5e7eb;
  --color-success: #059669;
  --color-warning: #d97706;
  --color-danger: #dc2626;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-optical-sizing: auto;
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* App shell */
.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Navigation */
.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.nav-brand-wordmark {
  height: 18px;
}

.nav-links {
  display: flex;
  gap: 4px;
}

.nav-link {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-secondary);
  transition:
    background 0.15s,
    color 0.15s;
}

.nav-link:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.nav-link.active {
  background: var(--color-primary);
  color: #fff;
}

/* Main content */
.main-content {
  flex: 1;
}

.page-container {
  max-width: 600px;
  margin: 0 auto;
  padding: 24px 16px;
}

/* Feed */
.feed-container {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
}

.feed-loading {
  text-align: center;
  padding: 48px 16px;
  color: var(--color-text-muted);
}

.feed-loading::before {
  content: '';
  display: block;
  width: 32px;
  height: 32px;
  margin: 0 auto 16px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Passage card */
.passage-card {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  padding-bottom: 48px;
  margin-bottom: 16px;
}

.passage-context {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 12px;
  margin-bottom: 12px;
  font-style: italic;
}

.passage-lang {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--color-bg);
  color: var(--color-text-secondary);
  margin-bottom: 8px;
}

.passage-text {
  font-size: 18px;
  line-height: 1.7;
  color: var(--color-text);
}

.passage-text .word {
  cursor: pointer;
  border-radius: 3px;
  transition: background 0.15s;
}

.passage-text .word:hover {
  background: #dbeafe;
}

.passage-text .word.tapped {
  background: #bfdbfe;
}

/* Hint button (hides context line to avoid spoiling probes) */
.hint-btn {
  display: inline-block;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-muted);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  cursor: pointer;
  font-family: inherit;
  margin-top: 12px;
  margin-bottom: 8px;
  transition:
    background 0.15s,
    color 0.15s;
}

.hint-btn:hover {
  background: #e5e7eb;
  color: var(--color-text-secondary);
}

.feedback-anchor {
  position: absolute;
  right: 16px;
  bottom: 12px;
}

.feedback-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  color: var(--color-text-muted);
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.feedback-btn:hover { color: var(--color-text-secondary); background: var(--color-bg); }
.feedback-btn:disabled { cursor: default; color: var(--color-success); border-color: var(--color-success); }

.feedback-popup {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  flex-direction: column;
  gap: 4px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 6px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
  z-index: 150;
  min-width: 160px;
}

.feedback-option {
  display: block;
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--color-text);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background 0.15s;
}

.feedback-option:hover { background: var(--color-bg); }

.passage-translation {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--color-bg);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--color-primary);
  line-height: 1.5;
}

.passage-romanization {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-top: 8px;
  font-style: italic;
  line-height: 1.6;
}

/* Word popup */
.word-popup {
  position: fixed;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
  z-index: 200;
  max-width: 280px;
  font-size: 14px;
}

.word-popup-word {
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 4px;
}

.word-popup-root {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

.word-popup-romanization {
  font-size: 12px;
  color: var(--color-primary);
  font-style: italic;
  margin-bottom: 4px;
}

.word-popup-meaning {
  color: var(--color-text-secondary);
}

/* Probe card */
.probe-card {
  background: var(--color-surface);
  border: 2px solid var(--color-primary);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}

.probe-question {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
}

.probe-option {
  display: block;
  width: 100%;
  padding: 12px 16px;
  margin-bottom: 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  font-family: inherit;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s;
}

.probe-option:hover {
  border-color: var(--color-primary);
  background: #eff6ff;
}

.probe-option.correct {
  border-color: var(--color-success);
  background: #d1fae5;
}

.probe-option.incorrect {
  border-color: var(--color-danger);
  background: #fee2e2;
}

/* Gist check probe (yes/no) */
.gist-check-card {
  text-align: center;
}

.gist-check-buttons {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 12px;
}

.gist-check-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  font-size: 24px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  font-family: inherit;
}

.gist-check-btn:hover { transform: scale(1.05); }
.gist-check-btn:disabled { cursor: default; transform: none; }

.gist-yes { color: var(--color-success); }
.gist-yes:hover { border-color: var(--color-success); background: #d1fae5; }
.gist-yes-selected { border-color: var(--color-success); background: #d1fae5; }

.gist-no { color: var(--color-danger); }
.gist-no:hover { border-color: var(--color-danger); background: #fee2e2; }
.gist-no-selected { border-color: var(--color-danger); background: #fee2e2; }

/* Self-assessment probe */
.self-assess-card { text-align: center; }
.self-assess-options { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.self-assess-btn {
  padding: 10px 16px; border: 1px solid var(--color-border); border-radius: var(--radius-md);
  background: var(--color-surface); font-family: inherit; font-size: 15px; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.self-assess-btn:hover { border-color: var(--color-primary); background: #eff6ff; }
.self-assess-btn:disabled { cursor: default; }
.self-assess-selected { border-color: var(--color-primary); background: #dbeafe; font-weight: 600; }

.probe-skip {
  display: block;
  width: 100%;
  padding: 8px;
  margin-top: 4px;
  border: none;
  background: none;
  color: var(--color-text-muted);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.15s;
}

.probe-skip:hover {
  color: var(--color-text-secondary);
}

/* Welcome back card */
.welcome-back-card {
  background: linear-gradient(135deg, #eff6ff, #f0f9ff);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  text-align: center;
}

.welcome-back-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 4px;
}

.welcome-back-subtitle {
  font-size: 15px;
  color: var(--color-text-secondary);
}

/* Feed sections */
.feed-section {
  margin-bottom: 8px;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--color-primary-hover);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text);
}

.btn-outline:hover {
  background: var(--color-bg);
}

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
}

.alert-danger {
  background: #fee2e2;
  color: var(--color-danger);
  border: 1px solid #fecaca;
}

/* "Try This" card */
.try-this-card {
  background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}

.try-this-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-success);
  margin-bottom: 8px;
}

.try-this-phrase {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}

.try-this-meaning {
  font-size: 15px;
  color: var(--color-text-secondary);
  margin-bottom: 12px;
}

.try-this-suggestion {
  font-size: 14px;
  color: var(--color-text);
  font-style: italic;
}

/* Progress page */
.reading-streak {
  font-size: 15px;
  color: var(--color-text-secondary);
  margin-bottom: 20px;
}

.progress-summary {
  display: flex;
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  flex: 1;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--color-primary);
}

.stat-label {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-top: 4px;
}

.lang-progress {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}

.lang-progress-title {
  font-size: 18px;
  margin-bottom: 12px;
}

.vocab-bar {
  display: flex;
  height: 24px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--color-bg);
  margin-bottom: 12px;
}

.vocab-bar-segment {
  transition: width 0.3s;
  min-width: 0;
}

.vocab-bar-segment.stable {
  background: #059669;
}
.vocab-bar-segment.familiar {
  background: #2563eb;
}
.vocab-bar-segment.acquiring {
  background: #d97706;
}
.vocab-bar-segment.encountered {
  background: #d1d5db;
}

.vocab-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.legend-dot.stable {
  background: #059669;
}
.legend-dot.familiar {
  background: #2563eb;
}
.legend-dot.acquiring {
  background: #d97706;
}
.legend-dot.encountered {
  background: #d1d5db;
}

.vocab-total {
  font-size: 14px;
  color: var(--color-text-muted);
}

/* Utility */
code {
  background: var(--color-bg);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}
