/*
 * Design system « conteurs d'Afrique de l'Ouest » — app web JaliStories.
 * Implémenté depuis les maquettes Claude Design (Accueil/Catalogue/Fiche/Reader).
 * Accent = orange de marque #fc6c38. Mode clair/sombre + sépia (reader).
 */

:root {
    --bg:#FBF6EF; --surface:#F3ECE0; --ink:#241D17; --ink-muted:#6B5F52;
    --border:#E4D9C8; --accent:#fc6c38; --accent-hover:#e85a28; --accent-tint:#FDE3D6;
    --secondary:#2E3F6E; --gold:#8A6318; --gold-tint:#F1E3C4;
}
:root[data-theme="dark"] {
    --bg:#171310; --surface:#1E1913; --ink:#F1E9DC; --ink-muted:#A99C8B;
    --border:#362E24; --accent:#ff8452; --accent-hover:#ff9d72; --accent-tint:#3A2418;
    --secondary:#4A5FA0; --gold:#D9A94A; --gold-tint:#3A2E14;
}

* { box-sizing:border-box; }
body {
    margin:0; font-family:'Work Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background:var(--bg); color:var(--ink); line-height:1.6;
    transition:background .2s, color .2s;
}
/* Barre d'onglets + padding : voir appnav.css (commun à tout l'espace web). */
a { color:inherit; }
.serif { font-family:'Spectral', Georgia, serif; }
::selection { background:var(--accent-tint); }
.appui-wrap { max-width:1180px; margin:0 auto; }
@keyframes fadeUp { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }

/* ---- En-tête app (Accueil) ---- */
.app-header {
    position:sticky; top:0; z-index:20; display:flex; align-items:center; gap:12px;
    padding:12px 16px; background:var(--bg); border-bottom:1px solid var(--border);
}
.app-brand { display:flex; align-items:center; gap:8px; text-decoration:none; color:var(--ink); flex:0 0 auto; }
.app-search { flex:1; max-width:460px; position:relative; }
.app-search i { position:absolute; left:12px; top:50%; transform:translateY(-50%); color:var(--ink-muted); font-size:14px; }
.app-search input {
    width:100%; padding:9px 12px 9px 34px; border-radius:999px; border:1px solid var(--border);
    background:var(--surface); color:var(--ink); font-size:13.5px; font-family:inherit; outline:none;
}
.app-search input:focus { border-color:var(--accent); }
.header-actions { display:flex; align-items:center; gap:8px; flex:0 0 auto; }
.icon-btn {
    width:36px; height:36px; border-radius:999px; border:1px solid var(--border);
    background:var(--surface); color:var(--ink); display:flex; align-items:center;
    justify-content:center; cursor:pointer; flex:0 0 auto; font-size:15px; text-decoration:none;
}
.icon-btn:hover { border-color:var(--accent); color:var(--accent); }
.coins-badge {
    display:flex; align-items:center; gap:5px; background:var(--gold-tint); color:var(--gold);
    font-weight:700; font-size:13px; padding:7px 11px; border-radius:999px; white-space:nowrap; text-decoration:none;
}
.avatar {
    width:34px; height:34px; border-radius:999px; background:var(--secondary); color:#fff;
    display:flex; align-items:center; justify-content:center; font-weight:700; font-size:13px; flex:0 0 auto; text-decoration:none;
}

/* ---- En-tête contextuel (Catalogue/Fiche/Reader) ---- */
.top-header {
    position:sticky; top:0; z-index:20; display:flex; align-items:center; gap:12px;
    padding:12px 16px; background:var(--bg); border-bottom:1px solid var(--border);
}
.top-header .back { font-size:18px; color:var(--ink); text-decoration:none; flex:0 0 auto; }
.top-header .title { font-family:'Spectral',serif; font-weight:600; font-size:18px; margin:0; flex:1; min-width:0;
    white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* ---- Barre d'onglets : déplacée dans appnav.css (commun à tout le site) ---- */

/* ---- Contenu / sections ---- */
.app-main { max-width:1180px; margin:0 auto; padding:20px 16px 8px; animation:fadeUp .4s ease both; }
.greeting { font-family:'Spectral',serif; font-weight:600; font-size:clamp(20px,3vw,26px); margin:0 0 4px; }
.greeting-sub { margin:0 0 20px; color:var(--ink-muted); font-size:14px; }
.sec { margin-bottom:28px; }
.sec-row { display:flex; align-items:baseline; justify-content:space-between; margin-bottom:12px; gap:8px; }
.sec-title { font-family:'Spectral',serif; font-weight:600; font-size:17px; margin:0; }
.link-accent { color:var(--accent); text-decoration:none; font-weight:600; font-size:13px; }
.hscroll { display:flex; gap:14px; overflow-x:auto; padding-bottom:6px; scrollbar-width:thin; }

/* Reprendre la lecture */
.continue-card { flex:0 0 240px; display:flex; gap:12px; border:1px solid var(--border); border-radius:12px; padding:10px; background:var(--surface); text-decoration:none; color:var(--ink); }
.continue-cover { width:56px; flex:0 0 56px; aspect-ratio:2/3; border-radius:6px; object-fit:cover; background:var(--bg); border:1px solid var(--border); }
.continue-body { display:flex; flex-direction:column; gap:6px; min-width:0; flex:1; }
.continue-title { font-weight:600; font-size:13.5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.continue-chap { font-size:12px; color:var(--ink-muted); }
.progress-track { height:5px; border-radius:999px; background:var(--border); overflow:hidden; margin-top:auto; }
.progress-fill { height:100%; background:var(--accent); }

/* Série de lecture quotidienne */
.streak-card { display:flex; align-items:center; gap:14px; border:1px solid var(--border); border-radius:12px; padding:12px 14px; background:var(--surface); margin-bottom:22px; }
.streak-flame { flex:0 0 44px; width:44px; height:44px; border-radius:50%; display:grid; place-items:center; font-size:20px; background:var(--accent-tint); }
.streak-flame.is-cold { background:var(--border); filter:grayscale(1); opacity:.7; }
.streak-body { flex:1; min-width:0; }
.streak-count { font-family:'Spectral',serif; font-weight:600; font-size:15.5px; margin:0 0 2px; }
.streak-next { font-size:12.5px; color:var(--ink-muted); margin:0; }
.streak-next strong { color:var(--accent); font-weight:600; }
.streak-track { height:5px; border-radius:999px; background:var(--border); overflow:hidden; margin-top:8px; }
.streak-track > div { height:100%; background:var(--accent); transition:width .3s ease; }
@media (max-width:420px) { .streak-flame { flex-basis:38px; width:38px; height:38px; font-size:17px; } }

/* Challenge du mois */
.contest-hero { padding:18px 0 6px; }
.contest-status { display:inline-block; font-size:11.5px; font-weight:700; text-transform:uppercase; letter-spacing:.04em; padding:4px 10px; border-radius:999px; background:var(--border); color:var(--ink-muted); }
.contest-status.is-open { background:var(--accent-tint); color:var(--accent-hover); }
.contest-title { font-family:'Spectral',serif; font-weight:600; font-size:clamp(22px,4vw,30px); margin:10px 0 6px; }
.contest-theme { margin:0 0 6px; font-size:14.5px; }
.contest-deadline { margin:0 0 4px; color:var(--ink-muted); font-size:13px; display:flex; align-items:center; gap:6px; }
.contest-text { font-size:14.5px; line-height:1.65; margin:0; }
.contest-prize { background:var(--gold-tint); border:1px solid var(--gold); border-radius:10px; padding:12px 14px; font-size:14px; line-height:1.6; }
.contest-entry-form { display:flex; gap:10px; flex-wrap:wrap; }
.contest-select { flex:1; min-width:200px; padding:11px 12px; border:1px solid var(--border); border-radius:10px; background:var(--surface); color:var(--ink); font-size:14px; font-family:inherit; }
.contest-cta { border:1px solid var(--border); border-radius:12px; padding:16px; background:var(--surface); display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:12px; }
.contest-cta p { margin:0; font-size:14px; }
.contest-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(140px,1fr)); gap:16px; }
.contest-empty { text-align:center; padding:48px 16px; }
.contest-empty i { font-size:40px; color:var(--ink-muted); opacity:.5; }
.contest-empty h2 { font-family:'Spectral',serif; font-weight:600; font-size:20px; margin:12px 0 6px; }
.contest-empty p { max-width:420px; margin:0 auto 18px; font-size:14px; }
.book-badge-rank { position:absolute; top:6px; left:6px; background:var(--gold); color:#fff; font-size:11px; font-weight:700; padding:3px 8px; border-radius:999px; }

/* Chips genres / filtres */
.chip-row { display:flex; gap:8px; overflow-x:auto; padding-bottom:8px; scrollbar-width:thin; }
.chip {
    flex:0 0 auto; background:var(--surface); color:var(--ink); border:1px solid var(--border);
    padding:7px 14px; border-radius:999px; font-size:13px; font-weight:600; white-space:nowrap;
    text-decoration:none; cursor:pointer;
}
.chip.active { background:var(--accent); color:#fff; border-color:var(--accent); }

/* Grilles de livres */
.book-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(150px,1fr)); gap:22px 16px; }
.book-grid.wide { grid-template-columns:repeat(auto-fill, minmax(165px,1fr)); }
/* Desktop : exactement 5 livres par rangée */
@media (min-width:1024px) { .book-grid, .book-grid.wide { grid-template-columns:repeat(5, 1fr); } }
.book-card { display:flex; flex-direction:column; gap:6px; text-decoration:none; color:var(--ink); }
.book-cover { aspect-ratio:2/3; border-radius:8px; position:relative; overflow:hidden; background:var(--surface); border:1px solid var(--border); }
.book-cover img { width:100%; height:100%; object-fit:cover; display:block; }
.book-badge-coin { position:absolute; top:6px; left:6px; background:var(--gold-tint); color:var(--gold); font-size:10px; font-weight:700; padding:2px 6px; border-radius:999px; display:flex; align-items:center; gap:3px; }
.book-badge-genre { position:absolute; top:6px; right:6px; background:rgba(0,0,0,.5); color:#fff; font-size:9.5px; font-weight:600; padding:2px 6px; border-radius:999px; }

/* Promotions « livres du mois » */
.book-badge-promo { position:absolute; top:6px; left:6px; background:#c0392b; color:#fff; font-size:10px; font-weight:700; padding:3px 7px; border-radius:999px; letter-spacing:.02em; }
.book-price-promo { display:flex; align-items:baseline; gap:6px; margin-top:2px; font-size:12px; }
.price-old { text-decoration:line-through; color:var(--ink-muted); }
.price-new { color:#c0392b; font-weight:700; }
.tag-promo { background:#c0392b; border-color:#c0392b; color:#fff; }
.promo-banner { display:flex; align-items:center; gap:10px; margin:0 0 18px; padding:11px 14px; border-radius:10px; background:var(--accent-tint); border:1px solid var(--accent); font-size:13.5px; }
.promo-banner i { color:#c0392b; font-size:16px; }
.promo-banner .price-old { margin-right:2px; }
.promo-banner strong { color:#c0392b; font-size:15px; }
.book-title { font-family:'Spectral',serif; font-weight:600; font-size:14px; line-height:1.3; }
.book-author { font-size:12px; color:var(--ink-muted); }
.book-card:hover .book-title { color:var(--accent); }

/* Auteurs à suivre */
.author-chip { flex:0 0 84px; display:flex; flex-direction:column; align-items:center; gap:6px; text-align:center; text-decoration:none; color:var(--ink); }
.author-ini { width:56px; height:56px; border-radius:999px; background:var(--secondary); color:#fff; display:flex; align-items:center; justify-content:center; font-weight:700; font-size:15px; overflow:hidden; }
.author-ini img { width:100%; height:100%; object-fit:cover; }
.author-name { font-size:12px; font-weight:500; }

/* Boutons */
.btn {
    text-decoration:none; font-weight:600; border-radius:8px; display:inline-flex; align-items:center;
    gap:8px; cursor:pointer; border:1px solid transparent; line-height:1.2; font-family:inherit; font-size:15px; padding:13px 22px;
}
.btn-accent { background:var(--accent); color:#fff; }
.btn-accent:hover { background:var(--accent-hover); color:#fff; }
.btn-ghost { background:transparent; color:var(--ink); border-color:var(--border); }
.btn-ghost:hover { border-color:var(--accent); color:var(--accent); }
.btn-soft { background:var(--surface); color:var(--ink); border:1px solid var(--border); }
.btn-block { width:100%; justify-content:center; }
.center { text-align:center; }
.muted { color:var(--ink-muted); }

/* Toolbar catalogue (compte + tri) */
.cat-toolbar { display:flex; align-items:center; justify-content:space-between; margin-bottom:14px; }
.cat-count { font-size:13px; color:var(--ink-muted); }

/* ---- Fiche livre ---- */
.detail-main { max-width:920px; margin:0 auto; padding:24px 16px; animation:fadeUp .4s ease both; }
.detail-head { display:grid; grid-template-columns:140px 1fr; gap:20px; align-items:start; }
@media (max-width:520px) { .detail-head { grid-template-columns:112px 1fr; gap:16px; } }
.detail-cover { aspect-ratio:2/3; border-radius:12px; overflow:hidden; background:var(--surface); border:1px solid var(--border); }
.detail-cover img { width:100%; height:100%; object-fit:cover; display:block; }
.detail-meta { display:flex; flex-direction:column; gap:10px; }
.detail-title { font-family:'Spectral',serif; font-weight:700; font-size:clamp(22px,4vw,30px); margin:0; line-height:1.15; }
.detail-author { color:var(--accent); text-decoration:none; font-weight:600; font-size:14.5px; }
.detail-rating { display:flex; align-items:center; gap:6px; font-size:13.5px; color:var(--ink-muted); }
.detail-rating .bi-star-fill { color:var(--gold); }
.tag-row { display:flex; flex-wrap:wrap; gap:6px; }
.tag { background:var(--surface); border:1px solid var(--border); padding:4px 11px; border-radius:999px; font-size:12px; font-weight:500; }
.detail-desc { margin:22px 0 0; font-size:15.5px; line-height:1.7; color:var(--ink-muted); max-width:70ch; white-space:pre-line; }
.cta-row { display:flex; gap:12px; margin-top:22px; flex-wrap:wrap; }
.chapters { display:flex; flex-direction:column; border:1px solid var(--border); border-radius:12px; overflow:hidden; }
.chapter-row { display:flex; align-items:center; gap:12px; padding:14px 16px; border-bottom:1px solid var(--border); background:var(--bg); text-decoration:none; color:var(--ink); }
.chapter-row:last-child { border-bottom:none; }
.chapter-row:hover { background:var(--surface); }
.chapter-n { font-family:'Spectral',serif; font-weight:600; font-size:14px; color:var(--ink-muted); width:22px; flex:0 0 22px; }
.chapter-title { flex:1; font-size:14.5px; font-weight:500; }
.chapter-lock { display:flex; align-items:center; gap:5px; background:var(--gold-tint); color:var(--gold); font-size:12.5px; font-weight:700; padding:5px 10px; border-radius:999px; }
.chapter-check { color:var(--accent); font-size:16px; }
.author-card { margin-top:32px; padding:18px; border-radius:12px; background:var(--surface); display:flex; align-items:center; gap:14px; }
.author-card .ini { width:48px; height:48px; border-radius:999px; background:var(--secondary); color:#fff; display:flex; align-items:center; justify-content:center; font-weight:700; flex:0 0 auto; overflow:hidden; }
.author-card .ini img { width:100%; height:100%; object-fit:cover; }

/* ---- Reader ---- */
.reader-root { --r-fs:19px; --r-cw:34ch; min-height:100vh; background:var(--bg); color:var(--ink); transition:background .15s, color .15s; }
/* Thème de lecture indépendant du thème du site (clair / sombre / sépia) */
.reader-root[data-rtheme="light"] { --bg:#FBF6EF; --surface:#F3ECE0; --ink:#241D17; --ink-muted:#6B5F52; --border:#E4D9C8; --accent:#fc6c38; }
.reader-root[data-rtheme="dark"]  { --bg:#171310; --surface:#1E1913; --ink:#F1E9DC; --ink-muted:#A99C8B; --border:#362E24; --accent:#ff8452; }
.reader-root[data-rtheme="sepia"] { --bg:#F1E5CB; --surface:#E9DBBB; --ink:#3B2E1E; --ink-muted:#7A6647; --border:#DCC99C; --accent:#A6461F; }
.reader-header { position:sticky; top:0; z-index:20; display:flex; align-items:center; gap:12px; padding:12px 16px; background:var(--bg); border-bottom:1px solid var(--border); }
.reader-header .htitle { flex:1; min-width:0; }
.reader-header .htitle .t { font-size:13px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.reader-header .htitle .s { font-size:11.5px; color:var(--ink-muted); }
.reader-settings { position:sticky; top:61px; z-index:19; background:var(--surface); border-bottom:1px solid var(--border); padding:16px; display:flex; flex-direction:column; gap:16px; }
.reader-settings.hidden { display:none; }
.rs-label { font-size:12px; font-weight:600; color:var(--ink-muted); margin-bottom:8px; text-transform:uppercase; letter-spacing:.04em; }
.swatch-row { display:flex; gap:10px; }
.swatch { flex:1; display:flex; flex-direction:column; align-items:center; gap:6px; padding:10px 8px; border-radius:10px; border:1px solid var(--border); cursor:pointer; font-size:12px; font-weight:600; }
.swatch.active { border:2px solid var(--accent); }
.rs-controls { display:flex; gap:24px; flex-wrap:wrap; }
.rs-group { flex:1; min-width:140px; }
.rs-stepper { display:flex; align-items:center; gap:12px; }
.ctrl-btn { width:34px; height:34px; border-radius:8px; border:1px solid var(--border); background:var(--bg); color:var(--ink); font-size:16px; cursor:pointer; display:flex; align-items:center; justify-content:center; }
.rs-val { font-size:13px; color:var(--ink-muted); min-width:40px; text-align:center; }
.reader-main { max-width:var(--r-cw); margin:0 auto; padding:40px 20px 120px; font-family:'Spectral',serif; font-size:var(--r-fs); line-height:1.75; letter-spacing:.1px; }
.reader-main .chap-kicker { font-size:12.5px; font-family:'Work Sans',sans-serif; color:var(--ink-muted); text-transform:uppercase; letter-spacing:.08em; margin-bottom:6px; }
.reader-main h1 { font-weight:700; font-size:1.7em; margin:0 0 28px; line-height:1.25; }
.reader-main p { margin:0 0 1.3em; text-wrap:pretty; }
/* Le contenu des chapitres arrive avec des styles inline (font-family/font-size
   du type "Times New Roman; medium") qui empêchent les réglages de lecture
   d'agir. On force l'héritage pour que la taille (--r-fs) et la police Spectral
   s'appliquent partout. Le gras/italique restent préservés. */
.reader-main p, .reader-main span, .reader-main div,
.reader-main li, .reader-main td, .reader-main blockquote {
    font-size:inherit !important;
    font-family:inherit !important;
}
.reader-footer { position:sticky; bottom:0; background:var(--bg); border-top:1px solid var(--border); padding:14px 16px max(14px, env(safe-area-inset-bottom)); display:flex; align-items:center; justify-content:space-between; gap:12px; }
.reader-footer .nav-btn { font-weight:600; font-size:13.5px; padding:11px 16px; border-radius:8px; display:flex; align-items:center; gap:6px; text-decoration:none; }
.reader-footer .prev { background:transparent; border:1px solid var(--border); color:var(--ink); }
.reader-footer .next { background:var(--accent); border:none; color:#fff; }
.reader-footer .disabled { opacity:.4; pointer-events:none; }
.reader-progress { flex:1; height:5px; background:var(--border); border-radius:999px; overflow:hidden; max-width:200px; }
.reader-progress > div { height:100%; background:var(--accent); }

/* Chapitre fourni en PDF. La colonne de lecture (--r-cw, calibrée pour du texte)
   est trop étroite pour une page A4 : on l'élargit. Le !important répond à la
   règle d'héritage ci-dessus, qui forcerait sinon Spectral 19px sur ces blocs. */
.reader-main.has-pdf { max-width:min(1100px, 96vw); }
.pdf-chapter { margin:0 0 28px; }
.pdf-chapter, .pdf-chapter div, .pdf-chapter span {
    font-family:'Work Sans',sans-serif !important;
    font-size:14px !important;
    line-height:1.5;
}
.pdf-chapter .pdf-bar { display:flex; align-items:center; gap:12px; flex-wrap:wrap; margin-bottom:12px; }
.pdf-chapter .pdf-note { color:var(--ink-muted); font-size:12.5px !important; }
.pdf-chapter .pdf-frame {
    display:block; width:100%; height:78vh; min-height:420px;
    border:1px solid var(--border); border-radius:12px; background:var(--surface);
}
@media (max-width:640px) {
    .pdf-chapter .pdf-frame { height:62vh; min-height:320px; }
}

/* Pied de page minimaliste : styles dans appnav.css (commun à tout le site). */
