/**
 * TST Exam Mode — exam.css  v3.1.0
 *
 * ┌─────────────────────────────────────────────────────────────────────────┐
 * │ WHAT THIS FILE DOES                                                     │
 * │                                                                         │
 * │ All styles for the exam plugin. Uses --c-* CSS variables from          │
 * │ typing-trainer.css so it automatically matches the active TST theme.   │
 * │                                                                         │
 * │ FILE STRUCTURE                                                          │
 * │   OUTER BOX (tstem-outer-box) — themed background wrapper              │
 * │   WIDGET INNER (tstem-widget) — content, max-width, font               │
 * │   EXAM HEADER — title, category badge, sound + font controls           │
 * │   INFO BAR — duration / pass WPM / backspace / language pills          │
 * │   PROGRESS BAR — thin live completion bar                              │
 * │   LIVE STATS — WPM / errors / timer cells                              │
 * │   PASSAGE + TYPING AREAS — fixed heights for 600px total layout        │
 * │   PASSAGE WORD HIGHLIGHTS — real-time correct/wrong/current colours    │
 * │   CONTROL BAR — Start / Submit buttons + large timer                   │
 * │   EMAIL GATE — post-exam guest email capture                           │
 * │   RESULT PANEL — qualification badge, stat cards, accordions           │
 * │   TEXT COMPARISON — colour-coded word-level diff                       │
 * │   EXAM LIST — card grid                                                │
 * │   HISTORY TABLE — results table                                        │
 * │   MODAL — View Details overlay                                         │
 * │   PRINT STYLES — @media print                                          │
 * │   RESPONSIVE — @media breakpoints                                      │
 * └─────────────────────────────────────────────────────────────────────────┘
 *
 * CSS VARIABLE FALLBACKS
 * ─────────────────────
 * Every var() has a hardcoded fallback so the plugin works even if
 * typing-trainer.css isn't loaded (e.g. API usage without the main plugin).
 *
 * EDIT NOTES
 * ──────────
 * v3.0.0  Initial build. No outer box; no fixed heights; missing word colours.
 * v3.1.0  Added .tstem-outer-box; fixed heights; word highlights; progress bar;
 *         paste block; personal best; print button; modal styles; @media print.
 * v3.2.0  ADDED .tstem-hidden utility class (replaces inline style="display:none").
 *         Elementor strips inline styles from PHP templates — .tstem-hidden is
 *         the ONLY safe way to hide elements at load time in this plugin.
 *         FIXED typing textarea: now always visible on load (border + background
 *         hardcoded so it shows even before TST CSS variables load).
 *         REMOVED email gate styles (email gate removed in v3.2.0).
 *         UPDATED sound-off icon: uses .tstem-hidden class not display:none.
 */

/* ================================================================
   VISIBILITY UTILITY — tstem-hidden
   Used by JS to show/hide elements instead of .show()/.hide().
   Elementor strips inline style="display:none" from PHP templates,
   so inline styles are NOT a reliable hide mechanism in this plugin.
   JS uses:
     .removeClass('tstem-hidden')  to show
     .addClass('tstem-hidden')     to hide
   The template (exam-test.php) marks initially-hidden elements
   with class="tstem-hidden" in the HTML.
   ================================================================ */
.tstem-hidden { display: none !important; }

/* ================================================================
   OUTER BOX — matches .tst-widget from typing-trainer.css
   Provides the themed coloured background and border-radius.
   Width: full container width. Inner content constrained by .tstem-widget.
   ================================================================ */
.tstem-outer-box {
  background:    var(--c-bg, #eef1ff);
  border-radius: 16px;
  padding:       24px;
  /* Box shadow matches TST widget shadow */
  box-shadow:    0 2px 16px var(--c-shadow, rgba(59,91,219,0.10));
  transition:    background 0.3s;
}

/* ================================================================
   WIDGET INNER — JS mount point, constrains max width
   ================================================================ */
.tstem-widget {
  font-family: system-ui, -apple-system, sans-serif;
  color:        var(--c-text, #1a1f36);
  max-width:    900px;
  margin:       0 auto;
}
.tstem-widget * { box-sizing: border-box; }

/* ================================================================
   EXAM HEADER — title + badge left, controls right
   ================================================================ */
.tstem-exam-header {
  display:          flex;
  align-items:      flex-start;
  justify-content:  space-between;
  gap:              1rem;
  padding-bottom:   0.85rem;
  border-bottom:    1px solid var(--c-border, #d0d9f0);
  margin-bottom:    0.85rem;
  flex-wrap:        wrap;
}
.tstem-exam-header-left  { flex: 1; min-width: 200px; }
.tstem-exam-header-right { display: flex; align-items: center; gap: 0.6rem; flex-shrink: 0; flex-wrap: wrap; }

.tstem-exam-category-badge {
  display:        inline-block;
  font-size:      0.7rem;
  font-weight:    700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color:          var(--c-primary, #3b5bdb);
  background:     var(--c-primary-faint, #eef1ff);
  padding:        0.18rem 0.55rem;
  border-radius:  20px;
  margin-bottom:  0.3rem;
}
.tstem-exam-title {
  margin:      0;
  font-size:   clamp(1rem, 3vw, 1.3rem);
  font-weight: 700;
  line-height: 1.3;
  color:       var(--c-text, #1a1f36);
}

/* Sound + font controls */
.tstem-tool-btn {
  background:    var(--c-surface, #fff);
  border:        1.5px solid var(--c-border, #d0d9f0);
  color:         var(--c-text-sub, #4b5280);
  padding:       0.3rem 0.6rem;
  border-radius: 7px;
  cursor:        pointer;
  display:       flex;
  align-items:   center;
  gap:           0.25rem;
  font-size:     0.78rem;
  font-weight:   600;
  transition:    all 0.13s;
}
.tstem-tool-btn.active,
.tstem-tool-btn:hover { border-color: var(--c-primary, #3b5bdb); color: var(--c-primary, #3b5bdb); }

.tstem-font-group {
  display:     flex;
  align-items: center;
  gap:         0.35rem;
  color:       var(--c-text-muted, #8891b0);
  font-size:   0.75rem;
}
.tstem-font-slider { width: 64px; accent-color: var(--c-primary, #3b5bdb); }
.tstem-font-val    { font-size: 0.73rem; color: var(--c-text-muted, #8891b0); min-width: 30px; }

/* ================================================================
   INFO BAR — pill row showing exam parameters
   ================================================================ */
.tstem-exam-info-bar {
  display:       flex;
  gap:           0.4rem;
  flex-wrap:     wrap;
  margin-bottom: 0.75rem;
}
.tstem-info-pill {
  display:        inline-flex;
  align-items:    center;
  gap:            0.25rem;
  font-size:      0.75rem;
  font-weight:    600;
  padding:        0.2rem 0.6rem;
  border-radius:  20px;
  background:     var(--c-bg, #eef1ff);
  color:          var(--c-text-sub, #4b5280);
  border:         1px solid var(--c-border, #d0d9f0);
}
.tstem-info-pill-warning { background: #fff3cd; color: #856404; border-color: #ffc107; }
.tstem-info-pill-lang    { background: var(--c-primary-faint, #eef1ff); color: var(--c-primary, #3b5bdb); border-color: transparent; }

/* ================================================================
   PROGRESS BAR — thin bar showing passage completion %
   Hidden before exam starts. JS fills .tstem-progress-fill width.
   ================================================================ */
.tstem-progress-bar-wrap {
  display:       flex;
  align-items:   center;
  gap:           0.5rem;
  margin-bottom: 0.6rem;
}
.tstem-progress-track {
  flex:          1;
  height:        6px;
  background:    var(--c-border, #d0d9f0);
  border-radius: 3px;
  overflow:      hidden;
}
.tstem-progress-fill {
  height:        100%;
  width:         0%;
  background:    var(--c-primary, #3b5bdb);
  border-radius: 3px;
  transition:    width 0.3s ease;
}
.tstem-progress-label {
  font-size:  0.7rem;
  font-weight:700;
  color:      var(--c-primary, #3b5bdb);
  min-width:  32px;
  text-align: right;
}

/* ================================================================
   LIVE STATS — WPM / errors / timer strip
   Hidden before exam starts. JS shows on _start().
   ================================================================ */
.tstem-live-stats {
  display:         flex;
  flex-wrap:       wrap;
  gap:             0.5rem;
  margin-bottom:   0.75rem;
  justify-content: flex-end;
}
.tstem-live-stat {
  background:    var(--c-surface, #fff);
  border:        1px solid var(--c-border, #d0d9f0);
  border-radius: 10px;
  padding:       0.5rem 0.8rem;
  text-align:    center;
  box-shadow:    0 1px 4px var(--c-shadow, rgba(59,91,219,0.06));
  min-width:     80px;
}
.tstem-live-val   { display: block; font-size: 1.3rem; font-weight: 800; color: var(--c-primary, #3b5bdb); }
.tstem-live-label { display: block; font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--c-text-muted, #8891b0); margin-top: 1px; }
.tstem-live-stat-timer .tstem-live-val { color: var(--c-stat-3, #e03131); }

.tstem-timer-warning .tstem-timer-val { color: #e8590c; animation: tstem-pulse 1s infinite; }
.tstem-timer-danger  .tstem-timer-val { color: #e03131; animation: tstem-pulse 0.5s infinite; }
@keyframes tstem-pulse { 0%,100% { opacity:1 } 50% { opacity:.5 } }

/* ================================================================
   PASSAGE + TYPING AREAS — MERGED CARD
   ─────────────────────────────────────────────────────────────────
   v3.2.0: Both boxes merged into ONE unified card.
   No separate rounded boxes — just a single card with a thin
   divider line between the passage and the textarea.

   WHY: Two separate scrolling boxes feel disconnected. When the
   passage auto-scrolls as you type, the card "jumps" because
   it's a separate floating element. One merged card reads as a
   single cohesive unit — the reference text above, your typing
   below, same container.

   STRUCTURE:
     .tstem-typing-card              ← one card wrapping both
       .tstem-passage-wrap           ← top half (passage)
         .tstem-passage-label        ← "ORIGINAL TEXT" bar
         .tstem-passage-text         ← scrollable passage
       .tstem-card-divider           ← thin separator line
       .tstem-typing-wrap            ← bottom half (textarea)
         .tstem-typing-label         ← "TYPE HERE" bar
         .tstem-typing-area          ← the textarea
   ================================================================ */

/* The merged outer card */
.tstem-typing-card {
  background:    var(--c-surface, #fff);
  border:        1px solid var(--c-border, #d0d9f0);
  border-radius: 12px;
  box-shadow:    0 2px 12px var(--c-shadow, rgba(59,91,219,0.07));
  overflow:      hidden;
  margin-bottom: 0.65rem;
}

/* Each half has NO individual border, background, shadow, or radius —
   all of that comes from the parent .tstem-typing-card */
.tstem-passage-wrap,
.tstem-typing-wrap {
  background:    transparent;
  border:        none;
  border-radius: 0;
  box-shadow:    none;
  margin-bottom: 0;
  overflow:      visible;
}

/* Thin divider line between the two halves */
.tstem-card-divider {
  height:     1px;
  background: var(--c-border, #d0d9f0);
  margin:     0;
}

/* Label bars — passage label and typing label */
.tstem-passage-label,
.tstem-typing-label {
  padding:        0.3rem 1rem;
  background:     var(--c-bg, #eef1ff);
  border-bottom:  1px solid var(--c-border, #d0d9f0);
  font-size:      0.62rem;
  font-weight:    700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color:          var(--c-text-muted, #8891b0);
}

/* Passage text — fixed height, smooth auto-scroll to current word */
.tstem-passage-text {
  padding:         0.85rem 1rem;
  font-size:       18px;
  line-height:     1.85;
  color:           var(--c-text, #1a1f36);
  height:          190px;           /* adjust if passage height needs changing */
  overflow-y:      auto;
  word-break:      break-word;
  scroll-behavior: smooth;
}

/* Typing textarea — fixed height, background hardcoded (never transparent).
   IMPORTANT: must NOT be transparent — see v3.2.0 fix notes in exam.js.  */
.tstem-typing-area {
  width:       100%;
  height:      150px;           /* adjust if textarea height needs changing */
  min-height:  100px;
  max-height:  220px;
  padding:     0.85rem 1rem;
  font-size:   18px;
  line-height: 1.85;
  border:      none;
  outline:     none;
  resize:      vertical;
  color:       var(--c-text, #1a1f36);
  background:  var(--c-surface, #ffffff);
  font-family: inherit;
  display:     block;
  box-sizing:  border-box;
}
/* Disabled: muted + italic so user sees "not started yet" signal */
.tstem-typing-area:disabled {
  background:  var(--c-bg, #f0f2f9);
  cursor:      not-allowed;
  color:       var(--c-text-muted, #8891b0);
  font-style:  italic;
}
/* Focus: blue inner glow matches TST primary theme */
.tstem-typing-area:focus {
  outline:    none;
  box-shadow: inset 0 0 0 2px var(--c-primary, #3b5bdb);
}

/* Backspace blocked: red border shake */
.tstem-no-backspace-shake { animation: tstem-shake 0.3s ease; border-color: #e03131 !important; }
@keyframes tstem-shake {
  0%,100% { transform:translateX(0) }
  20%     { transform:translateX(-4px) }
  40%     { transform:translateX( 4px) }
  60%     { transform:translateX(-4px) }
  80%     { transform:translateX( 2px) }
}

/* Paste blocked: orange border flash */
.tstem-paste-blocked { animation: tstem-paste-flash 0.5s ease; }
@keyframes tstem-paste-flash {
  0%,100% { border-color: var(--c-border, #d0d9f0); }
  40%,60% { border-color: #e8590c; box-shadow: inset 0 0 0 2px #e8590c; }
}

/* ================================================================
   PASSAGE WORD HIGHLIGHT — live real-time feedback during typing
   JS adds/removes these classes via _highlightPassage()
   ================================================================ */
.tstem-pw          { cursor: default; border-radius: 3px; padding: 1px 2px; transition: background 0.08s, color 0.08s; }
.tstem-pw-pending  { color: var(--c-text-muted, #8891b0); }
.tstem-pw-current  { background: var(--c-primary-faint, #e8edff); color: var(--c-primary, #3b5bdb); outline: 1px solid var(--c-primary, #3b5bdb); outline-offset: 1px; }
.tstem-pw-correct  { color: var(--c-text, #1a1f36); }
.tstem-pw-wrong    { background: #fff5f5; color: #c92a2a; text-decoration: underline wavy #e03131; }

/* ================================================================
   CONTROL BAR — Start / Submit + large timer
   ================================================================ */
.tstem-control-bar {
  display:     flex;
  align-items: center;
  gap:         0.75rem;
  flex-wrap:   wrap;
  margin-top:  0.5rem;
}
/* Base button style shared by all .tstem-ctrl-btn variants */
.tstem-ctrl-btn {
  display:       inline-flex;
  align-items:   center;
  gap:           0.4rem;
  padding:       0.55rem 1.4rem;
  border-radius: 8px;
  border:        none;
  cursor:        pointer;
  font-size:     0.88rem;
  font-weight:   700;
  font-family:   system-ui, sans-serif;
  transition:    all 0.13s;
}
/* Start button — outlined primary */
.tstem-btn-start   { background: var(--c-bg, #eef1ff); color: var(--c-primary, #3b5bdb); border: 2px solid var(--c-primary, #3b5bdb); }
.tstem-btn-start:hover { background: var(--c-primary-faint, #dde4ff); }
/* Submit / primary solid buttons */
.tstem-btn-primary { background: var(--c-primary, #3b5bdb); color: #fff; border: 2px solid var(--c-primary, #3b5bdb); }
.tstem-btn-primary:hover { background: var(--c-primary-dark, #2f4ac0); border-color: var(--c-primary-dark, #2f4ac0); }
.tstem-btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
/* Secondary / ghost buttons */
.tstem-btn-secondary {
  display: inline-flex; align-items: center;
  padding: 0.5rem 1rem; border-radius: 8px;
  border: 1.5px solid var(--c-border, #d0d9f0);
  background: var(--c-surface, #fff);
  color: var(--c-text-sub, #4b5280);
  font-size: 0.82rem; font-weight: 600;
  text-decoration: none; cursor: pointer;
  transition: all 0.13s; font-family: system-ui, sans-serif;
}
.tstem-btn-secondary:hover { border-color: var(--c-primary, #3b5bdb); color: var(--c-primary, #3b5bdb); }

/* Large countdown timer — pushed to right via margin-left: auto */
.tstem-timer-display {
  font-size:   1.4rem;
  font-weight: 800;
  color:       var(--c-text, #1a1f36);
  margin-left: auto;
  display:     flex;
  align-items: baseline;
  gap:         2px;
}
.tstem-timer-sep { font-size: 0.9rem; color: var(--c-text-muted, #8891b0); }

/* ================================================================
   NOTICES
   ================================================================ */
.tstem-notice { padding: 0.8rem 1rem; background: var(--c-bg, #eef1ff); border: 1px solid var(--c-border, #d0d9f0); border-radius: 8px; font-size: 0.9rem; color: var(--c-text-sub, #4b5280); }
.tstem-error  { background: #fff5f5; border-color: #ffc9c9; color: #c92a2a; }
.tstem-guest-notice {
  display:       flex;
  align-items:   center;
  gap:           0.4rem;
  padding:       0.5rem 0.8rem;
  background:    var(--c-bg, #eef1ff);
  border:        1px solid var(--c-border, #d0d9f0);
  border-radius: 8px;
  font-size:     0.78rem;
  color:         var(--c-text-muted, #8891b0);
  margin-top:    0.5rem;
}
.tstem-guest-notice a { color: var(--c-primary, #3b5bdb); font-weight: 600; }

/* ================================================================
   EMAIL GATE — removed in v3.2.0
   Guests now see results immediately; scores saved to localStorage.
   No email required. These styles kept as stubs to avoid 404 errors
   from any cached CSS that may reference these classes.
   ================================================================ */
.tstem-email-gate { display: none !important; } /* gate removed — never shown */

/* ================================================================
   RESULT PANEL
   ================================================================ */
.tstem-result { padding: 0.25rem 0; }
.tstem-result-saved {
  text-align: center; font-size: 0.88rem; font-weight: 600;
  color: var(--c-stat-2, #2f9e44); margin-bottom: 0.85rem; min-height: 1.3em;
}

/* Qualification badge */
.tstem-qualification {
  display:         flex;
  align-items:     center;
  justify-content: center;
  gap:             0.85rem;
  padding:         1rem 1.25rem;
  border-radius:   12px;
  margin-bottom:   1.1rem;
}
.tstem-qual-pass  { background: linear-gradient(135deg, #2f9e44, #40c057); color: #fff; }
.tstem-qual-fail  { background: linear-gradient(135deg, #c92a2a, #e03131); color: #fff; }
.tstem-qual-icon  { font-size: 2rem; }
.tstem-qual-status    { font-size: 1.5rem; font-weight: 900; line-height: 1; }
.tstem-qual-threshold { font-size: 0.82rem; opacity: 0.88; margin-top: 0.2rem; }

/* Personal best notice */
.tstem-personal-best {
  padding:     0.65rem 1rem;
  border-radius: 8px;
  font-size:   0.85rem;
  margin-bottom: 0.85rem;
  text-align:  center;
}
.tstem-pb-improved { background: #ebfbee; color: #2f9e44; border: 1px solid #b2f2bb; }
.tstem-pb-same     { background: var(--c-bg, #eef1ff); color: var(--c-text-sub, #4b5280); border: 1px solid var(--c-border, #d0d9f0); }

/* Returning guest notice */
.tstem-returning-notice {
  background: var(--c-primary-faint, #eef1ff);
  border: 1px solid var(--c-border, #d0d9f0);
  border-left: 4px solid var(--c-primary, #3b5bdb);
  border-radius: 8px;
  padding: 0.65rem 1rem;
  font-size: 0.86rem;
  margin-bottom: 0.85rem;
  color: var(--c-text-sub, #4b5280);
}

/* Stat cards grid — auto-fill so they wrap gracefully */
.tstem-result-grid {
  display:               grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap:                   0.65rem;
  margin-bottom:         1rem;
}
.tstem-stat-card {
  background:    var(--c-surface, #fff);
  border:        1px solid var(--c-border, #d0d9f0);
  border-radius: 10px;
  padding:       0.85rem 0.7rem;
  text-align:    center;
  box-shadow:    0 1px 4px var(--c-shadow, rgba(59,91,219,0.06));
  cursor:        help;
  transition:    transform 0.13s, box-shadow 0.13s;
}
.tstem-stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 10px var(--c-shadow, rgba(59,91,219,0.12)); }
.tstem-stat-value { display: block; font-size: 1.5rem; font-weight: 900; color: var(--c-text, #1a1f36); }
.tstem-stat-label { display: block; font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--c-text-muted, #8891b0); margin-top: 0.15rem; }
.tstem-stat-desc  { display: none; }

/* Stat card colour variants */
.tstem-stat-primary   .tstem-stat-value { color: var(--c-primary, #3b5bdb); }
.tstem-stat-secondary .tstem-stat-value { color: var(--c-primary-dark, #2f4ac0); }
.tstem-stat-green     .tstem-stat-value { color: var(--c-stat-2, #2f9e44); }
.tstem-stat-red       .tstem-stat-value { color: var(--c-stat-3, #e03131); }
.tstem-stat-orange    .tstem-stat-value { color: #e8590c; }
.tstem-stat-yellow    .tstem-stat-value { color: #d69e2e; }
.tstem-stat-blue      .tstem-stat-value { color: #1971c2; }
.tstem-stat-grey      .tstem-stat-value { color: var(--c-text-sub, #4b5280); }

/* Result action buttons */
.tstem-result-actions {
  display:     flex;
  gap:         0.6rem;
  flex-wrap:   wrap;
  margin-top:  1.25rem;
  padding-top: 0.85rem;
  border-top:  1px solid var(--c-border, #d0d9f0);
}
.tstem-btn-print { gap: 0.4rem; }

/* ================================================================
   ACCORDIONS — error breakdown, formulas, text comparison
   ================================================================ */
.tstem-accordion {
  background:    var(--c-surface, #fff);
  border:        1px solid var(--c-border, #d0d9f0);
  border-radius: 9px;
  margin-bottom: 0.6rem;
  overflow:      hidden;
}
.tstem-accordion-toggle {
  padding:     0.8rem 1rem;
  font-size:   0.88rem;
  font-weight: 700;
  cursor:      pointer;
  list-style:  none;
  display:     flex;
  align-items: center;
  gap:         0.4rem;
  color:       var(--c-text, #1a1f36);
  user-select: none;
}
.tstem-accordion-toggle::-webkit-details-marker { display: none; }
.tstem-accordion-toggle::after { content:'▾'; margin-left:auto; transition:transform 0.2s; font-size:0.8rem; color:var(--c-text-muted, #8891b0); }
details[open] .tstem-accordion-toggle::after { transform:rotate(180deg); }
.tstem-accordion-body { padding: 0.65rem 1rem 0.9rem; border-top: 1px solid var(--c-border, #d0d9f0); }

/* Error breakdown two-column layout */
.tstem-breakdown-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.tstem-breakdown-cols h4 { margin: 0 0 0.5rem; font-size: 0.84rem; }
.tstem-breakdown-list { margin: 0; padding: 0 0 0 1rem; }
.tstem-breakdown-list li { font-size: 0.82rem; color: var(--c-text-sub, #4b5280); margin-bottom: 0.2rem; }

/* Formulas */
.tstem-formulas { display: flex; flex-direction: column; gap: 0.4rem; }
.tstem-formula-row { display: flex; gap: 0.6rem; align-items: flex-start; font-size: 0.82rem; }
.tstem-formula-row span { flex: 0 0 150px; font-weight: 600; color: var(--c-text-sub, #4b5280); }
.tstem-formula-row code { background: var(--c-bg, #f5f7ff); padding: 0.15rem 0.45rem; border-radius: 4px; font-size: 0.8rem; color: var(--c-text, #1a1f36); word-break: break-word; flex: 1; }

/* ================================================================
   TEXT COMPARISON — side-by-side original vs typed with colours
   ================================================================ */
.tstem-comparison { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; margin-bottom: 0.6rem; }
.tstem-comparison-label { font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--c-text-muted, #8891b0); margin-bottom: 0.35rem; }
.tstem-comparison-text { font-size: 0.86rem; line-height: 2; word-break: break-word; }

/* ── Correct word ── */
.tstem-word-ok  { color: var(--c-text, #1a1f36); }

/* ── Full error word styles ── */
/* additions = extra word in typed that isn't in original */
.tstem-word-add        { background: #ffe3e3; color: #c92a2a; border-bottom: 2px solid #e03131; padding: 1px 2px; border-radius: 3px; cursor: help; }
/* omissions = word from original that wasn't typed (original col shows strikethrough) */
.tstem-word-omit       { background: #fff3cd; color: #856404; border-bottom: 2px dashed #d69e2e; padding: 1px 2px; border-radius: 3px; text-decoration: line-through; cursor: help; }
/* typed col placeholder for omissions */
.tstem-word-omit-placeholder { color: #a6a6a6; font-style: italic; cursor: help; }
/* repetitions = same word typed twice in a row */
.tstem-word-rep        { background: #fff0f6; color: #a61e4d; border-bottom: 2px dotted #c2255c; padding: 1px 2px; border-radius: 3px; cursor: help; }
/* substitutions = wrong word or misspelling */
.tstem-word-sub        { background: #ffe8cc; color: #c96000; border-bottom: 2px solid #e8590c; padding: 1px 2px; border-radius: 3px; cursor: help; }
/* incomplete = word started but not finished */
.tstem-word-incomplete { background: #f3f0ff; color: #5f3dc4; border-bottom: 2px dotted #9775fa; padding: 1px 2px; border-radius: 3px; cursor: help; }

/* ── Half error word styles ── */
.tstem-word-cap     { background: #e7f5ff; color: #1864ab; border-bottom: 2px solid #74c0fc; padding: 1px 2px; border-radius: 3px; cursor: help; }
.tstem-word-punc    { background: #f8f0fb; color: #862e9c; border-bottom: 2px solid #cc5de8; padding: 1px 2px; border-radius: 3px; cursor: help; }
.tstem-word-spacing { background: #fff9db; color: #7a5c0a; border-bottom: 2px dotted #fcc419; padding: 1px 2px; border-radius: 3px; cursor: help; }
.tstem-word-trans   { background: #e6fcf5; color: #087f5b; border-bottom: 2px solid #38d9a9; padding: 1px 2px; border-radius: 3px; cursor: help; }

/* Catch-all for any unclassified error */
.tstem-word-err { background: #ffe3e3; color: #c92a2a; border-bottom: 2px solid #e03131; padding: 1px 2px; border-radius: 3px; cursor: help; }

/* Legend below comparison */
.tstem-comparison-legend { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-top: 0.5rem; }
.tstem-legend-item { font-size: 0.7rem; font-weight: 600; padding: 0.15rem 0.45rem; border-radius: 4px; }
.tstem-legend-additions      { background: #ffe3e3; color: #c92a2a; }
.tstem-legend-substitutions  { background: #ffe8cc; color: #c96000; }
.tstem-legend-omissions      { background: #fff3cd; color: #856404; }
.tstem-legend-repetitions    { background: #fff0f6; color: #a61e4d; }
.tstem-legend-incomplete     { background: #f3f0ff; color: #5f3dc4; }
.tstem-legend-capitalization { background: #e7f5ff; color: #1864ab; }
.tstem-legend-punctuation    { background: #f8f0fb; color: #862e9c; }
.tstem-legend-spacing        { background: #fff9db; color: #7a5c0a; }
.tstem-legend-transposition  { background: #e6fcf5; color: #087f5b; }

/* ================================================================
   EXAM LIST — card grid
   ================================================================ */
.tstem-exam-list {
  display:               grid;
  grid-template-columns: repeat(var(--tstem-cols, 3), 1fr);
  gap:                   1.25rem;
}
.tstem-exam-card {
  display:         flex;
  flex-direction:  column;
  background:      var(--c-surface, #fff);
  border:          1px solid var(--c-border, #d0d9f0);
  border-radius:   14px;
  padding:         1.1rem;
  text-decoration: none;
  color:           var(--c-text, #1a1f36);
  box-shadow:      0 2px 8px var(--c-shadow, rgba(59,91,219,0.07));
  transition:      transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.tstem-exam-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px var(--c-shadow, rgba(59,91,219,0.13)); border-color: var(--c-primary, #3b5bdb); }
.tstem-card-header   { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.4rem; }
.tstem-card-category { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--c-primary, #3b5bdb); background: var(--c-primary-faint, #eef1ff); padding: 0.15rem 0.45rem; border-radius: 20px; }
.tstem-card-title    { font-size: 0.95rem; font-weight: 700; margin: 0 0 0.35rem; color: var(--c-text, #1a1f36); }
.tstem-card-excerpt  { font-size: 0.8rem; color: var(--c-text-sub, #4b5280); line-height: 1.5; margin: 0 0 0.6rem; flex: 1; }
.tstem-card-meta     { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.65rem; }
.tstem-card-meta-item{ display: flex; align-items: center; gap: 0.25rem; font-size: 0.73rem; color: var(--c-text-muted, #8891b0); }
.tstem-card-cta      { font-size: 0.8rem; font-weight: 700; color: var(--c-primary, #3b5bdb); margin-top: auto; }

/* ================================================================
   HISTORY TABLE
   ================================================================ */
.tstem-history-wrap   { font-family: system-ui, sans-serif; border: 1px solid var(--c-border, #d0d9f0); border-radius: 12px; overflow: hidden; }
.tstem-history-header {
  background:      linear-gradient(135deg, var(--c-primary, #3b5bdb), var(--c-primary-dark, #2f4ac0));
  color:           #fff;
  padding:         1rem 1.25rem;
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  flex-wrap:       wrap;
  gap:             0.6rem;
}
.tstem-history-title  { margin: 0; font-size: 1rem; font-weight: 700; display: flex; align-items: center; gap: 0.4rem; color: #fff; }
.tstem-history-count  { font-weight: 400; opacity: 0.8; }
.tstem-history-email-lookup { display: flex; gap: 0.4rem; }
.tstem-history-email-lookup .tstem-input { max-width: 200px; background: rgba(255,255,255,0.15); border-color: rgba(255,255,255,0.3); color: #fff; }
.tstem-history-email-lookup .tstem-input::placeholder { color: rgba(255,255,255,0.6); }

.tstem-history-table-wrap { overflow-x: auto; }
.tstem-history-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.tstem-history-table th {
  padding: 0.65rem 0.9rem; text-align: left;
  font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--c-primary, #3b5bdb); background: var(--c-bg, #f5f7ff);
  border-bottom: 2px solid var(--c-border, #d0d9f0); white-space: nowrap;
}
.tstem-history-table td { padding: 0.65rem 0.9rem; border-bottom: 1px solid var(--c-border, #d0d9f0); color: var(--c-text, #1a1f36); vertical-align: middle; }
.tstem-history-table tr:last-child td { border-bottom: none; }
.tstem-history-table tr:hover td { background: var(--c-bg, #f5f7ff); }

.tstem-td-title { font-weight: 600; max-width: 180px; }
.tstem-td-date  { font-size: 0.75rem; color: var(--c-text-muted, #8891b0); white-space: nowrap; }

.tstem-cat-chip        { background: var(--c-primary-faint, #eef1ff); color: var(--c-primary, #3b5bdb); font-size: 0.72rem; font-weight: 700; padding: 0.15rem 0.5rem; border-radius: 20px; white-space: nowrap; }
.tstem-wpm-chip        { font-size: 0.8rem; font-weight: 700; padding: 0.2rem 0.55rem; border-radius: 20px; display: inline-flex; align-items: center; gap: 0.25rem; }
.tstem-wpm-chip.tstem-pass { background: #ebfbee; color: #2f9e44; }
.tstem-wpm-chip.tstem-fail { background: #fff5f5; color: #e03131; }

.tstem-status-badge        { font-size: 0.75rem; font-weight: 700; padding: 0.2rem 0.55rem; border-radius: 6px; white-space: nowrap; }
.tstem-qualified           { background: #ebfbee; color: #2f9e44; border: 1px solid #b2f2bb; }
.tstem-not-qualified       { background: #fff5f5; color: #e03131; border: 1px solid #ffc9c9; }

.tstem-btn-view {
  background: var(--c-primary, #3b5bdb); color: #fff; border: none; border-radius: 6px;
  padding: 0.35rem 0.75rem; font-size: 0.75rem; font-weight: 700; cursor: pointer;
  font-family: system-ui, sans-serif; transition: background 0.13s; display: inline-flex; align-items: center; gap: 0.25rem;
}
.tstem-btn-view:hover { background: var(--c-primary-dark, #2f4ac0); }

.tstem-empty { text-align: center; color: var(--c-text-muted, #8891b0); padding: 2rem; }

/* ================================================================
   MODAL — "View Details" overlay for history table
   Placed outside .tstem-exam-widget in the HTML (see exam-test.php).
   Hidden by .tstem-hidden class in template.
   JS opens: removeClass('tstem-hidden')
   JS closes: addClass('tstem-hidden')
   ================================================================ */
.tstem-result-modal {
  position:       fixed;
  inset:          0;
  z-index:        99999;
  display:        flex;        /* flex for centering modal-inner */
  align-items:    center;
  justify-content:center;
  padding:        1rem;
}
/* When hidden, override display:flex with display:none */
.tstem-result-modal.tstem-hidden { display: none !important; }
/* Semi-transparent dark backdrop */
.tstem-result-modal-backdrop {
  position:   absolute;
  inset:      0;
  background: rgba(0,0,0,0.55);
  cursor:     pointer;
}
/* White scrollable inner panel */
.tstem-result-modal-inner {
  position:   absolute;
  top:        50%;
  left:       50%;
  transform:  translate(-50%, -50%);
  background: var(--c-surface, #fff);
  border-radius: 16px;
  padding:    1.75rem;
  width:      min(92vw, 680px);
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  position:   relative; /* for the close button */
}
.tstem-result-modal-close {
  position:   absolute;
  top:        1rem;
  right:      1rem;
  background: var(--c-bg, #f5f7ff);
  border:     1px solid var(--c-border, #d0d9f0);
  color:      var(--c-text-muted, #8891b0);
  border-radius: 50%;
  width:      28px;
  height:     28px;
  display:    flex;
  align-items:center;
  justify-content: center;
  font-size:  0.8rem;
  cursor:     pointer;
  transition: all 0.13s;
  z-index:    1;
}
.tstem-result-modal-close:hover { background: var(--c-primary-faint, #eef1ff); color: var(--c-primary, #3b5bdb); border-color: var(--c-primary, #3b5bdb); }
.tstem-modal-loading { text-align: center; padding: 2rem; color: var(--c-text-muted, #8891b0); font-size: 0.9rem; }
.tstem-modal-exam-title { font-size: 1rem; font-weight: 700; color: var(--c-text, #1a1f36); margin-bottom: 0.2rem; }
.tstem-modal-exam-date  { font-size: 0.78rem; color: var(--c-text-muted, #8891b0); margin-bottom: 0.85rem; }

/* ================================================================
   SUBMITTING STATE — spinner overlay while AJAX score request runs.
   Covers the whole merged .tstem-typing-card (passage + textarea).
   ================================================================ */
.tstem-submitting .tstem-typing-card {
  position: relative;
}
.tstem-submitting .tstem-typing-card::after {
  content:         'Calculating score…';
  display:         flex;
  align-items:     center;
  justify-content: center;
  position:        absolute;
  inset:           0;
  background:      rgba(255,255,255,0.88);
  font-size:       0.9rem;
  font-weight:     600;
  color:           var(--c-primary, #3b5bdb);
  border-radius:   12px;
  z-index:         10;
}

/* ================================================================
   PRINT STYLES — for the print result button
   ================================================================ */
@media print {
  .tstem-outer-box,
  .tstem-exam-header,
  .tstem-exam-info-bar,
  .tstem-progress-bar-wrap,
  .tstem-live-stats,
  .tstem-typing-card,
  .tstem-control-bar,
  .tstem-guest-notice,
  .tstem-result-actions,
  .tstem-btn-retake,
  .tstem-btn-print,
  .tstem-result-modal { display: none !important; }

  .tstem-result-panel { display: block !important; }
  .tstem-result { padding: 0; }
  .tstem-accordion { page-break-inside: avoid; }
  details[open] { display: block; }
  details .tstem-accordion-body { display: block; }
  .tstem-stat-card { border: 1px solid #ccc; }
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 680px) {
  .tstem-outer-box       { padding: 16px; border-radius: 12px; }
  .tstem-exam-list       { grid-template-columns: 1fr; }
  .tstem-comparison      { grid-template-columns: 1fr; }
  .tstem-result-grid     { grid-template-columns: repeat(2, 1fr); }
  .tstem-breakdown-cols  { grid-template-columns: 1fr; }
  .tstem-formula-row span{ flex: 0 0 110px; }
  .tstem-history-header  { flex-direction: column; }
  .tstem-history-email-lookup { width: 100%; }
  .tstem-history-email-lookup .tstem-input { flex: 1; }
  .tstem-result-modal-inner { padding: 1.25rem; top: auto; bottom: 0; left: 0; right: 0; transform: none; width: 100%; max-height: 90vh; border-radius: 16px 16px 0 0; }
}
@media (max-width: 420px) {
  .tstem-result-grid     { grid-template-columns: repeat(2, 1fr); }
  .tstem-qualification   { flex-direction: column; gap: 0.4rem; }
}

/* ================================================================
   FULLSCREEN MODE
   ================================================================ */
.tstem-body-fullscreen { overflow: hidden; }

.tstem-outer-box.tstem-fullscreen-mode {
  position:   fixed;
  inset:      0;
  z-index:    99999;
  background: #f5f7ff;
  display:    flex;
  flex-direction: column;
  overflow:   hidden;
}

/* Fullscreen header — dark navy bar */
.tstem-fs-header {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  background:      #0d1b4b;
  color:           #fff;
  padding:         0 1.25rem;
  height:          70px;
  flex-shrink:     0;
}
.tstem-fs-header.tstem-hidden { display: none; }

.tstem-fs-back-btn,
.tstem-fs-settings-btn {
  background:    rgba(255,255,255,0.12);
  border:        none;
  border-radius: 50%;
  width:         42px;
  height:        42px;
  display:       flex;
  align-items:   center;
  justify-content: center;
  cursor:        pointer;
  color:         #fff;
  transition:    background 0.15s;
  flex-shrink:   0;
}
.tstem-fs-back-btn:hover,
.tstem-fs-settings-btn:hover { background: rgba(255,255,255,0.22); }

.tstem-fs-center { text-align: center; flex: 1; }
.tstem-fs-timer-label { font-size: 0.75rem; opacity: 0.75; text-transform: uppercase; letter-spacing: 0.06em; }
.tstem-fs-timer-val   { font-size: 1.5rem; font-weight: 800; }

/* Fullscreen progress bar */
.tstem-fs-progress {
  height:     5px;
  background: rgba(0,0,0,0.12);
  flex-shrink: 0;
}
.tstem-fs-progress.tstem-hidden { display: none; }
.tstem-fs-progress-fill {
  height:     100%;
  width:      0%;
  background: linear-gradient(90deg, #2eb8b8, #3b5bdb);
  transition: width 0.3s ease;
}

/* In fullscreen: widget fills remaining space */
.tstem-fullscreen-mode .tstem-exam-widget {
  flex:       1;
  overflow-y: auto;
  padding:    1rem 1.5rem;
  display:    flex;
  flex-direction: column;
}

/* In fullscreen: passage + textarea grow to fill available space */
.tstem-fullscreen-mode .tstem-typing-card {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.tstem-fullscreen-mode .tstem-passage-text {
  max-height: 35vh;
}
.tstem-fullscreen-mode .tstem-typing-area {
  flex: 1;
  min-height: 160px;
}

/* In fullscreen: hide the regular control bar, show fs action bar */
.tstem-fullscreen-mode .tstem-control-bar,
.tstem-fullscreen-mode .tstem-exam-header,
.tstem-fullscreen-mode .tstem-exam-info-bar { display: none !important; }

/* Fullscreen action bar */
.tstem-fs-action-bar {
  display:         flex;
  justify-content: space-between;
  align-items:     center;
  padding:         0.75rem 1.5rem;
  border-top:      1px solid var(--c-border, #d0d9f0);
  background:      #fff;
  flex-shrink:     0;
}
.tstem-fs-action-bar.tstem-hidden { display: none !important; }
.tstem-fullscreen-mode .tstem-fs-action-bar { display: flex !important; }

.tstem-fs-cancel-btn {
  background: #e03131;
  color:      #fff;
  border:     none;
  padding:    0.55rem 1.4rem;
  border-radius: 8px;
  font-weight: 700;
  cursor:     pointer;
  font-size:  0.9rem;
}
.tstem-fs-cancel-btn:hover { background: #c92a2a; }

/* ================================================================
   DIFFERENCES VIEW
   ================================================================ */
.tstem-diff-section {
  margin:        1.25rem 0;
  border-radius: 12px;
  overflow:      hidden;
  border:        1px solid var(--c-border, #d0d9f0);
  box-shadow:    0 2px 8px rgba(59,91,219,0.07);
}
.tstem-diff-header {
  background:  linear-gradient(135deg, #0d1b4b 0%, #1a3a7a 100%);
  color:       #fff;
  font-size:   1rem;
  font-weight: 700;
  padding:     0.75rem 1.25rem;
  text-align:  center;
  letter-spacing: 0.04em;
}
.tstem-diff-body {
  padding:     1.1rem 1.25rem;
  background:  #fff;
  line-height: 2.2;
  font-size:   0.92rem;
  word-break:  break-word;
}
.tstem-diff-legend {
  display:     flex;
  gap:         1.5rem;
  padding:     0.6rem 1.25rem;
  background:  #f8f9ff;
  border-top:  1px solid var(--c-border, #d0d9f0);
  font-size:   0.78rem;
  font-weight: 600;
}
.tstem-diff-leg { display: flex; align-items: center; gap: 0.4rem; }
.tstem-diff-leg-orig  { color: #087f5b; }
.tstem-diff-leg-typed { color: #c92a2a; }
.tstem-diff-leg-omit  { color: #1864ab; }

/* Diff word styles */
.tstem-dw-ok    { color: var(--c-text, #1a1f36); }
.tstem-dw-omit  { background: #d0ebff; color: #1864ab; padding: 1px 4px; border-radius: 3px; text-decoration: line-through; cursor: help; }
.tstem-dw-typed { background: #ffe3e3; color: #c92a2a; padding: 1px 4px; border-radius: 3px; cursor: help; }
.tstem-dw-orig  { background: #c3fae8; color: #087f5b; padding: 1px 4px; border-radius: 3px; cursor: help; }
.tstem-dw-pair  { display: inline-flex; gap: 1px; vertical-align: baseline; }

/* ================================================================
   SIDE-BY-SIDE COMPARISON
   ================================================================ */
.tstem-sidebyside {
  display:       grid;
  grid-template-columns: 1fr 1fr;
  gap:           0;
  margin:        1.25rem 0;
  border-radius: 12px;
  overflow:      hidden;
  border:        1px solid var(--c-border, #d0d9f0);
  box-shadow:    0 2px 8px rgba(59,91,219,0.07);
}
.tstem-sbs-col { display: flex; flex-direction: column; }
.tstem-sbs-col:first-child { border-right: 1px solid var(--c-border, #d0d9f0); }
.tstem-sbs-header {
  background:  linear-gradient(135deg, #0d1b4b 0%, #1a3a7a 100%);
  color:       #fff;
  font-size:   0.9rem;
  font-weight: 700;
  padding:     0.65rem 1rem;
  text-align:  center;
}
.tstem-sbs-body {
  padding:     1rem;
  background:  #fff;
  font-size:   0.88rem;
  line-height: 1.8;
  color:       var(--c-text, #1a1f36);
  flex:        1;
}
@media (max-width: 640px) {
  .tstem-sidebyside { grid-template-columns: 1fr; }
  .tstem-sbs-col:first-child { border-right: none; border-bottom: 1px solid var(--c-border, #d0d9f0); }
}
