/* =====================================================
   chika.monster v2 — Japanese-Minimal 3D-Render Diorama
   Sepia-Nostalgic palette · Bebas-bold typography
   ===================================================== */

:root {
    --washi: #E8D9BC;
    --sepia-paper: #D2BC95;
    --cedar-tan: #A8845C;
    --aged-walnut: #6E5238;
    --sepia-ink: #3A2A1C;
    --persimmon: #C99572;
    --moss-sage: #7B8A6E;
    --window-light: #F4ECD6;

    --font-display: "Bebas Neue", "Arial Narrow", sans-serif;
    --font-body: "Cormorant Garamond", "Georgia", serif;
    --font-jp: "Noto Serif JP", "Yu Mincho", serif;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--washi);
    color: var(--sepia-ink);
    font-family: var(--font-body);
    font-style: italic;
    line-height: 1.7;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    position: relative;
    min-height: 100vh;
}

/* ----- Paper grain texture overlay ----- */
.paper-grain {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.06;
    mix-blend-mode: multiply;
    background-image:
        radial-gradient(circle at 13% 27%, var(--aged-walnut) 0.3px, transparent 1px),
        radial-gradient(circle at 67% 53%, var(--cedar-tan) 0.3px, transparent 1px),
        radial-gradient(circle at 32% 81%, var(--sepia-ink) 0.3px, transparent 1px),
        radial-gradient(circle at 88% 12%, var(--aged-walnut) 0.3px, transparent 1px),
        radial-gradient(circle at 47% 64%, var(--cedar-tan) 0.3px, transparent 1px);
    background-size: 3px 3px, 5px 5px, 4px 4px, 6px 6px, 3px 3px;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 999;
    background: radial-gradient(ellipse at center, transparent 0%, rgba(110, 82, 56, 0.06) 60%, rgba(58, 42, 28, 0.12) 100%);
}

/* ----- House navigation rail ----- */
.house-nav {
    position: fixed;
    right: 28px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    user-select: none;
}

.house-nav ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.house-nav li {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    color: var(--aged-walnut);
    opacity: 0.45;
    transition: opacity 0.5s ease, color 0.5s ease, transform 0.5s ease;
    padding: 2px 6px;
}

.house-nav li:hover {
    opacity: 1;
    transform: translateX(-4px);
    color: var(--sepia-ink);
}

.house-nav li.active {
    opacity: 1;
    color: var(--sepia-ink);
}

.house-nav li.active .nav-num::before {
    content: "—";
    color: var(--persimmon);
    margin-right: 6px;
    letter-spacing: 0;
}

.nav-num {
    font-size: 13px;
    letter-spacing: 0.18em;
    min-width: 22px;
}

.nav-label {
    font-family: var(--font-jp);
    font-style: normal;
    font-size: 13px;
    opacity: 0.75;
    letter-spacing: 0.08em;
}

/* ----- Section / Room base ----- */
main {
    position: relative;
    z-index: 1;
}

.room {
    min-height: 100vh;
    padding: 80px 8vw 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border-bottom: 1px solid rgba(110, 82, 56, 0.12);
}

.room::after {
    content: "";
    position: absolute;
    bottom: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 1px;
    background: var(--aged-walnut);
    opacity: 0.4;
}

.room-inner {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
}

.room-inner.two-col {
    flex-direction: row;
    align-items: center;
    gap: 6vw;
}

.room-inner.two-col.reversed {
    flex-direction: row-reverse;
}

/* Dark night-garden section */
.dark-section {
    background: linear-gradient(180deg, var(--washi) 0%, var(--washi) 5%, #C9B79A 35%, #8C7659 100%);
    color: var(--washi);
}

.dark-section .room-marker,
.dark-section .room-title,
.dark-section .body,
.dark-section .small-note {
    color: var(--window-light);
}

.dark-section .room-marker {
    color: var(--persimmon);
}

/* ----- Opening section ----- */
.opening-header {
    text-align: center;
    width: 100%;
    margin-bottom: 30px;
}

.room-marker {
    font-family: var(--font-display);
    font-size: 13px;
    letter-spacing: 0.22em;
    color: var(--aged-walnut);
    text-transform: uppercase;
    margin-bottom: 32px;
    display: inline-block;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--cedar-tan);
    font-style: normal;
}

.display-title {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(64px, 9vw, 168px);
    line-height: 0.95;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--sepia-ink);
    margin: 12px 0 28px;
    font-style: normal;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(12px, 1.6vw, 30px);
    flex-wrap: wrap;
}

.closing-title {
    font-size: clamp(48px, 7vw, 120px);
}

.title-line {
    display: inline-block;
    position: relative;
    color: transparent;
}

.title-line::before {
    content: attr(data-text);
    position: absolute;
    inset: 0;
    color: var(--sepia-ink);
    clip-path: inset(0 100% 0 0);
    transition: clip-path 1.2s cubic-bezier(0.7, 0, 0.3, 1);
}

.title-line.revealed::before {
    clip-path: inset(0 0 0 0);
}

.title-line::after {
    /* keep occupancy */
    content: attr(data-text);
    visibility: hidden;
}

.title-slash {
    font-family: var(--font-display);
    color: var(--persimmon);
    font-size: 0.65em;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.8s ease 0.6s, transform 0.8s ease 0.6s;
}

.display-title.title-shown .title-slash {
    opacity: 1;
    transform: translateY(0);
}

.subtitle {
    font-family: var(--font-body);
    font-style: italic;
    font-size: clamp(14px, 1.2vw, 19px);
    color: var(--aged-walnut);
    letter-spacing: 0.04em;
    margin-top: 8px;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 1.4s ease 1.2s, transform 1.4s ease 1.2s;
}

.subtitle.revealed {
    opacity: 1;
    transform: translateY(0);
}

.scroll-cue {
    margin-top: 60px;
    text-align: center;
    font-family: var(--font-body);
    font-style: italic;
    font-size: 14px;
    color: var(--cedar-tan);
    letter-spacing: 0.06em;
    opacity: 0;
    animation: fadeUp 1.6s ease 2.6s forwards, pulseUp 2.6s ease-in-out 4s infinite;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 0.9; transform: translateY(0); }
}

@keyframes pulseUp {
    0%, 100% { transform: translateY(0); opacity: 0.9; }
    50% { transform: translateY(6px); opacity: 0.5; }
}

/* ----- Room text aside ----- */
.room-text {
    flex: 1 1 38%;
    max-width: 460px;
    padding: 0 12px;
}

.room-title {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(36px, 5vw, 80px);
    line-height: 1.0;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--sepia-ink);
    margin: 16px 0 28px;
    font-style: normal;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1s ease, transform 1s ease;
}

.room.in-view .room-title {
    opacity: 1;
    transform: translateY(0);
}

.body {
    font-family: var(--font-body);
    font-style: italic;
    font-size: clamp(15px, 1.1vw, 18px);
    line-height: 1.75;
    color: var(--aged-walnut);
    margin-bottom: 18px;
    max-width: 38ch;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1.2s ease 0.3s, transform 1.2s ease 0.3s;
}

.room.in-view .body {
    opacity: 1;
    transform: translateY(0);
}

.small-note {
    color: var(--cedar-tan);
    font-size: 0.9em;
    opacity: 0;
    transition: opacity 1.2s ease 0.6s;
}

.room.in-view .small-note {
    opacity: 0.85;
}

.jp {
    font-family: var(--font-jp);
    font-style: normal;
    color: var(--sepia-ink);
    font-size: 0.92em;
    margin: 0 4px;
    letter-spacing: 0.06em;
}

.dark-section .jp {
    color: var(--window-light);
}

/* ----- Diorama stage ----- */
.diorama-stage {
    flex: 1 1 60%;
    width: 100%;
    max-width: 760px;
    aspect-ratio: 800 / 560;
    position: relative;
    margin: 30px auto;
}

#section-0 .diorama-stage,
#section-8 .diorama-stage {
    aspect-ratio: 800 / 520;
    max-width: 700px;
}

.diorama {
    width: 100%;
    height: 100%;
    display: block;
    overflow: visible;
    filter: drop-shadow(0 20px 36px rgba(58, 42, 28, 0.14));
}

/* Layer base states (hidden until in view) */
.layer-piece {
    opacity: 0;
    transform: translateY(28px) scale(0.985);
    transform-origin: center;
    transition: opacity 1.2s cubic-bezier(0.4, 0, 0.2, 1),
                transform 1.2s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: opacity, transform;
}

.room.in-view .layer-piece {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Choreographed staggered reveal by data-order */
.room.in-view .layer-piece[data-order="1"] { transition-delay: 0.1s; }
.room.in-view .layer-piece[data-order="2"] { transition-delay: 0.45s; }
.room.in-view .layer-piece[data-order="3"] { transition-delay: 0.85s; }
.room.in-view .layer-piece[data-order="4"] { transition-delay: 1.20s; }
.room.in-view .layer-piece[data-order="5"] { transition-delay: 1.55s; }
.room.in-view .layer-piece[data-order="6"] { transition-delay: 1.90s; }
.room.in-view .layer-piece[data-order="7"] { transition-delay: 2.25s; }

/* Atmospheric layer (light rays) */
.layer-atmos {
    opacity: 0;
    transition: opacity 2s ease 1.8s;
}

.room.in-view .layer-atmos {
    opacity: 1;
}

/* Lantern glow pulse */
.lantern-glow {
    transform-origin: center;
    transform-box: fill-box;
    animation: lanternPulse 5s ease-in-out infinite;
}

@keyframes lanternPulse {
    0%, 100% { opacity: 0.85; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.06); }
}

/* Steam rising */
.steam-wisp {
    transform-origin: bottom center;
    transform-box: fill-box;
}

.room.in-view .steam-wisp:nth-child(1) {
    animation: steamRise 4s ease-in-out 2.5s infinite;
}

.room.in-view .steam-wisp:nth-child(2) {
    animation: steamRise 4.4s ease-in-out 3.1s infinite;
}

.room.in-view .steam-wisp:nth-child(3) {
    animation: steamRise 3.8s ease-in-out 3.6s infinite;
}

@keyframes steamRise {
    0% { opacity: 0; transform: translateY(0) scaleY(0.6); }
    30% { opacity: 0.7; }
    70% { opacity: 0.45; }
    100% { opacity: 0; transform: translateY(-60px) scaleY(1.4); }
}

/* Hanging cloth sway */
.cloth-sway {
    transform-origin: top center;
    transform-box: fill-box;
    animation: cloth 6s ease-in-out infinite;
}

@keyframes cloth {
    0%, 100% { transform: rotate(-1.2deg); }
    50% { transform: rotate(1.4deg); }
}

/* Bird fly in */
.bird-fly {
    transform: translate(-400px, -80px);
    opacity: 0;
    transition: transform 2.2s cubic-bezier(0.3, 0.1, 0.2, 1) 1.8s,
                opacity 1.4s ease 1.8s;
}

.room.in-view .bird-fly {
    transform: translate(0, 0);
    opacity: 1;
}

/* Moon glow extra pulse */
.moon-glow {
    transform-origin: center;
    transform-box: fill-box;
    animation: moonPulse 8s ease-in-out infinite;
}

@keyframes moonPulse {
    0%, 100% { opacity: 0.9; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.04); }
}

/* Dim overlay for bath section */
.dim-overlay {
    transition: opacity 2s ease 1.8s;
}

.room.in-view .dim-overlay {
    opacity: 0.18;
}

/* Closing door slide */
.door-close {
    transition: opacity 1.2s ease 0.85s, transform 2.4s cubic-bezier(0.4, 0, 0.3, 1) 1.6s;
}

.room.in-view .door-close {
    transform: translateY(0) scale(1);
}

/* Closing line */
.closing-line {
    font-family: var(--font-body);
    font-style: italic;
    font-size: clamp(16px, 1.4vw, 22px);
    color: var(--aged-walnut);
    text-align: center;
    margin: 36px 0 8px;
    letter-spacing: 0.04em;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 1.4s ease, transform 1.4s ease;
}

#section-8.in-view .closing-line {
    opacity: 1;
    transform: translateY(0);
}

#section-8.in-view .closing-line.small-note {
    transition-delay: 0.4s;
    color: var(--cedar-tan);
}

.closing-header {
    margin-bottom: 0;
}

/* ----- Footer ----- */
.house-footer {
    padding: 60px 8vw 80px;
    text-align: center;
    font-family: var(--font-body);
    font-style: italic;
    font-size: 13px;
    color: var(--cedar-tan);
    letter-spacing: 0.08em;
    border-top: 1px solid rgba(110, 82, 56, 0.18);
    background: var(--washi);
    position: relative;
    z-index: 1;
}

/* ----- Parallax layer hooks (transform applied via JS) ----- */
.layer-bg,
.layer-mid,
.layer-fg,
.layer-atmos {
    transition: transform 0.4s linear;
}

/* ----- Section-specific tints ----- */
#section-0 {
    background: linear-gradient(180deg, var(--washi) 0%, var(--washi) 100%);
}

#section-1 {
    background: linear-gradient(180deg, var(--washi) 0%, #EAD9B8 100%);
}

#section-2 {
    background: linear-gradient(180deg, #EAD9B8 0%, var(--washi) 100%);
}

#section-3 {
    background: linear-gradient(180deg, var(--washi) 0%, #EFE0C4 100%);
}

#section-4 {
    background: linear-gradient(180deg, #EFE0C4 0%, #E4D5B0 100%);
}

#section-5 {
    background: linear-gradient(180deg, #E4D5B0 0%, #D9C8A2 100%);
}

#section-6 {
    background: linear-gradient(180deg, #D9C8A2 0%, #CEBC92 100%);
}

#section-7 {
    background: linear-gradient(180deg, #CEBC92 0%, #3A2A1C 100%);
}

#section-8 {
    background: linear-gradient(180deg, #3A2A1C 0%, var(--washi) 30%, var(--washi) 100%);
}

/* ----- Responsive ----- */
@media (max-width: 900px) {
    .house-nav { right: 12px; }
    .nav-label { display: none; }
    .nav-num { font-size: 11px; }

    .room {
        padding: 60px 5vw 80px;
    }

    .room-inner.two-col,
    .room-inner.two-col.reversed {
        flex-direction: column;
        gap: 30px;
    }

    .room-text {
        max-width: 100%;
        text-align: center;
    }

    .body {
        margin-left: auto;
        margin-right: auto;
    }

    .display-title {
        gap: 8px;
    }
}

@media (max-width: 540px) {
    .house-nav {
        right: 8px;
        gap: 10px;
    }
    .nav-num { font-size: 10px; min-width: 16px; }

    .room { padding: 50px 4vw 70px; }
    .room-title { font-size: clamp(28px, 8vw, 44px); }
    .display-title { font-size: clamp(48px, 14vw, 80px); }
    .closing-title { font-size: clamp(36px, 11vw, 56px); }
}
