/* ==========================================================================
   Page d'accueil — colonne « Produits populaires » + rangées produits
   Refonte du 27/09/2026, inspirée de pixartprinting.fr
   (sauvegarde : homeController.css.bak-20260927)
   Markup : app/Views/home/index.php + app/Components/Slider.php
   Script : /assets/js/home-carousels.js
   ========================================================================== */

.hp-home {
    --hp-accent: #511298;          /* violet Uprinter (usp-bar, hero-slider) */
    --hp-accent-soft: #f3f1f7;
    --hp-ink: #1a1a1a;
    --hp-muted: #6b6b76;
    --hp-line: #e6e2ec;
    --hp-surface: #f6f5f8;
    --hp-promo: #d6264a;
    --hp-radius: 12px;
    --hp-gap: 16px;
}

/* ---------------- Colonne latérale ---------------- */

.hp-side {
    position: sticky;
    top: 16px;
    background: #fff;
    border: 1px solid var(--hp-line);
    border-radius: var(--hp-radius);
    padding: 8px 0 12px;
    z-index: 5;   /* sticky crée un contexte d'empilement : sans ça le volet passe sous les cartes */
}

.hp-side__title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--hp-ink);
    margin: 0;
    padding: 12px 20px 10px;
}

.hp-side__list {
    list-style: none;
    margin: 0;
    padding: 0 8px;
}

.hp-side__list--links {
    border-top: 1px solid var(--hp-line);
    margin-top: 8px;
    padding-top: 8px;
}

.hp-side__item { position: relative; }

.hp-side__link {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--hp-ink);
    font: inherit;
    font-size: .95rem;
    text-align: left;
    text-decoration: none;
    transition: background-color .15s, color .15s;
}

.hp-side__link:hover,
.hp-side__link:focus-visible,
.hp-side__item:hover > .hp-side__link,
.hp-side__link[aria-expanded="true"] {
    background: var(--hp-accent-soft);
    color: var(--hp-accent);
}

.hp-side__link:focus-visible { outline: 2px solid var(--hp-accent); outline-offset: -2px; }

.hp-side__icon { font-size: 1.1rem; color: var(--hp-accent); flex: none; }
.hp-side__link span { flex: 1; }
.hp-side__chev { font-size: .8rem; color: var(--hp-muted); transition: transform .15s; }

/* Sous-menu : volet à droite sur desktop (survol ou clic), accordéon sur mobile */
.hp-side__sub {
    display: none;
    list-style: none;
    margin: 0;
    padding: 8px;
    background: #fff;
}

.hp-side__subtitle {
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--hp-muted);
    padding: 6px 12px 8px;
}

.hp-side__sub a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--hp-ink);
    font-size: .92rem;
    text-decoration: none;
}

.hp-side__sub a i { color: var(--hp-muted); }
.hp-side__sub a:hover,
.hp-side__sub a:focus-visible { background: var(--hp-accent-soft); color: var(--hp-accent); }
.hp-side__sub a:hover i { color: var(--hp-accent); }

@media (min-width: 768px) {
    .hp-side__sub {
        position: absolute;
        top: -8px;
        left: calc(100% + 8px);
        min-width: 280px;
        border: 1px solid var(--hp-line);
        border-radius: var(--hp-radius);
        box-shadow: 0 12px 32px rgba(26, 26, 26, .12);
        z-index: 2000;
    }
    /* pont invisible entre le lien et le volet : le survol ne se perd pas dans l'écart */
    .hp-side__sub::before {
        content: "";
        position: absolute;
        top: 0; bottom: 0; left: -10px;
        width: 10px;
    }
    .hp-side__item:hover > .hp-side__sub,
    .hp-side__link[aria-expanded="true"] + .hp-side__sub {
        display: block;
        animation: hpFadeIn .15s ease-out;
    }
}

@media (max-width: 767.98px) {
    .hp-side { position: static; }
    .hp-side__subtitle { display: none; }
    .hp-side__sub { padding: 0 0 6px 36px; }
    .hp-side__link[aria-expanded="true"] + .hp-side__sub { display: block; }
    .hp-side__link[aria-expanded="true"] .hp-side__chev { transform: rotate(90deg); }
}

.hp-side__all {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 10px 16px 0;
    padding: 11px 14px;
    border-radius: 8px;
    background: var(--hp-accent);
    color: #fff;
    font-weight: 600;
    font-size: .92rem;
    text-decoration: none;
    transition: background-color .15s;
}

.hp-side__all:hover,
.hp-side__all:focus-visible { background: #3f0e78; color: #fff; }

@keyframes hpFadeIn {
    from { opacity: 0; transform: translateX(-6px); }
    to   { opacity: 1; transform: none; }
}

/* ---------------- Rangées produits ---------------- */

.hp-rows { min-width: 0; }            /* sinon la piste élargit la colonne flex */

.hp-row + .hp-row { margin-top: 40px; }

.hp-row__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.hp-row__title {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--hp-ink);
    margin: 0;
}

.hp-row__tools { display: flex; align-items: center; gap: 8px; }

.hp-row__more {
    margin-right: 8px;
    color: var(--hp-accent);
    font-weight: 600;
    font-size: .95rem;
    text-decoration: none;
}
.hp-row__more:hover { text-decoration: underline; }

.hp-row__arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--hp-line);
    border-radius: 50%;
    background: #fff;
    color: var(--hp-ink);
    transition: background-color .15s, border-color .15s, opacity .15s;
}
.hp-row__arrow:hover:not(:disabled) { border-color: var(--hp-accent); color: var(--hp-accent); }
.hp-row__arrow:disabled { opacity: .35; cursor: default; }
.hp-row__arrow:focus-visible { outline: 2px solid var(--hp-accent); outline-offset: 2px; }

/* Rangée entièrement visible : flèches inutiles (classe posée par le JS) */
.hp-row.is-static .hp-row__arrow { display: none; }

.hp-row__track {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: calc((100% - 3 * var(--hp-gap)) / 4);   /* 4 cartes visibles */
    gap: var(--hp-gap);
    list-style: none;
    margin: 0;
    padding: 4px 2px 12px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scrollbar-width: none;
}
.hp-row__track::-webkit-scrollbar { display: none; }
.hp-row__track:focus-visible { outline: 2px solid var(--hp-accent); outline-offset: 4px; border-radius: var(--hp-radius); }

.hp-row__item { scroll-snap-align: start; min-width: 0; }

/* ---------------- Carte produit ---------------- */

.hp-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    color: var(--hp-ink);
    text-decoration: none;
}

.hp-card__media {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: var(--hp-radius);
    background: var(--hp-surface);
    overflow: hidden;
}

.hp-card__media img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 8%;
    transition: transform .35s ease;
}

a.hp-card:hover .hp-card__media img,
a.hp-card:focus-visible .hp-card__media img { transform: scale(1.05); }

a.hp-card:focus-visible { outline: none; }
a.hp-card:focus-visible .hp-card__media { outline: 2px solid var(--hp-accent); outline-offset: 2px; }

.hp-card__badge {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--hp-accent);
    color: #fff;
    font-size: .75rem;
    font-weight: 700;
    line-height: 1.4;
}
.hp-card__badge--promo { background: var(--hp-promo); }

.hp-card__body { padding: 12px 2px 0; }

.hp-card__name {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

a.hp-card:hover .hp-card__name { color: var(--hp-accent); }

/* ---------------- Responsive ---------------- */

@media (max-width: 1199.98px) {
    .hp-row__track { grid-auto-columns: calc((100% - 2 * var(--hp-gap)) / 3); }
}

@media (max-width: 991.98px) {
    .hp-row__track { grid-auto-columns: calc((100% - var(--hp-gap)) / 2.2); }
    .hp-row__title { font-size: 1.35rem; }
}

@media (max-width: 575.98px) {
    /* la carte suivante dépasse : signale qu'on peut faire glisser */
    .hp-row__track { grid-auto-columns: 62%; }
    .hp-row__arrow { display: none; }
    .hp-row + .hp-row { margin-top: 28px; }
}

@media (prefers-reduced-motion: reduce) {
    .hp-row__track { scroll-behavior: auto; }
    .hp-card__media img, .hp-side__sub { transition: none; animation: none; }
}
