/* ─── Variables ───────────────────────────────────────── */
.tm-brands-container {
    --tm-gold:    #dcbe76;
    --tm-accent:  #633b24;
    --tm-radius:  14px;
    --tm-gap:     28px;
    --tm-logo-w:  120px;

    display: flex;
    flex-direction: column;
    gap: var(--tm-gap);
    width: 100%;
    font-family: inherit;  /* Police du thème WordPress */
}

/* ─── Logo nav strip ─────────────────────────────────────────────────── */
/* max-width = (6 × 72px) + (5 × 10px gap) + (2 × 18px padding) = 518px  */
/* garantit 6 items max par ligne ; justify-content:center centre la      */
/* dernière ligne incomplète automatiquement                               */
.tm-logo-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    padding: 0;
    width: 80%;
    margin-left: auto;
    margin-right: auto;
}

.tm-nav-item {
    display: block;
    width: calc((100% - 50px) / 6); /* 6 colonnes, 5 gaps × 10px → pleine largeur carte */
    aspect-ratio: 1 / 1;
    height: auto;
    border-radius: 10px;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(99, 59, 36, 0.14);
    background: #f5f0eb;
    flex-shrink: 0;
    color: inherit;
    text-decoration: none;
    transition:
        transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1),
        box-shadow 0.18s ease,
        border-color 0.15s;
}
.tm-nav-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(45, 31, 21, 0.14);
    border-color: rgba(220, 190, 118, 0.6);
    text-decoration: none;
}
.tm-nav-item:focus-visible {
    outline: 2px solid var(--tm-gold, #dcbe76);
    outline-offset: 2px;
}

.tm-nav-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    padding: 8px;
    box-sizing: border-box;
}

.tm-nav-rank {
    position: absolute;
    top: 3px;
    left: 4px;
    font-size: 8px;
    font-weight: 700;
    line-height: 1.4;
    background: #633b24;
    color: #F5E6D3;
    border-radius: 4px;
    padding: 1px 4px;
    z-index: 1;
    font-family: inherit;
}

.tm-nav-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    color: #968271;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    font-family: inherit;
}
/* ─── Fin logo nav strip ──────────────────────────────────────────────── */

/* ─── Reset marges thème (Kadence .entry-content h2/p → spécificité 0-1-1) */
.tm-brand h2,
.tm-brand p {
    margin: 0;
}

/* ─── Brand card ──────────────────────────────────────── */
.tm-brand {
    --tm-card-bg:   #f5f0eb;
    --tm-card-text: #2d1f15;

    background: var(--tm-card-bg);
    color: var(--tm-card-text);
    border: 1px solid rgba(99, 59, 36, 0.14);
    border-radius: var(--tm-radius);
    padding: 20px 18px;
    position: relative;
    box-shadow:
        0 2px 8px rgba(45, 31, 21, 0.08),
        0 8px 32px rgba(45, 31, 21, 0.05);
    transition: box-shadow 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.tm-brand:hover {
    box-shadow:
        0 4px 16px rgba(45, 31, 21, 0.12),
        0 16px 48px rgba(45, 31, 21, 0.08);
}

/* ─── Background image + overlay ─────────────────────────────────────── */
.tm-brand.tm-has-bg {
    overflow: hidden;
}

.tm-brand.tm-has-bg::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background:
        linear-gradient(var(--tm-overlay-color, rgba(0,0,0,0)), var(--tm-overlay-color, rgba(0,0,0,0))),
        var(--tm-bg-image) center / cover no-repeat;
    z-index: 0;
    pointer-events: none;
}

.tm-brand.tm-has-bg > * {
    position: relative;
    z-index: 1;
}

/* ─── Top row : rank (abs gauche) | nom (centré) | sponsored (abs droite) */
.tm-brand-top {
    position: relative;
    display: flex;
    align-items: top;
    justify-content: center;
    min-height: 36px;
    margin-bottom: 20px;
}

/* Rank et sponsored en absolu pour ne pas pousser le nom */
.tm-rank {
    position: absolute;
    left: 0;
    font-family: inherit;
    font-size: 50px;
    font-weight: 700;
    color: var(--tm-accent);
    letter-spacing: -0.02em;
    line-height: 1;
}

.tm-sponsored {
    position: absolute;
    right: 0;
    font-size: 14px;
    color: rgba(99, 59, 36, 0.60);
    font-style: italic;
    letter-spacing: 0.04em;
    line-height: 1;
}

/* ─── Brand name — style identique au titre "Nouveautés en construction" ── */
/*   Source : https://pro.hugo-bourgeois.fr/a-venir/                         */
/*   CSS Kadence original : uppercase, color #dcbe76, text-shadow 3px 4px 0  */
.tm-brand-name {
    font-family: inherit;
    font-size: clamp(4rem, 8vw, 5.5rem);
    font-weight: 700;
    text-transform: uppercase;
    color: var(--tm-gold);
    text-shadow: 2px 3px 0px #000;
    letter-spacing: 0.02em;
    line-height: 1.15;
    margin: 0;
    text-align: center;
    /* Marge latérale pour ne pas chevaucher rank/sponsored absolus */
    padding: 0 100px;
}

.tm-brand-name mark {
    background: transparent;
    color: #7a461b;
}

/* ─── Body : grille 3 colonnes — logo | centre | spacer symétrique ──────── */
/* Col 1 = logo, col 2 = catégorie (row 1) + boutons (row 2), col 3 = spacer */
.tm-brand-body {
    display: grid;
    grid-template-columns: var(--tm-logo-w) 1fr var(--tm-logo-w);
    column-gap: 24px;
    row-gap: 16px;
    margin-bottom: 24px;
}

.tm-brand-body::after { display: none; }

.tm-logo-col {
    grid-column: 1;
    grid-row: 1;
    width: var(--tm-logo-w);
    height: var(--tm-logo-w);
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.70);
    border: 1px solid rgba(99, 59, 36, 0.14);
    border-radius: 10px;
    padding: 10px;
    box-shadow: 0 2px 8px rgba(45, 31, 21, 0.08);
}

.tm-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.tm-info-col {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* ─── Category ────────────────────────────────────────── */
.tm-category {
    font-family: inherit;
    font-size: 20px;
    color: #000;
    margin: 0;
    letter-spacing: 0.02em;
    line-height: 1.4;
    text-align: center;
}

.tm-category::before {
    content: "Catégorie : ";
    font-weight: 700;
}

/* ─── Buttons — col 2 row 2, centrés sous la catégorie ───────────────────── */
.tm-buttons {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
}

.tm-btn-site,
.tm-btn-promo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    padding: 11px 11px;
    min-width: 148px;
    cursor: pointer;
    letter-spacing: 0.01em;
    text-decoration: none;
    line-height: 1;
    transition:
        transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1),
        box-shadow 0.18s ease,
        background 0.15s ease;
}

.tm-btn-site {
    background: var(--tm-accent);
    color: #F5E6D3;
    border: none;
    box-shadow: 0 2px 8px rgba(99, 59, 36, 0.30);
}
.tm-btn-site:link,
.tm-btn-site:visited {
    color: #F5E6D3;
    text-decoration: none;
}
.tm-btn-site:hover {
    background: #7a4a2e;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 59, 36, 0.40);
    color: #F5E6D3;
    text-decoration: none;
}
.tm-btn-site:focus,
.tm-btn-site:active {
    color: #F5E6D3;
    text-decoration: none;
}
.tm-btn-site:active  { transform: translateY(0); box-shadow: 0 1px 4px rgba(99,59,36,.25); }
.tm-btn-site:focus-visible { outline: 2px solid var(--tm-accent); outline-offset: 3px; }

.tm-btn-promo {
    background: transparent;
    color: var(--tm-accent);
    border: 1.5px solid var(--tm-accent);
    box-shadow: 0 2px 8px rgba(99, 59, 36, 0.10);
}
.tm-btn-promo:link,
.tm-btn-promo:visited,
.tm-btn-promo:focus,
.tm-btn-promo:active {
    color: var(--tm-accent);
    text-decoration: none;
}
.tm-btn-promo:hover {
    background: rgba(99, 59, 36, 0.08);
    transform: translateY(-2px);
    color: var(--tm-accent);
    box-shadow: 0 6px 20px rgba(99, 59, 36, 0.18);
    text-decoration: none;
}
.tm-btn-promo:active  { transform: translateY(0); }
.tm-btn-promo:focus-visible { outline: 2px solid var(--tm-accent); outline-offset: 3px; }
.tm-btn-promo.copied,
.tm-btn-promo:disabled,
.tm-btn-promo.copied:disabled {
    background: rgba(99, 59, 36, 0.12) !important;
    color: var(--tm-accent) !important;
    border-color: var(--tm-accent) !important;
    opacity: 1 !important;
}

/* ─── Refs section ────────────────────────────────────── */
.tm-refs {}

.tm-refs-label {
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    color: var(--tm-card-text);
    letter-spacing: 0.01em;
    margin: 0;
    text-align: center;
}

/* Séparateur centré 50% sous le label */
.tm-refs-label::after {
    content: '';
    display: block;
    width: 50%;
    height: 1px;
    background: rgba(99, 59, 36, 0.20);
    margin: 10px auto 16px;
}

/* PC : 1 ligne, max 6, centré */
.tm-refs-grid {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 10px;
}

/* Blindage : le thème utilise [data-count] comme sélecteur global (page vidéos)
   et lui applique height:892px !important — on force auto ici pour ne pas
   hériter de cette règle sur notre grille de refs. */
.tm-refs-grid[data-count] {
    height: auto !important;
}

.tm-ref-item {
    display: block;
    width: clamp(100px, 12vw, 160px);
    aspect-ratio: 1 / 1;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid rgba(99, 59, 36, 0.14);
    box-shadow: 0 2px 6px rgba(45, 31, 21, 0.10);
    transition:
        transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1),
        box-shadow 0.18s ease;
}
.tm-ref-item:link,
.tm-ref-item:visited,
.tm-ref-item:focus,
.tm-ref-item:active {
    color: inherit;
    text-decoration: none;
}
.tm-ref-item:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 8px 24px rgba(45, 31, 21, 0.18);
    color: inherit;
    text-decoration: none;
}
.tm-ref-item:active  { transform: translateY(0) scale(1); }
.tm-ref-item:focus-visible { outline: 2px solid var(--tm-accent); outline-offset: 2px; }
.tm-ref-no-link { cursor: default; }
.tm-ref-no-link:hover { transform: none; box-shadow: 0 2px 6px rgba(45, 31, 21, 0.10); }

.tm-ref-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ─── Dark card variant ───────────────────────────────── */
.tm-brand.tm-dark {
    --tm-card-bg:   #3a2819;
    --tm-card-text: #F5E6D3;
    border-color: rgba(219, 189, 118, 0.22);
}
.tm-brand.tm-dark .tm-sponsored {
    color: rgb(245, 230, 211);
}
.tm-brand.tm-dark .tm-rank {
    color: rgb(245, 230, 211);
}
.tm-brand.tm-dark .tm-refs-label {
    color: rgb(245, 230, 211);
}
.tm-brand.tm-dark .tm-btn-site{
    background: var(--tm-gold);
    color: rgb(245, 230, 211);
    border: none;
    box-shadow: 0 2px 8px rgba(219, 189, 118, 0.30);
}

.tm-brand.tm-dark .tm-category { color: rgb(245, 230, 211); }
.tm-brand.tm-dark .tm-logo-col { background: rgba(255,255,255,0.06); border-color: rgba(219,189,118,.14); }
.tm-brand.tm-dark .tm-btn-promo { color: var(--tm-gold); border-color: var(--tm-gold); }
.tm-brand.tm-dark .tm-btn-promo:link,
.tm-brand.tm-dark .tm-btn-promo:visited,
.tm-brand.tm-dark .tm-btn-promo:focus,
.tm-brand.tm-dark .tm-btn-promo:active { color: var(--tm-gold); }
.tm-brand.tm-dark .tm-btn-promo:hover { background: rgba(219,189,118,.10); color: var(--tm-gold); }
.tm-brand.tm-dark .tm-btn-promo.copied,
.tm-brand.tm-dark .tm-btn-promo:disabled {
    background: rgba(219, 189, 118, 0.15) !important;
    color: var(--tm-gold) !important;
    border-color: var(--tm-gold) !important;
    opacity: 1 !important;
}
.tm-brand.tm-dark .tm-refs-label::after { background: rgba(219, 189, 118, 0.25); }
.tm-brand.tm-dark .tm-ref-item { border-color: rgba(219, 189, 118, 0.14); }

/* ─── Empty state ─────────────────────────────────────── */
.tm-no-brands {
    color: rgba(45, 31, 21, 0.45);
    font-style: italic;
    text-align: center;
    padding: 32px;
}

/* ─── Mobile (< 782px) ────────────────────────────────── */
@media (max-width: 782px) {
    /* Nav logos mobile : pleine largeur */
    .tm-logo-nav {
        gap: 8px;
        padding: 0;
        width: 100%;
    }
    .tm-nav-item {
        width: calc((100% - 40px) / 6); /* 5 gaps × 8px */
        height: auto;
    }
    .tm-nav-rank {
        font-size: 7px;
    }

    .tm-brand-name {
        padding: 0 80px;
        text-shadow: 1px 1.5px 0px #000;
        font-size: clamp(1.1rem, 5vw, 1.6rem);
    }
    .tm-sponsored {
        font-size: 8px;
        padding: 1px 6px;
    }
    .tm-rank {
        font-size: 32px;
    }

    .tm-category {
        font-size: 16px;
    }

    /* Mobile : logo + catégorie côte à côte, boutons pleine largeur en dessous */
    .tm-brand-body {
        grid-template-columns: 80px 1fr;
        column-gap: 12px;
        row-gap: 10px;
    }

    .tm-logo-col {
        grid-column: 1;
        grid-row: 1;
        width: 80px;
        height: 80px;
    }

    .tm-info-col {
        grid-column: 2;
        grid-row: 1;
        align-items: flex-start;
    }

    .tm-category {
        text-align: left;
    }

    .tm-buttons {
        grid-column: 1 / -1;
        grid-row: 2;
        flex-wrap: nowrap;
        gap: 8px;
    }

    .tm-btn-site,
    .tm-btn-promo {
        flex: 1;
        min-width: 0;
        font-size: 13px;
        text-align: center;
    }

    /* Mobile : max 3 par ligne, dernière ligne centrée */
    .tm-refs-grid {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }

    .tm-ref-item {
        width: calc(33.33% - 6px);
        min-width: 80px;
        flex-shrink: 0;
        aspect-ratio: 1 / 1;
    }
}
