/* ===== Reset minimal ===== */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; padding: 0; }
img { max-width: 100%; height: auto; }

/* Skip-link : invisible jusqu'au focus clavier (accessibilité) */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 20;
  background: var(--bg); color: var(--link); padding: 8px 16px;
}
.skip-link:focus { left: 0; }

/* ===== Variables ===== */
:root {
  color-scheme: light dark;
  --bg: #fefefe;
  --text: #1a1a1a;
  --sidebar-bg: #f7f7f7;
  --sidebar-border: #e5e5e5;
  --link: #0f5fa6;
  --muted: #6b6b6b;
  --tap-flash: rgba(15, 95, 166, 0.15);
  --hover-bg: rgba(0, 0, 0, 0.04);
  --current-bg: rgba(15, 95, 166, 0.08);
}

/* Dark mode : suit la préférence système (pas de toggle — un brief se lit
   souvent à 7h du matin, l'OS sait déjà quel mode l'utilisateur veut). */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131313;
    --text: #e8e4dc;
    --sidebar-bg: #1c1c1c;
    --sidebar-border: #303030;
    --link: #7fb4e6;
    --muted: #9d9d9d;
    --tap-flash: rgba(127, 180, 230, 0.2);
    --hover-bg: rgba(255, 255, 255, 0.06);
    --current-bg: rgba(127, 180, 230, 0.16);
  }
}

html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Charter', 'Iowan Old Style', Georgia, serif;
  font-size: 17px;
  line-height: 1.65;
  -webkit-tap-highlight-color: var(--tap-flash);
}

a { color: var(--link); text-decoration: underline; text-underline-offset: 2px; }
a:hover, a:focus-visible { text-decoration-thickness: 2px; }

/* ===== Desktop layout (≥ 768px) ===== */
.nav-toggle { display: none; }

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 280px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  overflow-y: auto;
  padding: 24px 20px;
  font-family: -apple-system, system-ui, sans-serif;
  font-size: 14px;
}

.sidebar-header { margin-bottom: 24px; }
.site-title { font-size: 18px; margin: 0 0 4px; font-weight: 600; }
.site-subtitle { margin: 0; color: var(--muted); font-size: 13px; }
.site-about { margin: 4px 0 0; font-size: 13px; }

.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 24px 0 8px; font-weight: 600; }

.filter-list, .brief-list { list-style: none; padding: 0; margin: 0; }

.filter-list li label {
  display: flex; align-items: center; gap: 8px;
  min-height: 28px; padding: 2px 4px;
  cursor: pointer;
}
.filter-checkbox { width: 16px; height: 16px; cursor: pointer; }

.brief-item a {
  display: block;
  min-height: 44px; padding: 10px 8px;
  color: var(--text); text-decoration: none;
  border-radius: 4px;
  word-break: break-word;
}
.brief-item a:hover, .brief-item a:focus-visible { background: var(--hover-bg); }
.brief-item a[aria-current="page"] { background: var(--current-bg); font-weight: 600; }

.brief-date { display: block; font-size: 13px; color: var(--muted); }
.brief-angle { font-size: 14px; }
.brief-no-angle { float: right; opacity: 0.5; }

.brief-item.hidden { display: none; }

.month-group.hidden { display: none; }
.month-label {
  cursor: pointer; min-height: 28px; padding: 4px;
  font-size: 13px; font-weight: 600; color: var(--muted);
  list-style-position: outside;
}
.month-count { font-weight: 400; }

.content {
  margin-left: 280px;
  padding: 48px 32px;
  max-width: 720px;
}

.brief-header { margin-bottom: 32px; padding-bottom: 16px; border-bottom: 1px solid var(--sidebar-border); }
.brief-date-display { color: var(--muted); margin: 0 0 4px; font-size: 14px; font-family: -apple-system, system-ui, sans-serif; }
.brief-angle-display { margin: 0; font-size: 28px; font-weight: 600; }
.brief-subtitle {
  margin: 8px 0 0; color: var(--muted);
  font-family: -apple-system, system-ui, sans-serif; font-size: 15px; line-height: 1.4;
}

/* Sommaire des items en tête de brief */
.brief-toc {
  margin: 0 0 24px; padding: 12px 16px;
  background: var(--sidebar-bg); border: 1px solid var(--sidebar-border); border-radius: 8px;
  font-family: -apple-system, system-ui, sans-serif; font-size: 14px;
}
.brief-toc ol { margin: 0; padding-left: 20px; }
.brief-toc li { margin: 4px 0; }
.brief-toc a { text-decoration: none; }
.brief-toc a:hover, .brief-toc a:focus-visible { text-decoration: underline; }

/* Bascule de langue FR / EN (contrôle segmenté sobre) */
.lang-toggle {
  display: inline-flex; gap: 2px; margin-top: 16px;
  background: var(--sidebar-bg); border: 1px solid var(--sidebar-border);
  border-radius: 8px; padding: 2px;
}
.lang-btn {
  font-family: -apple-system, system-ui, sans-serif; font-size: 13px;
  padding: 6px 14px; min-height: 32px; border: 0; background: transparent;
  color: var(--muted); border-radius: 6px; cursor: pointer;
}
.lang-btn:hover, .lang-btn:focus-visible { color: var(--text); }
.lang-btn.is-active { background: var(--bg); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,0.08); }

/* Corps du brief : casse les longues URLs pour éviter tout débordement horizontal (mobile).
   `anywhere` (et pas `break-word`) car il réduit aussi la largeur min-content : sans ça
   une URL insécable élargit tout le <body> et le viewport mobile coupe le contenu. */
.brief-body, .brief-meta { overflow-wrap: anywhere; word-break: break-word; }
.brief-body.hidden { display: none; }

/* Footer Meta (transparence : comment le brief est produit) */
.brief-meta {
  margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--sidebar-border);
  color: var(--muted); font-family: -apple-system, system-ui, sans-serif; font-size: 13px;
}
.brief-meta p { margin: 0; }
.brief-meta p + .brief-legend { margin-top: 8px; }

/* Navigation précédent/suivant en fin de brief (évite le cul-de-sac de lecture) */
.brief-nav {
  display: flex; justify-content: space-between; gap: 16px;
  margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--sidebar-border);
  font-family: -apple-system, system-ui, sans-serif;
}
.brief-nav-link { display: block; max-width: 48%; text-decoration: none; }
.brief-nav-newer { margin-left: auto; text-align: right; }
.brief-nav-kicker { display: block; font-size: 13px; color: var(--muted); }
.brief-nav-title { font-size: 14px; }

.brief-body h1 { font-size: 24px; margin-top: 32px; }
.brief-body h2 { font-size: 20px; margin-top: 28px; }
.brief-body h3 { font-size: 18px; margin-top: 24px; }
.brief-body p { margin: 16px 0; }
.brief-body code { background: var(--sidebar-bg); padding: 2px 4px; border-radius: 3px; font-size: 0.9em; }
.brief-body pre { background: var(--sidebar-bg); padding: 12px; border-radius: 4px; overflow-x: auto; }
.brief-body blockquote { border-left: 3px solid var(--sidebar-border); margin: 16px 0; padding-left: 16px; color: var(--muted); }
.table-wrap { overflow-x: auto; margin: 16px 0; }
.brief-body table { border-collapse: collapse; margin: 0; }
.brief-body th, .brief-body td { border: 1px solid var(--sidebar-border); padding: 6px 12px; }

/* ===== Mobile (< 768px) ===== */
@media (max-width: 767px) {
  body { font-size: 16px; line-height: 1.6; }

  .nav-toggle {
    display: block;
    position: sticky; top: 0; z-index: 10;
    width: 100%;
    padding: 14px max(16px, env(safe-area-inset-left)) 14px max(16px, env(safe-area-inset-left));
    background: var(--bg);
    border-bottom: 1px solid var(--sidebar-border);
    text-align: left;
    font-family: -apple-system, system-ui, sans-serif;
    font-size: 16px; font-weight: 600;
    border: 0;
    border-bottom: 1px solid var(--sidebar-border);
    cursor: pointer;
    min-height: 48px;
  }

  .sidebar {
    position: static;
    width: 100%;
    border-right: 0;
    border-bottom: 1px solid var(--sidebar-border);
    font-size: 15px;
    display: none;
  }
  .sidebar.is-open { display: block; }

  .content {
    margin-left: 0;
    padding: 24px 16px;
    max-width: 100%;
  }

  .brief-angle-display { font-size: 24px; }

  /* Restore tap-friendly filters on mobile (44px touch target) */
  .filter-list li label { min-height: 44px; padding: 8px 4px; }

  .brief-nav { flex-direction: column; }
  .brief-nav-link { max-width: 100%; }
  .brief-nav-newer { margin-left: 0; text-align: left; }
}

/* ===== Très petits écrans (< 380px) ===== */
@media (max-width: 379px) {
  .content { padding: 24px 12px; }
  .filter-list li label { font-size: 13px; }
}
