/* ---- Tokens ------------------------------------------------------------- */
:root,
:root[data-theme="dark"] {
  --bg: #0f1113;
  --fg: #d4d2cc;
  --muted: #7d817b;
  --border: #23262a;
  --card: #171a1c;
  --accent: #5bc98c;
}

:root[data-theme="light"] {
  --bg: #f3f2ec;
  --fg: #181a17;
  --muted: #6d716a;
  --border: #dcdcd3;
  --card: #e9e8e1;
  --accent: #1c7a48;
}

/* ---- Fonts ---------------------------------------------------------------
   Auto-hébergée (variable font, un seul fichier couvre 400→800) : évite de
   faire fuiter l'IP des visiteurs vers Google Fonts à chaque page vue. */
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/fonts/jetbrains-mono-variable.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---- Base --------------------------------------------------------------- */
* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  transition: background-color 150ms, color 150ms;
}

a { color: inherit; }

.accent { color: var(--accent); }

@keyframes blink {
  0%, 55% { opacity: 1; }
  56%, 100% { opacity: 0; }
}

/* ---- Header ------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.site-header__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 40px;
}

.prompt {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.prompt__label {
  font-size: 14px;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}

/* Prompt façon host:path — l'hôte porte l'identité (yagni),
   le chemin reste le nom du blog. */
.prompt__host { color: var(--fg); }
.prompt__sep { color: var(--muted); }
.prompt__path { color: var(--accent); }

.prompt__sigil {
  font-size: 14px;
  color: var(--muted);
}

.prompt__field {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  height: 20px;
}

.prompt__echo {
  font-size: 14px;
  color: var(--fg);
  white-space: pre;
}

.prompt__cursor {
  display: inline-block;
  flex-shrink: 0;
  width: 9px;
  height: 18px;
  margin-left: 1px;
  background: var(--accent);
  animation: blink 1s step-end infinite;
}

.prompt__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: none;
  outline: none;
  opacity: 0;
  font-family: inherit;
  font-size: 14px;
  cursor: text;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-shrink: 0;
}

.site-nav__link {
  font-size: 13.5px;
  color: var(--muted);
  text-decoration: none;
}

.site-nav__link.is-active { color: var(--accent); }

.theme-toggle {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: none;
  color: var(--fg);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

.site-header__feedback {
  padding: 0 40px 14px;
  font-size: 12.5px;
  color: var(--muted);
}

.site-header__feedback.is-error { color: var(--accent); }

/* ---- Layout ------------------------------------------------------------- */
.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 64px 24px 110px;
}

.site-footer {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 24px 50px;
  color: var(--muted);
  font-size: 12px;
}

/* ---- Home / listing ----------------------------------------------------- */
.listing__intro {
  margin-bottom: 30px;
  font-size: 13px;
  color: var(--muted);
}

.listing {
  margin: 0;
  padding: 0;
  list-style: none;
}

.listing__row {
  display: flex;
  gap: 20px;
  align-items: baseline;
  padding: 18px 16px;
  border-radius: 8px;
  text-decoration: none;
  transition: background-color 120ms;
}

.listing__row:hover { background: var(--card); }

.listing__date {
  min-width: 104px;
  font-size: 13px;
  color: var(--muted);
}

.listing__read {
  min-width: 54px;
  font-size: 13px;
  color: var(--accent);
}

.listing__title {
  font-size: 17px;
  color: var(--fg);
}

.listing__tags {
  display: block;
  margin-top: 5px;
  font-size: 12.5px;
  color: var(--muted);
}

/* ---- Article ------------------------------------------------------------ */
.back-link {
  display: inline-block;
  margin-bottom: 28px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
}

.article__meta {
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--muted);
}

.tag-link {
  color: var(--muted);
  text-decoration: none;
}

.tag-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.article__title {
  margin: 0 0 40px;
  font-weight: 700;
  font-size: 32px;
  line-height: 1.28;
  color: var(--fg);
}

.article-body p {
  margin: 0 0 1.15em;
  font-size: 16.5px;
  line-height: 1.78;
  color: var(--fg);
}

.article-body h2 {
  margin: 1.7em 0 0.55em;
  font-weight: 600;
  font-size: 21px;
  line-height: 1.3;
  color: var(--fg);
}

.article-body h3 {
  margin: 1.5em 0 0.5em;
  font-weight: 600;
  font-size: 17px;
  line-height: 1.3;
  color: var(--fg);
}

.article-body blockquote {
  margin: 1.7em 0;
  padding: 6px 0 6px 20px;
  border-left: 3px solid var(--accent);
  font-style: italic;
  font-size: 17.5px;
  line-height: 1.55;
  color: var(--fg);
}

.article-body blockquote p { font-size: inherit; margin: 0; }

.article-body pre {
  margin: 1.7em 0;
  padding: 16px 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--fg);
}

.article-body pre code {
  background: none;
  padding: 0;
  font-size: inherit;
  color: inherit;
}

.article-body code {
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--card);
  font-size: 0.9em;
  color: var(--accent);
}

.article-body a {
  color: var(--accent);
  text-underline-offset: 2px;
}

.article-body ul,
.article-body ol {
  margin: 0 0 1.15em;
  padding-left: 1.4em;
  font-size: 16.5px;
  line-height: 1.78;
  color: var(--fg);
}

.article-body li { margin-bottom: 0.35em; }

.article-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.9em auto 0;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.article-body figure { margin: 1.9em 0; }

.article-body figcaption {
  margin-top: 9px;
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
}

.article-body table {
  display: block;
  margin: 1.9em 0;
  border-collapse: collapse;
  overflow-x: auto;
  font-size: 15px;
}

.article-body th,
.article-body td {
  padding: 8px 14px;
  border: 1px solid var(--border);
  text-align: left;
}

.article-body th {
  background: var(--card);
  color: var(--fg);
  font-weight: 600;
}

.article-body td { color: var(--fg); }

.forgejo-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.forgejo-link__icon {
  width: 1em;
  height: 1em;
  flex-shrink: 0;
}

.article__source {
  margin-top: 52px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
  font-size: 13px;
}

.article__source a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  text-decoration: none;
}

.article__source a:hover { color: var(--accent); }

/* Le logo Forgejo hérite de la couleur du lien (gris → vert au survol). */
.source-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

/* ---- About -------------------------------------------------------------- */
.about__prompt {
  margin-bottom: 28px;
  font-size: 13px;
  color: var(--muted);
}

.about-body p {
  margin: 0 0 1.3em;
  font-size: 16px;
  line-height: 1.9;
  color: var(--fg);
}

.about-body p:last-child { color: var(--muted); margin-bottom: 0; }

/* ---- Small screens ------------------------------------------------------ */
@media (max-width: 620px) {
  .site-header__bar { padding: 16px 20px; }
  .site-header__feedback { padding: 0 20px 12px; }
  .site-nav { gap: 14px; }
}

/* La barre de commande est pilotée au clavier : inutile — et encombrante —
   sur mobile. On la masque et on laisse la nav occuper toute la largeur. */
@media (max-width: 560px) {
  .prompt { display: none; }

  .site-header__bar {
    gap: 12px;
    justify-content: flex-start;
  }

  .site-nav {
    flex: 1;
    gap: 16px;
  }

  .site-nav__link { font-size: 13px; }

  /* Liens à gauche, bascule de thème repoussée à droite. */
  .theme-toggle { margin-left: auto; }

  /* Les colonnes date/durée tassent le titre sur mobile. On le fait passer
     en pleine largeur en tête, la date et la durée reviennent en dessous. */
  .listing__row {
    flex-wrap: wrap;
    gap: 4px 14px;
    padding: 16px 12px;
  }

  .listing__meta {
    order: -1;
    flex-basis: 100%;
  }

  .listing__date,
  .listing__read {
    min-width: 0;
  }
}

/* Illustrations d'article livrées en paire clair/sombre (ex: fichier-dark.svg
   + fichier-light.svg), marquées .theme-img-dark / .theme-img-light : seule
   celle qui correspond au thème courant du site s'affiche. Contrairement à
   `prefers-color-scheme` dans le SVG lui-même, ceci suit le vrai toggle de
   la page, pas seulement la préférence système. */
.article-body .theme-img-dark,
.article-body .theme-img-light {
  display: none;
}

:root[data-theme="dark"] .article-body .theme-img-dark,
:root[data-theme="light"] .article-body .theme-img-light {
  display: block;
}
