/* ============================================================
   C365 — feuille unique

   Site public et administration. Palette Primer de GitHub, Inter
   auto-hébergée, thème clair. Pas de framework, pas de variables
   inutilisées : ce qui est écrit ici est ce qui sert.
   ============================================================ */

/* ── Police ───────────────────────────────────────────────────
   Déclarée ici plutôt qu'importée : un @import est une requête
   bloquante enchaînée après cette feuille, soit un aller-retour de
   plus avant que le texte ne s'affiche. Fichier variable, une seule
   face pour toutes les graisses.
   ------------------------------------------------------------ */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('fonts/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
                 U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('fonts/inter-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+1E00-1E9F,
                 U+2020, U+20A0-20AB, U+20AD-20C0, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --bg:       #f6f8fa;
  --panel:    #ffffff;
  --line:     #d1d9e0;
  --line-2:   #c0c9d2;
  --text:     #24292f;
  --text-2:   #424a53;
  --text-3:   #57606a;
  --heading:  #1b1f23;
  --accent:   #0969da;
  --accent-2: #0550ae;
  --danger:   #cf222e;
  --ok:       #1a7f37;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --radius: 6px;
  --measure: 720px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; height: auto; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); text-decoration: underline; }
ul, ol { list-style: none; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

h1, h2, h3, h4 {
  color: var(--heading);
  line-height: 1.2;
  letter-spacing: -.015em;
  text-wrap: balance;
}

/* ============================================================
   SITE PUBLIC
   ============================================================ */

.topbar {
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.topbar-logo {
  display: block;
  max-width: 1060px;
  margin-inline: auto;
  padding: 1.25rem 1.5rem;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--heading);
}
.topbar-logo:hover { color: var(--heading); text-decoration: none; }

main {
  max-width: 1060px;
  margin-inline: auto;
  padding: 3rem 1.5rem 4rem;
}

/* Intertitre en petites capitales, prolongé d'un filet — comme le
   sommaire d'un journal annonce ses rubriques. */
.section-label {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .11em;
  text-transform: uppercase;
  color: var(--text-3);
}
.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.empty {
  padding: 3rem 0;
  color: var(--text-3);
  text-align: center;
}

/* ── La liste ─────────────────────────────────────────────────
   Des rangées séparées par un filet. Le titre porte la page, la
   vignette identifie l'article sans chercher à le raconter.
   ------------------------------------------------------------ */
.list { display: flex; flex-direction: column; }

.row {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 2rem;
  padding: 1.75rem 0;
  border-bottom: 1px solid var(--line);
}

.row-body { flex: 1; min-width: 0; }

.row-meta {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: .45rem;
  font-size: .6875rem;
  color: var(--text-3);
}
.row-meta time { font-variant-numeric: tabular-nums; white-space: nowrap; }
.sep { color: var(--line-2); }
.row-cat {
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-2);
}

.row-link { color: var(--text); }
.row-link:hover { color: var(--text); text-decoration: none; }

/* Le lien du titre couvre la rangée entière : la vignette et les
   blancs deviennent cliquables sans qu'aucun lien n'en contienne un
   autre — ce qu'aucun navigateur n'accepte. Le texte reste
   sélectionnable, la nappe ne passe qu'au-dessus des vides. */
.row-link::after {
  content: '';
  position: absolute;
  inset: 0;
}

.row-title {
  font-size: clamp(1.25rem, 2.2vw, 1.5rem);
  font-weight: 800;
  margin-bottom: .4rem;
}
.row:hover .row-title { color: var(--accent); }

.row-excerpt {
  max-width: 62ch;
  font-size: .9375rem;
  line-height: 1.55;
  color: var(--text-3);
}

/* La vignette garde le format d'origine du visuel : les illustrations
   de C365 portent du texte, un cadre imposé les rognerait. Le
   plafond de hauteur empêche seulement une image en portrait de
   pousser la rangée hors de proportion. */
.row-thumb {
  flex-shrink: 0;
  width: 200px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}
.row-thumb img {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  font-size: .875rem;
}
.pager-pos { color: var(--text-3); font-variant-numeric: tabular-nums; }

/* ── L'article ── */
.article { max-width: var(--measure); margin-inline: auto; }

.article-title {
  font-size: clamp(1.875rem, 4vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -.025em;
  margin: 0 0 2rem;
  /* « balance », hérité de la règle des titres, égalise les lignes :
     bon pour une manchette de deux lignes, mauvais ici, où il raccourcit
     chaque ligne d'un quart et laisse le titre flotter au-dessus d'une
     image bien plus large. « pretty » remplit la largeur disponible et
     se contente d'éviter un dernier mot resté seul. */
  text-wrap: pretty;
}

.article-cover {
  margin: 1.25rem 0 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
}

.article-body { font-size: 1.0625rem; line-height: 1.75; color: var(--text-2); }
.article-body > * + * { margin-top: 1.25rem; }
.article-body h2 {
  margin-top: 2.5rem;
  font-size: 1.5rem;
  font-weight: 700;
}
.article-body h3 {
  margin-top: 2rem;
  font-size: 1.1875rem;
  font-weight: 700;
}
.article-body ul, .article-body ol { padding-left: 1.25rem; }
.article-body ul li { list-style: disc; }
.article-body ol li { list-style: decimal; }
.article-body li + li { margin-top: .35rem; }
.article-body img {
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.article-body blockquote {
  padding-left: 1.25rem;
  border-left: 3px solid var(--line-2);
  color: var(--text-3);
}
.article-body pre {
  padding: 1rem;
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: .875rem;
}
.article-body code { font-family: ui-monospace, Consolas, monospace; font-size: .9em; }
.article-body hr { margin: 2.5rem 0; border: none; border-top: 2px solid var(--line-2); }
/* Un tableau large déborderait la colonne de lecture : il défile
   dans son coin plutôt que d'élargir toute la page. */
.article-body table { display: block; width: 100%; overflow-x: auto; border-collapse: collapse; font-size: .9375rem; }
.article-body th, .article-body td {
  padding: .5rem .7rem;
  border: 1px solid var(--line-2);
  text-align: left;
  vertical-align: top;
}
.article-body th { background: var(--panel); font-weight: 600; color: var(--heading); }

.article-source, .article-back {
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  font-size: .875rem;
  color: var(--text-3);
}
.article-back { margin-top: 1rem; border-top: none; padding-top: 0; }

.footer {
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.footer > span {
  display: block;
  max-width: 1060px;
  margin-inline: auto;
  padding: 1.5rem;
  font-size: .8125rem;
  color: var(--text-3);
}

/* ── Écran étroit ──────────────────────────────────────────────
   La vignette cède du terrain avant le texte : à 200 px dans une
   colonne de 340, il ne resterait au titre que quelques signes par
   ligne.
   ------------------------------------------------------------ */
@media (max-width: 700px) {
  main { padding: 2rem 1.25rem 3rem; }
  .row { gap: 1rem; padding: 1.375rem 0; }
  .row-thumb { width: 104px; }
  .row-thumb img { max-height: 140px; }
  .row-title { font-size: 1.1875rem; }
}

/* ============================================================
   ADMINISTRATION
   ============================================================ */

body.admin { background: var(--bg); }

.admin-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .875rem 1.5rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.admin-logo { font-weight: 800; color: var(--heading); }
.admin-logo:hover { text-decoration: none; }
.admin-nav { display: flex; align-items: center; gap: 1rem; font-size: .875rem; }

.admin-main { max-width: 1060px; margin-inline: auto; padding: 2.5rem 1.5rem 4rem; }
.admin-main--narrow { max-width: var(--measure); }

.admin-title { font-size: 1.5rem; font-weight: 800; }
.admin-title--section { margin-top: 2.5rem; margin-bottom: 1rem; font-size: 1.125rem; }
.admin-sub { margin-top: .25rem; margin-bottom: 1.75rem; font-size: .875rem; color: var(--text-3); }

/* ── Tableau ── */
.table { width: 100%; border-collapse: collapse; font-size: .9375rem; background: var(--panel); }
.table th, .table td {
  padding: .75rem .9rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table th {
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
  background: var(--bg);
}
.table tr:last-child td { border-bottom: none; }
.table-link { font-weight: 600; color: var(--heading); }
.table-link:hover { color: var(--accent); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.nowrap { white-space: nowrap; }
/* La cellule reste une cellule de tableau : la passer en flex lui
   retire sa hauteur de ligne, et sa bordure inférieure se décale de
   celle des autres colonnes — le trait de séparation apparaît brisé.
   L'alignement à droite est donc obtenu sans changer son display. */
.row-actions { text-align: right; white-space: nowrap; font-size: .8125rem; }
.row-actions > * { display: inline-block; vertical-align: middle; }
.row-actions > * + * { margin-left: .9rem; }

.tag {
  display: inline-block;
  padding: .1rem .5rem;
  font-size: .6875rem;
  font-weight: 600;
  color: var(--text-3);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9999px;
}
.tag-live { color: var(--ok); border-color: #b7e0c2; background: #f0fdf4; }
.tag-warn { color: var(--danger); border-color: #f3c2c6; background: #fef2f2; }

/* ── Formulaires ── */
.form { display: flex; flex-direction: column; gap: .4rem; }
.form label { margin-top: 1rem; font-size: .875rem; font-weight: 600; color: var(--text-2); }
.form label:first-of-type { margin-top: 0; }
.hint { font-weight: 400; color: var(--text-3); }

.form input[type="text"],
.form input[type="url"],
.form input[type="password"],
.form input[type="datetime-local"],
.form select,
.form textarea {
  width: 100%;
  padding: .6rem .75rem;
  font: inherit;
  font-size: .9375rem;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
}
.form textarea { font-family: ui-monospace, Consolas, monospace; font-size: .875rem; line-height: 1.6; resize: vertical; }
.form input:focus, .form select:focus, .form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(9, 105, 218, .1);
}
.form input[type="file"] { font-size: .875rem; }

.checkbox {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 400;
}
.checkbox input { width: auto; }

.image-current {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: .75rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.image-current img { width: 120px; border-radius: 4px; }

.form-actions { display: flex; align-items: center; gap: .75rem; margin-top: 1.75rem; }

.btn {
  display: inline-block;
  padding: .55rem 1rem;
  font: inherit;
  font-size: .9375rem;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
}
.btn-sm { padding: .35rem .7rem; font-size: .8125rem; }
.btn-primary { color: #fff; background: var(--accent); }
.btn-primary:hover { background: var(--accent-2); color: #fff; text-decoration: none; }
.btn-quiet { color: var(--text-2); background: var(--panel); border-color: var(--line-2); }
.btn-danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.btn-quiet:hover { color: var(--text); text-decoration: none; }

.link-danger {
  font: inherit;
  font-size: .8125rem;
  color: var(--danger);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.link-danger:hover { text-decoration: underline; }
.inline { display: inline; }

.alert { padding: .75rem 1rem; margin-bottom: 1.5rem; border-radius: var(--radius); font-size: .9375rem; }
.alert-ok    { color: var(--ok);     background: #f0fdf4; border: 1px solid #b7e0c2; }
.alert-error { color: var(--danger); background: #fef2f2; border: 1px solid #f3c2c6; }
.alert-warn  { color: #8a5a00; background: #fff8e6; border: 1px solid #f0dca4; }
.alert p + p { margin-top: .25rem; }
/* Le panneau qui demande où déplacer les articles porte un formulaire :
   sans cette marge, le sélecteur colle au paragraphe qui l'explique. */
.alert .form { margin-top: 1rem; }
.alert .form-actions { margin-top: 1rem; }

/* ── Connexion ── */
.login {
  max-width: 380px;
  margin: 12vh auto;
  padding: 2rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.login-title { font-size: 1.5rem; font-weight: 800; }
.login-sub { margin-bottom: 1.75rem; font-size: .875rem; color: var(--text-3); }
.login-back { margin-top: 1.5rem; font-size: .8125rem; }

@media (max-width: 700px) {
  .admin-main { padding: 1.5rem 1rem 3rem; }
  .table th:nth-child(2), .table td:nth-child(2),
  .table th:nth-child(5), .table td:nth-child(5) { display: none; }
}

/* ── Éditeur de contenu ──────────────────────────────────────────
   La surface d'édition reprend la typographie de l'article publié :
   ce qui est écrit ici doit ressembler à ce qui sera lu.
   ---------------------------------------------------------------- */
.editor {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}
.editor:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(9, 105, 218, .12); }
.editor.is-busy { opacity: .7; pointer-events: none; }

/* Plein écran : l'éditeur quitte le flux et couvre la fenêtre. */
.editor.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 50;
  border-radius: 0;
  border: none;
  box-shadow: none;
}
body.has-fullscreen-editor { overflow: hidden; }

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .15rem;
  padding: .35rem .45rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
/* Les groupes sont séparés par un trait plutôt que par un vide : la
   barre reste lisible même lorsqu'elle passe à la ligne. */
.editor-group { display: flex; align-items: center; gap: .15rem; }
.editor-group + .editor-group { margin-left: .3rem; padding-left: .4rem; border-left: 1px solid var(--line-2); }

.editor-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  padding: 0;
  color: var(--text-2);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
}
.editor-btn:hover { color: var(--text); background: var(--panel); border-color: var(--line-2); }
.editor-btn.is-active { color: var(--accent); background: #eaf2fd; border-color: #bcd8fb; }
.editor-btn:disabled { opacity: .35; cursor: default; }
.editor-btn:disabled:hover { color: var(--text-2); background: transparent; border-color: transparent; }

.editor-icon {
  width: 1.05rem;
  height: 1.05rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* Le gras et le barré se lisent mieux pleins que filaires. */
.editor-btn[aria-label="Gras"] .editor-icon { fill: currentColor; stroke-width: 1; }

.form .editor-select,
.editor-select {
  width: auto;
  min-width: 8.5rem;
  height: 1.9rem;
  margin: 0;
  padding: 0 .5rem;
  font: inherit;
  font-size: .8125rem;
  line-height: 1.9rem;
  color: var(--text-2);
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 5px;
  cursor: pointer;
}
.form .editor-select:disabled,
.editor-select:disabled { opacity: .35; cursor: default; }

.editor-surface {
  flex: 1;
  min-height: 24rem;
  max-height: 62vh;
  padding: 1.5rem 1.75rem;
  overflow-y: auto;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
}
.editor.is-fullscreen .editor-surface,
.editor.is-fullscreen .editor-source {
  max-height: none;
  padding-inline: max(1.75rem, calc((100vw - 46rem) / 2));
}
.editor-surface:focus { outline: none; }
.editor-surface > :first-child { margin-top: 0; }
.editor-surface p { margin: 0 0 1rem; }
.editor-surface h2 { margin: 1.75rem 0 .6rem; font-size: 1.3125rem; font-weight: 700; color: var(--heading); }
.editor-surface h3 { margin: 1.5rem 0 .5rem; font-size: 1.0625rem; font-weight: 700; color: var(--heading); }
.editor-surface ul, .editor-surface ol { margin: 0 0 1rem; padding-left: 1.5rem; }
.editor-surface ul li { list-style: disc; }
.editor-surface ol li { list-style: decimal; }
.editor-surface li { margin-bottom: .3rem; }
.editor-surface blockquote {
  margin: 0 0 1rem;
  padding-left: 1rem;
  border-left: 3px solid var(--line-2);
  color: var(--text-2);
}
.editor-surface pre {
  margin: 0 0 1rem;
  padding: .9rem 1rem;
  overflow-x: auto;
  font-family: ui-monospace, Consolas, monospace;
  font-size: .875rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.editor-surface a { color: var(--accent); text-decoration: underline; }
.editor-surface img { max-width: 100%; height: auto; border-radius: var(--radius); }
.editor-surface hr { margin: 1.75rem 0; border: none; border-top: 2px solid var(--line-2); }
.editor-surface table { width: 100%; margin: 0 0 1rem; border-collapse: collapse; font-size: .9375rem; }
.editor-surface th, .editor-surface td {
  padding: .45rem .6rem;
  border: 1px solid var(--line-2);
  text-align: left;
  vertical-align: top;
}
.editor-surface th { background: var(--bg); font-weight: 600; }

/* En vue « Source », le champ d'origine reprend la place de la
   surface : d'où la bordure retirée, déjà portée par .editor. */
.form .editor-source {
  flex: 1;
  min-height: 24rem;
  margin: 0;
  border: none;
  border-radius: 0;
}
.form .editor-source:focus { box-shadow: none; }

.editor-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .4rem .75rem;
  border-top: 1px solid var(--line);
  background: var(--bg);
  font-size: .75rem;
  color: var(--text-3);
}
.editor-message.is-error { color: var(--danger); }
