/* daitoua.quest - Sepia Archival Exhibition */

:root {
    --parchment: #EDE4D3;
    --deep-sepia: #3B2A1A;
    --burnt-umber: #6B3A2A;
    --faded-ink: #8B7355;
    --archive-shadow: #1E1914;
    --darkened-paper: #D4C4A0;
    --oxidized-bronze: #5C4A32;
    --gallery-white: #F5F0E8;
    --seal-vermillion: #A0382A;
    --heading-color: #4A3728;
    --body-color: #2C2218;
    --meta-color: #6B5B4A;
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--parchment);
    color: var(--body-color);
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.85;
    overflow-x: hidden;
}

/* Paper grain texture */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23g)' opacity='0.4'/%3E%3C/svg%3E");
    background-attachment: fixed;
}

/* === TOP NAV === */
.top-bar {
    position: fixed;
    top: -40px;
    left: 0;
    right: 0;
    height: 40px;
    background: var(--archive-shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
    transition: top 0.3s ease;
}

.top-bar.visible {
    top: 0;
}

.nav-domain {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
    color: var(--darkened-paper);
    letter-spacing: 0.06em;
}

.nav-contents {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
    color: var(--darkened-paper);
    background: none;
    border: 1px solid var(--faded-ink);
    padding: 4px 12px;
    cursor: pointer;
    letter-spacing: 0.06em;
    transition: background 0.2s ease;
}

.nav-contents:hover {
    background: rgba(139,115,85,0.2);
}

/* === TOC OVERLAY === */
.toc-overlay {
    position: fixed;
    inset: 0;
    background: rgba(30,25,20,0.95);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.toc-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

.toc-inner {
    text-align: center;
}

.toc-close {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
    color: var(--darkened-paper);
    background: none;
    border: 1px solid var(--faded-ink);
    padding: 6px 16px;
    cursor: pointer;
    margin-bottom: 40px;
    letter-spacing: 0.06em;
}

.toc-list {
    list-style: none;
}

.toc-list li {
    margin: 20px 0;
}

.toc-link {
    font-family: 'Playfair Display', serif;
    font-size: 24px;
    font-weight: 700;
    color: var(--darkened-paper);
    text-decoration: none;
    transition: color 0.2s ease;
}

.toc-link:hover {
    color: var(--burnt-umber);
}

/* === TITLE WALL === */
.title-wall {
    height: 100vh;
    display: grid;
    place-items: center;
    position: relative;
    background: var(--parchment);
    background-attachment: fixed;
}

.title-domain {
    position: absolute;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--faded-ink);
    opacity: 0.5;
}

.title-kanji {
    font-family: 'Noto Serif JP', serif;
    font-size: clamp(8rem, 15vw, 20rem);
    font-weight: 900;
    color: var(--deep-sepia);
    text-shadow:
        0 0 2px rgba(59,42,26,0.3),
        0 0 6px rgba(59,42,26,0.15),
        0 0 14px rgba(59,42,26,0.08);
    line-height: 1;
    opacity: 0;
    animation: inkFadeIn 1.5s ease-out 0.5s forwards;
}

.title-rule {
    width: clamp(200px, 40vw, 400px);
    height: 4px;
    margin: 20px auto;
    display: block;
}

.title-subtitle {
    font-family: 'Source Serif 4', serif;
    font-size: clamp(14px, 1.5vw, 18px);
    color: var(--faded-ink);
    text-align: center;
    opacity: 0;
    animation: fadeIn 1s ease-out 1.5s forwards;
}

.vertical-title {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    writing-mode: vertical-rl;
    font-family: 'Noto Serif JP', serif;
    font-size: 48px;
    font-weight: 900;
    color: var(--deep-sepia);
    opacity: 0.1;
}

/* === TIMELINE CORRIDOR === */
.timeline-corridor {
    display: flex;
    min-height: 100vh;
    padding: 80px 40px;
    scroll-margin-top: 80px;
}

.timeline-sidebar {
    width: 38.2%;
    position: sticky;
    top: 60px;
    height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-right: 40px;
}

.timeline-svg {
    width: 40px;
    height: 600px;
}

.tl-labels {
    position: absolute;
    left: 50px;
    top: 0;
    height: 600px;
}

.tl-label {
    position: absolute;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
    color: var(--faded-ink);
    opacity: 0;
    transition: opacity 0.3s ease;
    white-space: nowrap;
}

.tl-label.active {
    opacity: 1;
}

.tl-marker.active {
    fill: var(--burnt-umber);
    animation: markerPulse 0.6s ease-out;
}

.timeline-content {
    width: 61.8%;
    display: flex;
    flex-direction: column;
    gap: 40px;
}

.doc-card {
    background: var(--parchment);
    border: 1px solid var(--faded-ink);
    border-radius: 1px;
    padding: 30px;
    box-shadow:
        inset 0 0 30px rgba(107,58,42,0.04),
        0 2px 8px rgba(30,25,20,0.12);
    scroll-margin-top: 80px;
}

.doc-card-title {
    font-family: 'Playfair Display', serif;
    font-size: clamp(1.2rem, 2vw, 1.6rem);
    font-weight: 700;
    color: var(--heading-color);
    margin-bottom: 4px;
}

.doc-card-date {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
    color: var(--meta-color);
    letter-spacing: 0.06em;
    display: block;
    margin-bottom: 16px;
}

.doc-card p {
    margin-bottom: 12px;
}

/* === SECTION DIVIDERS === */
.section-divider {
    padding: 40px 0;
    display: flex;
    justify-content: center;
}

.section-divider svg {
    width: 60%;
    max-width: 400px;
    height: 10px;
}

/* === DOCUMENT GALLERY === */
.document-gallery {
    padding: 60px 40px;
    scroll-margin-top: 80px;
}

.gallery-title {
    font-family: 'Playfair Display', serif;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    font-weight: 700;
    color: var(--heading-color);
    text-align: center;
    margin-bottom: 50px;
}

.masonry-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
    max-width: 1100px;
    margin: 0 auto;
}

.archive-card {
    background: var(--parchment);
    border: 1px solid var(--faded-ink);
    border-radius: 1px;
    padding: 28px;
    box-shadow:
        inset 0 0 30px rgba(107,58,42,0.04),
        0 2px 8px rgba(30,25,20,0.12);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.4s ease, transform 0.4s ease, box-shadow 0.3s ease;
    cursor: default;
}

.archive-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.archive-card:hover {
    transform: scale(1.02);
    box-shadow:
        inset 0 0 30px rgba(107,58,42,0.04),
        0 4px 16px rgba(30,25,20,0.18);
}

.archive-card.tall {
    grid-row: span 2;
}

.card-heading {
    font-family: 'Playfair Display', serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--heading-color);
    margin-bottom: 4px;
}

.card-date {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    color: var(--meta-color);
    letter-spacing: 0.06em;
    display: block;
    margin-bottom: 12px;
}

.card-excerpt {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 0;
    transition: all 0.3s ease;
}

.archive-card:hover .card-excerpt {
    -webkit-line-clamp: unset;
}

.card-expanded {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    margin-top: 0;
}

.archive-card:hover .card-expanded {
    max-height: 300px;
    margin-top: 12px;
}

.card-more {
    display: block;
    text-align: center;
    color: var(--faded-ink);
    font-size: 18px;
    letter-spacing: 0.3em;
    margin-top: 8px;
    transition: opacity 0.2s ease;
}

.archive-card:hover .card-more {
    opacity: 0;
}

/* === READING ROOM === */
.reading-room {
    padding: 80px 40px;
    scroll-margin-top: 80px;
}

.room-title {
    font-family: 'Playfair Display', serif;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    font-weight: 700;
    color: var(--heading-color);
    text-align: center;
    margin-bottom: 50px;
}

.room-content {
    max-width: 680px;
    margin: 0 auto;
}

.sub-heading {
    font-family: 'Playfair Display', serif;
    font-size: clamp(1.1rem, 2vw, 1.4rem);
    font-weight: 700;
    color: var(--heading-color);
    margin: 40px 0 16px;
}

.room-content p {
    margin-bottom: 20px;
}

.pull-quote {
    margin: 40px 0 40px -40px;
    padding-left: 20px;
    border-left: 3px solid var(--burnt-umber);
}

.pull-quote p {
    font-family: 'Playfair Display', serif;
    font-size: 1.3em;
    font-style: italic;
    font-weight: 700;
    color: var(--heading-color);
    line-height: 1.6;
}

.footnote {
    color: var(--oxidized-bronze);
    cursor: help;
    font-size: 0.8em;
    position: relative;
}

.footnote:hover {
    color: var(--burnt-umber);
}

/* === COLOPHON === */
.colophon {
    background: var(--darkened-paper);
    padding: 80px 40px;
    text-align: center;
    scroll-margin-top: 80px;
}

.inkan-seal {
    margin-bottom: 40px;
}

.colophon-title {
    font-family: 'Playfair Display', serif;
    font-size: 20px;
    font-weight: 700;
    color: var(--heading-color);
    margin-bottom: 24px;
}

.colophon-text {
    font-family: 'Source Serif 4', serif;
    font-size: 15px;
    color: var(--meta-color);
    max-width: 600px;
    margin: 0 auto 16px;
    line-height: 1.7;
}

.colophon-domain {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
    color: var(--faded-ink);
    letter-spacing: 0.06em;
    display: block;
    margin-top: 30px;
}

/* === FOOTNOTE TOOLTIP === */
.footnote-tooltip {
    position: absolute;
    background: var(--gallery-white);
    border: 1px solid var(--faded-ink);
    box-shadow: 0 2px 8px rgba(30,25,20,0.15);
    padding: 12px 16px;
    font-family: 'Source Serif 4', serif;
    font-size: 14px;
    color: var(--body-color);
    max-width: 320px;
    line-height: 1.5;
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.footnote-tooltip.visible {
    opacity: 1;
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes markerPulse {
    0% { r: 4; }
    50% { r: 6; }
    100% { r: 4; }
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .timeline-corridor {
        flex-direction: column;
        padding: 60px 20px;
    }

    .timeline-sidebar {
        width: 100%;
        position: relative;
        height: auto;
        padding-right: 0;
        padding-bottom: 30px;
    }

    .timeline-content {
        width: 100%;
    }

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

    .archive-card.tall {
        grid-row: span 1;
    }

    .vertical-title {
        display: none;
    }

    .pull-quote {
        margin-left: 0;
    }
}

@media (max-width: 480px) {
    .title-kanji {
        font-size: 6rem;
    }

    .document-gallery,
    .reading-room {
        padding: 40px 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
