/* ============================================================
   VocabFlow — Forgetting Curve Vocabulary Trainer
   Warm bookish theme, scoped to .vf-ui
   ============================================================ */

/* Override --color-bg at :root so html element resolves to warm cream too —
   without this, html stays dark navy and shows on iOS rubber-band scroll.
   Body-scope override exists below but doesn't cascade to html. */
:root {
  --color-bg: #fcfaf6;
}

/* --- Page-level overrides (light warm theme) --- */
.forgetting-curve-vocab-page {
  --color-bg: #fcfaf6;
  --color-surface: #fff;
  --color-text: #1a1714;
  --color-text-muted: #6b6259;
  /* Explicit chrome ink mapping so shared header/footer text is readable
     on this warm-cream theme. The chrome rules already fall back to
     --color-text, so this is belt-and-braces for any future edits that
     might reset --color-text on a deeper element. */
  --chrome-ink: #1a1714;
  --chrome-ink-muted: #6b6259;
  background: #fcfaf6;
}
.forgetting-curve-vocab-page .tool-frame {
  max-width: 960px;
  position: relative;
}
.forgetting-curve-vocab-page .tool-ui {
  max-width: 780px;
  margin-inline: auto;
  width: 100%;
}
.forgetting-curve-vocab-page .tool-discovery__grid {
  align-items: start;
}
.forgetting-curve-vocab-page .tool-discovery__card {
  min-height: 0;
}
.forgetting-curve-vocab-page .tool-header-block {
  text-align: center;
  max-width: 620px;
  justify-self: center;
  width: 100%;
}
.forgetting-curve-vocab-page .page-title {
  font-family: 'Newsreader', Georgia, serif;
  color: #1a1714;
  max-width: none;
  font-size: clamp(1.8rem, 5vw, 2.6rem);
}
.forgetting-curve-vocab-page .page-subtitle {
  color: #6b6259;
  max-width: none;
  justify-self: center;
}
/* Language toggle — pill anchored to tool-frame top-right */
.vf-lang-toggle {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border: 1px solid #d5cfc6;
  border-radius: 999px;
  background: #fff;
  color: #1a1714;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
  z-index: 2;
}
.vf-lang-toggle:hover {
  border-color: #a69e93;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

/* --- Local design tokens --- */
.vf-ui {
  --vf-bg: #fcfaf6;
  --vf-white: #fff;
  --vf-cream: #f5f1eb;
  --vf-sand: #e8e0d4;
  --vf-ink: #1a1714;
  --vf-ink2: #3d3832;
  --vf-ink3: #6b6259;
  --vf-ink4: #9c9184;
  --vf-ink5: #c4b9ab;
  --vf-blue: #2563eb;
  --vf-blue-s: rgba(37, 99, 235, 0.07);
  --vf-blue-m: rgba(37, 99, 235, 0.15);
  --vf-coral: #e05a3a;
  --vf-coral-s: rgba(224, 90, 58, 0.07);
  --vf-coral-m: rgba(224, 90, 58, 0.15);
  --vf-green: #16a34a;
  --vf-green-s: rgba(22, 163, 74, 0.07);
  --vf-bdr: rgba(26, 23, 20, 0.06);
  --vf-bdr2: rgba(26, 23, 20, 0.1);
  --vf-r: 14px;
  --vf-rs: 10px;
  --vf-rxs: 6px;
  --vf-sh: 0 1px 8px rgba(26, 23, 20, 0.05);
  --vf-sh2: 0 4px 20px rgba(26, 23, 20, 0.07);

  font-family: 'Manrope', 'Noto Sans TC', sans-serif;
  color: var(--vf-ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* --- Section titles --- */
.vf-section-title {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
  color: var(--vf-ink);
}
.vf-section-sub {
  font-size: 14px;
  color: var(--vf-ink3);
  margin-bottom: 24px;
  line-height: 1.7;
}

/* ===== STATS BAR ===== */
.vf-stats {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.vf-stat {
  flex: 1;
  background: var(--vf-white);
  border: 1px solid var(--vf-bdr);
  border-radius: var(--vf-rxs);
  padding: 12px 8px;
  text-align: center;
}
.vf-stat-n {
  font-family: 'Newsreader', serif;
  font-size: 24px;
  font-weight: 600;
  line-height: 1;
}
.vf-stat:nth-child(1) .vf-stat-n { color: var(--vf-green); }
.vf-stat:nth-child(2) .vf-stat-n { color: var(--vf-coral); }
.vf-stat:nth-child(3) .vf-stat-n { color: var(--vf-blue); }
.vf-stat-l {
  font-size: 9.5px;
  color: var(--vf-ink4);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-top: 2px;
}

/* ===== STREAK ===== */
.vf-streak {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--vf-white);
  border: 1px solid var(--vf-bdr);
  border-radius: var(--vf-rxs);
  padding: 10px 14px;
  margin-bottom: 12px;
}
.vf-streak-icon { font-size: 18px; }
.vf-streak-text {
  flex: 1;
  font-size: 12px;
  color: var(--vf-ink3);
}
.vf-streak-text b { color: var(--vf-ink); }
.vf-streak-days { display: flex; gap: 3px; }
.vf-sd {
  width: 8px;
  height: 8px;
  border-radius: 3px;
  background: var(--vf-sand);
}
.vf-sd.on {
  background: var(--vf-green);
  box-shadow: 0 0 4px rgba(22, 163, 74, 0.3);
}

/* ===== CONTROLS ===== */
.vf-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}
.vf-level-btns { display: flex; gap: 5px; }
.vf-lv {
  padding: 10px 14px;
  border-radius: 99px;
  border: 1px solid var(--vf-bdr);
  background: var(--vf-white);
  font-size: 11.5px;
  font-family: inherit;
  font-weight: 500;
  color: var(--vf-ink3);
  cursor: pointer;
  transition: all 0.2s;
  min-height: 44px;
}
.vf-lv:hover { border-color: var(--vf-blue); color: var(--vf-blue); }
.vf-lv.on { background: var(--vf-ink); color: var(--vf-bg); border-color: var(--vf-ink); }
.vf-counter {
  font-size: 12px;
  color: var(--vf-ink4);
  font-variant-numeric: tabular-nums;
}

/* ===== FLASHCARD ===== */
.vf-card {
  background: var(--vf-white);
  border: 1px solid var(--vf-bdr);
  border-radius: var(--vf-r);
  box-shadow: var(--vf-sh2);
  overflow: hidden;
  margin-bottom: 16px;
  animation: vf-cardIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes vf-cardIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
.vf-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}
.vf-badge {
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
/* Topic icon hero */
.vf-card-hero {
  display: flex;
  justify-content: center;
  padding: 16px 24px 0;
}
.vf-topic-icon {
  width: 44px;
  height: 44px;
  opacity: 0.85;
}
.vf-badge.a1 { background: var(--vf-green-s); color: var(--vf-green); }
.vf-badge.a2 { background: var(--vf-blue-s); color: var(--vf-blue); }
.vf-badge.b1 { background: rgba(184, 149, 106, 0.12); color: #8b6d3f; }
.vf-badge.b2 { background: var(--vf-coral-s); color: var(--vf-coral); }
.vf-topic { font-size: 11px; color: var(--vf-ink4); }

.vf-body { padding: 8px 24px 24px; }
.vf-word-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 2px;
}
.vf-word {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 40px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.vf-audio {
  width: 36px;
  height: 36px;
  border-radius: 99px;
  border: 1px solid var(--vf-bdr);
  background: var(--vf-cream);
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 4px;
  min-height: 0;
}
.vf-audio--inline { margin-left: auto; margin-bottom: 0; }
.vf-audio:hover {
  background: var(--vf-coral-s);
  border-color: var(--vf-coral);
  transform: scale(1.06);
}
.vf-audio:active { transform: scale(0.94); }
.vf-audio.playing {
  background: var(--vf-coral);
  border-color: var(--vf-coral);
  color: #fff;
  animation: vf-pulse 0.8s ease infinite;
}
@keyframes vf-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(224, 90, 58, 0.3); }
  50% { box-shadow: 0 0 0 8px rgba(224, 90, 58, 0); }
}
.vf-phonetic { font-size: 14px; color: var(--vf-ink4); font-weight: 300; margin-bottom: 2px; }
.vf-pos { font-size: 12px; color: var(--vf-ink5); font-style: italic; margin-bottom: 20px; }

/* Answer zone */
.vf-answer { min-height: 32px; margin-bottom: 20px; }
.vf-answer-placeholder {
  padding: 10px 18px;
  color: var(--vf-ink5);
  font-size: 12px;
  text-align: center;
}
/* Masked word in example */
.vf-masked {
  color: var(--vf-coral);
  font-weight: 600;
  border-bottom: 2px dashed var(--vf-coral-m);
  letter-spacing: 2px;
}
.vf-answer-show {
  padding: 14px 18px;
  background: var(--vf-blue-s);
  border-radius: var(--vf-rxs);
  border-left: 3px solid var(--vf-blue);
  animation: vf-revealSlide 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes vf-revealSlide {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: none; }
}
.vf-zh { font-size: 20px; font-weight: 600; margin-bottom: 2px; }
.vf-en { font-size: 13px; color: var(--vf-ink2); }
/* English mode: en is primary (large), zh is secondary reference */
.vf-en.vf-en--primary { font-size: 18px; font-weight: 600; color: var(--vf-ink1); margin-bottom: 2px; }
.vf-zh.vf-zh--ref { font-size: 13px; font-weight: 400; color: var(--vf-ink3); }
.vf-col { margin-top: 8px; font-size: 12px; color: var(--vf-ink3); line-height: 1.6; }
.vf-col strong { color: var(--vf-ink2); }
.vf-tip {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--vf-ink3);
  background: var(--vf-cream);
  padding: 8px 12px;
  border-radius: var(--vf-rxs);
  line-height: 1.5;
}

/* Sentence */
.vf-ctx {
  background: var(--vf-cream);
  border-radius: var(--vf-rs);
  padding: 16px 18px;
  border: 1px solid var(--vf-bdr);
}
.vf-ctx-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--vf-ink4);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  margin-bottom: 8px;
}
.vf-ctx-label::after { content: ''; flex: 1; height: 1px; background: var(--vf-bdr); }
.vf-ctx-en { font-size: 15px; color: var(--vf-ink2); line-height: 1.8; }
.vf-ctx-en .hl { color: var(--vf-coral); font-weight: 600; border-bottom: 2px solid var(--vf-coral-m); }
.vf-ctx-zh { font-size: 13px; color: var(--vf-ink4); margin-top: 6px; display: none; }
.vf-ctx-zh.show { display: block; animation: vf-revealSlide 0.3s ease; }

/* Memory bar */
.vf-memory { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--vf-bdr); }
.vf-mem-label {
  font-size: 10px;
  color: var(--vf-ink4);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
}
.vf-mem-bar { height: 4px; background: var(--vf-sand); border-radius: 99px; overflow: hidden; }
.vf-mem-fill { height: 100%; border-radius: 99px; transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1); }

/* ===== ACTION BAR (sticky bottom) ===== */
#vf-action-area {
  position: sticky;
  bottom: 0;
  z-index: 10;
  background: var(--vf-bg);
  padding: 12px 0 max(12px, env(safe-area-inset-bottom));
  margin: 0 -1px;
}
#vf-action-area::before {
  content: '';
  position: absolute;
  top: -20px;
  left: 0;
  right: 0;
  height: 20px;
  background: linear-gradient(to top, var(--vf-bg), transparent);
  pointer-events: none;
}

.vf-actions { display: flex; gap: 8px; }
.vf-btn {
  flex: 1;
  padding: 14px;
  border-radius: var(--vf-rs);
  border: 2px solid var(--vf-bdr);
  background: var(--vf-white);
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s;
  text-align: center;
  min-height: 0;
}
.vf-btn:hover { transform: translateY(-2px); box-shadow: var(--vf-sh2); }
.vf-btn.again:hover { border-color: var(--vf-coral); background: var(--vf-coral-s); color: var(--vf-coral); }
.vf-btn.good:hover { border-color: var(--vf-blue); background: var(--vf-blue-s); color: var(--vf-blue); }
.vf-btn.easy:hover { border-color: var(--vf-green); background: var(--vf-green-s); color: var(--vf-green); }
.vf-btn .btn-time { display: block; font-size: 10px; color: var(--vf-ink4); font-weight: 400; margin-top: 2px; }

.vf-reveal-btn {
  width: 100%;
  padding: 16px;
  border-radius: var(--vf-rs);
  border: none;
  background: var(--vf-ink);
  color: var(--vf-bg);
  font-size: 15px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  min-height: 0;
}
.vf-reveal-btn:hover {
  background: var(--vf-coral);
  box-shadow: 0 6px 20px rgba(224, 90, 58, 0.2);
  transform: translateY(-2px);
}
.vf-reveal-btn .sk { font-size: 10px; opacity: 0.5; margin-left: 6px; }

/* ===== SESSION DONE ===== */
.vf-done { text-align: center; padding: 40px 20px; }
.vf-done-icon { font-size: 48px; margin-bottom: 12px; }
.vf-done h3 { font-family: 'Newsreader', serif; font-size: 22px; margin-bottom: 6px; }
.vf-done p { font-size: 13px; color: var(--vf-ink3); line-height: 1.6; }
.vf-done-next {
  display: inline-block;
  margin-top: 14px;
  padding: 8px 18px;
  background: var(--vf-blue-s);
  border-radius: var(--vf-rxs);
  font-size: 12px;
  color: var(--vf-blue);
  font-weight: 500;
}
.vf-done-stats {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 16px;
  font-size: 13px;
  color: var(--vf-ink3);
}
.vf-done-stats span { font-weight: 600; color: var(--vf-ink); }
.vf-share-btn {
  margin-top: 16px;
  padding: 10px 20px;
  border-radius: 99px;
  border: none;
  background: var(--vf-ink);
  color: var(--vf-bg);
  font-size: 12px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 0;
}
.vf-share-btn:hover {
  background: var(--vf-coral);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(224, 90, 58, 0.2);
}

/* ===== CURVE SECTION ===== */
.vf-curve-section {
  padding: 40px 0 0;
  margin-top: 40px;
  border-top: 1px solid var(--vf-bdr);
}
.vf-curve-card {
  background: var(--vf-white);
  border: 1px solid var(--vf-bdr);
  border-radius: var(--vf-r);
  padding: 28px 24px;
  box-shadow: var(--vf-sh);
  margin-bottom: 24px;
}
.vf-curve-canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 2.2 / 1;
  margin-bottom: 16px;
}
#vf-curveCanvas { width: 100%; height: 100%; display: block; }
.vf-curve-legend { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.vf-curve-legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--vf-ink3); }
.vf-curve-legend-dot { width: 10px; height: 10px; border-radius: 3px; }
.vf-curve-info { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 20px; }
.vf-ci { background: var(--vf-cream); border-radius: var(--vf-rs); padding: 16px; text-align: center; }
.vf-ci-num { font-family: 'Newsreader', serif; font-size: 28px; font-weight: 600; color: var(--vf-coral); line-height: 1; }
.vf-ci-label { font-size: 11px; color: var(--vf-ink4); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; }

/* Slider */
.vf-curve-slider { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--vf-bdr); }
.vf-curve-slider label {
  font-size: 12px; color: var(--vf-ink3); font-weight: 500;
  display: flex; justify-content: space-between; margin-bottom: 6px;
}
.vf-curve-slider input[type="range"] {
  width: 100%; -webkit-appearance: none; height: 6px;
  border-radius: 99px; background: var(--vf-sand); outline: none;
}
.vf-curve-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; border-radius: 99px;
  background: var(--vf-blue); cursor: pointer; box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}
.vf-curve-disclaimer { font-size: 10.5px; color: var(--vf-ink5); text-align: center; margin-top: 10px; font-style: italic; }

/* ===== EXPLAINER ===== */
.vf-explainer { padding: 40px 0 0; margin-top: 8px; border-top: 1px solid var(--vf-bdr); }
.vf-explainer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 20px; }
.vf-exp-card {
  background: var(--vf-white);
  border: 1px solid var(--vf-bdr);
  border-radius: var(--vf-rs);
  padding: 20px;
}
.vf-exp-card-icon { font-size: 24px; margin-bottom: 10px; }
.vf-exp-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; color: var(--vf-ink); }
.vf-exp-card p { font-size: 13px; color: var(--vf-ink3); line-height: 1.6; }

/* References */
.vf-references { margin-top: 24px; padding: 16px 20px; background: var(--vf-cream); border-radius: var(--vf-rs); }
.vf-ref-title { font-size: 11px; font-weight: 600; color: var(--vf-ink4); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 8px; }
.vf-references ul { list-style: none; padding: 0; }
.vf-references li { font-size: 12px; color: var(--vf-ink4); line-height: 1.8; }

/* ===== FOCUS VISIBLE (Accessibility) ===== */
.vf-btn:focus-visible,
.vf-lv:focus-visible,
.vf-reveal-btn:focus-visible,
.vf-audio:focus-visible,
.vf-share-btn:focus-visible {
  outline: 2px solid var(--vf-blue);
  outline-offset: 2px;
}

/* ===== DAILY LIMIT SELECTOR ===== */
.vf-daily-limit {
  display: flex;
  align-items: center;
  gap: 3px;
}
.vf-daily-label {
  font-size: 11px;
  color: var(--vf-ink4);
  margin: 0 2px;
}
.vf-lv-sm {
  padding: 3px 8px;
  font-size: 10.5px;
}

/* ===== DONE BACKUP ===== */
.vf-done-backup {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}
.vf-done-backup button {
  padding: 6px 14px;
  border-radius: 99px;
  border: 1px solid var(--vf-bdr);
  background: var(--vf-white);
  font-size: 11px;
  font-family: inherit;
  color: var(--vf-ink3);
  cursor: pointer;
  transition: all 0.2s;
  min-height: 0;
}
.vf-done-backup button:hover {
  border-color: var(--vf-blue);
  color: var(--vf-blue);
}

/* ===== ONBOARDING ===== */
.vf-onboard-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--vf-ink2);
}
.vf-onboard-num {
  width: 22px;
  height: 22px;
  border-radius: 99px;
  background: var(--vf-coral);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  margin-left: 8px;
}
.vf-onboard-num:first-child { margin-left: 0; }

/* ===== RESPONSIVE ===== */
@media (max-width: 540px) {
  .vf-explainer-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .vf-stats { display: grid; grid-template-columns: 1fr 1fr; }
  .vf-word { font-size: 32px; }
  .vf-curve-info { grid-template-columns: 1fr; }
  .vf-body { padding: 8px 16px 20px; }
  .vf-card-top { padding: 16px 16px 0; }
  .vf-card-hero { padding: 12px 16px 0; }
  .vf-ctx { padding: 12px 14px; }
  .vf-topic-icon { width: 36px; height: 36px; }
}
