/* ===== ROOT & VARIABLES ===== */
:root {
    /* Color palette */
    --bg-primary: #F6F1EB;
    --bg-secondary: #EDE5DA;
    --text-primary: #5B4A3F;
    --text-secondary: #6E5D50;
    --accent-warm: #C4A882;
    --accent-cool: #5A7E8C;
    --accent-cool-dark: #4A6B78;
    --divider: #D8CCBC;

    /* Typography */
    --font-display: 'Commissioner', sans-serif;
    --font-mono: 'DM Mono', monospace;

    /* Easing */
    --ease-smooth: cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-snap-type: y mandatory;
    height: 100%;
}

body {
    font-family: var(--font-display);
    background-color: var(--bg-primary);
    color: var(--text-secondary);
    line-height: 1.72;
    overflow-x: hidden;
    min-height: 100%;
}

/* ===== SECTION STRUCTURE ===== */
main {
    width: 100%;
}

.section {
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    overflow: hidden;
}

.section-content {
    width: 100%;
    max-width: 640px;
    padding: 80px 40px;
    text-align: center;
    position: relative;
    z-index: 2;
    /* Optical centering at 42% from top */
    transform: translateY(-8vh);
}

/* Background colors alternate */
.section-cover {
    background-color: var(--bg-primary);
}

.section-frontispiece {
    background-color: var(--bg-secondary);
}

.section-contents {
    background-color: var(--bg-primary);
}

.section-plate {
    background-color: var(--bg-secondary);
}

.section-colophon {
    background-color: var(--bg-primary);
}

/* ===== CHAPTER NUMBERS ===== */
.chapter-number {
    position: absolute;
    top: 40px;
    left: 40px;
    font-size: 6rem;
    font-weight: 300;
    color: var(--text-primary);
    opacity: 0.06;
    z-index: 1;
    line-height: 1;
}

/* ===== PAGE CORNER MOTIF ===== */
.section::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 16px;
    height: 16px;
    background: linear-gradient(135deg, transparent 50%, var(--divider) 50%);
    z-index: 3;
    transition: transform 300ms var(--ease-smooth);
}

.section:hover::before {
    transform: translateY(-2px);
}

/* ===== SECTION DIVIDERS ===== */
.section-divider {
    width: 60vw;
    height: 1px;
    background-color: var(--accent-warm);
    opacity: 0.3;
    margin: 0 auto;
    display: block;
}

/* ===== TYPOGRAPHY ===== */
h1, h2 {
    font-family: var(--font-display);
    color: var(--text-primary);
    font-weight: 400;
    letter-spacing: 0.01em;
    line-height: 1.25;
}

.domain-title {
    font-size: clamp(2.4rem, 6vw, 3.5rem);
    font-weight: 300;
    margin-bottom: 16px;
    text-transform: lowercase;
}

.domain-subtitle {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--accent-warm);
    letter-spacing: 0.06em;
    font-weight: 400;
    text-transform: lowercase;
}

/* Section II: Frontispiece */
.frontispiece-text {
    margin-top: 40px;
    text-align: left;
}

.frontispiece-text p {
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    color: var(--text-secondary);
    margin-bottom: 1.5em;
    max-width: 38em;
    margin-left: auto;
    margin-right: auto;
}

.frontispiece-text p:last-child {
    margin-bottom: 0;
}

/* Section III: Contents list */
.contents-list {
    list-style: none;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.contents-item {
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    font-weight: 400;
    color: var(--text-secondary);
    transition: all 300ms var(--ease-smooth);
    position: relative;
    padding-left: 20px;
    opacity: 0;
    transform: translateY(20px);
}

.contents-item:hover {
    transform: translateY(-2px);
    color: var(--accent-cool-dark);
}

.item-number {
    font-family: var(--font-mono);
    color: var(--accent-cool);
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    margin-right: 8px;
    position: absolute;
    left: 0;
}

/* Section IV: Image pair */
.image-pair {
    display: flex;
    gap: 32px;
    justify-content: center;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.plate-image {
    width: 280px;
    aspect-ratio: 3 / 2;
    margin: 0;
    transition: all 300ms var(--ease-smooth);
}

.plate-image:hover {
    transform: translateY(-4px);
}

.image-pair:has(.plate-image:nth-child(1):hover) .plate-image:nth-child(2) {
    opacity: 0.85;
}

.image-pair:has(.plate-image:nth-child(2):hover) .plate-image:nth-child(1) {
    opacity: 0.85;
}

.plate-caption {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--accent-warm);
    letter-spacing: 0.06em;
    max-width: 560px;
    margin: 0 auto;
    text-align: center;
    line-height: 1.6;
}

/* Section V: Colophon */
.colophon-title {
    font-size: 1.2rem;
    font-weight: 400;
    text-transform: lowercase;
    margin-bottom: 8px;
}

.colophon-year {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--accent-warm);
    letter-spacing: 0.06em;
    margin-bottom: 12px;
}

.colophon-contact {
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.colophon-contact a {
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 1px solid var(--accent-warm);
    transition: color 300ms var(--ease-smooth);
}

.colophon-contact a:hover {
    color: var(--accent-cool);
}

.colophon-credit {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--accent-warm);
    letter-spacing: 0.06em;
    opacity: 0.8;
}

/* ===== IMAGES & DUOTONE ===== */
.duotone-image {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-primary);
}

.duotone-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    filter: grayscale(100%) contrast(1.1) sepia(0.3);
    mix-blend-mode: multiply;
}

.duotone-image::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--accent-cool);
    opacity: 0.4;
    mix-blend-mode: color;
    pointer-events: none;
}

.duotone-image::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--accent-warm);
    opacity: 0.2;
    mix-blend-mode: lighten;
    pointer-events: none;
}

/* Frontispiece image */
.frontispiece-image {
    width: 100%;
    max-width: 560px;
    aspect-ratio: 3 / 2;
    margin: 0 auto;
    overflow: hidden;
    box-shadow: 0 0 0 rgba(90, 126, 140, 0.08);
    transition: all 300ms var(--ease-smooth);
}

.frontispiece-image:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 20px rgba(90, 126, 140, 0.08);
}

/* ===== PAGE INDICATOR ===== */
.page-indicator {
    position: fixed;
    bottom: 40px;
    right: 40px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 1000;
    opacity: 0;
    transition: opacity 800ms var(--ease-smooth);
}

.page-indicator.visible {
    opacity: 1;
}

.page-dot {
    width: 6px;
    height: 6px;
    border: 1px solid var(--accent-warm);
    border-radius: 50%;
    background-color: transparent;
    cursor: pointer;
    transition: all 400ms ease-out;
    padding: 0;
}

.page-dot.active {
    background-color: var(--text-primary);
    border-color: var(--text-primary);
}

/* ===== SPINE LINES ===== */
.spine-lines {
    position: fixed;
    left: 24px;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    flex-direction: column;
    gap: 4px;
    z-index: 1;
}

@media (min-width: 1025px) {
    .spine-lines {
        display: flex;
    }
}

.spine-line {
    width: 1px;
    height: 60px;
    background-color: var(--divider);
    opacity: 0.3;
}

.spine-line:nth-child(1) {
    opacity: 0.3;
}

.spine-line:nth-child(2) {
    opacity: 0.25;
}

.spine-line:nth-child(3) {
    opacity: 0.4;
}

.spine-line:nth-child(4) {
    opacity: 0.2;
}

.spine-line:nth-child(5) {
    opacity: 0.35;
}

.spine-line:nth-child(6) {
    opacity: 0.18;
}

.spine-line:nth-child(7) {
    opacity: 0.28;
}

.spine-line:nth-child(8) {
    opacity: 0.16;
}

.spine-line-extended {
    display: none;
}

.spine-lines.extended .spine-line-extended {
    display: block;
}

/* ===== MARGIN ANNOTATIONS ===== */
.margin-annotation {
    position: fixed;
    left: 0;
    top: 42%;
    display: none;
    z-index: 2;
    opacity: 0;
    transition: opacity 400ms var(--ease-smooth);
}

.margin-annotation.visible {
    display: flex;
    opacity: 1;
}

.annotation-mark {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--accent-warm);
    letter-spacing: 0.06em;
    padding-left: 8px;
    border-left: 1px solid var(--accent-warm);
    opacity: 0.8;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUpStagger {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spreadHorizontal {
    from {
        transform: scaleX(0.95);
    }
    to {
        transform: scaleX(1);
    }
}

.frontispiece-image {
    opacity: 0;
}

.frontispiece-text {
    opacity: 0;
}

.section-frontispiece.is-visible .frontispiece-image,
.section-frontispiece.is-visible .frontispiece-text {
    animation: fadeIn 600ms var(--ease-smooth) forwards;
}

.section-contents.is-visible .contents-item {
    animation: slideUpStagger 400ms var(--ease-smooth) forwards;
}

.section-contents.is-visible .contents-item:nth-child(1) {
    animation-delay: 0ms;
}

.section-contents.is-visible .contents-item:nth-child(2) {
    animation-delay: 100ms;
}

.section-contents.is-visible .contents-item:nth-child(3) {
    animation-delay: 200ms;
}

.section-contents.is-visible .contents-item:nth-child(4) {
    animation-delay: 300ms;
}

.section-contents.is-visible .contents-item:nth-child(5) {
    animation-delay: 400ms;
}

.image-pair {
    transform: scaleX(0.95);
}

.section-plate.is-visible .image-pair {
    animation: spreadHorizontal 500ms var(--ease-smooth) forwards;
}

.section-contents.is-visible .contents-item:hover {
    transform: translateY(-2px);
    color: var(--accent-cool-dark);
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .section-content {
        padding: 60px 24px;
    }

    .chapter-number {
        font-size: 4rem;
        top: 20px;
        left: 20px;
    }

    .image-pair {
        flex-direction: column;
        gap: 24px;
    }

    .plate-image {
        width: 100%;
        max-width: 280px;
    }

    .page-indicator {
        bottom: 24px;
        right: 24px;
        gap: 8px;
    }

    .domain-subtitle,
    .plate-caption,
    .colophon-year,
    .annotation-mark {
        font-size: 0.7rem;
    }
}

@media (max-width: 480px) {
    .section-content {
        padding: 40px 16px;
        max-width: 100%;
    }

    .domain-title {
        font-size: 1.8rem;
    }

    .chapter-number {
        font-size: 3rem;
        top: 12px;
        left: 12px;
    }

    .page-indicator {
        bottom: 12px;
        right: 12px;
        gap: 6px;
    }

    .page-dot {
        width: 5px;
        height: 5px;
    }

    .frontispiece-text p {
        font-size: 0.95rem;
    }

    .contents-item {
        font-size: 0.95rem;
    }

    .section-contents .contents-item {
        opacity: 1;
        transform: none;
    }

    .image-pair {
        padding: 0 16px;
    }

    .plate-image {
        width: 100%;
    }
}
