/* === Permis Bateau — Shared Stylesheet ===
   Inspired by Tufte CSS: clean, print-friendly, readable typography.
   https://edwardtufte.github.io/tufte-css/
*/

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --color-bg: #fffff8;
  --color-text: #111;
  --color-muted: #6a6a6a;
  --color-accent: #1a5276;
  --color-accent-light: #2980b9;
  --color-border: #ddd;
  --color-correct: #27ae60;
  --color-wrong: #e74c3c;
  --color-warning: #f39c12;
  --font-serif: 'Georgia', 'Times New Roman', serif;
  --font-sans: 'Helvetica Neue', 'Arial', sans-serif;
  --font-mono: 'SFMono-Regular', 'Consolas', 'Liberation Mono', monospace;
  --max-width: 720px;
  --line-height: 1.6;
}

html { font-size: 15px; }
body {
  font-family: var(--font-serif);
  line-height: var(--line-height);
  color: var(--color-text);
  background: var(--color-bg);
  margin: 0;
  padding: 2rem 1rem;
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: 600;
  line-height: 1.2;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  color: var(--color-accent);
}

h1 { font-size: 2.2rem; margin-top: 0; border-bottom: 2px solid var(--color-accent); padding-bottom: 0.3rem; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.3rem; }
h4 { font-size: 1.1rem; }

p, ul, ol, dl { margin-bottom: 1rem; }

a { color: var(--color-accent-light); text-decoration: none; }
a:hover { text-decoration: underline; }

blockquote {
  border-left: 4px solid var(--color-accent);
  margin: 1.5rem 0;
  padding: 0.5rem 1rem;
  background: #f8f8f4;
  font-style: italic;
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: #f0f0ea;
  padding: 0.1em 0.3em;
  border-radius: 3px;
}

pre code {
  display: block;
  padding: 1rem;
  overflow-x: auto;
  background: #f0f0ea;
  border-radius: 4px;
}

hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 2rem 0;
}

/* --- Layout --- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
}

/* --- Tables --- */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-family: var(--font-sans);
  font-size: 0.95rem;
}

th, td {
  border: 1px solid var(--color-border);
  padding: 0.5rem 0.75rem;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--color-accent);
  color: white;
  font-weight: 600;
}

tr:nth-child(even) td { background: #f8f8f4; }

/* --- Figures / Images --- */
figure {
  margin: 1.5rem 0;
  text-align: center;
}

figure img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

figcaption {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--color-muted);
  margin-top: 0.5rem;
}

/* --- Cards / Infoboxes --- */
.card {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.25rem;
  margin: 1.5rem 0;
  background: white;
}

.card--info { border-left: 4px solid var(--color-accent-light); }
.card--warning { border-left: 4px solid var(--color-warning); }
.card--tip { border-left: 4px solid var(--color-correct); }

.card h4:first-child { margin-top: 0; }

/* --- Quiz --- */
.quiz-question {
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.25rem;
  margin: 1.25rem 0;
}

.quiz-question p { margin-bottom: 0.5rem; }

.quiz-options { list-style: none; padding: 0; }

.quiz-option {
  display: block;
  padding: 0.6rem 1rem;
  margin: 0.4rem 0;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: background 0.15s, border-color 0.15s;
}

.quiz-option:hover {
  background: #f0f0ea;
  border-color: var(--color-accent-light);
}

.quiz-option.selected {
  background: #e8f0fe;
  border-color: var(--color-accent-light);
}

.quiz-option.correct {
  background: #e8f8e8;
  border-color: var(--color-correct);
}

.quiz-option.wrong {
  background: #fde8e8;
  border-color: var(--color-wrong);
}

.quiz-feedback {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  display: none;
}

.quiz-feedback.show { display: block; }
.quiz-feedback.correct { background: #e8f8e8; border: 1px solid var(--color-correct); }
.quiz-feedback.wrong { background: #fde8e8; border: 1px solid var(--color-wrong); }

/* --- Examen blanc (mode examen, correction différée) --- */
.exam-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  padding: 0.6rem 0.2rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.exam-bar .count { font-weight: 700; color: var(--color-accent); }

.exam-question {
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin: 1rem 0;
}
.exam-question .topic-chip {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  padding: 0.1rem 0.5rem;
  border-radius: 3px;
  background: #eef3f7;
  color: var(--color-accent);
  margin-bottom: 0.5rem;
}

.exam-btn {
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  border-radius: 6px;
  background: var(--color-accent);
  color: white;
  padding: 0.75rem 1.5rem;
}
.exam-btn:hover { background: var(--color-accent-light); }
.exam-btn:disabled { opacity: 0.5; cursor: default; }
.exam-btn.secondary { background: #fff; color: var(--color-accent); border: 1px solid var(--color-accent); }

.exam-result {
  border-radius: 10px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  text-align: center;
  font-family: var(--font-sans);
}
.exam-result.pass { background: #e8f8e8; border: 2px solid var(--color-correct); }
.exam-result.fail { background: #fde8e8; border: 2px solid var(--color-wrong); }
.exam-result .score { font-size: 2.4rem; font-weight: 800; color: var(--color-accent); }
.exam-result .verdict { font-size: 1.3rem; font-weight: 800; margin: 0.3rem 0; }

@media print {
  .exam-bar { position: static; }
}

/* --- Navigation / Meta --- */
.lesson-nav {
  display: flex;
  justify-content: space-between;
  margin: 2rem 0;
  padding: 1rem 0;
  border-top: 1px solid var(--color-border);
  font-family: var(--font-sans);
  font-size: 0.95rem;
}

.meta {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--color-muted);
  margin: 1rem 0;
}

.tag {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  margin-right: 0.3rem;
  color: white;
}

.tag--côtier { background: #2980b9; }
.tag--fluvial { background: #27ae60; }
.tag--important { background: #e74c3c; }
.tag--commun { background: #8e44ad; }

/* --- Print --- */
@media print {
  body {
    font-size: 12pt;
    padding: 0;
    color: #000;
    background: #fff;
  }

  .container { max-width: 100%; }

  a { color: inherit; text-decoration: none; }

  .quiz-option { break-inside: avoid; }
  .quiz-feedback { display: none !important; }

  @page { margin: 1.5cm; }
}

/* --- Responsive --- */
@media (max-width: 600px) {
  html { font-size: 14px; }
  body { padding: 1rem; }
  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.4rem; }
}
