/* ===========================================================
   genpatsu.io — A Bowl of Sunset
   palette: sunset-warm
   typography: baskerville-refined
   layout: immersive-scroll
   =========================================================== */

:root {
    --peach-paper: #fce6c8;
    --apricot-glow: #f4a574;
    --apricot-cream: #f4c89a;
    --terracotta-dusk: #e87a5d;
    --rose-ember: #c4516b;
    --plum-dusk: #7a3a52;
    --eggplant-night: #3d2640;
    --seafoam-vapor: #9bb5a0;
    --candle-white: #fff8eb;

    --serif: 'Libre Baskerville', 'Lora', Georgia, serif;
    --italic-serif: 'Cormorant Garamond', 'Cormorant', Georgia, serif;
    --mono: 'DM Mono', 'Courier New', monospace;

    --horizon-color: #f4c89a;
    --core-temperature: 0;
}

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

html, body {
    background: var(--peach-paper);
    color: var(--plum-dusk);
    font-family: var(--serif);
    font-size: 16px;
    line-height: 1.85;
    letter-spacing: 0.005em;
    overflow-x: hidden;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
}

body {
    position: relative;
    min-height: 100vh;
}

/* ===========================================================
   Background layers
   =========================================================== */

.sunset-gradient {
    position: fixed;
    inset: 0;
    z-index: -3;
    background: linear-gradient(
        180deg,
        #fce6c8 0%,
        #f4c89a 18%,
        #f4a574 38%,
        #e87a5d 50%,
        #c4516b 60%,
        #7a3a52 80%,
        #3d2640 100%
    );
    background-size: 100% 1200%;
    background-position-y: 0%;
    background-attachment: fixed;
    transition: background-position-y 80ms linear;
    pointer-events: none;
}

.bokeh-field {
    position: fixed;
    inset: 0;
    z-index: -2;
    pointer-events: none;
    opacity: 0.55;
    filter: blur(2px);
}

.bokeh-field::before,
.bokeh-field::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: transparent;
    box-shadow:
        12vw 18vh 0 -1vw rgba(252, 230, 200, 0.18),
        82vw 8vh 0 -2vw rgba(244, 165, 116, 0.18),
        66vw 28vh 0 -1vw rgba(232, 122, 93, 0.13),
        18vw 48vh 0 -3vw rgba(255, 248, 235, 0.16),
        72vw 58vh 0 -1vw rgba(196, 81, 107, 0.14),
        34vw 78vh 0 -2vw rgba(155, 181, 160, 0.12),
        88vw 88vh 0 -1vw rgba(244, 200, 154, 0.18),
        4vw 32vh 0 -3vw rgba(232, 122, 93, 0.10),
        50vw 12vh 0 -1vw rgba(255, 248, 235, 0.18);
    width: 12vw;
    height: 12vw;
    top: 0;
    left: 0;
}

.bokeh-field::after {
    box-shadow:
        24vw 6vh 0 -2vw rgba(244, 165, 116, 0.12),
        60vw 20vh 0 -1vw rgba(252, 230, 200, 0.18),
        14vw 64vh 0 -2vw rgba(196, 81, 107, 0.10),
        78vw 72vh 0 -1vw rgba(255, 248, 235, 0.14),
        40vw 38vh 0 -3vw rgba(155, 181, 160, 0.10),
        92vw 42vh 0 -2vw rgba(232, 122, 93, 0.10),
        28vw 92vh 0 -1vw rgba(122, 58, 82, 0.18),
        66vw 90vh 0 -2vw rgba(61, 38, 64, 0.18);
    width: 14vw;
    height: 14vw;
}

.bubble-field {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    pointer-events: none;
}

.bubble-field circle {
    fill: rgba(255, 248, 235, 0.06);
    stroke: rgba(155, 181, 160, 0.55);
    stroke-width: 0.5;
    mix-blend-mode: soft-light;
    filter: drop-shadow(0 0 2px rgba(244, 200, 154, 0.4));
}

.bubble-field .bubble-glyph {
    fill: rgba(122, 58, 82, 0.45);
    stroke: rgba(122, 58, 82, 0.55);
    stroke-width: 0.4;
    mix-blend-mode: normal;
}

.horizon-line {
    position: fixed;
    top: 62vh;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--horizon-color);
    z-index: 2;
    pointer-events: none;
    opacity: 0.65;
    transition: background 240ms linear, opacity 600ms ease;
    box-shadow: 0 0 8px rgba(244, 200, 154, 0.4);
}

.falling-sun {
    position: fixed;
    left: 50%;
    top: 32vh;
    width: 22vh;
    height: 22vh;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(
        circle at 50% 50%,
        rgba(255, 248, 235, 0.95) 0%,
        rgba(244, 200, 154, 0.7) 30%,
        rgba(244, 165, 116, 0.4) 55%,
        rgba(232, 122, 93, 0.15) 75%,
        transparent 100%
    );
    z-index: 0;
    pointer-events: none;
    transition: top 80ms linear, opacity 600ms ease, transform 80ms linear;
    filter: blur(2px);
}

/* ===========================================================
   Chapter dot navigator
   =========================================================== */

.chapter-dot {
    position: fixed;
    left: 3vw;
    bottom: 4vh;
    z-index: 50;
    font-family: var(--italic-serif);
    color: var(--plum-dusk);
    font-size: 0.95rem;
    letter-spacing: 0.06em;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    user-select: none;
    transition: color 480ms ease;
    pointer-events: none;
}

.dot-glyph {
    font-size: 1.4rem;
    font-family: var(--serif);
    color: var(--terracotta-dusk);
    transition: color 480ms ease, transform 480ms cubic-bezier(0.16, 1, 0.3, 1);
}

.dot-label {
    font-style: italic;
    opacity: 0.75;
    transition: opacity 600ms ease;
}

/* ===========================================================
   Sound toggle
   =========================================================== */

.sound-toggle {
    position: fixed;
    right: 3vw;
    bottom: 4vh;
    z-index: 50;
    background: transparent;
    border: 1px solid rgba(122, 58, 82, 0.35);
    color: var(--plum-dusk);
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 50%;
    font-size: 1rem;
    font-family: var(--serif);
    cursor: pointer;
    transition: background 320ms ease, color 320ms ease, border-color 320ms ease, transform 320ms ease;
    line-height: 1;
}

.sound-toggle:hover {
    background: rgba(255, 248, 235, 0.2);
    transform: scale(1.06);
}

.sound-toggle.is-on {
    color: var(--terracotta-dusk);
    border-color: var(--terracotta-dusk);
    background: rgba(244, 200, 154, 0.2);
}

/* ===========================================================
   Rooms (12 × 100vh)
   =========================================================== */

.rooms {
    position: relative;
    z-index: 3;
}

.room {
    position: relative;
    min-height: 100vh;
    width: 100%;
    padding: 8vh 14vw 8vh 22vw; /* asymmetric: left larger than right (~1.6×) */
    display: flex;
    align-items: center;
    overflow: visible;
}

.room-inner {
    position: relative;
    max-width: 56ch;
    transform: translateY(0);
    transition: transform 1200ms cubic-bezier(0.16, 1, 0.3, 1), opacity 1200ms ease-out;
    opacity: 0.001;
}

.room.is-visible .room-inner {
    opacity: 1;
}

.room-inner--centered {
    margin: 0 auto;
    text-align: center;
    max-width: 60ch;
}

.room-inner--right {
    margin-left: auto;
    text-align: left;
}

.room-inner--quiet {
    text-align: center;
}

/* Editorial sine wave drift on baseline (±24px) */
.room:nth-child(1) .room-inner { transform: translateY(0px); }
.room:nth-child(2) .room-inner { transform: translateY(12px); }
.room:nth-child(3) .room-inner { transform: translateY(22px); }
.room:nth-child(4) .room-inner { transform: translateY(12px); }
.room:nth-child(5) .room-inner { transform: translateY(-8px); }
.room:nth-child(6) .room-inner { transform: translateY(-22px); }
.room:nth-child(7) .room-inner { transform: translateY(-12px); }
.room:nth-child(8) .room-inner { transform: translateY(8px); }
.room:nth-child(9) .room-inner { transform: translateY(22px); }
.room:nth-child(10) .room-inner { transform: translateY(12px); }
.room:nth-child(11) .room-inner { transform: translateY(-8px); }
.room:nth-child(12) .room-inner { transform: translateY(-22px); }

@media (max-width: 720px) {
    .room {
        padding: 8vh 8vw 8vh 12vw;
    }
    .room-inner {
        max-width: 100%;
    }
}

.room--tall {
    min-height: 120vh;
}

/* ===========================================================
   Typography
   =========================================================== */

.kicker {
    font-family: var(--italic-serif);
    font-style: italic;
    font-size: 0.95rem;
    color: var(--plum-dusk);
    opacity: 0.7;
    letter-spacing: 0.08em;
    margin-bottom: 1.2rem;
}

.title-display {
    font-family: var(--serif);
    font-style: italic;
    font-weight: 700;
    font-size: clamp(3rem, 8vw, 7.5rem);
    line-height: 1.05;
    color: var(--plum-dusk);
    margin-bottom: 1.6rem;
    letter-spacing: -0.005em;
    font-variant: small-caps;
    word-spacing: 0.02em;
}

.title-display span {
    display: inline-block;
    opacity: 0;
    transform: translateY(0.4em) rotate(-1.5deg);
    transition: opacity 900ms cubic-bezier(0.16, 1, 0.3, 1), transform 900ms cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform, opacity;
}

.title-display.is-revealed span {
    opacity: 1;
    transform: translateY(0) rotate(0);
}

.title-display--warning {
    color: var(--rose-ember);
}

.title-display--quiet {
    color: var(--seafoam-vapor);
    font-size: clamp(2.4rem, 6vw, 5rem);
}

.title-display--final {
    color: var(--candle-white);
    font-size: clamp(3rem, 9vw, 8rem);
}

.subtitle {
    font-family: var(--italic-serif);
    font-style: italic;
    font-size: 1.4rem;
    color: var(--terracotta-dusk);
    margin-bottom: 2.4rem;
    letter-spacing: 0.02em;
}

.italic {
    font-family: var(--italic-serif);
    font-style: italic;
}

.paragraph {
    font-size: 1.125rem;
    line-height: 1.85;
    letter-spacing: 0.005em;
    color: var(--plum-dusk);
    margin-bottom: 1.4rem;
    transition: opacity 1200ms ease-out 200ms;
    opacity: 0.001;
}

.room.is-visible .paragraph {
    opacity: 1;
}

.paragraph--lead {
    font-size: 1.25rem;
    margin-top: 1.4rem;
}

.paragraph--narrow {
    max-width: 44ch;
    margin: 1.6rem auto 2.4rem;
}

.paragraph--whisper {
    font-family: var(--italic-serif);
    font-style: italic;
    font-size: 1.4rem;
    color: var(--seafoam-vapor);
    text-align: center;
    margin: 1.6rem 0;
    letter-spacing: 0.04em;
}

.paragraph--final {
    color: var(--candle-white);
    font-size: 1.25rem;
}

.paragraph em {
    font-style: italic;
    color: var(--terracotta-dusk);
    font-weight: 400;
}

.cormorant-aside {
    font-family: var(--italic-serif);
    font-style: italic;
    font-size: 1.05rem;
    color: var(--rose-ember);
    margin-top: 1.6rem;
    letter-spacing: 0.02em;
    opacity: 0.85;
    transition: opacity 1200ms ease-out 400ms;
}

.room.is-visible .cormorant-aside {
    opacity: 0.85;
}

/* ===========================================================
   Marginalia (hand-drawn ink illustrations)
   =========================================================== */

.marginalia {
    position: absolute;
    width: 80px;
    height: 80px;
    top: -20px;
    right: -100px;
    opacity: 0.85;
}

@media (max-width: 1100px) {
    .marginalia {
        right: -40px;
        top: -40px;
        width: 60px;
        height: 60px;
    }
}

@media (max-width: 720px) {
    .marginalia {
        position: relative;
        right: 0;
        top: 0;
        margin-top: 1.6rem;
        opacity: 0.7;
    }
}

.marginalia path,
.marginalia circle {
    stroke-dasharray: var(--draw-len, 400);
    stroke-dashoffset: var(--draw-len, 400);
    transition: stroke-dashoffset 1800ms cubic-bezier(0.16, 1, 0.3, 1);
}

.room.is-visible .marginalia path,
.room.is-visible .marginalia circle {
    stroke-dashoffset: 0;
}

/* ===========================================================
   Two clocks
   =========================================================== */

.two-clocks {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3vw;
    margin: 3rem 0;
}

@media (max-width: 720px) {
    .two-clocks {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
}

.clock-card {
    padding: 2rem 1.6rem;
    border-top: 1px solid rgba(122, 58, 82, 0.3);
    border-bottom: 1px solid rgba(122, 58, 82, 0.3);
}

.clock-card--warm {
    border-color: rgba(196, 81, 107, 0.4);
}

.clock-label {
    font-family: var(--italic-serif);
    font-style: italic;
    font-size: 1rem;
    color: var(--plum-dusk);
    opacity: 0.7;
    margin-bottom: 0.8rem;
    letter-spacing: 0.04em;
}

.clock-readout {
    font-family: var(--serif);
    font-style: italic;
    font-size: 2rem;
    color: var(--plum-dusk);
    line-height: 1.2;
    margin-bottom: 0.6rem;
}

.clock-card--warm .clock-readout {
    color: var(--rose-ember);
}

.clock-mono {
    font-family: var(--mono);
    font-weight: 300;
    font-size: 0.95rem;
    color: var(--plum-dusk);
    text-transform: lowercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
    opacity: 0.7;
}

.clock-card--warm .clock-mono {
    color: var(--rose-ember);
}

.clock-aside {
    font-family: var(--italic-serif);
    font-style: italic;
    font-size: 1rem;
    color: var(--plum-dusk);
    line-height: 1.6;
    opacity: 0.85;
}

/* ===========================================================
   Cracked teacups
   =========================================================== */

.teacups {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2vw;
    margin: 3rem 0;
}

@media (max-width: 720px) {
    .teacups {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
}

.teacup {
    text-align: center;
}

.teacup svg {
    width: 100%;
    max-width: 180px;
    height: auto;
    display: block;
    margin: 0 auto 1rem;
}

.teacup .crack {
    transition: stroke-dashoffset 2400ms cubic-bezier(0.16, 1, 0.3, 1);
}

.room.is-visible .teacup .crack {
    stroke-dashoffset: 0 !important;
}

.teacup figcaption {
    font-family: var(--italic-serif);
    font-style: italic;
    font-size: 0.95rem;
    color: var(--rose-ember);
    letter-spacing: 0.04em;
}

/* ===========================================================
   Simulator (reactor-as-fruit)
   =========================================================== */

.simulator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4vw;
    margin: 3rem auto;
    flex-wrap: wrap;
}

.simulator-jar {
    position: relative;
    width: 240px;
    height: 320px;
    flex-shrink: 0;
}

.jar-glass {
    position: absolute;
    inset: 0;
    border-radius: 30% 30% 50% 50% / 8% 8% 12% 12%;
    background:
        radial-gradient(ellipse 60% 40% at 30% 20%, rgba(255, 248, 235, 0.45), transparent 60%),
        radial-gradient(ellipse 80% 90% at 50% 50%, rgba(255, 248, 235, 0.10), rgba(155, 181, 160, 0.08));
    border: 1.5px solid rgba(255, 248, 235, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    box-shadow:
        inset 0 0 60px rgba(255, 248, 235, 0.18),
        inset -8px -8px 30px rgba(122, 58, 82, 0.18),
        0 20px 60px rgba(122, 58, 82, 0.2);
    overflow: hidden;
}

.jar-glass::before {
    content: '';
    position: absolute;
    top: 12%;
    left: 18%;
    width: 18%;
    height: 40%;
    background: linear-gradient(160deg, rgba(255, 248, 235, 0.6), transparent 70%);
    border-radius: 50%;
    filter: blur(4px);
}

.jar-fruit {
    position: absolute;
    left: 50%;
    top: 50%;
    width: calc(100px + var(--core-temperature) * 50px);
    height: calc(100px + var(--core-temperature) * 50px);
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background:
        radial-gradient(circle at 35% 30%,
            rgba(255, 248, 235, calc(0.6 + var(--core-temperature) * 0.3)),
            transparent 35%),
        radial-gradient(circle at 50% 50%,
            hsl(calc(36 - var(--core-temperature) * 24),
                calc(55% + var(--core-temperature) * 25%),
                calc(78% - var(--core-temperature) * 20%)),
            hsl(calc(20 - var(--core-temperature) * 30),
                calc(70% + var(--core-temperature) * 15%),
                calc(60% - var(--core-temperature) * 18%)) 70%,
            hsl(calc(340 + var(--core-temperature) * 10),
                calc(40% + var(--core-temperature) * 35%),
                calc(35% - var(--core-temperature) * 5%)) 100%);
    box-shadow:
        0 0 calc(20px + var(--core-temperature) * 80px)
            calc(4px + var(--core-temperature) * 14px)
            hsla(calc(28 - var(--core-temperature) * 24),
                85%, 65%,
                calc(0.4 + var(--core-temperature) * 0.4)),
        inset -10px -14px 30px rgba(122, 58, 82, 0.25);
    animation: pulse-glow calc(2.4s - var(--core-temperature) * 1.6s) ease-in-out infinite;
    transition: width 480ms ease, height 480ms ease;
}

@keyframes pulse-glow {
    0%, 100% {
        filter: brightness(1);
    }
    50% {
        filter: brightness(calc(1.05 + var(--core-temperature) * 0.15));
    }
}

.jar-rods {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    gap: 8px;
    align-items: flex-start;
    pointer-events: none;
    padding-top: 4px;
}

.rod {
    display: block;
    width: 6px;
    height: calc(40% + (1 - var(--core-temperature)) * 38%);
    background: linear-gradient(180deg, #8B4513 0%, #6B3410 60%, #4A2308 100%);
    border-radius: 3px 3px 4px 4px;
    box-shadow:
        inset -1px 0 2px rgba(0, 0, 0, 0.3),
        inset 1px 0 1px rgba(255, 200, 150, 0.2);
    transition: height 240ms cubic-bezier(0.16, 1, 0.3, 1);
}

.rod:nth-child(1) { height: calc(36% + (1 - var(--core-temperature)) * 40%); }
.rod:nth-child(2) { height: calc(42% + (1 - var(--core-temperature)) * 36%); }
.rod:nth-child(3) { height: calc(40% + (1 - var(--core-temperature)) * 38%); }
.rod:nth-child(4) { height: calc(38% + (1 - var(--core-temperature)) * 40%); }
.rod:nth-child(5) { height: calc(34% + (1 - var(--core-temperature)) * 42%); }

.jar-base {
    position: absolute;
    bottom: -6px;
    left: 12%;
    right: 12%;
    height: 14px;
    background: linear-gradient(180deg, rgba(122, 58, 82, 0.4), rgba(61, 38, 64, 0.5));
    border-radius: 50%;
    filter: blur(2px);
}

.simulator-dial {
    position: relative;
    width: 220px;
    height: 220px;
    cursor: grab;
    user-select: none;
    touch-action: none;
}

.simulator-dial:active {
    cursor: grabbing;
}

.dial-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.dial-handle {
    transform-origin: 100px 100px;
    transition: transform 80ms linear;
}

.dial-readout {
    position: absolute;
    left: 0;
    right: 0;
    bottom: -3rem;
    text-align: center;
    font-family: var(--mono);
    font-weight: 300;
    font-size: 0.95rem;
    color: var(--plum-dusk);
    text-transform: lowercase;
    letter-spacing: 0.06em;
}

.dial-label {
    display: block;
    font-family: var(--italic-serif);
    font-style: italic;
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
    opacity: 0.7;
    text-transform: none;
}

.dial-mono {
    display: block;
    font-size: 1.4rem;
    color: var(--terracotta-dusk);
}

.simulator-warning {
    font-family: var(--italic-serif);
    font-style: italic;
    font-size: 1.2rem;
    color: var(--rose-ember);
    text-align: center;
    margin: 2rem auto 0;
    opacity: 0;
    transform: translateY(0.6em);
    transition: opacity 800ms ease, transform 800ms cubic-bezier(0.16, 1, 0.3, 1);
}

.simulator-warning.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* ===========================================================
   Haiku
   =========================================================== */

.haiku {
    margin: 2rem 0;
    padding-left: 2rem;
    border-left: 1px solid rgba(122, 58, 82, 0.25);
}

.haiku-line {
    font-family: var(--italic-serif);
    font-style: italic;
    font-size: 1.3rem;
    color: var(--plum-dusk);
    line-height: 1.6;
    letter-spacing: 0.02em;
}

.haiku-line:nth-child(2) {
    color: var(--terracotta-dusk);
}

/* ===========================================================
   Final room (the exhale)
   =========================================================== */

.room--final {
    color: var(--candle-white);
}

.room--final .title-display {
    color: var(--candle-white);
}

.star-field {
    position: relative;
    width: 100%;
    height: 30vh;
    margin: 2rem 0;
    overflow: hidden;
}

.star-field .star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: var(--candle-white);
    border-radius: 50%;
    box-shadow: 0 0 6px var(--candle-white);
    opacity: 0;
    animation: star-blink 4s ease-in-out infinite;
}

@keyframes star-blink {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.2); }
}

.colophon {
    color: var(--candle-white);
    opacity: 0.6;
    font-size: 1rem;
    margin-top: 3rem;
    letter-spacing: 0.08em;
}

.room--quiet {
    background: rgba(155, 181, 160, 0.05);
}
