/* article.css — composants communs à toutes les pages d'article (/articles/{slug}).
 *
 * Chaque article charge ce fichier, puis son propre {slug}.css pour ce qui ne sert qu'à lui.
 * Le sommaire (bloc replié et rail) est rempli par article.js depuis les <h2 id="…"> de .article-body.
 * La citation utilise Cormorant Garamond italique 500, à charger dans le <head> de l'article.
 */

html {
    scroll-behavior: smooth;
}

/* --- En-tête : image de couverture, rubrique, titre, auteur et date --- */

.article-hero {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    width: 100%;
    max-width: 1260px;
    height: 500px;
    overflow: hidden;
    background: var(--course-card-background);
}

.article-hero-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Assombrit l'image sous le titre et la fond dans la page par le bas */
.article-hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(90deg, rgba(0, 0, 0, 0.88) 0%, rgba(0, 0, 0, 0.6) 40%, rgba(0, 0, 0, 0) 72%),
        linear-gradient(0deg, #000 0%, rgba(0, 0, 0, 0.4) 28%, rgba(0, 0, 0, 0) 55%);
    pointer-events: none;
}

/* Même largeur et mêmes marges que la colonne de l'article : le titre reste aligné sur le texte */
.article-hero-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 22px;
    width: 100%;
    max-width: 940px;
    padding: 0 30px 64px;
}

.article-hero-pill {
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.article-hero-title {
    max-width: 820px;
    font-size: clamp(38px, 3.6vw + 18px, 72px);
    line-height: 1.1;
    text-align: left;
    text-wrap: balance;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.6), 0 0 25px rgba(0, 0, 0, 0.4);
}

/* Fin du titre en vert, sur sa propre ligne et légèrement agrandie (règle « h1 > span » de common.css).
   L'agrandissement part de la gauche, pour que la ligne reste alignée sur le reste du titre. */
.article-hero-title > span {
    color: var(--accent-color);
    white-space: nowrap;
    transform-origin: left center;
}

.article-hero-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin: 0;
    font-size: 15px;
    line-height: 1.5;
    color: #BDBDBD;
}

/* --- Mise en page : colonne de l'article, plus le rail du sommaire à droite sur grand écran --- */

.article-layout {
    display: grid;
    grid-template-columns: minmax(0, 880px);
    justify-content: center;
    align-items: start;
    gap: 60px;
    width: 100%;
    max-width: 1260px;
    padding: 16px 30px 36px;
}

.article-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* --- Chapeau et encadré auteur --- */

.article-lede {
    margin: 0;
    font-size: clamp(20px, 0.5vw + 18px, 23px);
    line-height: 1.55;
    font-weight: 500;
    text-wrap: pretty;
}

.article-author {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 32px;
    padding: 14px 18px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    background: var(--course-card-background);
}

.article-author img {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
    background: #1a1f29;
}

.article-author p {
    margin: 0;
    font-size: 15px;
    line-height: 1.5;
    color: var(--gray-text-color);
    text-wrap: pretty;
}

.article-author strong {
    font-weight: 600;
    color: white;
}

/* --- Sommaire : bloc replié sous le chapeau, remplacé par le rail collant sur grand écran --- */

.article-toc-list {
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    list-style: none;
}

.article-toc {
    margin-top: 20px;
    border: 1px solid var(--separator-color);
    border-radius: 8px;
    background: var(--course-card-background);
}

.article-toc summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    font-size: 16px;
    line-height: 1.5;
    font-weight: 600;
    list-style: none;
    cursor: pointer;
    user-select: none;
}

.article-toc summary::-webkit-details-marker {
    display: none;
}

.article-toc summary::after {
    content: "";
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23A9A9A9' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
    transition: transform .3s var(--ease-out-quint);
}

.article-toc details[open] summary::after {
    transform: rotate(180deg);
}

.article-toc .article-toc-list {
    padding: 0 20px 16px;
    counter-reset: article-toc;
}

.article-toc li {
    border-top: 1px solid #1c212b;
    counter-increment: article-toc;
}

.article-toc a {
    display: flex;
    gap: 14px;
    padding: 10px 0;
    font-size: 16px;
    line-height: 1.5;
    color: white;
    text-decoration: none;
}

.article-toc a:hover {
    color: var(--accent-color);
}

.article-toc a::before {
    content: counter(article-toc, decimal-leading-zero);
    flex-shrink: 0;
    padding-top: 2px;
    font-size: 14px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--accent-color);
}

.article-rail {
    display: none;
    position: sticky;
    top: 32px;
    padding-top: 6px;
}

.article-rail nav {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Petites étiquettes en capitales : titre du rail, source d'une citation */
.article-rail-label,
.article-quote figcaption {
    font-family: "JetBrains Mono", ui-monospace, monospace;
    font-size: 10.5px;
    line-height: 1.5;
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--darker-gray-text-color);
}

.article-rail .article-toc-list {
    border-left: 1px solid var(--separator-color);
}

.article-rail a {
    display: block;
    margin-left: -1px;
    padding: 7px 0 7px 18px;
    border-left: 2px solid transparent;
    font-size: 15px;
    line-height: 1.5;
    color: var(--darker-gray-text-color);
    text-decoration: none;
    transition: color .3s var(--ease-out-quint), border-color .3s var(--ease-out-quint);
}

.article-rail a:hover {
    color: white;
}

/* Section en cours de lecture (classe posée par article.js) */
.article-rail a.active {
    border-left-color: var(--accent-color);
    font-weight: 600;
    color: white;
}

/* --- Sections et texte courant --- */

.article-separator {
    width: 100%;
    margin: 56px 0;
    border: 0;
    border-top: 1px solid var(--separator-color);
}

/* Le texte est en retrait par rapport au chapeau, aux séparateurs et à la carte de fin */
.article-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 0 30px;
    font-size: 18px;
    line-height: 1.7;
    text-wrap: pretty;
}

.article-section h2 {
    font-size: clamp(26px, 1.6vw + 18px, 34px);
    line-height: 1.25;
    text-align: left;
    text-wrap: balance;
    scroll-margin-top: 24px;
}

.article-section p {
    margin: 0;
}

.article-section a {
    color: var(--accent-color);
}

/* --- Listes : à flèches vertes, à croix rouges --- */

.article-list-arrow,
.article-list-cross {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
    padding: 0;
    line-height: 1.5;
    list-style: none;
}

.article-list-arrow li,
.article-list-cross li {
    position: relative;
    padding-left: 28px;
}

/* Puces dessinées en SVG : le caractère « → » n'est pas dans la police servie par Google Fonts,
   son dessin changerait d'un appareil à l'autre. */
.article-list-arrow li::before,
.article-list-cross li::before {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    background: center / contain no-repeat;
}

.article-list-arrow li::before {
    top: 4px;
    left: -3px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237FDD00' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12h15M13 6l6 6-6 6'/%3E%3C/svg%3E");
}

.article-list-cross {
    gap: 14px;
}

.article-list-cross li {
    padding-left: 30px;
}

.article-list-cross li::before {
    top: 5px;
    left: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23FF4D4D' stroke-width='2.75' stroke-linecap='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E");
}

/* --- Citation : guillemet vert dans la marge, source en dessous --- */

.article-quote {
    display: grid;
    grid-template-columns: clamp(40px, 5vw, 64px) minmax(0, 1fr);
    column-gap: clamp(10px, 1.5vw, 18px);
    row-gap: 22px;
    margin: 16px 0;
}

.article-quote::before {
    content: "«";
    font-family: "Cormorant Garamond", serif;
    font-size: clamp(80px, 8vw, 120px);
    line-height: 0.75;
    font-style: italic;
    font-weight: 500;
    color: var(--accent-color);
    text-shadow: 0 0 28px rgba(200, 255, 84, 0.45);
}

.article-quote blockquote {
    margin: 0;
    font-family: "Cormorant Garamond", serif;
    font-size: clamp(28px, 1.6vw + 18px, 40px);
    line-height: 1.2;
    font-style: italic;
    font-weight: 500;
    text-wrap: balance;
}

.article-quote figcaption {
    grid-column: 2;
    display: flex;
    align-items: center;
    gap: 14px;
    line-height: 1.3;
}

.article-quote figcaption::before {
    content: "";
    flex-shrink: 0;
    width: 40px;
    height: 1px;
    background: #474747;
}

/* --- Note : précision en italique, repérée par une étoile verte --- */

.article-note {
    position: relative;
    padding-left: 18px;
    font-size: 16px;
    line-height: 1.5;
    font-style: italic;
    color: var(--gray-text-color);
}

.article-note::before {
    content: "*";
    position: absolute;
    left: 0;
    font-style: normal;
    font-weight: 700;
    color: var(--accent-color);
}

.article-note strong {
    font-weight: 600;
    color: white;
}

/* --- Phrase mise en avant : centrée, entre deux traits verts --- */

.article-highlight {
    align-self: center;
    max-width: 560px;
    padding: 20px 0;
    font-size: clamp(24px, 1.2vw + 18px, 30px);
    line-height: 1.3;
    font-weight: 700;
    text-align: center;
    text-wrap: balance;
}

.article-highlight::before,
.article-highlight::after {
    content: "";
    display: block;
    width: 48px;
    height: 2px;
    margin: 0 auto;
    background: var(--accent-color);
}

.article-highlight::before {
    margin-bottom: 22px;
}

.article-highlight::after {
    margin-top: 22px;
}

/* --- Images : pleine largeur, à côté du texte, ou petit visuel devant un paragraphe --- */

.article-figure {
    margin: 8px 0;
    overflow: hidden;
    border: 1px solid var(--separator-color);
    border-radius: 8px;
    background: var(--course-card-background);
}

.article-figure img {
    display: block;
    width: 100%;
    height: auto;
}

/* Texte et image côte à côte, empilés quand la place manque */
.article-split {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
    align-items: center;
    gap: 28px;
}

.article-split img {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid var(--separator-color);
    border-radius: 8px;
    background: var(--course-card-background);
}

.article-icon-row {
    display: grid;
    grid-template-columns: clamp(72px, 10vw, 120px) minmax(0, 1fr);
    align-items: center;
    gap: clamp(18px, 3vw, 32px);
}

.article-icon-row img {
    display: block;
    width: 100%;
    height: auto;
}

/* --- Conversation avec un agent : onglet, titre de la session, messages horodatés --- */

.article-chat {
    margin: 8px 0;
    overflow: hidden;
    border: 1px solid #2c2c2c;
    border-radius: 10px;
    background: #1a1a1a;
    color: #D6D6D6;
    text-wrap: balance;
}

.article-chat-tabs {
    display: flex;
    border-bottom: 1px solid #2c2c2c;
    background: #141414;
    font-size: 14px;
    line-height: 1.5;
}

.article-chat-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-right: 1px solid #2c2c2c;
    background: #1a1a1a;
    color: white;
}

.article-chat-tab svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    fill: none;
    stroke: #D97757;
    stroke-width: 2.4;
    stroke-linecap: round;
}

.article-chat-title {
    padding: 12px 20px;
    border-bottom: 1px solid #2c2c2c;
    font-size: 15px;
    line-height: 1.2;
    font-weight: 600;
    color: #E8E8E8;
}

.article-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px 20px 26px;
}

.article-chat-time {
    align-self: flex-end;
    font-size: 12px;
    line-height: 1.5;
    color: #7A7A7A;
}

.article-chat-time:not(:first-child) {
    margin-top: 10px;
}

/* Message de l'agent : puce grise, titre et texte */
.article-chat-agent {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-left: 26px;
}

.article-chat-agent::before {
    content: "";
    position: absolute;
    top: 9px;
    left: 0;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #8A8A8A;
}

.article-chat-agent strong {
    font-size: clamp(18px, 1vw + 14px, 22px);
    line-height: 1.3;
    font-weight: 700;
    color: #E8E8E8;
}

.article-chat-agent p {
    font-size: 15px;
    line-height: 1.6;
    color: #BDBDBD;
}

/* Message de l'utilisateur : bulle encadrée */
.article-chat-user {
    padding: 14px 16px;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    background: #202020;
    font-size: 15px;
    line-height: 1.55;
    color: #EDEDED;
}

/* --- Schéma : SVG en ligne dans un cadre, avec défilement horizontal sur petit écran et légende --- */

.article-diagram {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin: 8px 0;
    padding: 24px 20px 18px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    background: var(--course-card-background);
}

.article-diagram-scroll {
    overflow-x: auto;
}

.article-diagram svg {
    display: block;
    width: 100%;
    min-width: 720px;
    height: auto;
}

.article-diagram figcaption {
    font-size: 14px;
    line-height: 1.5;
    color: var(--darker-gray-text-color);
}

/* --- Carte de fin : vignette avec reflet, accroche et bouton entouré d'une lumière tournante --- */

@property --article-cta-angle {
    syntax: '<angle>';
    inherits: true;
    initial-value: 0deg;
}

@keyframes article-cta-sweep {
    to {
        --article-cta-angle: 360deg;
    }
}

@keyframes article-cta-shine {
    0% {
        transform: translate(-70%, 70%);
    }
    45%, 100% {
        transform: translate(70%, -70%);
    }
}

.article-cta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    background: var(--course-card-background);
    transition: border-color .3s var(--ease-out-quint), box-shadow .3s var(--ease-out-quint);
}

.article-cta:hover {
    border-color: var(--yellow-color);
    box-shadow: var(--glow-yellow-card);
}

.article-cta-image {
    position: relative;
    min-height: 260px;
    overflow: hidden;
}

.article-cta-image img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Reflet diagonal qui traverse la vignette toutes les 10 secondes */
.article-cta-image::after {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, rgba(255, 255, 255, 0) 34%, rgba(255, 255, 255, 0.04) 39%, rgba(255, 255, 255, 0.12) 44%, rgba(255, 255, 255, 0.2) 48%, rgba(255, 255, 255, 0.24) 50%, rgba(255, 255, 255, 0.2) 52%, rgba(255, 255, 255, 0.12) 56%, rgba(255, 255, 255, 0.04) 61%, rgba(255, 255, 255, 0) 66%);
    mix-blend-mode: screen;
    transform: translate(-70%, 70%);
    animation: article-cta-shine 10s cubic-bezier(.4, 0, .6, 1) 1s infinite;
    pointer-events: none;
}

.article-cta-body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 14px;
    padding: 36px 36px 38px;
}

.article-cta-body h2 {
    font-size: 28px;
    line-height: 1.2;
    text-align: left;
    text-wrap: balance;
}

.article-cta-body p {
    margin: 0;
    font-size: 17px;
    line-height: 1.55;
    color: #BDBDBD;
    text-wrap: pretty;
}

/* Contour du bouton : une lumière en fait le tour en 3 secondes, doublée d'une traîne floue */
.article-cta-button {
    --article-cta-light: conic-gradient(from var(--article-cta-angle), rgba(127, 221, 0, 0) 0deg, rgba(127, 221, 0, 0) 240deg, #7FDD00 310deg, #EFFF00 345deg, rgba(127, 221, 0, 0) 360deg);
    position: relative;
    isolation: isolate;
    width: fit-content;
    margin-top: 10px;
    padding: 2px;
    border-radius: 8px;
    background: var(--article-cta-light), linear-gradient(rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.14));
    animation: article-cta-sweep 3s linear infinite;
}

.article-cta-button::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: 8px;
    background: var(--article-cta-light);
    filter: blur(10px);
    opacity: 0.8;
}

.article-cta-button .button {
    padding: 14px 22px;
    font-size: 17px;
    line-height: 1.35;
}

/* --- Adaptations --- */

@media (min-width: 1260px) {
    .article-hero-content {
        max-width: none;
    }

    .article-layout {
        grid-template-columns: minmax(0, 880px) 260px;
    }

    .article-toc {
        display: none;
    }

    .article-rail {
        display: block;
    }
}

@media (max-width: 784px) {
    .article-section {
        padding: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .article-cta-button,
    .article-cta-image::after {
        animation: none;
    }
}
