/* base.css — shared reset + design tokens for the whole IELTS Listening
   module, themed to the Unio brand identity (logo/colors/type supplied
   by the user). Variable NAMES kept as ielts-* so every other stylesheet
   just inherits the new theme without needing per-rule edits; only the
   VALUES below were changed to Unio's palette. */
:root {
  /* Unio brand palette, referenced directly for the few spots that need
     a specific brand color rather than a semantic one. */
  --unio-dark: #1b1b24;
  --unio-yellow: #F4BE2A;
  --unio-red: #C94F4F;
  --unio-blue: #5B8DEF;
  --unio-gray: #8C8F9F;
  --unio-cream: #FFF7DD;
  --unio-pink: #fff2f3;

  --ielts-navy: var(--unio-dark);
  --ielts-navy-dark: #101014;
  --ielts-blue: var(--unio-blue);
  --ielts-blue-light: #eaf0ff;
  --ielts-answered: #3e6fde; /* darker unio-blue shade so white badge text stays readable */
  --ielts-review: var(--unio-red);
  --ielts-current: var(--unio-dark);
  --ielts-correct: #2e9e5b;
  --ielts-incorrect: var(--unio-red);
  --ielts-border: #e5e1d8;
  --ielts-bg: #fbf9f2; /* muted nod to Unio cream, kept light for long reading sessions */
  --ielts-text: var(--unio-dark);
  --ielts-text-muted: var(--unio-gray);
  /* Darker than --ielts-text-muted — for secondary text that still needs
     to be comfortably readable (instructions, part context), not just
     decorative hints. */
  --ielts-text-secondary: #5b5e6b;
  --ielts-white: #ffffff;
  /* Fixed light text/icon color for surfaces that stay dark navy in BOTH
     themes (topbar, header, danger buttons) — never redefined below, unlike
     --ielts-white which flips to a dark card-surface color in dark mode. */
  --on-dark-text: #ffffff;
  --topbar-height: 56px;
  --navbar-height: 96px;
  --font-main: "Inter", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-heading: "Roboto Slab", Georgia, serif;
}

/* Dark mode — toggled via Settings (exam.html), applies site-wide because
   every page loads js/theme.js and every rule below is variable-driven. */
body.dark-theme {
  --ielts-navy: #101014;
  --ielts-blue-light: #223047;
  --ielts-border: #34343f;
  --ielts-bg: #16161d;
  --ielts-text: #f1f1f4;
  --ielts-text-muted: #9a9aa8;
  --ielts-text-secondary: #c3c5cf;
  --ielts-white: #1f1f29;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-main);
  color: var(--ielts-text);
  background: var(--ielts-bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-heading); }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
a { color: inherit; }

/* Shared line-icon set (see js/icons.js) — sized relative to the
   surrounding text so one rule fits every context, with a light hover
   lift on whatever button/link wraps it. */
.icon { width: 1em; height: 1em; display: inline-block; vertical-align: -0.15em; flex-shrink: 0; transition: transform 0.15s ease; }
.icon-btn, .btn, a.btn { transition: transform 0.12s ease, background-color 0.12s ease, opacity 0.12s ease; }
.icon-btn:hover .icon, .btn:hover .icon { transform: scale(1.1); }

.btn {
  border: 1px solid var(--ielts-border);
  background: var(--ielts-white);
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ielts-text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:hover { background: var(--ielts-bg); }
.btn-primary {
  background: var(--unio-yellow);
  border-color: var(--unio-yellow);
  color: var(--unio-dark);
}
.btn-primary:hover { background: #e0ac1c; }
.btn-danger {
  background: var(--ielts-incorrect);
  border-color: var(--ielts-incorrect);
  color: var(--on-dark-text);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Small reusable Unio "gateway arch" logo mark, referenced from every page header. */
.unio-logo { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.unio-logo svg { display: block; flex-shrink: 0; }
.unio-logo-word { font-family: var(--font-heading); font-weight: 700; letter-spacing: 0.02em; }

/* Skill switcher (Listening / Reading / Writing / Speaking) — shared tab
   bar under the header on every skill-specific page. */
.skill-nav {
  display: flex;
  gap: 4px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  border-bottom: 1px solid var(--ielts-border);
  background: var(--ielts-white);
  overflow-x: auto;
}
.skill-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 18px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ielts-text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.12s ease, border-color 0.12s ease;
}
.skill-nav-link:hover { color: var(--ielts-text); }
.skill-nav-link:hover .icon { transform: scale(1.12); }
.skill-nav-link.active { color: var(--unio-dark); border-bottom-color: var(--unio-yellow); }
body.dark-theme .skill-nav-link.active { color: var(--unio-yellow); }

/* Writing's hover dropdown — "Luyện đề" (the Cambridge-content practice
   flow) vs "Chấm bài" (free-form: student pastes their own prompt +
   answer to get checked). */
.skill-nav-dropdown { position: relative; }
.skill-nav-caret { width: 11px; height: 11px; margin-left: -2px; transition: transform 0.15s ease; }
.skill-nav-dropdown:hover .skill-nav-caret, .skill-nav-dropdown:focus-within .skill-nav-caret, .skill-nav-dropdown.open .skill-nav-caret { transform: rotate(180deg); }
.skill-nav-submenu {
  /* position:fixed (coords set by js/skill-nav.js on hover), not absolute —
     .skill-nav has overflow-x:auto for mobile scrolling, which per the CSS
     spec forces overflow-y to auto too and would clip an absolutely
     positioned dropdown. Fixed positioning escapes that clipping.
     Deliberately NOT using `transform` here (not even for the open/close
     animation): a `transform` on this element would make it the
     containing block for ITS OWN position:fixed descendants (the nested
     "Chấm bài" flyout below), so their viewport-relative JS coordinates
     would resolve against this box instead and land in the wrong place. */
  position: fixed;
  min-width: 170px;
  background: var(--ielts-white);
  border: 1px solid var(--ielts-border);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.14);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s;
  z-index: 50;
}
.skill-nav-dropdown:hover .skill-nav-submenu,
.skill-nav-dropdown:focus-within .skill-nav-submenu,
.skill-nav-dropdown.open .skill-nav-submenu {
  opacity: 1;
  visibility: visible;
}
.skill-nav-submenu-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ielts-text);
  text-decoration: none;
  transition: background-color 0.12s ease;
  white-space: nowrap;
}
.skill-nav-submenu-link:hover { background: var(--ielts-bg); }

/* Nested flyout — "Chấm bài" opens straight to the 3 task-type options
   (Task 1 General / Academic, Task 2) instead of an intermediate page. */
.skill-nav-submenu-dropdown { position: relative; }
.skill-nav-submenu-dropdown .skill-nav-submenu-link { justify-content: space-between; }
.skill-nav-caret-right { width: 11px; height: 11px; flex-shrink: 0; margin-left: 10px; }
.skill-nav-flyout {
  /* Same position:fixed rationale as .skill-nav-submenu; coords set by
     js/skill-nav.js on hover. */
  position: fixed;
  min-width: 170px;
  background: var(--ielts-white);
  border: 1px solid var(--ielts-border);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.14);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  z-index: 51;
}
.skill-nav-submenu-dropdown:hover .skill-nav-flyout,
.skill-nav-submenu-dropdown:focus-within .skill-nav-flyout,
.skill-nav-submenu-dropdown.open .skill-nav-flyout {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}

.demo-badge {
  display: inline-block;
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffe69c;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  vertical-align: middle;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* Scrollable containers must never force page-level horizontal scroll. */
.scroll-x { overflow-x: auto; max-width: 100%; }

/* ---------------- MODAL (shared across all pages) ---------------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--ielts-white);
  border-radius: 10px;
  padding: 24px;
  max-width: 480px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
}
.modal-box.modal-box-wide { max-width: 640px; }
.modal-box.modal-box-history { max-width: 900px; }
.modal-box h2 { margin-top: 0; font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal-stats { background: var(--ielts-bg); border-radius: 6px; padding: 10px 14px; font-size: 13px; margin: 12px 0; }
.exit-modal-mascot { display: block; margin: 4px auto 14px; }

/* Exam/Practice + full-test/single-part choice cards (test-selection page) */
.step-title { font-size: 13.5px; font-weight: 700; margin: 18px 0 6px; }
.mode-choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 8px; }
.mode-choice-card {
  border: 1px solid var(--ielts-border);
  border-radius: 8px;
  padding: 16px;
  text-align: left;
  background: var(--ielts-white);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.mode-choice-card:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,0.08); border-color: var(--unio-blue); }
.mode-choice-card h3 { margin: 0 0 6px; font-size: 15px; }
.mode-choice-card ul { margin: 8px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--ielts-text-muted); }
.mode-choice-card ul li { margin-bottom: 4px; }
.mode-choice-card .btn { width: 100%; text-align: center; text-decoration: none; display: block; }
@media (max-width: 480px) {
  .mode-choice-grid { grid-template-columns: 1fr; }
}

/* Radio-backed choice cards (Bước 1 / Bước 2 in the mode modal) */
/* Selection is signalled by the radio dot itself (styled Unio blue via
   accent-color below) — no extra background/shadow decoration, so cards
   of different content lengths still line up cleanly. */
input[type="radio"], input[type="checkbox"] { accent-color: var(--unio-blue); }
label.mode-choice-card { display: block; cursor: pointer; }
label.mode-choice-card input[type="radio"] { margin-right: 8px; }
label.mode-choice-card:has(input:checked) { border-color: var(--unio-blue); }
.scope-sub { font-size: 12.5px; color: var(--ielts-text-muted); margin: 4px 0 0; }
.scope-card-parts { padding-bottom: 10px; }
.scope-option-list { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.scope-option { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; padding: 6px 8px; border-radius: 6px; transition: background-color 0.12s ease; }
.scope-option:hover { background: var(--ielts-bg); }
.scope-option em { font-style: normal; color: var(--ielts-text-muted); }
.scope-option .status-pill { margin-left: auto; }

/* Time-limit picker (Bước 2 in both mode-choice popups) */
.time-limit-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.time-limit-row input[type="number"] {
  width: 72px;
  padding: 7px 8px;
  border: 1px solid var(--ielts-border);
  border-radius: 6px;
  font-size: 14px;
  text-align: center;
  background: var(--ielts-white);
  color: var(--ielts-text);
}
.time-limit-unit { font-size: 13px; color: var(--ielts-text-muted); }
.time-limit-hint { font-size: 12.5px; color: var(--ielts-text-muted); margin-left: 6px; }
.time-limit-row #resetTimeBtn { padding: 6px 12px; font-size: 12.5px; margin-left: auto; }

.status-pill { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; }
.status-pill.submitted { background: #e6f4ea; color: var(--ielts-correct); }
.status-pill.in_progress { background: #fff3cd; color: #856404; }
.status-pill.abandoned { background: #f1f1f1; color: #777; }
