/* =========================================
   1. VARIABLES & RESET
   ========================================= */
:root {
  --font-header: "Poppins", sans-serif;
  --font-body: "Roboto Slab", serif;
  
  /* Tes variables de template */
  --color-bg: #2c214d;
  --color-bg-rgb: 44, 33, 77;
  --color-surface: #423275;
  --color-text: #ffdcb5;
  --color-text-muted: #aca6cb;
  --color-accent: #ff577f;
  --color-highlight: #ff577f;
  --color-on-highlight: #2c214d; /* Texte posé sur la couleur vive (étiquettes, bouton) */
  --color-highlight-on-surface: #ff83a0; /* Couleur vive en texte sur une carte (pseudos, liens) */

  --radius: 12px;
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  background-color: var(--color-bg);
  color: var(--color-text);
  margin: 0;
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
}

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

h1, h2, h3, h4 {
  font-family: var(--font-header);
  margin: 0;
  font-weight: 700;
}

/* =========================================
   2. HEADER & FOOTER
   ========================================= */
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 3rem;
  position: fixed;
  width: 100%;
  top: 0;
  z-index: 1000;
  background: linear-gradient(
    180deg,
    rgba(var(--color-bg-rgb), 0.98) 0%,
    rgba(var(--color-bg-rgb), 0.8) 70%,
    rgba(var(--color-bg-rgb), 0) 100%
  );
  backdrop-filter: blur(4px);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-header);
  font-size: 1.5rem;
  font-weight: 700;
}
.logo img { height: 32px; }

.main-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-family: var(--font-header);
  font-weight: 500;
}
.main-nav a:hover { color: var(--color-highlight); }

.button {
  background-color: var(--color-highlight);
  color: var(--color-on-highlight);
  padding: 10px 22px;
  border-radius: var(--radius);
  font-weight: 600;
  white-space: nowrap;
}
.main-nav .button:hover { color: var(--color-on-highlight); }
.button:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
  box-shadow: 0 4px 12px rgba(var(--color-bg-rgb), 0.3);
}

.main-footer {
  padding: 3rem;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin-top: 4rem;
  border-top: 1px solid rgba(255,255,255,0.05);
}
.footer-links {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 2rem;
}
.footer-links a:hover { color: var(--color-highlight); }

/* =========================================
   3. LAYOUT PRINCIPAL & BREADCRUMB
   ========================================= */
.site-content {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  padding: 8rem 2rem 2rem 2rem; /* Marge haute pour le header fixed */
  min-height: 85vh;
}

.breadcrumb {
  width: 100%;
  max-width: 1200px;
  margin-bottom: 2rem;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  font-family: var(--font-header);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.breadcrumb-separator { color: var(--color-accent); }
.breadcrumb-item:hover { color: var(--color-highlight); }

/* =========================================
   4. HOME: SYSTEME DE PILES 3D (STACKS)
   ========================================= */
/* Balisage généré par Forum.php : .forum-section > a > h2.forum-header + .forum-item.
   Les piles sont posées à plat pour que chaque fil se lise sans survol ;
   le survol garde le relief (la pile se soulève, la carte visée avance).
   Elles se répartissent en deux colonnes équilibrées : 2 + 2 avec quatre
   catégories, 3 + 2 avec cinq, quel que soit le nombre de catégories vides. */
.stacks-container {
  columns: 2 320px;
  column-gap: 2.5rem;
  padding: 2rem 0;
  width: 100%;
  max-width: 1200px;
}
/* Une seule catégorie : une pile centrée */
.stacks-container:not(:has(> .forum-section ~ .forum-section)) {
  columns: 1;
  max-width: 600px;
}

/* Le "Paquet" (Section) */
.forum-section {
  min-width: 0;
  margin-bottom: 3.5rem;
  break-inside: avoid;
  position: relative;
  transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
  z-index: 1;
}
.forum-section:has(> a > .forum-header):not(:has(.forum-item)) { display: none; }

/* Titre de la section, en étiquette au-dessus du paquet */
.forum-section > a {
  display: block;
  margin-bottom: 1.25rem;
  text-align: center;
}
.forum-section > a > .forum-header {
  display: block;
  background: var(--color-highlight);
  color: var(--color-on-highlight);
  padding: 0.8rem 1rem;
  border-radius: var(--radius);
  font-size: 1.1rem;
  line-height: 1.3;
  box-shadow: 10px 10px 20px rgba(0,0,0,0.3);
  overflow-wrap: anywhere;
}

/* La "Carte" (Item) : sujet et auteur à gauche, avatar en haut à droite, chiffres dessous */
.forum-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 45px;
  column-gap: 1rem;
  row-gap: 0.3rem;
  align-items: start;
  align-content: start;
  position: relative;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, var(--color-surface), rgba(var(--color-bg-rgb), 0.95));
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  box-shadow: -10px 10px 25px rgba(0, 0, 0, 0.6);
  transition: all 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  backdrop-filter: blur(5px);
}
.forum-item .forum-avatar {
  grid-column: 2;
  grid-row: 1 / span 2;
  width: 45px;
  height: 45px;
  object-fit: cover;
  border: 2px solid var(--color-accent);
}
.forum-item .forum-subject {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  font-family: var(--font-header);
  font-size: 1.1rem;
  line-height: 1.3;
  font-weight: 600;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 3; /* Max 3 lignes */
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.forum-item .forum-subject:hover { color: var(--color-highlight-on-surface); }
.forum-item .forum-author {
  grid-column: 1;
  grid-row: 2;
  min-width: 0;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  overflow-wrap: anywhere;
}
.forum-item .forum-author a:hover { color: var(--color-highlight-on-surface); }
.forum-item .forum-messages,
.forum-item .forum-last-message {
  grid-column: 1 / -1;
  min-width: 0;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--color-text-muted);
}
.forum-item .forum-messages { grid-row: 3; margin-top: 0.4rem; }
.forum-item .forum-last-message { grid-row: 4; }

/* --- ANIMATION AU SURVOL (HOVER) --- */

/* 1. Le paquet se soulève */
.forum-section:hover {
  transform: translateY(-6px);
  z-index: 100; /* Passe au premier plan */
}
.forum-section:hover .forum-item { box-shadow: 0 5px 15px rgba(0,0,0,0.2); }

/* 2. Effet sur la carte active */
.forum-section:hover .forum-item:hover {
  transform: scale(1.03) translateX(5px);
  background: var(--color-surface);
  border-color: var(--color-highlight);
  z-index: 10;
}

/* Page catégorie : la pile s'étale en grille, sans la carte de fond */
.content-card:has(> .item-list > .forum-section) {
  width: 100%;
  max-width: 1200px;
  background: none;
  border: 0;
  padding: 0;
}
.item-list:has(> .forum-section) { list-style: none; margin: 0; padding: 0; }
.item-list > .forum-section {
  width: 100%;
  margin-bottom: 0;
  padding: 0;
  border-bottom: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
  gap: 1.25rem;
}
/* L'étiquette répète le titre h1 de la page */
.item-list > .forum-section > a { display: none; }
.item-list > .forum-section .forum-item { margin-bottom: 0; }
.item-list > .forum-section:hover { transform: none; }

/* Hero Banner (Home) */
.hero-banner {
  width: 100%;
  max-width: 1200px;
  margin-bottom: 5rem;
  padding: 4rem 3rem;
  border-radius: var(--radius);
  background-size: cover;
  background-position: center;
  position: relative;
  border: 1px solid var(--color-accent);
  background-color: var(--color-surface);
}
.hero-banner::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, rgba(var(--color-bg-rgb), 0.95) 20%, rgba(var(--color-bg-rgb), 0.3) 100%);
  border-radius: var(--radius);
}
.hero-content { position: relative; z-index: 1; max-width: 600px; }
.hero-content h1 { font-size: 3rem; margin-bottom: 1rem; color: white; }
.hero-content p { font-size: 1.2rem; color: var(--color-text-muted); }

/* =========================================
   5. PAGE THREAD (SUJET)
   ========================================= */
.page-header {
  width: 100%;
  max-width: 1200px;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-accent);
}
.page-header h1 { font-size: 2.2rem; line-height: 1.3; overflow-wrap: anywhere; }

.post-list { width: 100%; max-width: 1200px; }

.post-item {
  display: flex;
  gap: 2rem;
  background-color: var(--color-surface);
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 2rem;
  border: 1px solid rgba(255,255,255,0.02);
  transition: border-color 0.3s;
}
.post-item:hover { border-color: rgba(255,255,255,0.1); }

.post-author {
  flex-shrink: 0;
  width: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  border-right: 1px solid rgba(255,255,255,0.05);
  padding-right: 1.5rem;
}
.avatar {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  margin-bottom: 1rem;
  border: 4px solid var(--color-bg);
  box-shadow: 0 0 0 2px var(--color-accent);
  object-fit: cover;
}
.author-name {
  font-family: var(--font-header);
  font-weight: 700;
  color: var(--color-highlight-on-surface);
  margin-bottom: 0.25rem;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.post-content { flex-grow: 1; min-width: 0; }
.post-date {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  display: block;
}
.post-body { font-size: 1.05rem; line-height: 1.8; white-space: pre-line; overflow-wrap: anywhere; }
.post-body a { color: var(--color-highlight-on-surface); text-decoration: underline; }
.post-body img,
.post-body video { max-width: 100%; height: auto; }
.post-body iframe {
  display: block;
  width: 100%;
  max-width: 560px;
  height: auto;
  aspect-ratio: 16 / 9;
  border: 0;
}
.post-body pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.post-body table { display: block; max-width: 100%; overflow-x: auto; }

/* =========================================
   6. PAGE USER (PROFIL)
   ========================================= */
.profile-header {
  width: 100%;
  max-width: 1200px;
  display: flex;
  align-items: center;
  gap: 2.5rem;
  background-color: var(--color-surface);
  padding: 2.5rem;
  border-radius: var(--radius);
  margin-bottom: 2rem;
  border: 1px solid var(--color-accent);
}
.profile-avatar {
  width: 140px;
  height: 140px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 4px solid var(--color-highlight);
  object-fit: cover;
}
.profile-info { min-width: 0; }
.profile-info h1 { font-size: 2.8rem; line-height: 1.2; margin-bottom: 0.5rem; overflow-wrap: anywhere; }
.profile-meta { font-size: 1.1rem; color: var(--color-text-muted); margin: 0; overflow-wrap: anywhere; }

.profile-grid {
  width: 100%;
  max-width: 1200px;
  display: grid;
  grid-template-columns: minmax(0, 2.5fr) minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
}

.content-card {
  background-color: var(--color-surface);
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 2rem;
  border: 1px solid rgba(255,255,255,0.02);
}
.card-title {
  font-size: 1.4rem;
  color: var(--color-highlight-on-surface);
  overflow-wrap: anywhere;
  margin-bottom: 1.5rem;
  padding-bottom: 0.8rem;
  border-bottom: 2px solid var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.item-list > div {
  padding: 1.2rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.item-list > div:last-child { border-bottom: none; }

.comment-date { font-size: 0.8rem; color: var(--color-text-muted); margin-bottom: 0.3rem; }
.comment-thread-title { line-height: 1.4; overflow-wrap: anywhere; }
.comment-thread-title a { font-weight: 600; font-size: 1.1rem; }
.comment-thread-title a:hover { color: var(--color-highlight-on-surface); }
.comment {
  background: rgba(var(--color-bg-rgb), 0.5);
  padding: 1rem;
  border-radius: 8px;
  font-size: 0.95rem;
  margin-top: 0.8rem;
  border-left: 3px solid var(--color-highlight);
  font-style: italic;
  color: var(--color-text-muted);
  white-space: pre-line;
  overflow-wrap: anywhere;
}
/* Message repris tel quel : vidéos, images et blocs limités à la carte */
.comment a { color: var(--color-highlight-on-surface); text-decoration: underline; }
.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;
}
.comment pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.comment table { display: block; max-width: 100%; overflow-x: auto; }

.info-list { list-style: none; padding: 0; margin: 0; }
.info-list li {
  padding: 0.8rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  overflow-wrap: anywhere;
}
.info-list li strong { color: var(--color-highlight-on-surface); }

/* =========================================
   7. FORMULAIRES (LOGIN/REGISTER)
   ========================================= */
.form-container {
  max-width: 480px;
  width: 100%;
  background-color: var(--color-surface);
  padding: 3rem;
  border-radius: var(--radius);
  border: 1px solid var(--color-accent);
}
.form-container h2 { text-align: center; font-size: 2rem; margin-bottom: 2rem; }
.form-group { margin-bottom: 1.5rem; }
.form-group label {
  display: block; margin-bottom: 0.5rem;
  font-weight: 600; font-family: var(--font-header);
}
.form-input {
  width: 100%; padding: 12px 16px;
  background-color: var(--color-bg);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius);
  color: var(--color-text);
  font-family: var(--font-body);
}
.form-input:focus {
  outline: none; border-color: var(--color-highlight);
  box-shadow: 0 0 0 2px rgba(var(--color-bg-rgb), 0.2);
}
.form-button { width: 100%; margin-top: 1rem; cursor: pointer; border: none; font-size: 1.1rem; }

/* =========================================
   8. PAGINATION
   ========================================= */
.pagination {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; margin-top: 3rem;
  font-family: var(--font-header);
}
.pagination a, .pagination span {
  padding: 8px 14px;
  background: var(--color-surface);
  border-radius: 6px;
  color: var(--color-text-muted);
}
.pagination a:hover,
.pagination .current-page {
  background: var(--color-highlight); color: var(--color-on-highlight);
}
.pagination:not(:has(a)) { display: none; } /* Vide ou page unique */

/* =========================================
   9. RESPONSIVE (MOBILE)
   ========================================= */
@media (max-width: 1100px) {
  .profile-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
}

@media (max-width: 768px) {
  /* Header dans le flux : logo et nom, puis le menu qui passe à la ligne */
  .main-header {
    position: relative;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
    padding: 1rem 1.25rem;
    background: rgba(var(--color-bg-rgb), 0.98);
  }
  .logo { min-width: 0; font-size: 1.15rem; line-height: 1.3; }
  .logo img { flex-shrink: 0; }
  .logo span { min-width: 0; overflow-wrap: anywhere; }
  .main-nav { flex-wrap: wrap; gap: 0.5rem 1.25rem; }
  .button { padding: 8px 18px; }
  .site-content { padding: 1.5rem 1rem 2rem; }

  .hero-banner { margin-bottom: 2.5rem; padding: 2.5rem 1.5rem; }
  .hero-content h1 { font-size: 2rem; }
  .hero-content p { font-size: 1.05rem; }

  /* Piles dépliées en une colonne, titres complets */
  .stacks-container,
  .stacks-container:not(:has(> .forum-section ~ .forum-section)) {
    columns: auto;
    max-width: none;
    padding: 0;
  }
  .forum-section { margin-bottom: 2.5rem; }
  .forum-section > a { text-align: left; }
  .forum-item .forum-subject { display: block; overflow: visible; }
  .forum-section:hover,
  .forum-section:hover .forum-item:hover { transform: none; }

  .page-header h1 { font-size: 1.7rem; }
  .post-item { flex-direction: column; gap: 1rem; padding: 1.5rem; }
  .post-author {
    width: 100%; flex-direction: row; align-items: center; gap: 1rem;
    text-align: left;
    border-right: none; border-bottom: 1px solid rgba(255,255,255,0.05);
    padding-right: 0; padding-bottom: 1rem;
  }
  .post-author .avatar { width: 60px; height: 60px; margin-bottom: 0; flex-shrink: 0; }
  .post-date { margin-top: 0; padding-bottom: 0; border-bottom: 0; }
  .author-name { min-width: 0; }

  .profile-header { flex-direction: column; gap: 1.25rem; text-align: center; padding: 1.5rem; }
  .profile-avatar { width: 110px; height: 110px; }
  .profile-info { width: 100%; }
  .profile-info h1 { font-size: 2rem; }
  .card-title { font-size: 1.2rem; }

  .main-footer { padding: 2rem 1rem; margin-top: 2rem; }
}

@media (max-width: 480px) {
  .footer-links { flex-direction: column; align-items: center; }
  .post-item { padding: 1.25rem 1rem; }
  .content-card { padding: 1.25rem; }
  .profile-avatar { width: 96px; height: 96px; }
  .profile-info h1 { font-size: 1.7rem; }
  .profile-meta { font-size: 1rem; }
  .comment { padding: 0.8rem; }
  .form-container { padding: 2rem 1.25rem; }
}
