/* ============================================================
   TOEFL Practice
   ------------------------------------------------------------
   Two visual worlds, on purpose:

   1. THE DRILL FRAME (.tf-frame and everything inside it) is a
      near-verbatim copy of the approved prototype, which is itself
      matched to the real TOEFL interface. It stays white in dark
      mode, keeps its ETS teal bar, its serif-free Helvetica stack
      and its exact control shapes, because the whole point of this
      section is that a student who has drilled here recognises the
      real thing on test day. Change it only with a reason.

   2. EVERYTHING AROUND IT — the landing page, the pickers, the
      progress report — is ordinary site furniture and uses the
      site's own variables, so it follows the light/dark theme like
      every other module.

   All user-facing text in this module is English (D12).
   ============================================================ */

/* The real ETS/TOEFL brand face. Provisioned on the server alongside the
   other webfonts, not in the repo — the fallback stack is what renders if it
   is missing, and since it is used only for the wordmark, that is survivable. */
@font-face {
  font-family: 'Greet Standard';
  src: url('/assets/fonts/greet-standard/GreetStandardVF.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

#module-toefl {
  --tf-ink:      #1a1a1a;
  --tf-line:     #000;
  --tf-gray:     #6b6b6b;
  --tf-teal:     #066a6e;
  --tf-teal-lit: #0c8085;
  --tf-panel:    #fafafa;
  --tf-green:    #1e8a5a;
  --tf-green-bg: rgba(30, 138, 90, .10);
  --tf-gold:     #c9922a;
  --tf-gold-bg:  rgba(201, 146, 42, .10);
  --tf-danger:   #c0392b;
  --tf-danger-bg:rgba(192, 57, 43, .08);
}

/* ── Landing page ───────────────────────────────────────── */

.tf-hero {
  background: var(--tf-teal);
  color: #fff;
  border-radius: var(--r-md, 12px);
  padding: 26px 28px;
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.tf-hero-mark { display: flex; align-items: baseline; gap: 1px; font-family: 'Greet Standard', Helvetica, Arial, sans-serif; font-weight: 700; font-size: 26px; white-space: nowrap; }
.tf-hero-mark .etsmark  { width: 23px; height: 23px; flex: none; transform: translateY(-4px); margin-right: -1px; }
.tf-hero-mark .toeflword{ height: 27px; width: auto; flex: none; margin: 0 6px 0 1px; transform: translateY(2px); }
.tf-hero-sub { font-size: 14px; opacity: .9; line-height: 1.6; flex: 1 1 320px; }

.tf-notice {
  background: var(--warn-bg, rgba(217,119,6,.09));
  border: 1px solid rgba(217, 119, 6, .32);
  border-radius: var(--r-md, 12px);
  padding: 14px 18px;
  margin-bottom: 18px;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text);
}
.tf-notice b { display: block; margin-bottom: 3px; }
.tf-notice div { color: var(--text2); }

.tf-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.tf-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md, 12px);
  padding: 20px;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, border-color .15s;
  display: flex; flex-direction: column; gap: 8px;
}
.tf-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--tf-teal); }
.tf-card.soon { cursor: default; opacity: .55; }
.tf-card.soon:hover { transform: none; box-shadow: none; border-color: var(--border); }
.tf-card-icon  { font-size: 24px; }
.tf-card-title { font-weight: 700; font-size: 16px; color: var(--text); }
.tf-card-desc  { font-size: 13px; color: var(--text2); line-height: 1.55; }
.tf-card-meta  { font-size: 12px; color: var(--text3); margin-top: auto; padding-top: 8px; }
.tf-badge-soon {
  align-self: flex-start; font-size: 11px; font-weight: 700; letter-spacing: .4px;
  text-transform: uppercase; padding: 3px 8px; border-radius: 100px;
  background: var(--surface3); color: var(--text3);
}

/* ── Section header shared by pickers and the report ────── */

.tf-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.tf-head h2 { margin: 0; font-size: 20px; font-weight: 700; color: var(--text); }
.tf-head .tf-spacer { flex: 1; }
.tf-back {
  border: 1px solid var(--border2); background: var(--surface); color: var(--text2);
  border-radius: var(--r-sm, 8px); padding: 7px 12px; font-size: 13px; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.tf-back:hover { border-color: var(--tf-teal); color: var(--tf-teal); }
.tf-btn {
  border: 1.5px solid var(--tf-teal); background: var(--tf-teal); color: #fff;
  border-radius: var(--r-sm, 8px); padding: 9px 16px; font-size: 14px; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; gap: 7px;
}
.tf-btn:hover { background: var(--tf-teal-lit); border-color: var(--tf-teal-lit); }
.tf-btn.ghost { background: transparent; color: var(--tf-teal); }
.tf-btn.ghost:hover { background: rgba(6, 106, 110, .08); }
.tf-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Question-type picker ───────────────────────────────── */

.tf-types { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.tf-type {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md, 12px); padding: 18px; display: flex; flex-direction: column; gap: 12px;
}
.tf-type.mixed { border-color: var(--tf-teal); border-style: dashed; }
.tf-type-top { display: flex; align-items: flex-start; gap: 10px; }
.tf-type-ord {
  width: 26px; height: 26px; flex: none; border-radius: 50%;
  background: var(--tf-teal); color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.tf-type-name { font-weight: 700; font-size: 15px; color: var(--text); line-height: 1.35; }
.tf-type-desc { font-size: 12.5px; color: var(--text2); line-height: 1.55; margin-top: 3px; }

.tf-tiers { display: flex; gap: 8px; }
.tf-tier {
  flex: 1; border: 1px solid var(--border2); border-radius: var(--r-sm, 8px);
  padding: 9px 8px; text-align: center; cursor: pointer; background: var(--surface2);
  transition: border-color .15s, background .15s;
}
.tf-tier:hover:not(.locked) { border-color: var(--tf-teal); background: rgba(6, 106, 110, .06); }
.tf-tier.locked { cursor: not-allowed; opacity: .5; }
.tf-tier.done { border-color: var(--tf-green); background: var(--tf-green-bg); }
.tf-tier-name { font-size: 12.5px; font-weight: 700; color: var(--text); }
.tf-tier-meta { font-size: 11px; color: var(--text3); margin-top: 3px; }
.tf-tier.done .tf-tier-meta { color: var(--tf-green); }

.tf-gate {
  font-size: 12px; color: var(--text2); background: var(--surface2);
  border-radius: var(--r-sm, 8px); padding: 8px 10px; line-height: 1.5;
}
.tf-gate.passed { background: var(--tf-green-bg); color: var(--tf-green); }
.tf-gate b { color: var(--text); }
.tf-gate.passed b { color: var(--tf-green); }

.tf-bar { height: 5px; border-radius: 3px; background: var(--surface3); overflow: hidden; }
.tf-bar > i { display: block; height: 100%; background: var(--tf-teal); border-radius: 3px; }

/* ── Drill launcher ─────────────────────────────────────── */

.tf-launch {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md, 12px); padding: 22px; max-width: 560px;
}
.tf-launch-row { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.tf-launch-row label { font-size: 13px; font-weight: 600; color: var(--text2); min-width: 110px; }
.tf-launch-row select, .tf-launch-row input {
  border: 1px solid var(--border2); background: var(--surface2); color: var(--text);
  border-radius: var(--r-sm, 8px); padding: 8px 10px; font-size: 14px; font-family: inherit;
}
.tf-note { font-size: 12.5px; color: var(--text3); line-height: 1.6; margin-top: 4px; }

/* ============================================================
   THE DRILL FRAME — the prototype, preserved.
   ============================================================ */

.tf-stage {
  display: flex; align-items: flex-start; justify-content: center;
  background: #e8e8e8; border-radius: var(--r-md, 12px); padding: 12px;
  position: relative;
}
.tf-frame {
  width: 1200px; max-width: 100%;
  /* fitFrame() measures the real available box and overrides this on every
     render and resize. The value here only has to be close enough that the
     first paint does not visibly jump: nav 56 + content padding 56 +
     footer ~34 + stage padding 24. */
  height: calc(100dvh - 170px); min-height: 460px;
  background: #fff; border: 1px solid var(--tf-line);
  display: flex; flex-direction: column; user-select: none;
  font-family: Helvetica, Arial, sans-serif; color: var(--tf-ink);
}
.tf-frame *, .tf-frame *::before, .tf-frame *::after { box-sizing: border-box; }

.tf-topbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; padding: 14px 20px;
  border-bottom: 1px solid var(--tf-line); background: var(--tf-teal);
}
.tf-logo {
  display: flex; align-items: baseline; gap: 1px;
  font-family: 'Greet Standard', Helvetica, Arial, sans-serif;
  font-weight: 700; font-size: 26px; letter-spacing: .2px; white-space: nowrap; color: #fff;
}
.tf-logo .etsmark   { width: 23px; height: 23px; flex: none; transform: translateY(-4px); margin-right: -1px; }
.tf-logo .toeflword { height: 27px; width: auto; flex: none; margin: 0 6px 0 1px; transform: translateY(2px); }
.tf-logo .resttext  { transform: translateY(1px); display: inline-block; }

.tf-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.tf-tbtn {
  display: flex; align-items: center; gap: 6px;
  border: 1.5px solid #fff; border-radius: 6px; background: var(--tf-teal);
  padding: 9px 13px; font-size: 14px; font-weight: 600; cursor: pointer;
  color: #fff; white-space: nowrap; font-family: inherit;
}
.tf-tbtn:hover:not(:disabled) { background: var(--tf-teal-lit); }
.tf-tbtn.primary { background: #fff; color: var(--tf-teal); }
.tf-tbtn.primary:hover:not(:disabled) { background: #eef6f6; }
.tf-tbtn:disabled { opacity: .35; cursor: not-allowed; }
.tf-icon { width: 16px; height: 16px; flex: none; }

.tf-progressbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; border-bottom: 1px solid #ccc; font-size: 14px;
}
.tf-progressbar .tf-left  { font-weight: 700; }
.tf-progressbar .tf-right { display: flex; align-items: center; gap: 14px; }
.tf-timer { font-weight: 700; letter-spacing: .5px; font-variant-numeric: tabular-nums; }
/* Past the budget the clock turns red and keeps counting into negative — it
   never blocks, never auto-advances. Seeing the overrun is the whole message. */
.tf-timer.over { color: var(--tf-danger); }
.tf-scorebadge { display: none; font-weight: 700; padding: 3px 11px; border-radius: 100px; font-size: 13px; }
.tf-scorebadge.show { display: inline-block; }
.tf-scorebadge.good { background: var(--tf-green-bg);  color: var(--tf-green); }
.tf-scorebadge.mid  { background: var(--tf-gold-bg);   color: var(--tf-gold); }
.tf-scorebadge.low  { background: var(--tf-danger-bg); color: var(--tf-danger); }
.tf-hidebtn {
  display: flex; align-items: center; gap: 6px; background: none; border: none;
  font-size: 14px; font-weight: 600; cursor: pointer; color: var(--tf-ink); font-family: inherit;
}

.tf-title { text-align: center; font-size: 26px; font-weight: 700; padding: 20px 20px 14px; }
.tf-title small { display: block; font-size: 13px; font-weight: 400; color: var(--tf-gray); margin-top: 5px; }

.tf-body { display: flex; padding: 0 20px 24px; gap: 0; flex: 1; min-height: 0; }
.tf-pane { padding: 4px 18px; overflow-y: auto; flex: 1 1 0; }
.tf-pane.passage p { font-size: 17.5px; line-height: 1.7; margin: 0 0 18px; }
.tf-pane.passage { scrollbar-width: none; }
.tf-pane.passage::-webkit-scrollbar { display: none; width: 0; }

/* Sentence markers. Type 3 labels sentences; Type 8 marks insertion points. */
.tf-marker { font-weight: 700; color: var(--tf-teal); }
.tf-square {
  display: inline-block; width: 13px; height: 13px; margin: 0 3px;
  border: 1.5px solid var(--tf-ink); background: #fff; vertical-align: -1px; cursor: pointer;
}
.tf-square:hover { background: rgba(6, 106, 110, .15); border-color: var(--tf-teal); }
.tf-square.chosen { background: var(--tf-teal); border-color: var(--tf-teal); }
.tf-square.locked { cursor: default; }
.tf-square.key { background: var(--tf-green); border-color: var(--tf-green); }
.tf-square.miss { background: var(--tf-danger); border-color: var(--tf-danger); }
/* The highlighted target for Sentence Simplification and Reference. */
.tf-hl { background: #cfe9ea; box-shadow: 0 0 0 1px #8fc6c8; }

.tf-insertbox {
  border: 1px solid var(--tf-line); background: var(--tf-panel);
  padding: 12px 14px; margin: 0 0 18px; font-size: 16.5px; line-height: 1.65; font-style: italic;
}

/* The divider keeps the real interface's shape even when the passage is short
   enough not to scroll: the thumb renders full height and inert. */
.tf-divider { width: 22px; flex: none; display: flex; flex-direction: column; align-items: center; padding: 6px 0; }
.tf-chevbtn { background: none; border: none; cursor: pointer; color: var(--tf-gray); font-size: 11px; padding: 2px; line-height: 1; font-family: inherit; }
.tf-track { flex: 1; width: 8px; background: #e2e2e2; border-radius: 4px; position: relative; margin: 8px 0; cursor: pointer; }
.tf-thumb { position: absolute; left: 0; width: 8px; background: #8a8a8a; border-radius: 4px; cursor: grab; }
.tf-divider.inert .tf-track, .tf-divider.inert .tf-chevbtn { cursor: default; }
.tf-divider.inert .tf-thumb { cursor: default; background: #c4c4c4; }

.tf-qhead { font-size: 17px; font-weight: 700; line-height: 1.5; margin: 6px 0 22px; }
.tf-choices { display: flex; flex-direction: column; gap: 18px; }
.tf-choice { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; font-size: 16px; line-height: 1.5; }
.tf-radio { width: 20px; height: 20px; border: 2px solid var(--tf-ink); border-radius: 50%; flex: none; margin-top: 2px; position: relative; }
.tf-choice.selected .tf-radio::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--tf-ink); }
.tf-choice.locked { cursor: default; }
.tf-choice.correct-choice .tf-radio { border-color: var(--tf-green); }
.tf-choice.correct-choice .tf-radio::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--tf-green); }
.tf-choice.correct-choice span:last-child { color: var(--tf-green); font-weight: 600; }
.tf-choice.wrong-choice .tf-radio { border-color: var(--tf-danger); }
.tf-choice.wrong-choice .tf-radio::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--tf-danger); }
.tf-choice.wrong-choice span:last-child { color: var(--tf-danger); text-decoration: line-through; }

.tf-explain {
  margin-top: 20px; padding: 12px 14px; border-radius: 8px;
  font-size: 13.5px; line-height: 1.7;
  background: var(--tf-danger-bg); border: 1px solid rgba(192, 57, 43, .3); color: #7a1f14;
}
.tf-explain.right { background: var(--tf-green-bg); border-color: rgba(30, 138, 90, .3); color: #14543a; }
.tf-explain b { color: var(--tf-danger); }
.tf-explain.right b { color: var(--tf-green); }
/* Option letters lifted out of the explanation prose so the eye can jump
   straight to "why C is wrong". */
.tf-explain .tf-opt {
  font-weight: 700; padding: 0 3px; border-radius: 3px;
  background: rgba(0, 0, 0, .06);
}
.tf-optnote { margin-top: 7px; font-size: 13px; line-height: 1.6; color: var(--tf-danger); }

.tf-gatechip {
  margin-top: 14px; padding: 10px 12px; border-radius: 8px; font-size: 13px; line-height: 1.6;
  background: rgba(6, 106, 110, .08); border: 1px solid rgba(6, 106, 110, .25); color: #0a5254;
}
.tf-gatechip.unlocked { background: var(--tf-green-bg); border-color: rgba(30, 138, 90, .35); color: #14543a; }

.tf-review {
  position: absolute; top: 78px; right: 34px; background: #fff;
  border: 1px solid var(--tf-line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.15);
  padding: 14px; width: 232px; display: none; z-index: 5; max-height: 60vh; overflow-y: auto;
  font-family: Helvetica, Arial, sans-serif; color: var(--tf-ink);
}
.tf-review.open { display: block; }
.tf-review h4 { margin: 0 0 10px; font-size: 14px; }
.tf-review-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 4px; border-radius: 4px; cursor: pointer; font-size: 14px; }
.tf-review-row:hover { background: #f2f2f2; }
.tf-review-row .status { font-size: 12px; color: var(--tf-gray); }
.tf-review-row.answered  .status { color: #1a7a1a; }
.tf-review-row.correct   .status { color: var(--tf-green); }
.tf-review-row.incorrect .status { color: var(--tf-danger); }

/* ── Session summary ────────────────────────────────────── */

.tf-summary { max-width: 900px; }
.tf-score {
  display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md, 12px); padding: 22px; margin-bottom: 18px;
}
.tf-score-big { font-size: 40px; font-weight: 800; line-height: 1; color: var(--text); }
.tf-score-big small { font-size: 18px; font-weight: 600; color: var(--text3); }
.tf-score-lbl { font-size: 13px; color: var(--text2); margin-top: 6px; }

.tf-qlist { display: flex; flex-direction: column; gap: 12px; }
.tf-qrow {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--tf-green); border-radius: var(--r-sm, 8px); padding: 14px 16px;
}
.tf-qrow.wrong { border-left-color: var(--tf-danger); }
.tf-qrow.skipped { border-left-color: var(--text3); }
.tf-qrow-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--text3); margin-bottom: 6px; }
.tf-qrow-stem { font-size: 14px; font-weight: 600; color: var(--text); line-height: 1.5; }
.tf-qrow-exp { font-size: 13px; color: var(--text2); line-height: 1.65; margin-top: 8px; }
.tf-qrow-toggle { font-size: 12px; font-weight: 600; color: var(--tf-teal); cursor: pointer; margin-top: 7px; display: inline-block; }

/* ── Progress report ────────────────────────────────────── */

.tf-report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin-bottom: 22px; }
.tf-stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md, 12px); padding: 18px 20px;
}
.tf-stat-val { font-size: 30px; font-weight: 800; color: var(--text); line-height: 1.1; }
.tf-stat-val small { font-size: 15px; font-weight: 600; color: var(--text3); }
.tf-stat-lbl { font-size: 12.5px; color: var(--text2); margin-top: 5px; }
.tf-stat-sub { font-size: 11.5px; color: var(--text3); margin-top: 8px; line-height: 1.5; }

.tf-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-bottom: 22px; }
.tf-chartbox {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md, 12px); padding: 18px;
}
.tf-chartbox h3 { margin: 0 0 12px; font-size: 14px; font-weight: 700; color: var(--text); }
.tf-chartbox .tf-canvas-wrap { position: relative; height: 260px; }

.tf-next { display: flex; flex-direction: column; gap: 10px; }
.tf-next-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--surface2); border-radius: var(--r-sm, 8px); padding: 10px 12px; font-size: 13px;
}
.tf-next-row .n { font-weight: 700; color: var(--text); flex: 1 1 180px; }
.tf-next-row .d { color: var(--text2); }

.tf-empty { text-align: center; padding: 46px 20px; color: var(--text3); font-size: 14px; line-height: 1.7; }

/* ── Responsive ─────────────────────────────────────────── */

@media (max-width: 860px) {
  .tf-frame { height: auto; min-height: 0; }
  .tf-body { flex-direction: column; padding: 0 12px 18px; }
  .tf-pane { padding: 4px 6px; overflow: visible; }
  .tf-pane.passage { max-height: 42vh; overflow-y: auto; border-bottom: 1px solid #ddd; padding-bottom: 12px; margin-bottom: 14px; }
  .tf-divider { display: none; }
  .tf-title { font-size: 20px; padding: 16px 14px 10px; }
  .tf-topbar { padding: 10px 12px; }
  .tf-logo { font-size: 20px; }
  .tf-logo .toeflword { height: 21px; }
  .tf-tbtn { padding: 7px 10px; font-size: 13px; }
  .tf-stage { padding: 0; background: transparent; }
  .tf-review { right: 12px; top: 64px; }
}
