/* ============================================
   THEME BLOCK - Sections colorées fullscreen

   Structure :
   - Marges : 140px haut/bas, marge latérale de référence (--marge-laterale) à gauche/droite
   - Layout 50-50 : titre+texte | cases
   - Cases : 150px hauteur fixe, alignées haut-gauche, padding 10px + 40px droite
   - Texte : 2 colonnes (à résoudre)
   ============================================ */

.theme-block {
    position: relative;
    width: 100%;
    padding: 0;
    margin: 0;
}

.theme-block__container {
    max-width: 100%;
    margin: 0;
    padding: 140px var(--marge-laterale);
    display: flex;
    gap: 75px;
    align-items: flex-start;
}

/* Limiter la largeur à 1600px sur grands écrans */
@media (min-width: 1600px) {
    .theme-block__container {
        padding-left: calc((100% - 1600px) / 2 + var(--marge-laterale));
        padding-right: calc((100% - 1600px) / 2 + var(--marge-laterale));
    }
}

/* ============================================
   ZONE GAUCHE/DROITE - Titre + Texte (50%)
   ============================================ */

.theme-block__main {
    flex: 1 1 50%;
    max-width: 50%;
}

.theme-block__title {
    font-family: 'tt-commons-pro', 'TT Commons Pro', sans-serif !important;
    font-size: 51px;
    font-weight: 200 !important;
    line-height: 1.2;
    margin-bottom: 30px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Texte sur 2 colonnes - VERSION PROPRE */
.theme-block__content {
    font-family: var(--font-body);
    font-size: 16px;
    font-weight: 400;
    line-height: 25px;
    column-count: 2;
    column-gap: 40px;
}

.theme-block__content p {
    margin-bottom: 15px;
    /* #34227 pt10 — evite qu'une phrase soit coupee entre 2 colonnes (column-count:2 ci-dessus) */
    break-inside: avoid;
}

/* #34227 pt7a — sous-titre a puces "•" du bloc (1er paragraphe, marque en PHP theme-block.php),
   meme graisse/police que le corps, juste plus lourd pour se detacher du texte courant */
.theme-block__content p.theme-block__subtitle {
    font-weight: var(--fw-medium);
}

/* ============================================
   ZONE GAUCHE/DROITE - Cases (50%)
   ============================================ */

.theme-block__themes {
    flex: 1 1 50%;
    max-width: 50%;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.theme-block__themes-title {
    font-family: var(--font-body);
    font-size: 15px;
    font-weight: 300;
    line-height: 25px;
    margin-bottom: 15px;
}

.theme-block__themes-list {
    --cases-gap: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: var(--cases-gap);
}

.theme-block__theme-item {
    height: 150px;
    max-width: calc((100% - var(--cases-gap)) / 2); /* deux cases tiennent toujours sur une ligne */
    min-width: min-content; /* sauf si un mot est plus large : jamais de mot qui sort de sa case */
    border: none;
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    will-change: transform;
}

/* #34227 — l'effet de soulevement au survol ne doit apparaitre que si l'encart
   contient reellement un lien (.theme-block__theme-link) — sinon il suggere une
   interaction qui n'existe pas pour les items rendus en <span> (pas d'URL fournie) */
.theme-block__theme-item:has(.theme-block__theme-link):hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.theme-block__theme-link,
.theme-block__theme-text {
    display: block;
    padding: 10px 10px 10px 10px;
    font-family: var(--font-body);
    font-size: 28px;
    font-weight: 200;
    line-height: 1.2;
    text-align: left;
    text-decoration: none;
    color: inherit;
    white-space: normal;
    height: 100%;
    width: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

.theme-block__theme-link {
    cursor: pointer;
}

/* ============================================
   LAYOUT VARIANTS
   ============================================ */

.theme-block--text-right .theme-block__container {
    flex-direction: row-reverse;
}

/* ============================================
   COULEURS DE FOND - Originales
   ============================================ */

.bg-red {
    background-color: var(--color-rouge);
    color: var(--color-blanc);
}

.bg-orange {
    background-color: var(--color-orange);
    color: var(--color-blanc);
}

.bg-blue {
    background-color: var(--color-bleu);
    color: var(--color-blanc);
}

.bg-green {
    background-color: var(--color-vert);
    color: var(--color-blanc);
}

.bg-black {
    background-color: #000000;
    color: var(--color-blanc);
}

.bg-white {
    background-color: var(--color-blanc);
    color: #000000;
}

.bg-gray {
    background-color: #F5F5F5;
    color: #000000;
}

/* ============================================
   COULEURS DES CASES - Teintes plus foncées (pas du noir transparent)
   ============================================ */

/* ROUGE → Rouge foncé lumineux */
.bg-red .theme-block__theme-item {
    background-color: var(--color-rouge-cases);
}

.bg-red .theme-block__theme-item:has(.theme-block__theme-link):hover {
    background-color: #CC1E00;
}

/* ORANGE → Orange foncé lumineux */
.bg-orange .theme-block__theme-item {
    background-color: var(--color-orange-cases);
}

.bg-orange .theme-block__theme-item:has(.theme-block__theme-link):hover {
    background-color: #EB6905;
}

/* BLEU → Bleu foncé lumineux */
.bg-blue .theme-block__theme-item {
    background-color: var(--color-bleu-cases);
}

.bg-blue .theme-block__theme-item:has(.theme-block__theme-link):hover {
    background-color: #0055C7;
}

/* VERT → Vert foncé lumineux */
.bg-green .theme-block__theme-item {
    background-color: var(--color-vert-cases);
}

.bg-green .theme-block__theme-item:has(.theme-block__theme-link):hover {
    background-color: #0F302C;
}

/* NOIR → Gris moyen */
.bg-black .theme-block__theme-item {
    background-color: #333333;
}

.bg-black .theme-block__theme-item:has(.theme-block__theme-link):hover {
    background-color: #4D4D4D;
}

/* BLANC → Gris clair */
.bg-white .theme-block__theme-item {
    background-color: #E0E0E0;
}

.bg-white .theme-block__theme-item:has(.theme-block__theme-link):hover {
    background-color: #CCCCCC;
}

/* GRIS → Gris moyen */
.bg-gray .theme-block__theme-item {
    background-color: #D0D0D0;
}

.bg-gray .theme-block__theme-item:has(.theme-block__theme-link):hover {
    background-color: #BBBBBB;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1250px) {
    .theme-block__content {
        column-count: 1;
    }
}

@media (max-width: 1024px), (hover: none) and (pointer: coarse) and (orientation: portrait) and (max-width: 1032px) {
    .theme-block__container {
        padding: 100px var(--marge-laterale);
        gap: 40px;
    }

    .theme-block__title {
        font-size: 40px;
    }

    .theme-block__theme-item {
        height: 120px;
    }

    .theme-block__theme-link,
    .theme-block__theme-text {
        font-size: 24px;
        padding: 10px 10px 10px 10px;
    }
}

@media (max-width: 768px), (hover: none) and (pointer: coarse) and (orientation: portrait) and (max-width: 1032px) {
    .theme-block {
        margin: 0;
        padding-top: 0;
        padding-bottom: 0;
    }

    .theme-block__container {
        flex-direction: column;
        padding: 60px var(--marge-laterale);
        gap: 54px;
    }

    .theme-block__main,
    .theme-block__themes {
        flex: 1 1 100%;
        max-width: 100%;
    }

    .theme-block__title {
        font-size: 45px;
        font-weight: 300;
        line-height: 55px; /* était 72.718px — trop grand, corrigé par Fabrice */
    }

    .theme-block__content {
        column-count: 1;
        font-family: 'tt-commons-pro', 'TT Commons Pro', sans-serif;
        font-weight: 400;
        font-size: 18px;
        line-height: 30px;
    }

    .theme-block__themes-title {
        font-size: 31px;
        line-height: 27px;
        font-weight: 400;
    }

    /* #34227 pt11 — grille fixe 2 colonnes : l'ancien flex-wrap (max-width:60%) ne tenait a 2 par
       ligne que si le texte etait court (ex. "PEA"/"SCPI") ; des libelles plus longs (ex. "Retraite
       Art 39 / 83") depassaient 50% et retombaient a 1 colonne. La grille garantit 2 colonnes quelle
       que soit la longueur du texte. */
    .theme-block__themes-list {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .theme-block__theme-item {
        height: 148px;
        max-width: none; /* la grille a deux colonnes fixe la largeur */
        min-width: auto;
    }

    .theme-block__theme-link,
    .theme-block__theme-text {
        font-size: 18px;
        line-height: 1.3;
        padding: 10px 30px 10px 10px;
        white-space: normal;
        word-break: normal;
        overflow-wrap: normal;
    }

    .theme-block--text-right .theme-block__container {
        flex-direction: column;
    }
}

/* ============================================
   PAYSAGE TACTILE - Tablette et téléphone en paysage
   Tailles et marges réduites
   ============================================ */

@media (hover: none) and (pointer: coarse) and (orientation: landscape) and (min-width: 769px) and (max-width: 1376px) {
    .theme-block__container {
        padding: 100px var(--marge-laterale);
    }

    .theme-block__title {
        font-size: 44px;
    }

    .theme-block__theme-link,
    .theme-block__theme-text {
        font-size: 24px;
    }
}
