/*
 * CHANGSHA RUINS — CSS-ONLY PHOTO BOOKS
 * Four turning leaves. Eight magazine-style pages in each book.
 * The background on every face uses the same color as the book spine.
 */

@font-face {
    font-family: "Marfa";
    src: local("ABC Marfa Thin Trial"),
         url("fonts/ABCMarfa-Thin-Trial.otf") format("opentype");
    font-display: swap;
}

@font-face {
    font-family: "RotisSans";
    src: local("Agfa Rotis Sans Serif"),
         url("fonts/AgfaRotisSansSerif.otf") format("opentype");
    font-display: swap;
}

@font-face {
    font-family: "RotisLight";
    src: local("Agfa Rotis Semisans Light"),
         url("fonts/AgfaRotisSemisansLight.otf") format("opentype");
    font-display: swap;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: #090909;
    color: #ededed;
    font-family: "RotisLight", Arial, sans-serif;
}

/* Theme colors are identical to their corresponding book-spine colors. */
.theme-red {
    --paper: #8d2829;
    --ink: #fff0e3;
    --muted: #f0ccc2;
    --edge: #542023;
}

.theme-blue {
    --paper: #607f9b;
    --ink: #ffffff;
    --muted: #e2edf5;
    --edge: #3a566c;
}

.theme-yellow {
    --paper: #cbbc8b;
    --ink: #1c1812;
    --muted: #4c4131;
    --edge: #857753;
}

.theme-white {
    --paper: #e7e7e7;
    --ink: #161616;
    --muted: #555;
    --edge: #b1b1b1;
}

.theme-black {
    --paper: #242424;
    --ink: #f0f0f0;
    --muted: #bbbbbb;
    --edge: #111111;
}

.book-top {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 90;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    width: 100%;
    padding: 23px clamp(20px, 3.5vw, 70px);
    background: linear-gradient(#090909f5, #09090900);
    font-family: "RotisSans", Arial, sans-serif;
    font-size: 0.7rem;
    letter-spacing: 0.09em;
}

.book-top a {
    color: #f2f2f2;
    text-decoration: none;
}

.book-top a:hover {
    text-decoration: underline;
    text-underline-offset: 5px;
}

.book-identity {
    color: #a5a5a5;
    overflow-wrap: anywhere;
    text-align: center;
}

.book-stage {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 94px 50px 95px;
    overflow: hidden;
    perspective: 2000px;
}

.flip {
    position: absolute;
    top: 15px;
    left: 0;
    opacity: 0;
    pointer-events: none;
}

/* Book positioned so the unflipped cover occupies the right-hand page. */
.book {
    position: relative;
    width: min(40vw, 535px);
    height: min(72vh, 680px);
    min-height: 430px;
    transform: translateX(48%);
    filter: drop-shadow(13px 18px 13px #000c);
}

.sheet {
    position: absolute;
    inset: 0;
    transform-origin: left center;
    transform-style: preserve-3d;
    transition: transform 900ms cubic-bezier(0.25, 0.6, 0.16, 1);
}

.sheet-1 {
    z-index: 4;
}

.sheet-2 {
    z-index: 3;
}

.sheet-3 {
    z-index: 2;
}

.sheet-4 {
    z-index: 1;
}

.face {
    position: absolute;
    inset: 0;
    overflow: hidden;
    backface-visibility: hidden;
    background: var(--paper);
    color: var(--ink);
    border: 1px solid var(--edge);
    box-shadow: inset -13px 0 23px #0002;
}

.face.back {
    transform: rotateY(180deg);
    box-shadow: inset 13px 0 23px #0002;
}

/* Each checked checkbox physically flips one paper leaf. */
.book-stage:has(#flip1:checked) .sheet-1,
.book-stage:has(#flip2:checked) .sheet-2,
.book-stage:has(#flip3:checked) .sheet-3,
.book-stage:has(#flip4:checked) .sheet-4 {
    transform: rotateY(-180deg);
}

.book-stage:has(#flip1:checked) .sheet-1 {
    z-index: 5;
}

.book-stage:has(#flip2:checked) .sheet-2 {
    z-index: 6;
}

.book-stage:has(#flip3:checked) .sheet-3 {
    z-index: 7;
}

.book-stage:has(#flip4:checked) .sheet-4 {
    z-index: 8;
}

/* Page-turn controls live on the front and reverse of each leaf. */
.turn {
    position: absolute;
    bottom: 16px;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 38px;
    background: rgba(8, 8, 8, 0.79);
    color: #fff;
    border: 1px solid #ffffffbf;
    cursor: pointer;
    font-family: Arial, sans-serif;
    font-size: 1.2rem;
    transition: background 220ms ease;
}

.turn:hover {
    background: #575757;
}

.turn-next {
    right: 17px;
}

.turn-prev {
    left: 17px;
}

.page-guide {
    position: absolute;
    bottom: 29px;
    left: 50%;
    transform: translateX(-50%);
    color: #888;
    font-family: "RotisSans", Arial, sans-serif;
    font-size: 0.56rem;
    letter-spacing: 0.13em;
    text-align: center;
    white-space: nowrap;
}

/* -------------- SHARED MAGAZINE EDITORIAL GRID -------------- */

.editorial {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--paper);
    color: var(--ink);
}

.editorial img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Full-bleed photography with oversized magazine typography. */
.cover-page,
.full-photo-page,
.typography-page {
    isolation: isolate;
}

.cover-page > img,
.full-photo-page > img,
.typography-page > img {
    position: absolute;
    inset: 0;
}

.image-wash {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, #0009 0%, #0001 43%, #000b 100%);
}

.photo-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-start;
    padding: 9%;
    color: #fff;
    text-shadow: 0 1px 15px #000a;
    pointer-events: none;
}

.image-kicker,
.page-topline,
.contact-header span,
.collage-words small {
    font-family: "RotisSans", Arial, sans-serif;
    font-size: clamp(0.52rem, 0.8vw, 0.72rem);
    letter-spacing: 0.14em;
}

.photo-overlay h1 {
    width: 110%;
    max-width: 100%;
    margin: auto 0 11%;
    font-family: "Marfa", Georgia, serif;
    font-weight: 400;
    font-size: clamp(2.7rem, 4.8vw, 5.5rem);
    line-height: 0.95;
    letter-spacing: -0.045em;
    overflow-wrap: anywhere;
}

.photo-overlay h2 {
    margin: auto 0 13%;
    font-family: "Marfa", Georgia, serif;
    font-weight: 400;
    font-size: clamp(2rem, 4vw, 4rem);
    line-height: 1;
}

.image-caption {
    max-width: 270px;
    margin: 0;
    font-family: "RotisLight", Arial, sans-serif;
    font-size: 0.76rem;
    line-height: 1.45;
}

/* Magazine-column layout: picture dominates 75% of page width. */
.split-photo-page {
    display: grid;
    grid-template-columns: 74% 26%;
    gap: 0;
}

.split-large,
.split-small {
    overflow: hidden;
}

.split-side {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 13px;
    padding: 18px 12px 70px;
    min-width: 0;
}

.split-small {
    width: 100%;
    height: 33%;
}

.split-side p {
    margin: 0;
    font-size: clamp(0.61rem, 0.9vw, 0.9rem);
    line-height: 1.45;
    overflow-wrap: anywhere;
}

/* A strict editorial contact sheet with a compact header/footer. */
.contact-page {
    display: flex;
    flex-direction: column;
    gap: 9px;
    padding: 6%;
}

.contact-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 6px;
    min-height: 9%;
}

.contact-header strong {
    font-family: "RotisSans", Arial, sans-serif;
    font-size: clamp(0.75rem, 1.6vw, 1.35rem);
    font-weight: 400;
    line-height: 0.95;
    text-align: right;
}

.contact-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 7px;
    flex: 1;
    min-height: 0;
}

.grid-image {
    min-height: 0;
    overflow: hidden;
}

.grid-image.image-1 {
    grid-row: 1 / 3;
}

.contact-grid:has(.image-2:last-child) .image-2 {
    grid-row: 1 / 3;
}

.contact-caption {
    margin: 0 0 14px;
    font-size: 0.62rem;
    line-height: 1.4;
}

/* The same photo appears as the background for immense expressive type. */
.typography-page .image-wash {
    background: #0006;
}

.type-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 8%;
    color: #fff;
}

.type-overlay > span {
    font-family: "RotisSans", Arial, sans-serif;
    font-size: 0.58rem;
    letter-spacing: 0.12em;
}

.type-overlay strong {
    max-width: 100%;
    font-family: "Marfa", Georgia, serif;
    font-size: clamp(2.65rem, 5.2vw, 5.65rem);
    font-weight: 400;
    letter-spacing: -0.05em;
    line-height: 0.9;
    overflow-wrap: anywhere;
}

.type-overlay p {
    width: 70%;
    margin: 0 0 40px;
    font-size: clamp(0.6rem, 0.9vw, 0.88rem);
    line-height: 1.5;
}

/* Documentation: 68% photo and a narrow explanatory column. */
.note-page {
    display: grid;
    grid-template-columns: 68% 32%;
}

.note-image {
    overflow: hidden;
}

.note-rail {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px 14px 70px;
    min-width: 0;
    overflow-wrap: anywhere;
}

.note-rail > span,
.pending-note {
    font-family: "RotisSans", Arial, sans-serif;
    font-size: 0.51rem;
    letter-spacing: 0.09em;
}

.note-rail h2 {
    font-family: "Marfa", Georgia, serif;
    font-weight: 400;
    font-size: clamp(1.1rem, 1.9vw, 2.2rem);
    line-height: 1;
    margin: 0;
}

.note-rail p {
    font-size: clamp(0.58rem, 0.78vw, 0.8rem);
    line-height: 1.43;
    margin: 0;
}

.note-rail a {
    color: inherit;
    margin-top: auto;
    font-size: 0.59rem;
    text-underline-offset: 3px;
}

/* Natural photo collage: three independent layers and a very small poem. */
.collage-page {
    isolation: isolate;
}

.collage-image {
    position: absolute;
    overflow: hidden;
    border: 3px solid var(--paper);
    box-shadow: 4px 6px 10px #0004;
}

.collage-image.a {
    left: 5%;
    top: 5%;
    width: 66%;
    height: 57%;
    transform: rotate(-3deg);
}

.collage-image.b {
    right: 6%;
    top: 24%;
    width: 45%;
    height: 40%;
    transform: rotate(5deg);
}

.collage-image.c {
    left: 16%;
    bottom: 9%;
    width: 58%;
    height: 35%;
    transform: rotate(-2deg);
}

.collage-words {
    position: absolute;
    right: 6%;
    bottom: 15%;
    width: 42%;
    color: var(--ink);
    text-shadow: 0 1px 5px var(--paper);
}

.collage-words p {
    margin: 9px 0 0;
    font-family: "Marfa", Georgia, serif;
    font-size: clamp(1.1rem, 2vw, 2.5rem);
    line-height: 1.03;
}

/* Closing page: still photo-first, with a brief return link. */
.end-page {
    display: grid;
    grid-template-columns: 72% 28%;
}

.end-photo {
    overflow: hidden;
}

.end-details {
    display: flex;
    flex-direction: column;
    padding: 16px 12px 75px;
    gap: 12px;
}

.end-details small {
    font-family: "RotisSans", Arial, sans-serif;
    font-size: 0.54rem;
    letter-spacing: 0.08em;
}

.end-details h2 {
    margin: 0;
    font-family: "Marfa", Georgia, serif;
    font-weight: 400;
    font-size: clamp(1.1rem, 1.85vw, 2.1rem);
    line-height: 1;
}

.end-details p {
    margin: 0;
    font-size: clamp(0.58rem, 0.8vw, 0.79rem);
    line-height: 1.4;
}

.end-details a {
    margin-top: auto;
    font-family: "RotisSans", Arial, sans-serif;
    font-size: 0.58rem;
    color: inherit;
    text-underline-offset: 4px;
}

/* -------------- PHOTOGRAPHIC INDEX BELOW FLIP BOOK -------------- */

.photo-index {
    padding: 85px clamp(20px, 6vw, 90px) 85px;
    background: var(--paper);
    color: var(--ink);
}

.index-header > span,
.source-notes > span {
    font-family: "RotisSans", Arial, sans-serif;
    font-size: 0.68rem;
    letter-spacing: 0.16em;
}

.index-header h2 {
    max-width: 1100px;
    margin: 12px 0;
    font-family: "Marfa", Georgia, serif;
    font-size: clamp(2rem, 5vw, 5.3rem);
    font-weight: 400;
    line-height: 0.98;
}

.index-header p {
    margin: 0;
    font-size: 0.81rem;
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 28px;
    margin: 44px 0 65px;
}

.photo-grid figure {
    margin: 0;
}

.photo-grid a {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
}

.photo-grid img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 350ms ease;
}

.photo-grid a:hover img {
    transform: scale(1.04);
}

.photo-grid figcaption {
    margin-top: 8px;
    font-family: "RotisSans", Arial, sans-serif;
    font-size: 0.57rem;
    letter-spacing: 0.12em;
}

.source-notes {
    display: grid;
    gap: 12px;
    max-width: 690px;
    padding-top: 20px;
    border-top: 1px solid var(--ink);
}

.source-notes p {
    margin: 0;
    font-size: 0.86rem;
    line-height: 1.6;
}

.source-notes a,
.source-notes > span:last-child,
.bottom-return {
    color: inherit;
    font-family: "RotisSans", Arial, sans-serif;
    font-size: 0.72rem;
    text-underline-offset: 4px;
}

.bottom-return {
    display: inline-block;
    margin-top: 65px;
}

@media (max-width: 850px) {
    .book {
        width: min(42vw, 430px);
        height: min(62vh, 570px);
        min-height: 380px;
    }

    .book-stage {
        padding: 90px 18px 75px;
    }

    .photo-overlay h1 {
        font-size: clamp(2rem, 4.4vw, 3.2rem);
    }

    .photo-overlay h2 {
        font-size: clamp(1.6rem, 4vw, 2.8rem);
    }

    .split-side,
    .note-rail,
    .end-details {
        padding: 10px 7px 58px;
        gap: 7px;
    }

    .split-side p,
    .note-rail p,
    .end-details p {
        font-size: 0.55rem;
    }
}

@media (max-width: 600px) {
    .book-top {
        padding: 16px;
        font-size: 0.58rem;
    }

    .book-identity {
        display: none;
    }

    .book-stage {
        min-height: 590px;
    }

    .book {
        width: 45.5vw;
        height: 53vh;
        min-height: 330px;
        transform: translateX(49%);
    }

    .page-guide {
        width: 100%;
        bottom: 22px;
        font-size: 0.47rem;
    }

    .turn {
        width: 29px;
        height: 29px;
        bottom: 8px;
        font-size: 0.9rem;
    }

    .turn-next {
        right: 7px;
    }

    .turn-prev {
        left: 7px;
    }

    .image-kicker,
    .page-topline,
    .contact-header span,
    .collage-words small {
        font-size: 0.42rem;
    }

    .photo-overlay h1 {
        font-size: clamp(1.45rem, 5vw, 2.5rem);
    }

    .photo-overlay h2 {
        font-size: 1.6rem;
    }

    .type-overlay strong {
        font-size: 2rem;
    }

    .type-overlay p {
        font-size: 0.48rem;
    }

    .split-photo-page {
        grid-template-columns: 72% 28%;
    }

    .split-side p,
    .note-rail p,
    .end-details p {
        font-size: 0.48rem;
        line-height: 1.2;
    }

    .note-rail h2,
    .end-details h2 {
        font-size: 0.86rem;
    }

    .contact-caption {
        font-size: 0.43rem;
    }

    .collage-words p {
        font-size: 0.85rem;
    }

    .source-notes p {
        font-size: 0.77rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .sheet,
    .photo-grid img {
        transition-duration: 0.01ms;
    }
}
