/* ========================================
   daitoua.quest - Archival Investigation
   Palette: "Archival Lamplight"
   ======================================== */

/* --- CSS Custom Properties --- */
:root {
    --deep-archive: #0D0A06;
    --walnut-desk: #2C1810;
    --foxed-parchment: #D4C5A0;
    --aged-cream: #F0E6D0;
    --red-seal: #8B2500;
    --faded-ink: #3D2817;
    --lamplight-gold: #C49B3C;
    --margin-blue: #2B4570;
    --cork: #C4956A;
    --walnut-mid: #3D2817;
    --near-black: #1A1209;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--deep-archive);
    color: var(--faded-ink);
    font-family: 'Lora', serif;
    font-weight: 400;
    font-size: clamp(15px, 1.1vw, 18px);
    line-height: 1.75;
    overflow-x: hidden;
}

/* --- OPENING VIEWPORT --- */
.opening-viewport {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--deep-archive);
    overflow: hidden;
}

.lamp-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 800px;
    height: 800px;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(196,155,60,0.15) 0%, rgba(196,155,60,0.05) 35%, transparent 70%);
    border-radius: 50%;
    opacity: 0;
    animation: lampOn 600ms ease-out forwards;
    pointer-events: none;
}

@keyframes lampOn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* Envelope */
.envelope {
    position: relative;
    opacity: 0;
    transform: translateY(20px);
    animation: envelopeFadeIn 600ms ease-out 600ms forwards;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
}

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

.envelope-body {
    position: relative;
    width: clamp(320px, 50vw, 560px);
    padding: 48px 40px 40px;
    background-color: var(--foxed-parchment);
    border-radius: 4px;
    transform: rotate(1.5deg);
    box-shadow:
        4px 4px 12px rgba(0,0,0,0.4),
        inset 0 0 40px rgba(60,40,20,0.3);
    text-align: center;
}

.envelope-flap {
    position: absolute;
    top: -28px;
    left: 10%;
    width: 80%;
    height: 56px;
    background: linear-gradient(to bottom, var(--aged-cream), var(--foxed-parchment));
    clip-path: polygon(0 100%, 50% 0, 100% 100%);
    transform-origin: bottom center;
    transform: rotateX(0deg);
    transition: transform 0.6s ease-out;
    box-shadow: 0 -2px 6px rgba(0,0,0,0.15);
}

.envelope.opened .envelope-flap {
    transform: rotateX(180deg);
}

.wax-seal {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, #B03000, var(--red-seal), #6B1D00);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    opacity: 0;
    animation: sealAppear 500ms ease-out 1200ms forwards;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.5);
}

@keyframes sealAppear {
    0% { opacity: 0; transform: scale(1.0); }
    50% { opacity: 1; transform: scale(1.05); }
    100% { opacity: 1; transform: scale(1.0); }
}

.seal-kanji {
    font-family: 'Noto Serif JP', serif;
    font-weight: 700;
    font-size: 24px;
    color: var(--aged-cream);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.envelope-stamp {
    font-family: 'Special Elite', cursive;
    font-size: clamp(24px, 4vw, 56px);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--red-seal);
    filter: blur(0.3px);
    transform: rotate(-1deg);
    margin-bottom: 8px;
    overflow: hidden;
    white-space: nowrap;
}

.envelope-stamp .char {
    display: inline-block;
    opacity: 0;
    animation: typeChar 80ms steps(1) forwards;
}

.envelope-subtitle {
    font-family: 'Noto Serif JP', serif;
    font-weight: 700;
    font-size: clamp(18px, 3vw, 36px);
    color: var(--faded-ink);
    opacity: 0;
    animation: fadeIn 600ms ease-out 1400ms forwards;
    letter-spacing: 0.15em;
}

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

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

/* Intro document */
.envelope-document {
    width: clamp(300px, 48vw, 520px);
    margin-top: 20px;
    padding: 28px 32px;
    background-color: var(--aged-cream);
    border-radius: 2px;
    box-shadow:
        3px 3px 10px rgba(0,0,0,0.35),
        inset 0 0 30px rgba(60,40,20,0.15);
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
    z-index: 1;
}

.envelope-document.revealed {
    opacity: 1;
    transform: translateY(0);
}

.document-text {
    font-family: 'Lora', serif;
    font-size: clamp(14px, 1vw, 16px);
    line-height: 1.8;
    color: var(--faded-ink);
    margin-bottom: 16px;
}

.document-annotation {
    font-family: 'Caveat', cursive;
    font-size: clamp(16px, 1.3vw, 22px);
    color: #5C3A1E;
    transform: rotate(-1deg);
    text-align: right;
}

/* Scroll indicator */
.scroll-indicator {
    position: absolute;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    animation: pulseAttention 2s ease-in-out 1800ms infinite, fadeIn 400ms ease-out 1800ms forwards;
    z-index: 3;
}

@keyframes pulseAttention {
    0%, 100% { transform: translateX(-50%) translateY(0); opacity: 0.6; }
    50% { transform: translateX(-50%) translateY(8px); opacity: 1; }
}

/* --- INVESTIGATION BOARD --- */
.investigation-board {
    position: relative;
    min-height: 100vh;
    padding: 80px 5vw 120px;
    background-color: var(--near-black);
    overflow: hidden;
}

.investigation-board::before {
    content: '';
    position: absolute;
    inset: 0;
    background-color: var(--cork);
    opacity: 0.08;
    pointer-events: none;
}

.section-stamp {
    text-align: center;
    margin-bottom: 60px;
    position: relative;
    z-index: 2;
}

.stamp-circle {
    display: inline-block;
    font-family: 'Special Elite', cursive;
    font-size: clamp(16px, 2vw, 24px);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--red-seal);
    border: 2px solid var(--red-seal);
    border-radius: 50%;
    width: clamp(100px, 14vw, 160px);
    height: clamp(100px, 14vw, 160px);
    line-height: clamp(100px, 14vw, 160px);
    filter: blur(0.3px);
    transform: rotate(-7deg);
    opacity: 0.85;
}

.board-surface {
    position: relative;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 40px 32px;
    max-width: 1200px;
    margin: 0 auto;
    z-index: 2;
}

.red-strings {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.red-strings line {
    stroke: var(--red-seal);
    stroke-width: 1.5;
    opacity: 0.6;
    filter: url(#string-blur);
}

/* Pinned cards */
.pinned-card {
    position: relative;
    background-color: var(--foxed-parchment);
    padding: 32px 24px 24px;
    border-radius: 2px;
    box-shadow:
        4px 4px 12px rgba(0,0,0,0.4),
        inset 0 0 40px rgba(60,40,20,0.3);
    opacity: 0;
    transform: translateY(-30px);
    transition: opacity 0.4s ease-out, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 2;
}

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

.card-1 { transform: rotate(-2deg) translateY(-30px); }
.card-1.visible { transform: rotate(-2deg) translateY(0); }

.card-2 { transform: rotate(1.5deg) translateY(-30px); }
.card-2.visible { transform: rotate(1.5deg) translateY(0); }

.card-3 { transform: rotate(-1deg) translateY(-30px); }
.card-3.visible { transform: rotate(-1deg) translateY(0); }

.card-4 { transform: rotate(2.5deg) translateY(-30px); }
.card-4.visible { transform: rotate(2.5deg) translateY(0); }

.card-5 { transform: rotate(-0.5deg) translateY(-30px); }
.card-5.visible { transform: rotate(-0.5deg) translateY(0); }

/* Paperclip */
.paperclip {
    position: absolute;
    top: -8px;
    right: 20px;
    width: 16px;
    height: 40px;
    border: 2px solid #A0A0A0;
    border-radius: 8px 8px 4px 4px;
    background: transparent;
}

.paperclip::after {
    content: '';
    position: absolute;
    top: 6px;
    left: 3px;
    width: 10px;
    height: 28px;
    border: 2px solid #B0B0B0;
    border-radius: 5px 5px 3px 3px;
    background: transparent;
}

/* Pin */
.pin {
    position: absolute;
    top: -6px;
    left: 24px;
    width: 12px;
    height: 12px;
    background: radial-gradient(circle at 40% 35%, #CC3333, #991111);
    border-radius: 50%;
    box-shadow: 1px 2px 4px rgba(0,0,0,0.4);
}

.pin::after {
    content: '';
    position: absolute;
    top: 10px;
    left: 5px;
    width: 2px;
    height: 10px;
    background: #888;
    border-radius: 0 0 1px 1px;
}

.card-title {
    font-family: 'Special Elite', cursive;
    font-size: clamp(16px, 1.8vw, 22px);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--faded-ink);
    margin-bottom: 4px;
    filter: blur(0.2px);
}

.card-date {
    font-family: 'Special Elite', cursive;
    font-size: 13px;
    color: var(--red-seal);
    margin-bottom: 12px;
    letter-spacing: 0.04em;
}

.card-body {
    font-family: 'Lora', serif;
    font-size: clamp(13px, 0.95vw, 15px);
    line-height: 1.7;
    color: var(--faded-ink);
    margin-bottom: 12px;
}

.card-annotation {
    font-family: 'Caveat', cursive;
    font-size: clamp(14px, 1.1vw, 18px);
    color: #5C3A1E;
    transform: rotate(-0.5deg);
    line-height: 1.4;
}

/* --- TIMELINE CORRIDOR --- */
.timeline-corridor {
    position: relative;
    min-height: 100vh;
    padding: 100px 5vw 120px;
    background: linear-gradient(to bottom, var(--near-black), var(--deep-archive));
    overflow: hidden;
}

.timeline-stamp {
    margin-bottom: 80px;
}

.timeline-thread {
    position: absolute;
    left: 50%;
    top: 200px;
    bottom: 80px;
    width: 2px;
    background-color: var(--red-seal);
    transform: translateX(-50%);
    transform-origin: top;
    opacity: 0.7;
}

.timeline-entries {
    position: relative;
    max-width: 900px;
    margin: 0 auto;
    z-index: 2;
}

.timeline-entry {
    position: relative;
    width: 45%;
    margin-bottom: 60px;
    opacity: 0;
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.entry-left {
    margin-right: auto;
    text-align: right;
    padding-right: 40px;
    transform: translateX(-30px);
}

.entry-left.visible {
    opacity: 1;
    transform: translateX(0);
}

.entry-right {
    margin-left: auto;
    text-align: left;
    padding-left: 40px;
    transform: translateX(30px);
}

.entry-right.visible {
    opacity: 1;
    transform: translateX(0);
}

.entry-marker {
    position: absolute;
    top: 8px;
    width: 12px;
    height: 12px;
    background-color: var(--red-seal);
    border-radius: 50%;
    border: 2px solid var(--lamplight-gold);
    box-shadow: 0 0 8px rgba(196,155,60,0.3);
    z-index: 3;
}

.entry-left .entry-marker {
    right: -6px;
}

.entry-right .entry-marker {
    left: -6px;
}

.entry-card {
    background-color: var(--foxed-parchment);
    padding: 20px 24px;
    border-radius: 2px;
    box-shadow:
        3px 3px 10px rgba(0,0,0,0.35),
        inset 0 0 30px rgba(60,40,20,0.2);
}

.entry-date {
    font-family: 'Special Elite', cursive;
    font-size: clamp(20px, 2.5vw, 32px);
    letter-spacing: 0.08em;
    color: var(--red-seal);
    filter: blur(0.3px);
}

.entry-text {
    font-family: 'Lora', serif;
    font-size: clamp(13px, 0.95vw, 15px);
    line-height: 1.7;
    color: var(--faded-ink);
    margin-top: 8px;
}

/* --- READING ROOM FOOTER --- */
.reading-room {
    position: relative;
    min-height: 60vh;
    padding: 100px 5vw;
    background: linear-gradient(to bottom, var(--walnut-desk), var(--walnut-mid));
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.lamp-vignette {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 40%, transparent 30%, rgba(0,0,0,0.5) 100%);
    pointer-events: none;
}

.reading-content {
    position: relative;
    max-width: 640px;
    z-index: 2;
    text-align: center;
}

.reading-text {
    font-family: 'Lora', serif;
    font-size: clamp(15px, 1.2vw, 19px);
    line-height: 1.9;
    color: var(--foxed-parchment);
    margin-bottom: 32px;
}

.margin-note {
    font-family: 'Noto Serif JP', serif;
    font-size: clamp(16px, 1.5vw, 22px);
    color: var(--lamplight-gold);
    transform: rotate(-1deg);
    margin-bottom: 8px;
    letter-spacing: 0.05em;
}

.margin-note-translation {
    font-family: 'Caveat', cursive;
    font-size: clamp(15px, 1.3vw, 20px);
    color: #5C3A1E;
    transform: rotate(0.5deg);
    margin-bottom: 40px;
    opacity: 0.9;
}

.footer-seal {
    margin: 0 auto;
    opacity: 0.7;
}

/* --- Responsive adjustments --- */
@media (max-width: 768px) {
    .board-surface {
        grid-template-columns: 1fr;
        gap: 32px;
    }

    .pinned-card {
        transform: none !important;
    }
    .pinned-card.visible {
        transform: none !important;
    }

    .timeline-entry {
        width: 80%;
        margin-left: auto;
        text-align: left;
        padding-left: 30px;
        padding-right: 0;
    }

    .entry-left {
        transform: translateX(-20px);
    }

    .entry-right {
        transform: translateX(-20px);
    }

    .entry-left.visible,
    .entry-right.visible {
        transform: translateX(0);
    }

    .timeline-thread {
        left: 10%;
    }

    .entry-left .entry-marker,
    .entry-right .entry-marker {
        left: -6px;
        right: auto;
    }

    .envelope-body {
        width: 90vw;
        padding: 36px 24px 28px;
    }

    .envelope-document {
        width: 88vw;
    }
}

/* --- Noise texture overlay (subtle) --- */
.pinned-card::before,
.entry-card::before {
    content: '';
    position: absolute;
    inset: 0;
    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='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    border-radius: 2px;
    pointer-events: none;
}
