/* Workbench : un carnet de labo. Papier quadrillé, encre, tampons et ruban adhésif. */

/* IBM Plex Mono (licence SIL OFL, voir polices/LICENSE-IBM-Plex-Mono.txt), servie par le site lui-même */
@font-face { font-family: "Plex Mono"; src: url("polices/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("polices/ibm-plex-mono-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --papier: #f4efe3;
  --papier-2: #fbf8f1;
  --quadrillage: rgba(66, 99, 160, 0.09);
  --encre: #1f2328;
  --encre-douce: #57606a;
  --trait: #d8cfbc;
  --accent: #c2410c;          /* fer à souder */
  --accent-doux: #fde7d6;
  --vert: #2b8a3e;
  --jaune: #b7791f;
  --rouge: #c92a2a;
  --bleu: #1c6fb8;
  --gris: #6c757d;
  --violet: #7048e8;
  --ruban: rgba(250, 222, 140, 0.75);
  --code-fond: #1e2228;
  --code-texte: #e6e1d6;
  --ombre: 0 1px 0 rgba(0, 0, 0, 0.04), 0 6px 18px -10px rgba(60, 40, 10, 0.35);
  --rayon: 6px;
  --largeur: 72rem;
  --mono: "Plex Mono", ui-monospace, "SFMono-Regular", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --titres: "Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --texte: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --papier: #16181d;
    --papier-2: #1d2027;
    --quadrillage: rgba(140, 170, 230, 0.06);
    --encre: #e8e3d8;
    --encre-douce: #a3a9b3;
    --trait: #333844;
    --accent: #fb8c4a;
    --accent-doux: #3a2417;
    --vert: #51cf66;
    --jaune: #f2c14e;
    --rouge: #ff6b6b;
    --bleu: #5aa9f0;
    --gris: #9aa1aa;
    --violet: #9f86ff;
    --ruban: rgba(240, 210, 120, 0.35);
    --code-fond: #0f1115;
    --ombre: 0 1px 0 rgba(0, 0, 0, 0.3), 0 8px 22px -12px rgba(0, 0, 0, 0.8);
    color-scheme: dark;
  }
}

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

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

body {
  margin: 0;
  font: 17px/1.6 var(--texte);
  color: var(--encre);
  background-color: var(--papier);
  background-image:
    linear-gradient(var(--quadrillage) 1px, transparent 1px),
    linear-gradient(90deg, var(--quadrillage) 1px, transparent 1px);
  background-size: 24px 24px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; width: 100%; max-width: var(--largeur); margin: 0 auto; padding: 2rem 1rem 4rem; }

a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

h1, h2, h3 { font-family: var(--titres); line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; }
h1 { font-size: clamp(1.9rem, 4.5vw, 2.8rem); margin: 0.2em 0 0.4em; }
h2 { font-size: 1.45rem; margin: 2em 0 0.7em; }
h3 { font-size: 1.15rem; margin: 0 0 0.3em; }

.mono { font-family: var(--mono); font-size: 0.82em; letter-spacing: 0.01em; }
code, kbd, pre { font-family: var(--mono); }

.evitement { position: absolute; left: -999px; top: 0; }
.evitement:focus { left: 1rem; top: 1rem; background: var(--papier-2); padding: 0.5rem 1rem; z-index: 10; }

/* --- En-tête et pied --- */

.entete { border-bottom: 2px solid var(--encre); background: var(--papier-2); }
.entete-dedans {
  max-width: var(--largeur); margin: 0 auto; padding: 0.7rem 1rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.logo { display: flex; align-items: center; gap: 0.5rem; color: var(--encre); text-decoration: none; font-family: var(--titres); font-weight: 700; font-size: 1.35rem; }
.logo svg { width: 34px; height: 34px; }
.entete nav { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.entete nav a {
  color: var(--encre); text-decoration: none; padding: 0.3rem 0.7rem; border-radius: 99px;
  font-family: var(--mono); font-size: 0.85rem; border: 1px solid transparent;
}
.entete nav a:hover { border-color: var(--trait); }
.entete nav a[aria-current="page"] { background: var(--encre); color: var(--papier); }

.pied { border-top: 1px dashed var(--trait); color: var(--encre-douce); text-align: center; padding: 1.5rem 1rem 2rem; font-size: 0.9rem; }
.pied p { margin: 0.3rem auto; max-width: 40rem; }
.pied a { color: inherit; }

/* --- Tampons de statut --- */

.tampon {
  --t: var(--gris);
  display: inline-block; font-family: var(--mono); font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em; line-height: 1;
  color: var(--t); border: 2px solid var(--t); border-radius: 4px; padding: 0.3em 0.5em;
  transform: rotate(-2deg); white-space: nowrap;
  background: color-mix(in srgb, var(--t) 8%, transparent);
}
.tampon-en-cours { --t: var(--bleu); }
.tampon-idee { --t: var(--violet); border-style: dashed; }
.tampon-en-pause { --t: var(--jaune); }
.tampon-termine { --t: var(--vert); }
.tampon-abandonne { --t: var(--gris); text-decoration: line-through; text-decoration-thickness: 1px; }

.bilan { font-family: var(--mono); font-size: 0.75rem; font-weight: 700; padding: 0.15em 0.5em; border-radius: 99px; white-space: nowrap; vertical-align: 0.1em; }
.bilan-marche { color: var(--vert); background: color-mix(in srgb, var(--vert) 14%, transparent); }
.bilan-mitige { color: var(--jaune); background: color-mix(in srgb, var(--jaune) 16%, transparent); }
.bilan-crame { color: var(--rouge); background: color-mix(in srgb, var(--rouge) 14%, transparent); }

/* --- Barre de progression : une règle graduée --- */

.progression { display: flex; align-items: center; gap: 0.6rem; }
.progression-piste {
  flex: 1; height: 12px; border: 1.5px solid var(--encre); border-radius: 3px; overflow: hidden; position: relative;
  background:
    repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), color-mix(in srgb, var(--encre) 35%, transparent) calc(10% - 1px) 10%);
}
.progression-remplie {
  height: 100%;
  background: repeating-linear-gradient(-45deg, var(--projet, var(--accent)) 0 6px, color-mix(in srgb, var(--projet, var(--accent)) 75%, white) 6px 12px);
}
.progression-remplie.figee { filter: grayscale(1); opacity: 0.6; }
.progression-valeur { min-width: 3.2em; text-align: right; font-weight: 700; }

/* --- Accueil --- */

.intro { max-width: 46rem; margin: 1rem 0 2.5rem; }
.intro h1 { font-size: clamp(1.8rem, 4.5vw, 2.6rem); }
.intro p { font-size: 1.1rem; color: var(--encre-douce); }
.compteurs { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; padding: 0; margin: 1.2rem 0 0; list-style: none; }
.compteurs strong { font-size: 1.4em; color: var(--encre); }
.compteurs a { color: var(--encre-douce); }

.titre-section { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem 1rem; flex-wrap: wrap; margin: 2.5rem 0 1rem; border-bottom: 2px solid var(--encre); padding-bottom: 0.4rem; }
.titre-section h2 { margin: 0; }
.legende { display: flex; flex-wrap: wrap; gap: 0.6rem; list-style: none; margin: 0; padding: 0; }
.legende .tampon { font-size: 0.62rem; }

.grille-projets { align-items: start; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); gap: 1.4rem; }

.carte-projet {
  background: var(--papier-2); border: 1px solid var(--trait); border-radius: var(--rayon);
  box-shadow: var(--ombre); overflow: hidden; display: flex; flex-direction: column;
  border-top: 5px solid var(--projet);
  transition: transform 0.15s ease;
}
.carte-projet:hover { transform: translateY(-2px); }
.carte-couverture { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; border-bottom: 1px solid var(--trait); background: var(--papier); }
.carte-corps { padding: 1rem 1.1rem 1.1rem; display: flex; flex-direction: column; gap: 0.55rem; flex: 1; }
.carte-haut { display: flex; justify-content: space-between; }
.carte-projet h3 a { color: var(--encre); text-decoration: none; }
.carte-projet h3 a::after { content: ""; position: absolute; inset: 0; }
.carte-projet { position: relative; }
.carte-projet h3 a:hover { text-decoration: underline; }
.carte-projet p { margin: 0; color: var(--encre-douce); font-size: 0.95rem; }
.carte-projet .progression { margin-top: auto; padding-top: 0.4rem; }
.carte-meta { color: var(--encre-douce); }

/* --- Listes d'entrées (accueil, fiche) --- */

.liste-entrees { list-style: none; margin: 0; padding: 0; }
.ligne-entree {
  display: grid; grid-template-columns: 9.5rem 1fr; gap: 0.3rem 1rem;
  padding: 0.85rem 0; border-bottom: 1px dashed var(--trait);
}
.ligne-entree time { color: var(--encre-douce); padding-top: 0.2rem; }
.ligne-entree p { margin: 0.25rem 0 0; color: var(--encre-douce); font-size: 0.95rem; }
.etiquette-projet {
  display: inline-block; font-family: var(--mono); font-size: 0.72rem; text-decoration: none;
  color: var(--projet); border-left: 4px solid var(--projet); padding-left: 0.4rem; margin-right: 0.4rem;
}
.ligne-titre { color: var(--encre); font-weight: 600; text-decoration: none; margin-right: 0.35rem; }
.ligne-titre:hover { color: var(--accent); text-decoration: underline; }

.vide { color: var(--encre-douce); font-style: italic; }

/* --- Fiche projet --- */

.fil { color: var(--encre-douce); margin: 0; }
.fil a { color: inherit; }
.fiche-entete { border-bottom: 2px solid var(--encre); padding-bottom: 1.2rem; margin-bottom: 2rem; }
.fiche-entete h1 { border-left: 8px solid var(--projet); padding-left: 0.8rem; }
.chapeau { font-size: 1.15rem; color: var(--encre-douce); max-width: 46rem; margin: 0 0 1rem; }
.fiche-etat { display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap; }
.fiche-etat .tampon { font-size: 0.9rem; }
.fiche-etat .progression { flex: 1; min-width: 14rem; max-width: 30rem; }

.fiche-colonnes { display: grid; grid-template-columns: 17rem 1fr; gap: 2.5rem; align-items: start; }
.fiche-cote { display: flex; flex-direction: column; gap: 1.3rem; position: sticky; top: 1rem; }
.fiche-couverture { width: 100%; border-radius: var(--rayon); border: 1px solid var(--trait); box-shadow: var(--ombre); background: var(--papier-2); }
.fiche-infos { display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 1rem; margin: 0; padding: 0.9rem 1rem; background: var(--papier-2); border: 1px solid var(--trait); border-radius: var(--rayon); }
.fiche-infos dt { color: var(--encre-douce); }
.fiche-infos dd { margin: 0; font-weight: 700; }
.materiel {
  background: var(--papier-2); border: 1px solid var(--trait); border-radius: var(--rayon); padding: 0.9rem 1rem;
  position: relative;
}
.materiel::before { /* ruban adhésif */
  content: ""; position: absolute; top: -9px; left: 50%; width: 70px; height: 18px; margin-left: -35px;
  background: var(--ruban); transform: rotate(-3deg);
}
.materiel h2 { font-size: 1rem; margin: 0 0 0.4rem; font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.08em; }
.materiel ul { margin: 0; padding: 0; list-style: none; font-size: 0.92rem; }
.materiel li { padding: 0.25rem 0 0.25rem 1.4rem; position: relative; border-bottom: 1px dotted var(--trait); }
.materiel li:last-child { border-bottom: 0; }
.materiel li::before { content: "▢"; position: absolute; left: 0; color: var(--encre-douce); font-family: var(--mono); }
.journal h2 { border-bottom: 2px solid var(--encre); padding-bottom: 0.3rem; }
.journal .ligne-entree { grid-template-columns: 9.5rem 1fr; }

/* --- Entrée --- */

.entree { max-width: 46rem; margin: 0 auto; }
.entree-entete { border-bottom: 2px solid var(--encre); padding-bottom: 1rem; margin-bottom: 1.8rem; }
.entree-entete h1 { border-left: 8px solid var(--projet); padding-left: 0.8rem; }
.entree-meta { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; color: var(--encre-douce); margin: 0; }
.encart-echec {
  margin: 1rem 0 0; padding: 0.7rem 1rem; border: 2px dashed var(--rouge); border-radius: var(--rayon);
  background: color-mix(in srgb, var(--rouge) 7%, transparent);
}
.entree-suite { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 3rem; border-top: 2px solid var(--encre); padding-top: 1rem; }
.entree-suite a { display: flex; flex-direction: column; gap: 0.2rem; color: var(--encre); text-decoration: none; padding: 0.7rem 0.9rem; border: 1px solid var(--trait); border-radius: var(--rayon); background: var(--papier-2); }
.entree-suite a:hover { border-color: var(--accent); }
.entree-suite .mono { color: var(--encre-douce); }
.entree-suite .suivante { text-align: right; grid-column: 2; }

/* --- Texte Markdown --- */

.prose { overflow-wrap: break-word; }
.prose > :first-child { margin-top: 0; }
.prose h2 { font-size: 1.35rem; }
.prose h3 { margin-top: 1.6em; }
.prose img, .prose video {
  max-width: 100%; height: auto; display: block; margin: 1.6rem auto;
  background: var(--papier-2); border: 1px solid var(--trait); border-radius: 3px; box-shadow: var(--ombre);
  padding: 6px;
}
.prose figure { margin: 1.6rem 0; }
.prose figure img { margin: 0 auto; }
.prose figcaption { text-align: center; font-family: var(--mono); font-size: 0.8rem; color: var(--encre-douce); margin-top: 0.5rem; }
.prose p:has(> img:only-child) { margin: 0; }
.prose blockquote { margin: 1.4rem 0; padding: 0.3rem 1rem; border-left: 4px solid var(--accent); background: var(--accent-doux); border-radius: 0 var(--rayon) var(--rayon) 0; }
.prose table { border-collapse: collapse; width: 100%; font-size: 0.92rem; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--trait); padding: 0.4rem 0.6rem; text-align: left; }
.prose th { background: var(--papier-2); font-family: var(--mono); font-size: 0.85em; }
.prose hr { border: 0; border-top: 2px dashed var(--trait); margin: 2rem 0; }
.prose :not(pre) > code { background: color-mix(in srgb, var(--encre) 8%, transparent); padding: 0.1em 0.35em; border-radius: 4px; font-size: 0.88em; }
.prose li + li { margin-top: 0.25em; }

pre[class*="language-"], .prose pre {
  background: var(--code-fond); color: var(--code-texte); padding: 1rem 1.1rem; border-radius: var(--rayon);
  overflow-x: auto; font-size: 0.85rem; line-height: 1.55; tab-size: 2; margin: 1.4rem 0;
  border-left: 4px solid var(--projet, var(--accent));
}
code[class*="language-"] { font-size: inherit; background: none; padding: 0; }
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: #7f8a99; font-style: italic; }
.token.punctuation { color: #b9b4aa; }
.token.property, .token.tag, .token.constant, .token.symbol, .token.deleted { color: #ff8f73; }
.token.boolean, .token.number { color: #f9c86b; }
.token.selector, .token.attr-name, .token.string, .token.char, .token.builtin, .token.inserted { color: #a8d977; }
.token.operator, .token.entity, .token.url { color: #e6e1d6; }
.token.atrule, .token.attr-value, .token.keyword { color: #7cc4ff; }
.token.function, .token.class-name { color: #f5a8d4; }
.token.regex, .token.important, .token.variable, .token.macro { color: #ffb86c; }

/* --- Frise --- */

.titre-page { max-width: 46rem; margin-bottom: 2rem; }
.titre-page p { color: var(--encre-douce); font-size: 1.05rem; }
.frise { position: relative; max-width: 50rem; }
.frise-mois h2 {
  display: inline-block; margin: 2rem 0 1rem; font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.1em;
  background: var(--encre); color: var(--papier); padding: 0.3rem 0.8rem; border-radius: 4px;
}
.frise-mois ol { list-style: none; margin: 0; padding: 0 0 0 1.4rem; border-left: 3px solid var(--encre); }
.frise-point { position: relative; display: grid; grid-template-columns: 3.4rem 1fr; gap: 0.8rem; padding: 0.4rem 0 1.1rem; }
.frise-point::before {
  content: ""; position: absolute; left: calc(-1.4rem - 9.5px); top: 0.75rem; width: 16px; height: 16px; border-radius: 50%;
  background: var(--projet); border: 3px solid var(--papier); box-shadow: 0 0 0 2px var(--encre);
}
.frise-point.est-echec::before { border-radius: 2px; transform: rotate(45deg); background: var(--rouge); }
.frise-point time { padding-top: 0.6rem; color: var(--encre-douce); }
.frise-carte { background: var(--papier-2); border: 1px solid var(--trait); border-radius: var(--rayon); padding: 0.7rem 0.9rem; box-shadow: var(--ombre); }
.frise-carte .etiquette-projet { display: block; margin-bottom: 0.2rem; }
.frise-carte p { margin: 0.3rem 0 0; color: var(--encre-douce); font-size: 0.93rem; }

/* --- Mur des échecs : des polaroïds scotchés de travers --- */

.mur { list-style: none; margin: 0; padding: 1rem 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr)); gap: 2.2rem 1.6rem; }
.piece { --penche: -1.5deg; transform: rotate(var(--penche)); transition: transform 0.15s ease; }
.piece:nth-child(3n + 2) { --penche: 1.2deg; }
.piece:nth-child(3n + 3) { --penche: -0.6deg; }
.piece:nth-child(4n + 4) { --penche: 2deg; }
.piece:hover { transform: rotate(0) scale(1.02); }
.piece a {
  display: flex; flex-direction: column; gap: 0.6rem; height: 100%; text-decoration: none; color: var(--encre);
  background: var(--papier-2); padding: 10px 10px 14px; border: 1px solid var(--trait); box-shadow: var(--ombre); position: relative;
}
.piece a::before { content: ""; position: absolute; top: -10px; left: 50%; width: 80px; height: 20px; margin-left: -40px; background: var(--ruban); transform: rotate(2deg); }
.piece img, .piece-sans-image { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: var(--papier); border: 1px solid var(--trait); }
.piece-sans-image { display: grid; place-items: center; font-size: 4rem; color: var(--rouge); font-family: var(--mono); opacity: 0.6; }
.piece-texte { font-family: var(--titres); font-weight: 700; font-size: 1.05rem; line-height: 1.3; }
.piece-meta { color: var(--encre-douce); border-top: 1px dashed var(--trait); padding-top: 0.4rem; margin-top: auto; }

/* --- Petits écrans --- */

@media (max-width: 52rem) {
  .fiche-colonnes { grid-template-columns: 1fr; gap: 1.8rem; }
  .fiche-cote { position: static; }
}

@media (max-width: 34rem) {
  body { font-size: 16px; }
  main { padding-top: 1.2rem; }
  .ligne-entree, .journal .ligne-entree { grid-template-columns: 1fr; gap: 0.1rem; }
  .entree-suite { grid-template-columns: 1fr; }
  .entree-suite .suivante { grid-column: 1; }
  .frise-point { grid-template-columns: 1fr; gap: 0.2rem; }
  .frise-point time { padding-top: 0; }
  .entete nav a { padding: 0.3rem 0.55rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
