/* ============================================
   DAITOUA.COM - Archival Historical Experience
   ============================================ */

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    background-color: #F4EDE4;
    color: #4A3F35;
    font-family: 'Source Serif 4', 'Georgia', serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.1vw, 1.15rem);
    line-height: 1.75;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---- DOSSIER FRAME ---- */
.dossier-frame-outer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 1px solid rgba(92, 74, 58, 0.3);
    pointer-events: none;
    z-index: 100;
}

.dossier-frame-inner {
    position: fixed;
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    border: 1px solid rgba(92, 74, 58, 0.15);
    pointer-events: none;
    z-index: 100;
}

/* ---- BRASS FASTENERS ---- */
.brass-fastener {
    position: fixed;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, #D4B87A, #B8956A 50%, #8B7355 100%);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
    z-index: 101;
    pointer-events: none;
}

.brass-fastener--tl { top: 3px; left: 3px; }
.brass-fastener--tr { top: 3px; right: 3px; }
.brass-fastener--bl { bottom: 3px; left: 3px; }
.brass-fastener--br { bottom: 3px; right: 3px; }

/* ---- PAPER TEXTURE OVERLAY ---- */
.paper-texture {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
    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='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23noise)' opacity='0.5'/%3E%3C/svg%3E");
    background-repeat: repeat;
}

/* ---- VIGNETTE ---- */
.vignette-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 49;
    background: radial-gradient(ellipse at center, transparent 50%, rgba(30, 26, 22, 0.08) 100%);
}

/* ---- FOXING SPOTS ---- */
.foxing-spots {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 48;
}

.foxing-spot {
    position: absolute;
    border-radius: 50%;
    background-color: #C4B5A0;
}

/* ---- RED THREADS SVG ---- */
.red-threads {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 45;
}

.red-thread-path {
    fill: none;
    stroke: #A0522D;
    stroke-width: 1.5;
    stroke-opacity: 0.4;
    stroke-linecap: round;
}

.red-thread-path--glow {
    filter: drop-shadow(0 0 6px rgba(160, 82, 45, 0.3));
}

/* ---- NAVIGATION DRAWER ---- */
.drawer-trigger {
    position: fixed;
    left: 16px;
    top: 40%;
    z-index: 200;
    background: rgba(59, 47, 37, 0.08);
    border: 1px solid rgba(184, 149, 106, 0.3);
    border-radius: 4px;
    padding: 10px 8px;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.3s ease;
}

.drawer-trigger:hover {
    background: rgba(59, 47, 37, 0.15);
    transform: translateX(2px);
}

.card-catalog-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 320px;
    height: 100%;
    background-color: #3B2F25;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='wood'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.02 0.2' numOctaves='5' seed='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23wood)' opacity='0.05'/%3E%3C/svg%3E");
    z-index: 300;
    transform: translateX(-100%);
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow-y: auto;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
}

.card-catalog-drawer.is-open {
    transform: translateX(0);
}

.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(30, 26, 22, 0.5);
    z-index: 250;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.drawer-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 20px 16px;
    border-bottom: 1px solid rgba(196, 181, 160, 0.2);
}

.drawer-title {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.2em;
    color: #C9B99A;
    text-transform: uppercase;
}

.drawer-close {
    background: none;
    border: none;
    color: #C9B99A;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    transition: color 0.2s ease;
}

.drawer-close:hover {
    color: #F4EDE4;
}

.drawer-cards {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.catalog-card {
    display: block;
    background: #F4EDE4;
    border: 1px solid #C4B5A0;
    border-left: 2px solid #A0522D;
    border-radius: 2px;
    padding: 12px 16px;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.catalog-card:hover {
    transform: translateX(4px);
    box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.1);
}

.catalog-card__title {
    display: block;
    font-family: 'Playfair Display', serif;
    font-weight: 500;
    font-size: 0.9rem;
    color: #3B2F25;
    line-height: 1.3;
}

.catalog-card__date {
    display: block;
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: 0.75rem;
    color: #8B7D6B;
    margin-top: 4px;
    letter-spacing: 0.04em;
}

/* ---- DATE INDICATOR ---- */
.date-indicator {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 150;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.date-indicator__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #B8956A;
}

.date-indicator__text {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: 0.7rem;
    color: #8B7D6B;
    letter-spacing: 0.04em;
}

/* ---- OPENING SECTION ---- */
.opening-section {
    position: relative;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #F4EDE4;
    overflow: hidden;
}

.opening-content {
    text-align: center;
    position: relative;
    z-index: 10;
}

.opening-thread {
    width: 60vw;
    max-width: 600px;
    height: 4px;
    display: block;
    margin: 0 auto 0;
    opacity: 0;
}

.opening-thread.is-animating {
    opacity: 1;
}

.opening-thread line {
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    transition: stroke-dashoffset 2s ease-in-out;
}

.opening-thread.is-animating line {
    stroke-dashoffset: 0;
}

.site-title {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(3rem, 6vw, 5rem);
    letter-spacing: 0.2em;
    color: #3B2F25;
    line-height: 1.1;
    margin-bottom: 8px;
    overflow: hidden;
}

.title-letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

.title-letter.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.site-subtitle {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: 0.85rem;
    color: #8B7D6B;
    letter-spacing: 0.08em;
    margin-top: 12px;
    opacity: 0;
    transition: opacity 0.8s ease 2.5s;
}

.site-subtitle.is-visible {
    opacity: 1;
}

.scroll-chevron {
    position: absolute;
    bottom: -40vh;
    left: 50%;
    transform: translateX(-50%);
    animation: pulse-chevron 2s ease-in-out infinite;
}

@keyframes pulse-chevron {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

/* ---- TOPOGRAPHIC MAP OVERLAYS ---- */
.topo-map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1.5s ease;
    z-index: 1;
}

.topo-map.is-visible {
    opacity: 1;
}

.topo-map--1 {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 800 600'%3E%3Cellipse cx='400' cy='300' rx='350' ry='250' fill='none' stroke='%238B7355' stroke-width='0.5' opacity='0.06'/%3E%3Cellipse cx='400' cy='300' rx='300' ry='200' fill='none' stroke='%238B7355' stroke-width='0.5' opacity='0.06'/%3E%3Cellipse cx='400' cy='300' rx='250' ry='150' fill='none' stroke='%238B7355' stroke-width='0.5' opacity='0.06'/%3E%3Cellipse cx='400' cy='300' rx='200' ry='110' fill='none' stroke='%238B7355' stroke-width='0.5' opacity='0.06'/%3E%3Cellipse cx='400' cy='300' rx='150' ry='80' fill='none' stroke='%238B7355' stroke-width='0.5' opacity='0.06'/%3E%3Cellipse cx='400' cy='300' rx='100' ry='50' fill='none' stroke='%238B7355' stroke-width='0.5' opacity='0.06'/%3E%3C/svg%3E");
    background-size: cover;
    background-position: center;
}

.topo-map--2 {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 800 600'%3E%3Cpath d='M100,300 Q200,150 400,250 Q600,350 700,200' fill='none' stroke='%23C4B5A0' stroke-width='0.5' opacity='0.06'/%3E%3Cpath d='M80,340 Q220,180 420,280 Q620,380 720,230' fill='none' stroke='%23C4B5A0' stroke-width='0.5' opacity='0.06'/%3E%3Cpath d='M60,380 Q240,210 440,310 Q640,410 740,260' fill='none' stroke='%23C4B5A0' stroke-width='0.5' opacity='0.06'/%3E%3Cpath d='M120,260 Q180,120 380,220 Q580,320 680,170' fill='none' stroke='%23C4B5A0' stroke-width='0.5' opacity='0.06'/%3E%3Cpath d='M140,220 Q160,90 360,190 Q560,290 660,140' fill='none' stroke='%23C4B5A0' stroke-width='0.5' opacity='0.06'/%3E%3C/svg%3E");
    background-size: cover;
    background-position: center;
}

.topo-map--3 {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 800 600'%3E%3Cellipse cx='350' cy='250' rx='280' ry='180' fill='none' stroke='%23C4B5A0' stroke-width='0.5' opacity='0.06' transform='rotate(-10 350 250)'/%3E%3Cellipse cx='350' cy='250' rx='220' ry='130' fill='none' stroke='%23C4B5A0' stroke-width='0.5' opacity='0.06' transform='rotate(-10 350 250)'/%3E%3Cellipse cx='350' cy='250' rx='160' ry='90' fill='none' stroke='%23C4B5A0' stroke-width='0.5' opacity='0.06' transform='rotate(-10 350 250)'/%3E%3Cellipse cx='500' cy='400' rx='200' ry='120' fill='none' stroke='%23C4B5A0' stroke-width='0.5' opacity='0.06' transform='rotate(15 500 400)'/%3E%3Cellipse cx='500' cy='400' rx='140' ry='80' fill='none' stroke='%23C4B5A0' stroke-width='0.5' opacity='0.06' transform='rotate(15 500 400)'/%3E%3C/svg%3E");
    background-size: cover;
    background-position: center;
}

/* ---- PAPER TEAR DIVIDERS ---- */
.paper-tear {
    position: relative;
    width: 100%;
    height: 60px;
    z-index: 10;
    margin: -1px 0;
}

.paper-tear svg {
    display: block;
    width: 100%;
    height: 100%;
}

.paper-tear--light-to-light {
    background: transparent;
}

.paper-tear--light-to-dark {
    background: transparent;
}

.paper-tear--dark-to-light {
    background: transparent;
}

/* ---- CHAPTERS ---- */
.chapter {
    position: relative;
    padding: 80px 0 120px;
    min-height: 80vh;
}

.chapter--light {
    background-color: #F4EDE4;
}

.chapter--dark {
    background-color: #1E1A16;
    color: #C9B99A;
}

.chapter--dark .paper-texture-local {
    opacity: 0.03;
}

.chapter--final {
    padding-bottom: 60px;
}

.chapter-grid {
    display: grid;
    grid-template-columns: 1fr 220px;
    gap: 40px;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 60px;
    position: relative;
    z-index: 5;
}

.chapter-main {
    position: relative;
}

.chapter-number {
    display: block;
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: 0.8rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.chapter--light .chapter-number {
    color: #8B7D6B;
}

.chapter--dark .chapter-number {
    color: #8B7D6B;
}

.chapter-title {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(2rem, 4.5vw, 3.8rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    line-height: 1.1;
    margin-bottom: 40px;
}

.chapter--light .chapter-title {
    color: #3B2F25;
}

.chapter--dark .chapter-title {
    color: #C9B99A;
}

/* ---- DOCUMENT PANELS ---- */
.document-panel {
    background: #FAF6F0;
    border: 1px solid #C4B5A0;
    border-radius: 4px;
    padding: 32px;
    display: grid;
    grid-template-columns: 1fr 200px;
    gap: 24px;
    position: relative;
}

.document-panel--dark {
    background: rgba(250, 246, 240, 0.05);
    border-color: rgba(196, 181, 160, 0.2);
}

.document-panel__content {
    max-width: 38em;
}

.document-panel__content p {
    margin-bottom: 1.25em;
}

.document-panel__content p:last-child {
    margin-bottom: 0;
}

.chapter--dark .document-panel__content {
    color: #C9B99A;
}

.document-panel__annotations {
    border-left: 1px solid rgba(196, 181, 160, 0.3);
    padding-left: 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ---- ANNOTATIONS ---- */
.annotation {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.annotation__date {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: 0.75rem;
    color: #A0522D;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.chapter--dark .annotation__date {
    color: #D4A574;
}

.annotation__text {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: 0.75rem;
    color: #8B7D6B;
    line-height: 1.5;
}

.chapter--dark .annotation__text {
    color: rgba(201, 185, 154, 0.7);
}

/* ---- REVEAL ANIMATIONS ---- */
.reveal-element {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.reveal-element.is-revealed {
    opacity: 1;
    transform: translateY(0);
}

.reveal-annotation {
    opacity: 0;
    transition: opacity 0.5s ease-out;
}

.reveal-annotation.is-revealed {
    opacity: 0.7;
}

/* ---- MARGINAL NOTES (gutter) ---- */
.chapter-gutter {
    display: flex;
    flex-direction: column;
    gap: 32px;
    padding-top: 80px;
}

.marginal-note {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.marginal-note__coord {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: 0.72rem;
    color: #A0522D;
    letter-spacing: 0.04em;
}

.marginal-note--dark .marginal-note__coord {
    color: #D4A574;
}

.marginal-note__text {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: 0.72rem;
    color: #8B7D6B;
    line-height: 1.5;
}

.marginal-note--dark .marginal-note__text {
    color: rgba(201, 185, 154, 0.6);
}

/* ---- STAMP MARKS ---- */
.stamp-mark {
    position: absolute;
    width: 80px;
    height: 80px;
    z-index: 2;
    animation: stamp-rotate 120s linear infinite;
}

.stamp-mark--1 {
    top: 20px;
    right: -40px;
}

.stamp-mark--2 {
    top: 30px;
    right: -30px;
}

@keyframes stamp-rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ---- SOURCE LIST ---- */
.source-list {
    list-style: none;
    padding: 0;
    margin: 1em 0;
}

.source-list li {
    position: relative;
    padding: 12px 0 12px 20px;
    border-bottom: 1px solid rgba(196, 181, 160, 0.3);
}

.source-list li:last-child {
    border-bottom: none;
}

.source-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 20px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #A0522D;
    opacity: 0.5;
}

.source-list li strong {
    color: #3B2F25;
    font-weight: 600;
}

/* ---- LINKS ---- */
a {
    color: #A0522D;
    text-decoration: none;
    background-image: linear-gradient(to right, #A0522D 33%, transparent 33%);
    background-size: 6px 1px;
    background-repeat: repeat-x;
    background-position: bottom;
    transition: background-size 0.3s ease;
}

a:hover {
    background-image: linear-gradient(to right, #A0522D 100%, transparent 0%);
    background-size: 6px 1px;
}

.catalog-card {
    background-image: none;
}

.catalog-card:hover {
    background-image: none;
}

/* ---- CLOSING SECTION ---- */
.closing-section {
    background-color: #F4EDE4;
    padding: 60px 40px 80px;
    text-align: center;
    position: relative;
    z-index: 5;
}

.closing-content {
    max-width: 600px;
    margin: 0 auto;
}

.closing-rule {
    width: 60px;
    height: 1px;
    background-color: #C4B5A0;
    margin: 0 auto 32px;
}

.closing-jp {
    font-family: 'Noto Serif JP', serif;
    font-weight: 600;
    font-size: clamp(1.2rem, 2.5vw, 2rem);
    color: #5C4A3A;
    letter-spacing: 0.15em;
}

.closing-attribution {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: 0.8rem;
    color: #8B7D6B;
    margin-top: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.closing-disclaimer {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: 0.72rem;
    color: #8B7D6B;
    margin-top: 24px;
    line-height: 1.7;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
    opacity: 0.7;
}

/* ---- IMAGE FILTER (if images are added) ---- */
img {
    filter: sepia(0.3) saturate(0.8) contrast(1.05);
}

/* ---- RESPONSIVE ---- */
@media (max-width: 900px) {
    .chapter-grid {
        grid-template-columns: 1fr;
        padding: 0 24px;
    }

    .chapter-gutter {
        padding-top: 20px;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 16px;
    }

    .document-panel {
        grid-template-columns: 1fr;
    }

    .document-panel__annotations {
        border-left: none;
        border-top: 1px solid rgba(196, 181, 160, 0.3);
        padding-left: 0;
        padding-top: 16px;
    }

    .card-catalog-drawer {
        width: 280px;
    }

    .stamp-mark {
        display: none;
    }
}

@media (max-width: 600px) {
    .chapter {
        padding: 50px 0 80px;
    }

    .chapter-grid {
        padding: 0 16px;
    }

    .document-panel {
        padding: 20px 16px;
    }

    .dossier-frame-outer,
    .dossier-frame-inner,
    .brass-fastener {
        display: none;
    }

    .drawer-trigger {
        left: 10px;
    }

    .date-indicator {
        right: 12px;
        bottom: 12px;
    }
}