/* Fonts */
@import url("https://fonts.googleapis.com/css2?family=Instrument+Serif&family=Space+Mono:ital@1&display=swap");

/* Theme colors - marsala background, cream text */
:root {
    background: #560325;
    color: #fff1d0;
}

body {
    font-family: "Space Mono", monospace;
    font-style: italic;
    margin: 0;
    padding: 1.5rem;
    font-size: 1.1rem;
}

/* Responsive container */
main {
    max-width: 100%;
    margin: 0 auto;
}

/* Tablet: 75% width */
@media (min-width: 768px) {
    body {
        padding: 2rem;
    }

    main {
        max-width: 75%;
    }
}

/* Desktop: 60% width */
@media (min-width: 1366px) {
    main {
        max-width: 60%;
    }
}

h1 {
    font-family: "Instrument Serif", serif;
    font-weight: 400;
    font-style: normal;
    font-size: 3rem;
}

h2 {
    font-family: "Instrument Serif", serif;
    font-weight: 400;
    font-style: normal;
    font-size: 2rem;
}

h3,
h4,
h5,
h6 {
    font-family: "Instrument Serif", serif;
    font-weight: 400;
    font-style: normal;
}

p,
a {
    font-size: 1.35rem;
}

hr {
    border: none;
    border-top: 2px solid #fff1d0;
    margin: 1.5rem 0;
}

@media (min-width: 768px) {
    hr {
        margin: 2rem 0;
    }
}

/* Section separators - match grid gaps */
section + section {
    margin-top: 1.5rem;
}

@media (min-width: 768px) {
    section + section {
        margin-top: 1rem;
    }
}

section hr {
    margin: 1.5rem 0;
}

@media (min-width: 768px) {
    section hr {
        margin: 1rem 0;
    }
}

/* Counter */
.counter {
    font-size: 1.2rem;
    margin: 1rem 0;
}

/* Back to top button */
.back-to-top {
    display: block;
    width: fit-content;
    margin: 3rem auto 2rem;
    font-family: "Space Mono", monospace;
    font-style: italic;
    font-size: 1.1rem;
    background: #fff1d0;
    color: #560325;
    border: 2px solid #fff1d0;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    text-decoration: none;
}

.back-to-top:hover {
    background: #560325;
    color: #fff1d0;
}

/* Global transition */
* {
    transition: cubic-bezier(0, 1, 1, 1) 400ms;
}

/* Navigation buttons */
nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 2rem 0;
}

nav button {
    font-family: "Space Mono", monospace;
    font-style: italic;
    font-size: 1rem;
    background: #fff1d0;
    color: #560325;
    border: 2px solid #fff1d0;
    padding: 0.5rem 1rem;
    cursor: pointer;
}

nav button:hover {
    background: #560325;
    color: #fff1d0;
}

/* Back to top button */
#back-to-top {
    display: block;
    text-align: center;
    margin: 2rem 0;
    text-decoration: none;
}

#back-to-top button {
    font-family: "Space Mono", monospace;
    font-style: italic;
    font-size: 1rem;
    background: #fff1d0;
    color: #560325;
    border: 2px solid #fff1d0;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
}

#back-to-top button:hover {
    background: #560325;
    color: #fff1d0;
}

/* Media counter */
#media-counter {
    font-weight: bold;
    margin: 1rem 0;
}

/* Masonry layout for media */
.media-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1rem 0;
}

@media (min-width: 768px) {
    .media-grid {
        gap: 1rem;
    }
}

/* Row container for desktop */
.media-row {
    display: flex;
    gap: 1.5rem;
    width: 100%;
    justify-content: center;
}

@media (min-width: 768px) {
    .media-row {
        gap: 1rem;
    }
}

.media-item {
    display: block;
    width: 100%;
    opacity: 0;
    transform: translateY(1rem);
    line-height: 0;
}

/* Desktop sizing for different layouts */
@media (min-width: 768px) {
    .media-item.portrait-third {
        width: calc(33.333% - 0.667rem);
    }

    .media-item.portrait-double {
        width: calc(50% - 0.5rem);
    }

    .media-item.landscape-half {
        width: calc(50% - 0.5rem);
    }

    .media-item.landscape-with-portrait {
        width: calc(66.667% - 0.5rem);
    }

    .media-item.portrait-with-landscape {
        width: calc(33.333% - 0.5rem);
    }

    /* Single items - centered with reasonable max width */
    .media-item.single-portrait {
        width: 40%;
        max-width: 600px;
    }

    .media-item.single-landscape {
        width: 80%;
        max-width: 1200px;
    }
}

.media-item.loaded {
    opacity: 1;
    transform: translateY(0);
}

.media-item img,
.media-item video {
    width: 100%;
    height: auto;
    display: block;
    border: 2px solid #fff1d0;
}

/* Video height constraints for desktop/tablet */
@media (min-width: 768px) {
    .media-item video {
        max-height: 80vh;
        max-width: 100%;
        width: auto;
        height: auto;
        margin: 0 auto;
    }
}

.media-item video {
    cursor: pointer;
}

/* Lazy loading optimization */
img[loading="lazy"],
video[loading="lazy"] {
    content-visibility: auto;
}
