@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,600;9..144,700&family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --ink: #12213D;
  --ink-soft: #1D3057;
  --paper: #F1E9D2;
  --paper-dim: #E4D9BA;
  --gold: #C89B3C;
  --gold-soft: #E3C878;
  --pen-red: #B23A2E;
  --pen-green: #3F7A5C;
  --text-on-ink: #F1E9D2;
  --text-muted: #9DAAC7;
  --radius: 4px;
  --shadow: 0 8px 24px rgba(18, 33, 61, 0.25);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--text-on-ink);
  font-family: 'IBM Plex Sans Arabic', sans-serif;
  direction: rtl;
  min-height: 100vh;
  background-image:
    radial-gradient(circle at 15% 10%, rgba(200, 155, 60, 0.08), transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(200, 155, 60, 0.06), transparent 40%);
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

.wrap {
  max-width: 780px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

/* ===== Letterhead / Header ===== */
.letterhead {
  border-bottom: 1px solid rgba(241, 233, 210, 0.2);
  padding-bottom: 20px;
  margin-bottom: 32px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.letterhead .seal {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--gold-soft);
  border: 1px solid var(--gold);
  border-radius: 999px;
  padding: 4px 12px;
  white-space: nowrap;
}

.brand {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 22px;
  color: var(--text-on-ink);
  text-decoration: none;
}

.brand span { color: var(--gold); }

/* ===== Typography ===== */
h1, h2, h3 {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  color: var(--text-on-ink);
  line-height: 1.25;
  margin: 0 0 8px;
}

h1 { font-size: clamp(28px, 5vw, 40px); }
h2 { font-size: 24px; }

p { line-height: 1.7; color: var(--text-muted); margin: 0 0 16px; }

.eyebrow {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--gold-soft);
  text-transform: uppercase;
  margin-bottom: 10px;
  display: block;
}

/* ===== Cards / Feature tiles ===== */
.grid {
  display: grid;
  gap: 16px;
  margin-top: 28px;
}

.tile {
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  text-decoration: none;
  display: block;
  position: relative;
  border: 1px solid rgba(18, 33, 61, 0.08);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.tile:hover { transform: translateY(-3px); box-shadow: 0 14px 32px rgba(18, 33, 61, 0.35); }

.tile .code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--pen-red);
  letter-spacing: 0.06em;
  margin-bottom: 6px;
  display: block;
}

.tile h3 {
  color: var(--ink);
  font-size: 20px;
  margin-bottom: 6px;
}

.tile p { color: #4A4536; margin: 0; font-size: 14.5px; }

.tile .arrow {
  position: absolute;
  left: 20px;
  bottom: 20px;
  font-size: 18px;
  color: var(--pen-red);
}

/* ===== Standard picker (practice page) ===== */
.standard-list { display: grid; gap: 10px; margin-top: 20px; }

.standard-row {
  background: var(--ink-soft);
  border: 1px solid rgba(241, 233, 210, 0.12);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.standard-row:hover { border-color: var(--gold); background: #223561; }

.standard-row .meta {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--gold-soft);
}

.standard-row .name { color: var(--text-on-ink); font-size: 14.5px; margin-top: 2px; }
.standard-row .count { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--text-muted); }

/* ===== Question card (bubble sheet) ===== */
.progress-bar {
  height: 4px;
  background: rgba(241, 233, 210, 0.15);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 22px;
}
.progress-fill { height: 100%; background: var(--gold); transition: width 0.3s ease; }

.qcard {
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}

.qcard .qmeta {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--pen-red);
  letter-spacing: 0.08em;
  margin-bottom: 14px;
  display: flex;
  gap: 14px;
}

.qcard .qtext {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 17px;
  line-height: 1.6;
  direction: ltr;
  text-align: left;
  color: var(--ink);
  margin-bottom: 24px;
}

.options { display: grid; gap: 10px; }

.option {
  display: flex;
  align-items: center;
  gap: 12px;
  direction: ltr;
  text-align: left;
  border: 1.5px solid rgba(18, 33, 61, 0.2);
  border-radius: var(--radius);
  padding: 12px 16px;
  cursor: pointer;
  background: transparent;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14.5px;
  color: var(--ink);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.option:hover { border-color: var(--ink); background: rgba(18, 33, 61, 0.04); }

.bubble {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
  position: relative;
}

.option.selected .bubble { background: var(--ink); }
.option.selected .bubble::after {
  content: '';
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--paper);
}

.option.correct { border-color: var(--pen-green); background: rgba(63, 122, 92, 0.1); }
.option.correct .bubble { background: var(--pen-green); border-color: var(--pen-green); }
.option.correct .bubble::after { background: var(--paper); }

.option.incorrect { border-color: var(--pen-red); background: rgba(178, 58, 46, 0.08); }
.option.incorrect .bubble { background: var(--pen-red); border-color: var(--pen-red); }
.option.incorrect .bubble::after { background: var(--paper); }

.option[disabled] { cursor: default; }

.mark {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  margin-right: auto;
}
.mark.ok { color: var(--pen-green); }
.mark.no { color: var(--pen-red); }

.explanation {
  margin-top: 18px;
  padding: 14px 16px;
  background: rgba(18, 33, 61, 0.05);
  border-right: 3px solid var(--gold);
  border-radius: 2px;
  font-size: 14px;
  color: #3A3626;
  direction: ltr;
  text-align: left;
  display: none;
}
.explanation.show { display: block; }

.draft-flag {
  display: inline-block;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--pen-red);
  border: 1px solid var(--pen-red);
  border-radius: 3px;
  padding: 1px 6px;
  margin-inline-start: 8px;
}

/* ===== Buttons ===== */
.btn {
  font-family: 'IBM Plex Sans Arabic', sans-serif;
  font-weight: 600;
  font-size: 15px;
  border: none;
  border-radius: var(--radius);
  padding: 13px 26px;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
}
.btn:active { transform: scale(0.97); }
.btn-gold { background: var(--gold); color: var(--ink); }
.btn-gold:hover { background: var(--gold-soft); }
.btn-outline { background: transparent; color: var(--text-on-ink); border: 1.5px solid rgba(241,233,210,0.3); }
.btn-outline:hover { border-color: var(--gold); color: var(--gold-soft); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-row { display: flex; gap: 12px; margin-top: 22px; justify-content: flex-end; }

/* ===== Results screen ===== */
.result-hero {
  text-align: center;
  padding: 40px 20px;
}
.result-score {
  font-family: 'Fraunces', serif;
  font-size: 64px;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
}
.result-label { font-family: 'IBM Plex Mono', monospace; font-size: 13px; color: var(--text-muted); letter-spacing: 0.08em; margin-top: 8px; }

.breakdown { display: grid; gap: 8px; margin-top: 28px; }
.breakdown-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--ink-soft); border-radius: var(--radius); padding: 10px 16px;
  font-size: 13.5px;
}
.breakdown-row .code { font-family: 'IBM Plex Mono', monospace; color: var(--gold-soft); }

/* ===== Back link ===== */
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-muted); text-decoration: none; font-size: 14px;
  margin-bottom: 20px;
}
.back-link:hover { color: var(--gold-soft); }

/* ===== Loading state ===== */
.loading { text-align: center; padding: 60px 20px; color: var(--text-muted); font-family: 'IBM Plex Mono', monospace; font-size: 13px; }
