/* Styles */
body {
    padding: 5px 50px;
}

.conteneur {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.donner {
    border: 1px dashed gray;
    padding: 20px;
}

li[class^="reponse-"] {
    border: 1px solid gray;
    padding: 10px;
    margin-bottom: 10px;
    background-color: #f7f7f7;
    cursor: default;
}

li[class^="reponse-"]:hover {
    background-color: #e2e2e2;
}

/* ===== Exercice 1 : Sélecteurs CSS ===== */

.conteneur:has(.reponse-1:hover) nav.main-nav a {
    background-color: yellow;
    outline: 1px solid red
}

.conteneur:has(.reponse-2:hover) nav.main-nav a.active {
    background-color: yellow;
    outline: 1px solid red
}

.conteneur:has(.reponse-3:hover) article.post.featured {
    background-color: yellow;
    outline: 1px solid red
}

.conteneur:has(.reponse-4:hover) .post p:first-of-type {
    background-color: yellow;
    outline: 1px solid red
}

.conteneur:has(.reponse-5:hover) .main-nav li:nth-child(even) {
    background-color: yellow;
    outline: 1px solid red
}

/* ===== Exercice 2 : Box Model ===== */

.box {
    width: 600px;
    height: 100px;
    background-color: blue;
    margin: 0 auto;
}

.conteneur-box {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 150px;
    border: 1px dashed gray;
}

/* ===== Exercice 3 : Flexbox ===== */

/* 3.1 Barre de navigation */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #333;
    padding: 10px 20px;
    border-radius: 4px;
}

.navbar .logo {
    color: white;
    font-weight: bold;
    font-size: 1.2rem;
}

.navbar .nav-links {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 20px;
}

.navbar .nav-links a {
    color: white;
    text-decoration: none;
}

.navbar .nav-links a:hover {
    text-decoration: underline;
}

/* 3.2 Cartes de même hauteur */
.cards {
    display: flex;
    gap: 20px;
    margin-top: 10px;
}

.card {
    display: flex;
    flex-direction: column;
    flex: 1;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 15px;
    background-color: #f9f9f9;
}

/* Le paragraphe prend tout l'espace disponible pour pousser le lien vers le bas */
.card p {
    flex-grow: 1;
}

.card-link {
    display: inline-block;
    margin-top: 10px;
    padding: 8px 12px;
    background-color: #333;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    text-align: center;
}

.card-link:hover {
    background-color: #555;
}

/* ===== Exercice 4 : CSS Grid ===== */

/* 4.1 Grille de cartes responsive */
.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 10px;
}

.grid-card {
    background-color: #e0e0e0;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 20px;
    text-align: center;
}

/* 4.2 Layout complet avec Grid Areas */
.page-layout {
    display: grid;
    grid-template-areas:
        "header header"
        "sidebar main"
        "footer footer";
    grid-template-columns: 200px 1fr;
    grid-template-rows: auto 1fr auto;
    gap: 10px;
    height: 300px;
    margin-top: 10px;
    border: 1px dashed gray;
    padding: 10px;
}

.page-header {
    grid-area: header;
    background-color: #333;
    color: white;
    padding: 10px;
    text-align: center;
    border-radius: 4px;
}

.page-sidebar {
    grid-area: sidebar;
    background-color: #ccc;
    padding: 10px;
    border-radius: 4px;
}

.page-main {
    grid-area: main;
    background-color: #f0f0f0;
    padding: 10px;
    border-radius: 4px;
}

.page-footer {
    grid-area: footer;
    background-color: #333;
    color: white;
    padding: 10px;
    text-align: center;
    border-radius: 4px;
}

/* ===== Exercice 5 : Responsive Design (Mobile First) ===== */

/* Base mobile */
.container {
    width: 100%;
    padding: 15px;
    border: 1px dashed gray;
    margin-top: 10px;
    box-sizing: border-box;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 15px;
}

.nav-menu a {
    padding: 8px;
    background-color: #333;
    color: white;
    text-decoration: none;
    border-radius: 4px;
}

.content {
    display: block;
}

.sidebar-responsive {
    display: none;
}

.main-content {
    background-color: #f0f0f0;
    padding: 10px;
    border-radius: 4px;
}

/* Tablette (min-width: 600px) */
@media (min-width: 600px) {
    .nav-menu {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .sidebar-responsive {
        display: block;
        background-color: #ccc;
        padding: 10px;
        border-radius: 4px;
        margin-bottom: 10px;
    }
}

/* Desktop (min-width: 900px) */
@media (min-width: 900px) {
    .content {
        display: flex;
        gap: 15px;
    }

    .sidebar-responsive {
        width: 200px;
        flex-shrink: 0;
        margin-bottom: 0;
    }

    .main-content {
        flex-grow: 1;
    }
}

/* ===== Exercice 6 : Variables CSS et thèmes ===== */

/* Thème clair (défaut) */
.theme-demo {
    --bg-color: #ffffff;
    --text-color: #111111;
    --border-color: #cccccc;
    --btn-bg: #333333;
    --btn-text: #ffffff;

    background-color: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: 4px;
    margin-top: 10px;
    transition: background-color 0.3s, color 0.3s;
}

/* Thème sombre */
.theme-demo.dark {
    --bg-color: #1a1a1a;
    --text-color: #f0f0f0;
    --border-color: #444444;
    --btn-bg: #f0f0f0;
    --btn-text: #1a1a1a;
}

.theme-toggle {
    margin-top: 10px;
    padding: 8px 16px;
    background-color: var(--btn-bg);
    color: var(--btn-text);
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

/* ===== Exercice 7 : Transitions et animations ===== */

/* 7.1 Bouton animé */
.btn-anime {
    padding: 12px 24px;
    background-color: #333;
    color: white;
    border: 2px solid #333;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s, color 0.3s, transform 0.2s;
}

.btn-anime:hover {
    background-color: white;
    color: #333;
    transform: scale(1.05);
}

/* 7.2 Spinner de chargement */
@keyframes rotation {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #ccc;
    border-top-color: #333;
    border-radius: 50%;
    animation: rotation 0.8s linear infinite;
    margin-top: 10px;
}