/* ═══════════════════════════════════════════════════════
   Ardor Academy — TOEIC Mock Test · Global Stylesheet
   ═══════════════════════════════════════════════════════ */

:root {
  --brand-orange: #F47B3E;
  --brand-red:    #E03C38;
  --brand-dark:   #1C1C1E;
  --text-primary: #1a1a1a;
  --text-muted:   #6b7280;
  --border:       #e5e7eb;
  --bg-page:      #f3f4f6;
  --bg-card:      #ffffff;
  --blue-accent:  #2563eb;
  --green:        #16a34a;
  --radius:       10px;
  --shadow:       0 2px 12px rgba(0,0,0,0.08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
}

/* ─── Header ─────────────────────────────────────────── */
.aa-header {
  background: var(--brand-dark);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.aa-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.aa-logo-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.aa-logo-text {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  line-height: 1.1;
}

.aa-logo-text span {
  color: #9ca3af;
  font-weight: 400;
}

.aa-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* ─── Timer ──────────────────────────────────────────── */
.timer-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 5px 12px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
}

.timer-badge svg { opacity: 0.7; }

.timer-badge.warning { background: rgba(234,179,8,0.15); border-color: #ca8a04; color: #fde68a; }
.timer-badge.danger  { background: rgba(220,38,38,0.2);  border-color: #dc2626; color: #fca5a5; animation: pulse 1s infinite; }

@keyframes pulse { 0%,100% { opacity:1 } 50% { opacity:.6 } }

/* ─── Section badge in header ────────────────────────── */
.section-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brand-orange);
  padding: 3px 8px;
  border: 1px solid var(--brand-orange);
  border-radius: 4px;
}

/* ─── Layout ─────────────────────────────────────────── */
.main-layout {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 20px;
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 20px 40px;
}

@media (max-width: 768px) {
  .main-layout { grid-template-columns: 1fr; }
  .sidebar { order: -1; }
}

/* ─── Card ───────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

/* ─── Part header inside card ────────────────────────── */
.part-header {
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.part-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brand-orange);
}

.question-counter {
  font-size: 13px;
  color: var(--text-muted);
  margin-left: auto;
}

/* ─── Audio player ───────────────────────────────────── */
.audio-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fafafa;
}

.play-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--brand-dark);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.play-btn:hover:not(:disabled) { background: #333; }
.play-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.play-btn.played { background: #4b5563; }

.play-hint {
  font-size: 12px;
  color: var(--text-muted);
}

/* ─── Photo area ─────────────────────────────────────── */
.photo-section {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  text-align: center;
  background: #f9fafb;
}

.photo-section img {
  max-width: 100%;
  max-height: 320px;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.12);
}

/* ─── Question body ──────────────────────────────────── */
.question-body { padding: 20px; }

.question-instruction {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 14px;
  font-style: italic;
}

.question-item {
  margin-bottom: 24px;
}

.question-item:last-child { margin-bottom: 0; }

.question-text {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.6;
  margin-bottom: 14px;
}

/* Part 6 passage */
.passage-box {
  background: #f8f9fb;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  font-size: 14.5px;
  line-height: 1.8;
  margin-bottom: 20px;
  white-space: pre-wrap;
}

.blank-highlight {
  display: inline-block;
  background: #fef3c7;
  border: 1.5px solid #d97706;
  border-radius: 4px;
  padding: 0 8px;
  font-weight: 700;
  color: #92400e;
  font-size: 13px;
}

.blank-active {
  background: #dbeafe;
  border-color: var(--blue-accent);
  color: var(--blue-accent);
}

/* ─── Options ────────────────────────────────────────── */
.options-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option-item label {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font-size: 15px;
  line-height: 1.4;
}

.option-item label:hover { border-color: var(--brand-orange); background: #fff7f2; }

.option-item input[type=radio] { display: none; }

.option-item input[type=radio]:checked + label {
  border-color: var(--brand-orange);
  background: #fff4ee;
}

.option-letter {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-top: 1px;
}

input[type=radio]:checked + label .option-letter {
  background: var(--brand-orange);
  color: #fff;
}

/* ─── Navigation footer ──────────────────────────────── */
.nav-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s, opacity 0.15s;
}

.btn:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-secondary {
  background: #f3f4f6;
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: #e5e7eb; }

.btn-primary {
  background: var(--brand-dark);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: #333; }

.btn-orange {
  background: var(--brand-orange);
  color: #fff;
}
.btn-orange:hover:not(:disabled) { background: #e5671e; }

.btn-submit {
  background: var(--green);
  color: #fff;
}
.btn-submit:hover:not(:disabled) { background: #15803d; }

/* ─── Sidebar ────────────────────────────────────────── */
.sidebar { display: flex; flex-direction: column; gap: 16px; }

.sidebar-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}

.sidebar-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* Question palette */
.palette {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.palette-btn {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  background: #f9fafb;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
}

.palette-btn.current {
  border-color: var(--brand-orange);
  color: var(--brand-orange);
  background: #fff4ee;
}

.palette-btn.answered {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  color: #fff;
}

.palette-btn.answered.current {
  background: var(--brand-orange);
  border-color: var(--brand-orange);
}

.palette-btn.locked {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #ef4444;
  cursor: not-allowed;
  opacity: 0.7;
}

.palette-legend {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: var(--text-muted);
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ─── Cover page ─────────────────────────────────────── */
.cover-page {
  min-height: calc(100vh - 56px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}

.cover-card {
  background: var(--bg-card);
  border-radius: 16px;
  box-shadow: 0 4px 32px rgba(0,0,0,0.1);
  border: 1px solid var(--border);
  max-width: 640px;
  width: 100%;
  overflow: hidden;
}

.cover-hero {
  background: var(--brand-dark);
  padding: 36px 40px 28px;
  text-align: center;
}

.cover-hero h1 {
  font-size: 24px;
  font-weight: 800;
  color: #fff;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.cover-hero p {
  margin-top: 6px;
  font-size: 14px;
  color: #9ca3af;
}

.cover-body { padding: 32px 40px; }

.test-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 28px;
}

.meta-item {
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}

.meta-item .meta-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.meta-item .meta-val {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.form-input {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
  margin-bottom: 14px;
}

.form-input:focus { border-color: var(--brand-orange); }

.instructions-toggle {
  background: none;
  border: none;
  color: var(--blue-accent);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  margin-bottom: 20px;
  display: block;
}

.instructions-box {
  background: #f8f9fb;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.7;
  margin-bottom: 20px;
  display: none;
}

.instructions-box.open { display: block; }

.instructions-box ul { padding-left: 18px; }
.instructions-box li { margin-bottom: 5px; }

.start-btn {
  width: 100%;
  padding: 14px;
  background: var(--brand-orange);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  letter-spacing: 0.01em;
}

.start-btn:hover { background: #e5671e; }
.start-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.disclaimer-text {
  margin-top: 20px;
  font-size: 11px;
  color: #9ca3af;
  line-height: 1.6;
  text-align: center;
}

/* ── Print styles (PDF download) ── */
@media print {
  @page { margin: 18mm 16mm; }

  .aa-header, .lang-switcher, #download-card,
  #retake-btn, .toast, .disclaimer-text { display: none !important; }

  #print-header { display: block !important; }

  body { background: #fff !important; }

  .results-page { max-width: 100%; padding: 0; }

  .score-hero {
    background: #1C1C1E !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 16px;
  }

  .results-grid { grid-template-columns: 1fr 1fr; gap: 12px; }

  .result-section-card, .results-card {
    break-inside: avoid;
    border: 1px solid #e5e7eb;
    box-shadow: none;
  }

  .score-bar-fill {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* Greyscale photo for Part 1 */
#question-photo { filter: grayscale(100%); }

/* Side-by-side layout for Part 6 & 7 */
.question-body.passage-split {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
.question-body.passage-split #passage-wrapper {
  flex: 1;
  position: sticky;
  top: 76px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}
.question-body.passage-split #single-q,
.question-body.passage-split #group-q {
  flex: 1;
  min-width: 0;
}

/* ─── Section transition ─────────────────────────────── */
.section-break {
  min-height: calc(100vh - 56px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.section-break-card {
  background: var(--bg-card);
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  max-width: 540px;
  width: 100%;
  padding: 40px;
  text-align: center;
}

.section-break-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
  font-size: 28px;
}

.section-break-card h2 {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 8px;
}

.section-break-card p {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 24px;
}

/* ─── Results page ───────────────────────────────────── */
.results-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.score-hero {
  background: var(--brand-dark);
  border-radius: 14px;
  padding: 32px;
  text-align: center;
  margin-bottom: 20px;
  color: #fff;
}

.score-hero h2 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #9ca3af;
  margin-bottom: 8px;
}

.score-total {
  font-size: 72px;
  font-weight: 900;
  line-height: 1;
  color: #fff;
  letter-spacing: -0.03em;
}

.score-max {
  font-size: 22px;
  font-weight: 400;
  color: #6b7280;
}

.cefr-band {
  display: inline-block;
  margin-top: 12px;
  background: var(--brand-orange);
  color: #fff;
  border-radius: 6px;
  padding: 4px 14px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.cefr-summary {
  margin-top: 8px;
  font-size: 13px;
  color: #9ca3af;
}

.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 600px) { .results-grid { grid-template-columns: 1fr; } }

.result-section-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.result-section-card h3 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.score-bar-row {
  margin-bottom: 10px;
}

.score-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 4px;
}

.score-bar-label span:first-child { color: var(--text-primary); font-weight: 500; }
.score-bar-label span:last-child  { color: var(--text-muted); }

.score-bar-track {
  height: 7px;
  background: #e5e7eb;
  border-radius: 99px;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--brand-orange);
  transition: width 0.8s cubic-bezier(.4,0,.2,1);
}

.score-bar-fill.low  { background: var(--brand-red); }
.score-bar-fill.high { background: var(--green); }

/* Weakness + tips */
.results-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.results-card h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tip-item {
  padding: 12px 14px;
  border-radius: 8px;
  border-left: 3px solid var(--brand-orange);
  background: #fff7f2;
  margin-bottom: 10px;
  font-size: 13.5px;
  line-height: 1.6;
}

.tip-item strong { display: block; margin-bottom: 3px; }
.tip-item:last-child { margin-bottom: 0; }

.tip-item.good {
  border-left-color: var(--green);
  background: #f0fdf4;
}

/* Email section */
.email-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.email-card h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
}

.email-row {
  display: flex;
  gap: 10px;
}

.email-row .form-input { margin-bottom: 0; }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
  background: #fff;
  border-radius: 14px;
  padding: 28px 32px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
}

.modal h3 { font-size: 18px; font-weight: 800; margin-bottom: 10px; }
.modal p  { font-size: 14px; color: var(--text-muted); margin-bottom: 20px; line-height: 1.6; }

.modal-actions { display: flex; gap: 10px; justify-content: center; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--brand-dark);
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 300;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--green); }
.toast.error   { background: var(--brand-red); }

/* ─── Language switcher ──────────────────────────────── */
.lang-switcher {
  display: flex;
  align-items: center;
  gap: 2px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 3px;
}

.lang-btn {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.lang-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }
.lang-btn.active { background: rgba(255,255,255,0.15); color: #fff; }

/* Util */
.text-muted  { color: var(--text-muted); }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.d-none { display: none !important; }
