/* Shared styles for the LanguageBasics flashcard engine.
   Extracted unchanged from the original 6 standalone lesson files
   (they were byte-for-byte identical) and unified here. */

:root {
  --bg: #0f172a;
  --card: #ffffff;
  --text: #111827;
  --muted: #64748b;
  --accent: #2563eb;
  --accent2: #16a34a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #1e3a8a, var(--bg));
  color: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  /* LB-14: extra top padding clears the fixed header bar so the card column
     never slides under it. The bar is ~52px tall; 70px leaves a little breathing
     room above the title. */
  padding: 70px 18px 18px;
}

/* ---- LB-14: fixed top header bar ---- */
/* A single horizontal line pinned to the top: streak (left), hamburger
   (right). Calm, low-emphasis, matching the app's style. LB-36 removed the
   overall mastery rollup from the middle. */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  min-height: 52px;
  background: rgba(15, 23, 42, .85);
  backdrop-filter: blur(6px);
}
.header-streak {
  font-size: .9rem;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
}

.app { width: min(480px, 100%); text-align: center; }

h1 { font-size: 1.25rem; font-weight: 700; margin: 0 0 14px; }

/* Visually hide but keep for screen readers. */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Lesson selector (and LB-23 language selector, hidden until a 2nd language) */
.lesson-select,
.language-select {
  margin: 0 0 14px;
}
.lesson-select select,
.language-select select {
  font: inherit;
  padding: 8px 12px;
  border-radius: 10px;
  border: 0;
  background: var(--card);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  max-width: 100%; /* LB-39: long option text must not widen the page at 320px */
}

.card {
  background: var(--card);
  color: var(--text);
  border-radius: 28px;
  min-height: 360px;
  padding: 28px 20px;
  box-shadow: 0 24px 60px rgba(0,0,0,.3);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

/* LB-36: in a test, focus moves to the card after a reveal. Keyboard users
   see a ring; a mouse/touch reveal does not draw one. */
.card:focus { outline: none; }
.card:focus-visible { outline: 3px solid var(--accent2); outline-offset: 3px; }

.label { color: var(--muted); font-size: 1rem; margin-bottom: 8px; }

/* Active-recall instruction shown on the prompt side of each card. */
.recall { color: var(--accent2); font-size: 1rem; font-weight: 600; margin-bottom: 14px; }

/* max-width + overflow-wrap are overflow guards for the big-number cards:
   they cap width to the card and let an over-long token wrap instead of
   bleeding past the edge. Short cards (lessons 1-4) never hit the cap, so
   their look is unchanged. The per-card font-size shrink is applied inline
   by engine.js (promptFontSize / wordFontSize) by string length. */
.number { font-size: clamp(7rem, 32vw, 11rem); line-height: 1; font-weight: 800; max-width: 100%; overflow-wrap: anywhere; }

.word { font-size: clamp(3rem, 14vw, 5rem); line-height: 1.05; font-weight: 800; color: var(--accent); margin-top: 16px; max-width: 100%; overflow-wrap: anywhere; }

/* Stacked multi-part answer lines (lessons 2 and 6). Each <br>-separated
   line just wraps naturally; matches the original word-line look. */

.pronunciation { font-size: 1.4rem; color: var(--muted); margin-top: 10px; }

.timer { margin: 18px auto 0; width: 100%; height: 10px; background: rgba(255,255,255,.25); border-radius: 99px; overflow: hidden; }

/* The bar duration is set inline by engine.js to match each lesson's
   revealMs so the shrink animation and the setTimeout stay in sync. */
.bar { width: 100%; height: 100%; background: var(--accent2); transform-origin: left; animation: shrink 5s linear forwards; }

@keyframes shrink { from { transform: scaleX(1); } to { transform: scaleX(0); } }

.controls { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 16px; }

button {
  border: 0;
  border-radius: 14px;
  padding: 14px 12px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  color: white;
  background: var(--accent);
}

button.secondary { background: #475569; }

.hint { color: #cbd5e1; font-size: .95rem; margin-top: 12px; }

/* ---- Settings: hamburger button ---- */
/* LB-14: lives in the fixed header bar (right-aligned via the flex layout).
   Calm, low-emphasis: a quiet translucent control that doesn't compete with
   the flashcard. */
.app { position: relative; }

.hamburger {
  flex-shrink: 0;
  margin-left: auto; /* LB-34: stay right-aligned when the streak span is removed */
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .12);
  border-radius: 12px;
}
.hamburger:hover { background: rgba(255, 255, 255, .2); }

.hamburger-bars {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  width: 20px;
}
.hamburger-bars span {
  display: block;
  height: 2px;
  width: 100%;
  background: #ffffff;
  border-radius: 2px;
}

/* ---- Settings: modal overlay ---- */
/* Hidden by default; settings.js adds .open to show it. A calm dark scrim over
   the cards with a centered light panel that matches the .card surface. */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(15, 23, 42, .65);
}
.modal.open { display: flex; }

.modal-panel {
  width: min(420px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--card);
  color: var(--text);
  border-radius: 20px;
  padding: 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .4);
  text-align: left;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-title { font-size: 1.2rem; font-weight: 700; margin: 0; }

.modal-close {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--text);
  background: #e2e8f0;
  border-radius: 10px;
}
.modal-close:hover { background: #cbd5e1; }

/* Settings groups */
.setting {
  margin: 0 0 20px;
  padding: 0;
  border: 0;
}
.setting:last-child { margin-bottom: 0; }

.setting-label {
  display: block;
  font-weight: 600;
  font-size: .95rem;
  color: var(--text);
  margin-bottom: 8px;
  padding: 0;
}

.setting-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.setting-range { flex: 1; cursor: pointer; }

.setting-value {
  min-width: 2.2rem;
  text-align: center;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--accent);
}

.setting-radios { gap: 18px; }

.radio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: .95rem;
  cursor: pointer;
  color: var(--text);
}
.radio input { cursor: pointer; }

.setting-help {
  margin: 8px 0 0;
  font-size: .82rem;
  color: var(--muted);
  line-height: 1.35;
}

/* ---- Lesson readout (LB-36: "This lesson: N of M known.") ---- */
/* Near the lesson picker. Plain text, low-emphasis — no bars/badges. */
.mastery-readout {
  margin: 0 0 14px;
  font-size: .9rem;
  line-height: 1.35;
}
.mastery-readout-lesson { font-weight: 700; color: #ffffff; }

/* ---- LB-36: test-result modal ---- */
/* Reuses .modal / .modal-panel / .modal-head / .modal-close (shared with the
   settings modal) for the overlay + panel chrome. These rules style only the
   result body. */
.result-block {
  text-align: center;
  margin-bottom: 16px;
}
.result-score {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
}
.result-best {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent2);
  margin-bottom: 8px;
}
.result-lesson {
  font-size: .95rem;
  color: var(--text);
}
.result-list-head {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--text);
}
.result-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  max-height: 40vh;
  overflow-y: auto;
}
.result-item {
  padding: 8px 0;
  border-top: 1px solid #e2e8f0;
  overflow-wrap: anywhere;
}
.result-item:first-child { border-top: 0; }
.result-item-main { display: block; font-weight: 700; color: var(--text); }
.result-item-hint { display: block; font-size: .9rem; color: var(--muted); margin-top: 2px; }
.result-none {
  text-align: center;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 16px;
}
/* Full-width stacked actions, matching the card buttons. */
.result-actions { display: grid; grid-template-columns: 1fr; gap: 10px; }
.result-actions button { width: 100%; }
.result-footer {
  margin: 14px 0 0;
  font-size: .8rem;
  color: var(--muted);
  text-align: center;
}

/* ---- Test-mode card region ---- */
/* "Card 3 of 10" progress, shown inside the card only during a test. */
.test-progress { color: var(--muted); font-size: .9rem; margin-bottom: 10px; }

/* ---- LB-36: rating buttons ("Not yet" left, "I knew it" right) ---- */
.rate-controls { grid-template-columns: 1fr 1fr; }
.rate-controls button { width: 100%; }

/* ---- LB-36: "Test me" button + "Stop test" link ---- */
.test-me { margin-top: 16px; display: flex; justify-content: center; }
.test-me button { min-width: 50%; }

.link-button {
  display: block;
  margin: 14px auto 0;
  padding: 6px 10px;
  background: transparent;
  color: #cbd5e1;
  font-weight: 600;
  text-decoration: underline;
  border-radius: 8px;
}
.link-button:hover { color: #ffffff; }

/* The hidden attribute must win over the display rules above. */
[hidden] { display: none !important; }

/* ---- LB-39: privacy link + privacy page ---- */
.privacy-link-wrap { margin: 18px 0 0; font-size: .9rem; }
.privacy-link { color: #cbd5e1; text-decoration: underline; padding: 6px 10px; border-radius: 8px; }
.privacy-link:hover { color: #ffffff; }
.privacy-link:focus-visible,
.privacy-link-modal:focus-visible,
.privacy-page a:focus-visible { outline: 3px solid var(--accent2); outline-offset: 3px; }
.setting-privacy { margin: 16px 0 0; font-size: .9rem; }
.privacy-link-modal { color: var(--accent); text-decoration: underline; border-radius: 4px; }
/* On the white dialogs, hover and focus go DARKER (the page-level .privacy-link:hover is white and would vanish). */
.privacy-link-modal:hover,
.privacy-link-modal:focus-visible { color: #1d4ed8; }

.privacy-body { display: block; padding: 18px; }
.privacy-page {
  width: min(640px, 100%);
  margin: 0 auto;
  padding: 20px 18px;
  background: var(--card);
  color: var(--text);
  border-radius: 16px;
  text-align: left;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.privacy-page h1 { font-size: 1.4rem; margin: 0 0 14px; }
.privacy-page h2 { font-size: 1.1rem; margin: 20px 0 6px; }
.privacy-page ul { margin: 0; padding-left: 1.2rem; }
.privacy-page li { margin: 4px 0; }
.privacy-page a { color: var(--accent); }
.privacy-back { margin: 0 0 12px; }
.privacy-lead { font-size: 1.05rem; }
