/* ===== THÈME "PAPER" ===== */
@import url("https://fonts.googleapis.com/css2?family=Karla:wght@400;700&family=Lora:wght@700&display=swap");

:root {
  /* -- Polices -- */
  --font-heading: 'Lora', serif;
  --font-body: 'Karla', sans-serif;

  /* -- Mode Clair (par défaut) -- */
  --color-background: #f8f5f2;
  --color-surface: #ffffff;
  --color-text: #3a3a3a;
  --color-heading: #1a1a1a;
  --color-primary: #b3541e;
  --color-border: #e0dcd7;
  --color-text-muted: #8a8a8a;
  --color-button-text: #ffffff;
}

body.dark-mode {
  /* -- Mode Sombre -- */
  --color-background: #2d2d2d;
  --color-surface: #3a3a3a;
  --color-text: #dcdcdc;
  --color-heading: #ffffff;
  --color-primary: #e59c72;
  --color-border: #4a4a4a;
  --color-text-muted: #9e9e9e;
  --color-button-text: #1a1a1a;
}

/* ===== CONFIGURATION GLOBALE ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
  background-color: var(--color-background);
  color: var(--color-text);
  font-family: var(--font-body);
  line-height: 1.7;
  transition: background-color 0.3s, color 0.3s;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-heading);
  color: var(--color-heading);
  font-weight: 700;
  transition: color 0.3s;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 700;
  transition: color 0.3s;
}

a:hover {
  text-decoration: underline;
}

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

/* ===== HEADER ===== */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: 2rem;
  transition: border-color 0.3s;
}
.logo {
  display: flex;
  align-items: center;
  gap: 1rem;
  text-decoration: none;
}
.logo-img {
  width: 40px;
  height: 40px;
}
.logo h1 {
  font-size: 1.8rem;
}
.main-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.nav-link {
  font-size: 1rem;
}
.nav-link.active {
  font-weight: 700;
  color: var(--color-heading);
}
.theme-button {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
}

/* ===== BANNIÈRE ===== */
.banner {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 2rem;
  text-align: center;
  margin-bottom: 2rem;
  transition: background-color 0.3s, border-color 0.3s;
}
.banner h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

/* ===== FIL D'ARIANE ===== */
.breadcrumb {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-bottom: 2rem;
  transition: color 0.3s;
}
.breadcrumb a {
  font-weight: 400;
}

/* ===== CONTENU ET SECTIONS ===== */
.page-title {
  font-size: 2rem;
  margin-bottom: 2rem;
  text-align: center;
}
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}
.categories-wrapper, .category-list, .post-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.forum-section, .category-item-full, .post, .reply-form, .profile-header, .profile-section, .auth-container {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 1.5rem;
  transition: background-color 0.3s, border-color 0.3s;
}
.forum-header {
  font-size: 1.3rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
  transition: border-color 0.3s;
}
.forum-header a {
  text-decoration: none;
}
.forum-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-border);
  transition: border-color 0.3s;
}
.forum-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.forum-item:first-of-type {
  padding-top: 0;
}
.forum-subject {
  font-size: 1rem;
}
.forum-meta {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  display: flex;
  gap: 1rem;
  white-space: nowrap;
  transition: color 0.3s;
}
.forum-meta a {
  font-weight: 400;
  color: var(--color-text-muted);
}

/* ===== BOUTONS ET FORMULAIRES ===== */
.action-button {
  background-color: var(--color-primary);
  color: var(--color-button-text);
  padding: 0.6rem 1.2rem;
  border-radius: 4px;
  border: none;
  font-family: var(--font-body);
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}
.reply-form, .auth-container {
  padding: 2rem;
}
.reply-form h3, .auth-container h2 {
  margin-top: 0;
  text-align: center;
}
.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 700;
}
.form-group input, .reply-form textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 1rem;
  background-color: var(--color-background);
  color: var(--color-text);
  font-family: var(--font-body);
}
.reply-form textarea {
  min-height: 120px;
  margin: 1rem 0;
}
.auth-container {
  max-width: 450px;
  margin: 2rem auto;
}
.auth-container .action-button {
  width: 100%;
  margin-top: 1rem;
}
.auth-switch {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.9rem;
}

/* ===== PAGE CATÉGORIES ===== */
.category-item-full {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.category-item-full h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1.3rem;
}
.category-item-full p {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin: 0;
}
.category-meta {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  text-align: right;
  white-space: nowrap;
  display: flex;
  flex-direction: column;
}

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 2.5rem;
}
.pagination a, .pagination span {
  font-weight: 700;
}
.pagination .page-active {
  color: var(--color-text);
}

/* ===== PAGE DE SUJET (THREAD) ===== */
.post {
  display: flex;
  gap: 1.5rem;
}
.post-author {
  flex-shrink: 0;
  width: 150px;
  text-align: center;
}
.avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  margin-bottom: 0.75rem;
}
.author-name {
  display: block;
  font-weight: 700;
  font-size: 0.9rem;
  overflow-wrap: break-word;
}
.author-meta {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}
.post-body {
  flex-grow: 1;
}
.post-meta {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-border);
}
.post-content p {
  margin-bottom: 1rem;
}

/* ===== PAGE DE PROFIL ===== */
.profile-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
}
.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
}
.profile-info h1 {
  margin: 0;
  font-size: 2rem;
}
.profile-sections {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 1.5rem;
}
.stats-list {
  list-style: none;
  padding: 0;
}

/* ===== FOOTER ===== */
.site-footer {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 2px solid var(--color-border);
  text-align: center;
  transition: border-color 0.3s;
}
.footer-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 1rem;
}
.footer-links a {
  font-weight: 400;
  font-size: 0.9rem;
}
.footer-copyright p {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  transition: color 0.3s;
}

/* ===== BANNIÈRE ===== */
.banner {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 2rem;
  min-height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.banner-img,
.banner > img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

/* Voile adaptatif */
.banner::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(248, 245, 242, 0.65); /* clair */
  transition: background 0.3s;
  z-index: 1;
}

body.dark-mode .banner::before {
  background: rgba(0, 0, 0, 0.55); /* sombre */
}

.banner-overlay {
  position: relative;
  z-index: 2;
  color: var(--color-heading);
  padding: 1rem;
}

.banner h2 {
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
}

.banner p {
  font-size: 1rem;
}


/* .forum-item {
    display: grid;
    grid-template-columns: 48px minmax(0, 3fr) minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1.5fr);
    gap: 16px;
    align-items: center;
    padding: 16px;
}

.forum-item:first-of-type {
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}
.forum-item:last-of-type {
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    margin-bottom: 0;
}
.forum-item:only-of-type {
    border-radius: 8px;
} */

.forum-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: block;
}

/* .forum-subject {
    font-size: 1.1rem;
    font-weight: 700;
    text-decoration: none;
    line-height: 1.4;
}
.forum-subject:hover {
    text-decoration: underline;
}

.forum-author,
.forum-messages,
.forum-last-message {
    font-size: 0.9rem;
}

.forum-author a {
    font-weight: 600;
    text-decoration: none;
}
.forum-author a:hover {
    text-decoration: underline;
}

.forum-messages {
    text-align: center;
}

.forum-last-message {
    text-align: right;
    white-space: nowrap;
} */

/* ===== Balisage généré par Forum.php : .forum-section > a > h2.forum-header + .forum-item ===== */
/* Les règles .forum-item ci-dessus sont en commentaire : auteur, nombre de messages et date
   n'avaient aucun style. Sujet sur la première ligne, puis auteur, messages et dernier message
   (cf. docs/forums_generation.md §7). */
.forum-section > a {
  display: block;
}
.forum-section > a:hover {
  text-decoration: none;
}
.forum-section > a:hover > .forum-header {
  color: var(--color-primary);
}
.forum-item {
  display: grid;
  grid-template-columns: 48px auto auto minmax(0, 1fr);
  column-gap: 1rem;
  row-gap: 0.25rem;
  align-items: baseline;
}
.forum-item .forum-avatar {
  grid-column: 1;
  grid-row: 1 / span 2;
  align-self: center;
  object-fit: cover;
}
.forum-subject {
  grid-column: 2 / -1;
  grid-row: 1;
  line-height: 1.4;
  min-width: 0;
  overflow-wrap: anywhere;
}
.forum-author,
.forum-messages,
.forum-last-message {
  grid-row: 2;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--color-text-muted);
}
.forum-author {
  grid-column: 2;
  min-width: 0;
  overflow-wrap: break-word;
}
.forum-author a {
  color: var(--color-text);
}
.forum-messages {
  grid-column: 3;
  white-space: nowrap;
}
.forum-last-message {
  grid-column: 4;
  text-align: right;
}

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

/* Fil d'Ariane généré : liens et séparateurs posés directement dans .site-container */
.site-container > .breadcrumb-item,
.site-container > .breadcrumb-separator {
  font-size: 0.9rem;
}
.site-container > .breadcrumb-separator {
  margin: 0 0.4rem;
  color: var(--color-text-muted);
}
.main-content {
  margin-top: 1.25rem;
}

/* En-tête : le nom du site passe à la ligne au lieu de pousser le menu hors de l'écran */
.site-header {
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
}
.logo {
  flex: 1 1 22rem;
  min-width: 0;
}
.logo-img {
  flex-shrink: 0;
  object-fit: contain;
}
.logo h1 {
  line-height: 1.25;
  min-width: 0;
  overflow-wrap: anywhere;
}
.main-nav {
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
}

/* Contenu des messages : textes longs, images et vidéos intégrées */
.page-title {
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.post-author,
.post-body {
  min-width: 0;
}
.post-body {
  overflow-wrap: anywhere;
}
.post-content img,
.post-content video,
.post-content iframe {
  max-width: 100%;
}
.post-content img,
.post-content video {
  height: auto;
}
.post-content iframe {
  height: auto;
  aspect-ratio: 16 / 9;
}
.post-content pre {
  white-space: pre-wrap;
}
.footer-links,
.pagination {
  flex-wrap: wrap;
}
.reply-form {
  margin-top: 1.5rem;
}

/* ===== MOBILE ===== */
@media (max-width: 800px) {
  .logo h1 {
    font-size: 1.5rem;
  }
}

/* Écran étroit : pseudo, messages et date passent à la ligne sans être coupés ;
   l'auteur du message passe au-dessus du texte */
@media (max-width: 680px) {
  .forum-item {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: 0.75rem;
    padding-left: calc(40px + 0.75rem);
  }
  .forum-item .forum-avatar {
    position: absolute;
    top: 0.75rem;
    left: 0;
    width: 40px;
    height: 40px;
  }
  .forum-item:first-of-type .forum-avatar {
    top: 0;
  }
  .forum-subject,
  .forum-last-message {
    flex: 1 1 100%;
    text-align: left;
  }
  .forum-messages {
    margin-left: auto;
  }
  .post {
    flex-direction: column;
    gap: 0.75rem;
  }
  .post-author {
    width: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-align: left;
  }
  .post-author .avatar {
    display: block;
    width: 44px;
    height: 44px;
    margin-bottom: 0;
  }
}

@media (max-width: 600px) {
  .site-container {
    padding: 1rem;
  }
  .site-header {
    margin-bottom: 1.25rem;
  }
  .logo {
    gap: 0.75rem;
  }
  .logo h1 {
    font-size: 1.4rem;
  }
  .main-nav {
    gap: 0.5rem 1.25rem;
  }
  .banner {
    min-height: 180px;
    padding: 1.25rem 1rem;
  }
  .banner-overlay {
    padding: 0;
  }
  .banner h2 {
    font-size: 1.35rem;
    line-height: 1.3;
  }
  .page-title {
    font-size: 1.5rem;
    margin-bottom: 1.25rem;
  }
  .forum-section,
  .post,
  .reply-form,
  .profile-header,
  .profile-section {
    padding: 1rem;
  }
  .forum-header {
    font-size: 1.15rem;
  }
  .profile-header {
    flex-wrap: wrap;
    gap: 1rem;
  }
  .profile-info {
    min-width: 0;
  }
  .profile-info h1 {
    font-size: 1.5rem;
    overflow-wrap: anywhere;
  }
  .profile-sections {
    grid-template-columns: minmax(0, 1fr);
  }
  .footer-links {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
  }
}

/* Très petit écran : titre sur toute la largeur, petit avatar devant le pseudo */
@media (max-width: 359px) {
  .forum-item {
    padding-left: 0;
  }
  .forum-item .forum-avatar {
    position: static;
    align-self: center;
    width: 24px;
    height: 24px;
  }
  .forum-subject {
    order: -1;
  }
}
