/* Absorb — styles. Canon Mebius (tokens AA) + spec mainbap v2 §4.5/4.6. */

@font-face { font-family:"Inter Display"; src:url("./fonts/inter-400.woff2") format("woff2"); font-weight:400; font-style:normal; font-display:swap; }
@font-face { font-family:"Inter Display"; src:url("./fonts/inter-500.woff2") format("woff2"); font-weight:500; font-style:normal; font-display:swap; }
@font-face { font-family:"Inter Display"; src:url("./fonts/inter-600.woff2") format("woff2"); font-weight:600; font-style:normal; font-display:swap; }
@font-face { font-family:"Inter Display"; src:url("./fonts/inter-700.woff2") format("woff2"); font-weight:700; font-style:normal; font-display:swap; }

:root{
  --bg:#F5F5F5; --card:#FFFFFF; --border:#EBEBEB; --divider:#EDEDED; --muted:#F0F0F0;
  --r-card:24px; --r-tile:16px; --r-pill:9999px;
  --t1:#121212; --t2:#525252; --t3:#6B6B6B;
  --accent:#0A7CFF; --accent-text:#0068E0; --c2:#A22BFF; --c3:#EA580C; --c4:#16A34A;
  --pos-bg:#E7F6EC; --pos-fg:#15803D; --neg-bg:#FDECEC; --neg-fg:#B91C1C;
  --blue-50:#E6F1FE; --shadow-control:0 1px 2px rgba(0,0,0,.06), 0 2px 6px rgba(0,0,0,.04);
  --ease:cubic-bezier(.2,.8,.2,1);
  font-family:"Inter Display","Inter","SF Pro Display",-apple-system,system-ui,"Segoe UI",Roboto,sans-serif;
  color:var(--t1);
}
*{ box-sizing:border-box; }
html,body{ margin:0; padding:0; background:var(--bg); }
body{ font-size:15px; line-height:1.5; -webkit-font-smoothing:antialiased; padding-bottom:88px; }
@media (min-width:761px){ body{ padding-bottom:32px; } }

h1,h2,h3{ letter-spacing:-0.01em; margin:0; }
a{ color:var(--accent-text); }
button{ font:inherit; }

/* — accessibilité — */
.skip{ position:absolute; left:-9999px; top:0; background:var(--card); padding:12px 16px; border-radius:var(--r-pill); z-index:99; }
.skip:focus{ left:12px; top:12px; }
:focus-visible{ outline:2px solid var(--accent); outline-offset:2px; border-radius:8px; }
/* le conteneur principal reçoit un focus programmatique : jamais d'anneau (critique n°1) */
main#app:focus, main#app:focus-visible{ outline:none; }
/* chiffres tabulaires réservés aux compteurs (critique n°4) */
.num,.kpi-hero,.kpi-tile .v,.end-score,.mv,.idea-head .pill{ font-variant-numeric:tabular-nums; }

/* — topbar : compacte + logo sur mobile, nav complète sur desktop — */
.topbar{ display:flex; align-items:center; gap:24px; max-width:1060px; margin:0 auto; padding:12px 16px 0; }
.brand{ font-size:18px; font-weight:700; letter-spacing:-0.02em; }
.brand a{ color:var(--t1); text-decoration:none; }
.topnav{ display:none; }
@media (min-width:761px){
  body{ padding-top:0; }
  .topbar{ padding:20px 24px 4px; }
  .topnav{ display:flex; gap:6px; margin-left:auto; }
  .topnav a{ text-decoration:none; color:var(--t2); padding:10px 16px; border-radius:var(--r-pill); min-height:44px; display:inline-flex; align-items:center; }
  /* actif : texte bleu, pas de pastille (canon : seul l'actif en couleur) */
  .topnav a[aria-current="page"]{ background:transparent; border-color:transparent; color:var(--accent-text); font-weight:600; }
}

main#app{ max-width:1060px; margin:0 auto; padding:16px 16px 8px; }
@media (min-width:761px){ main#app{ padding:12px 24px; } }
main#app p{ max-width:68ch; }

/* — barre de navigation basse (mobile) — */
.bottomnav{ position:fixed; bottom:0; left:0; right:0; background:var(--card); border-top:1px solid var(--border); display:flex; justify-content:space-around; padding:6px 8px calc(6px + env(safe-area-inset-bottom)); z-index:40; }
.bottomnav a{ display:flex; flex-direction:column; align-items:center; gap:2px; text-decoration:none; color:var(--t3); font-size:11px; font-weight:500; padding:6px 10px; border-radius:var(--r-tile); min-width:64px; min-height:44px; justify-content:center; }
.bottomnav a .ic{ display:flex; line-height:1; }
.bottomnav a .ic svg{ width:22px; height:22px; display:block; }
.bottomnav a[aria-current="page"]{ color:var(--accent-text); font-weight:600; }
@media (min-width:761px){ .bottomnav{ display:none; } }

/* — cartes & tuiles — */
.card{ background:var(--card); border:1px solid var(--border); border-radius:var(--r-card); padding:20px; box-shadow:none; }
@media (min-width:761px){ .card{ padding:24px; } }
.tile{ background:var(--bg); border-radius:var(--r-tile); padding:14px 16px; }
.overline{ font-size:12px; font-weight:500; letter-spacing:0.02em; text-transform:uppercase; color:var(--t3); }
.kpi-hero{ font-size:34px; font-weight:600; letter-spacing:-0.02em; line-height:1.1; }
.sub{ color:var(--t2); }
.ter{ color:var(--t3); font-size:13px; }

/* pastilles */
.pill{ display:inline-flex; align-items:center; gap:6px; border-radius:var(--r-pill); padding:4px 10px; font-size:13px; font-weight:600; line-height:1.3; white-space:nowrap; }
.pill-blue{ background:var(--blue-50); color:var(--accent-text); }
.pill-pos{ background:var(--pos-bg); color:var(--pos-fg); }
.pill-neg{ background:var(--neg-bg); color:var(--neg-fg); }
.pill-grey{ background:var(--muted); color:var(--t2); }
.pill-plain{ background:var(--card); border:1px solid var(--border); color:var(--t2); font-weight:500; }

/* — boutons — */
.btn{ display:inline-flex; align-items:center; justify-content:center; gap:8px; min-height:44px; padding:10px 20px; border-radius:var(--r-pill); border:1px solid transparent; font-size:15px; font-weight:600; cursor:pointer; text-decoration:none; transition:background .18s var(--ease), color .18s var(--ease), border-color .18s var(--ease); }
.btn-primary{ background:var(--accent-text); color:#fff; }   /* AA : blanc sur #0068E0 ≈ 5,2:1 */
.btn-primary:hover{ background:#0056B7; }
.btn-ghost{ background:var(--card); color:var(--t1); border-color:var(--border); box-shadow:0 1px 2px rgba(0,0,0,.04); }
.btn-ghost:hover{ border-color:var(--t3); }
.btn:disabled{ opacity:.4; cursor:not-allowed; }
.btn-sm{ min-height:44px; padding:8px 14px; font-size:14px; font-weight:500; }
.linklike{ background:none; border:none; color:var(--accent-text); cursor:pointer; padding:8px; min-height:44px; border-radius:8px; font-size:13px; display:inline-flex; align-items:center; }

/* — segmented control — */
.segmented{ display:flex; background:var(--bg); border-radius:var(--r-pill); padding:4px; gap:2px; overflow-x:auto; }
.segmented button{ flex:1; min-height:44px; border:1px solid transparent; background:transparent; border-radius:var(--r-pill); padding:8px 14px; font-size:14px; font-weight:500; color:var(--t3); cursor:pointer; white-space:nowrap; }
.segmented button[aria-selected="true"]{ background:var(--card); border:1px solid var(--border); color:var(--accent-text); font-weight:600; }
@media (min-width:761px){
  /* desktop : seul l'actif en couleur (canon), cohérent avec la nav */
  .segmented button[aria-selected="true"]{ background:transparent; border-color:transparent; color:var(--accent-text); font-weight:600; }
}

/* — filtres — */
.filters{ display:flex; gap:8px; flex-wrap:wrap; }
.filters button{ min-height:44px; padding:8px 16px; border-radius:var(--r-pill); border:1px solid var(--border); background:var(--card); color:var(--t2); font-size:14px; font-weight:500; cursor:pointer; }
/* actif : seul l'actif en couleur (canon) — fond bleu + texte blanc */
.filters button[aria-pressed="true"]{ background:var(--accent-text); border-color:var(--accent-text); color:#fff; font-weight:600; }
@media (max-width:760px){
  .filters{ flex-wrap:nowrap; overflow-x:auto; scrollbar-width:none;
    -webkit-mask-image:linear-gradient(to right,#000 0,#000 calc(100% - 28px),transparent 100%);
    mask-image:linear-gradient(to right,#000 0,#000 calc(100% - 28px),transparent 100%); }
  .filters::after{ content:""; display:block; flex:0 0 24px; } /* padding de fin : la dernière puce ne colle pas au bord */
  .filters button{ white-space:nowrap; flex-shrink:0; }
}

/* — grille bibliothèque — */
/* minmax(0,1fr) : empêche le contenu (pastilles nowrap) de forcer la largeur des colonnes */
.grid-books{ display:grid; grid-template-columns:repeat(2, minmax(0,1fr)); gap:16px; }
@media (min-width:761px){ .grid-books{ grid-template-columns:repeat(4, minmax(0,1fr)); } }
@media (max-width:760px){ .grid-books{ gap:12px; } }
.book-tile{ display:flex; flex-direction:column; gap:10px; background:var(--card); border:1px solid var(--border); border-radius:var(--r-card); padding:14px; text-decoration:none; color:var(--t1); transition:transform .2s var(--ease); min-width:0; }
.book-tile:hover,.book-tile:focus-visible{ transform:translateY(-2px); }
.cover{ width:100%; aspect-ratio:2/3; object-fit:contain; object-position:top; border-radius:var(--r-tile); background:var(--muted); filter:grayscale(1); transition:filter .2s var(--ease); }
.book-tile.action .cover, .book-tile:hover .cover, .book-tile:focus-visible .cover{ filter:grayscale(0); }
.book-tile .t{ font-weight:600; font-size:14px; line-height:1.3; }
.book-tile .a{ color:var(--t3); font-size:12px; }
.book-tile .abs{ display:flex; align-items:center; gap:8px; }
.absbar{ flex:1; height:4px; border-radius:2px; background:var(--muted); overflow:hidden; }
.absbar>span{ display:block; height:100%; background:var(--accent); border-radius:2px; width:0; transition:width .3s var(--ease); }
.newbook{ flex-direction:row; align-items:center; justify-content:center; gap:10px; border-style:solid; color:var(--t2); min-height:0; padding:14px 16px; cursor:pointer; font:inherit; }
.newbook .nb-plus{ width:30px; height:30px; border-radius:var(--r-pill); background:var(--muted); color:var(--t2); font-size:20px; font-weight:600; display:flex; align-items:center; justify-content:center; flex-shrink:0; }
@media (max-width:760px){ .grid-books .newbook{ display:none; } }

/* — héros accueil — */
.hero-head{ display:flex; align-items:flex-start; justify-content:space-between; gap:16px; flex-wrap:wrap; }
.hero-num{ display:flex; align-items:baseline; gap:14px; flex-wrap:wrap; }
.hero-line2{ display:flex; justify-content:space-between; align-items:center; gap:12px; flex-wrap:wrap; margin-top:14px; padding-top:14px; border-top:1px solid var(--divider); }
.kpis{ display:grid; grid-template-columns:repeat(3,1fr); gap:12px; margin-top:16px; }
.kpi-tile{ background:var(--card); border:1px solid var(--border); border-radius:var(--r-tile); padding:14px 16px; }
.kpi-tile .v{ font-size:34px; font-weight:600; letter-spacing:-0.02em; line-height:1.1; }
.kpi-tile .l{ font-size:13px; color:var(--t2); margin-top:2px; }
.kpi-tile .d{ margin-top:6px; }
.kpi-empty{ margin-top:16px; }

/* — page livre — */
.book-head{ display:flex; gap:16px; align-items:flex-start; }
/* la couverture suit la même règle grayscale que la bibliothèque :
   en couleur seulement si une action est due (focus + contexte) */
.book-head img{ width:64px; height:96px; object-fit:contain; object-position:top; border-radius:16px; background:var(--muted); filter:grayscale(1); transition:filter .2s var(--ease); }
.book-head img.action, .book-head:hover img{ filter:grayscale(0); }
.book-head .bh-main{ flex:1; min-width:0; }
.book-head .bh-score{ margin-left:auto; text-align:right; }
.abs-delta{ margin-top:6px; }
@media (max-width:599px){
  .book-head{ flex-wrap:wrap; }
  .book-head .bh-score{ flex-basis:100%; display:flex; align-items:center; gap:10px; margin-left:0; margin-top:4px; text-align:left; }
  .book-head .bh-score .abs-delta{ margin-top:0; }
  .book-head .bh-score .kpi-hero{ font-size:26px; }
}
.concept-list{ display:flex; flex-direction:column; gap:10px; margin-top:16px; }
.concept-tile{ display:flex; gap:12px; align-items:flex-start; background:var(--card); border:1px solid var(--border); border-radius:var(--r-tile); padding:14px 16px; text-decoration:none; color:var(--t1); opacity:0; animation:fadeUp .3s var(--ease) forwards; }
.concept-tile .rank{ width:26px; height:26px; border-radius:var(--r-pill); background:var(--muted); color:var(--t2); font-size:13px; font-weight:600; display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.concept-tile.current{ border-color:var(--accent); }
.concept-tile.current .rank{ background:var(--accent-text); color:#fff; }
.concept-tile .ct{ font-weight:600; }
.concept-tile .cl{ color:var(--t2); font-size:13px; }
.concept-tile .cstat{ margin-left:auto; display:inline-flex; align-items:center; gap:6px; flex-shrink:0; }
.concept-tile .cstat .cstat-t{ font-size:13px; color:var(--t3); }
.concept-tile .cstat.ok .cstat-t{ color:var(--pos-fg); font-weight:600; }
/* mobile étroit : le libellé de statut disparaît (chevron seul), le texte retrouve ~280px ;
   une idée absorbée garde sa coche verte */
@media (max-width:479px){
  .card{ padding:16px; }
  .concept-list{ gap:8px; }
  .concept-tile{ padding:10px 12px; gap:8px; }
  .concept-tile .rank{ width:24px; height:24px; font-size:12px; }
  .concept-tile .cstat .cstat-t{ display:none; }
  .concept-tile .cstat.ok .chev{ display:none; }
  .concept-tile .cstat.ok::after{ content:"✓"; color:var(--pos-fg); font-weight:700; font-size:15px; }
}
.chev{ color:var(--t3); font-size:18px; line-height:1; }

/* — page idée — */
.idea-head{ display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; margin:0 0 10px; }
.preq{ border:none; }
.preq textarea,.answer-field{ font-size:16px; /* anti-zoom iOS */ }
textarea{ width:100%; border:1px solid var(--border); border-radius:var(--r-tile); padding:12px 14px; font:inherit; font-size:16px; resize:none; min-height:88px; background:var(--card); color:var(--t1); }
textarea:focus{ outline:2px solid var(--accent); outline-offset:0; }
.pred-tile{ background:var(--muted); border-radius:var(--r-tile); padding:12px 14px; color:var(--t2); }
.blocktitle{ font-size:22px; font-weight:600; letter-spacing:-0.01em; }
.idea-block{ margin-top:20px; }
.script-tile{ background:#F5F5F5; border-radius:var(--r-tile); padding:14px 16px; display:flex; gap:12px; align-items:flex-start; margin-top:8px; }
.script-tile .st{ flex:1; white-space:pre-wrap; }
.copy-btn{ flex-shrink:0; }
details.convince{ margin-top:20px; border-top:1px solid var(--divider); padding-top:14px; }
details.convince summary{ cursor:pointer; color:var(--t2); font-weight:500; min-height:44px; display:flex; align-items:center; list-style:none; }
details.convince summary::-webkit-details-marker{ display:none; }
details.convince summary::before{ content:"▸ "; color:var(--t3); }
details.convince[open] summary::before{ content:"▾ "; }
.footer-read{ margin-top:24px; display:flex; gap:12px; flex-wrap:wrap; }

/* — revue plein écran — */
.revue{ position:fixed; inset:0; background:var(--bg); z-index:60; overflow-y:auto; }
.revue-inner{ max-width:680px; margin:0 auto; padding:20px 16px calc(24px + env(safe-area-inset-bottom)); }
.segbar{ display:flex; gap:6px; margin-bottom:18px; }
.segbar .seg{ flex:1; height:6px; border-radius:3px; background:#E3E3E3; transition:background .3s var(--ease); }
.segbar .seg.done{ background:#949494; }
.segbar .seg.now{ background:var(--accent); }
.qcard{ background:var(--card); border:1px solid var(--border); border-radius:var(--r-card); padding:20px; }
.qcard .q{ font-size:20px; font-weight:600; line-height:1.35; margin:10px 0 16px; }
.typepill{ font-size:12px; }
.reveal-zone{ overflow:hidden; }
.reveal-in{ animation:reveal .22s var(--ease); }
.criteria{ display:flex; flex-direction:column; gap:8px; margin-top:8px; }
.crit{ display:flex; gap:12px; align-items:flex-start; background:var(--bg); border-radius:var(--r-tile); padding:12px 14px; cursor:pointer; min-height:44px; }
.crit input{ width:20px; height:20px; margin:2px 0 0; accent-color:var(--accent); flex-shrink:0; transform:scale(1); transition:transform .12s var(--ease); }
.crit input:checked{ transform:scale(1); animation:pop .12s var(--ease); }
.result-pill{ display:inline-flex; align-items:center; gap:8px; min-height:44px; padding:10px 18px; border-radius:var(--r-pill); font-weight:600; font-size:15px; animation:pop2 .16s var(--ease); }
.rev-actions{ display:flex; gap:12px; align-items:center; flex-wrap:wrap; margin-top:18px; }
.transfer{ margin-top:16px; padding:14px 16px; border-radius:var(--r-tile); background:var(--blue-50); }
.end-score{ font-size:56px; font-weight:600; letter-spacing:-0.02em; line-height:1; }
.mv{ display:flex; justify-content:space-between; gap:12px; padding:10px 0; border-bottom:1px solid var(--divider); font-size:14px; }
.mv:last-child{ border-bottom:none; }

/* — pari — */
.pari-form{ display:flex; flex-direction:column; gap:14px; margin-top:14px; }
.pari-form label{ font-weight:600; font-size:13px; color:var(--t2); display:block; margin-bottom:6px; }
.pari-form input[type="date"], .pari-form input[type="text"]{ width:100%; min-height:44px; border:1px solid var(--border); border-radius:var(--r-tile); padding:10px 14px; font:inherit; font-size:16px; background:var(--card); color:var(--t1); }
.outcomes{ display:flex; gap:8px; flex-wrap:wrap; margin-top:10px; }

/* — thèmes — */
.theme-tile{ display:block; text-decoration:none; color:var(--t1); }
.rel-pill{ font-size:12px; padding:3px 10px; }
.entry{ background:var(--card); border:1px solid var(--border); border-radius:var(--r-tile); padding:14px 16px; margin-top:10px; }
.entry .eh{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.verdict{ background:var(--blue-50); border-radius:var(--r-tile); padding:16px; margin-top:16px; }

/* — modal — */
.modal-bg{ position:fixed; inset:0; background:rgba(18,18,18,.4); z-index:80; display:flex; align-items:center; justify-content:center; padding:16px; }
.modal{ background:var(--card); border-radius:var(--r-card); max-width:560px; width:100%; max-height:86vh; overflow-y:auto; padding:24px; }
.modal pre{ background:var(--bg); border-radius:var(--r-tile); padding:12px; overflow-x:auto; font-size:12px; }

/* — .ics & divers — */
.footrows{ display:flex; flex-direction:column; gap:8px; margin-top:16px; }
.footrow{ display:flex; align-items:center; justify-content:space-between; gap:8px; width:100%; min-height:48px; padding:12px 16px; background:var(--card); border:1px solid var(--border); border-radius:var(--r-tile); color:var(--t1); font-size:15px; font-weight:500; cursor:pointer; text-decoration:none; text-align:left; }
.footrow:hover{ border-color:var(--t3); }
.biblio-head{ display:flex; align-items:center; justify-content:space-between; gap:12px; margin:24px 0 12px; }
.biblio-head h2{ margin:0; }
.add-book{ display:none; }
@media (max-width:760px){ .add-book{ display:inline-flex; } }
.ics-link{ margin-top:18px; text-align:center; }
.muted-note{ color:var(--t3); font-size:13px; }
.checklist{ list-style:none; padding:0; margin:8px 0 0; display:flex; flex-direction:column; gap:8px; }
.rest-row{ padding:12px 0; border-bottom:1px solid var(--divider); }
.rest-row:last-child{ border-bottom:none; }
.rest-row .rc{ font-weight:600; }
.rest-row .rr{ color:var(--t3); font-size:13px; }

/* — animations §4.6 — */
@keyframes fadeUp{ from{ opacity:0; transform:translateY(8px); } to{ opacity:1; transform:none; } }
@keyframes reveal{ from{ opacity:0; transform:translateY(8px); } to{ opacity:1; transform:none; } }
@keyframes pop{ from{ transform:scale(.9); } to{ transform:scale(1); } }
@keyframes pop2{ from{ opacity:0; transform:scale(.95); } to{ opacity:1; transform:scale(1); } }
.toast{ position:fixed; left:50%; bottom:104px; transform:translateX(-50%); background:var(--t1); color:#fff; border-radius:var(--r-pill); padding:10px 18px; font-size:14px; z-index:90; animation:pop2 .16s var(--ease); }

@media (prefers-reduced-motion: reduce){
  *,*::before,*::after{ animation-duration:.01ms !important; animation-iteration-count:1 !important; transition-duration:.01ms !important; }
  .concept-tile{ opacity:1; }
}
