@import url("https://fonts.googleapis.com/css2?family=Lora:wght@600&family=Lato:wght@400;700&display=swap");

:root {
  /* -- Couleurs de base -- */
  --color-background: #fffbeb;
  --color-surface: rgba(255, 253, 250, 0.8);
  --color-text: #78350f;
  --color-text-subtle: #b47f5a;
  --color-white: #ffffff;
  --color-black-transparent-strong: rgba(0, 0, 0, 0.5);
  --color-black-transparent-medium: rgba(0, 0, 0, 0.08);

  /* -- Couleurs d'accentuation -- */
  --color-accent-orange: #f59e0b;
  --color-accent-red: #38bdf8;
  --color-on-accent: #6f310e;
  --color-border: rgba(120, 53, 15, 0.15);
  
  /* -- Couleurs superpositions (overlays) -- */
  --color-hero-overlay: rgba(120, 53, 15, 0.8);

  /* -- Couleurs pour l'animation JS des feuilles -- */
  --leaf-color-1: #16a34a;
  --leaf-color-2: #22c55e;
  --leaf-color-3: #4ade80;
  --leaf-color-4: #86efac;
  
  /* -- Typographie (statique) -- */
  --font-serif: "Lora", serif;
  --font-sans: "Lato", sans-serif;
}

/* --- Base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  background-color: var(--color-background);
  font-family: var(--font-sans);
  color: var(--color-text);
  font-size: 16px;
  line-height: 1.7;
}
#falling-leaves-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}
.page-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px;
}
a {
  color: var(--color-accent-red);
  text-decoration: none;
  font-weight: 700;
}
a:hover {
  text-decoration: underline;
}
h1,
h2,
h3,
h4 {
  font-family: var(--font-serif);
}

/* --- Header, Footer, Breadcrumb --- */
.site-header,
.breadcrumb,
.category-card,
.site-footer,
.post-item,
.auth-form,
.profile-sidebar {
  background: var(--color-surface);
  backdrop-filter: blur(8px);
  border: 1px solid var(--color-border);
  border-radius: 12px;
}
.site-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px 24px;
  padding: 16px 24px;
  margin-bottom: 24px;
}
.logo-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  font-size: 1.5rem;
  line-height: 1.3;
  color: var(--color-text);
}
.logo-link span {
  min-width: 0;
  overflow-wrap: anywhere;
}
.logo {
  height: 32px;
  width: auto;
  max-width: 120px;
  flex-shrink: 0;
}
.main-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
}
.nav-link {
  font-weight: 700;
  color: var(--color-text-subtle);
}
.nav-link.active,
.nav-link:hover {
  color: var(--color-text);
  text-decoration: none;
}
.breadcrumb {
  padding: 12px 24px;
  margin-bottom: 32px;
  font-size: 0.9rem;
  font-weight: 700;
}
.breadcrumb span a {
  color: var(--color-text-subtle);
}
.breadcrumb span a:hover {
  color: var(--color-text);
}
.breadcrumb span:last-child {
  color: var(--color-text);
}
.breadcrumb span:not(:last-child)::after {
  content: "›";
  margin: 0 8px;
  color: var(--color-text-subtle);
}
/* Fil d'Ariane généré par Forum.php : a.breadcrumb-item + span.breadcrumb-separator */
.breadcrumb .breadcrumb-item {
  color: var(--color-text-subtle);
}
.breadcrumb .breadcrumb-item:last-child {
  color: var(--color-text);
}
.breadcrumb-separator {
  margin: 0 8px;
  color: var(--color-text-subtle);
}
.breadcrumb span.breadcrumb-separator::after {
  content: none;
}
.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px 32px;
  padding: 32px;
  margin-top: 48px;
  color: var(--color-text-subtle);
  font-size: 0.9rem;
}
.footer-column h4 {
  color: var(--color-text);
  font-weight: 600;
  margin-bottom: 8px;
}
.footer-column a {
  color: var(--color-text-subtle);
  font-weight: 400;
  display: block;
  padding: 4px 0;
}
.footer-column a:hover {
  color: var(--color-text);
}
.footer-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
}
.footer-nav a {
  color: var(--color-text);
}

/* --- Structure de page --- */
.page-title {
  font-size: 2.5rem;
  line-height: 1.3;
  margin-bottom: 24px;
  font-family: var(--font-serif);
  overflow-wrap: anywhere;
}
.page-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px 24px;
  margin-bottom: 16px;
}
.nav-button {
  background-color: var(--color-accent-red);
  color: var(--color-on-accent);
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 800;
  text-decoration: none;
  border: none;
  cursor: pointer;
}
.nav-button:hover {
  background-color: var(--color-text);
  color: var(--color-background);
  text-decoration: none;
}

.hero-banner {
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  margin-bottom: 48px;
}
.banner-image {
  width: 100%;
  display: block;
}
.hero-text {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 32px;
  background: linear-gradient(to top, var(--color-hero-overlay), transparent);
}
.hero-text h1 {
  font-size: 2.5rem;
  color: var(--color-white);
  text-shadow: 1px 1px 5px var(--color-black-transparent-strong);
}

/* --- Listes --- */
.category-card {
  padding: 32px;
  margin-bottom: 32px;
}
.category-card h2 {
  font-size: 1.8rem;
  margin-bottom: 24px;
}
.category-card h2 a {
  color: var(--color-text);
  text-decoration: none;
}
.category-card h2 a:hover {
  color: var(--color-accent-red);
}
.thread-list {
  display: flex;
  flex-direction: column;
}
.thread-item {
  position: relative;
  padding: 16px 0;
  border-top: 1px solid var(--color-border);
}
.thread-item:first-child {
  border-top: none;
  padding-top: 0;
}
.thread-item:hover .thread-title a {
  color: var(--color-accent-orange);
}
.thread-link-cover {
  color: var(--color-text);
  text-decoration: none;
  transition: color 0.2s ease;
}
.thread-link-cover::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
}
.thread-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.thread-meta {
  font-size: 0.9rem;
  color: var(--color-text-subtle);
}
.thread-meta a {
  position: relative;
  z-index: 2;
  color: var(--color-text);
  text-decoration: none;
}
.thread-meta a:hover {
  color: var(--color-accent-red);
  text-decoration: underline;
}
.thread-meta strong {
  font-weight: 700;
}
.category-list-full a.category-card {
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.category-list-full a.category-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 15px var(--color-black-transparent-medium);
}

/* --- Page de Sujet & Profil --- */
.post-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 32px;
}
.post-item {
  display: flex;
  gap: 16px;
  padding: 24px;
}
.post-author {
  flex-shrink: 0;
  text-align: center;
  width: 150px;
  overflow-wrap: anywhere;
}
.post-author a {
  color: var(--color-text);
  text-decoration: none;
}
.post-avatar {
  display: block;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  margin: 0 auto 8px;
}
.post-content {
  flex: 1;
  min-width: 0;
  padding-left: 16px;
  border-left: 1px solid var(--color-border);
  overflow-wrap: anywhere;
}
.post-content a {
  color: var(--color-text);
  text-decoration: underline;
  text-decoration-color: var(--color-accent-red);
}
.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;
}
.profile-grid {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  align-items: start;
  gap: 32px;
}
.profile-sidebar {
  padding: 32px;
  margin-bottom: 0;
  text-align: center;
}
.profile-avatar {
  display: block;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto 16px;
}
.profile-sidebar h1 {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.profile-rank {
  color: var(--color-text-subtle);
  margin-bottom: 16px;
  overflow-wrap: anywhere;
}
.profile-sidebar hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 16px 0;
}
.profile-stats {
  list-style: none;
  text-align: left;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}
.profile-main .category-card {
  margin-bottom: 0;
}
.profile-main h2 {
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.profile-main .category-card > h4 {
  font-size: 1.15rem;
  line-height: 1.3;
  margin-bottom: 4px;
}
.profile-activity + h4 {
  margin-top: 24px;
}
/* Membre sans sujet ou sans réponse : intitulé masqué */
.profile-main .category-card > h4:has(+ .profile-activity:empty),
.profile-activity:empty {
  display: none;
}
/* Derniers sujets et réponses générés par Forum.php : div > h4.comment-thread-title + .comment-date + .comment */
.profile-activity > div {
  min-width: 0;
  padding: 12px 0;
  border-top: 1px solid var(--color-border);
  overflow-wrap: anywhere;
}
.profile-activity > div:first-child {
  border-top: none;
  padding-top: 8px;
}
.comment-thread-title {
  font-size: 1.05rem;
  line-height: 1.4;
}
.comment-thread-title a {
  color: var(--color-text);
}
.comment-thread-title a:hover {
  color: var(--color-accent-red);
}
.comment-date {
  font-size: 0.85rem;
  color: var(--color-text-subtle);
}
.comment {
  margin-top: 4px;
  font-size: 0.95rem;
}
.comment img,
.comment video,
.comment iframe {
  max-width: 100%;
}
.comment img,
.comment video {
  height: auto;
}
.comment iframe {
  height: auto;
  aspect-ratio: 16 / 9;
}
.comment pre {
  white-space: pre-wrap;
}
@media (max-width: 860px) {
  .profile-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }
  .profile-sidebar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 20px;
    align-items: center;
    text-align: left;
  }
  .profile-avatar {
    grid-row: 1 / span 2;
    margin: 0;
  }
  .profile-sidebar h1 {
    align-self: end;
  }
  .profile-rank {
    align-self: start;
    margin-bottom: 0;
  }
  .profile-sidebar hr,
  .profile-stats {
    grid-column: 1 / -1;
  }
}

/* --- Auth --- */
.auth-container {
  max-width: 450px;
  margin-top: 10vh;
  text-align: center;
}
.auth-container .logo-link {
  justify-content: center;
  margin-bottom: 24px;
}
.auth-form {
  padding: 32px;
}
.auth-form h2 {
  font-family: var(--font-serif);
  font-size: 2rem;
  margin-bottom: 24px;
}
.form-group {
  margin-bottom: 16px;
  text-align: left;
}
.form-group label {
  font-weight: 700;
  margin-bottom: 4px;
  display: block;
}
.form-group input {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-background);
  font-family: var(--font-sans);
  font-size: 1rem;
}
.auth-form .nav-button {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  margin-top: 8px;
}
.auth-switch {
  text-align: center;
  margin-top: 24px;
  font-size: 0.9rem;
  color: var(--color-text-subtle);
}
.auth-switch a {
  color: var(--color-accent-red);
}

.category-list-full {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  margin-top: 32px;
}

.category-list-full .category-card {
  padding: 24px;
  margin-bottom: 0;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.category-list-full .category-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 15px var(--color-black-transparent-medium);
}

.category-list-full .category-card h2 {
  font-size: 1.5rem;
  margin-bottom: 8px;
  padding-bottom: 0;
  border-bottom: none;
  color: var(--color-text);
}

.category-list-full .category-card p {
  font-size: 0.95rem;
  color: var(--color-text-subtle);
  margin: 0;
}

@media (min-width: 768px) {
  .category-list-full {
    grid-template-columns: repeat(2, 1fr);
  }
}
/* --- Pagination --- */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 32px;
}

.page-item,
.page-link,
.current-page,
.page-item-separator {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--color-text-subtle);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  backdrop-filter: blur(8px);
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.page-item:hover,
.page-link:hover {
  border-color: var(--color-accent-orange);
  color: var(--color-text);
  text-decoration: none;
}

.page-item.active,
.current-page {
  background-color: var(--color-accent-red);
  color: var(--color-on-accent);
  pointer-events: none;
}

.page-item-separator {
  background: transparent;
  border: none;
  backdrop-filter: none;
  box-shadow: none;
}


/* .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 : les fils s'affichaient en texte brut.
   Même rendu que .category-card / .thread-item de ce modèle (cf. docs/forums_generation.md §7). */
.forum-section {
  background: var(--color-surface);
  backdrop-filter: blur(8px);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 32px;
  margin-bottom: 32px;
}
/* Catégorie sans aucun fil : masquée */
.forum-section:has(> a > .forum-header):not(:has(.forum-item)) {
  display: none;
}
.forum-section > a {
  display: block;
  margin-bottom: 16px;
  color: var(--color-text);
}
.forum-section > a > .forum-header {
  font-size: 1.8rem;
  line-height: 1.3;
  color: var(--color-text);
  overflow-wrap: anywhere;
}
.forum-item {
  display: grid;
  grid-template-columns: 64px auto auto minmax(0, 1fr);
  row-gap: 2px;
  align-items: baseline;
  padding: 16px 0;
  border-top: 1px solid var(--color-border);
}
.forum-section > a + .forum-item {
  border-top: none;
  padding-top: 0;
}
.forum-item:last-child {
  padding-bottom: 0;
}
.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;
  min-width: 0;
  font-size: 1.1rem;
  line-height: 1.4;
  color: var(--color-text);
  overflow-wrap: anywhere;
}
.forum-author,
.forum-messages,
.forum-last-message {
  grid-row: 2;
  min-width: 0;
  font-size: 0.9rem;
  color: var(--color-text-subtle);
}
.forum-author {
  grid-column: 2;
  overflow-wrap: anywhere;
}
.forum-author a {
  color: var(--color-text);
}
.forum-messages {
  grid-column: 3;
  white-space: nowrap;
}
.forum-last-message {
  grid-column: 4;
}
.forum-messages::before,
.forum-last-message::before {
  content: "·";
  margin: 0 8px;
}
/* Page catégorie : la liste est déjà dans une .category-card et le h1 reprend le nom */
.category-card > .forum-section {
  background: none;
  backdrop-filter: none;
  border: none;
  border-radius: 0;
  padding: 0;
  margin: 0;
}
.category-card > .forum-section > a:has(> .forum-header) {
  display: none;
}

/* --- Mobile --- */
@media (max-width: 600px) {
  .page-container {
    padding: 16px;
  }
  .site-header {
    padding: 14px 16px;
  }
  .logo-link {
    font-size: 1.2rem;
  }
  .main-nav {
    width: 100%;
    gap: 6px 20px;
    padding-top: 10px;
    border-top: 1px solid var(--color-border);
  }
  .breadcrumb {
    padding: 10px 16px;
    margin-bottom: 24px;
  }
  .hero-banner {
    margin-bottom: 24px;
  }
  .page-title {
    font-size: 1.7rem;
  }
  .category-card,
  .forum-section {
    padding: 20px 16px;
    margin-bottom: 24px;
  }
  .forum-section > a > .forum-header {
    font-size: 1.5rem;
  }
  .forum-item {
    grid-template-columns: 52px auto auto minmax(0, 1fr);
  }
  .forum-item .forum-avatar {
    width: 40px;
    height: 40px;
    grid-row: 1 / span 3;
    align-self: start;
    margin-top: 2px;
  }
  .forum-subject {
    font-size: 1rem;
  }
  .forum-last-message {
    grid-column: 2 / -1;
    grid-row: 3;
  }
  .forum-last-message::before {
    content: none;
  }
  .post-list {
    margin-top: 16px;
  }
  .post-item {
    flex-direction: column;
    gap: 12px;
    padding: 16px;
  }
  .post-author {
    width: auto;
    text-align: left;
  }
  .post-author a {
    display: flex;
    align-items: center;
    gap: 12px;
  }
  .post-avatar {
    width: 40px;
    height: 40px;
    margin: 0;
    flex-shrink: 0;
  }
  .post-content {
    padding-left: 0;
    padding-top: 12px;
    border-left: none;
    border-top: 1px solid var(--color-border);
  }
  .profile-sidebar {
    column-gap: 16px;
    margin-bottom: 0;
  }
  .profile-avatar {
    width: 72px;
    height: 72px;
  }
  .profile-sidebar h1 {
    font-size: 1.5rem;
  }
  .profile-main h2 {
    font-size: 1.5rem;
    margin-bottom: 16px;
  }
  .site-footer {
    flex-direction: column;
    text-align: center;
    padding: 24px 16px;
    margin-top: 32px;
  }
  .footer-nav {
    justify-content: center;
  }
}
