/* =========================================================================
   style.css — design de l'engine CPGE (clair/sombre, français, responsive).
   Spectral (titres, serif) + Inter (corps) + un seul accent bleu encre.
   Le thème suit l'OS par défaut ; le bouton bascule mémorise dans localStorage
   (voir theme.js + l'anti-FOUC dans base.html).
   ========================================================================= */

:root {
  --bg:        #fafbfe;
  --surface:   #ffffff;
  --text:      #1b1c24;
  --muted:     #6a6d7e;
  --border:    #e6e7f1;
  --accent:    #1e50c8;   /* bleu encre */
  --accent-fg: #ffffff;
  --ok:        #1f9d63;   /* sémantique : nouveau / validé */
  --warn:      #c98a16;   /* sémantique : attention */
  --danger:    #cc2f2f;   /* sémantique : urgent / erreur (au-dessus de warn) */
  --shadow:    0 1px 2px rgba(20, 20, 40, .06), 0 8px 24px rgba(20, 20, 40, .05);
  --radius:    12px;
  --maxw:      52rem;
}

:root[data-theme="dark"] {
  --bg:        #13141b;
  --surface:   #1b1d27;
  --text:      #e9eaf2;
  --muted:     #989bb2;
  --border:    #2a2d3c;
  --accent:    #6f9bf2;   /* bleu encre éclairci pour fond sombre */
  --accent-fg: #13141b;
  --ok:        #54c98c;
  --warn:      #e0b15a;
  --danger:    #f06a6a;
  --shadow:    0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: Spectral, Georgia, "Times New Roman", serif;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
}
h1 { font-size: 2rem; margin: 0 0 .25rem; }
h2 { font-size: 1.35rem; margin: 0 0 .75rem; }

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

/* ---- Barre du haut (collante, se condense au défilement) ------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1rem 1.25rem;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  -webkit-backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid transparent;
  transition: padding .18s ease, border-color .18s ease, box-shadow .18s ease;
}
/* Ajoutée par theme.js dès que la page défile (scrollY > 4). */
.topbar.is-stuck {
  padding-top: .55rem;
  padding-bottom: .55rem;
  border-bottom-color: var(--border);
  box-shadow: var(--shadow);
}

/* Respecte le réglage système « réduire les animations ». */
@media (prefers-reduced-motion: reduce) {
  .topbar, .nav a, .nav-toggle, .theme-toggle { transition: none; }
  html { scroll-behavior: auto; }
}
.home {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  min-width: 0;
  font-family: Spectral, serif;
  font-weight: 600;
  font-size: 1.15rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.home:hover { text-decoration: none; }
.logo { height: 1.8rem; width: auto; display: block; }

.nav {
  display: flex;
  align-items: center;
  gap: .15rem;
  flex-wrap: nowrap;
  flex: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .25rem;
}
.nav a {
  color: var(--muted);
  padding: .4rem .85rem;
  border-radius: 999px;
  font-size: .95rem;
  transition: background .15s, color .15s;
}
.nav a:hover { color: var(--text); background: var(--bg); text-decoration: none; }
.nav a.active { background: var(--accent); color: var(--accent-fg); font-weight: 600; }
.nav a.active:hover { background: var(--accent); color: var(--accent-fg); }

/* Anneau de focus clavier visible (tous les éléments interactifs de la barre). */
.nav a:focus-visible,
.home:focus-visible,
.theme-toggle:focus-visible,
.nav-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- Bouton hamburger (mobile uniquement) ---------------------------- */
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2rem; height: 2rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
}
.nav-toggle svg { width: 1.1rem; height: 1.1rem; }

@media (max-width: 36rem) {
  .nav-toggle { display: inline-flex; }
  /* La nav devient un panneau déroulant sous la barre. */
  .nav {
    position: absolute;
    top: calc(100% + .35rem);
    right: .75rem;
    left: .75rem;
    flex-direction: column;
    align-items: stretch;
    gap: .1rem;
    border-radius: var(--radius);
    padding: .4rem;
    box-shadow: var(--shadow);
    display: none;
  }
  .topbar.nav-open .nav { display: flex; }
  .nav a { padding: .6rem .75rem; }
}

.theme-toggle {
  margin-left: .25rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  width: 2rem; height: 2rem;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}
.theme-toggle:hover { border-color: var(--accent); }

/* ---- Contenu --------------------------------------------------------- */
.content {
  max-width: var(--maxw);
  margin: 1rem auto 4rem;
  padding: 0 1.25rem;
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .78rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 .35rem;
}
.lede { color: var(--muted); font-size: 1.1rem; margin: 0 0 1.5rem; }
.notice {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  border-radius: var(--radius);
  padding: .85rem 1rem;
  margin: 0 0 1.5rem;
}
/* Variantes sémantiques (réutilisent --ok / --warn). */
.notice--ok {
  background: color-mix(in srgb, var(--ok) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--ok) 32%, var(--border));
}
.notice--warn {
  background: color-mix(in srgb, var(--warn) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--warn) 34%, var(--border));
}
.notice--danger {
  background: color-mix(in srgb, var(--danger) 11%, var(--surface));
  border-color: color-mix(in srgb, var(--danger) 36%, var(--border));
}

/* Petite étiquette d'état en ligne (ex. « Nouveau », « DS samedi »). */
.tag {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .78rem;
  font-weight: 600;
  padding: .15rem .55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.tag::before { content: ""; width: .5rem; height: .5rem; border-radius: 999px; background: currentColor; }
.tag--ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 32%, var(--border)); background: color-mix(in srgb, var(--ok) 9%, var(--surface)); }
.tag--warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 34%, var(--border)); background: color-mix(in srgb, var(--warn) 11%, var(--surface)); }
.tag--danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 36%, var(--border)); background: color-mix(in srgb, var(--danger) 11%, var(--surface)); }

.block { margin: 2rem 0; }

/* ---- Barre de filtre (bloc `list` filterable) ------------------------- */
/* Recherche + menu déroulant de tags à cocher (multi-sélection, OU) + tri +
   compteur. Sans JS, la barre est inerte et la liste complète s'affiche
   (filter.js). */
.filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .4rem;
  margin: 0 0 .8rem;
}
.filter-search {
  flex: 1 1 12rem;
  min-width: 9rem;
  padding: .35rem .7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .9rem;
}
.filter-search:focus { outline: none; border-color: var(--accent); }

/* Menu de tags : <details> stylé en bouton, panneau flottant de cases à cocher. */
.facet { position: relative; }
.facet > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  padding: .32rem .7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: .85rem;
  font-weight: 500;
  white-space: nowrap;
}
.facet > summary::-webkit-details-marker { display: none; }
.facet > summary::after { content: " ▾"; color: var(--muted); font-size: .75em; }
.facet > summary:hover { border-color: var(--accent); }
.facet[open] > summary {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  color: var(--accent);
}
.facet-count { color: var(--accent); }
.facet-panel {
  position: absolute;
  top: calc(100% + .35rem);
  left: 0;
  z-index: 20;
  min-width: 15rem;
  max-height: 18rem;
  overflow: auto;
  padding: .55rem .7rem;
  display: flex;
  flex-direction: column;
  gap: .2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.facet-option {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-size: .88rem;
  cursor: pointer;
  white-space: nowrap;
}
.facet-option input { accent-color: var(--accent); margin: 0; }

/* Sélecteur de tri, assorti au champ de recherche. */
.filter-sort {
  padding: .32rem .5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .85rem;
  cursor: pointer;
}
.filter-sort:focus { outline: none; border-color: var(--accent); }

.filter-count { color: var(--muted); font-size: .82rem; margin-left: auto; }

/* Petites étiquettes de tags sous une entrée de liste (informatif ; les mêmes
   valeurs servent de facettes quand le bloc est filtrable), et compte de
   l'entrée (`count` + `count_label`, ex. « 26 questions »). */
.pdf-list .row-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .3rem;
  margin-top: 2px;
}
.pdf-list .row-tag {
  padding: .05rem .5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: .72rem;
  white-space: nowrap;
}
.pdf-list .row-count { color: var(--muted); font-size: .78rem; white-space: nowrap; }

/* ---- Listes (la primitive : 1 ou N liens, + desc optionnel) ---------- */
.pdf-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.pdf-list .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .85rem 1.1rem;
  border-top: 1px solid var(--border);
}
.pdf-list .row:first-child { border-top: none; }
/* Ligne masquée par le filtre (attribut hidden posé par filter.js) : le
   display:flex ci-dessus l'emporterait sur la règle UA [hidden] — on la rétablit.
   Dans une liste filtrable, le trait ne sépare que des lignes VISIBLES (la
   première visible n'est pas forcément :first-child). */
.pdf-list .row[hidden] { display: none; }
.pdf-list--filterable .row { border-top: none; }
.pdf-list--filterable .row:not([hidden]) ~ .row:not([hidden]) {
  border-top: 1px solid var(--border);
}

/* row-main / row-desc : titre, description et date empilés à gauche de la ligne. */
.pdf-list .row-main { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pdf-list .row-title { font-weight: 500; }
.pdf-list .row-desc { color: var(--muted); font-size: .9rem; }
.pdf-list .row-date { color: var(--muted); font-size: .82rem; }

.row-links { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }
.pdf-link {
  display: inline-block;
  padding: .3rem .7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 500;
  white-space: nowrap;
}
.pdf-link:hover { border-color: var(--accent); background: var(--bg); text-decoration: none; }

.pending { color: var(--muted); font-style: italic; }

/* Ligne « À venir » (entrée sans lien) : grisée, comme une carte inactive. */
.pdf-list .row-disabled { opacity: .55; }

/* `.doc-list` : alias historique de `.pdf-list` (les deux ont été unifiés). */
.doc-list { /* même rendu que .pdf-list */ }

/* Highlight = « dernier document » : une liste rendue compacte et mise en avant. */
.highlight {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
}
.highlight .row { padding: 1rem 1.1rem; }
.highlight .row-title { font-size: 1.05rem; font-weight: 600; }

/* ---- Cards (navigation / hub) ---------------------------------------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1rem;
}
.card {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  padding: 1.1rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
  transition: border-color .15s ease, transform .15s ease;
}
.card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  text-decoration: none;
}
.card-title { font-family: Spectral, serif; font-weight: 600; font-size: 1.15rem; }
.card-desc { color: var(--muted); font-size: .92rem; }

/* Carte inactive (« À venir ») : grisée, non cliquable. Équivalent navigation de
   l'état « À venir » d'une liste — voir cards.html. */
.card-disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.card-disabled:hover { border-color: var(--border); transform: none; }

/* ---- Featured (un lien proéminent) -----------------------------------
   Action principale « cliquez ici » : volontairement plus discrète qu'un
   gros bouton plein, mais reste l'élément le plus saillant de la page.
   Partage la matière des cartes (surface + ombre) avec un fond et un filet
   teintés d'accent, plus une pastille fléchée pleine à droite. */
.featured {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.1rem;
  margin: 1.5rem 0;
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
}
.featured:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  text-decoration: none;
}
.featured .featured-main { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.featured .featured-label { font-weight: 600; font-size: 1.05rem; }
.featured .featured-sub { color: var(--muted); font-size: .9rem; }
/* Pastille fléchée : l'affordance « action » qui porte l'accent plein. */
.featured .featured-go {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem; height: 2rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 1.1rem;
  line-height: 1;
  transition: transform .15s ease;
}
.featured:hover .featured-go { transform: translateX(2px); }

/* ---- Prose (markdown rendu) ------------------------------------------ */
.prose { max-width: 42rem; }
.prose h2 { margin-top: 2rem; }
.prose h3 { font-family: Spectral, serif; margin-top: 1.5rem; }
.prose img { max-width: 100%; height: auto; border-radius: 8px; }
.prose table { border-collapse: collapse; width: 100%; margin: 1rem 0; }
.prose th, .prose td { border: 1px solid var(--border); padding: .5rem .7rem; text-align: left; }
.prose th { background: var(--surface); }
.prose code {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: .1rem .35rem;
  font-size: .9em;
}
.prose pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow: auto;
}
.prose pre code { border: none; padding: 0; background: none; }
.prose blockquote {
  border-left: 3px solid var(--accent);
  margin: 1rem 0;
  padding: .25rem 0 .25rem 1rem;
  color: var(--muted);
}

/* ---- Pied de page ---------------------------------------------------- */
.footer {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
  color: var(--muted);
  font-size: .9rem;
  border-top: 1px solid var(--border);
}
.footer-extra { margin-top: .35rem; }

/* ---- Responsive ------------------------------------------------------ */
@media (max-width: 36rem) {
  h1 { font-size: 1.6rem; }
  .topbar { padding: .85rem 1rem; }
  .pdf-list .row { flex-direction: column; align-items: flex-start; gap: .5rem; }
  .row-links { justify-content: flex-start; }
}
