/* ============================
   STYLES.CSS — Examens Interactifs
   "Il était une fois un vieux couple heureux"
   Mohammed Khaïr-Eddine
   ============================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,700;1,400&family=Crimson+Pro:ital,wght@0,300;0,400;0,600;1,300;1,400&display=swap');

/* ---- Variables ---- */
:root {
  --sand:       #f5efe6;
  --parchment:  #ede3d0;
  --ochre:      #c2854a;
  --terracotta: #a8553a;
  --ink:        #2c1e0f;
  --ink-light:  #4a3520;
  --moss:       #4a6741;
  --sky:        #5b7fa6;
  --cream:      #fdf8f0;
  --gold:       #d4a83a;
  --correct:    #3a7a3a;
  --wrong:      #9e2a2a;
  --neutral:    #6b5a42;
  --border:     #c8b89a;
  --shadow:     rgba(44,30,15,0.12);
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Crimson Pro', Georgia, serif;
  background-color: var(--sand);
  color: var(--ink);
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse at 20% 10%, rgba(194,133,74,0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 90%, rgba(168,85,58,0.06) 0%, transparent 50%);
}

/* ---- Navigation Index ---- */
.nav-index {
  background: var(--ink);
  color: var(--parchment);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px var(--shadow);
}

.nav-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 2rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-inner::-webkit-scrollbar { display: none; }

.nav-brand {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 1rem;
  color: var(--gold);
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.nav-sep {
  color: var(--ochre);
  flex-shrink: 0;
  opacity: 0.6;
}

.nav-exams {
  display: flex;
  gap: 0.4rem;
  list-style: none;
  flex-shrink: 0;
}

.nav-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--parchment);
  font-family: 'Crimson Pro', serif;
  font-size: 0.85rem;
  padding: 0.3rem 0.65rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.nav-btn:hover,
.nav-btn.active {
  background: var(--ochre);
  border-color: var(--ochre);
  color: #fff;
}

/* ---- Hero ---- */
.hero {
  text-align: center;
  padding: 5rem 2rem 3rem;
  background: linear-gradient(to bottom, var(--cream), var(--sand));
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(90deg, transparent, transparent 60px, rgba(194,133,74,0.04) 60px, rgba(194,133,74,0.04) 61px);
  pointer-events: none;
}

.hero-ornament {
  font-size: 2rem;
  color: var(--ochre);
  letter-spacing: 1rem;
  margin-bottom: 1.5rem;
  opacity: 0.6;
}

.hero h1 {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

.hero h1 em {
  color: var(--terracotta);
  font-style: italic;
}

.hero-subtitle {
  font-size: 1.1rem;
  color: var(--neutral);
  font-style: italic;
  margin-bottom: 0.25rem;
}

.hero-author {
  font-size: 0.95rem;
  color: var(--ochre);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---- Main Container ---- */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* ---- Exam Panel ---- */
.exam-panel {
  display: none;
  animation: fadeSlide 0.4s ease;
}
.exam-panel.active { display: block; }

@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Exam Header ---- */
.exam-header {
  background: var(--ink);
  color: var(--parchment);
  border-radius: 12px 12px 0 0;
  padding: 2rem 2.5rem 1.5rem;
  position: relative;
  overflow: hidden;
}

.exam-header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--ochre), var(--gold), var(--terracotta));
}

.exam-num {
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.5rem;
}

.exam-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.75rem;
}

.exam-meta {
  display: flex;
  gap: 1.5rem;
  font-size: 0.88rem;
  color: rgba(237,227,208,0.7);
}

.exam-meta span {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

/* ---- Text Support Box ---- */
.text-support {
  background: var(--cream);
  border: 1px solid var(--border);
  border-top: none;
  padding: 2rem 2.5rem;
  position: relative;
}

.text-support-label {
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ochre);
  font-weight: 600;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.text-support-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.text-support p {
  font-size: 1.05rem;
  line-height: 1.85;
  color: var(--ink-light);
  text-align: justify;
  font-style: italic;
  border-left: 3px solid var(--ochre);
  padding-left: 1.25rem;
}

/* ---- Questions Section ---- */
.questions-section {
  background: #fff;
  border: 1px solid var(--border);
  border-top: none;
  padding: 2.5rem;
}

.section-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  color: var(--ink);
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.section-title .icon {
  background: var(--ochre);
  color: #fff;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem;
  flex-shrink: 0;
}

/* ---- Question Item ---- */
.question-item {
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: var(--cream);
  border-radius: 8px;
  border: 1px solid var(--border);
  transition: border-color 0.2s;
}

.question-item:last-child { margin-bottom: 0; }

.question-text {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 1rem;
  line-height: 1.5;
}

.question-num {
  display: inline-block;
  background: var(--ochre);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.1rem 0.5rem;
  border-radius: 20px;
  margin-right: 0.5rem;
  font-family: 'Crimson Pro', serif;
  letter-spacing: 0.05em;
}

/* ---- Options (QCM) ---- */
.options-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.option-label {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1rem;
  line-height: 1.4;
  user-select: none;
}

.option-label:hover {
  border-color: var(--ochre);
  background: rgba(194,133,74,0.05);
}

.option-label input[type="radio"],
.option-label input[type="checkbox"] {
  margin-top: 0.15rem;
  accent-color: var(--ochre);
  flex-shrink: 0;
  width: 16px; height: 16px;
}

/* Option states after correction */
.option-label.correct {
  background: rgba(58,122,58,0.1);
  border-color: var(--correct);
  color: var(--correct);
}

.option-label.wrong {
  background: rgba(158,42,42,0.08);
  border-color: var(--wrong);
  color: var(--wrong);
}

.option-label.missed {
  background: rgba(58,122,58,0.06);
  border-color: var(--correct);
  color: var(--correct);
  font-weight: 600;
}

/* ---- True/False ---- */
.tf-group {
  display: flex;
  gap: 0.75rem;
}

.tf-btn {
  flex: 1;
  padding: 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-family: 'Crimson Pro', serif;
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.2s;
  color: var(--ink);
}
.tf-btn:hover { border-color: var(--ochre); background: rgba(194,133,74,0.05); }
.tf-btn.selected { background: var(--ochre); border-color: var(--ochre); color: #fff; }
.tf-btn.correct  { background: var(--correct); border-color: var(--correct); color: #fff; }
.tf-btn.wrong    { background: var(--wrong); border-color: var(--wrong); color: #fff; }

/* ---- Fill in the blank ---- */
.fill-blank {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-size: 1rem;
}

.blank-input {
  border: none;
  border-bottom: 2px solid var(--ochre);
  background: transparent;
  font-family: 'Crimson Pro', serif;
  font-size: 1rem;
  color: var(--ink);
  padding: 0.2rem 0.4rem;
  width: 160px;
  outline: none;
  transition: border-color 0.2s;
}
.blank-input:focus { border-color: var(--terracotta); }
.blank-input.correct { border-color: var(--correct); background: rgba(58,122,58,0.08); color: var(--correct); }
.blank-input.wrong   { border-color: var(--wrong); background: rgba(158,42,42,0.06); color: var(--wrong); }

/* ---- Feedback ---- */
.feedback {
  display: none;
  margin-top: 0.75rem;
  padding: 0.6rem 0.9rem;
  border-radius: 5px;
  font-size: 0.9rem;
  line-height: 1.4;
}
.feedback.show { display: block; }
.feedback.correct-fb { background: rgba(58,122,58,0.1); color: var(--correct); border-left: 3px solid var(--correct); }
.feedback.wrong-fb   { background: rgba(158,42,42,0.08); color: var(--wrong); border-left: 3px solid var(--wrong); }

/* ---- Score Banner ---- */
.score-banner {
  display: none;
  margin-top: 1.5rem;
  padding: 1.25rem 2rem;
  background: var(--ink);
  color: var(--gold);
  border-radius: 8px;
  text-align: center;
  font-family: 'Playfair Display', serif;
  font-size: 1.3rem;
}
.score-banner.show { display: block; }
.score-banner .score-detail { font-family: 'Crimson Pro', serif; font-size: 0.95rem; color: var(--parchment); margin-top: 0.3rem; }

/* ---- Action Buttons ---- */
.actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.btn {
  padding: 0.7rem 1.5rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Crimson Pro', serif;
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.2s;
  letter-spacing: 0.03em;
}

.btn-primary {
  background: var(--ochre);
  color: #fff;
}
.btn-primary:hover { background: var(--terracotta); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(168,85,58,0.25); }

.btn-secondary {
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover { border-color: var(--ochre); color: var(--ochre); }

/* ---- Production Écrite ---- */
.production-section {
  background: var(--parchment);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 12px 12px;
  padding: 2.5rem;
}

.production-theme {
  background: var(--ink);
  color: var(--cream);
  border-radius: 8px;
  padding: 1.25rem 1.75rem;
  margin-bottom: 1.5rem;
  position: relative;
  overflow: hidden;
}
.production-theme::before {
  content: '✍';
  position: absolute;
  right: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 2.5rem;
  opacity: 0.15;
}

.production-theme h3 {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  color: var(--gold);
  margin-bottom: 0.5rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 0.8rem;
}

.production-theme p {
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--parchment);
}

.toolbox {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}

.toolbox-title {
  font-size: 0.78rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ochre);
  font-weight: 600;
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toolbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}

.tool-category {
  background: var(--cream);
  border-radius: 6px;
  padding: 0.75rem;
}

.tool-category h4 {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--terracotta);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.tool-category ul {
  list-style: none;
  font-size: 0.92rem;
  color: var(--ink-light);
  line-height: 1.7;
}

.tool-category li::before {
  content: '·';
  color: var(--ochre);
  margin-right: 0.35rem;
  font-weight: bold;
}

.writing-area {
  width: 100%;
  min-height: 200px;
  padding: 1.25rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: 'Crimson Pro', serif;
  font-size: 1.05rem;
  line-height: 1.85;
  color: var(--ink);
  background: #fff;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
  background-image: repeating-linear-gradient(transparent, transparent 31px, rgba(194,133,74,0.15) 31px, rgba(194,133,74,0.15) 32px);
  background-attachment: local;
}
.writing-area:focus { border-color: var(--ochre); }
.writing-area::placeholder { color: rgba(74,53,32,0.35); font-style: italic; }

.word-counter {
  text-align: right;
  font-size: 0.85rem;
  color: var(--neutral);
  margin-top: 0.4rem;
}

/* ---- Exam Grid / Selector ---- */
.exam-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.exam-card {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  cursor: pointer;
  transition: all 0.25s;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.exam-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--ochre), var(--gold));
  transform: scaleX(0);
  transition: transform 0.25s;
}

.exam-card:hover {
  border-color: var(--ochre);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px var(--shadow);
}
.exam-card:hover::before { transform: scaleX(1); }

.exam-card-num {
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ochre);
  margin-bottom: 0.5rem;
}

.exam-card-title {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  color: var(--ink);
  line-height: 1.3;
}

/* ---- Welcome screen ---- */
.welcome {
  text-align: center;
  padding: 3rem 2rem;
}

.welcome h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.8rem;
  color: var(--ink);
  margin-bottom: 1rem;
}

.welcome p {
  font-size: 1.1rem;
  color: var(--neutral);
  line-height: 1.7;
  max-width: 600px;
  margin: 0 auto 2rem;
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .exam-header { padding: 1.5rem; }
  .text-support, .questions-section, .production-section { padding: 1.5rem; }
  .toolbox-grid { grid-template-columns: 1fr; }
  .actions { flex-direction: column; }
  .exam-meta { flex-direction: column; gap: 0.4rem; }
}

/* ---- Student Name Bar ---- */
.student-name-bar {
  background: linear-gradient(135deg, var(--ink) 0%, #3a2a14 100%);
  border: 1px solid var(--border);
  border-top: none;
  padding: 1.25rem 2.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.student-name-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--gold);
  font-family: 'Crimson Pro', serif;
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.04em;
}

.student-name-icon {
  font-size: 1.1rem;
}

.student-name-input {
  flex: 1;
  min-width: 220px;
  max-width: 420px;
  padding: 0.6rem 1rem;
  border: 1.5px solid var(--ochre);
  border-radius: 6px;
  background: rgba(253,248,240,0.08);
  color: var(--cream);
  font-family: 'Crimson Pro', serif;
  font-size: 1.05rem;
  outline: none;
  transition: all 0.2s;
}
.student-name-input::placeholder { color: rgba(237,227,208,0.35); font-style: italic; }
.student-name-input:focus {
  border-color: var(--gold);
  background: rgba(253,248,240,0.13);
  box-shadow: 0 0 0 3px rgba(212,168,58,0.15);
}

/* ---- WhatsApp Bar ---- */
.whatsapp-bar {
  margin-top: 1.25rem;
  background: linear-gradient(135deg, #1a3324, #0d2018);
  border-radius: 10px;
  padding: 1.25rem 1.75rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  border: 1px solid rgba(37,211,102,0.25);
  box-shadow: 0 4px 18px rgba(0,0,0,0.18);
}

.btn-whatsapp {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: #25D366;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.75rem 1.6rem;
  font-family: 'Crimson Pro', serif;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: all 0.22s;
  box-shadow: 0 4px 14px rgba(37,211,102,0.35);
  white-space: nowrap;
}
.btn-whatsapp:hover {
  background: #20c05a;
  transform: translateY(-2px);
  box-shadow: 0 7px 22px rgba(37,211,102,0.45);
}
.btn-whatsapp:active { transform: translateY(0); }

.whatsapp-hint {
  font-family: 'Crimson Pro', serif;
  font-size: 0.9rem;
  color: rgba(37,211,102,0.75);
  font-style: italic;
  line-height: 1.4;
}

@media (max-width: 640px) {
  .student-name-bar { padding: 1rem 1.5rem; flex-direction: column; align-items: flex-start; }
  .student-name-input { max-width: 100%; width: 100%; }
  .whatsapp-bar { flex-direction: column; align-items: flex-start; }
}