:root {
    --bg-color: #111111;
    --widget-bg: #1a1a1a;
    --primary-orange: #FFBF40;
    --text-light: #f0f0f0;
    --text-secondary: #a0a0a0;
    --font-title: 'Gentium Book Plus', serif;
    --font-body: 'Roboto', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background-color: var(--bg-color);
    color: var(--text-light);
    font-family: var(--font-body);
    line-height: 1.6;
    min-height: 100vh;
}

header { text-align: center; padding: 3rem 1rem; }
header h1 { font-family: var(--font-title); font-size: 3rem; color: var(--primary-orange); }
header p { color: var(--text-secondary); font-size: 1.1rem; }

#widget-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    grid-auto-rows: 1fr;
    gap: 2rem;
    padding: 1rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.widget {
    background-color: var(--widget-bg);
    border: 1px solid #2a2a2a;
    border-radius: 20px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    animation: fadeIn 0.5s ease-out forwards;
    opacity: 0;
    position: relative;
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
    overflow: hidden;
    height: 350px; /* HAUTEUR FIXE POUR TOUS LES WIDGETS */
}

.widget-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid #333;
    padding-bottom: 0.8rem;
    flex-shrink: 0;
}
.widget-header i { font-size: 1.5rem; color: var(--primary-orange); }
.widget-header h3 {
    font-family: var(--font-title);
    font-size: 1.3rem;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.widget-content {
    flex-grow: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow-y: auto; /* Barre de défilement si contenu trop long */
}
/* Style pour la barre de défilement */
.widget-content::-webkit-scrollbar { width: 5px; }
.widget-content::-webkit-scrollbar-track { background: #2a2a2a; }
.widget-content::-webkit-scrollbar-thumb { background: var(--primary-orange); border-radius: 5px; }

.widget-content p { font-size: 0.95rem; }
.widget-content strong { color: var(--primary-orange); font-weight: 400; }

.widget-detail-link {
    position: absolute;
    bottom: 10px;
    right: 15px;
    font-size: 2rem;
    line-height: 1;
    color: var(--primary-orange);
    text-decoration: none;
    transition: transform 0.2s;
    z-index: 10;
}
.widget-detail-link:hover { transform: translateX(5px); cursor: pointer; }

.widget-reload-icon {
    position: absolute;
    bottom: 12px;
    left: 15px;
    font-size: 0.8rem; /* Très petit */
    color: var(--primary-orange);
    cursor: pointer;
    transition: transform 0.2s ease-in-out;
    z-index: 15;
}
.widget-reload-icon:hover { transform: rotate(90deg); }

/* --- STYLES SPÉCIFIQUES REALIA --- */
.widget-Realia { padding: 0; cursor: pointer; }
.widget-Realia .widget-header { padding: 1.5rem 1.5rem 0.8rem 1.5rem; margin-bottom: 0; }
.widget-Realia .widget-content { height: 100%; overflow: hidden; }
.widget-Realia .widget-image {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Remplit l'espace en rognant */
    border-radius: 0 0 18px 18px;
    margin: 0;
}
.widget-Realia .widget-detail-link { display: none; }

/* --- STYLES MODAL REALIA --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}
.modal.visible { display: flex; align-items: center; justify-content: center; opacity: 1; }
.modal-content {
    background-color: var(--widget-bg);
    padding: 20px;
    border: 1px solid #444;
    border-radius: 10px;
    width: 90%;
    max-width: 800px;
    text-align: center;
    animation: zoomIn 0.3s ease-out;
}
#modal-image { width: 100%; max-height: 70vh; object-fit: contain; border-radius: 5px; }
#modal-info { padding: 20px 10px 0 10px; text-align: left; }
#modal-title { font-family: var(--font-title); color: var(--primary-orange); cursor: pointer; display: inline-block; }
#modal-title:hover { text-decoration: underline; }
#modal-description { margin-top: 10px; color: var(--text-light); }
#modal-reference { margin-top: 15px; font-size: 0.8em; color: var(--text-secondary); }
.modal-close {
    position: absolute;
    top: 15px; right: 35px;
    color: #f1f1f1;
    font-size: 40px; font-weight: bold;
    cursor: pointer;
}
@keyframes zoomIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* --- STYLES SPÉCIFIQUES QUIZ --- */
.quiz-content { justify-content: center; overflow: hidden; }
.quiz-answers-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 15px;
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}
.quiz-answer {
    padding: 10px 12px;
    background-color: #2b2b2b;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background-color 0.2s;
}
.quiz-answer:not(.answered):hover { background-color: #3a3a3a; }
.quiz-answer.answered { cursor: default; }

.quiz-info-transition {
    opacity: 0;
    position: absolute;
    top: 50%; left: 1.5rem; right: 1.5rem;
    transform: translateY(-50%);
    text-align: center;
    transition: opacity 0.4s 0.2s ease-in;
    pointer-events: none;
}
.quiz-info-transition.visible { opacity: 1; }
.quiz-answers-container.hidden-transition { opacity: 0; }

footer { text-align: center; padding: 2rem; color: var(--text-secondary); font-size: 0.9rem; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@media (max-width: 768px) { #widget-grid { grid-template-columns: 1fr; height: auto; grid-auto-rows: auto;} .widget {height: auto; min-height: 300px;} }