/* ============================================================
   CUMDECI UI — Typographie, Components, Accessibilité, Récits
   VERSION FINALE — UTILISE UNIQUEMENT LES TOKENS --cd-*
============================================================ */

/* ------------------------------------------------------------
   POLICE (pilotée par data-font sur <html>)
------------------------------------------------------------ */
html[data-font="system"]      { font-family: system-ui, sans-serif; }
html[data-font="inter"]       { font-family: "Inter", sans-serif; }
html[data-font="roboto"]      { font-family: "Roboto", sans-serif; }
html[data-font="open-sans"]   { font-family: "Open Sans", sans-serif; }
html[data-font="merriweather"]{ font-family: "Merriweather", serif; }
html[data-font="source-serif-4"] { font-family: "Source Serif 4", serif; }
html[data-font="fira-code"]   { font-family: "Fira Code", monospace; }

/* ------------------------------------------------------------
   TAILLE DU TEXTE
------------------------------------------------------------ */
html {
    font-size: var(--fs, 100%);
}

/* ------------------------------------------------------------
   INTERLIGNAGE
------------------------------------------------------------ */
html {
    line-height: var(--line-height-factor, 1.4);
}

/* ------------------------------------------------------------
   ACCESSIBILITÉ (UI VISUELLE)
------------------------------------------------------------ */

/* Dyslexie : léger espacement lettres / mots */
body[data-dyslexia="1"] {
    letter-spacing: .04em;
    word-spacing: .08em;
}

/* Boutons agrandis */
body[data-bigbuttons="1"] button {
    padding: 14px 20px !important;
    font-size: 1.1rem !important;
}

/* Daltonisme : désaturation + contraste */
body[data-daltonism="1"] #ZC {
    filter: saturate(0) contrast(1.15) brightness(1.03);
}
body[data-daltonism="1"] a {
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Curseur agrandi */
body[data-cursor="1"],
body[data-cursor="1"] * {
    cursor:
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 64 64'%3E%3Cpath d='M6 6 L22 42 L30 34 L42 60 L50 56 L38 30 L46 26 Z' fill='rgba(0,0,0,0.25)'/%3E%3Cpath d='M4 4 L20 40 L28 32 L40 58 L48 54 L36 28 L44 24 Z' fill='%23ffffff' stroke='%23111' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E")
      0 0, auto !important;
}

h1, h2, h3 {
  text-align: start; /* ne pas avoir des titres justifiés */
  text-justify: auto;
}

/* ------------------------------------------------------------
   COMPOSANTS UI
------------------------------------------------------------ */
#ZH .header-title {
    font-size: 28px;
    font-weight: bold;
    white-space: nowrap;
}

/* Empêche un lien autour du logo de modifier son apparence */
#ZH .header-title a,
a.header-title {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

/* Style par défaut (fallback si aucun thème) */
a.cd-link {
  text-decoration: none;
  cursor: pointer;
  transition: color .20s, border-color .20s, background .20s;
}

/* Lettrine d’introduction des récits */
.cd-recit-intro {
    font-size: 1.15em;
    line-height: 1.65;
    text-align: justify;
}

.cd-recit-intro::first-letter {
    float: left;
    font-size: 3.2em;
    font-weight: 600;
    line-height: 0.9;
    padding-right: 0.15em;
    padding-top: 0.05em;
    color: var(--cd-text); /* remplacé ! */
}

/* Icônes (ex : settings) */
.cd-settings-icon {
    cursor: pointer;
}

/* ============================================================
   Récit (titre, sous-titre, auteur)
============================================================ */

.recit-entete {
    margin-bottom: 0px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.recit-entete .publication-info {
    font-size: 0.9rem;
    opacity: .7;
    margin-bottom: 5px;
}

.recit-entete .title {
    font-size: 2.6rem;
    margin: 5px 0 10px 0;
    font-weight: 700;
}

.recit-entete .subtitle {
    font-size: 1.4rem;
    margin: 0 0 10px 0;
    opacity: .85;
}

.recit-entete .author {
    font-style: normal;
    font-size: 1rem;
    opacity: .8;
    margin-top: 5px;
}

.secondary-image {
    margin: 30px 0;
    column-span: all; /* pour les layouts en colonnes */
}

.secondary-image img {
    width: 100%;
    height: auto;
    display: block;
}

.secondary-caption {
    font-family: "Montserrat", Arial, sans-serif;
    font-size: 0.8rem;
    color: #666;
    padding: 10px 0;
}



/* ============================================================
   BOUTONS — adaptation automatique au thème (clair/sombre/auto)
============================================================ */

.font-btn {
    background: var(--cd-btn-bg);
    color: var(--cd-btn-fg);
    border: 1px solid var(--cd-btn-border);
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: background .2s, color .2s, border-color .2s;
}

.font-btn:hover {
    background: var(--cd-btn-bg-hover);
    border-color: var(--cd-btn-border);
}

.font-btn.btn--ghost {
    background: transparent;
    color: var(--cd-link);
    border: 1px solid var(--cd-border);
}

.font-btn.btn--danger {
    background: #c0392b;
    color: white;
    border: 1px solid #922b21;
}

/* ============================================================
   ZS — Uniformisation ABSOLUE des boutons (<button> et <a>)
============================================================ */

/* Reset complet pour que <button> et <a> soient IDENTIQUES */
#ZS .font-btn,
#ZS a.font-btn,
#ZS button.font-btn {
    all: unset;                 /* supprime 100% des styles natifs */
    display: flex;
    align-items: center;
    justify-content: center;

    background: var(--cd-btn-bg);
    color: var(--cd-btn-fg);
    border: 1px solid var(--cd-btn-border);

    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;

    width: 100%;
    box-sizing: border-box;
    text-decoration: none;

    transition: background .2s, border-color .2s, color .2s;
}

/* Hover */
#ZS .font-btn:hover {
    background: var(--cd-btn-bg-hover);
}

/* Icônes normalisées */
#ZS .font-btn img {
    width: 22px;
    height: 22px;
    pointer-events: none;
    display: block;
}

/* Variante danger */
#ZS .font-btn.btn--danger {
    background: #c0392b;
    border-color: #922b21;
    color: white;
}
#ZS .font-btn.btn--danger:hover {
    background: #a93226;
}

/* ZS — Espacement vertical entre chaque bouton */
#ZS .font-btn {
    margin-bottom: 10px !important;
}

/* Retire le dernier espace pour un rendu propre */
#ZS .font-btn:last-child {
    margin-bottom: 0 !important;
}

/* ===============================================================
   HAMBURGER — Version animée + état actif (X)
   MAIS UNIQUEMENT EN MOBILE
============================================================== */

#ZH .hamburger {
    width: 24px;
    height: 18px;
    display: none; /* caché par défaut */
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
}

#ZH .hamburger span {
    display: block;
    height: 2px;
    width: 100%;
    background: var(--cd-text);
    border-radius: 2px;
    transition: transform .25s ease, opacity .25s ease;
}

#ZH .menu-item {
    padding: 6px 12px;
    border-radius: 10px;

    background: var(--cd-btn-bg);
    border: 1px solid var(--cd-btn-border);

    transition: background .2s;
}

/* texte */
#ZH .menu-item a {
    color: var(--cd-btn-fg);
    text-decoration: none;
    font-weight: 600;
}

/* hover sur le bloc */
#ZH .menu-item:hover {
    background: var(--cd-btn-bg-hover);
}


/* === MOBILE SEULEMENT === */
@media (max-width: 760px) {

    /* Affiche le hamburger */
    #ZH .hamburger {display: flex !important; }

    /* État actif = menu ouvert */
    #Layout:has(#ZMH.open) #ZH .hamburger span:nth-child(1) {transform: translateY(8px) rotate(45deg); }
    #Layout:has(#ZMH.open) #ZH .hamburger span:nth-child(2) {opacity: 0; }
    #Layout:has(#ZMH.open) #ZH .hamburger span:nth-child(3) {transform: translateY(-8px) rotate(-45deg); }
}

#ZC .content p {
    margin-bottom: 20px;
    text-align: justify;
    line-height: calc(1.4 * var(--line-height-factor, 1));
    font-family: var(--font-family);
    font-size: 1rem;
    color: var(--text);
}

/* ============================================================
   ZF — Ligne de signets simple
   - 1 ligne
   - sans wrap
   - sans scroll-bar
   - sans centrage
   - affichage conditionnel des flèches
============================================================ */

#ZF {
    white-space: nowrap;
    overflow: hidden;
}

/* Conteneur interne placé APRÈS le texte "Signet" */
#ZF .zf-nav {
    display: inline-flex;      /* Place les signets juste après "Signet" */
    align-items: center;
    gap: 8px;

    white-space: nowrap;       /* Jamais de retour ligne */
    overflow: hidden;          /* Jamais de scroll */
    vertical-align: middle;
}

/* Boutons signets */
#ZF .zf-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 4px 12px;
    border-radius: 6px;

    background: var(--cd-btn-bg);
    color: var(--cd-btn-fg);
    border: 1px solid var(--cd-btn-border);

    white-space: nowrap;
    cursor: pointer;
    flex-shrink: 0;
    user-select: none;
}

#ZF.compact .zf-current-btn {
    display: inline-flex;
    padding: 4px 12px;
    border-radius: 6px;
    background: var(--cd-btn-bg);
    color: var(--cd-btn-fg);
    border: 1px solid var(--cd-btn-border);
    cursor: pointer;
}

/* ========== ZF — ligne "Signet" + navigation signets ========== */

#ZF .zf-nav {
    display: inline-flex;      /* À la suite de "Signet" */
    align-items: center;
    gap: 8px;

    white-space: nowrap;       /* Une seule ligne */
    overflow: hidden;          /* Jamais de scrollbar */
    vertical-align: middle;
}

/* ============================================================
   ZF — Navigation FULL ou COMPACT
   NE MODIFIE PAS #ZF
============================================================ */

/* Le conteneur interne après le texte "Signet" */
#ZF .zf-nav {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    vertical-align: middle;

    white-space: nowrap;   /* une seule ligne */
    overflow: hidden;      /* jamais de scroll */
}

/* -- Boutons FULL (signets) -- */
#ZF .zf-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 4px 12px;
    border-radius: 6px;
    border: 1px solid var(--cd-btn-border);
    background: var(--cd-btn-bg);
    color: var(--cd-btn-fg);
    white-space: nowrap;
    flex-shrink: 0;
    cursor: pointer;
}

/* Conteneur des signets */
#ZF .zf-nav {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    overflow: hidden;
    vertical-align: middle;
}

/* Boutons signets */
#ZF .zf-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid var(--cd-btn-border);
    background: var(--cd-btn-bg);
    color: var(--cd-btn-fg);
    flex-shrink: 0;
    cursor: pointer;
    white-space: nowrap;
}

/* Boutons compact */
#ZF .zf-prev,
#ZF .zf-next,
#ZF .zf-current {
    display: none;
}

/* Mode full : tous les signets visibles */
#ZF.full .zf-btn {
    display: inline-flex !important;
}
#ZF.full .zf-prev,
#ZF.full .zf-next,
#ZF.full .zf-current {
    display: none !important;
}

/* Mode compact : afficher ‹ courant › */
#ZF.compact .zf-btn {
    display: none !important;
}
#ZF.compact .zf-prev,
#ZF.compact .zf-next,
#ZF.compact .zf-current {
    display: inline-flex !important;
}

#ZF .zf-prefix a {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 10px;
    font-size: 0.95rem;
    cursor: pointer;
    white-space: nowrap;

    background: var(--cd-btn-bg);
    color: var(--cd-text);
    border: 1px solid var(--cd-btn-border);
    transition: background .20s, color .20s, border-color .20s;
}

#ZF .zf-prefix a:hover {
    background: var(--cd-btn-bg-hover);
}

/* Si boutons agrandis → ZF suit la hauteur de ZH */
body[data-bigbuttons="1"] #ZF {
    height: var(--ZH-height);
    display: flex;
    align-items: center; /* vertical align parfait */
}

/* Les boutons du ZF, en mode bigButtons, occupent la hauteur */
body[data-bigbuttons="1"] #ZF button {
    height: calc(var(--ZH-height) - 6px); /* ajustement fin */
    display: inline-flex;
    align-items: center;
}

/* ============================================================
   FIX CUMDECI CHECKBOX (layout + affichage)
   Patch minimal, sans régression
============================================================ */

/* Conteneur Cumdeci pour checkbox */
.cd-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 6px 0;
    cursor: pointer;
}

/* On masque l'input natif SANS casser la mise en page */
.cd-checkbox > input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

/* Boîte visible */
.cd-checkbox > .cb-box {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 2px solid var(--cd-border);
    background: var(--cd-bg);
    flex-shrink: 0;
}

/* ACTIVE */
.cd-checkbox > input[type="checkbox"]:checked ~ .cb-box {
    background: var(--cd-btn-bg-hover);
    border-color: var(--cd-btn-border);
}

/* Label */
.cd-checkbox > .cb-label {
    font-size: 1rem;
    line-height: 1.3;
}


/* ZF — normalisation locale des boutons (copie ZS) */
#ZF .font-btn,
#ZF a.font-btn,
#ZF button.font-btn {
  all: unset;
  display: inline-flex;
  align-items: center;
  justify-content: center;

  background: var(--cd-btn-bg);
  color: var(--cd-btn-fg);
  border: 1px solid var(--cd-btn-border);
  padding: 3px 8px;
  border-radius: 6px;

  cursor: pointer;
  white-space: nowrap;
  box-sizing: border-box;

  line-height: 1;          /* ✅ IMPORTANT */
  font: inherit;           /* ✅ rétablit font-size + family */
}


#ZF {
  height: auto;
  min-height: var(--ZF-height);
}

#ZF {
  display: flex;
  align-items: center;
  gap: 6px;
}

