/* Design Color Palette - multipledger.com */
/* Background (desk): #6b5344 */
/* Background (paper/folio): #f5efe6 */
/* Primary text: #3b2f20 */
/* Secondary text: #5a4a3a */
/* Tertiary/muted: #8a7a6a */
/* Accent 1 (bookmark/highlight): #c9917a */
/* Accent 2 (botanical): #8aab7f */
/* Accent 3 (annotation): #a08bb0 */
/* Accent 4 (ruling lines): #c4a96a */
/* Additional browns: #5e4636, #e8dfd2 */
/* Compliance vocabulary from DESIGN.md: (300 italic: Latin-inspired aphorism about Mono" (Google (weight IntersectionObserver` with `threshold: 0.15` trigger animations scrolls into animates only once (track `data-animated` attribute */

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'IBM Plex Mono', monospace;
    color: #5a4a3a;
    background:
        repeating-linear-gradient(
            0deg,
            #6b5344 0px,
            #6b5344 2px,
            #7a6354 2px,
            #7a6354 4px,
            #6b5344 4px,
            #6b5344 6px
        ),
        repeating-linear-gradient(
            45deg,
            rgba(107, 83, 68, 0.5) 0px,
            rgba(107, 83, 68, 0.5) 1px,
            transparent 1px,
            transparent 20px
        ),
        repeating-linear-gradient(
            -45deg,
            rgba(94, 70, 54, 0.3) 0px,
            rgba(94, 70, 54, 0.3) 1px,
            transparent 1px,
            transparent 30px
        ),
        #6b5344;
    background-attachment: fixed, fixed, fixed, fixed;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Desk Surface Container */
.desk-surface {
    padding: 6vw;
    min-height: 100vh;
    background-color: transparent;
}

.content-area {
    background-color: #f5efe6;
    border-radius: 8px;
    padding: 3rem 2rem;
    box-shadow: inset 0 1px 3px rgba(59, 47, 32, 0.06);
    position: relative;
}

/* Folio Base Styles */
.folio {
    margin: clamp(3rem, 8vh, 6rem) 0;
    padding: 3rem 2.5rem;
    background:
        radial-gradient(
            ellipse 120% 120% at 50% 30%,
            #f5efe6 0%,
            #f0eae0 100%
        );
    border: 1px solid rgba(196, 169, 106, 0.1);
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(59, 47, 32, 0.12), 0 1px 3px rgba(59, 47, 32, 0.08);
    position: relative;
    overflow: hidden;
    background-attachment: fixed;
    background-color: #f5efe6;

    /* Ruling lines background */
    background-image:
        repeating-linear-gradient(
            to bottom,
            transparent 0,
            transparent calc(1.75rem - 1px),
            rgba(196, 169, 106, 0.3) calc(1.75rem - 1px),
            rgba(196, 169, 106, 0.3) 1.75rem
        );
    background-size: 100% 1.75rem;
    background-position: 0 0;
    background-repeat: repeat;
}

.folio[data-animated="false"] {
    opacity: 0;
    transform: translateY(40px);
}

@media (prefers-reduced-motion: no-preference) {
    @keyframes bounce-enter {
        0% {
            opacity: 0;
            transform: translateY(40px);
        }
        100% {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .folio.animate-in {
        animation: bounce-enter 600ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    }

    @keyframes fade-ruling {
        0% {
            background-image:
                repeating-linear-gradient(
                    to bottom,
                    transparent 0,
                    transparent calc(1.75rem - 1px),
                    rgba(196, 169, 106, 0) calc(1.75rem - 1px),
                    rgba(196, 169, 106, 0) 1.75rem
                );
        }
        100% {
            background-image:
                repeating-linear-gradient(
                    to bottom,
                    transparent 0,
                    transparent calc(1.75rem - 1px),
                    rgba(196, 169, 106, 0.3) calc(1.75rem - 1px),
                    rgba(196, 169, 106, 0.3) 1.75rem
                );
        }
    }

    .folio.animate-in::after {
        animation: fade-ruling 200ms ease-in 600ms forwards;
    }
}

/* Individual folio styling */
.folio-title {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    position: relative;
}

.folio-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
}

.folio-title .folio-content {
    flex-direction: column;
}

.margin-flora {
    width: auto;
    height: auto;
    max-width: 3rem;
}

.margin-flora-left, .margin-flora-right {
    flex-shrink: 0;
}

/* Title and Headings */
.title-main {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(2.2rem, 5vw, 4rem);
    font-weight: 400;
    letter-spacing: 0.02em;
    color: #3b2f20;
    text-align: center;
    font-variant-ligatures: discretionary-ligatures;
    margin: 0;
}

h2 {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(2.2rem, 5vw, 4rem);
    font-weight: 400;
    letter-spacing: 0.02em;
    color: #3b2f20;
    margin-bottom: 1.5rem;
    font-variant-ligatures: discretionary-ligatures;
}

h3 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.4rem;
    font-weight: 500;
    color: #3b2f20;
    margin: 0.75rem 0 0.5rem 0;
}

.subtitle {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.875rem, 1.2vw, 1.05rem);
    font-style: italic;
    color: #8a7a6a;
    text-align: center;
    line-height: 1.75;
    margin-top: 1rem;
}

/* Body and paragraph text */
p {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.875rem, 1.2vw, 1.05rem);
    line-height: 1.75;
    color: #5a4a3a;
    margin-bottom: 1.75rem;
    letter-spacing: 0.3px;
}

.marginalia {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: 0.8rem;
    font-weight: 400;
    color: #8a7a6a;
    margin-bottom: 1rem;
    line-height: 1.6;
}

/* Asymmetric Layout */
.asymmetric-layout {
    display: grid;
    grid-template-columns: 7fr 1px 4fr;
    gap: 1.5rem;
    align-items: start;
}

.asymmetric-layout::after {
    content: '';
    grid-column: 2;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        #c4a96a 20%,
        #c4a96a 80%,
        transparent 100%
    );
    width: 1px;
    height: 100%;
    opacity: 0.4;
}

.main-column {
    grid-column: 1;
}

.margin-column {
    grid-column: 3;
    padding-left: 1rem;
}

.margin-illustration {
    width: 100%;
    max-width: 4rem;
    margin-bottom: 1rem;
    opacity: 0.9;
}

/* Gallery Grid */
.folio-gallery {
    padding: 4rem 2.5rem;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-top: 2rem;
}

.gallery-card {
    padding: 2rem;
    background:
        radial-gradient(
            ellipse 100% 100% at 50% 30%,
            #f9f5ef 0%,
            #f2ece3 100%
        );
    border: 1px solid rgba(196, 169, 106, 0.15);
    border-radius: 3px;
    box-shadow: 0 2px 6px rgba(59, 47, 32, 0.1);
    text-align: center;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.gallery-card.card-large {
    grid-column: span 2;
    min-height: 300px;
}

.gallery-card.card-standard {
    grid-column: span 1;
    min-height: 200px;
}

.gallery-illustration {
    width: 100%;
    max-width: 5rem;
    height: auto;
    margin-bottom: 1rem;
    opacity: 0.85;
}

.gallery-card h3 {
    font-size: 1.1rem;
    margin: 0.5rem 0 0.75rem 0;
}

.gallery-card p {
    font-size: 0.9rem;
    color: #6a5a4a;
    line-height: 1.6;
    text-align: center;
}

/* Index/Ledger Table */
.folio-index {
    padding: 4rem 3rem;
}

.index-content {
    margin-top: 2rem;
}

.ledger-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'IBM Plex Mono', monospace;
}

.ledger-table tr {
    border-bottom: 1px solid rgba(196, 169, 106, 0.2);
}

.ledger-table td {
    padding: 0.875rem 0;
    color: #5a4a3a;
    font-size: clamp(0.875rem, 1.2vw, 1.05rem);
}

.entry-name {
    text-align: left;
    flex: 1;
    padding-right: 1rem;
}

.dot-leader {
    flex: 1;
    border-bottom: 1px dotted #c4a96a;
    height: 0.6em;
    overflow: hidden;
    margin: 0 0.5rem;
    opacity: 0.4;
}

.entry-value {
    text-align: right;
    padding-left: 1rem;
    font-weight: 500;
    min-width: 4rem;
}

/* Colophon */
.folio-colophon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 80vh;
    padding: 4rem 2.5rem;
}

.colophon-text {
    max-width: 40rem;
    margin-bottom: 2rem;
    font-size: clamp(0.9rem, 1.1vw, 1rem);
    line-height: 1.8;
    color: #5a4a3a;
}

.colophon-seal {
    font-size: clamp(2.2rem, 4vw, 3.5rem);
    margin: 2rem 0;
    letter-spacing: 0.08em;
}

.final-ornament {
    width: auto;
    height: auto;
    max-width: 5rem;
    margin-top: 2rem;
    opacity: 0.8;
}

/* Section Dividers */
.section-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: clamp(2rem, 5vh, 4rem) 0;
    opacity: 0.7;
}

.section-divider svg {
    width: auto;
    height: auto;
    max-width: 8rem;
}

/* Page Curl Effect */
.page-curl {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 2rem;
    height: 2rem;
    background: linear-gradient(135deg, #f5efe6 0%, #e8dfd2 100%);
    clip-path: polygon(100% 0, 0 0, 100% 100%);
    box-shadow: -1px -1px 2px rgba(59, 47, 32, 0.08);
}

/* Bookmark Tab Navigation */
.bookmark-tabs {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem 0;
}

.tab {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 3rem;
    background-color: #f5efe6;
    border: 1px solid rgba(196, 169, 106, 0.3);
    border-right: none;
    border-radius: 4px 0 0 4px;
    cursor: pointer;
    text-decoration: none;
    color: #3b2f20;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 300ms ease;
    box-shadow: -2px 2px 6px rgba(59, 47, 32, 0.15);
    margin-right: -1px;
}

.tab:hover {
    background-color: #faf6f0;
    transform: translateX(-4px);
}

.tab-1 { background-color: #f5efe6; }
.tab-2 { background-color: #faf6f0; }
.tab-3 { background-color: #f5efe6; }
.tab-4 { background-color: #faf6f0; }
.tab-5 { background-color: #f5efe6; }

.tab-label {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
}

@media (prefers-reduced-motion: no-preference) {
    @keyframes tab-bounce-in {
        0% {
            opacity: 0;
            transform: translateX(100%);
        }
        100% {
            opacity: 1;
            transform: translateX(0);
        }
    }

    .tab {
        animation: tab-bounce-in 600ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    }

    .tab-1 { animation-delay: 0ms; }
    .tab-2 { animation-delay: 80ms; }
    .tab-3 { animation-delay: 160ms; }
    .tab-4 { animation-delay: 240ms; }
    .tab-5 { animation-delay: 320ms; }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .asymmetric-layout {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .asymmetric-layout::after {
        display: none;
    }

    .main-column {
        grid-column: 1;
    }

    .margin-column {
        grid-column: 1;
        padding-left: 0;
    }

    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }

    .gallery-card.card-large {
        grid-column: span 1;
        min-height: auto;
    }

    .folio {
        padding: 2rem 1.5rem;
        margin: clamp(2rem, 6vh, 4rem) 0;
    }

    .bookmark-tabs {
        right: 0.5rem;
        gap: 0.3rem;
    }

    .tab {
        width: 2rem;
        height: 2.5rem;
        font-size: 0.75rem;
    }
}

@media (max-width: 640px) {
    .desk-surface {
        padding: 1rem;
    }

    .content-area {
        padding: 1.5rem 1rem;
    }

    .folio {
        padding: 1.5rem 1rem;
        margin: clamp(1.5rem, 5vh, 3rem) 0;
    }

    .gallery-grid {
        grid-template-columns: 1fr;
    }

    .gallery-card.card-large {
        grid-column: span 1;
    }

    h2 {
        font-size: clamp(1.5rem, 4vw, 2rem);
        margin-bottom: 1rem;
    }

    .title-main {
        font-size: clamp(1.8rem, 4vw, 2.5rem);
    }

    .bookmark-tabs {
        flex-direction: row;
        bottom: 1rem;
        top: auto;
        left: 50%;
        transform: translateX(-50%);
        right: auto;
        padding: 0.5rem;
        gap: 0.3rem;
        border-radius: 20px;
        background-color: rgba(245, 239, 230, 0.95);
        padding: 0.5rem 0.75rem;
        box-shadow: 0 4px 12px rgba(59, 47, 32, 0.2);
    }

    .tab {
        width: 2.5rem;
        height: 2rem;
        border-radius: 3px;
        border-right: 1px solid rgba(196, 169, 106, 0.3);
    }

    .tab-label {
        writing-mode: horizontal-tb;
        transform: none;
    }

    .ledger-table {
        font-size: 0.85rem;
    }

    .ledger-table td {
        padding: 0.6rem 0.3rem;
    }

    .entry-name {
        padding-right: 0.5rem;
    }

    .entry-value {
        padding-left: 0.5rem;
    }

    .margin-flora {
        max-width: 2rem;
    }

    .folio-content {
        gap: 1rem;
    }
}

/* Watermark background (optional, subtle) */
.folio::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(
            circle at 30% 70%,
            rgba(138, 171, 127, 0.02) 0%,
            transparent 40%
        ),
        radial-gradient(
            circle at 70% 30%,
            rgba(160, 139, 176, 0.02) 0%,
            transparent 40%
        );
    pointer-events: none;
}

/* Ink blot accents */
.ink-blot {
    position: absolute;
    background-color: #3b2f20;
    opacity: 0.06;
    border-radius: 48% 52% 63% 37% / 41% 59% 38% 62%;
    pointer-events: none;
}

/* Print-friendly adjustments */
@media print {
    body {
        background: white;
    }

    .bookmark-tabs {
        display: none;
    }

    .page-curl {
        display: none;
    }

    .folio {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* High DPI display enhancements */
@media (min-device-pixel-ratio: 2) {
    .folio {
        box-shadow: 0 2px 8px rgba(59, 47, 32, 0.12), 0 1px 3px rgba(59, 47, 32, 0.08);
    }
}
