/* ============================================================
   fizik.re — palette Encre ardoise
   Mobile-first, sidebar fixe sur desktop, drawer sur mobile.
   ============================================================ */

:root {
  /* Palette Encre ardoise */
  --bg:           #f3efe7;
  --surface:      #fbf8f1;
  --surface-alt:  #f7f3ea;
  --line:         #e2dccd;
  --line-soft:    #ece6d6;
  --ink:          #0a0908;
  --ink-soft:     #3a3735;
  --ink-faint:    #7d7972;
  --accent:       #3d4f8a;
  --accent-ink:   #ffffff;
  --accent-soft:  #dde2f0;
  --accent-ring:  #b6bdda;
  --chip-bg:      #ece6d6;

  /* Doc type colors */
  --t-cours-bg: var(--accent-soft);   --t-cours-fg: var(--accent);
  --t-exo-bg:   #fff5d6;              --t-exo-fg:   #a36500;
  --t-corr-bg:  #dcf2e2;              --t-corr-fg:  #15623a;
  --t-tp-bg:    #ffe4d6;              --t-tp-fg:    #a13b00;
  --t-fiche-bg: #f0e5ff;              --t-fiche-fg: #5b2ea3;
  --t-annale-bg:var(--chip-bg);       --t-annale-fg:var(--ink-soft);
  --t-video-bg: var(--ink);           --t-video-fg: var(--surface);

  --sidebar-w: 240px;
  --radius-card: 14px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(10,9,8,0.04);

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.45;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
.visually-hidden, .skip {
  position: absolute; clip: rect(0 0 0 0); width: 1px; height: 1px;
  overflow: hidden; white-space: nowrap;
}
.skip:focus {
  position: fixed; top: 8px; left: 8px; width: auto; height: auto; clip: auto;
  background: var(--ink); color: var(--surface); padding: 8px 14px; border-radius: 6px; z-index: 100;
}

.mono { font-family: var(--font-mono); font-feature-settings: "ss02"; }
.dim  { color: var(--ink-faint); }
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 500; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* ============================================================
   Sidebar (desktop) / drawer (mobile)
   ============================================================ */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--surface-alt);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 20px 14px 18px;
  gap: 18px;
  z-index: 30;
  overflow-y: auto;
  scrollbar-width: thin;
}

.brand {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 0 6px;
  font-weight: 600; letter-spacing: -0.02em; font-size: 18px;
}
.brand-mark {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 500;
}
.brand-dot { color: var(--ink-faint); font-weight: 400; }

.nav-section { display: flex; flex-direction: column; gap: 4px; }
.nav-label {
  font-family: var(--font-mono); font-size: 10px;
  color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.08em;
  padding: 0 8px; margin-bottom: 2px;
}
.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.nav-list--dense { gap: 0; }

.nav-class, .nav-chap, .nav-link {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--ink);
  transition: background .12s, color .12s;
}
.nav-class:hover, .nav-chap:hover, .nav-link:hover { background: var(--surface); color: var(--ink); }
.nav-class.is-active, .nav-chap.is-active {
  background: var(--accent-soft); color: var(--accent);
}
.nav-class.is-active .class-code { background: var(--accent); color: var(--accent-ink); }

.class-code {
  width: 24px; height: 24px; border-radius: 6px;
  background: var(--chip-bg); color: var(--ink-soft);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700; letter-spacing: 0.03em;
  flex-shrink: 0;
}
.class-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.ico-chevron { color: var(--ink-faint); }

.nav-chap { padding: 5px 8px; font-size: 12px; }
.chap-num {
  font-family: var(--font-mono); font-size: 10px; color: var(--ink-faint);
  width: 18px; flex-shrink: 0;
}
.nav-chap.is-active .chap-num { color: var(--accent); }
.chap-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-chap.is-active .chap-title { font-weight: 600; }
.chap-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }

.nav-section--bottom { margin-top: auto; gap: 2px; }
.brand-year {
  font-family: var(--font-mono); font-size: 10px; color: var(--ink-faint);
  padding: 0 8px; margin-top: 4px;
}

/* ============================================================
   Mobile menu trigger + drawer overlay
   ============================================================ */
.menu-btn {
  position: fixed; top: 14px; left: 14px; z-index: 40;
  width: 40px; height: 40px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  display: none;
  align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
}
.menu-backdrop {
  position: fixed; inset: 0; background: rgba(10,9,8,0.4);
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
  z-index: 20;
}
body.menu-open .menu-backdrop { opacity: 1; pointer-events: auto; }

/* ============================================================
   Main column
   ============================================================ */
.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: 40px 56px 64px;
}

.page { max-width: 1080px; }
.page-header { margin-bottom: 32px; }
.page-header--tight { margin-bottom: 18px; }
.page-eyebrow {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--accent); text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.page-title {
  margin: 0;
  font-size: 44px; font-weight: 600; line-height: 1.05; letter-spacing: -0.025em;
  color: var(--ink);
}
.page-title--md { font-size: 36px; }
.page-lead {
  margin: 14px 0 0; font-size: 16px; color: var(--ink-soft);
  max-width: 600px; line-height: 1.5;
}
.page-lead--sm { font-size: 14px; }

.section { margin-top: 44px; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 14px;
}
.section-label {
  margin: 0; font-family: var(--font-mono); font-size: 11px;
  color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 500;
}

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
}
.card--list { padding: 4px; }

.grid { display: grid; gap: 16px; }
.grid--classes { grid-template-columns: repeat(3, 1fr); }
.grid--chapters { grid-template-columns: repeat(2, 1fr); }

.card--class {
  padding: 22px;
  display: flex; flex-direction: column; gap: 14px;
  min-height: 180px;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.card--class:hover { border-color: var(--accent-ring); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(10,9,8,0.06); color: var(--ink); }
.card--class.is-featured {
  border-color: var(--accent-ring);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.card-head {
  display: flex; align-items: flex-start; gap: 10px;
}
.card-head-body { flex: 1; min-width: 0; }
.class-badge {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--chip-bg); color: var(--ink-soft);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 14px; font-weight: 700; letter-spacing: 0.03em;
}
.card--class.is-featured .class-badge { background: var(--accent); color: var(--accent-ink); }
.card-body { flex: 1; }
.card-title {
  font-size: 21px; font-weight: 600; line-height: 1.15; letter-spacing: -0.02em;
  color: var(--ink);
}
.card-sub {
  font-size: 13px; color: var(--ink-soft);
  margin-top: 4px; line-height: 1.4;
}
.card-foot {
  margin-top: auto;
  display: flex; align-items: center; justify-content: space-between;
}
.ico-arrow { color: var(--ink-soft); transition: transform .15s, color .15s; }
.card--class:hover .ico-arrow,
.card--chapter:hover .ico-arrow { color: var(--accent); transform: translateX(2px); }
.card--class.is-featured .ico-arrow { color: var(--accent); }

/* Chapter card */
.card--chapter {
  display: flex; flex-direction: column; gap: 10px;
  padding: 16px;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.card--chapter:hover { border-color: var(--accent-ring); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(10,9,8,0.06); color: var(--ink); }
.card--chapter.is-now { border-color: var(--accent-ring); box-shadow: 0 0 0 3px var(--accent-soft); }

.chap-badge {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--chip-bg); color: var(--ink-soft);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}
.chap-badge--done { background: var(--ink); color: var(--surface); }
.chap-badge--now  { background: var(--accent); color: var(--accent-ink); }
.chap-badge--big {
  border-radius: 8px; padding: 4px 10px; height: auto; width: auto;
  background: var(--accent); color: var(--accent-ink); font-size: 12px; letter-spacing: 0.04em;
}

.card--chapter .card-head { align-items: flex-start; }
.card--chapter .card-title { font-size: 16px; line-height: 1.2; margin-top: 2px; }

/* ============================================================
   Doc type pill (cours, exo, corr, ...)
   ============================================================ */
.doctype {
  display: inline-flex; align-items: center;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  padding: 4px 7px; border-radius: 5px;
  letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--surface); color: var(--ink-soft); border: 1px solid var(--line);
  flex-shrink: 0;
}
.doctype[data-kind="cours"]   { background: var(--t-cours-bg); color: var(--t-cours-fg); border-color: transparent; }
.doctype[data-kind="exo"]     { background: var(--t-exo-bg); color: var(--t-exo-fg); border-color: transparent; }
.doctype[data-kind="corr"]    { background: var(--t-corr-bg); color: var(--t-corr-fg); border-color: transparent; }
.doctype[data-kind="tp"]      { background: var(--t-tp-bg); color: var(--t-tp-fg); border-color: transparent; }
.doctype[data-kind="fiche"]   { background: var(--t-fiche-bg); color: var(--t-fiche-fg); border-color: transparent; }
.doctype[data-kind="annale"]  { background: var(--t-annale-bg); color: var(--t-annale-fg); border-color: transparent; }
.doctype[data-kind="video"]   { background: var(--t-video-bg); color: var(--t-video-fg); border-color: transparent; }

/* ============================================================
   Chips & buttons
   ============================================================ */
.chip {
  display: inline-flex; align-items: center;
  padding: 3px 8px; border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 500;
  background: var(--chip-bg); color: var(--ink-soft);
  border: 1px solid var(--line);
}
.chip--accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-pill);
  font-size: 13px; font-weight: 600;
  background: var(--ink); color: var(--surface); border: 1px solid var(--ink);
  cursor: pointer;
  transition: opacity .12s, transform .12s;
}
.btn:hover { opacity: 0.92; transform: translateY(-1px); color: var(--surface); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn--ghost:hover { background: var(--surface); color: var(--ink); }
.btn--accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn--accent:hover { color: var(--accent-ink); }

/* ============================================================
   List rows (recent + chapter files)
   ============================================================ */
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px;
  border-radius: 10px;
  transition: background .1s;
}
.row:hover { background: var(--surface-alt); color: var(--ink); }
.row.is-active { background: var(--accent-soft); }
.row.is-active .row-title { color: var(--accent); }
.row-body { flex: 1; min-width: 0; }
.row-title {
  font-size: 14px; font-weight: 600; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row-meta {
  font-size: 11px; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row-sep { height: 1px; background: var(--line-soft); margin: 0 10px; }
.row-dl {
  width: 32px; height: 32px; border-radius: 8px;
  background: transparent; color: var(--ink-soft);
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.row-dl:hover { background: var(--surface); color: var(--accent); border-color: var(--accent-ring); }

/* ============================================================
   Banner — semaine en cours
   ============================================================ */
.banner {
  display: flex; align-items: center; gap: 14px;
  padding: 14px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  margin-bottom: 18px;
}
.banner-ico {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.banner-body { flex: 1; min-width: 0; }
.banner-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.banner-now { font-size: 13px; color: var(--ink-soft); }
.banner-bar { height: 4px; background: var(--line-soft); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.banner-bar-fill { height: 100%; background: var(--accent); transition: width .3s; }

/* ============================================================
   Chapter page — list + preview
   ============================================================ */
.chapter-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 24px;
  align-items: start;
}
.chapter-list { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.chap-num-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }

.chapter-preview {
  position: sticky; top: 24px;
  display: flex; flex-direction: column; gap: 10px;
  height: calc(100vh - 48px);
  min-height: 480px;
}
.preview-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 4px;
}
.preview-title {
  font-size: 15px; font-weight: 600; color: var(--ink);
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.preview-actions { display: flex; gap: 8px; margin-left: auto; }
.preview-frame {
  flex: 1; min-height: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  position: relative;
}
.preview-frame iframe {
  width: 100%; height: 100%; border: 0;
  background: var(--bg);
}
.preview-fallback {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: 8px;
  font-size: 12px; color: var(--ink-soft);
  pointer-events: none;
  opacity: 0;
}
/* Show fallback when iframe failed to load (set via JS) */
.preview-frame[data-failed="true"] iframe { display: none; }
.preview-frame[data-failed="true"] .preview-fallback { opacity: 1; pointer-events: auto; }

/* ============================================================
   Videos grid
   ============================================================ */
.videos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 8px; }
.video {
  position: relative; display: block; aspect-ratio: 16/9;
  border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line);
  background: var(--ink);
}
.video img { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-play {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: white; font-size: 28px; background: rgba(0,0,0,0.25);
  text-shadow: 0 2px 12px rgba(0,0,0,0.5);
}
.video--plain {
  aspect-ratio: auto; padding: 16px; background: var(--surface); color: var(--ink-soft);
  font-family: var(--font-mono); font-size: 12px; border: 1px solid var(--line);
  word-break: break-all;
}

/* ============================================================
   Misc
   ============================================================ */
.empty {
  padding: 24px;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 12px;
  text-align: center;
  color: var(--ink-faint);
  font-size: 14px;
}
.page--404 { padding-top: 80px; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1100px) {
  .grid--classes { grid-template-columns: 1fr 1fr; }
  .chapter-grid { grid-template-columns: 1fr; }
  .chapter-preview { position: static; height: 70vh; }
}

@media (max-width: 760px) {
  .main { margin-left: 0; padding: 64px 18px 32px; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.22,.61,.36,1);
    width: 86%; max-width: 320px;
    box-shadow: 4px 0 24px rgba(10,9,8,0.18);
  }
  body.menu-open .sidebar { transform: translateX(0); }
  .menu-btn { display: inline-flex; }
  .grid--classes { grid-template-columns: 1fr; }
  .grid--chapters { grid-template-columns: 1fr; }
  .page-title { font-size: 30px; }
  .page-title--md { font-size: 26px; }
  .page-lead { font-size: 14px; }
  .chapter-preview { min-height: 380px; height: 60vh; }
  .preview-actions { width: 100%; margin-left: 0; }
  .preview-actions .btn { flex: 1; justify-content: center; }
  .videos { grid-template-columns: 1fr; }
  .card--class { padding: 16px; min-height: 0; }
  .card-title { font-size: 17px; }
}
