/* =====================================================================
   PRAN NÒT - main.css
   Reset, base typographique, mise en page générale.
   ===================================================================== */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--c-navy);
  line-height: var(--lh-tight);
  margin: 0 0 var(--sp-3);
  letter-spacing: -0.02em;
  font-weight: 700;
}
h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }
p { margin: 0 0 var(--sp-4); }
small { font-size: var(--fs-sm); }
mark { background: var(--c-accent-soft); color: var(--c-navy); padding: 0 2px; border-radius: 3px; }
code, kbd { font-family: var(--font-mono); font-size: 0.92em; background: var(--c-surface); padding: 1px 6px; border-radius: 6px; }
hr { border: 0; border-top: 1px solid var(--c-border); margin: var(--sp-8) 0; }

/* Focus visible accessible */
:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--c-accent-ring);
  outline-offset: 2px;
  border-radius: 6px;
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: var(--sp-4); top: -60px; z-index: 100;
  background: var(--c-navy); color: var(--c-on-navy); padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-sm); text-decoration: none; transition: top var(--dur);
}
.skip-link:focus { top: var(--sp-4); }

/* ------------------------------------------------------------------
   Mise en page applicative
   ------------------------------------------------------------------ */
.app-main {
  flex: 1;
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: var(--nav-top-offset) var(--sp-6) var(--sp-16);
}
.app-main.narrow { max-width: var(--container-narrow); }

@media (max-width: 768px) {
  .app-main {
    padding: var(--sp-6) var(--sp-4) calc(var(--mobile-nav-h) + var(--sp-16) + env(safe-area-inset-bottom));
  }
  .page-head {
    flex-direction: column;
    align-items: stretch;
    gap: var(--sp-3);
    margin-bottom: var(--sp-5);
  }
  .page-head h1 { font-size: clamp(1.4rem, 5vw, 1.85rem); }
  .page-head-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
  }
  .page-head-actions .btn {
    font-size: var(--fs-xs);
    padding: 6px 10px;
  }
}

/* En-tête de page éditorial, aligné à gauche */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-8);
}
.page-head .eyebrow { margin-bottom: var(--sp-2); }
.page-head h1 { font-size: clamp(1.9rem, 4vw, 2.75rem); margin: 0; }
.page-head p { color: var(--c-text-muted); margin: var(--sp-2) 0 0; max-width: 60ch; }
.page-head-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

.eyebrow {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--c-accent-text);
}

.section { margin-bottom: var(--sp-12); }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--sp-4); margin-bottom: var(--sp-4);
}
.section-head h2 { font-size: var(--fs-lg); margin: 0; }
.section-head a { font-size: var(--fs-sm); color: var(--c-accent-text); font-weight: 600; text-decoration: none; }
.section-head a:hover { text-decoration: underline; }

.muted { color: var(--c-text-muted); }
.faint { color: var(--c-text-faint); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-accent { color: var(--c-accent-text); }
.text-success { color: var(--c-success); }
.text-error { color: var(--c-error); }
.font-display { font-family: var(--font-display); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* Grilles utilitaires */
.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-main-side { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: var(--sp-8); }
@media (max-width: 960px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main-side { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--sp-2); }
.row { display: flex; align-items: center; gap: var(--sp-3); }
.row-wrap { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.flex-1 { flex: 1; min-width: 0; }
.mt-0 { margin-top: 0; } .mt-2 { margin-top: var(--sp-2); } .mt-4 { margin-top: var(--sp-4); } .mt-6 { margin-top: var(--sp-6); } .mt-8 { margin-top: var(--sp-8); }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: var(--sp-2); } .mb-4 { margin-bottom: var(--sp-4); } .mb-6 { margin-bottom: var(--sp-6); } .mb-8 { margin-bottom: var(--sp-8); }

/* Footer */
.site-footer {
  border-top: 1px solid var(--c-border);
  padding: var(--sp-6);
  font-size: var(--fs-sm);
  color: var(--c-text-muted);
}
.site-footer-inner {
  max-width: var(--container); margin: 0 auto;
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--sp-3);
}
.site-footer a { color: var(--c-navy); font-weight: 600; text-decoration: none; }
@media (max-width: 768px) {
  .site-footer { padding-bottom: calc(var(--mobile-nav-h) + var(--sp-6) + env(safe-area-inset-bottom)); }
}

/* Bannière hors-ligne */
.offline-banner {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--mobile-nav-h) + 12px + env(safe-area-inset-bottom));
  z-index: var(--z-toast);
  background: var(--c-navy); color: var(--c-on-navy); font-size: var(--fs-sm);
  padding: var(--sp-2) var(--sp-4); border-radius: var(--r-pill);
  display: flex; align-items: center; gap: var(--sp-2); box-shadow: var(--sh-md);
  max-width: calc(100vw - 24px); width: max-content; box-sizing: border-box;
}
.offline-banner svg { width: 16px; height: 16px; }
@media (min-width: 769px) { .offline-banner { bottom: var(--sp-6); } }

/* Économie de données : masquer les médias lourds */
body.data-saver img[data-heavy], body.data-saver video { display: none !important; }

/* Contenu riche (notes, devoirs) */
.prose { font-size: var(--fs-base); line-height: 1.75; color: var(--c-text); max-width: 72ch; }
.prose h1, .prose h2, .prose h3 { margin-top: var(--sp-8); }
.prose h1 { font-size: var(--fs-xl); }
.prose h2 { font-size: var(--fs-lg); }
.prose h3 { font-size: var(--fs-md); }
.prose ul, .prose ol { padding-left: 1.4em; margin: 0 0 var(--sp-4); }
.prose li { margin-bottom: var(--sp-1); }
.prose blockquote {
  margin: var(--sp-4) 0; padding: var(--sp-3) var(--sp-4);
  border-left: 3px solid var(--c-accent); background: var(--c-surface-2); border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.prose table { border-collapse: collapse; width: 100%; margin: var(--sp-4) 0; font-size: var(--fs-sm); }
.prose th, .prose td { border: 1px solid var(--c-border); padding: var(--sp-2) var(--sp-3); text-align: left; }
.prose img { border-radius: var(--r-md); }
.prose .ql-formula, .prose .formula { font-family: var(--font-mono); background: var(--c-surface); padding: 2px 6px; border-radius: 6px; }
