/* Thème commun des pages Élèves — même look que la section Math CST (prepa/).
   Chargé par histoire-secondaire-4.html et histoire-secondaire-3.html.
   La couleur de la page est donnée par --c sur <body>. */
:root {
  --ink: #1d1a16;
  --paper: #fdf8ea;
  --c-eleve: #a9d3f2;
  --c-groupe: #ffb9a6;
  --c-curriculum: #c5e18d;
  --c-creations: #ffd866;
  --terra: #c0392b;
  --dash: color-mix(in oklab, var(--ink) 25%, transparent);
  --grid: color-mix(in oklab, var(--ink) 7%, transparent);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  --c: var(--c-eleve);
  font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  line-height: 1.5;
  background: #fff;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ===== Structure : barre latérale + contenu ===== */
.pa-app { display: flex; min-height: 100vh; }
.pa-side {
  position: sticky; top: 0; height: 100vh; width: 15rem; flex: none;
  display: flex; flex-direction: column; overflow-y: auto;
  background: var(--paper); border-right: 2px solid var(--ink);
}
.pa-brand { display: flex; align-items: center; gap: .625rem; padding: 1rem 1rem .5rem; }
.pa-logo {
  display: grid; place-items: center; width: 2rem; height: 2rem; flex: none;
  border: 2px solid var(--ink); border-bottom-width: 4px; border-radius: .625rem;
  background: var(--c-creations); font-weight: 800; font-size: .8rem; transform: rotate(-5deg);
}
.pa-brand strong { display: block; font-size: 1.05rem; font-weight: 800; letter-spacing: -.01em; line-height: 1.2; }
.pa-brand small { display: block; font-size: .7rem; opacity: .6; line-height: 1.2; }
.pa-nav { display: flex; flex-direction: column; gap: .5rem; padding: .75rem; }
.pa-tile {
  display: flex; align-items: center; gap: .75rem; width: 100%; padding: .5rem .625rem;
  border: 2px solid transparent; border-bottom-width: 4px; border-radius: 1rem;
  transition: background-color .15s, border-color .15s, transform .1s;
}
.pa-tile:hover { background: color-mix(in oklab, var(--c) 40%, transparent); }
.pa-tile:hover .pa-badge { transform: rotate(-7deg) scale(1.06); }
.pa-tile:active { transform: translateY(2px); }
.pa-tile[aria-current=page] { background: #fff; border-color: var(--ink); }
.pa-tile b { display: block; font-size: .875rem; font-weight: 700; line-height: 1.25; }
.pa-tile small { display: block; font-size: .72rem; line-height: 1.3; opacity: .65; }
.pa-badge {
  display: grid; place-items: center; flex: none; width: 2.5rem; height: 2.5rem;
  border: 2px solid var(--ink); border-radius: .75rem; background: var(--c); transition: transform .15s;
}
.pa-badge svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pa-side-deco {
  flex: 1; min-height: 3rem; margin-top: .5rem;
  background-image: linear-gradient(color-mix(in oklab, var(--ink) 9%, transparent) 1px, transparent 1px), linear-gradient(90deg, color-mix(in oklab, var(--ink) 9%, transparent) 1px, transparent 1px);
  background-size: 20px 20px;
  -webkit-mask-image: linear-gradient(transparent, #000); mask-image: linear-gradient(transparent, #000);
}
.pa-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ===== Bandeau de page ===== */
.pa-hero {
  display: flex; flex-wrap: wrap; align-items: center; gap: .875rem 1rem;
  padding: 1.125rem 2rem; border-bottom: 2px solid var(--ink);
  background-color: color-mix(in oklab, var(--c) 50%, #fff);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 20px 20px;
}
.pa-hero .pa-badge { width: 3rem; height: 3rem; border-bottom-width: 4px; background: #fff; transform: rotate(-4deg); }
.pa-hero .pa-badge svg { width: 24px; height: 24px; }
.pa-hero h1 { font-size: 1.375rem; font-weight: 800; letter-spacing: -.015em; line-height: 1.2; }
.pa-hero p { font-size: .875rem; opacity: .75; }

/* ===== Contenu ===== */
.pa-board { flex: 1; width: 100%; max-width: var(--w, 46rem); margin: 0 auto; padding: 1.75rem 2rem 3rem; }
.pa-board-head { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.25rem; }
.pa-board-head h2 { flex: 1; font-size: 1.25rem; font-weight: 800; letter-spacing: -.01em; }
.pa-hint { margin-top: 1rem; font-size: .875rem; opacity: .7; }
.site-foot { padding: 1.25rem 2rem 1.75rem; border-top: 2px dashed var(--dash); text-align: center; font-size: .8125rem; }
.site-foot a { font-weight: 700; }
.site-foot a:hover { text-decoration: underline; }

/* Pastilles et boutons */
.pa-pill {
  display: inline-block; padding: .05rem .5rem; border: 2px solid var(--ink); border-radius: 999px;
  background: #fff; font-size: .625rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; line-height: 1.5; white-space: nowrap;
}
.pa-pill--final { background: var(--c-groupe); }
.pa-btn {
  display: inline-flex; align-items: center; gap: .375rem; padding: .3rem .75rem;
  border: 2px solid var(--ink); border-bottom-width: 4px; border-radius: .75rem; background: #fff;
  font-size: .8125rem; font-weight: 700; cursor: pointer; white-space: nowrap; transition: transform .1s, background-color .15s;
}
.pa-btn:hover { background: var(--paper); }
.pa-btn:active { transform: translateY(2px); }
.pa-btn--fill { background: var(--c-creations); }
.pa-btn--fill:hover { background: color-mix(in oklab, var(--c-creations) 70%, #fff); }

/* ===== Accueil : liste des matières ===== */
.pa-stus { display: grid; gap: .75rem; list-style: none; }
.pa-stu {
  display: flex; align-items: center; gap: .875rem; width: 100%; padding: .75rem 1rem;
  border: 2px solid var(--ink); border-bottom-width: 5px; border-radius: 1rem; background: #fff;
  transition: background-color .15s, transform .1s;
}
.pa-stu:hover { background: color-mix(in oklab, var(--c) 35%, #fff); }
.pa-stu:hover .pa-badge { transform: rotate(-7deg) scale(1.06); }
.pa-stu:active { transform: translateY(2px); }
.pa-stu > span:nth-child(2) { flex: 1; min-width: 0; }
.pa-stu b { display: block; font-size: 1rem; font-weight: 800; line-height: 1.25; }
.pa-stu small { display: block; font-size: .8rem; opacity: .7; }
.pa-stu .arrow { font-weight: 800; }

/* ===== Tableau du plan ===== */
.plan-scroll { overflow-x: auto; border: 2px solid var(--ink); border-bottom-width: 4px; border-radius: 1.25rem; background: #fff; }
.plan-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.plan-table th, .plan-table td { padding: .5rem .75rem; text-align: left; vertical-align: middle; border-bottom: 1px solid color-mix(in oklab, var(--ink) 10%, transparent); }
.plan-table tbody tr:last-child td { border-bottom: 0; }
.plan-table thead th {
  border-bottom: 2px solid var(--ink); background: color-mix(in oklab, var(--c) 45%, #fff);
  font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap;
}
.plan-table tbody tr { transition: background-color .15s; }
.plan-table tbody tr:hover > td:not(.bloc) { background: color-mix(in oklab, var(--c) 28%, #fff); }
.plan-table .chapitre td, .plan-table .chapitre:hover > td:not(.bloc) {
  padding-top: .65rem; padding-bottom: .65rem; background: var(--paper);
  border-top: 2px dashed var(--dash); border-bottom: 2px dashed var(--dash); font-size: .95rem; font-weight: 800;
}
.plan-table tbody tr.chapitre:first-child td { border-top: 0; }
.plan-table .bloc {
  vertical-align: top; white-space: nowrap; border-right: 2px dashed var(--dash);
  font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
}
.plan-table .item { white-space: nowrap; font-size: .8rem; opacity: .7; }
.plan-table .eval td { font-weight: 700; }
.plan-table td.pdf, .plan-table td.audio { white-space: nowrap; }
.plan-table td.ecoute, .plan-table th.th-ecoute { text-align: center; }
.plan-table .chk {
  appearance: none; -webkit-appearance: none; display: inline-block; vertical-align: middle;
  width: 1.2rem; height: 1.2rem; border: 2px solid var(--ink); border-radius: .3rem; background: #fff center / 100% no-repeat; cursor: pointer;
}
.plan-table .chk:checked {
  background-color: var(--ink);
  background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3e%3c/svg%3e");
}
.plan-table .play, .plan-table .pdfbtn {
  display: inline-flex; align-items: center; justify-content: center; height: 1.9rem;
  border: 2px solid var(--ink); border-bottom-width: 3px; border-radius: .6rem; background: #fff;
  font-size: .7rem; font-weight: 800; letter-spacing: .06em; line-height: 1; cursor: pointer; transition: transform .1s, background-color .15s;
}
.plan-table .play { width: 1.9rem; background: var(--c-creations); font-family: "Segoe UI Symbol", "Arial Unicode MS", sans-serif; font-variant-emoji: text; }
.plan-table .pdfbtn { padding: 0 .65rem; }
.plan-table .play:hover { background: color-mix(in oklab, var(--c-creations) 70%, #fff); }
.plan-table .pdfbtn:hover { background: var(--c-creations); }
.plan-table .play:active, .plan-table .pdfbtn:active { transform: translateY(2px); }
.plan-table .play.playing { background: var(--ink); color: #fff; }
/* Item écouté : ligne en vert « réussi » */
.plan-table tr.done > td:not(.bloc), .plan-table tr.done:hover > td:not(.bloc) { background: color-mix(in oklab, var(--c-curriculum) 55%, #fff); }

/* ===== Fenêtre PDF + notes ===== */
.pdf-modal {
  position: fixed; inset: 0; z-index: 50; background: rgb(29 26 22 / .45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.pdf-modal[hidden] { display: none; }
.pdf-box {
  width: min(1240px, 100%); height: min(88vh, 1100px); display: flex; flex-direction: column; overflow: hidden;
  border: 2px solid var(--ink); border-bottom-width: 5px; border-radius: 1.25rem; background: #fff;
}
.pdf-head {
  display: flex; align-items: center; gap: .875rem; padding: .75rem 1rem;
  border-bottom: 2px solid var(--ink); background-color: color-mix(in oklab, var(--c) 50%, #fff);
}
.pdf-head strong { margin-right: auto; font-size: 1.05rem; font-weight: 800; }
.pdf-head audio { height: 36px; max-width: 320px; }
.pdf-audio { display: flex; align-items: center; gap: .375rem; }
.pdf-audio[hidden] { display: none; }
.saut, .pdf-close, .notes-btn {
  flex: none; border: 2px solid var(--ink); border-bottom-width: 4px; border-radius: .75rem; background: #fff;
  font-size: .8125rem; font-weight: 700; white-space: nowrap; cursor: pointer; transition: transform .1s, background-color .15s;
}
.saut { height: 2.1rem; padding: 0 .65rem; }
.pdf-close { width: 2.1rem; height: 2.1rem; font-size: 1.15rem; line-height: 1; }
.notes-btn { padding: .2rem .65rem; background: var(--c-creations); }
.saut:hover, .pdf-close:hover { background: var(--paper); }
.notes-btn:hover { background: color-mix(in oklab, var(--c-creations) 70%, #fff); }
.saut:active, .pdf-close:active, .notes-btn:active { transform: translateY(2px); }
.pdf-body { flex: 1; display: flex; min-height: 0; }
.pdf-body iframe { flex: 2 1 0; min-width: 0; width: 100%; border: 0; }
.notes { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; border-left: 2px solid var(--ink); background: #fff; }
.notes-head {
  display: flex; align-items: center; gap: .5rem; padding: .5rem .75rem;
  border-bottom: 2px solid var(--ink); background: var(--paper); font-size: .75rem;
}
.notes-head strong { margin-right: auto; font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.notes-etat { font-size: .7rem; font-weight: 700; white-space: nowrap; }
.notes-tools {
  position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
  padding: .375rem .5rem; border-bottom: 2px dashed var(--dash); background: #fff;
}
.notes-tools .sep { width: 2px; height: 20px; background: var(--dash); margin: 0 4px; }
.notes-tools button {
  position: relative; width: 30px; height: 28px; border: 2px solid transparent; border-radius: .5rem; background: transparent;
  font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.notes-tools button:hover { background: var(--paper); border-color: var(--ink); }
.notes-tools button.on { background: var(--c-creations); border-color: var(--ink); }
.notes-tools button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.notes-tools .couleur { position: static; }
.notes-tools .couleur .barre { position: absolute; left: 5px; right: 5px; bottom: 2px; height: 3px; border-radius: 2px; }
.palette {
  position: absolute; top: calc(100% - 2px); left: 8px; z-index: 5; display: none; gap: 5px; align-items: center; flex-wrap: wrap; max-width: calc(100% - 16px);
  padding: 7px; border: 2px solid var(--ink); border-bottom-width: 4px; border-radius: .875rem; background: #fff;
}
.palette.open { display: flex; }
.palette .pastille, .notes-tools .palette .pastille { width: 22px; height: 22px; border: 2px solid var(--ink); border-radius: 50%; cursor: pointer; padding: 0; }
.palette .pastille:hover { transform: scale(1.15); }
.palette .pastille.aucune { background: #fff; position: relative; }
.palette .pastille.aucune::after { content: ""; position: absolute; left: 2px; right: 2px; top: 50%; height: 2px; margin-top: -1px; background: var(--terra); transform: rotate(-45deg); }
.palette .autre {
  position: relative; width: 22px; height: 22px; border: 2px solid var(--ink); border-radius: 50%; overflow: hidden; cursor: pointer;
  background: conic-gradient(#f44, #fa0, #ff4, #4c4, #4cf, #44f, #c4f, #f44);
}
.palette .autre input { position: absolute; inset: -4px; opacity: 0; cursor: pointer; }
.notes-editor {
  flex: 1; min-height: 0; overflow: auto; outline: 0; padding: 1rem 1.125rem; font-size: 14px; line-height: 1.7;
  background-color: var(--paper);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 20px 20px; background-attachment: local;
}
.notes-editor:empty::before { content: attr(data-placeholder); opacity: .55; pointer-events: none; }
.notes-editor ul, .notes-editor ol { padding-left: 22px; }

/* ===== Petits écrans ===== */
@media (max-width: 820px) {
  .pa-app { flex-direction: column; }
  .pa-side { position: static; width: 100%; height: auto; flex-direction: row; align-items: center; overflow: visible; border-right: 0; border-bottom: 2px solid var(--ink); }
  .pa-brand { padding: .5rem 0 .5rem .75rem; }
  .pa-brand > span:last-child { display: none; }
  .pa-nav { flex: 1; min-width: 0; flex-direction: row; gap: .25rem; padding: .5rem .5rem; overflow-x: auto; scrollbar-width: thin; }
  .pa-tile { width: auto; flex: none; gap: .5rem; padding: .3rem .6rem .3rem .35rem; border-bottom-width: 3px; }
  .pa-tile small { display: none; }
  .pa-tile .pa-badge { width: 2rem; height: 2rem; border-radius: .6rem; }
  .pa-side-deco { display: none; }
  .pa-hero { padding: 1rem; }
  .pa-board { padding: 1.25rem 1rem 2.5rem; }
  .plan-table th, .plan-table td { padding: .45rem .5rem; }
  .plan-table .bloc { white-space: normal; }
}
@media (max-width: 760px) {
  .pdf-body { flex-direction: column; }
  .notes { border-left: 0; border-top: 2px solid var(--ink); }
}
@media (max-width: 560px) {
  .pdf-head { flex-wrap: wrap; }
  .pdf-audio { width: 100%; order: 3; }
  .pdf-head audio { max-width: 100%; width: 100%; flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .pa-tile, .pa-badge, .pa-stu, .pa-btn, .plan-table tbody tr, .plan-table .play, .plan-table .pdfbtn, .saut, .pdf-close, .notes-btn { transition: none; }
  .pa-tile:hover .pa-badge, .pa-stu:hover .pa-badge { transform: none; }
}
