/* --- COLOR CONSTANTS (START) --- */

:root {
    --global-font: "Pangolin", Arial, sans-serif;
    --global-font-size: 14px;
    --global-font-color: var(--darkindigo);
    --lighterindigo: #736BB3;
    --lightblue: #7EABC9;
    --lightgreen: #64B997;
    --lightred: #B95062;
    --lightyellow: #DAC758;
    --darkindigo: #1E1C36;
    --trans-white: rgba(255, 255, 255, 0.65);
    --pink: #f4c5cf; 
    --pink-dark: #df9cab;
    --tape-gray: #dbd8cb;
    --tape-edge-gray: #b9b4a4;
    --purple: #5C3890;
    --lightpurple: #AA89D1;
    --green: #2f9941;
}

/* --- WEBSITE FONTS (START) --- */

@font-face { /* font for usual text */
    font-family: "Pangolin";
    src: url("../font/Pangolin.ttf") format("truetype");
}

/* --- resetting formatting! (START) -- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: unset;
    font-size: initial;
}

b, i, strong, em {
    font-weight: unset;
    font-style: normal;
}

body {
    overflow-x: hidden;
    font-family: var(--global-font);
    font-size: var(--global-font-size);
    color: var(--global-font-color);
    line-height: 1.5;
    letter-spacing: 0.5px;
    cursor: url("../images/souris/souris.png") 16 16, auto;

    background-image: url("../graphics/site/bg/grass_02.jpg");
    background-attachment: fixed;
    background-size: cover; 
    background-repeat: repeat;

    display: flex;
    justify-content: center;
    align-items: flex-start;
}

body.is-gallery .card {
	height: auto;
	min-height: clamp(420px, 72vh, 760px);
	max-height: none;
	background: rgba(246, 243, 235, 0.82);
	border: 4px solid var(--lighterindigo);
	border-radius: 8px;
	box-shadow: 4px 4px 0 rgba(30, 28, 54, 0.24);
	overflow: visible;
}

body.is-gallery .card__content {
	overflow: visible;
	padding: clamp(0.75rem, 2vw, 1.25rem);
}

a,
button,
input,
label {
    cursor: url("../images/souris/souris.png") 16 16, pointer;
}

p {
    margin: 10px 0px;  
    font-size: clamp(0.95rem, 1.25vw, 1.15rem);
}
b, strong{
    font-weight: 900;
    color:var(--green);
}

i, em {
    font-style: italic;
    color: #8aceff;
}

div {
    background: none;
    border: none;
    margin: 1em 0;
    padding: 0 1em;
}

#main-container {
    width: 100%;
    max-width: 1200px;
    margin: clamp(24px, 8vh, 60px) auto;
    padding: 0
}

#upper-container {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto;
    column-gap: clamp(6px, 1.5vw, 12px);
    row-gap: 0;
    align-items: center;
    width: 100%;
    margin: 0 0 0;
    padding: 0;
}

#message {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    margin: 0;
    padding: 0;
    text-align: right;
}

.welcome-gif {
    display: block;
    max-width: min(100%, 280px);
    height: auto;
    margin-left: auto;
}

#middle-container {
    display: grid;
    grid-template-columns: minmax(140px, 0.85fr) minmax(260px, 1.7fr) minmax(140px, 0.85fr);
    grid-template-rows: 1fr;
    /* MODIFIÉ : Le gap s'adapte à la fois à la largeur (vw) et à la hauteur (vh) */
    gap: clamp(8px, 1vw + 1vh, 30px); 
    width: 100%;
    align-items: stretch;
    max-height: 65vh;
}

/* right container */
#right-container {
    display: flex;
    flex-direction: column;
    gap: clamp(6px, 1.5vh, 18px);
    overflow: hidden;
}

#right-container > div {
    margin-top: 0;
    margin-bottom: 0;
}


#left-container {
    /* MODIFIÉ : Réduit l'espace vertical ici aussi */
    --left-gap: clamp(6px, 1.5vh, 18px);
    display: flex;
    flex-direction: column;
    gap: var(--left-gap);
    overflow: hidden;
}

/* remove gap between 2nd and 3rd child of left container */
#left-container > *:nth-child(3) {
    margin-top: calc(-1 * var(--left-gap));
}


#center-container {
    justify-self: stretch;
    overflow: hidden;
}

#footer-container, #message-container, #visitor-count, #chat-container {
    background: var(--trans-white);
    border: 5px solid var(--lighterindigo);
    border-radius: 8px;
    padding: clamp(10px, 1.8vw, 16px);
    box-shadow: 4px 4px 0 rgba(30, 28, 54, 0.24);
    font-family: var(--global-font);
}

#footer-container{
    border-color: var(--lightgreen);
    padding: clamp(0px, 0.5vw, 10px);
    margin: 0 clamp(10px, 1.8vw, 16px);
}

/* Left column layout: visitor-count takes its own height, chat and message share remaining space */
#left-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

#visitor-count {
    border-color: var(--lightblue);
    flex: 0 0 auto; /* take the height it needs */
}

#chat-container{
    border-color: var(--lightyellow);
    padding: 0;
    flex: 1 1 0; /* share remaining space */
    min-height: 0; /* allow flex children to shrink properly */
}

#message-container {
    border-color: var(--lightred);
    overflow: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--lightred) transparent;
    flex: 1 1 0; /* share remaining space */
    min-height: 0;
}

#footer-container {
    text-align: center;
}

footer {
    margin: 0;
    padding: 0 1em;
}

body.is-gallery #main-container {
    width: 100vw !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 20px !important;
}

body.is-gallery #middle-container {
    grid-template-rows: auto !important; /* Libère la hauteur pour la galerie */
    max-height: none !important;
}

body.is-gallery #center-container {
    height: auto !important;
    overflow: visible !important;
}
body.is-gallery #right-container {
    display: none;
}


/* 2. Sur PC, on force le centre à occuper son espace ET celui de la droite */
@media (min-width: 769px) {
    body.is-gallery #center-container {
        grid-column: 2 / -1; /* Commence à la colonne 2 et s'étire jusqu'au bord droit */
    }
}

#funny-thing {
    display: flex;
    justify-content: center;
    align-items: flex-end; /* 1. Aligne le chat tout en bas de la div */
    margin: 0;
    padding: 0;
    width: 100%;
    
    /* 2. OBLIGATOIRE : Donne une hauteur à ta div parente (ex: 400px, 50vh, etc.) */
    height: 300px; 
    
    /* 3. Sécurité : Empêche quoi que ce soit de déborder physiquement */
    overflow: hidden; 
}

.cat_image {
    height: 100%;          /* Prend toute la hauteur de #funny-thing (300px ici) */
    width: auto;           /* S'adapte proportionnellement */
    max-height: 100%;      /* Ne dépasse jamais la hauteur du parent */
    
    aspect-ratio: 3 / 4;   
    object-fit: cover;
    object-position: center bottom; 
    
    /* vertical-align: bottom; -> Supprimé car inutile avec align-items: flex-end */
}

.marquee {
  position: relative;
  overflow: hidden;
  width: calc(100% - 4em);
  height: 50px;
  margin: 0 2em;
  box-sizing: border-box;
}

.marquee__set {
  position: absolute;
  padding-left: 0;
  top: 0;
  display: flex;
  gap: 1rem;
  margin-left: 0;
  white-space: nowrap;
}

.marquee__set img {
  width: auto;
  display: block;
}


/* ==========================================================================
   1. FORMAT MOBILE (Écrans jusqu'à 768px de large)
   ========================================================================== */
@media (max-width: 768px) {
    #middle-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto;    
        gap: clamp(16px, 4vw, 24px); 
        max-height: none !important; /* Libère la hauteur pour empiler les blocs */
    }

    #left-container,
    #right-container {
        width: 100%;
        max-height: none !important;
        height: auto !important;
        /* CORRIGÉ : On remet 'hidden' pour empêcher le contenu de dépasser de l'écran */
        overflow: hidden !important; 
    }

    #center-container {
        width: 100%;
        height: 65vh;                
        min-height: 350px;           
        max-height: 550px;           
        overflow: hidden !important; /* Garde le scroll interne pour la Story */
    }

    #chat-container,
    #message-container {
        min-height: 240px;
    }

    /* SÉCURITÉ : Empêche les longs codes ou liens de déformer la largeur du site */
    #left-container *, 
    #right-container * {
        max-width: 100%;
        word-break: break-all; /* Force les longs textes/HTML à se couper proprement */
    }

    .cat_image {
        width: 25vw;
        max-width: 120px;
        height: auto;
    }
}

/* ==========================================================================
   2. FORMAT PC UNIQUEMENT - Écrans courts (Largeur PC ET Hauteur basse)
   ========================================================================== */
@media (min-width: 769px) and (max-height: 660px) {
    #middle-container {
        max-height: none !important; 
    }

    #left-container,
    #right-container {
        max-height: none !important;
        height: auto !important;
        overflow: hidden !important; /* Protection ici aussi pour le PC */
    }

    #center-container {
        height: 55vh; 
        min-height: 280px;
        overflow: hidden !important; 
    }
}