/* ============================================================
   mujun.cafe — Dark Academia Kissaten
   Design: Scholar's Desk / Leather-Bound Folio
   Colors: #1a0f0a, #2d1b14, #f0e4d4, #e8dcc8, #c4943a, #6b1a2a, #8a7060, #0d0704, #1f1210
   Fonts: Space Grotesk (sans), Cormorant Garamond (serif)
   ============================================================ */

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 400;
    color: #e8dcc8;
    background: linear-gradient(180deg, #1a0f0a 0%, #0d0704 100%);
    background-attachment: fixed;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* === SVG Definitions (hidden) === */
.svg-defs {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

#paradox-seal {
    position: fixed;
    width: 0;
    height: 0;
    overflow: hidden;
    pointer-events: none;
}

/* === Progress Indicator === */
#progress-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#progress-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #c4943a;
    transition: transform 0.3s ease;
    cursor: pointer;
    position: relative;
    z-index: 1001;
}

#progress-dot:hover {
    transform: scale(1.5);
}

#progress-indicator:hover #progress-line {
    opacity: 1;
    transform: scaleY(1);
}

#progress-line {
    position: absolute;
    top: 0;
    right: 3px;
    width: 2px;
    height: 80vh;
    background: linear-gradient(180deg, rgba(196,148,58,0.3), rgba(196,148,58,0.1));
    opacity: 0;
    transform: scaleY(0);
    transform-origin: top;
    transition: opacity 0.4s ease, transform 0.4s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
    padding: 20px 0;
}

.progress-label {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 300;
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #8a7060;
    padding-right: 12px;
    white-space: nowrap;
}

/* === Lamplight Overlay === */
#lamplight-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
    background: radial-gradient(circle at 50% 40%, rgba(196,148,58,0.08) 0%, transparent 300px);
    opacity: 0;
    transition: opacity 2s ease;
}

#lamplight-overlay.visible {
    opacity: 1;
}

/* === ACT I: INVITATION === */
#act-invitation {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    background: #1a0f0a;
    padding: 60px 20px;
}

/* Ex Libris Bookplate */
#ex-libris {
    position: absolute;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    animation: fadeInSlow 3s ease 1.5s forwards;
}

.bookplate-frame {
    position: relative;
    width: 160px;
    height: 100px;
    border: 1px solid #c4943a;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bookplate-corner {
    position: absolute;
    width: 12px;
    height: 12px;
    border-color: #c4943a;
    border-style: solid;
}

.bookplate-corner-tl {
    top: -3px;
    left: -3px;
    border-width: 2px 0 0 2px;
}

.bookplate-corner-tr {
    top: -3px;
    right: -3px;
    border-width: 2px 2px 0 0;
}

.bookplate-corner-bl {
    bottom: -3px;
    left: -3px;
    border-width: 0 0 2px 2px;
}

.bookplate-corner-br {
    bottom: -3px;
    right: -3px;
    border-width: 0 2px 2px 0;
}

.bookplate-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.bookplate-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.15em;
    color: #c4943a;
}

.bookplate-kanji {
    font-size: 0.8rem;
    color: #8a7060;
    letter-spacing: 0.3em;
}

/* Title Block */
#title-block {
    text-align: center;
    opacity: 0;
    animation: fadeInSlow 2s ease 1s forwards;
}

.site-title {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(2.5rem, 5vw, 4rem);
    color: #e8dcc8;
    letter-spacing: 0.02em;
    margin-bottom: 16px;
}

.site-subtitle {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 300;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    color: #8a7060;
    text-transform: none;
}

/* Scroll Chevron */
#scroll-chevron {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    opacity: 0;
    animation: fadeInSlow 2s ease 2.5s forwards, pulseChevron 2.5s ease-in-out 3s infinite;
}

.chevron-line {
    width: 20px;
    height: 2px;
    background: #c4943a;
    opacity: 0.6;
}

.chevron-line:first-child {
    transform: rotate(25deg) translateX(5px);
}

.chevron-line:last-child {
    transform: rotate(-25deg) translateX(5px);
    margin-top: -4px;
}

/* === ACT II: IMMERSION === */
#act-immersion {
    position: relative;
    padding: clamp(80px, 12vh, 160px) 20px;
}

/* Desk Surface */
.desk-surface {
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

/* Leather Texture on Desk Surface (applied via pseudo-element) */
.desk-surface::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        repeating-linear-gradient(175deg, transparent, transparent 120px, rgba(107, 26, 42, 0.04) 120px, rgba(107, 26, 42, 0.04) 121px),
        radial-gradient(ellipse at 20% 30%, rgba(45, 27, 20, 0.15) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 60%, rgba(45, 27, 20, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 40% 80%, rgba(45, 27, 20, 0.08) 0%, transparent 40%);
    pointer-events: none;
    z-index: 0;
    filter: url(#leather-grain);
    opacity: 0.3;
}

/* Content Blocks — Parchment Style */
.parchment-block {
    background: #f0e4d4;
    background-image: radial-gradient(ellipse at center, #f0e4d4 0%, #e8dcc8 100%);
    color: #1a0f0a;
    padding: clamp(32px, 4vw, 56px);
    position: relative;
    z-index: 1;
    box-shadow: 8px 8px 24px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.05);
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.6s cubic-bezier(0.23, 1, 0.32, 1), transform 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

.parchment-block.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Main block: slightly left, 55% width on desktop */
.block-main {
    width: 55%;
    margin-left: 8%;
}

/* Offset block: slightly right */
.block-offset {
    width: 55%;
    margin-left: 30%;
}

/* Block Headlines */
.block-headline {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: clamp(2.2rem, 5vw, 4rem);
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: #1a0f0a;
    margin-bottom: 20px;
}

/* Brass Rule */
.brass-rule {
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, #c4943a 20%, #c4943a 80%, transparent 100%);
    margin-bottom: 24px;
    transform: scaleX(0);
    transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1) 0.2s;
    transform-origin: center;
}

.parchment-block.visible .brass-rule {
    transform: scaleX(1);
}

/* Block Body Text */
.block-body {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.3vw, 1.1rem);
    line-height: 1.7;
    color: #1a0f0a;
    margin-bottom: 16px;
}

.block-body:last-of-type {
    margin-bottom: 0;
}

.block-body em {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-weight: 400;
    font-size: 1.05em;
}

/* Footnote Markers */
.footnote-marker {
    display: inline-block;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 300;
    font-size: 0.7rem;
    color: #6b1a2a;
    vertical-align: super;
    cursor: default;
    margin-left: 4px;
    transition: text-shadow 0.3s ease;
}

.footnote-marker:hover {
    text-shadow: 0 0 12px rgba(196, 148, 58, 0.3);
}

/* === Margin Notes === */
.margin-note {
    position: absolute;
    right: -5%;
    width: 22%;
    z-index: 2;
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

.margin-note.visible {
    opacity: 1;
    transform: translateX(0);
}

.margin-text {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(0.85rem, 1.2vw, 1.05rem);
    line-height: 1.55;
    color: #e8dcc8;
    margin-bottom: 8px;
}

.margin-attribution {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 300;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    color: #8a7060;
    text-transform: uppercase;
}

.margin-attribution em {
    text-transform: none;
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
}

/* === Pull Quote === */
.pull-quote-block {
    width: 60%;
    margin: clamp(40px, 6vh, 80px) auto;
    position: relative;
    z-index: 1;
    opacity: 0;
    transform: scale(0.95) rotate(-0.5deg);
    transition: opacity 0.5s cubic-bezier(0.23, 1, 0.32, 1), transform 0.5s cubic-bezier(0.23, 1, 0.32, 1);
}

.pull-quote-block.visible {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

.bracket-frame {
    position: relative;
    padding: 32px 40px;
}

.bracket-left,
.bracket-right {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #c4943a;
}

.bracket-left {
    left: 0;
}

.bracket-left::before,
.bracket-left::after {
    content: '';
    position: absolute;
    left: 0;
    width: 10px;
    height: 2px;
    background: #c4943a;
}

.bracket-left::before { top: 0; }
.bracket-left::after { bottom: 0; }

.bracket-right {
    right: 0;
}

.bracket-right::before,
.bracket-right::after {
    content: '';
    position: absolute;
    right: 0;
    width: 10px;
    height: 2px;
    background: #c4943a;
}

.bracket-right::before { top: 0; }
.bracket-right::after { bottom: 0; }

.pull-quote-text {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(1.4rem, 2.5vw, 2rem);
    line-height: 1.55;
    color: #e8dcc8;
    text-align: center;
    margin-bottom: 16px;
}

.pull-quote-cite {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 300;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #8a7060;
    display: block;
    text-align: center;
}

/* === Seal Watermark === */
.seal-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    opacity: 0.04;
    pointer-events: none;
    z-index: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='80' cy='100' r='60' fill='none' stroke='%236b1a2a' stroke-width='1.5'/%3E%3Ccircle cx='120' cy='100' r='60' fill='none' stroke='%236b1a2a' stroke-width='1.5'/%3E%3Ctext x='65' y='108' font-family='serif' font-size='28' fill='%236b1a2a'%3E%E7%9F%9B%3C/text%3E%3Ctext x='118' y='108' font-family='serif' font-size='28' fill='%236b1a2a'%3E%E7%9B%BE%3C/text%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}

.seal-watermark-reveal {
    width: 300px;
    height: 300px;
    transition: opacity 3s ease;
}

#revelation-block.visible .seal-watermark-reveal {
    opacity: 0.12;
}

/* === ACT III: REVELATION === */
#act-revelation {
    position: relative;
    padding: clamp(40px, 8vh, 100px) 20px 0;
}

.desk-surface-crowded {
    gap: 16px;
}

/* Fragments — Overlapping blocks */
.fragment {
    width: 45%;
    padding: clamp(20px, 3vw, 36px);
    position: relative;
    z-index: 1;
}

.fragment-1 {
    margin-left: 5%;
    transform: translateY(40px) rotate(-1deg);
}

.fragment-1.visible {
    transform: translateY(0) rotate(-1deg);
}

.fragment-2 {
    margin-left: 40%;
    margin-top: -40px;
    transform: translateY(40px) rotate(0.5deg);
}

.fragment-2.visible {
    transform: translateY(0) rotate(0.5deg);
}

.fragment-3 {
    margin-left: 15%;
    margin-top: -20px;
    transform: translateY(40px) rotate(-0.3deg);
}

.fragment-3.visible {
    transform: translateY(0) rotate(-0.3deg);
}

.fragment-text {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(1.1rem, 1.8vw, 1.4rem);
    line-height: 1.55;
    color: #1a0f0a;
    font-style: normal;
}

/* Revelation Block */
#revelation-block {
    width: 80%;
    margin: clamp(60px, 10vh, 120px) auto 0;
    overflow: hidden;
}

.revelation-headline {
    text-align: center;
}

.bracket-frame-final .bracket-left,
.bracket-frame-final .bracket-right {
    transform: scaleY(0);
    transition: transform 1.2s cubic-bezier(0.23, 1, 0.32, 1);
    transform-origin: center;
}

#revelation-block.visible .bracket-frame-final .bracket-left,
#revelation-block.visible .bracket-frame-final .bracket-right {
    transform: scaleY(1);
}

#revelation-block .block-body {
    text-align: center;
}

/* Final Void */
#final-void {
    min-height: 40vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, transparent 0%, #0d0704 100%);
    padding: 80px 20px;
}

#final-glyph {
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    color: #6b1a2a;
    opacity: 0;
    transition: opacity 1.5s ease;
    letter-spacing: 0.2em;
}

#final-glyph.visible {
    opacity: 0.7;
}

/* === Animations === */
@keyframes fadeInSlow {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes pulseChevron {
    0%, 100% {
        opacity: 0.4;
        transform: translateX(-50%) translateY(0);
    }
    50% {
        opacity: 0.8;
        transform: translateX(-50%) translateY(8px);
    }
}

@keyframes candleFlicker {
    0%, 100% {
        opacity: 0.15;
    }
    50% {
        opacity: 0.3;
    }
}

/* Interactive elements — candle-atmospheric glow */
a, .footnote-marker {
    transition: text-shadow 0.3s ease, box-shadow 0.3s ease;
}

/* === Page Turn Transition Styling === */
.act {
    position: relative;
}

.act.page-turning {
    transform: perspective(1200px) rotateY(2deg);
    transition: transform 0.8s cubic-bezier(0.23, 1, 0.32, 1);
}

.act.page-turned {
    transform: perspective(1200px) rotateY(0deg);
    transition: transform 0.8s cubic-bezier(0.23, 1, 0.32, 1);
}

/* === Responsive Design === */
@media (max-width: 768px) {
    .block-main,
    .block-offset {
        width: 100%;
        margin-left: 0;
    }

    .margin-note {
        position: relative;
        right: auto;
        width: 100%;
        margin: 16px 0;
        padding: 16px 20px;
        border-left: 2px solid #c4943a;
        opacity: 1;
        transform: none;
    }

    .margin-note.visible {
        transform: none;
    }

    .pull-quote-block {
        width: 90%;
    }

    .fragment {
        width: 90%;
        margin-left: 5% !important;
    }

    .fragment-1, .fragment-2, .fragment-3 {
        margin-top: 16px;
    }

    #revelation-block {
        width: 95%;
    }

    #ex-libris {
        position: relative;
        top: auto;
        left: auto;
        transform: none;
        margin-bottom: 40px;
    }

    .bookplate-frame {
        margin: 0 auto;
    }

    #progress-indicator {
        display: none;
    }
}

@media (max-width: 480px) {
    .block-headline {
        font-size: clamp(1.6rem, 6vw, 2.2rem);
    }

    .bracket-frame {
        padding: 20px 24px;
    }

    .parchment-block {
        padding: clamp(20px, 5vw, 32px);
    }
}
