/* ================================================================
   IndianTyping.com — test.css
   Loaded only on: english-typing-test.php, hindi-typing-test.php
   Depends on: main.css (must load first)
   Contains: pre-test, active test, results, all 3 states
================================================================ */

/* ================================================================
   1. PAGE LAYOUT
================================================================ */
.page {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: calc(var(--nav-h) + 40px) 24px 80px;
}

/* State machine: show/hide the 3 test phases */
.state { display: none; }
.state.active {
  display: block;
  animation: stateIn 0.4s var(--ease) both;
}

@keyframes stateIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ================================================================
   2. PRE-TEST STATE
================================================================ */
.pre-header {
  text-align: center; margin-bottom: 40px;
  animation: fadeUp 0.5s var(--ease) both;
}

.pre-eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--brand-dim);
  border: 1px solid rgba(232,66,10,0.2);
  border-radius: 100px; padding: 5px 14px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--brand); margin-bottom: 16px;
}

.pre-title {
  font-size: clamp(28px, 5vw, 46px); font-weight: 800;
  letter-spacing: -0.035em; line-height: 1.1; color: var(--text-1);
  margin-bottom: 10px;
}

.pre-title .hi { color: var(--brand); }

.pre-sub {
  font-size: 16px; color: var(--text-2);
  max-width: 480px; margin: 0 auto; line-height: 1.65;
}

/* Config card */
.config-card {
  max-width: 620px; margin: 0 auto 32px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r-xl); overflow: hidden;
  animation: fadeUp 0.5s var(--ease) 0.08s both;
  box-shadow: var(--shadow-md);
}

.config-section {
  padding: 24px 28px; border-bottom: 1px solid var(--border);
}

.config-section:last-child { border-bottom: none; }

.config-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-3); margin-bottom: 12px;
}

.config-opts { display: flex; gap: 8px; flex-wrap: wrap; }

.config-btn {
  padding: 10px 20px; border-radius: var(--r-md);
  border: 1.5px solid var(--border); background: var(--surface-2);
  font-size: 14px; font-weight: 600; color: var(--text-2);
  transition: all 0.15s var(--ease); cursor: pointer;
}

.config-btn:hover {
  border-color: var(--border-2); color: var(--text-1);
  background: var(--surface-3);
}

.config-btn.sel {
  border-color: var(--brand); background: var(--brand-dim);
  color: var(--brand); box-shadow: var(--shadow-glow);
}

.config-btn .tag {
  display: inline-block; font-size: 9px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  background: var(--green); color: #fff;
  padding: 1px 6px; border-radius: 100px;
  margin-left: 6px; vertical-align: 1px;
}

/* Start panel */
.start-panel { padding: 28px; text-align: center; }

.btn-start {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--brand); color: #fff;
  border-radius: var(--r-lg); padding: 18px 40px;
  font-size: 18px; font-weight: 700; letter-spacing: -0.01em;
  transition: all 0.2s var(--ease);
  box-shadow: 0 4px 20px rgba(232,66,10,0.25);
  border: none; cursor: pointer; font-family: var(--font);
}

.btn-start:hover {
  filter: brightness(1.07); transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(232,66,10,0.35);
}

.btn-start:active { transform: translateY(0); }

.start-hint { font-size: 13px; color: var(--text-3); margin-top: 12px; }

.start-hint kbd {
  display: inline-block;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 7px;
  font-size: 12px; font-family: var(--mono); color: var(--text-2);
}

/* Benchmark strip */
.bench-strip {
  max-width: 620px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  animation: fadeUp 0.5s var(--ease) 0.16s both;
}

.bench-card {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r-lg); padding: 16px;
  text-align: center; transition: all 0.2s var(--ease);
}

.bench-card:hover { border-color: var(--border-2); box-shadow: var(--shadow-sm); }
.bench-wpm  { font-size: 22px; font-weight: 800; color: var(--text-1); letter-spacing: -0.02em; }
.bench-wpm .unit { font-size: 11px; font-weight: 600; color: var(--text-3); letter-spacing: 0.04em; text-transform: uppercase; }
.bench-label { font-size: 11px; color: var(--text-3); margin-top: 4px; font-weight: 500; }
.bench-dot  { width: 8px; height: 8px; border-radius: 50%; margin: 6px auto 0; }

/* SEO section below fold */
.seo-section {
  max-width: var(--test-max); margin: 48px auto 0;
  animation: fadeUp 0.5s var(--ease) 0.24s both;
}

/* ================================================================
   3. ACTIVE TEST STATE
================================================================ */
#stateTest { position: relative; }

/* Top bar */
.test-topbar {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 20px;
}

.btn-exit {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--r-sm);
  border: 1.5px solid var(--border); background: var(--surface-2);
  font-size: 13px; font-weight: 600; color: var(--text-2);
  transition: all 0.15s; cursor: pointer; font-family: var(--font);
}

.btn-exit:hover { border-color: var(--red); color: var(--red); background: var(--red-dim); }

.test-label {
  font-size: 14px; font-weight: 600; color: var(--text-2);
  flex: 1; text-align: center;
}

.test-timer-wrap { display: flex; align-items: center; gap: 8px; }

.timer-display {
  font-family: var(--mono); font-size: 22px; font-weight: 600;
  color: var(--text-1); letter-spacing: 0.02em;
  min-width: 60px; text-align: right;
}

.timer-display.warning  { color: var(--amber); }
.timer-display.critical { color: var(--red); animation: timerPulse 0.5s ease infinite alternate; }

@keyframes timerPulse { from { opacity: 1; } to { opacity: 0.6; } }

.timer-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green); animation: timerPing 2s ease infinite;
}

.timer-dot.warning  { background: var(--amber); animation: none; }
.timer-dot.critical { background: var(--red); animation: criticalPulse 0.5s ease infinite; }

@keyframes timerPing    { 0%,100%{transform:scale(1);opacity:1;} 50%{transform:scale(1.5);opacity:0.7;} }
@keyframes criticalPulse { 0%,100%{transform:scale(1);} 50%{transform:scale(1.6);} }

/* Progress bar */
.progress-bar-wrap {
  height: 4px; background: var(--surface-3);
  border-radius: 2px; overflow: hidden; margin-bottom: 24px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--amber));
  border-radius: 2px; width: 100%;
  transform-origin: left; transform: scaleX(1);
  transition: transform 0.5s linear;
}

/* Live stats bar */
.stats-bar {
  display: flex; align-items: center; justify-content: center;
  gap: 32px; margin-bottom: 28px;
  padding: 14px 24px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
}

.stat-item { text-align: center; }

.stat-val {
  font-family: var(--mono); font-size: 26px; font-weight: 600;
  color: var(--text-1); line-height: 1; letter-spacing: -0.01em;
  transition: color 0.2s;
}

.stat-val.good { color: var(--green); }
.stat-val.warn { color: var(--amber); }
.stat-lbl { font-size: 11px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-3); margin-top: 4px; }
.stat-sep { width: 1px; height: 36px; background: var(--border); }

/* Text display area */
.text-display-wrap {
  max-width: var(--test-max); margin: 0 auto 20px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r-xl); overflow: hidden;
  box-shadow: var(--shadow-md);
}

.text-display-inner { padding: 28px 32px; position: relative; }

.text-display-desktop { display: block; }
.text-display-mobile  { display: none; }

#textDisplay {
  font-family: var(--mono); font-size: 19px; line-height: 1.85;
  letter-spacing: 0.01em; color: var(--text-3);
  user-select: none; pointer-events: none;
}

/* Character state classes — set by JS */
.char { display: inline; transition: color 0.05s, background 0.05s; border-radius: 2px; }
.char.correct  { color: var(--green); }
.char.wrong    { color: var(--red); background: var(--red-dim); }
.char.cursor   { border-left: 2px solid var(--brand); margin-left: -1px; animation: blink 0.9s step-end infinite; }
.char.upcoming { color: var(--text-3); }
.line-active   { background: var(--brand-dim); margin: -4px -8px; padding: 4px 8px; border-radius: 6px; }

@keyframes blink {
  0%, 100% { border-color: var(--brand); }
  50%       { border-color: transparent; }
}

/* Mobile teleprompter */
.teleprompter {
  font-family: var(--mono); font-size: 18px; line-height: 1.9;
  letter-spacing: 0.01em; overflow: hidden;
  height: calc(1.9em * 3); position: relative;
}

.tp-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 2px; }
.tp-line.prev { color: var(--text-3); opacity: 0.4; font-size: 15px; }
.tp-line.curr { color: var(--text-1); }
.tp-line.next { color: var(--text-3); opacity: 0.6; font-size: 16px; }

/* Input area (hidden on desktop, used for keyboard events) */
.input-wrap { max-width: var(--test-max); margin: 0 auto 16px; }

#testInput {
  width: 100%; padding: 16px 20px;
  font-family: var(--mono); font-size: 17px; line-height: 1.6;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r-lg); color: var(--text-1);
  outline: none; resize: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  caret-color: var(--brand); height: 60px; overflow: hidden;
}

#testInput:focus    { border-color: var(--brand); box-shadow: var(--shadow-glow); }
#testInput.has-error { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-dim); }

/* Paused overlay */
.paused-overlay {
  display: none; position: absolute; inset: 0;
  background: rgba(0,0,0,0.4); backdrop-filter: blur(4px);
  border-radius: var(--r-xl); z-index: 10;
  align-items: center; justify-content: center;
  flex-direction: column; gap: 12px; color: #fff; text-align: center;
}

.paused-overlay.visible { display: flex; animation: fadeIn 0.2s var(--ease) both; }
.paused-icon  { font-size: 40px; }
.paused-title { font-size: 20px; font-weight: 700; }
.paused-sub   { font-size: 14px; opacity: 0.75; }

/* ================================================================
   4. RESULTS STATE
================================================================ */
.results-wrap { max-width: 680px; margin: 0 auto; }

/* Personal best banner */
#pbBanner {
  background: linear-gradient(135deg, rgba(27,107,58,0.12), rgba(27,107,58,0.06));
  border: 1.5px solid rgba(27,107,58,0.3); border-radius: var(--r-lg);
  padding: 14px 20px; margin-bottom: 16px;
  align-items: center; gap: 12px;
  animation: fadeUp 0.5s var(--ease) 0.5s both;
}

/* Score hero */
.score-hero {
  text-align: center; padding: 48px 32px 40px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r-xl); margin-bottom: 16px;
  box-shadow: var(--shadow-lg); position: relative; overflow: hidden;
}

.score-hero::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 60% 50% at 50% 0%, var(--brand-dim), transparent 70%);
  pointer-events: none;
}

.score-emoji {
  font-size: 44px; margin-bottom: 12px; display: block;
  animation: bounceIn 0.6s var(--easeb) 0.1s both;
}

@keyframes bounceIn {
  from { transform: scale(0.3); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.score-wpm {
  font-size: clamp(56px, 12vw, 88px); font-weight: 800;
  letter-spacing: -0.04em; color: var(--text-1); line-height: 1;
  margin-bottom: 4px; animation: countUp 0.8s var(--ease) 0.2s both;
}

@keyframes countUp {
  from { opacity: 0; transform: scale(0.85) translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.score-wpm .unit {
  font-size: 0.35em; font-weight: 700; color: var(--brand);
  letter-spacing: 0.05em; text-transform: uppercase; vertical-align: 8px;
}

.score-acc { font-size: 18px; font-weight: 600; color: var(--text-2); margin-bottom: 16px; }
.score-acc strong { color: var(--green); }

.score-percentile {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--green-dim); border: 1px solid rgba(27,107,58,0.2);
  border-radius: 100px; padding: 6px 16px;
  font-size: 13px; font-weight: 600; color: var(--green);
}

[data-theme="dark"] .score-percentile { border-color: rgba(82,183,136,0.2); }

/* Stat cards grid */
.stat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 10px; margin-bottom: 16px;
}

.stat-card {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r-lg); padding: 18px 16px; text-align: center;
  animation: fadeUp 0.4s var(--ease) both;
}

.stat-card:nth-child(1) { animation-delay: 0.10s; }
.stat-card:nth-child(2) { animation-delay: 0.15s; }
.stat-card:nth-child(3) { animation-delay: 0.20s; }
.stat-card:nth-child(4) { animation-delay: 0.25s; }

.sc-val { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; color: var(--text-1); line-height: 1; margin-bottom: 6px; }
.sc-lbl { font-size: 11px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-3); }

/* Exam readiness bar */
.exam-bar {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r-lg); padding: 18px 22px; margin-bottom: 16px;
  animation: fadeUp 0.4s var(--ease) 0.3s both;
}

.exam-bar-title {
  font-size: 12px; font-weight: 700; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--text-3); margin-bottom: 12px;
}

.exam-rows { display: flex; flex-direction: column; gap: 8px; }

.exam-row { display: flex; align-items: center; gap: 12px; }

.exam-name   { font-size: 14px; font-weight: 600; color: var(--text-1); min-width: 110px; }
.exam-needed { font-size: 13px; color: var(--text-3); flex: 1; }

.exam-status {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 100px;
}

.exam-status.pass { background: var(--green-dim); color: var(--green); }
.exam-status.fail { background: var(--amber-dim); color: var(--amber); }

.exam-progress { flex: 1; height: 5px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.exam-progress-fill { height: 100%; border-radius: 3px; transition: width 1s var(--ease); }
.exam-progress-fill.pass-fill { background: var(--green); }
.exam-progress-fill.fail-fill { background: var(--amber); }

/* Error analysis accordion */
.error-accordion {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden; margin-bottom: 16px;
  animation: fadeUp 0.4s var(--ease) 0.35s both;
}

.err-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; cursor: pointer; background: none;
  font-family: var(--font); gap: 12px;
}

.err-toggle-left { display: flex; align-items: center; gap: 10px; }

.err-count {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--red-dim); color: var(--red);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}

.err-title   { font-size: 14px; font-weight: 700; color: var(--text-1); }
.err-sub     { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.err-chevron { font-size: 18px; color: var(--text-3); transition: transform 0.25s var(--ease); }
.error-accordion.open .err-chevron { transform: rotate(180deg); }

.err-body { display: none; border-top: 1px solid var(--border); padding: 16px 20px; }
.error-accordion.open .err-body { display: block; animation: fadeUp 0.25s var(--ease) both; }

.err-pairs {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 240px; overflow-y: auto;
}

.err-pair {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; padding: 8px 12px;
  background: var(--surface-2); border-radius: var(--r-sm);
}

.err-expected { font-family: var(--mono); color: var(--green); font-weight: 600; }
.err-vs       { color: var(--text-3); font-size: 11px; }
.err-typed    { font-family: var(--mono); color: var(--red); font-weight: 600; }
.err-context  { color: var(--text-3); font-size: 12px; flex: 1; font-family: var(--mono); }

/* Results CTA row */
.results-cta {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px;
  animation: fadeUp 0.4s var(--ease) 0.4s both;
  flex-wrap: wrap;
}

.btn-lg {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 14px 24px; border-radius: var(--r-lg);
  font-size: 15px; font-weight: 700; letter-spacing: -0.01em;
  border: none; cursor: pointer; font-family: var(--font);
  transition: all 0.2s var(--ease);
}

.btn-retry {
  background: var(--brand); color: #fff; flex: 1;
  box-shadow: 0 4px 16px rgba(232,66,10,0.25);
}

.btn-retry:hover { filter: brightness(1.08); transform: translateY(-2px); }

.btn-share {
  background: #25D366; color: #fff; flex: 1;
  box-shadow: 0 4px 16px rgba(37,211,102,0.25);
}

.btn-share:hover { filter: brightness(1.05); transform: translateY(-2px); }

.btn-outline-lg {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 12px 20px; border-radius: var(--r-md);
  border: 1.5px solid var(--border); background: var(--surface-2);
  font-size: 14px; font-weight: 600; color: var(--text-2);
  transition: all 0.15s; font-family: var(--font); cursor: pointer;
}

.btn-outline-lg:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-dim); }

/* ================================================================
   5. CONTENT CARDS (SEO sections below test)
================================================================ */
.content-card {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r-xl); padding: 32px 36px; margin-top: 20px;
}

.content-card h2 { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; color: var(--text-1); margin-bottom: 12px; }
.content-card h3 { font-size: 16px; font-weight: 700; color: var(--text-1); margin: 20px 0 8px; }
.content-card p  { font-size: 14px; color: var(--text-2); line-height: 1.75; margin-bottom: 12px; }
.content-card ul { padding-left: 18px; margin-bottom: 12px; }
.content-card li { font-size: 14px; color: var(--text-2); line-height: 1.7; margin-bottom: 5px; }

/* Table (test-specific override for font size) */
.content-card .table-wrap table { font-size: 13px; }
.content-card .table-wrap thead tr { background: var(--surface-2); }
.content-card .table-wrap th { padding: 10px 16px; font-size: 11px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-3); border-bottom: 1px solid var(--border); }
.content-card .table-wrap td { padding: 10px 16px; border-bottom: 1px solid var(--border); color: var(--text-2); }
.content-card .table-wrap tr:last-child td { border-bottom: none; }
.content-card .table-wrap tr:hover td { background: var(--surface-2); }

/* ================================================================
   6. RESPONSIVE
================================================================ */
@media (max-width: 800px) {
  .bench-strip          { grid-template-columns: repeat(2, 1fr); }
  .stat-grid            { grid-template-columns: repeat(2, 1fr); }
  .text-display-desktop { display: none; }
  .text-display-mobile  { display: block; }
  .stats-bar  { gap: 16px; padding: 12px 16px; }
  .stat-val   { font-size: 22px; }
  .page       { padding-left: 16px; padding-right: 16px; }
  .content-card { padding: 22px 18px; }
}

@media (max-width: 560px) {
  .config-opts  { gap: 6px; }
  .config-btn   { padding: 9px 14px; font-size: 13px; }
  .results-cta  { flex-direction: column; }
  .btn-lg       { width: 100%; justify-content: center; }
  .exam-row     { flex-wrap: wrap; }
}