@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+JP:wght@300;400;500;600;700&family=Zen+Old+Mincho:wght@400;700&display=swap');

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

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

body {
    font-family: 'Noto Serif JP', serif;
    color: #2c2c2c;
    background: #fafaf8;
    line-height: 2;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ===== Petal Canvas (floating petals container) ===== */
.petal-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
    overflow: hidden;
}

.floating-petal {
    position: absolute;
    pointer-events: none;
    will-change: transform, opacity;
}

.floating-petal img {
    width: 100%;
    height: auto;
}

/* ===== Hero Section ===== */
.hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    background: #ffffff;
}

.hero__bouquet {
    width: min(400px, 60vw);
    opacity: 0;
    transform: translateY(40px) scale(0.95);
    animation: heroFadeIn 2s ease-out 0.3s forwards;
    margin-bottom: 2rem;
}

.hero__title {
    font-family: 'Zen Old Mincho', serif;
    font-size: clamp(2.4rem, 6vw, 4.5rem);
    font-weight: 700;
    letter-spacing: 0.3em;
    color: #3a3a3a;
    opacity: 0;
    animation: heroFadeIn 2s ease-out 0.8s forwards;
    text-align: center;
}

.hero__subtitle {
    font-size: clamp(0.85rem, 2vw, 1rem);
    color: #999;
    margin-top: 1rem;
    letter-spacing: 0.15em;
    font-weight: 300;
    opacity: 0;
    animation: heroFadeIn 2s ease-out 1.2s forwards;
}

.hero__synopsis {
    max-width: 560px;
    margin-top: 3rem;
    padding: 0 1.5rem;
    font-size: 0.92rem;
    line-height: 2.2;
    color: #666;
    text-align: center;
    opacity: 0;
    animation: heroFadeIn 2s ease-out 1.6s forwards;
}

.hero__scroll-hint {
    position: absolute;
    bottom: 2.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    opacity: 0;
    animation: heroFadeIn 2s ease-out 2s forwards;
}

.hero__scroll-hint span {
    font-size: 0.75rem;
    color: #bbb;
    letter-spacing: 0.2em;
}

.hero__scroll-arrow {
    width: 1px;
    height: 40px;
    background: linear-gradient(to bottom, #ccc, transparent);
    animation: scrollPulse 2s ease-in-out infinite;
}

/* ===== Table of Contents ===== */
.toc {
    max-width: 560px;
    margin: 0 auto;
    padding: 4rem 1.5rem;
}

.toc__title {
    font-family: 'Zen Old Mincho', serif;
    font-size: 1.1rem;
    letter-spacing: 0.3em;
    color: #999;
    text-align: center;
    margin-bottom: 2.5rem;
}

.toc__list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.toc__item a {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    padding: 1rem 1.5rem;
    text-decoration: none;
    color: #3a3a3a;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-size: 1rem;
}

.toc__item a:hover {
    background: rgba(0, 0, 0, 0.02);
    transform: translateX(4px);
}

.toc__number {
    font-family: 'Zen Old Mincho', serif;
    font-size: 0.8rem;
    color: #bbb;
    min-width: 2rem;
}

.toc__chapter-name {
    font-weight: 500;
    letter-spacing: 0.15em;
}

/* ===== Divider ===== */
.divider {
    width: 60px;
    height: 1px;
    background: #ddd;
    margin: 0 auto;
}

/* ===== Chapter Styles ===== */
.chapter {
    position: relative;
    overflow: hidden;
    padding: 6rem 0;
}

.chapter__inner {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 2rem;
    position: relative;
    z-index: 2;
}

.chapter__header {
    text-align: center;
    margin-bottom: 4rem;
}

.chapter__number {
    font-family: 'Zen Old Mincho', serif;
    font-size: 0.8rem;
    color: #bbb;
    letter-spacing: 0.3em;
    margin-bottom: 0.8rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.chapter__title {
    font-family: 'Zen Old Mincho', serif;
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    font-weight: 700;
    letter-spacing: 0.25em;
    color: #3a3a3a;
    opacity: 0;
    transform: scale(0.85) translateY(30px);
    transition: opacity 1s ease, transform 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Chapter header visible state */
.chapter__header.in-view .chapter__number {
    opacity: 1;
    transform: translateY(0);
}

.chapter__header.in-view .chapter__title {
    opacity: 1;
    transform: scale(1) translateY(0);
}

/* Chapter body paragraphs */
.chapter__body p {
    font-size: 1rem;
    line-height: 2;
    margin-bottom: 1.4em;
    text-indent: 1em;
    letter-spacing: 0.04em;
    color: #333;
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.chapter__body p.in-view {
    opacity: 1;
    transform: translateY(0);
}

.chapter__body p.dialogue {
    text-indent: 0;
}

.chapter__body p.scene-break {
    text-indent: 0;
    text-align: center;
    margin: 2.5em 0;
    color: #ccc;
    letter-spacing: 1em;
}

/* ===== Flower Decorations (scroll-linked parallax) ===== */
.flower-deco {
    position: absolute;
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    transition: opacity 1.5s ease;
    will-change: transform;
}

.flower-deco.visible {
    opacity: 1;
}

.flower-deco--right {
    right: -3%;
    top: 10%;
    width: min(280px, 28vw);
}

.flower-deco--left {
    left: -3%;
    bottom: 10%;
    width: min(240px, 24vw);
}

.flower-deco--center-bottom {
    left: 50%;
    bottom: -5%;
    transform: translateX(-50%);
    width: min(320px, 38vw);
}

.flower-deco img {
    width: 100%;
    height: auto;
    opacity: 0.25;
    filter: saturate(0.7);
    transition: opacity 0.5s ease;
    mix-blend-mode: multiply;
}

/* Per-chapter flower intensity (builds to climax) */
.chapter--ch1 .flower-deco img {
    opacity: 0.12;
}

.chapter--ch2 .flower-deco img {
    opacity: 0.18;
}

.chapter--ch3 .flower-deco img {
    opacity: 0.22;
}

.chapter--ch4 .flower-deco img {
    opacity: 0.18;
}

.chapter--ch5 .flower-deco img {
    opacity: 0.30;
    filter: saturate(0.9);
}

/* ===== Chapter Gradient Backgrounds ===== */
.chapter--ch1 {
    background: #fafaf8;
}

.chapter--ch2 {
    background: linear-gradient(180deg, #fafaf8 0%, #f5f8f4 50%, #fafaf8 100%);
}

.chapter--ch3 {
    background: linear-gradient(180deg, #fafaf8 0%, #f4f6f3 50%, #fafaf8 100%);
}

.chapter--ch4 {
    background: linear-gradient(180deg, #fafaf8 0%, #f8f5f0 50%, #fafaf8 100%);
}

.chapter--ch5 {
    background: linear-gradient(180deg, #fafaf8 0%, #fdf6f0 30%, #fef8f2 70%, #fafaf8 100%);
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 4rem 1.5rem;
    color: #bbb;
    font-size: 0.8rem;
    letter-spacing: 0.1em;
}

.footer__error {
    font-family: monospace;
    font-size: 0.7rem;
    color: #d4d4d4;
    margin-top: 0.8rem;
    letter-spacing: 0.05em;
}

/* ===== Keyframes ===== */
@keyframes heroFadeIn {
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes scrollPulse {

    0%,
    100% {
        opacity: 0.3;
        height: 40px;
    }

    50% {
        opacity: 0.8;
        height: 50px;
    }
}

@keyframes petalDrift {
    0% {
        transform: translate(0, 0) rotate(0deg);
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    85% {
        opacity: 1;
    }

    100% {
        transform: translate(var(--drift-x), var(--drift-y)) rotate(var(--drift-rot));
        opacity: 0;
    }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .petal-canvas {
        display: none;
    }

    .flower-deco {
        opacity: 0.15 !important;
    }

    .chapter__title,
    .chapter__number,
    .chapter__body p {
        opacity: 1 !important;
        transform: none !important;
    }
}

/* ===== Responsive: Tablet (768-1023px) ===== */
@media (max-width: 1023px) {
    .chapter__inner {
        max-width: 640px;
        padding: 0 1.5rem;
    }

    .flower-deco--right,
    .flower-deco--left {
        width: min(200px, 26vw);
    }

    .flower-deco img {
        opacity: 0.18 !important;
    }
}

/* ===== Responsive: Mobile (767px and below) ===== */
@media (max-width: 767px) {
    .chapter__inner {
        padding: 0 1.2rem;
    }

    .chapter {
        padding: 4rem 0;
    }

    .chapter__body p {
        font-size: 0.95rem;
        line-height: 1.95;
    }

    .chapter__title {
        font-size: clamp(1.5rem, 5vw, 2rem);
    }

    .flower-deco--right {
        right: -8%;
        width: min(160px, 35vw);
    }

    .flower-deco--left {
        left: -8%;
        width: min(140px, 30vw);
    }

    .flower-deco img {
        opacity: 0.12 !important;
    }

    .toc__item a {
        padding: 0.8rem 1rem;
        font-size: 0.95rem;
    }

    .hero__bouquet {
        width: min(300px, 65vw);
    }
}

/* ===== Responsive: Small Mobile (480px and below) ===== */
@media (max-width: 480px) {
    .hero__bouquet {
        width: 70vw;
    }

    .chapter__body p {
        font-size: 0.9rem;
        line-height: 1.9;
    }

    .flower-deco--right,
    .flower-deco--left {
        width: min(120px, 30vw);
    }

    .flower-deco--center-bottom {
        width: min(200px, 50vw);
    }
}