@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@500;700;900&display=swap');

:root {
  /* Palette de couleurs */
  --color-background: #111111;
  --color-surface: #1e1e1e;
  --color-text-primary: #ffffff;
  --color-text-secondary: #aaaaaa;
  --color-accent-green: #107c10;
  --color-accent-green-bright: #9bf00b;
  --color-border: #333333;
  --color-on-accent: #ffffff;

  /* Couleur pour JS (RGB) */
  --js-particle-color: 155, 240, 11;

  /* Typographie (fixe) */
  --font-ui: 'Montserrat', sans-serif;

  /* Autres (fixe) */
  --border-radius: 4px;
}

/* ---=== Initialisation & Styles Généraux ===--- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--color-background);
    color: var(--color-text-primary);
    font-family: var(--font-ui);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

#vortex-background {
    position: fixed;
    top: 0;
    left: 0;
    z-index: -1;
}

a {
    color: var(--color-text-primary);
    text-decoration: none;
}

a:hover {
    color: var(--color-accent-green-bright);
}

/* ---=== Structure principale ===--- */
.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* ---=== Header ===--- */
.site-header {
    display: flex;
    align-items: center;
    padding-bottom: 1rem;
    margin-bottom: 2rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-weight: 900;
    font-size: 1.8rem;
}

.logo img {
    height: 40px;
    flex-shrink: 0;
}

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

.main-nav {
    display: flex;
    gap: 2rem;
    margin-left: 3rem;
}

.nav-link {
    font-weight: 700;
    white-space: nowrap;
    color: var(--color-text-secondary);
    transition: color 0.2s;
}

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

.login-button {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-left: auto;
    padding-left: 2rem;
    font-weight: 700;
    white-space: nowrap;
}

.login-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--color-accent-green);
}

/* ---=== Contenu Principal & Tuiles ===--- */
.main-content {
    margin-top: 1rem;
}

.breadcrumb {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-text-secondary);
    margin: 2rem 0;
}

.breadcrumb a {
    color: var(--color-text-secondary);
}

.breadcrumb a:hover {
    color: var(--color-text-primary);
}

.breadcrumb span:not(:last-child)::after {
    content: ' /';
    margin-right: 0.5rem;
}

/* Le séparateur généré porte déjà « > » */
.breadcrumb .breadcrumb-separator {
    margin: 0 0.5rem;
}

.breadcrumb span.breadcrumb-separator::after {
    content: none;
}

.page-title {
    font-size: 1.8rem;
    font-weight: 900;
    margin-bottom: 1.5rem;
}

.tile {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
}

.tile:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    border-color: var(--color-accent-green-bright);
}

.tile-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 1rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
}

.banner-tile {
    display: block;
    margin-bottom: 2.5rem;
}

/* La bannière générée est une balise <img> sans classe */
.banner-tile img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 300px;
    object-fit: cover;
}

/* Bandeau sans texte : le moteur ne remplit pas ce titre */
.tile-overlay:has(> h3:empty) {
    display: none;
}

/* ---=== Groupes de Catégories (Homepage) ===--- */
.tiles-grid {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

.category-title {
    font-size: 1.2rem;
    font-weight: 900;
    margin-top: 1rem;
    margin-bottom: 1rem;
}

.category-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.thread-tile {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    height: 150px;
}

.tile-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: block;
}

.tile-meta {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
}

.tile-meta a {
    color: var(--color-text-secondary);
    font-weight: 700;
}

.tile-meta a:hover {
    color: var(--color-accent-green-bright);
}

.tile-stat {
    position: absolute;
    top: 0.8rem;
    right: 0.8rem;
    background-color: var(--color-accent-green);
    color: var(--color-text-primary);
    padding: 0.3rem 0.6rem;
    border-radius: var(--border-radius);
    font-size: 0.8rem;
    font-weight: 700;
}

.category-tile {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--color-accent-green);
    height: 150px;
}

.category-tile h4 {
    font-size: 1.5rem;
    font-weight: 900;
}

/* ---=== Page Categories ===--- */
.category-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.category-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
}

.category-item-title {
    font-size: 1.2rem;
    font-weight: 900;
    display: block;
    margin-bottom: 0.5rem;
}

.category-description {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    text-transform: none;
}

.category-stats {
    text-align: right;
    flex-shrink: 0;
    margin-left: 2rem;
}

.category-stats span {
    display: block;
    font-weight: 700;
}

.category-stats span:first-child {
    color: var(--color-accent-green-bright);
    font-size: 1.1rem;
}

.pagination {
    margin-top: 2rem;
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

.pagination-link {
    font-weight: 700;
    padding: 0.5rem 1rem;
    border: 1px solid var(--color-border);
    background-color: var(--color-surface);
}

.pagination-link.active {
    background-color: var(--color-accent-green);
    border-color: var(--color-accent-green);
}

/* Pagination générée : span.current-page + a.page-link */
.pagination .page-link,
.pagination .current-page {
    font-weight: 700;
    padding: 0.5rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    background-color: var(--color-surface);
}

.pagination .current-page {
    background-color: var(--color-accent-green);
    border-color: var(--color-accent-green);
    color: var(--color-on-accent);
}

/* ---=== Page Category ===--- */
.thread-list-view {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.thread-item {
    padding: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.thread-item-title {
    font-size: 1.1rem;
    font-weight: 700;
}

.thread-item-meta {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    margin-top: 0.5rem;
}

/* ---=== Page Thread ===--- */
.thread-header {
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 1rem;
}

.thread-header h1 {
    font-size: 2rem;
    font-weight: 900;
    overflow-wrap: anywhere;
}

.thread-header p {
    color: var(--color-text-secondary);
    margin-top: 0.5rem;
}

.post-card {
    display: flex;
    gap: 1.5rem;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.post-author {
    flex: 0 0 190px;
    min-width: 0;
    text-align: center;
    overflow-wrap: anywhere;
}

.author-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px solid var(--color-accent-green);
}

.author-name {
    display: block;
    margin-top: 0.8rem;
    font-weight: 700;
    font-size: 0.95rem;
}

.author-rank {
    font-size: 0.8rem;
    color: var(--color-accent-green-bright);
}

.author-rank:empty {
    display: none;
}

.post-body {
    border-left: 1px solid var(--color-border);
    padding-left: 1.5rem;
    flex-grow: 1;
    min-width: 0;
}

.post-meta {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    margin-bottom: 1rem;
}

.post-content {
    text-transform: none;
    font-weight: 500;
    font-size: 1.1rem;
    line-height: 1.7;
    /* Les messages sont du texte brut : on garde leurs retours à la ligne */
    white-space: pre-line;
    overflow-wrap: anywhere;
}

/* Médias des messages, sur le fil comme sur le profil */
.post-content img,
.post-content video,
.comment img,
.comment video {
    max-width: 100%;
    height: auto;
}

/* Le moteur entoure les vidéos de <br> : inutiles avec pre-line */
.post-content br:has(+ iframe),
.post-content iframe + br,
.comment br:has(+ iframe),
.comment iframe + br {
    display: none;
}

.post-content iframe,
.comment iframe {
    display: block;
    width: 100%;
    max-width: 560px;
    height: auto;
    aspect-ratio: 16 / 9;
    border: 0;
}

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

.post-content p {
    margin-bottom: 1em;
}

.post-content p a {
    color: var(--color-accent-green-bright);
}

/* ---=== PAGE USER ===--- */
.user-profile-header {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.user-profile-avatar {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 4px solid var(--color-accent-green);
    object-fit: cover;
}

.user-profile-info {
    min-width: 0;
    overflow-wrap: anywhere;
}

.user-profile-info h1 {
    font-size: 2.2rem;
    font-weight: 900;
    line-height: 1.2;
}

.user-profile-rank {
    color: var(--color-accent-green-bright);
    font-weight: 700;
    font-size: 1rem;
}

.user-score-card {
    margin-left: auto;
    text-align: right;
}

.score-label {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    font-weight: 700;
}

.score-value {
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--color-accent-green-bright);
    line-height: 1;
}

.user-page-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 2rem;
    align-items: flex-start;
}

.user-sidebar-column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.user-sidebar-column .category-title {
    margin-bottom: 0.5rem;
}

.about-me-tile {
    padding: 1.5rem;
    font-size: 1rem;
    text-transform: none;
    line-height: 1.7;
    color: var(--color-text-secondary);
    font-weight: 500;
}

.stats-tile ul {
    list-style: none;
    padding: 1.5rem;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.stats-tile li {
    font-weight: 700;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.3rem 1rem;
}

.stats-tile li strong {
    color: var(--color-text-secondary);
}

.about-me-tile + .category-title {
    margin-top: 2rem;
}

/* Activité récente : balisage généré par Forum.php (format_thread_preview / format_comment_preview).
   Chaque sujet ou réponse est une tuile : date, titre du fil, puis le message. */
.user-main-column .thread-list-view > h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 900;
    color: var(--color-text-secondary);
}

.user-main-column .thread-list-view > div + h3 {
    margin-top: 1rem;
}

.user-main-column .thread-list-view > div {
    min-width: 0;
    padding: 1rem 1.2rem;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-accent-green);
    border-radius: var(--border-radius);
    overflow-wrap: anywhere;
}

.comment-thread-title {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.4;
    text-wrap: pretty;
}

.comment-date {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
}

.comment-date + .comment-thread-title {
    margin-top: 0.3rem;
}

.comment-thread-title + .comment-date {
    margin-top: 0.2rem;
}

.comment {
    margin-top: 0.8rem;
    font-size: 0.95rem;
    line-height: 1.7;
    text-transform: none;
    /* Les messages sont du texte brut : on garde leurs retours à la ligne */
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.comment iframe {
    margin: 0.5rem 0;
}

.achievements-tile {
    padding: 1rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 1rem;
}

.achievement {
    width: 60px;
    height: 60px;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    cursor: pointer;
}

/* ---=== Pages Login & Register ===--- */
.auth-container {
    max-width: 450px;
    margin: 4rem auto;
    text-align: center;
}

.auth-form {
    padding: 2rem;
}

.auth-title {
    font-size: 1.5rem;
    font-weight: 900;
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.form-group input {
    width: 100%;
    padding: 0.8rem;
    background: var(--color-background);
    border: 1px solid var(--color-border);
    color: var(--color-text-primary);
    font-family: var(--font-ui);
    font-size: 1rem;
    border-radius: var(--border-radius);
}

.form-group input:focus {
    outline: none;
    border-color: var(--color-accent-green-bright);
}

.auth-button {
    width: 100%;
    padding: 1rem;
    background: var(--color-accent-green);
    color: var(--color-text-primary);
    border: none;
    font-family: var(--font-ui);
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 0.2s;
}

.auth-button:hover {
    background-color: var(--color-accent-green-bright);
    color: var(--color-background);
}

.auth-switch {
    margin-top: 1.5rem;
    color: var(--color-text-secondary);
}

.auth-switch a {
    color: var(--color-accent-green-bright);
    font-weight: 700;
}

/* ---=== Footer ===--- */
.site-footer {
    padding: 3rem 0;
    margin-top: 3rem;
    border-top: 1px solid var(--color-border);
}

.footer-grid {
    display: grid;
    /* Colonne du logo plus large : le nom du site ne se coupe pas */
    grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr));
    gap: 2rem;
}

.footer-column .logo {
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

.copyright {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    line-height: 1.5;
    text-wrap: pretty;
}

.footer-column h4 {
    font-weight: 900;
    font-size: 1rem;
    margin-bottom: 1rem;
}

.footer-column ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.footer-column ul a {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    transition: color 0.2s, padding-left 0.2s;
}

.footer-column ul a:hover {
    color: var(--color-accent-green-bright);
    padding-left: 5px;
}

/* ---=== Balisage généré par Forum.php : .forum-section > a > h2.forum-header + .forum-item ===--- */
/* Chaque fil est une tuile (comme .thread-tile) : avatar, sujet, auteur et date du dernier
   message, nombre de messages en pastille (comme .tile-stat). */
.forum-section {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.forum-section:has(> a > .forum-header):not(:has(.forum-item)) {
    display: none;
}

.forum-section > a {
    align-self: flex-start;
    max-width: 100%;
    margin-bottom: 0.4rem;
}

.forum-section > a > .forum-header {
    font-size: 1.2rem;
    font-weight: 900;
    color: var(--color-text-primary);
    padding-left: 0.8rem;
    border-left: 4px solid var(--color-accent-green);
    overflow-wrap: anywhere;
    transition: color 0.2s;
}

.forum-section > a:hover > .forum-header {
    color: var(--color-accent-green-bright);
}

.forum-item {
    display: grid;
    grid-template-columns: 48px fit-content(40%) minmax(0, 1fr) auto;
    column-gap: 1rem;
    row-gap: 0.4rem;
    align-items: center;
    padding: 1rem;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    transition: transform 0.2s ease-out, box-shadow 0.2s ease-out, border-color 0.2s;
}

.forum-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    border-color: var(--color-accent-green-bright);
}

.forum-avatar {
    grid-column: 1;
    grid-row: 1 / span 2;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--color-accent-green);
    object-fit: cover;
    display: block;
}

.forum-subject {
    grid-column: 2 / 4;
    grid-row: 1;
    min-width: 0;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.4;
    color: var(--color-text-primary);
    overflow-wrap: anywhere;
    text-wrap: pretty;
}

.forum-author,
.forum-last-message {
    grid-row: 2;
    min-width: 0;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    overflow-wrap: anywhere;
}

.forum-author {
    grid-column: 2;
}

.forum-author::before {
    content: "par ";
}

.forum-author a {
    color: var(--color-text-secondary);
    font-weight: 700;
}

.forum-author a:hover {
    color: var(--color-accent-green-bright);
}

.forum-last-message {
    grid-column: 3;
    text-wrap: pretty;
}

.forum-messages {
    grid-column: 4;
    grid-row: 1 / span 2;
    background-color: var(--color-accent-green);
    color: var(--color-on-accent);
    padding: 0.3rem 0.6rem;
    border-radius: var(--border-radius);
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
}

/* ---=== Mobile ===--- */
@media (max-width: 1150px) {
    /* Footer : le logo et le nom du site sur leur propre ligne */
    .footer-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .footer-column:first-child {
        grid-column: 1 / -1;
    }
}

/* Header : le logo sur sa ligne, la navigation et la connexion en dessous */
@media (max-width: 1000px) {
    .site-header {
        flex-wrap: wrap;
        row-gap: 1rem;
    }

    .site-header > .logo {
        flex: 1 1 100%;
        font-size: 1.5rem;
    }

    .main-nav {
        margin-left: 0;
    }
}

@media (max-width: 900px) {
    .post-card {
        flex-direction: column;
        gap: 1rem;
    }

    .post-author {
        flex: none;
        display: flex;
        align-items: center;
        gap: 0.8rem;
        text-align: left;
    }

    .post-author > a:first-child {
        flex-shrink: 0;
    }

    .author-avatar {
        display: block;
        width: 48px;
        height: 48px;
    }

    .author-name {
        margin-top: 0;
        min-width: 0;
    }

    .post-body {
        border-left: none;
        border-top: 1px solid var(--color-border);
        padding-left: 0;
        padding-top: 1rem;
    }

    .user-page-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    /* Liste des fils : la date passe sous l'auteur, la pastille reste à droite */
    .forum-item {
        grid-template-columns: 48px minmax(0, 1fr) auto;
    }

    .forum-avatar {
        grid-row: 1 / span 3;
    }

    .forum-subject,
    .forum-author,
    .forum-last-message {
        grid-column: 2;
    }

    .forum-last-message {
        grid-row: 3;
    }

    .forum-messages {
        grid-column: 3;
        grid-row: 1 / span 3;
    }
}

/* Liste des fils empilée : avatar et sujet, puis auteur et pastille, puis date */
@media (max-width: 700px) {
    .forum-item {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.5rem 0.8rem;
        padding: 0.8rem;
    }

    .forum-avatar {
        align-self: flex-start;
        width: 40px;
        height: 40px;
    }

    .forum-subject {
        flex: 1 1 calc(100% - 40px - 0.8rem - 1px);
        font-size: 0.9rem;
    }

    .forum-messages {
        margin-left: auto;
        padding: 0.2rem 0.5rem;
        font-size: 0.75rem;
    }

    .forum-last-message {
        flex: 1 1 100%;
    }
}

@media (max-width: 600px) {
    .main-container {
        padding: 1rem;
    }

    .site-header {
        margin-bottom: 1rem;
    }

    /* Un nom de domaine d'un seul mot tient sur une ligne */
    .site-header > .logo,
    .footer-column .logo {
        font-size: clamp(0.9rem, 4.6vw, 1.2rem);
    }

    .main-nav {
        gap: 1.2rem;
    }

    .nav-link,
    .login-button {
        font-size: 0.85rem;
    }

    .login-button {
        padding-left: 1rem;
    }

    .breadcrumb {
        margin: 1rem 0;
    }

    .page-title {
        font-size: 1.4rem;
        overflow-wrap: anywhere;
    }

    .thread-header h1 {
        font-size: 1.4rem;
    }

    .post-card {
        padding: 1rem;
    }

    .post-content {
        font-size: 1rem;
    }

    /* Profil : l'avatar reste à gauche du pseudo, en plus petit */
    .user-profile-header {
        gap: 1rem;
        padding: 1rem;
        margin-bottom: 1.5rem;
    }

    .user-profile-avatar {
        width: 64px;
        height: 64px;
        border-width: 3px;
    }

    /* Un pseudo d'un seul mot tient sur une ligne */
    .user-profile-info h1 {
        font-size: clamp(1.1rem, 5.5vw, 1.6rem);
    }

    .user-profile-rank {
        font-size: 0.85rem;
    }

    .user-main-column .thread-list-view > div {
        padding: 0.8rem 1rem;
    }

    .comment-thread-title {
        font-size: 0.9rem;
    }

    .footer-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Très petits écrans : la navigation et la connexion sur une seule ligne */
@media (max-width: 360px) {
    .logo {
        gap: 0.6rem;
    }

    .logo img {
        height: 32px;
    }

    .main-nav {
        gap: 0.9rem;
    }

    .nav-link,
    .login-button {
        font-size: 0.75rem;
    }

    .login-button {
        padding-left: 0.8rem;
    }

    /* La date du dernier message tient sur une ligne */
    .forum-last-message {
        font-size: 0.72rem;
        letter-spacing: 0;
    }
}
