@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;700;900&family=Source+Serif+4:ital,wght@0,300;0,400;0,600;1,400&display=swap');

:root {
  --ink: #1a1208;
  --parchment: #fdf6e3;
  --cream: #f5ead0;
  --gold: #c8921a;
  --gold-light: #f0c040;
  --red: #8b2020;
  --green: #1a5c2e;
  --blue: #1a3a5c;
  --highlight: #ffe066;
  --shadow: rgba(26,18,8,0.18);
  --correct: #1a5c2e;
  --wrong: #8b2020;
  --radius: 6px;
}

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

body {
  font-family: 'Source Serif 4', Georgia, serif;
  background: var(--parchment);
  color: var(--ink);
  min-height: 100vh;
  padding: 0 0 60px 0;
}

/* ─── Header ─── */
.site-header {
  background: var(--ink);
  color: var(--gold-light);
  padding: 18px 24px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 3px solid var(--gold);
}
.site-header h1 {
  font-family: 'Playfair Display', serif;
  font-size: 1.55rem;
  letter-spacing: 0.04em;
}
.site-header nav a {
  color: var(--gold-light);
  text-decoration: none;
  margin-left: 18px;
  font-size: 0.88rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  opacity: 0.85;
  transition: opacity 0.2s;
}
.site-header nav a:hover { opacity: 1; text-decoration: underline; }

/* ─── Leaderboard banner ─── */
.scoreboard-bar {
  background: var(--gold);
  color: var(--ink);
  padding: 8px 24px;
  display: flex;
  gap: 32px;
  align-items: center;
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 0.95rem;
  border-bottom: 2px solid var(--ink);
  flex-wrap: wrap;
}
.scoreboard-bar .block-score { display: flex; gap: 8px; align-items: center; }
.scoreboard-bar .block-label { font-size: 1.1rem; }
.scoreboard-bar .pts { font-size: 0.8rem; font-weight: 400; margin-left: 2px; }

/* ─── Page wrapper ─── */
.page { max-width: 860px; margin: 0 auto; padding: 32px 20px; }

/* ─── Hero / Worksheet card ─── */
.worksheet-header {
  border: 2px solid var(--ink);
  background: var(--cream);
  padding: 28px 32px 22px;
  margin-bottom: 32px;
  position: relative;
  box-shadow: 4px 4px 0 var(--ink);
}
.worksheet-header::before {
  content: '';
  position: absolute;
  top: 6px; left: 6px; right: -6px; bottom: -6px;
  border: 1.5px solid var(--gold);
  pointer-events: none;
}
.worksheet-header h2 {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  color: var(--ink);
  margin-bottom: 6px;
}
.worksheet-header .subtitle {
  font-style: italic;
  color: var(--blue);
  font-size: 0.95rem;
  margin-bottom: 12px;
}
.worksheet-header .meta {
  display: flex; gap: 20px; flex-wrap: wrap;
  font-size: 0.82rem; color: #555; letter-spacing: 0.03em;
}
.badge {
  display: inline-block;
  background: var(--ink);
  color: var(--gold-light);
  font-family: 'Playfair Display', serif;
  font-size: 0.78rem;
  padding: 3px 10px;
  border-radius: 2px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ─── Student ID section ─── */
.student-id-section {
  background: #fff8e8;
  border: 1.5px solid var(--gold);
  padding: 18px 24px;
  margin-bottom: 28px;
  border-radius: var(--radius);
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.student-id-section label {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 5px;
}
.student-id-section select,
.student-id-section input {
  font-family: 'Source Serif 4', serif;
  font-size: 0.95rem;
  border: 1.5px solid #bbb;
  padding: 6px 10px;
  border-radius: 4px;
  background: #fff;
  outline: none;
}
.student-id-section select:focus,
.student-id-section input:focus {
  border-color: var(--gold);
}
.student-id-section .field { flex: 1; min-width: 140px; }

/* ─── Instructions ─── */
.instructions {
  background: var(--blue);
  color: #e8f0ff;
  border-radius: var(--radius);
  padding: 14px 20px;
  font-size: 0.88rem;
  line-height: 1.7;
  margin-bottom: 28px;
}
.instructions strong { color: var(--gold-light); }

/* ─── Questions ─── */
.question-block {
  background: #fff;
  border: 1px solid #ddd;
  border-left: 4px solid var(--gold);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.question-block.answered-correct {
  border-left-color: var(--correct);
  background: #f3fbf5;
}
.question-block.answered-wrong {
  border-left-color: var(--wrong);
  background: #fdf5f5;
}
.question-num {
  font-family: 'Playfair Display', serif;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.question-text {
  font-size: 1.05rem;
  line-height: 1.75;
  margin-bottom: 12px;
}
.question-text mark {
  background: var(--highlight);
  padding: 1px 3px;
  border-radius: 2px;
  font-weight: 600;
}
.question-text strong {
  text-decoration: underline;
  text-decoration-color: var(--red);
  text-underline-offset: 3px;
}
.question-text em.phrase-mark {
  font-style: normal;
  border-bottom: 2px dashed var(--blue);
}

/* ─── Answer choices ─── */
.choices {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.choice-btn {
  font-family: 'Source Serif 4', serif;
  font-size: 0.92rem;
  text-align: left;
  background: var(--parchment);
  border: 1.5px solid #ccc;
  border-radius: 4px;
  padding: 8px 14px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 10px;
}
.choice-btn:hover:not(:disabled) {
  border-color: var(--gold);
  background: #fff8e0;
}
.choice-btn.selected { border-color: var(--gold); background: #fff8e0; font-weight: 600; }
.choice-btn.correct  { border-color: var(--correct); background: #e6f7ec; color: var(--correct); }
.choice-btn.wrong    { border-color: var(--wrong); background: #fde8e8; color: var(--wrong); }
.choice-btn:disabled { cursor: default; }
.choice-letter {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ddd;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  flex-shrink: 0;
}
.choice-btn.correct .choice-letter { background: var(--correct); color: #fff; }
.choice-btn.wrong   .choice-letter { background: var(--wrong); color: #fff; }

/* ─── Feedback ─── */
.feedback {
  margin-top: 10px;
  font-size: 0.85rem;
  line-height: 1.6;
  padding: 8px 12px;
  border-radius: 4px;
  display: none;
}
.feedback.show { display: block; }
.feedback.correct-fb { background: #e6f7ec; color: var(--correct); border-left: 3px solid var(--correct); }
.feedback.wrong-fb   { background: #fde8e8; color: var(--wrong); border-left: 3px solid var(--wrong); }

/* ─── Progress & Submit ─── */
.progress-bar-wrap {
  background: #e0d8c8;
  border-radius: 20px;
  height: 10px;
  margin-bottom: 8px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
  border-radius: 20px;
  transition: width 0.4s ease;
}
.progress-text {
  font-size: 0.82rem;
  color: #777;
  margin-bottom: 24px;
}

.submit-btn {
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem;
  font-weight: 700;
  background: var(--ink);
  color: var(--gold-light);
  border: 2px solid var(--ink);
  padding: 12px 36px;
  cursor: pointer;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 4px;
  transition: all 0.2s;
  box-shadow: 3px 3px 0 var(--gold);
}
.submit-btn:hover:not(:disabled) {
  background: var(--gold);
  color: var(--ink);
  box-shadow: none;
  transform: translate(2px, 2px);
}
.submit-btn:disabled { opacity: 0.5; cursor: default; }

/* ─── Results panel ─── */
.results-panel {
  display: none;
  background: var(--ink);
  color: var(--gold-light);
  border-radius: var(--radius);
  padding: 30px 28px;
  margin-top: 30px;
  text-align: center;
  box-shadow: 5px 5px 0 var(--gold);
}
.results-panel.show { display: block; }
.results-panel h3 {
  font-family: 'Playfair Display', serif;
  font-size: 1.8rem;
  margin-bottom: 8px;
}
.results-panel .score-big {
  font-family: 'Playfair Display', serif;
  font-size: 3.5rem;
  font-weight: 900;
  color: var(--gold-light);
  line-height: 1;
  margin: 12px 0;
}
.results-panel .score-sub { font-size: 0.95rem; opacity: 0.8; margin-bottom: 20px; }
.results-panel .saved-msg {
  background: rgba(255,255,255,0.1);
  padding: 10px 16px;
  border-radius: 4px;
  font-size: 0.88rem;
  margin-top: 14px;
}

/* ─── Index page grid ─── */
.worksheet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 22px;
  margin-top: 28px;
}
.ws-card {
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 22px 20px;
  text-decoration: none;
  color: var(--ink);
  display: block;
  transition: all 0.18s;
  box-shadow: 4px 4px 0 var(--ink);
  position: relative;
}
.ws-card:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 var(--gold);
}
.ws-card .card-pts {
  position: absolute;
  top: 14px; right: 14px;
  background: var(--gold);
  color: var(--ink);
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 3px 9px;
  border-radius: 12px;
}
.ws-card h3 {
  font-family: 'Playfair Display', serif;
  font-size: 1.15rem;
  margin-bottom: 6px;
  padding-right: 56px;
}
.ws-card p {
  font-size: 0.84rem;
  color: #555;
  line-height: 1.55;
}
.ws-card .card-status {
  margin-top: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.ws-card .card-status.done { color: var(--correct); }
.ws-card .card-status.pending { color: #999; }

/* ─── Leaderboard page ─── */
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
  font-size: 0.95rem;
}
.leaderboard-table th {
  background: var(--ink);
  color: var(--gold-light);
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  padding: 10px 14px;
  text-align: left;
  letter-spacing: 0.05em;
}
.leaderboard-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #e0d8c8;
}
.leaderboard-table tr:nth-child(even) td { background: var(--cream); }
.leaderboard-table tr:hover td { background: #fff8e0; }
.rank-1 td { font-weight: 700; color: var(--gold); }

/* ─── Responsive ─── */
@media (max-width: 600px) {
  .site-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .worksheet-header { padding: 20px 16px; }
  .worksheet-header h2 { font-size: 1.4rem; }
  .page { padding: 20px 12px; }
  .student-id-section { flex-direction: column; }
}
