/* ============================================
   PPEBBL.com — Styles
   A forgotten private library in Kyoto at dusk
   ============================================ */

/* --- Color Reference ---
   Background:     #f0e8db (Aged Parchment)
   Primary Text:   #2c2418 (Deep Umber)
   Secondary Text: #4a3f35 (Warm Sepia)
   Tertiary:       #8a7e6e (Faded Stone)
   Accent Green:   #6b8f71 (Oxidized Copper)
   Accent Warm:    #c4653a (Persimmon Ink)
   Decorative:     #a89278 (Toasted Linen)
   Deep BG:        #1e1a2e (Evening Indigo)
   Night Text:     #e8dfd4 (Warm Cream)
   Golden:         #c4a35a (Gold)
   Golden Bright:  #d4b86a (Bright Gold)
   --- */

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

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

body {
    background-color: #f0e8db;
    color: #2c2418;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 400;
    line-height: 1.9;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Typography --- */
.heading {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: 38px;
    letter-spacing: 0.08em;
    line-height: 1.4;
    color: #2c2418;
    max-width: 560px;
    text-transform: none;
}

.heading--night {
    color: #e8dfd4;
}

.body-text {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 18px;
    font-weight: 400;
    line-height: 1.9;
    color: #4a3f35;
    max-width: 560px;
}

.body-text--night {
    color: #e8dfd4;
}

.body-text em {
    font-style: italic;
}

.title {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: 42px;
    letter-spacing: 0.2em;
    color: #2c2418;
    opacity: 0;
    transition: opacity 1.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.title.visible {
    opacity: 1;
}

.subtitle {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-style: italic;
    font-size: 16px;
    color: #8a7e6e;
    margin-top: 12px;
    opacity: 0;
    transition: opacity 1.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.subtitle.visible {
    opacity: 1;
}

/* --- Caption / Accent Typography --- */
.folio {
    display: block;
    font-family: 'Commissioner', sans-serif;
    font-weight: 200;
    font-size: 11px;
    letter-spacing: 0.15em;
    color: #8a7e6e;
    text-align: center;
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
}

.folio--night {
    color: #8a7e6e;
}

.marginal-note {
    position: absolute;
    right: 40px;
    top: 50%;
    transform: rotate(90deg) translateX(-50%);
    transform-origin: right center;
    font-family: 'Commissioner', sans-serif;
    font-weight: 200;
    font-size: 10px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: #8a7e6e;
    opacity: 0.6;
    white-space: nowrap;
}

.marginal-note--night {
    color: #8a7e6e;
}

/* --- Layout: Sections --- */
.section {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 80px 40px;
    margin-bottom: 0;
}

.section__content {
    position: relative;
    max-width: 1200px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

/* Single Statement: centered text */
.section--single-statement .section__content {
    align-items: center;
    text-align: center;
}

/* Annotated Fragment: text left, art right */
.section--annotated .section__content {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 80px;
    text-align: left;
}

.annotated__text {
    flex: 0 1 560px;
    max-width: 560px;
}

.annotated__art {
    flex: 0 1 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* The Spread: two text blocks with rule */
.section--spread .section__content {
    align-items: center;
    text-align: center;
    max-width: 560px;
}

.spread__upper,
.spread__lower {
    text-align: left;
}

.spread__rule {
    width: 120px;
    height: 1px;
    background-color: #a89278;
    opacity: 0.3;
    margin: 48px auto;
    transform: scaleX(0);
    transition: transform 1.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform-origin: center;
}

.spread__rule.visible {
    transform: scaleX(1);
}

/* --- Night Page --- */
.section--night {
    background-color: #1e1a2e;
    position: relative;
    z-index: 1;
}

.night-transition {
    position: absolute;
    top: -200px;
    left: 0;
    right: 0;
    height: 200px;
    background: linear-gradient(to bottom, #f0e8db, #1e1a2e);
    pointer-events: none;
    z-index: -1;
}

.section--night + .section {
    position: relative;
}

.section--night + .section::before {
    content: '';
    position: absolute;
    top: -200px;
    left: 0;
    right: 0;
    height: 200px;
    background: linear-gradient(to bottom, #1e1a2e, #f0e8db);
    pointer-events: none;
}

/* --- Colophon --- */
.section--colophon .section__content {
    text-align: center;
}

.colophon__content {
    text-align: center;
}

.colophon__line {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-style: italic;
    font-size: 15px;
    color: #8a7e6e;
    line-height: 2;
}

.colophon__rule {
    width: 60px;
    height: 1px;
    background-color: #a89278;
    opacity: 0.3;
    margin: 32px auto;
}

.colophon__edition {
    font-size: 13px;
    letter-spacing: 0.05em;
}

/* --- Closing --- */
.section--closing {
    min-height: 50vh;
    align-items: flex-end;
    padding-bottom: 30vh;
}

.fin {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-style: italic;
    font-size: 14px;
    color: #8a7e6e;
    opacity: 0;
    transition: opacity 2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.fin.visible {
    opacity: 1;
}

/* --- Moon Phase Indicator --- */
#moon-indicator {
    position: fixed;
    bottom: 32px;
    right: 32px;
    z-index: 1000;
    opacity: 0;
    transition: opacity 1s ease;
    color: #c4653a;
}

#moon-indicator.visible {
    opacity: 1;
}

#moon-indicator.pulse {
    animation: moonPulse 2s ease-in-out;
}

@keyframes moonPulse {
    0% { opacity: 1; }
    50% { opacity: 0.4; }
    100% { opacity: 1; }
}

/* --- Enso --- */
.enso {
    position: relative;
    z-index: 1;
}

#opening .enso {
    margin-bottom: 24px;
}

.enso--bg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 0;
    pointer-events: none;
}

/* --- Golden Seams --- */
.golden-seam {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    min-height: 120px;
    margin: 0;
}

.golden-seam__svg {
    width: 600px;
    max-width: 80vw;
    height: 80px;
    overflow: visible;
}

.golden-seam__path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    color: #c4a35a;
}

.golden-seam__path.visible {
    stroke-dashoffset: 0;
}

/* Night page golden seams: brighter gold #d4b86a at 80% opacity */
.section--night .golden-seam__path {
    stroke: #d4b86a;
    opacity: 0.8;
}

/* --- Ink Canvas --- */
.ink-canvas {
    display: block;
    opacity: 0.7;
}

/* --- Dot Constellations --- */
.dot-constellation {
    position: relative;
    width: 200px;
    height: 200px;
}

.dot-constellation--night {
    position: absolute;
    top: 20%;
    left: 10%;
    width: 160px;
    height: 160px;
    z-index: 0;
}

.dot {
    position: absolute;
    border-radius: 50%;
    background-color: #6b8f71;
    animation: dotPulse 8s ease-in-out infinite;
}

.dot--night {
    background-color: #e8dfd4;
}

@keyframes dotPulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.7; }
}

/* --- Reveal Animations --- */
[data-reveal] .heading,
[data-reveal] .body-text,
[data-reveal] .annotated__text,
[data-reveal] .colophon__content {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 1.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

[data-reveal].revealed .heading,
[data-reveal].revealed .body-text,
[data-reveal].revealed .annotated__text,
[data-reveal].revealed .colophon__content {
    opacity: 1;
    transform: translateY(0);
}

/* Counter-animate: art sinks as text rises */
[data-reveal] .annotated__art,
[data-reveal] .dot-constellation {
    opacity: 0;
    transform: translateY(-15px);
    transition: opacity 1.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 1.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

[data-reveal].revealed .annotated__art,
[data-reveal].revealed .dot-constellation {
    opacity: 1;
    transform: translateY(0);
}

/* Folio fade in */
[data-reveal] .folio {
    opacity: 0;
    transition: opacity 2s ease 0.5s;
}

[data-reveal].revealed .folio {
    opacity: 1;
}

/* Marginal note fade */
[data-reveal] .marginal-note {
    opacity: 0;
    transition: opacity 2s ease 0.8s;
}

[data-reveal].revealed .marginal-note {
    opacity: 0.6;
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .section--annotated .section__content {
        flex-direction: column;
        text-align: center;
        gap: 40px;
    }

    .annotated__text {
        max-width: 100%;
    }

    .heading {
        font-size: 28px;
    }

    .title {
        font-size: 32px;
    }

    .marginal-note {
        display: none;
    }
}

@media (max-width: 600px) {
    .section {
        padding: 60px 24px;
    }

    .heading {
        font-size: 24px;
    }

    .title {
        font-size: 28px;
    }

    .body-text {
        font-size: 16px;
    }
}

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

    [data-reveal] .heading,
    [data-reveal] .body-text,
    [data-reveal] .annotated__text,
    [data-reveal] .colophon__content,
    [data-reveal] .annotated__art,
    [data-reveal] .dot-constellation {
        opacity: 1;
        transform: none;
    }

    .spread__rule {
        transform: scaleX(1);
    }

    .golden-seam__path {
        stroke-dashoffset: 0;
    }

    .title, .subtitle {
        opacity: 1;
    }

    .fin {
        opacity: 1;
    }
}
