/* ── Shared quiz interaction styles ──
 * Used by both /quiz/[slug] and /challenge/[token].
 */

.quiz-main {
  max-width: 520px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
  color: var(--ink);
}

/* ── Quiz flow wrapper ── */

.quiz-flow {
  width: 100%;
  max-width: 520px;
}

/* ── Phases ── */

.quiz-phase {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
}

/* ── Intro / shared intro layout ── */

.quiz-intro {
  align-items: center;
  justify-content: center;
  text-align: center;
}

.quiz-intro .back-link {
  align-self: flex-start;
  margin-bottom: 2rem;
}

.quiz-intro-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.quiz-intro-card h1 {
  font-size: 1.75rem;
  margin: 0;
}

.quiz-intro-count {
  font-size: 1rem;
  color: var(--muted);
  margin: 0;
}

/* ── Progress bar ── */

.quiz-progress-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.quiz-progress-text {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

.quiz-progress-track {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}

/* ── Word card ── */

.quiz-word-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  padding: 2.5rem 1.5rem;
  text-align: center;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  height: 18rem;
  overflow: hidden;
}

.quiz-word {
  font-size: 2rem;
  font-weight: 700;
  margin: 0;
}

.quiz-word-card .def-flag-wrap {
  max-width: 100%;
}

.quiz-definition {
  font-size: 1rem;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
  position: relative;
  overflow: hidden;
  overflow-wrap: break-word;
  transition: color 0.2s ease 0.15s;
}

.quiz-definition::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--surface);
  border-radius: 4px;
  transform: translateX(-105%);
  transition: transform 0.35s ease;
  pointer-events: none;
}

.quiz-definition.hidden {
  color: transparent;
  transition: none;
}

.quiz-definition.hidden::after {
  transform: translateX(0);
}

.quiz-sentence-toggle {
  background: none;
  border: none;
  font: inherit;
  font-size: 0.8125rem;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.quiz-sentence-toggle:hover {
  opacity: 0.8;
}

.quiz-sentence {
  font-size: 0.875rem;
  color: var(--sentence, var(--muted));
  line-height: 1.5;
  font-style: italic;
  margin: 0;
  animation: fadeIn 0.2s ease;
}

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

@keyframes cardSlideIn {
  from { opacity: 0.6; transform: translateX(8px); }
  to { opacity: 1; transform: translateX(0); }
}

.quiz-card-enter {
  animation: cardSlideIn 0.2s ease;
}

/* ── Button area (fixed height prevents shift between question/reveal) ── */

.quiz-btn-area {
  height: 3.25rem;
  position: relative;
}

.quiz-btn-area .quiz-actions {
  position: absolute;
  inset: 0;
}

/* ── Action buttons ── */

.quiz-actions {
  display: flex;
  gap: 0.5rem;
}

.quiz-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.25rem;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
}

.quiz-action-btn:hover {
  background: var(--panel);
}

.quiz-action-btn:active {
  transform: scale(0.98);
}

.quiz-action-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.quiz-action-btn.primary:hover {
  opacity: 0.9;
  background: var(--accent);
}

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

.quiz-action-full {
  width: 100%;
}

.quiz-answer-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.quiz-btn-got {
  background: color-mix(in srgb, #22c55e 12%, var(--surface)) !important;
  border-color: #22c55e !important;
  color: #16a34a !important;
  font-weight: 600;
}

.quiz-btn-got:hover {
  background: color-mix(in srgb, #22c55e 20%, var(--surface)) !important;
}

.quiz-btn-got:active {
  background: #22c55e !important;
  color: white !important;
}

.quiz-btn-miss {
  background: color-mix(in srgb, #ef4444 12%, var(--surface)) !important;
  border-color: #ef4444 !important;
  color: #dc2626 !important;
  font-weight: 600;
}

.quiz-btn-miss:hover {
  background: color-mix(in srgb, #ef4444 20%, var(--surface)) !important;
}

.quiz-btn-miss:active {
  background: #ef4444 !important;
  color: white !important;
}

/* ── Result screen ── */

.quiz-result {
  align-items: center;
  text-align: center;
}

.quiz-result h1 {
  font-size: 1.375rem;
  margin: 0 0 0.5rem;
}

.quiz-score-big {
  font-size: 2.5rem;
  font-weight: 700;
  margin: 0;
  color: var(--accent);
}

.quiz-score-pct {
  font-size: 1.125rem;
  color: var(--muted);
  margin: 0 0 0.25rem;
}

.quiz-best {
  font-size: 0.8125rem;
  color: var(--muted);
  margin: 0 0 1rem;
}

.quiz-result-hint {
  font-size: 0.875rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}

/* ── Breakdown ── */

.quiz-breakdown {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1.5rem;
  text-align: left;
}

.quiz-result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}

.quiz-result-row:last-child {
  border-bottom: none;
}

.quiz-result-row.missed {
  background: color-mix(in srgb, #ef4444 6%, var(--panel));
}

.quiz-result-content {
  flex: 1;
  min-width: 0;
}

.quiz-result-word {
  font-weight: 500;
}

.quiz-result-def {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
  margin-top: 0.15rem;
}

.quiz-result-def.def-hover-only {
  opacity: 0;
  transition: opacity 0.15s;
}

.quiz-breakdown:hover .quiz-result-def.def-hover-only {
  opacity: 1;
}

.quiz-breakdown.per-row-hover:hover .quiz-result-def.def-hover-only {
  opacity: 0;
}

.quiz-breakdown.per-row-hover .quiz-result-row:hover .quiz-result-def.def-hover-only {
  opacity: 1;
}

.quiz-unlearn-btn {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  margin-right: 0.5rem;
}

.quiz-unlearn-btn:hover {
  border-color: var(--muted);
  color: var(--ink);
}

.quiz-result-icon {
  font-size: 1rem;
  font-weight: 700;
}

.quiz-result-row:not(.missed) .quiz-result-icon {
  color: #16a34a;
}

.quiz-result-row.missed .quiz-result-icon {
  color: #dc2626;
}

/* ── Share modal: link + divider ── */

.quiz-share-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.25rem 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.quiz-share-divider::before,
.quiz-share-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.quiz-share-link-box {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.quiz-share-link {
  flex: 1;
  font-size: 0.8rem;
  cursor: text;
}

.quiz-share-link-box button {
  flex-shrink: 0;
  white-space: nowrap;
}

/* ── Result actions ── */

.quiz-result-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

/* ── Share form inputs ── */

.quiz-share-input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font: inherit;
  font-size: 0.9375rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  box-sizing: border-box;
}


.quiz-share-subtitle {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0 0 1rem;
}

.name-hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0;
}

.quiz-share-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.quiz-share-signin {
  text-align: center;
  padding: 0.75rem 0 0.25rem;
}

.quiz-signin-btn {
  display: block;
  text-decoration: none;
  text-align: center;
  border: 1.5px solid var(--accent);
  color: var(--accent);
  background: transparent;
}

.quiz-signin-btn:hover {
  background: var(--accent);
  color: #fff;
}

.quiz-share-signin p {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0.5rem 0 0;
  line-height: 1.5;
}


.quiz-share-error {
  font-size: 0.85rem;
  color: var(--warn, #ef4444);
  margin: 0;
}

.quiz-share-success {
  font-size: 0.9rem;
  color: #16a34a;
  margin: 0 0 1rem;
  line-height: 1.5;
}

/* ── Keyboard hints ── */

.quiz-hints {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 1rem;
  justify-content: center;
  min-height: 1.5rem;
}

.quiz-hint {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

/* Show swipe hint on touch, keyboard hint on hover devices */
.quiz-hint-touch { display: none; }

@media (hover: none) {
  .quiz-hint-keyboard { display: none !important; }
  .quiz-hint-touch { display: inline-flex; }
}

.quiz-hints kbd {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  font-family: inherit;
  font-size: 0.6875rem;
  line-height: 1.4;
}

/* ── Triage intro overlay ── */

.quiz-card-wrap {
  position: relative;
}

.quiz-intro-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: 12px 12px 0 0;
  cursor: pointer;
}

.quiz-intro-overlay-card {
  background: var(--panel);
  border-radius: 0.75rem;
  padding: 1.75rem 1.5rem 1.25rem;
  max-width: 20rem;
  width: calc(100% - 2rem);
  text-align: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  cursor: default;
}

.quiz-intro-heading {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 0.75rem;
}

.quiz-intro-hint {
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--muted);
  margin: 0 0 1rem;
}

.quiz-intro-hints {
  list-style: none;
  padding: 0;
  margin: 0 0 1.25rem;
  text-align: left;
}

.quiz-intro-hints li {
  position: relative;
  padding-left: 1.5rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.quiz-intro-hints li::before {
  content: '\2605';
  position: absolute;
  left: 0;
  color: var(--accent, #6366f1);
  font-size: 0.7rem;
  top: 0.2rem;
}

.quiz-intro-start {
  display: inline-block;
  padding: 0.75rem 3rem;
  border: 1.5px solid var(--accent, #6366f1);
  border-radius: 2rem;
  background: transparent;
  color: var(--accent, #6366f1);
  font-size: 1.125rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.quiz-intro-start:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.has-word-prompt .quiz-word {
  position: relative;
}

.has-word-prompt .quiz-word::before {
  content: 'Do you know\2026?';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--muted);
  white-space: nowrap;
  padding-bottom: 0.35rem;
  transition: opacity 0.15s;
  pointer-events: none;
}

.has-word-prompt.prompt-hidden .quiz-word::before {
  opacity: 0;
}

/* ── Triage skip ── */

.triage-skip {
  display: block;
  margin: 1.5rem auto 0;
  background: none;
  border: none;
  font: inherit;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s;
  text-align: center;
}

.triage-skip:hover {
  color: var(--ink);
}

/* ── Leaderboard (shared by challenge + quiz chooser) ── */

.ch-leaderboard {
  width: 100%;
  max-width: 420px;
  margin: 1rem auto;
}

.ch-lb-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ch-lb-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  font-size: 0.9rem;
}

.ch-lb-row.ch-lb-you {
  background: var(--accent-bg, rgba(99, 102, 241, 0.08));
  font-weight: 600;
}

.ch-lb-rank {
  width: 1.5rem;
  text-align: center;
  font-weight: 600;
  color: var(--muted);
  flex-shrink: 0;
}

.ch-lb-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ch-lb-tag {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 400;
}

.ch-lb-you-tag {
  color: var(--accent, #6366f1);
  font-weight: 500;
}

.ch-lb-score {
  font-weight: 600;
  white-space: nowrap;
}

.ch-lb-pct {
  width: 3rem;
  text-align: right;
  color: var(--muted);
  font-size: 0.85rem;
  flex-shrink: 0;
}

/* ── Mobile ── */

@media (max-width: 640px) {
  .quiz-main {
    padding: 1rem 0.75rem 2rem;
  }

  .quiz-word {
    font-size: 1.75rem;
  }

  .quiz-word-card {
    padding: 2rem 1.25rem;
    height: 16rem;
  }

  .quiz-action-btn {
    padding: 1rem 1rem;
  }

  .quiz-btn-area {
    height: 3.75rem;
  }

  .quiz-hints {
    display: none;
  }
}
