/* --- Polices & Variables --- */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@500;700;800&display=swap");

:root {
    --font-main: 'Inter', sans-serif;
    --color-bg: #4a0000;
    --color-surface: #6b0000;
    --color-text: #fffde7;
    --color-text-muted: #ffecb3;
    --color-border: #8c0000;
    --item-1-bg: #880e4f;
    --item-2-bg: #ad1457;
    --item-3-bg: #c2185b;
    --item-4-bg: #d81b60;
    --item-5-bg: #e91e63;
    --color-accent-text: #f381a8; /* pseudos sur les cartes, lisible sur --color-surface et --color-bg */
    --slant-angle: -20deg;
}

/* --- Styles Généraux --- */
body {
  font-family: var(--font-main);
  background-color: var(--color-bg);
  color: var(--color-text);
  margin: 0;
  font-size: 16px;
  line-height: 1.5;
}

a {
  text-decoration: none;
  color: var(--color-text);
  transition: color 0.2s;
}

a:hover {
  color: white;
  text-decoration: none;
}

h1, h2, h3, h4 {
  font-weight: 800;
  margin: 0;
}

p {
    margin-bottom: 1rem;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem;
}

/* --- Header --- */
.main-header {
  padding: 1rem 2rem;
  background-color: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: relative;
  z-index: 20;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1400px;
  margin: 0 auto;
}

.logo {
  font-size: 1.5rem;
  font-weight: 800;
  display: flex;
  align-items: center;
}

.logo img {
  height: 32px;
  margin-right: 10px;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.main-nav a {
  color: var(--color-text-muted);
  font-weight: 500;
  font-size: 0.95rem;
}

.main-nav a:hover {
    color: white;
}

.button {
  background-color: white;
  color: var(--color-bg);
  padding: 8px 20px;
  border-radius: 99px;
  font-weight: 700;
  transition: transform 0.2s;
}

.button:hover {
    transform: scale(1.05);
    color: var(--color-bg); /* Force color keep */
}

/* .main-nav a imposait la couleur atténuée au bouton blanc */
.main-nav a.button,
.main-nav a.button:hover {
    color: var(--color-bg);
}

/* --- Footer --- */
.main-footer {
  background-color: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: 3rem 2rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-top: auto;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
  max-width: 1000px;
  margin: 0 auto 2rem auto;
}

.footer-column h4 {
  font-size: 1rem;
  text-transform: uppercase;
  color: white;
  margin-bottom: 1.5rem;
  letter-spacing: 1px;
}

.footer-column ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-column li {
  margin-bottom: 0.8rem;
}

.footer-column a {
  color: var(--color-text-muted);
}

.footer-column a:hover {
    color: white;
    text-decoration: underline;
}

.footer-bottom {
  text-align: center;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
}

/* --- Bannière --- */
.sub-header-banner {
  position: relative;
  padding: 4rem 2rem;
  text-align: center;
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  background: var(--color-surface); /* Fallback */
}

.banner-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
  opacity: 0.2;
  filter: blur(2px);
}

/* Bannière du moteur : balise <img> sans classe */
.sub-header-banner > img {
  display: block;
  max-width: 100%;
  height: auto;
  margin-bottom: 1.5rem;
  border-radius: 8px;
  position: relative;
  z-index: 2;
}

.sub-header-banner h1 {
  font-size: 2.5rem;
  position: relative;
  z-index: 2;
  text-shadow: 0 4px 20px rgba(0,0,0,0.8);
  max-width: 800px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.breadcrumb {
  font-size: 0.9rem;
  margin-top: 1rem;
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.breadcrumb-separator {
    color: var(--color-text-muted);
    font-size: 0.8rem;
}

.breadcrumb a {
  color: var(--color-text-muted);
  background: rgba(0,0,0,0.3);
  padding: 4px 8px;
  border-radius: 4px;
}

.breadcrumb a:hover {
  color: white;
  background: rgba(0,0,0,0.6);
}

/* --- HOMEPAGE : bandes inclinées --- */
/* Balisage généré par Forum.php : .forum-section > a > h2.forum-header + .forum-item.
   Les fils n'apparaissaient qu'au survol d'une colonne inclinée : les catégories deviennent des
   bandes empilées aux bords inclinés, fils toujours visibles (cf. docs/forums_generation.md §7). */
.main-stage {
  background: var(--color-bg);
  padding: 3rem 2rem 4rem;
}

.slanted-feed {
  max-width: 1200px;
  margin: 0 auto;
}

.forum-section {
  --cut: 2.5rem;
  --band-pad-x: 2rem;
  position: relative;
  padding: calc(var(--cut) + 1rem) var(--band-pad-x) calc(var(--cut) + 1.25rem);
  background: var(--band);
  clip-path: polygon(0 var(--cut), 100% 0, 100% calc(100% - var(--cut)), 0 100%);
  transition: filter 0.4s;
}

.forum-section + .forum-section {
  margin-top: calc(6px - var(--cut));
}

/* Couleur de bande par rang, en boucle au-delà de 5 catégories */
.forum-section:nth-child(5n+1) { --band: var(--item-1-bg); }
.forum-section:nth-child(5n+2) { --band: var(--item-2-bg); }
.forum-section:nth-child(5n+3) { --band: var(--item-3-bg); }
.forum-section:nth-child(5n+4) { --band: var(--item-4-bg); }
.forum-section:nth-child(5n+5) { --band: var(--item-5-bg); }

/* Catégories vides masquées (accueil) */
.forum-section:has(> a > .forum-header):not(:has(.forum-item)) {
  display: none;
}

/* Survol (JS du footer) : les autres bandes s'estompent */
.forum-section.is-dimmed {
  filter: saturate(0.5) brightness(0.8);
}

/* Titre de catégorie : étiquette inclinée */
.forum-section > a {
  display: inline-block;
  max-width: calc(100% - 1rem);
  margin: 0 0 0.75rem 0.5rem;
  padding: 0.5rem 1.5rem;
  background: var(--color-bg);
  color: var(--color-text);
  transform: skewX(var(--slant-angle));
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
  transition: background 0.2s;
}

.forum-section > a:hover {
  background: var(--color-surface);
}

.forum-section > a > .forum-header {
  display: block;
  font-size: 1.6rem;
  line-height: 1.25;
  color: var(--color-text);
  overflow-wrap: anywhere;
  transform: skewX(calc(var(--slant-angle) * -1));
}

/* Fils : une carte par sujet */
.forum-item {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  column-gap: 1rem;
  row-gap: 0.25rem;
  align-items: center;
  margin-top: 0.6rem;
  padding: 0.9rem 1.1rem;
  background: var(--color-bg);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.2);
  color: var(--color-text);
  text-align: left;
}

.forum-avatar {
  grid-column: 1;
  grid-row: 1 / span 3;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.2);
}

.forum-subject {
  grid-column: 2 / -1;
  grid-row: 1;
  min-width: 0;
  color: var(--color-text);
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.forum-author,
.forum-messages,
.forum-last-message {
  min-width: 0;
  font-size: 0.85rem;
}

.forum-author {
  grid-column: 2;
  grid-row: 2;
  overflow-wrap: anywhere;
}

.forum-author a {
  color: var(--color-accent-text);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: rgba(255,255,255,0.3);
}

/* Pastille inclinée comme les bandes */
.forum-messages {
  grid-column: 3;
  grid-row: 2;
  justify-self: end;
  padding: 0.15rem 0.9rem;
  background: var(--color-surface);
  color: var(--color-text);
  font-weight: 700;
  white-space: nowrap;
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
}

.forum-last-message {
  grid-column: 2 / -1;
  grid-row: 3;
  color: var(--color-text-muted);
  text-wrap: balance;
}

/* Grand écran : une ligne par sujet (avatar | sujet | auteur | messages | date) */
@media (min-width: 1200px) {
  .forum-item {
    grid-template-columns: 48px minmax(0, 1fr) 130px 7rem 16.5rem;
  }
  .forum-avatar {
    grid-row: 1;
  }
  .forum-subject {
    grid-column: 2;
  }
  .forum-author {
    grid-column: 3;
    grid-row: 1;
  }
  .forum-messages {
    grid-column: 4;
    grid-row: 1;
    justify-self: center;
  }
  .forum-last-message {
    grid-column: 5;
    grid-row: 1;
    text-align: right;
  }
}

/* --- PAGES INTERNES (Cards) --- */
.content-card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  margin-bottom: 2rem;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.card-header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--color-border);
  background: rgba(255,255,255,0.02);
}

.card-header h2 {
  font-size: 1.25rem;
  color: white;
}

/* En-tête du fil : titre et auteur passent à la ligne au lieu de s'écraser */
.card-header {
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
}

.card-header .item-meta {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.card-header .item-meta a {
  color: var(--color-accent-text);
  font-weight: 700;
}

.card-body {
  padding: 0; /* Padding géré par les enfants */
}

/* --- THREAD VIEW : Post Item --- */
.post-item {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  padding: 2rem;
  gap: 2rem;
}

.post-item:last-child {
    border-bottom: none;
}

/* Colonne Auteur */
.post-author {
  width: 180px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-right: 1rem;
  border-right: 1px solid rgba(255,255,255,0.05);
}

.post-author img {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 1rem;
  border: 3px solid var(--color-bg);
  box-shadow: 0 0 0 2px var(--color-border);
}

.post-author-name {
    font-weight: 800;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.post-author-name a {
    color: var(--color-accent-text); /* Couleur d'accent pour les noms */
}

.post-author .item-meta {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

/* Colonne Contenu */
.post-content {
  flex-grow: 1;
  min-width: 0; /* Empêche l'overflow des flex items */
  overflow-wrap: anywhere;
}

.post-content img,
.post-content video {
  max-width: 100%;
  height: auto;
}

.post-content pre {
  white-space: pre-wrap;
}

.post-content .item-meta {
    margin-top: 0;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.post-content p {
    margin-bottom: 1rem;
    line-height: 1.7;
    font-size: 1.05rem;
}

/* Gestion des iframes (Youtube) dans les posts */
.post-content iframe {
    display: block;
    width: 100%;
    max-width: 640px;
    height: auto;
    aspect-ratio: 16 / 9;
    border: 0;
    border-radius: 8px;
    margin: 1rem 0;
}

/* Mobile Thread View */
@media (max-width: 768px) {
    .post-item {
        flex-direction: column;
        padding: 1.5rem;
    }
    .post-author {
        width: 100%;
        flex-direction: row;
        border-right: none;
        border-bottom: 1px solid rgba(255,255,255,0.05);
        padding-bottom: 1rem;
        margin-bottom: 1rem;
        text-align: left;
        align-items: center;
        gap: 1rem;
    }
    .post-author img {
        width: 60px;
        height: 60px;
        margin-bottom: 0;
    }
}

/* --- USER PROFILE Specifics --- */
.card-body.post-item {
    /* Reset pour la carte d'info profil qui utilise la classe post-item */
    border-bottom: none;
}

/* Listes dans le profil (Derniers sujets/réponses) */
.card-body > div {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--color-border);
    transition: background 0.2s;
}

.card-body > div:last-child {
    border-bottom: none;
}

.card-body > div:hover {
    background-color: rgba(255,255,255,0.02);
}

.comment-date {
    font-size: 0.8rem;
    color: var(--color-accent-text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
    font-weight: 700;
}

.comment-thread-title {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.comment-thread-title a {
    color: white;
}

.comment-thread-title a:hover {
    color: var(--color-accent-text);
}

.comment {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-style: italic;
}

/* --- PAGE CATÉGORIE : même bande que sur l'accueil, sans carte autour --- */
.content-card:has(> .card-body > .forum-section) {
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
}

.card-body > .forum-section,
.card-body > .forum-section:hover {
  padding: calc(var(--cut) + 1rem) var(--band-pad-x) calc(var(--cut) + 1.25rem);
  border-bottom: 0;
  background: var(--band);
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.pagination:not(:has(a)) {
  display: none;
}

.pagination a,
.pagination .current-page {
  min-width: 2.5rem;
  padding: 0.4rem 0.9rem;
  text-align: center;
  font-weight: 700;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 99px;
  color: var(--color-text);
}

.pagination .current-page {
  background: white;
  color: var(--color-bg);
}

/* Footer : chiffres remplis sur l'accueil et les catégories seulement */
.footer-stats:has(span:empty) {
  display: none;
}

/* Scrollbar personnalisée pour Webkit */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--color-bg);
}
::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}

/* --- Mobile --- */
@media (max-width: 768px) {
  .main-header {
    padding: 0.9rem 1rem;
  }
  .header-content {
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
  }
  .logo {
    min-width: 0;
    font-size: 1.2rem;
    line-height: 1.3;
    overflow-wrap: anywhere;
  }
  .main-nav {
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
  }
  .sub-header-banner {
    padding: 2.5rem 1rem;
  }
  .sub-header-banner h1 {
    font-size: 1.8rem;
  }
  .container {
    padding: 1.5rem 1rem;
  }
  .main-stage {
    padding: 2rem 1rem 3rem;
  }
  .forum-section {
    --cut: 1.5rem;
    --band-pad-x: 1rem;
  }
  .card-header {
    padding: 1.25rem;
  }
  .card-body > .post-item {
    padding: 1.25rem;
    gap: 0;
  }
  .post-content .item-meta {
    margin-bottom: 1rem;
    padding-bottom: 0;
    border-bottom: 0;
  }
  .main-footer {
    padding: 2rem 1rem;
  }
}

@media (max-width: 480px) {
  .sub-header-banner h1 {
    font-size: 1.5rem;
  }
  .forum-section {
    --band-pad-x: 0.75rem;
  }
  .forum-section > a > .forum-header {
    font-size: 1.3rem;
  }
  /* Titre sur toute la largeur, avatar à côté du pseudo */
  .forum-item {
    grid-template-columns: 36px minmax(0, 1fr) auto;
    column-gap: 0.75rem;
    padding: 0.85rem 0.9rem;
  }
  .forum-avatar {
    grid-row: 2 / span 2;
    width: 36px;
    height: 36px;
  }
  .forum-subject {
    grid-column: 1 / -1;
    display: block;
    overflow: visible;
    margin-bottom: 0.35rem;
  }
}
