/* ============================================
   heisei.boo — A Haunted Book of Hours
   Serif-revival single-column book layout
   ============================================ */

:root {
    --bunko-cream: #f5f0e6;
    --inkstone: #2a2520;
    --aged-dark: #3d3630;
    --foxing: #8a7968;
    --copper: #c2784e;
    --interleaf: #d4c8b4;
    --phantom: #e8e0d2;
    --persimmon: #9b4a2c;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Source Serif 4', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    line-height: 1.78;
    color: var(--aged-dark);
    background: var(--bunko-cream);
    overflow-x: hidden;
}

/* --- Reading Progress Bar --- */
#progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: transparent;
    z-index: 1000;
    cursor: pointer;
}

#progress-fill {
    height: 100%;
    width: 0%;
    background: var(--copper);
    transition: width 0.1s linear;
}

#progress-tooltip {
    position: absolute;
    top: 6px;
    left: 0;
    background: var(--inkstone);
    color: var(--bunko-cream);
    font-family: 'Shippori Mincho', serif;
    font-size: 11px;
    padding: 3px 8px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    white-space: nowrap;
}

#progress-bar:hover #progress-tooltip {
    opacity: 1;
}

/* --- Bookmark Ribbon --- */
#bookmark-ribbon {
    position: fixed;
    left: calc(50% - 320px);
    top: 0;
    width: 4px;
    height: 0;
    background: var(--copper);
    z-index: 999;
    transition: height 0.1s linear;
}

/* --- Pages --- */
.page {
    max-width: 640px;
    margin: 0 auto;
    padding: 80px 24px;
    position: relative;
}

/* --- Title Page --- */
.title-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.ghost-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Shippori Mincho', serif;
    font-size: 30vw;
    color: var(--phantom);
    opacity: 0.4;
    pointer-events: none;
    z-index: 0;
    transition: opacity 0.1s linear;
    line-height: 1;
}

.title-content {
    position: relative;
    z-index: 1;
}

.era-title {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
    font-size: clamp(3rem, 8vw, 6rem);
    color: var(--inkstone);
    letter-spacing: 0.15em;
    margin-bottom: 8px;
}

.era-kanji {
    font-family: 'Shippori Mincho', serif;
    font-weight: 400;
    font-size: clamp(2rem, 5vw, 3.5rem);
    color: var(--inkstone);
    margin-bottom: 16px;
}

.era-dates {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-style: italic;
    font-size: clamp(1rem, 2vw, 1.4rem);
    color: var(--foxing);
    margin-bottom: 32px;
}

.title-rule {
    border: none;
    height: 1px;
    background: var(--foxing);
    width: 60%;
    margin: 0 auto 32px;
}

.epigraph {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-style: italic;
    font-size: 1rem;
    color: var(--foxing);
    margin-bottom: 40px;
}

.boo-mark {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-style: italic;
    font-size: 2rem;
    color: var(--phantom);
    opacity: 0.5;
}

/* --- Interleaf --- */
.interleaf {
    height: 50vh;
    background: var(--bunko-cream);
}

/* --- Chapters --- */
.chapter {
    position: relative;
    overflow: hidden;
}

/* Foxing spots */
.chapter::before,
.chapter::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
}

.chapter::before {
    left: var(--fox-1-x, 20%);
    top: var(--fox-1-y, 30%);
    width: 6px;
    height: 6px;
    background: radial-gradient(circle, var(--interleaf) 0%, transparent 70%);
    opacity: 0.25;
}

.chapter::after {
    left: var(--fox-2-x, 70%);
    top: var(--fox-2-y, 60%);
    width: 5px;
    height: 5px;
    background: radial-gradient(circle, var(--interleaf) 0%, transparent 70%);
    opacity: 0.2;
}

/* Page curl effect */
.chapter .chapter-content {
    position: relative;
    z-index: 1;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
    transition: clip-path 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.chapter.curling .chapter-content {
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 40px), calc(100% - 40px) 100%, 0 100%);
}

.chapter-header {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: var(--inkstone);
    letter-spacing: 0.08em;
    margin-bottom: 4px;
}

.chapter-subtitle {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: 1.1rem;
    color: var(--foxing);
    margin-bottom: 4px;
}

.chapter-date {
    font-family: 'Shippori Mincho', serif;
    font-weight: 400;
    font-size: 0.85rem;
    color: var(--foxing);
    margin-bottom: 32px;
}

.chapter-content p {
    margin-bottom: 1.3em;
    text-indent: 1.5em;
}

.body-first {
    text-indent: 0 !important;
}

/* Section Divider */
.section-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 40px 0;
    width: 40%;
    margin-left: auto;
    margin-right: auto;
}

.divider-line {
    flex: 1;
    height: 1px;
    background: var(--interleaf);
}

.divider-center {
    width: 1px;
    height: 8px;
    background: var(--interleaf);
}

/* --- Colophon --- */
.colophon-page {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.colophon {
    text-align: center;
}

.colophon-line {
    font-family: 'Shippori Mincho', serif;
    font-weight: 400;
    font-size: 0.85rem;
    color: var(--foxing);
    margin-bottom: 6px;
}

.colophon-rule {
    border: none;
    height: 1px;
    background: var(--interleaf);
    width: 120px;
    margin: 20px auto;
}

.colophon-mark {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--copper);
    letter-spacing: 0.1em;
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    .chapter .chapter-content {
        clip-path: none;
    }

    .ghost-watermark {
        opacity: 0.4;
    }
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .page {
        padding: 60px 20px;
    }

    #bookmark-ribbon {
        left: 16px;
    }

    .section-divider {
        width: 60%;
    }
}
