/* --- Polices & Variables (Strictement intouchées) --- */
:root {
  /* -- Couleurs de base -- */
  --color-background: #2f3e34;
  --color-surface: #3c4f41;
  --color-text: #f5f3f0;
  --color-text-subtle: #b5beb5;

  /* -- Couleurs d'accentuation -- */
  --color-accent: #f5f3f0;
  --color-accent-hover: #e6e4e1;
  --color-accent-shadow: #d1cfcc;
  --color-on-accent: #2f3e34; /* texte posé sur l'accent (boutons) */

  /* -- Couleurs des couches et ombres -- */
  --color-layer-1: #4a6350;
  --color-shadow-dark: #243028;
  --color-shadow-light: #344439;
  --color-shadow-medium: #202b24;
  --color-shadow-darker: #1a221d;
  
  /* -- Couleurs pour le JS (en format R, G, B) -- */
  --js-bokeh-color1: 245, 243, 240;
  --js-bokeh-color2: 74, 99, 80;

  /* -- Typographie (statique) -- */
  --font-family: 'Nunito', sans-serif;
}

/* --- Base & Reset --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--color-background);
  font-family: var(--font-family);
  color: var(--color-text);
  line-height: 1.6;
  font-size: 16px;
  overflow-x: hidden;
  min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

/* --- Fond Parallaxe (Formes Organiques) --- */
.parallax-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.shape {
  position: absolute;
  border-radius: 50%; /* Formes rondes/organiques */
  will-change: transform;
  transition: transform 0.1s linear;
  filter: blur(40px); /* Flou pour l'effet d'ambiance */
}

.shape-1 {
  width: 500px; height: 500px;
  background-color: var(--color-layer-1);
  top: -10%; left: -10%;
  opacity: 0.5;
}

.shape-2 {
  width: 400px; height: 400px;
  background-color: var(--color-accent);
  bottom: -5%; right: -5%;
  opacity: 0.3;
}

.shape-3 {
  width: 250px; height: 250px;
  background-color: var(--color-surface);
  top: 40%; right: 15%;
  opacity: 0.4;
}

/* --- Container Principal --- */
main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 20px 60px;
}

/* --- Header Flottant (Style Carte) --- */
.site-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 15px 30px;
  max-width: 1000px;
  margin: 30px auto 50px;
  padding: 15px 30px;
  background-color: var(--color-surface);
  border-radius: 20px; /* Arrondi prononcé style UI moderne */
  box-shadow: 
    0 10px 15px -3px var(--color-shadow-medium),
    0 4px 6px -2px var(--color-shadow-light);
  position: relative;
  z-index: 10;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--color-text);
  min-width: 0;
  line-height: 1.25;
}

.logo-link span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.logo {
  flex-shrink: 0;
  height: 40px;
  width: 40px;
  object-fit: contain;
  background-color: var(--color-text); /* Fallback visuel */
  border-radius: 8px;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav-link {
  font-weight: 700;
  color: var(--color-text-subtle);
  font-size: 1rem;
  position: relative;
}

.nav-link:hover, .nav-link.active {
  color: var(--color-text);
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: var(--color-accent);
    border-radius: 2px;
}

.nav-button {
  background-color: var(--color-accent);
  color: var(--color-on-accent); /* Contraste sur la couleur accent */
  display: inline-block;
  line-height: 1.4;
  text-align: center;
  padding: 10px 24px;
  border-radius: 12px;
  font-weight: 800;
  box-shadow: 0 4px 6px var(--color-accent-shadow);
  transition: transform 0.1s ease;
}

.nav-button:hover {
  transform: translateY(-2px);
  background-color: var(--color-accent-hover);
}

/* --- Hero Banner --- */
.hero-banner {
    padding: 10px; /* Cadre blanc autour de l'image */
    background-color: var(--color-surface);
    border-radius: 20px;
    margin-bottom: 50px;
    box-shadow: 0 4px 6px var(--color-shadow-medium);
}

/* La bannière du moteur est une balise img sans classe */
.banner-image,
.hero-banner > img {
    width: 100%;
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    display: block;
    background-color: var(--color-layer-1);
}

/* --- Sections Forum (Conteneur Gris/Bleu) --- */
/* Balisage généré par Forum.php : .forum-section > a > h2.forum-header + .forum-item */
.forum-section {
    background-color: var(--color-layer-1);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 40px;
    box-shadow: inset 0 2px 4px var(--color-shadow-light);
}

/* Catégorie sans fil : masquée */
.forum-section:has(> a > .forum-header):not(:has(.forum-item)) {
    display: none;
}

.forum-header {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1.25;
    color: var(--color-text);
    margin: 0 0 20px 10px;
    overflow-wrap: anywhere;
}

/* Le lien parent */
.forum-section > a {
    display: block;
}

.forum-section > a:hover .forum-header {
    text-decoration: underline;
    text-decoration-color: var(--color-accent);
    text-decoration-thickness: 3px;
    text-underline-offset: 6px;
}

/* --- Items Forum (Cartes Blanches) --- */
/* Avatar | titre sur toute la largeur, puis auteur • date | badge messages.
   La date garde sa largeur : c'est l'auteur qui passe à la ligne si besoin. */
.forum-item {
    background-color: var(--color-surface);
    border-radius: 12px;
    padding: 18px 25px 18px 20px;
    margin-bottom: 15px;
    box-shadow: 0 2px 4px var(--color-shadow-light);
    border: 1px solid rgba(255,255,255, 0.5);
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;

    display: grid;
    grid-template-columns: 48px fit-content(40%) max-content minmax(0, 1fr) auto;
    column-gap: 14px;
    row-gap: 6px;
    align-items: center;
}

.forum-item:last-child {
    margin-bottom: 0;
}

.forum-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 15px -3px var(--color-shadow-medium);
}

/* 1. Avatar à gauche */
.forum-avatar {
    grid-column: 1;
    grid-row: 1 / span 2;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    background-color: var(--color-layer-1);
}

/* 2. Titre en haut */
.forum-subject {
    grid-column: 2 / 5;
    grid-row: 1;
    min-width: 0;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--color-text);
    line-height: 1.3;
    overflow-wrap: anywhere;
}
.forum-subject:hover {
    text-decoration: underline;
    text-decoration-color: var(--color-accent);
    text-decoration-thickness: 2px;
}

/* 3. Auteur (Sous le titre) */
.forum-author {
    grid-column: 2;
    grid-row: 2;
    align-self: baseline;
    min-width: 0;
    font-size: 0.9rem;
    color: var(--color-text-subtle);
    font-weight: 600;
    overflow-wrap: anywhere;
}
.forum-author::before {
    content: "Par ";
    font-weight: 400;
}
.forum-author a {
    color: inherit;
}
.forum-author a:hover {
    color: var(--color-text);
}

/* 4. Date / Dernier message (À côté de l'auteur) */
.forum-last-message {
    grid-column: 3;
    grid-row: 2;
    align-self: baseline;
    min-width: 0;
    font-size: 0.9rem;
    color: var(--color-text-subtle);
    opacity: 0.8;
}
.forum-last-message::before {
    content: "• ";
    margin-right: 5px;
}

/* 5. Badge Messages (à droite) */
.forum-messages {
    grid-column: 5;
    grid-row: 1 / span 2;
    justify-self: end;

    background-color: var(--color-background); /* Contraste doux sur le blanc */
    color: var(--color-text);
    font-weight: 800;
    font-size: 0.9rem;

    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border-radius: 12px;

    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    text-align: center;
}

/* --- Page Profil & Contenus --- */
.profile-header {
    text-align: center;
    margin-bottom: 40px;
}

.profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 5px solid var(--color-surface);
    box-shadow: 0 10px 15px -3px var(--color-shadow-medium);
    margin-bottom: 15px;
}

.profile-name {
    font-size: 2rem;
    font-weight: 800;
    color: var(--color-text);
    margin: 0;
}

.profile-joindate {
    color: var(--color-text-subtle);
    font-weight: 600;
}

.user-content-grid {
    display: grid;
    grid-template-columns: 1fr 2.5fr;
    gap: 30px;
}

/* Stats (Cartes simples) */
.user-stats {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.stat-item {
    background-color: var(--color-surface);
    padding: 20px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 2px 4px var(--color-shadow-light);
}

.stat-item span {
    font-size: 2rem;
    font-weight: 800;
    color: var(--color-text);
    display: block;
    line-height: 1;
}

.stat-item label {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--color-text-subtle);
    font-weight: 700;
    letter-spacing: 1px;
}

/* Activité (Gros bloc blanc) */
.user-activity {
    background-color: var(--color-surface);
    border-radius: 20px;
    padding: 32px;
    box-shadow: 0 4px 6px var(--color-shadow-light);
}

.user-activity h2 {
    font-size: 1.5rem;
    margin-bottom: 24px;
    color: var(--color-text);
    border-bottom: 2px solid var(--color-layer-1);
    padding-bottom: 10px;
}

.activity-list h4 {
    margin: 20px 0 15px;
    color: var(--color-text-subtle);
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 1px;
}

.activity-list > div {
    padding: 15px 0;
    border-bottom: 1px solid var(--color-layer-1);
}
.activity-list > div:last-child {
    border-bottom: none;
}

.comment-date {
    font-size: 0.8rem;
    color: var(--color-text-subtle);
    font-weight: 700;
    margin-bottom: 5px;
}

.comment-thread-title a {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--color-text);
    overflow-wrap: anywhere;
}
.comment-thread-title a:hover {
    text-decoration: underline;
    text-decoration-color: var(--color-accent);
}

.comment {
    background-color: var(--color-background);
    padding: 15px;
    border-radius: 12px;
    color: var(--color-text-subtle);
    font-style: italic;
    margin-top: 10px;
    font-size: 0.95rem;
    overflow-wrap: anywhere;
}
.comment img,
.comment video {
    max-width: 100%;
    height: auto;
}
.comment iframe {
    display: block;
    width: 100%;
    max-width: 560px;
    height: auto;
    aspect-ratio: 16 / 9;
    border: 0;
    border-radius: 12px;
}

/* --- Page Sujet (fil de discussion) --- */
.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    margin: 0 0 12px 4px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--color-text-subtle);
}
.breadcrumb .breadcrumb-item {
    color: var(--color-text);
}
.breadcrumb .breadcrumb-item:hover {
    text-decoration: underline;
    text-decoration-color: var(--color-accent);
}

.page-title {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.25;
    color: var(--color-text);
    margin: 0 0 30px;
    overflow-wrap: anywhere;
}

.post-list {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.post-item {
    display: grid;
    grid-template-columns: 170px minmax(0, 1fr);
    background-color: var(--color-surface);
    border-radius: 20px;
    overflow: hidden;
    box-shadow:
      0 10px 15px -3px var(--color-shadow-medium),
      0 4px 6px -2px var(--color-shadow-light);
}

.post-author {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 24px 10px;
    background-color: var(--color-layer-1);
    text-align: center;
    min-width: 0;
}

.post-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    border: 4px solid var(--color-surface);
    box-shadow: 0 4px 6px var(--color-shadow-medium);
}

.author-name {
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--color-text);
    line-height: 1.3;
    max-width: 100%;
    overflow-wrap: anywhere;
}
.author-name:hover {
    text-decoration: underline;
    text-decoration-color: var(--color-accent);
}

.post-body {
    min-width: 0;
    padding: 22px 28px 26px;
}

.post-header {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-text-subtle);
    padding-bottom: 10px;
    margin-bottom: 14px;
    border-bottom: 2px solid var(--color-layer-1);
}

/* Les messages sont du texte brut : on garde leurs retours à la ligne */
.post-content {
    white-space: pre-line;
    overflow-wrap: anywhere;
    line-height: 1.7;
}
.post-content a {
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.post-content a:hover {
    text-decoration-thickness: 2px;
}
.post-content img,
.post-content video {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
}
/* Le moteur entoure les vidéos de <br> : inutiles avec pre-line */
.post-content br:has(+ iframe),
.post-content iframe + br {
    display: none;
}
.post-content iframe {
    display: inline-block;
    vertical-align: bottom;
    width: 100%;
    max-width: 560px;
    height: auto;
    aspect-ratio: 16 / 9;
    border: 0;
    border-radius: 12px;
    background-color: var(--color-layer-1);
    /* Seule sur sa ligne, même au milieu d'une phrase */
    margin: 0 max(0px, 100% - 560px) 0 0;
}
.post-content pre {
    white-space: pre-wrap;
}

/* --- Page Catégorie --- */
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 15px 20px;
    margin-bottom: 30px;
}
.page-header .page-title {
    margin: 0;
    min-width: 0;
}
/* Le nom de la catégorie est déjà le titre de la page */
.category-section .forum-section > a {
    display: none;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 30px;
}
.pagination .page-link,
.pagination .current-page {
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    background-color: var(--color-surface);
    color: var(--color-text);
    box-shadow: 0 2px 4px var(--color-shadow-light);
}
.pagination .current-page {
    background-color: var(--color-accent);
    color: var(--color-on-accent);
}
.pagination .page-link:hover {
    background-color: var(--color-layer-1);
}

/* --- Footer --- */
.site-footer {
    text-align: center;
    padding: 40px 20px;
    color: var(--color-text-subtle);
    font-weight: 700;
    margin-top: 60px;
    overflow-wrap: anywhere;
}

/* --- Responsive Mobile --- */
/* Tablette : la date passe sous l'auteur */
@media (max-width: 900px) {
    .forum-item {
        grid-template-columns: 48px minmax(0, 1fr) auto;
        row-gap: 4px;
    }
    .forum-avatar {
        grid-row: 1 / span 3;
    }
    .forum-subject,
    .forum-author {
        grid-column: 2;
    }
    .forum-last-message {
        grid-column: 2;
        grid-row: 3;
    }
    .forum-last-message::before {
        content: none;
    }
    .forum-messages {
        grid-column: 3;
        grid-row: 1 / span 3;
    }
}

@media (max-width: 800px) {
    .site-header {
        flex-direction: column;
        gap: 20px;
        margin-top: 0;
        border-radius: 0 0 20px 20px;
    }

    .user-content-grid {
        grid-template-columns: 1fr;
    }

    .user-stats {
        flex-direction: row;
        justify-content: center;
    }

    .stat-item {
        flex: 1;
    }
}

/* Mobile */
@media (max-width: 600px) {
    main {
        padding: 0 14px 40px;
    }

    .site-header {
        padding: 14px 16px;
        gap: 12px;
        margin-bottom: 30px;
    }
    .logo-link {
        font-size: 1.15rem;
        gap: 10px;
    }
    .main-nav {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px 18px;
    }
    .nav-button {
        padding: 8px 18px;
    }

    .hero-banner {
        padding: 6px;
        border-radius: 14px;
        margin-bottom: 30px;
    }
    .hero-banner > img {
        border-radius: 9px;
    }

    .forum-section {
        padding: 18px 12px;
        border-radius: 16px;
        margin-bottom: 28px;
    }
    .forum-header {
        font-size: 1.4rem;
        margin: 0 0 14px 6px;
    }

    /* Liste empilée : avatar | titre, auteur, date, badge */
    .forum-item {
        grid-template-columns: 40px minmax(0, 1fr);
        align-items: start;
        padding: 14px;
        column-gap: 12px;
        row-gap: 4px;
    }
    .forum-avatar {
        grid-row: 1 / span 3;
        width: 40px;
        height: 40px;
    }
    .forum-subject {
        grid-column: 2;
        font-size: 1rem;
    }
    .forum-author {
        grid-column: 2;
        grid-row: 2;
    }
    .forum-last-message {
        grid-column: 2;
        grid-row: 3;
        font-size: 0.85rem;
    }
    .forum-last-message::before {
        content: none;
    }
    .forum-messages {
        grid-column: 2;
        grid-row: 4;
        justify-self: start;
        height: 30px;
        min-width: 0;
        margin-top: 4px;
        font-size: 0.85rem;
        border-radius: 10px;
    }

    .page-title {
        font-size: 1.5rem;
        margin-bottom: 20px;
    }

    .post-item {
        grid-template-columns: minmax(0, 1fr);
        border-radius: 16px;
    }
    .post-author {
        flex-direction: row;
        justify-content: flex-start;
        text-align: left;
        padding: 12px 16px;
    }
    .post-avatar {
        width: 48px;
        height: 48px;
        border-width: 3px;
    }
    .author-name {
        font-size: 1rem;
    }
    .post-body {
        padding: 16px 16px 20px;
    }

    .user-activity {
        padding: 20px;
    }

    .site-footer {
        padding: 30px 16px;
        margin-top: 40px;
    }
}
