/**
 * Frontend CSS du bloc "BTP - Galerie de produits".
 * Chargee uniquement quand le bloc est present sur la page (via block.json).
 */

.btp-products {
    --btp-products-accent: var(--btp-accent-dark, #1c1917);
    --btp-products-radius: 14px;
    --btp-products-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
    --btp-products-shadow-hover: 0 12px 28px -8px rgba(15, 23, 42, 0.18);
    --btp-products-card-bg: #ffffff;
    --btp-products-border: rgba(15, 23, 42, 0.08);
    --btp-products-text: #0f172a;
    --btp-products-text-muted: #64748b;
    margin: 2.5em 0;
}

.btp-products .btp-products__title,
.btp-products__title.btp-products__title {
    font-size: clamp(1.4rem, 2.5vw, 1.85rem);
    font-weight: 700;
    margin: 0 0 1.2em;
    color: var(--btp-products-text);
    font-family: inherit;
    letter-spacing: -0.01em;
}
.btp-products__title--align-center { text-align: center; }
.btp-products__title--align-right  { text-align: right; }

.btp-products__list {
    display: grid;
    gap: 24px;
}

/* ============================================================
   Card produit (base, partagee par les 3 layouts)
   ============================================================ */
.btp-product-card {
    background: var(--btp-products-card-bg);
    border: 1px solid var(--btp-products-border);
    border-radius: var(--btp-products-radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
    box-shadow: var(--btp-products-shadow);
    position: relative;
}
.btp-product-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--btp-products-shadow-hover);
    border-color: rgba(15, 23, 42, 0.14);
}

.btp-product-card__media {
    display: block;
    position: relative;
    aspect-ratio: var(--btp-products-img-ratio, 1 / 1);
    overflow: hidden;
    background: #f8fafc;
    padding: var(--btp-products-img-padding, 0);
    box-sizing: border-box;
}
.btp-product-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
    display: block;
}
.btp-product-card:hover .btp-product-card__media img {
    transform: scale(1.04);
}

.btp-product-card__badge {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.2;
    text-transform: uppercase;
    background: var(--btp-products-accent);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}
.btp-product-card__badge--out {
    background: #475569;
}

.btp-product-card__body {
    padding: 18px 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.btp-products .btp-product-card__title {
    font-size: var(--btp-products-title-size, 15px);
    font-weight: 600;
    line-height: 1.35;
    margin: 0;
    color: var(--btp-products-title-color, var(--btp-products-text));
    font-family: inherit;
    /* Limite a 2 lignes avec ellipsis pour eviter les coupures bizarres */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-wrap: balance;
    word-break: normal;
    overflow-wrap: break-word;
    hyphens: manual;
}
.btp-product-card__title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.15s;
}
.btp-product-card__title a:hover {
    color: var(--btp-products-accent);
}

.btp-product-card__price {
    font-size: var(--btp-products-price-size, 16px);
    font-weight: 700;
    color: var(--btp-products-price-color, var(--btp-products-text));
    line-height: 1.2;
    margin-top: auto;
}
.btp-product-card__price del {
    color: var(--btp-products-text-muted);
    font-weight: 500;
    font-size: 13px;
    margin-right: 6px;
}
.btp-product-card__price ins {
    text-decoration: none;
    color: var(--btp-products-accent);
}
.btp-product-card__price .woocommerce-Price-currencySymbol { font-weight: inherit; }

.btp-product-card__cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 18px;
    background: var(--btp-products-btn-bg, var(--btp-products-text));
    color: var(--btp-products-btn-color, #ffffff) !important;
    border-radius: 999px;
    font-size: var(--btp-products-btn-size, 13px);
    font-weight: 600;
    text-decoration: none;
    transition: background 0.15s, transform 0.1s;
    font-family: inherit;
    letter-spacing: 0.01em;
}
.btp-product-card__cta:hover {
    background: var(--btp-products-accent);
    color: #ffffff !important;
}
.btp-product-card__cta:active {
    transform: scale(0.98);
}

/* ============================================================
   Layout : Grille (2/3/4 colonnes)
   ============================================================ */
.btp-products--grid .btp-products__list {
    grid-template-columns: repeat(var(--btp-products-cols, 3), minmax(0, 1fr));
}
.btp-products--cols-2 .btp-products__list { --btp-products-cols: 2; }
.btp-products--cols-3 .btp-products__list { --btp-products-cols: 3; }
.btp-products--cols-4 .btp-products__list { --btp-products-cols: 4; }

@media (max-width: 900px) {
    .btp-products--grid .btp-products__list { --btp-products-cols: 2 !important; }
}
@media (max-width: 560px) {
    .btp-products--grid .btp-products__list { --btp-products-cols: 1 !important; }
}

/* ============================================================
   Layout : Liste (1 produit par ligne, image gauche)
   ============================================================ */
.btp-products--list .btp-products__list {
    grid-template-columns: 1fr;
    gap: 18px;
}
.btp-products--list .btp-product-card {
    flex-direction: row;
}
.btp-products--list .btp-product-card__media {
    flex: 0 0 220px;
    aspect-ratio: 1 / 1;
    max-width: 220px;
}
.btp-products--list .btp-product-card__body {
    padding: 22px 26px;
    justify-content: center;
    gap: 12px;
}
.btp-products--list .btp-product-card__title {
    font-size: var(--btp-products-title-size, 18px);
    -webkit-line-clamp: 3;
}
.btp-products--list .btp-product-card__price {
    font-size: 18px;
    margin-top: 0;
}
.btp-products--list .btp-product-card__cta {
    align-self: flex-start;
}

@media (max-width: 600px) {
    .btp-products--list .btp-product-card { flex-direction: column; }
    .btp-products--list .btp-product-card__media { flex: none; max-width: none; width: 100%; aspect-ratio: 4 / 3; }
    .btp-products--list .btp-product-card__body { padding: 16px 18px 18px; }
}

/* ============================================================
   Layout : Hero (1 grand a gauche, autres en colonne a droite)
   ============================================================ */
.btp-products--hero .btp-products__list {
    grid-template-columns: 1.4fr 1fr;
    grid-auto-rows: minmax(0, 1fr);
    gap: 20px;
}
.btp-products--hero .btp-product-card--hero {
    grid-row: 1 / span 10;
}
.btp-products--hero .btp-product-card--hero .btp-product-card__media {
    aspect-ratio: 4 / 5;
}
.btp-products--hero .btp-product-card--hero .btp-product-card__body {
    padding: 24px 26px 26px;
}
.btp-products--hero .btp-product-card--hero .btp-product-card__title {
    font-size: var(--btp-products-title-size, 20px);
    -webkit-line-clamp: 3;
}
.btp-products--hero .btp-product-card--hero .btp-product-card__price {
    font-size: 18px;
}
.btp-products--hero .btp-product-card:not(.btp-product-card--hero) {
    flex-direction: row;
}
.btp-products--hero .btp-product-card:not(.btp-product-card--hero) .btp-product-card__media {
    flex: 0 0 140px;
    max-width: 140px;
    aspect-ratio: 1 / 1;
}
.btp-products--hero .btp-product-card:not(.btp-product-card--hero) .btp-product-card__body {
    padding: 14px 16px;
}
.btp-products--hero .btp-product-card:not(.btp-product-card--hero) .btp-product-card__title {
    font-size: var(--btp-products-title-size, 14px);
    -webkit-line-clamp: 2;
}
.btp-products--hero .btp-product-card:not(.btp-product-card--hero) .btp-product-card__price {
    font-size: 14px;
}

@media (max-width: 900px) {
    .btp-products--hero .btp-products__list { grid-template-columns: 1fr; }
    .btp-products--hero .btp-product-card--hero { grid-row: auto; }
    .btp-products--hero .btp-product-card:not(.btp-product-card--hero) { flex-direction: row; }
}
@media (max-width: 560px) {
    .btp-products--hero .btp-product-card:not(.btp-product-card--hero) { flex-direction: column; }
    .btp-products--hero .btp-product-card:not(.btp-product-card--hero) .btp-product-card__media { flex: none; max-width: none; width: 100%; aspect-ratio: 4 / 3; }
}

/* ============================================================
   Cas special : un seul produit dans le bloc
   Force le layout vertical (image top, contenu stacked), sinon
   en mode list/hero la card ecrase le texte dans une colonne etroite.
   ============================================================ */
.btp-products--single .btp-products__list {
    grid-template-columns: 1fr !important;
    display: grid !important;
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
}
.btp-products--single .btp-product-card,
.btp-products--single .btp-product-card--hero {
    flex-direction: column !important;
    grid-row: auto !important;
}
.btp-products--single .btp-product-card__media {
    flex: none !important;
    max-width: none !important;
    width: 100% !important;
    aspect-ratio: var(--btp-products-img-ratio, 4 / 3) !important;
}
.btp-products--single .btp-product-card__body {
    padding: 18px 20px 20px !important;
    text-align: left;
}
.btp-products--single .btp-product-card__cta {
    align-self: stretch !important;
    text-align: center;
}
