/* public/css/stardew.css */

@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');

:root {
    --sdv-bg-dark: #2a2238;
    --sdv-panel: #ffcd86;
    --sdv-border: #6d4123;
    --sdv-highlight: #ffdfa4;
    --sdv-shadow: #b37b46;
    --sdv-text: #4a2810;
    --sdv-green: #6cac47;
    --sdv-red: #d94c4c;
}

/* Reset de base */
* {
    box-sizing: border-box;
}

body {
    background-color: var(--sdv-bg-dark);
    font-family: 'VT323', monospace;
    font-size: 1.4rem;
    color: var(--sdv-text);
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Aligné en haut sur PC */
    min-height: 100vh;
}

#commentList .comment-box p {
    margin-bottom: .25rem;
}
#commentList .comment-box small {
    display: block;
    margin-top: .35rem;
}

/* --- LE CONTENEUR PRINCIPAL --- */
.stardew-container {
    background-color: var(--sdv-panel);
    border: 4px solid var(--sdv-border);
    border-radius: 10px;
    box-shadow:
        inset 0 0 0 4px var(--sdv-highlight),
        inset 0 0 20px var(--sdv-shadow),
        8px 8px 0px rgba(0,0,0,0.5);
    padding: 2rem;
    width: 100%;
    max-width: 900px;
    height: fit-content;
    margin-top: 20px;
}

/* --- TITRES --- */
h1 {
    font-size: 2.2rem;
    text-align: center;
    margin-bottom: 1.5rem;
}

.elisa-tools-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.35rem;
    position: relative;
}

.elisa-tools-wrap h3 {
    margin: 0;
}

.elisa-tools-menu {
    position: relative;
}

.elisa-tools-menu summary {
    list-style: none;
    cursor: pointer;
    width: 1.9rem;
    height: 1.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f9edd2;
    border: 2px solid var(--sdv-border);
    border-radius: 6px;
    color: var(--sdv-text);
    font-size: 1.1rem;
    line-height: 1;
}

.elisa-tools-menu summary::-webkit-details-marker {
    display: none;
}

.elisa-tools-menu[open] summary {
    background: var(--sdv-highlight);
}

.elisa-tools-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 0.35rem);
    z-index: 30;
    width: 220px;
    padding: 0.7rem;
    background: #fff8e8;
    border: 2px solid var(--sdv-border);
    border-radius: 8px;
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.25);
    text-align: left;
}

.elisa-tools-panel label {
    display: block;
    font-size: 1.1rem;
    margin-bottom: 0.35rem;
}

.elisa-source-select {
    width: 100%;
    margin-bottom: 0.6rem;
    font-family: 'VT323', monospace;
    font-size: 1.2rem;
    background: #fff;
    border: 2px solid var(--sdv-border);
    padding: 0.3rem 0.45rem;
}

.elisa-logout-link {
    display: block;
    text-align: center;
    text-decoration: none;
    background: #7a4a2a;
    border: 2px solid #3e220e;
    color: #fff;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    font-size: 1.2rem;
}

.elisa-logout-link:hover {
    background: #8f5630;
}

/* --- GRILLE DES NOTES --- */
.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.notes-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.notes-filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 1.2rem;
}

.notes-filter-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    border-width: 2px;
}

.notes-filter-toggle input[type="checkbox"]:checked::after {
    font-size: 1rem;
}

/* --- CARTES DE NOTES (Style Saint-Valentin) --- */
.note-card {
    background: #fff8e1;
    border: 2px solid var(--sdv-border);
    padding: 1rem;
    position: relative;
    box-shadow: 4px 4px 0 rgba(0,0,0,0.2);
    transition: transform 0.2s;
    min-height: 150px;
    display: flex;
    flex-direction: column;
}

.note-card.is-hidden-note {
    opacity: 0.72;
    border-style: dashed;
}

.note-visibility-control {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.35rem;
}

.note-visibility-label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 1rem;
}

.note-hidden-toggle {
    width: 18px;
    height: 18px;
    border-width: 2px;
}

.note-hidden-toggle:checked::after {
    font-size: 1rem;
}

.note-card:hover {
    transform: rotate(-1deg) scale(1.02);
}

/* La punaise devient un Coeur Pixelisé */
.note-card::after {
    content: '❤';
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--sdv-red);
    font-size: 2rem;
    text-shadow: 2px 2px 0px rgba(0,0,0,0.1);
}

.note-content {
    flex-grow: 1;
    text-decoration: none;
    color: inherit;
    font-size: 1.3rem;
    word-wrap: break-word;
}

/* --- BOUTONS (Correction du décalage texte) --- */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    background: var(--sdv-border);
    color: #fff;
    padding: 0 1.2rem;
    height: 3rem; /* Hauteur fixe pour stabiliser le texte */
    border: 2px solid #3e220e;
    font-family: 'VT323', monospace;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 4px 4px 0 rgba(0,0,0,0.3);
    text-align: center;
    text-decoration: underline; /* Réactive le soulignage */
    text-underline-offset: 4px;   /* Optionnel : décolle un peu le trait du texte pour le style pixel */
    line-height: 0; /* Empêche le décalage vers le bas */
}

.button:active {
    box-shadow: 2px 2px 0 rgba(0,0,0,0.3);
    transform: translate(2px, 2px);
}

.btn-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    /* IMPORTANT : On force nos couleurs par dessus Bootstrap si besoin */
    background: var(--sdv-border) !important;
    color: #fff !important;

    padding: 0 1.2rem;
    height: 3rem;
    border: 2px solid #3e220e !important; /* Force la bordure marron */

    font-family: 'VT323', monospace;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 4px 4px 0 rgba(0,0,0,0.3);
    text-align: center;
    text-decoration: underline;
    text-underline-offset: 4px;
    line-height: 0;

    /* On annule les arrondis de Bootstrap */
    border-radius: 0 !important;
    transition: transform 0.1s;
}

.btn-submit:hover {
    transform: scale(1.02);
    background-color: #854e2b !important; /* Un marron un peu plus clair au survol */
    color: #fff;
}

.btn-submit:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 rgba(0,0,0,0.3);
}

/* --- FORMULAIRES --- */
textarea,
input:not([type="checkbox"]):not([type="radio"]) {
    width: 100%;
    border: 3px solid var(--sdv-border);
    padding: 12px;
    font-family: 'VT323', monospace;
    background: #fffbf0;
    font-size: 1.4rem;
    color: var(--sdv-text);
    margin-bottom: 1rem; /* Petit espace sous chaque champ */
}

/* --- STYLE CASE À COCHER (Remember me) --- */
.sdv-checkbox-group label {
    display: flex;
    align-items: center; /* Centre verticalement la case et le texte */
    justify-content: flex-start; /* Aligné à gauche (ou 'center' si tu préfères) */
    gap: 10px; /* Espace entre la case et le texte */
    font-size: 1.3rem;
    cursor: pointer;
    margin-bottom: 1.5rem;
}

input[type="checkbox"] {
    appearance: none; /* On retire le style par défaut moche */
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    background: #fffbf0;
    border: 3px solid var(--sdv-border);
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* La petite croix quand c'est coché */
input[type="checkbox"]:checked::after {
    content: 'X';
    color: var(--sdv-red);
    font-weight: bold;
    font-size: 1.4rem;
    font-family: 'VT323', monospace;
}

/* --- MEDIA QUERY MOBILE (Correction iPhone 12-17 / 350px) --- */
@media (max-width: 600px) {
    body {
        display: flex;
        align-items: center; /* Centre le menu verticalement sur mobile */
        justify-content: center;
        padding: 10px;
        min-height: 100vh;
    }

    .stardew-container {
        width: 100%;
        max-width: 340px;
        margin: 0;
        padding: 1.2rem;
        border-width: 3px;
        box-shadow: 4px 4px 0px rgba(0,0,0,0.5);
    }

    h1 {
        font-size: 1.8rem;
    }

    .elisa-tools-wrap {
        width: 100%;
        display: flex;
    }

    .elisa-tools-panel {
        right: 50%;
        transform: translateX(50%);
        width: min(220px, calc(100vw - 70px));
    }

    .notes-grid {
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
        width: 100%;
    }

    .notes-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .note-card {
        width: 100%;
        min-height: 140px;
    }

    .button {
        width: 100%;
        font-size: 1.6rem;
        height: 3.5rem; /* Un peu plus grand pour le confort tactile */
    }

    .note-card::after {
        font-size: 2rem;
        top: -18px;
    }
}

/* --- AJOUTS POUR LA SECTION COMMENTAIRES & LECTURE --- */

/* La note en mode lecture (plus aérée) */
.note-card.sdv-read-mode {
    cursor: default;
    transform: none !important; /* Pas de rotation sur la vue détail */
    max-width: 100%;
}

.note-card.sdv-read-mode:hover {
    transform: none !important;
}

/* Méta-données (Date) */
.note-meta {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 2px dashed var(--sdv-border); /* Ligne de séparation style ticket */
    font-size: 1rem;
    color: #6d4123;
}

/* --- GALERIE D'IMAGES --- */
.sdv-gallery {
    margin-top: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
}

.sdv-gallery-item {
    max-width: 48%; /* Sur PC : 2 images par ligne */
    flex: 1 1 45%;
}

.sdv-gallery-item img {
    width: 100%;
    height: auto;
    border-radius: 4px;
    border: 2px solid var(--sdv-border);
    box-shadow: 2px 2px 0 rgba(0,0,0,0.2);
}

/* --- COMMENTAIRES --- */
.sdv-comments-section {
    margin-top: 2rem;
    background: rgba(255, 255, 255, 0.4); /* Fond légèrement plus foncé */
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--sdv-border);
}

.sdv-comments-section h3 {
    margin-top: 0;
    font-size: 1.6rem;
    text-align: center;
    border-bottom: 2px solid var(--sdv-border);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

.sdv-comment-scroll {
    max-height: 250px;
    overflow-y: auto;
    padding-right: 5px;
    /* Scrollbar personnalisée chrome/safari */
    scrollbar-width: thin;
    scrollbar-color: var(--sdv-border) transparent;
}

/* Style d'un commentaire individuel */
.comment-box {
    background: #fff;
    border: 1px solid var(--sdv-shadow);
    padding: 0.8rem;
    margin-bottom: 0.8rem;
    border-radius: 4px;
    box-shadow: 2px 2px 0 rgba(0,0,0,0.1);
}

.comment-box p {
    margin: 0;
    font-size: 1.3rem;
    line-height: 1.2;
}

.comment-box small {
    display: block;
    margin-top: 0.4rem;
    color: var(--sdv-red); /* Date en rouge/rose pour rappeler le thème */
    font-size: 1rem;
    text-align: right;
}

/* --- TEXTAREA --- */
.sdv-textarea {
    resize: vertical;
    min-height: 80px;
}


/* ========================================= */
/* MISE À JOUR MEDIA QUERY MOBILE       */
/* ========================================= */

@media (max-width: 600px) {
    /* ... Tes règles précédentes body/container ... */

    /* 1. Galerie sur Mobile : 1 image par ligne pour bien voir */
    .sdv-gallery {
        flex-direction: column;
    }

    .sdv-gallery-item {
        max-width: 100%; /* Prend toute la largeur */
        flex: 1 1 100%;
    }

    /* 2. Boutons commentaires : Pleine largeur */
    .sdv-full-btn {
        width: 100%;
        margin-top: 0.5rem;
    }

    /* 3. Texte de lecture plus confortable */
    .note-content p {
        font-size: 1.5rem; /* Un peu plus gros pour lire facile */
    }

    /* 4. Section commentaires plus compacte sur les bords */
    .sdv-comments-section {
        padding: 0.8rem;
        margin-top: 1.5rem;
    }

    /* 5. Fix iOS : input font-size 16px min pour éviter le zoom auto */
    textarea {
        font-size: 16px !important;
    }
}

/* ========================================= */
/* PAGE DE MAINTENANCE & ANIMATIONS     */
/* ========================================= */

/* --- L'ENCART HORLOGE (Haut Droite) --- */
.sdv-clock-box {
    position: absolute;
    top: 20px;
    right: 20px;
    background: #ffcd86; /* Beige fond */
    border: 4px solid #6d4123; /* Bordure marron */
    padding: 10px 20px;
    width: 160px;
    text-align: right;
    box-shadow: 4px 4px 0 rgba(0,0,0,0.5);
    z-index: 10;
    transform: rotate(1deg);
}

.sdv-clock-box .day {
    font-size: 1.4rem;
    color: #4a2810;
    font-weight: bold;
    border-bottom: 2px solid #b37b46;
    margin-bottom: 5px;
}

.sdv-clock-box .time {
    font-size: 2rem;
    color: #d94c4c; /* Rouge "tard" */
    letter-spacing: 2px;
}

/* Animation clignotement de l'heure */
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
.blink-text {
    animation: blink 1.5s infinite;
}

/* --- LA CARTE MAINTENANCE --- */
.maintenance-card {
    text-align: center;
    position: relative;
    max-width: 500px;
}

.maintenance-card h1 {
    color: var(--sdv-red);
    margin-bottom: 1rem;
}

.maintenance-card p {
    font-size: 1.5rem;
    line-height: 1.4;
    margin-bottom: 2rem;
}

/* --- ICÔNE PIXEL ART (La poule ou le Junimo) --- */
.pixel-art-icon {
    font-size: 4rem; /* Taille de l'émoji */
    margin: 1rem 0;
    display: inline-block;
    animation: bounce 2s infinite ease-in-out;
}

/* Animation rebond doux */
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* --- ANIMATION "Zzz" (Sommeil) --- */
.zzz-container {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 60px;
    pointer-events: none;
}

.zzz {
    position: absolute;
    color: #4a2810;
    font-weight: bold;
    font-family: 'VT323', monospace;
    opacity: 0;
    animation: floatZ 3s infinite;
}

.zzz:nth-child(1) { font-size: 1.5rem; animation-delay: 0s; left: 20%; }
.zzz:nth-child(2) { font-size: 2rem; animation-delay: 1s; left: 50%; }
.zzz:nth-child(3) { font-size: 2.5rem; animation-delay: 2s; left: 80%; }

@keyframes floatZ {
    0% { transform: translate(0, 20px) rotate(-10deg); opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { transform: translate(10px, -40px) rotate(10deg); opacity: 0; }
}

/* --- BARRE D'ÉNERGIE (Loading) --- */
.energy-bar-container {
    width: 80%;
    margin: 0 auto 1.5rem auto;
    text-align: left;
}

.energy-label {
    font-size: 1.2rem;
    margin-bottom: 5px;
    color: #555;
}

.energy-bar-outer {
    width: 100%;
    height: 30px;
    background: #503629; /* Fond sombre de la jauge */
    border: 3px solid #6d4123;
    border-radius: 15px; /* Arrondi style jauge */
    overflow: hidden;
    position: relative;
}

.energy-bar-fill {
    height: 100%;
    background: linear-gradient(to right, #e8c446, #6cac47); /* Dégradé Jaune -> Vert */
    width: 0%;
    animation: loadingFill 4s ease-in-out infinite;
}

/* Fausse barre blanche de reflet sur la jauge */
.energy-bar-outer::after {
    content: '';
    position: absolute;
    top: 5px;
    left: 5px;
    right: 5px;
    height: 4px;
    background: rgba(255,255,255,0.3);
    border-radius: 10px;
}

@keyframes loadingFill {
    0% { width: 5%; background: #d94c4c; } /* Rouge (fatigué) */
    50% { width: 60%; background: #e8c446; } /* Jaune */
    100% { width: 100%; background: #6cac47; } /* Vert (plein) */
}

/* --- INDICATEUR DE SAUVEGARDE --- */
.saving-indicator {
    font-size: 1.2rem;
    color: #888;
    margin-top: 10px;
    font-style: italic;
}

/* --- MEDIA QUERY MOBILE (Pour la page maintenance) --- */
@media (max-width: 600px) {
    .sdv-clock-box {
        top: 10px;
        right: 50%;
        transform: translateX(50%) rotate(0deg); /* Centré en haut sur mobile */
        width: auto;
        padding: 5px 15px;
    }

    .sdv-clock-box .time {
        font-size: 1.5rem;
    }

    .maintenance-card {
        margin-top: 60px; /* Place pour l'horloge */
        width: 90%;
    }
}

/* ========================================= */
/* PAGE SPÉCIALE VALENTINE              */
/* ========================================= */

.valentine-card {
    text-align: center;
    /* Un peu plus d'espace interne pour que ça respire */
    padding: 3rem 2rem;
    overflow: visible; /* Important pour que les animations sortent du cadre */
}

/* --- AMBIANCE DE FOND --- */
.floating-bg-hearts {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
}
.floating-bg-hearts span {
    position: absolute;
    display: block;
    font-size: 2rem;
    opacity: 0.2;
    bottom: -50px;
    animation: floatUp 15s linear infinite;
}
/* Positions et délais aléatoires pour les coeurs de fond */
.floating-bg-hearts span:nth-child(1) { left: 10%; animation-delay: 0s; }
.floating-bg-hearts span:nth-child(2) { left: 30%; animation-delay: 5s; font-size: 1.5rem; }
.floating-bg-hearts span:nth-child(3) { left: 55%; animation-delay: 2s; }
.floating-bg-hearts span:nth-child(4) { left: 70%; animation-delay: 8s; font-size: 2.5rem;}
.floating-bg-hearts span:nth-child(5) { left: 90%; animation-delay: 1s; }

@keyframes floatUp {
    0% { transform: translateY(0) rotate(0deg); opacity: 0; }
    20% { opacity: 0.3; }
    80% { opacity: 0.3; }
    100% { transform: translateY(-110vh) rotate(360deg); opacity: 0; }
}

/* --- LE BOUQUET --- */
.pixel-bouquet-container {
    font-size: 6rem;
    margin-bottom: 1rem;
    /* Filtre pour donner un aspect un peu plus "pixel art" à l'emoji */
    filter: contrast(1.2) saturate(1.2);
    display: inline-block;
}

/* Animation douce de flottement */
.floating-animation {
    animation: floatBouquet 3s ease-in-out infinite;
}
@keyframes floatBouquet {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-15px); }
}

/* Animation de rebond joyeux (après le OUI) */
.happy-bounce {
    animation: happyBounce 0.8s cubic-bezier(0.36, 0.07, 0.19, 0.97) both infinite;
}
@keyframes happyBounce {
    10%, 90% { transform: translate3d(0, -2px, 0); }
    20%, 80% { transform: translate3d(0, 4px, 0); }
    30%, 50%, 70% { transform: translate3d(0, -8px, 0); }
    40%, 60% { transform: translate3d(0, 8px, 0); }
}

/* --- TEXTES --- */
.valentine-question {
    font-size: 2.5rem;
    color: var(--sdv-red); /* On utilise le rouge Saint-Valentin */
    text-shadow: 2px 2px 0px rgba(255,255,255,0.4);
    margin-bottom: 0.5rem;
}
.valentine-subtext {
    font-size: 1.4rem;
    color: var(--sdv-text);
    margin-bottom: 2.5rem;
}

/* --- BOUTONS SPÉCIFIQUES --- */
.valentine-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

/* Le gros bouton OUI */
.sdv-btn-yes {
    font-size: 1.8rem !important;
    padding: 1rem 2rem !important;
    background-color: #d46a9b !important; /* Rose Stardew */
    border-color: #a34e6d !important;
    transform: scale(1);
    transition: transform 0.2s, background-color 0.2s;
    /* Petite animation pour attirer l'attention */
    animation: pulseBtn 2s infinite;
}
.sdv-btn-yes:hover {
    transform: scale(1.1) rotate(-2deg) !important;
    background-color: #e88ab5 !important;
    animation: none; /* On arrête le pulse au survol */
}

/* Le petit bouton NON */
.sdv-btn-no {
    font-size: 1.2rem !important;
    padding: 0.5rem 1rem !important;
    background-color: #a6a6a6 !important; /* Gris terne */
    border-color: #7a7a7a !important;
    opacity: 0.8;
}
.sdv-btn-no:hover {
    background-color: #c7c7c7 !important;
}

@keyframes pulseBtn {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); box-shadow: 0 0 15px var(--sdv-highlight); }
    100% { transform: scale(1); }
}

/* --- SYSTÈME DE PARTICULES (EXPLOSION) --- */
#particleContainer {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: 9999;
}
.particle-heart {
    position: absolute;
    font-size: 2rem;
    /* Les variables --tx, --ty, --rot sont définies en JS */
    animation: explode 1.5s ease-out forwards;
}

@keyframes explode {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(0.5) rotate(0deg);
    }
    100% {
        opacity: 0;
        /* On utilise les variables CSS pour la trajectoire */
        transform: translate(var(--tx), var(--ty)) scale(1.5) rotate(var(--rot));
    }
}

/* --- RESPONSIVE --- */
@media (max-width: 600px) {
    .valentine-question { font-size: 1.8rem; }
    .pixel-bouquet-container { font-size: 4rem; }
    .sdv-btn-yes { font-size: 1.4rem !important; width: 100%; }
    .sdv-btn-no { font-size: 1rem !important; margin-top: 10px;}
    .valentine-buttons { flex-direction: column-reverse; gap: 10px; }
}
