:root {
    --bg: #2f3b3d;
    --surface: #1a1a1a;
    --accent: #70e7e7;
    --accent-dk: #5ea5f5;
    --text: #e8eef0;
    --muted: #61817e;
    --border: #00a2ff;
    --gap: 0.5rem;
    --bg2: #0e0e0e;
    --surface2: #1a1a1a;
    --accent2: #e8c97e;
    --text2: #fff;
    --muted2: #888;
    --border2: #2a2a2a;
    --overlay-bg: rgba(0,0,0,0.92);
}

*, *::before, *::after { 
    box-sizing: border-box; margin: 0; padding: 0 
}

body {
    font-family: system-ui;
}

.first-exercise {
    .card-container {
        container-type: inline-size;
        container-name: card;
        max-width: 880px;
        width: 100%;
        margin: 1rem auto;
        padding: 1rem;

        @container card (min-width: 800px) {
            .card {
                display: flex;
            }

            .card__image {
                width: 50%;
                display: block;
            }

            .card__image img {
                object-fit: cover;
                width: 100%;
                height: 100%;
                border-radius: 1rem 0 0 1rem;
            }

            .card__content {
                flex: 1;
            }
        }
    }

    .card {
        line-height: 1.5;
        text-decoration: none;
        background-color: #fff;
        filter: drop-shadow(0 0 15px hsl(0, 0%, 85%));
        border-radius: 1rem;
    }

    .card__image {
        margin: 0;
    }

    .card__image img {
        max-width: 100%;
        display: block;
        border-radius: 1rem 1rem 0 0;
    }

    .card__content {
        padding: 1rem;
        color: black;
    }

    .card__title {
        font-size: 1.4rem;
        font-weight: bold;
    }

    .card__text {
        margin-top: 0.5rem;
    }
}

.second-exercise {
    background: var(--bg);
    color: var(--text);
    font-family: sans-serif;
    padding: 2rem;
        
    .strip-container {
        container-type: inline-size;
        container-name: strip;
        max-width: 1600px;
        margin: 0 auto;
    }

    .card-strip {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        gap: var(--gap);
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 1rem;
        scrollbar-width: thin;
        scrollbar-color: var(--accent) var(--border);

        @container strip (min-width: 640px) {
            .card { 
                flex: 0 0 calc((100% - 1 * var(--gap)) / 2); 
            }
        }

        @container strip (min-width: 768px) {
            .card { 
                flex: 0 0 calc((100% - 2 * var(--gap)) / 3); 
            }
        }

        @container strip (min-width: 960px) {
            .card {
                flex: 0 0 calc((100% - 3 * var(--gap)) / 4);
            }
        }
    }

    .card {
        flex: 0 0 100%;
        scroll-snap-align: start;
        background: var(--surface);
        display: flex;
        flex-direction: column;
        position: relative;
        overflow: hidden;
        filter: none;
    }

    .card::after {
        content: "";
        position: absolute;
        inset: 0;
        border: 0.1rem solid transparent;
        pointer-events: none;
        transition: border-color 0.3s;
        z-index: 2;
    }

    .card:hover::after { 
        border-color: var(--accent)
    }
    .card:hover {
        box-shadow: 0 0.5rem 0.5rem rgba(0, 0, 0, 0.25)
    }

    .card__image {
        position: relative;
        overflow: hidden;
        aspect-ratio: 3 / 2;
        flex-shrink: 0;
    }

    .card__image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
        filter: brightness(0.85) saturate(0.9);
        transition: transform 0.5s ease, filter 0.4s ease;
    }

    .card:hover .card__image img {
        transform: scale(1.07);
        filter: brightness(1) saturate(1.1);
    }

    .card__cat {
        position: absolute;
        top: 0.5rem; 
        left: 0.5rem;
        background: var(--accent);
        color: #111;
        font-size: 0.6rem;
        text-transform: uppercase;
        padding: 0.3em 0.7em;
        font-weight: 500;
        z-index: 1;
    }

    .card__body {
        padding: 1.1rem 1.1rem 1rem;
        display: flex;
        flex-direction: column;
        flex: 1;
        border-top: 1px solid var(--border);
    }

    .card__title {
        font-size: clamp(0.9rem 2cqi 1.05rem);
        font-weight: 700;
        line-height: 1.3;
        margin-bottom: 0.65rem;
        color: var(--text);
    }

    .card__text {
        font-size: 0.9rem;
        line-height: 1.5;
        color: var(--muted)
    }

    .btn-read {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        font-size: 0.7rem;
        font-weight: 500;
        text-transform: uppercase;
        color: var(--accent);
        text-decoration: none;
        padding-bottom: 0.25em;
        border-bottom: 0.1rem solid var(--accent);
        align-self: flex-start;
    }
}

.third-exercise {
    background: var(--bg2);
    color: var(--text2);
    font-family: sans-serif;
    min-height: 100vh;
    padding-top: 2rem;

    .gallery-input {
        display: none;
    }

    .gallery-wrapper {
        container-type: inline-size;
        container-name: gallery;
        padding: 0 2rem 4rem;
        max-width: 1600px;
        margin: 0 auto;

        @container gallery (max-width: 1200px) {
            .gallery {
                grid-template-columns: repeat(4, 1fr);
            }
        }

        @container gallery (max-width: 768px) {
            .gallery {
                grid-template-columns: repeat(3, 1fr);
                gap: 6px;
            }

            .gallery-wrapper {
                padding: 0 1rem 4rem;
            }
        }

        @container gallery (max-width: 480px) {
            .gallery {
                grid-template-columns: repeat(2, 1fr);
            }
        }
    }

    .gallery {
        display: grid;
        grid-template-columns: repeat(6, 1fr);
        gap: 0.5rem;
    }

    .gallery-item {
        position: relative;
        aspect-ratio: 4 / 3;
        overflow: hidden;
        cursor: pointer;
        background: var(--surface2);
    }

    .thumb {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
        transition: transform 0.5s ease, filter 0.3s ease;
        filter: brightness(0.85) saturate(0.9);
    }

    .gallery-item:hover .thumb {
        transform: scale(1.08);
        filter: brightness(1) saturate(1.1);
    }

    .overlay {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 1000;
        background: var(--overlay-bg);
        align-items: center;
        justify-content: center;
        animation: fadeIn 0.3s ease;
    }

    .gallery-input:checked + .overlay {
        display: flex;
    }

    .overlay-inner {
        position: relative;
        max-width: min(90vw, 1200px);
        max-height: 90vh;
        animation: zoomIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    .overlay-img {
        display: block;
        max-width: 100%;
        max-height: 88vh;
        object-fit: contain;
        border: 1px solid var(--border2);
        box-shadow: 0 2rem 5rem rgba(0, 0, 0, 0.8);
    }

    .overlay-close {
        display: block;
        position: absolute;
        top: -1rem;
        right: -1rem;
        width: 2rem;
        height: 2rem;
        background: var(--text2);
        color: #000;
        font-size: 1.2rem;
        font-weight: 700;
        line-height: 2rem;
        text-align: center;
        cursor: pointer;
        border-radius: 50%;
        z-index: 10;
    }

    .overlay-backdrop {
        position: absolute;
        inset: 0;
        z-index: -1;
    }
}

@keyframes fadeIn {
    from { 
        opacity: 0; 
    }
    to {
        opacity: 1; 
    }
}

@keyframes zoomIn {
    from {
        transform: scale(0.85);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}