/* ==========================================================================
   PAPETERIE SÉNÉGAL — BASE
   Éléments HTML, typographie, accessibilité, utilitaires de mise en page.
   ========================================================================== */

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

html {
    scroll-behavior: smooth;
    /* Décale les ancres sous l'en-tête collant */
    scroll-padding-top: var(--header-offset);
    -webkit-text-size-adjust: 100%;
    /* `clip` (et non `hidden`) : coupe tout débordement horizontal — dont les
       panneaux coulissants Bootstrap parqués hors écran — SANS créer de
       conteneur de défilement, ce qui préserve `position: sticky`.
       `overflow-x: hidden` sur body reste le repli des navigateurs anciens. */
    overflow-x: clip;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: var(--fs-body);
    line-height: var(--lh-body);
    color: var(--text);
    background-color: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Garde-fou anti-débordement horizontal, tous écrans confondus. */
    overflow-x: hidden;
}

/* ── TYPOGRAPHIE ──────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6, .display-font, .brand-text {
    font-family: var(--font-display);
    color: var(--text);
    font-weight: var(--fw-bold);
    line-height: var(--lh-tight);
    letter-spacing: -0.02em;
    margin: 0 0 var(--sp-3);
    text-wrap: balance;
}

h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); font-weight: var(--fw-semi); }
h4, h5, h6 { font-size: 1rem; font-weight: var(--fw-semi); letter-spacing: -0.01em; }

p { margin: 0 0 var(--sp-4); }
p:last-child { margin-bottom: 0; }

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--t-fast) var(--ease);
}
a:hover { color: var(--primary-dark); }

strong, b { font-weight: var(--fw-semi); }
small { font-size: var(--fs-xs); }

img, svg, video { max-width: 100%; height: auto; }

hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: var(--sp-6) 0;
    opacity: 1;
}

::selection { background: var(--primary-100); color: var(--primary-900); }

/* ── ACCESSIBILITÉ ────────────────────────────────────────────────────── */

/* Lien d'évitement : premier élément focusable de la page. */
.skip-link {
    position: absolute;
    left: var(--sp-4);
    top: -100px;
    z-index: 2000;
    padding: var(--sp-3) var(--sp-5);
    background: var(--primary);
    color: #fff;
    font-weight: var(--fw-semi);
    border-radius: 0 0 var(--r-sm) var(--r-sm);
    transition: top var(--t-base) var(--ease);
}
.skip-link:focus { top: 0; color: #fff; }

/* Focus visible unifié : jamais supprimé, toujours lisible. */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--r-xs);
}
/* Les contrôles à fond coloré utilisent l'anneau plutôt que le contour. */
.btn-ue:focus-visible,
.pcard__cart:focus-visible,
.qty__btn:focus-visible {
    outline: none;
    box-shadow: var(--ring);
}

.visually-hidden-focusable:not(:focus):not(:focus-within) {
    position: absolute !important;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

/* Cible tactile : tout contrôle interactif fait au moins 44 px sur mobile. */
@media (hover: none) and (pointer: coarse) {
    .btn-ue, .qty__btn, .icon-btn, .pcard__cart,
    button:not(.btn-close), [role="button"] {
        min-height: 44px;
    }
}

/* ── MOUVEMENT RÉDUIT ─────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    /* Neutralise aussi les déplacements au survol. */
    *:hover { transform: none !important; }
}

/* ── STRUCTURE ────────────────────────────────────────────────────────────
   Conteneur fluide jusqu'à --container : on ne remplace que la largeur max
   des paliers Bootstrap, la gouttière reste celle de la grille pour que
   `.row` et `.container` restent alignés au pixel. */
.container, .container-fluid {
    width: 100%;
    max-width: var(--container);
    margin-inline: auto;
}
@media (min-width: 768px) {
    :root { --bs-gutter-x: 2rem; }
}

/* Rythme vertical des sections de page */
.section { padding-block: var(--section-y); }
.section--tight { padding-block: clamp(1.75rem, 1rem + 2.5vw, 3rem); }
.section--alt { background: var(--surface); }

/* En-tête de section : sur-titre, titre, lien d'action aligné à droite */
.section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--sp-4);
    flex-wrap: wrap;
    margin-bottom: var(--sp-6);
}
.section-head__text { max-width: 62ch; }
.section-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--fs-label);
    font-weight: var(--fw-bold);
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--primary);
    margin-bottom: var(--sp-2);
}
.section-title { margin-bottom: var(--sp-2); }
.section-sub {
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    margin: 0;
}
.section-link {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    font-weight: var(--fw-semi);
    font-size: var(--fs-sm);
    white-space: nowrap;
    flex-shrink: 0;
}
.section-link i { transition: transform var(--t-base) var(--ease); }
.section-link:hover i { transform: translateX(3px); }

/* ── UTILITAIRES MAISON ───────────────────────────────────────────────── */
.text-muted-ue { color: var(--text-muted); }
.text-secondary-ue { color: var(--text-secondary); }
.fs-sm-ue { font-size: var(--fs-sm); }
.fs-xs-ue { font-size: var(--fs-xs); }

/* Troncature multi-lignes */
.clamp-1, .clamp-2, .clamp-3 {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.clamp-1 { -webkit-line-clamp: 1; line-clamp: 1; }
.clamp-2 { -webkit-line-clamp: 2; line-clamp: 2; }
.clamp-3 { -webkit-line-clamp: 3; line-clamp: 3; }

/* Apparition douce à l'arrivée dans le viewport (piloté par app.js). */
.reveal {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity var(--t-slow) var(--ease), transform var(--t-slow) var(--ease);
}
.reveal.is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
    .reveal { opacity: 1; transform: none; }
}
