/* ============================================================
   yamato.quest — Emaki Horizontal Scroll Stylesheet
   Palette: Sumi Ink #1A1614, Ink Wash #3D3530, Mist Gray #8A8178,
            Rice Paper #F5F0E6, Gold Leaf #C5A34E, Vermillion #D4453B,
            Indigo Night #1B2838, Dawn Pink #E8C4B8, Pine Green #3A5A3A,
            Cloud White #EDE8DE
   ============================================================ */

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #1A1614;
    color: #3D3530;
    font-family: "Shippori Mincho", "Noto Serif JP", Georgia, serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ----------------------------------------------------------
   The Scroll Container — 500vw horizontal canvas
   ---------------------------------------------------------- */

.emaki-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow-x: scroll;
    overflow-y: hidden;
    scroll-behavior: auto;
    background: #F5F0E6;
}

.emaki-container::-webkit-scrollbar {
    height: 0;
    display: none;
}

.emaki-container {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* ----------------------------------------------------------
   Sky Layer — Top 25%, gradient progression across 500vw
   ---------------------------------------------------------- */

.sky-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 500vw;
    height: 25vh;
    background: linear-gradient(
        to right,
        #E8C4B8 0%,
        #C5A34E 25%,
        #F5F0E6 50%,
        #1B2838 75%,
        #1A1614 100%
    );
    z-index: 1;
}

/* ----------------------------------------------------------
   Cloud Layer — Drifting suyari-gasumi gold clouds
   ---------------------------------------------------------- */

.cloud-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 500vw;
    height: 35vh;
    z-index: 2;
    pointer-events: none;
}

.cloud {
    position: absolute;
    width: 22vw;
    height: 4vw;
    min-height: 40px;
    animation: cloud-drift 30s linear infinite;
}

.cloud-slow {
    animation-duration: 48s;
    animation-direction: reverse;
}

@keyframes cloud-drift {
    0%   { transform: translateX(0) translateY(0); }
    50%  { transform: translateX(40px) translateY(-4px); }
    100% { transform: translateX(0) translateY(0); }
}

/* ----------------------------------------------------------
   Ground Layer — bottom 25%, single SVG mountain across 500vw
   ---------------------------------------------------------- */

.ground-layer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 500vw;
    height: 25vh;
    z-index: 2;
    pointer-events: none;
}

.mountain-svg {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.mountain-far {
    fill: #1A1614;
    fill-opacity: 0.30;
}

.mountain-mid {
    fill: #1A1614;
    fill-opacity: 0.60;
}

.mountain-near {
    fill: #1A1614;
    fill-opacity: 1.0;
}

/* ----------------------------------------------------------
   Episodes — five 100vw blocks, total 500vw
   ---------------------------------------------------------- */

.episode {
    position: relative;
    display: inline-block;
    width: 100vw;
    height: 100vh;
    vertical-align: top;
    z-index: 3;
}

/* The five episodes have unique tinted background washes layered
   over the sky/ground; very subtle, only in the middle band. */
.episode::before {
    content: "";
    position: absolute;
    top: 25vh;
    left: 0;
    width: 100%;
    height: 50vh;
    pointer-events: none;
    z-index: 0;
}

.episode-1::before {
    background: linear-gradient(180deg, rgba(245, 240, 230, 0.0) 0%, rgba(232, 196, 184, 0.18) 100%);
}
.episode-2::before {
    background: linear-gradient(180deg, rgba(245, 240, 230, 0.0) 0%, rgba(138, 129, 120, 0.16) 100%);
}
.episode-3::before {
    background: linear-gradient(180deg, rgba(237, 232, 222, 0.0) 0%, rgba(58, 90, 58, 0.16) 100%);
}
.episode-4::before {
    background: linear-gradient(180deg, rgba(237, 232, 222, 0.0) 0%, rgba(212, 69, 59, 0.16) 100%);
}
.episode-5::before {
    background: linear-gradient(180deg, rgba(27, 40, 56, 0.0) 0%, rgba(27, 40, 56, 0.30) 100%);
}

/* ----------------------------------------------------------
   Scroll seams between episodes — Gold Leaf 30% opacity
   ---------------------------------------------------------- */

.seam {
    position: absolute;
    top: 0;
    right: 0;
    width: 2px;
    height: 100%;
    background: #C5A34E;
    opacity: 0.30;
    z-index: 4;
    pointer-events: none;
}

.episode-1 .seam {
    /* The first episode (rightmost when starting) has no seam on its right edge */
    display: none;
}

/* ----------------------------------------------------------
   Episode Content Layout
   ---------------------------------------------------------- */

.episode-content {
    position: absolute;
    inset: 25vh 0 25vh 0;
    padding: 4vh 8vw;
    display: grid;
    grid-template-columns: 110px 1fr 1.4fr;
    grid-template-rows: 1fr;
    gap: 4vw;
    align-items: start;
    z-index: 3;
}

/* ----------------------------------------------------------
   Seal Mark — Vermillion red circle with kanji number
   ---------------------------------------------------------- */

.seal-mark {
    width: 80px;
    height: 80px;
    background: #D4453B;
    border-radius: 50%;
    transform: rotate(-2deg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #F5F0E6;
    font-family: "Noto Sans JP", "Noto Serif JP", sans-serif;
    font-weight: 900;
    font-size: 32px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05);
    margin-top: 8px;
    flex-shrink: 0;
    align-self: start;
    border: 2px solid rgba(245, 240, 230, 0.4);
}

.seal-mark span {
    transform: rotate(2deg);
    display: inline-block;
    line-height: 1;
}

/* ----------------------------------------------------------
   Title Blocks
   ---------------------------------------------------------- */

.title-block {
    position: relative;
    padding-right: 2vw;
}

.title-block.vertical-title {
    padding-top: 2vh;
}

.emaki-title {
    font-family: "Noto Serif JP", "Shippori Mincho", serif;
    font-weight: 700;
    font-size: clamp(56px, 8vw, 110px);
    color: #1A1614;
    writing-mode: vertical-rl;
    line-height: 1.05;
    letter-spacing: 0.05em;
    margin-bottom: 0;
}

.emaki-subtitle {
    font-family: "Zen Maru Gothic", "Shippori Mincho", serif;
    font-weight: 400;
    font-size: 13px;
    color: #8A8178;
    writing-mode: vertical-rl;
    margin-top: 24px;
    letter-spacing: 0.3em;
}

.episode-heading {
    font-family: "Noto Serif JP", "Shippori Mincho", serif;
    font-weight: 700;
    font-size: clamp(28px, 3.4vw, 52px);
    color: #1A1614;
    line-height: 1.15;
    letter-spacing: -0.01em;
    margin-bottom: 14px;
}

.annotation {
    font-family: "Zen Maru Gothic", "Shippori Mincho", serif;
    font-weight: 400;
    font-size: 12px;
    color: #8A8178;
    letter-spacing: 0.35em;
    text-transform: none;
    margin-bottom: 28px;
}

/* ----------------------------------------------------------
   Prose Block — narrative columns
   ---------------------------------------------------------- */

.prose-block {
    max-width: 540px;
    padding-top: 2vh;
}

.narrative {
    font-family: "Shippori Mincho", "Noto Serif JP", Georgia, serif;
    font-weight: 400;
    font-size: 18px;
    line-height: 1.9;
    color: #3D3530;
    margin-bottom: 22px;
    text-indent: 1.2em;
}

.signature {
    font-family: "Zen Maru Gothic", "Shippori Mincho", sans-serif;
    font-size: 12px;
    color: #8A8178;
    margin-top: 24px;
    letter-spacing: 0.18em;
    font-style: italic;
}

.closing-mark {
    font-family: "Noto Serif JP", serif;
    font-size: 14px;
    color: #C5A34E;
    margin-top: 30px;
    letter-spacing: 0.3em;
}

/* Episode 5 prose color shift to read on darker tone */
.episode-5 .narrative,
.episode-5 .episode-heading {
    color: #EDE8DE;
}
.episode-5 .annotation,
.episode-5 .signature {
    color: #C5A34E;
    opacity: 0.75;
}

/* ----------------------------------------------------------
   Particle Fields — falling seasonal elements
   ---------------------------------------------------------- */

.particle-field {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 2;
}

.particle {
    position: absolute;
    top: -20px;
    will-change: transform, opacity;
}

/* Petal — Episode 1 (Spring) */
.particle-petal {
    width: 10px;
    height: 10px;
    background: #E8C4B8;
    border-radius: 60% 40% 60% 40%;
    opacity: 0.85;
    animation: fall-petal linear infinite;
}

@keyframes fall-petal {
    0%   { transform: translate3d(0, 0, 0) rotate(0deg); opacity: 0; }
    8%   { opacity: 0.85; }
    90%  { opacity: 0.85; }
    100% { transform: translate3d(40px, 110vh, 0) rotate(720deg); opacity: 0; }
}

/* Ash — Episode 2 (Summer volcanic) */
.particle-ash {
    width: 4px;
    height: 4px;
    background: #8A8178;
    border-radius: 50%;
    opacity: 0.5;
    animation: fall-ash linear infinite;
}

@keyframes fall-ash {
    0%   { transform: translate3d(0, 0, 0); opacity: 0; }
    10%  { opacity: 0.55; }
    90%  { opacity: 0.45; }
    100% { transform: translate3d(-30px, 110vh, 0); opacity: 0; }
}

/* Rain — Episode 3 (Autumn) */
.particle-rain {
    width: 1.5px;
    height: 28px;
    background: linear-gradient(180deg, rgba(61, 53, 48, 0) 0%, rgba(61, 53, 48, 0.55) 100%);
    opacity: 0.7;
    animation: fall-rain linear infinite;
}

@keyframes fall-rain {
    0%   { transform: translate3d(0, 0, 0); opacity: 0; }
    10%  { opacity: 0.7; }
    100% { transform: translate3d(-12px, 110vh, 0); opacity: 0.6; }
}

/* Maple Leaves — Episode 4 (Late autumn) */
.particle-leaf {
    width: 12px;
    height: 12px;
    background: #D4453B;
    clip-path: polygon(50% 0%, 65% 30%, 100% 35%, 75% 55%, 85% 100%, 50% 75%, 15% 100%, 25% 55%, 0% 35%, 35% 30%);
    opacity: 0.85;
    animation: fall-leaf linear infinite;
}

@keyframes fall-leaf {
    0%   { transform: translate3d(0, 0, 0) rotate(0deg); opacity: 0; }
    10%  { opacity: 0.85; }
    50%  { transform: translate3d(30px, 55vh, 0) rotate(360deg); }
    100% { transform: translate3d(-20px, 110vh, 0) rotate(720deg); opacity: 0; }
}

/* Snow — Episode 5 (Winter) */
.particle-snow {
    background: #EDE8DE;
    border-radius: 50%;
    opacity: 0.9;
    box-shadow: 0 0 4px rgba(237, 232, 222, 0.3);
    animation: fall-snow linear infinite;
}

@keyframes fall-snow {
    0%   { transform: translate3d(0, 0, 0); opacity: 0; }
    10%  { opacity: 0.9; }
    50%  { transform: translate3d(20px, 55vh, 0); }
    100% { transform: translate3d(-15px, 110vh, 0); opacity: 0.4; }
}

/* ----------------------------------------------------------
   Position Indicator — subtle progress display
   ---------------------------------------------------------- */

.position-indicator {
    position: fixed;
    bottom: 26px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
    opacity: 0.85;
}

.indicator-track {
    width: 180px;
    height: 1px;
    background: rgba(26, 22, 20, 0.25);
    position: relative;
    overflow: hidden;
}

/* On dark episodes, lighten the track */
body.dark-mode .indicator-track {
    background: rgba(237, 232, 222, 0.25);
}

.indicator-fill {
    position: absolute;
    top: 0;
    right: 0;
    height: 1px;
    background: #C5A34E;
    width: 0%;
    transition: width 0.18s linear;
}

.indicator-label {
    font-family: "Noto Serif JP", serif;
    font-size: 11px;
    color: #1A1614;
    letter-spacing: 0.3em;
    transition: color 0.4s ease;
}

body.dark-mode .indicator-label {
    color: #C5A34E;
}

/* ----------------------------------------------------------
   Scroll Hint — initial fading prompt
   ---------------------------------------------------------- */

.scroll-hint {
    position: fixed;
    bottom: 70px;
    right: 60px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #1A1614;
    font-family: "Zen Maru Gothic", "Shippori Mincho", sans-serif;
    font-size: 12px;
    letter-spacing: 0.3em;
    opacity: 0.7;
    transition: opacity 0.6s ease;
    pointer-events: none;
    animation: hint-pulse 3s ease-in-out infinite;
}

.scroll-hint.fade-out {
    opacity: 0;
}

.hint-arrow {
    font-size: 18px;
    color: #C5A34E;
    display: inline-block;
    animation: arrow-nudge 1.6s ease-in-out infinite;
}

@keyframes hint-pulse {
    0%, 100% { opacity: 0.7; }
    50%      { opacity: 0.45; }
}

@keyframes arrow-nudge {
    0%, 100% { transform: translateX(0); }
    50%      { transform: translateX(-6px); }
}

/* ----------------------------------------------------------
   Reveal animations — for content blocks as they enter view
   ---------------------------------------------------------- */

.episode-content > * {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.9s ease, transform 0.9s ease;
}

.episode.in-view .episode-content > .seal-mark {
    transition-delay: 0.05s;
}
.episode.in-view .episode-content > .title-block {
    transition-delay: 0.20s;
}
.episode.in-view .episode-content > .prose-block {
    transition-delay: 0.45s;
}

.episode.in-view .episode-content > * {
    opacity: 1;
    transform: translateY(0);
}

/* ----------------------------------------------------------
   SVG path-draw animation for mountains (subtle, on load)
   ---------------------------------------------------------- */

.mountain-far,
.mountain-mid,
.mountain-near {
    transition: fill-opacity 1.4s ease;
}

/* ----------------------------------------------------------
   Responsive: smaller viewports keep horizontal motion
   but reduce typographic scale.
   ---------------------------------------------------------- */

@media (max-width: 900px) {
    .episode-content {
        grid-template-columns: 60px 1fr;
        grid-template-rows: auto 1fr;
        padding: 3vh 6vw;
        gap: 3vw;
    }
    .seal-mark {
        width: 56px;
        height: 56px;
        font-size: 22px;
    }
    .title-block {
        grid-column: 2 / 3;
    }
    .prose-block {
        grid-column: 1 / 3;
        max-width: 92vw;
        padding-top: 1vh;
    }
    .narrative {
        font-size: 16px;
        line-height: 1.85;
    }
    .emaki-title {
        font-size: clamp(48px, 14vw, 80px);
    }
}

@media (max-width: 560px) {
    .scroll-hint {
        right: 18px;
        bottom: 50px;
    }
    .position-indicator {
        bottom: 16px;
    }
    .indicator-track {
        width: 130px;
    }
}
