/* =============================================================
   renai.xyz — The Wax Salon
   Belle Epoque chiaroscuro · blobitecture · art-deco display
   Palette (chiaroscuro, high-contrast):
     #08070C  Ink Midnight   — background (95%)
     #F4C77A  Beeswax Glow   — flames, drop caps, hairlines
     #E9D9B8  Parchment      — body text
     #B89968  Tarnished Brass — marginalia, ornaments
     #5C2A2A  Sealing Wax    — single accent (used twice)
     #1A1620  Velvet Curtain — subtle elevated surface
   ============================================================= */

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

html {
    scroll-behavior: smooth;
}

body {
    background: #08070C;
    color: #E9D9B8;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-style: italic;
    font-weight: 400;
    font-size: 1.0625rem;
    line-height: 1.85;
    overflow-x: hidden;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "liga", "dlig", "onum", "smcp";
    filter: contrast(1.04) brightness(0.96);
}

/* -------------------------------------------------------------
   The drifting candle-vignette — site-wide atmosphere
   ------------------------------------------------------------- */
.vignette {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 10;
    background:
        radial-gradient(ellipse at 50% 40%,
            transparent 0%,
            transparent 35%,
            rgba(8, 7, 12, 0.45) 80%,
            rgba(8, 7, 12, 0.75) 100%);
    animation: vignetteDrift 180s ease-in-out infinite;
    mix-blend-mode: multiply;
}

@keyframes vignetteDrift {
    0%   { background-position: 50% 40%; transform: scale(1.0); }
    25%  { background-position: 48% 42%; transform: scale(1.02); }
    50%  { background-position: 52% 38%; transform: scale(1.01); }
    75%  { background-position: 49% 41%; transform: scale(1.015); }
    100% { background-position: 50% 40%; transform: scale(1.0); }
}

/* Site-wide imperceptible flicker — bound to candle phase */
body {
    animation: salonFlicker 0.9s infinite;
}

@keyframes salonFlicker {
    0%, 100% { opacity: 1; }
    14%      { opacity: 0.985; }
    32%      { opacity: 1; }
    58%      { opacity: 0.992; }
    82%      { opacity: 1; }
}

/* -------------------------------------------------------------
   Chapter — the universal scaffold
   ------------------------------------------------------------- */
.chapter {
    position: relative;
    min-height: 100vh;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: auto 1fr auto;
    align-content: center;
    padding: 8vh 5vw;
    overflow: hidden;
}

.chapter-grid {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: auto auto auto;
    column-gap: 1.5rem;
    row-gap: 2.5rem;
    align-items: center;
    position: relative;
    z-index: 2;
}

/* The corridor band of pure ink with a single thread of beeswax light */
.corridor {
    position: relative;
    width: 100%;
    height: 18vh;
    background: #08070C;
    display: flex;
    align-items: center;
    justify-content: center;
    grid-column: 1 / -1;
    pointer-events: none;
}

.corridor .thread {
    display: block;
    width: 1px;
    height: 70%;
    background: linear-gradient(to bottom,
        transparent 0%,
        rgba(244, 199, 122, 0.0) 8%,
        rgba(244, 199, 122, 0.55) 50%,
        rgba(244, 199, 122, 0.0) 92%,
        transparent 100%);
    animation: threadBreathe 4.5s ease-in-out infinite;
}

@keyframes threadBreathe {
    0%, 100% { opacity: 0.75; transform: scaleY(1); }
    50%      { opacity: 1; transform: scaleY(1.04); }
}

/* Wax-pool floor — each section "melts" into the next */
.wax-floor {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 12vh;
    z-index: 1;
    pointer-events: none;
}

/* -------------------------------------------------------------
   Chapter numerals — art-deco rules + Roman numeral
   ------------------------------------------------------------- */
.chapter-numeral {
    grid-column: 2 / 4;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    color: #B89968;
    margin-bottom: 1.5rem;
}

.chapter-numeral .rule {
    display: block;
    width: 1px;
    height: 24px;
    background: #B89968;
    opacity: 0.7;
}

.chapter-numeral .num {
    font-family: 'Limelight', 'Cormorant Unicase', serif;
    font-style: normal;
    font-size: 1.4rem;
    letter-spacing: 0.18em;
    color: #B89968;
}

/* -------------------------------------------------------------
   Chapter header (title + marginalia)
   ------------------------------------------------------------- */
.chapter-head {
    grid-column: 2 / 8;
}

.marginalia {
    display: block;
    font-family: 'Italiana', 'Cormorant Unicase', serif;
    font-style: normal;
    font-variant: small-caps;
    font-size: 0.78rem;
    letter-spacing: 0.32em;
    color: #B89968;
    text-transform: uppercase;
    margin-bottom: 2.2rem;
}

.chapter-title {
    font-family: 'Cormorant Unicase', 'Cormorant Garamond', serif;
    font-style: normal;
    font-weight: 500;
    font-size: clamp(3rem, 9vw, 8rem);
    letter-spacing: 0.16em;
    line-height: 0.95;
    text-transform: uppercase;
    color: #E9D9B8;
    display: flex;
    align-items: baseline;
    gap: 0.04em;
}

.dropcap {
    font-family: 'Limelight', 'Cormorant Unicase', serif;
    font-size: 1.35em;
    color: #F4C77A;
    line-height: 1;
    text-shadow: 0 0 18px rgba(244, 199, 122, 0.35);
}

.title-rest {
    font-family: 'Cormorant Unicase', serif;
    color: #E9D9B8;
}

/* -------------------------------------------------------------
   Chapter body — the love-letter face
   ------------------------------------------------------------- */
.chapter-body {
    grid-column: 4 / 9;
    max-width: 38rem;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-style: italic;
    font-weight: 400;
    font-size: 1.0625rem;
    line-height: 1.85;
    color: #E9D9B8;
    letter-spacing: 0.005em;
}

.chapter-body p {
    margin: 0;
}

/* -------------------------------------------------------------
   Chapter signature blob — custom-illustration
   ------------------------------------------------------------- */
.chapter-blob {
    grid-column: 9 / 12;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 240px;
}

.chapter-blob svg {
    width: 100%;
    height: auto;
    max-height: 60vh;
    filter: drop-shadow(0 0 22px rgba(244, 199, 122, 0.12));
}

/* Chapter III — right-anchor flip */
.chapter-iii .chapter-numeral { grid-column: 10 / 12; }
.chapter-iii .chapter-head    { grid-column: 6 / 12; text-align: right; }
.chapter-iii .chapter-head .chapter-title { justify-content: flex-end; }
.chapter-iii .chapter-body    { grid-column: 5 / 10; margin-left: auto; text-align: right; }
.chapter-iii .chapter-blob    { grid-column: 2 / 5; }

/* Chapter V — overlap composition (blob + paragraph share columns) */
.chapter-v .chapter-numeral { grid-column: 2 / 4; }
.chapter-v .chapter-head    { grid-column: 2 / 9; }
.chapter-v .chapter-body    { grid-column: 4 / 9; position: relative; z-index: 3; }
.chapter-v .chapter-blob    { grid-column: 7 / 11; opacity: 0.85; transform: translateX(-1.5rem); }

/* -------------------------------------------------------------
   Progressive disclosure — invisible until .lit
   ------------------------------------------------------------- */
.chapter:not(.vestibule):not(.chapter-vii) .chapter-numeral,
.chapter:not(.vestibule):not(.chapter-vii) .chapter-head,
.chapter:not(.vestibule):not(.chapter-vii) .chapter-body,
.chapter:not(.vestibule):not(.chapter-vii) .chapter-blob {
    opacity: 0;
    transition:
        opacity 1.2s ease-out,
        clip-path 0.9s cubic-bezier(0.2, 0.7, 0.2, 1),
        transform 1.2s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.chapter:not(.vestibule):not(.chapter-vii) .chapter-numeral {
    transition-delay: 0ms;
    transform: translateY(8px);
}

.chapter:not(.vestibule):not(.chapter-vii) .chapter-head {
    transition-delay: 200ms;
    clip-path: inset(50% 0 50% 0);
}

.chapter:not(.vestibule):not(.chapter-vii) .chapter-body {
    transition-delay: 550ms;
    clip-path: inset(50% 0 50% 0);
}

.chapter:not(.vestibule):not(.chapter-vii) .chapter-blob {
    transition-delay: 800ms;
    transform: translateX(2.5rem);
}

.chapter.lit .chapter-numeral {
    opacity: 1;
    transform: translateY(0);
}

.chapter.lit .chapter-head {
    opacity: 1;
    clip-path: inset(0 0 0 0);
}

.chapter.lit .chapter-body {
    opacity: 1;
    clip-path: inset(0 0 0 0);
}

.chapter.lit .chapter-blob {
    opacity: 1;
    transform: translateX(0);
}

/* -------------------------------------------------------------
   The Vestibule — Chapter 0
   ------------------------------------------------------------- */
.vestibule {
    grid-template-rows: 1fr auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    background:
        radial-gradient(ellipse at 50% 36%, rgba(244, 199, 122, 0.06) 0%, rgba(244, 199, 122, 0) 50%),
        #08070C;
}

.vestibule-stage {
    width: 100%;
    max-width: 720px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2vh;
}

.candle {
    width: clamp(120px, 18vw, 220px);
    height: auto;
    filter: drop-shadow(0 0 60px rgba(244, 199, 122, 0.35));
    margin-bottom: 2vh;
}

.candle .halo {
    animation: haloPulse 0.9s ease-in-out infinite;
    transform-origin: center;
}

@keyframes haloPulse {
    0%, 100% { opacity: 0.55; transform: scale(1.0); }
    50%      { opacity: 0.78; transform: scale(1.06); }
}

.vestibule-title {
    font-family: 'Limelight', 'Cormorant Unicase', serif;
    font-style: normal;
    font-weight: 400;
    font-size: clamp(4rem, 14vw, 12rem);
    letter-spacing: 0.18em;
    color: #E9D9B8;
    line-height: 1;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    background-image:
        radial-gradient(ellipse at 50% -20%,
            #F4C77A 0%,
            #F4C77A 15%,
            #E9D9B8 40%,
            #B89968 100%);
    text-shadow: 0 0 40px rgba(244, 199, 122, 0.18);
}

.vestibule-sub {
    font-family: 'Italiana', serif;
    font-style: normal;
    font-variant: small-caps;
    font-size: 0.82rem;
    letter-spacing: 0.42em;
    color: #B89968;
    text-transform: uppercase;
    opacity: 0.7;
    margin-top: 1.2rem;
}

/* -------------------------------------------------------------
   Chapter VII — The Closing Door (scroll-driven)
   ------------------------------------------------------------- */
.chapter-vii {
    height: 600vh;
    position: relative;
    background: #08070C;
    padding: 0;
    display: block;
    grid-template-rows: none;
}

.door-scroll-track {
    position: sticky;
    top: 0;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #08070C;
}

.door-stage {
    position: relative;
    width: min(64vw, 540px);
    height: 86vh;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.door-frame {
    position: relative;
    width: 100%;
    height: 100%;
    display: block;
}

.jamb {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: #1A1620;
    box-shadow: 0 0 16px rgba(184, 153, 104, 0.2);
}

.jamb-left  { left: 0; }
.jamb-right { right: 0; }

.lintel {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: #1A1620;
}

.slit {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    background: linear-gradient(to right,
        transparent 0%,
        rgba(244, 199, 122, 0.0) 30%,
        rgba(244, 199, 122, 0.45) 48%,
        rgba(244, 199, 122, 0.95) 50%,
        rgba(244, 199, 122, 0.45) 52%,
        rgba(244, 199, 122, 0.0) 70%,
        transparent 100%);
    transform-origin: center center;
    transition: transform 0.05s linear;
    will-change: transform;
}

.closing-line {
    position: absolute;
    bottom: 4vh;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-style: italic;
    font-weight: 300;
    font-size: 0.95rem;
    letter-spacing: 0.05em;
    color: #B89968;
    opacity: 0;
    transition: opacity 1.8s ease;
    text-align: center;
    white-space: nowrap;
}

.closing-line.visible {
    opacity: 0.85;
}

.closing-line.fading {
    opacity: 0;
}

/* -------------------------------------------------------------
   Decorative hairlines between chapter title + body
   ------------------------------------------------------------- */
.chapter-head::after {
    content: "";
    display: block;
    width: 38%;
    max-width: 220px;
    height: 1px;
    background: #B89968;
    margin: 1.8rem 0 0;
    opacity: 0.55;
}

.chapter-iii .chapter-head::after {
    margin-left: auto;
    margin-right: 0;
}

/* -------------------------------------------------------------
   Selection — a quiet beeswax stripe
   ------------------------------------------------------------- */
::selection {
    background: rgba(244, 199, 122, 0.25);
    color: #E9D9B8;
}

/* -------------------------------------------------------------
   Responsive — collapse the broken grid on narrow screens
   while keeping the cinematic chapter rhythm
   ------------------------------------------------------------- */
@media (max-width: 900px) {
    .chapter {
        padding: 12vh 7vw;
    }
    .chapter-grid {
        grid-template-columns: 1fr;
        row-gap: 1.6rem;
    }
    .chapter-numeral,
    .chapter-head,
    .chapter-body,
    .chapter-blob {
        grid-column: 1 / -1 !important;
        text-align: left !important;
    }
    .chapter-iii .chapter-head .chapter-title { justify-content: flex-start; }
    .chapter-iii .chapter-head::after { margin-left: 0; }
    .chapter-numeral {
        flex-direction: row;
        justify-content: flex-start;
        margin-bottom: 0.8rem;
    }
    .chapter-numeral .rule {
        width: 28px;
        height: 1px;
    }
    .chapter-blob {
        margin: 1.5rem 0;
        max-width: 280px;
    }
    .chapter-blob svg {
        max-height: 38vh;
    }
    .chapter-v .chapter-blob {
        transform: translateX(0);
    }
}

@media (max-width: 540px) {
    .chapter-title {
        font-size: clamp(2.2rem, 12vw, 4rem);
    }
    .vestibule-title {
        font-size: clamp(3.2rem, 18vw, 6rem);
    }
    .marginalia {
        font-size: 0.68rem;
        letter-spacing: 0.28em;
    }
    .closing-line {
        font-size: 0.78rem;
        white-space: normal;
        max-width: 80vw;
    }
}
