/* ================================================================
   saram.quest — Cottagecore Pastoral Storybook Scroll
   Palette: Meadow #f5f0e1, Earth #4a3728, Wildflower #c97b63,
            Sky #7baacc, Leaf #6b8f5e, Sunlight #e8c96a
   Fonts: Gaegu (display), Noto Sans KR (body), Caveat (accent)
================================================================ */

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: #f5f0e1;
    color: #4a3728;
    font-family: 'Noto Sans KR', 'Apple SD Gothic Neo', sans-serif;
    font-weight: 400;
    font-size: 1rem;
    line-height: 1.75;
    overflow-x: hidden;
    min-height: 100vh;
}

/* ── Font Utility Classes ─────────────────────────────────── */
.gaegu {
    font-family: 'Gaegu', cursive;
}

.caveat {
    font-family: 'Caveat', cursive;
}

.noto {
    font-family: 'Noto Sans KR', sans-serif;
}

/* ── Quest Path SVG ───────────────────────────────────────── */
.quest-path-container {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    height: 100vh;
    pointer-events: none;
    z-index: 10;
    overflow: visible;
}

.quest-path-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    /* height is set dynamically by JS */
    overflow: visible;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.quest-path-svg.path-ready {
    opacity: 0.35;
}

#questPath {
    stroke-dasharray: 0;
    stroke-dashoffset: 0;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.waypoint-star {
    transition: opacity 0.4s ease;
}

/* ── Hero Section ─────────────────────────────────────────── */
.hero-section {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    overflow: hidden;
}

.hero-landscape {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.landscape-sky {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, #b8d8ee 0%, #d6eaf8 45%, #e8f4f8 70%, #f5efe0 100%);
}

.landscape-sun {
    position: absolute;
    top: 12%;
    left: 55%;
    width: 80px;
    height: 80px;
    background: #e8c96a;
    border-radius: 50%;
    box-shadow: 0 0 40px rgba(232, 201, 106, 0.5), 0 0 80px rgba(232, 201, 106, 0.25);
}

.landscape-far-hills {
    position: absolute;
    bottom: 35%;
    left: 0;
    right: 0;
    height: 30%;
    background: #7baacc;
    opacity: 0.3;
    clip-path: polygon(0% 100%, 0% 55%, 5% 48%, 12% 40%, 20% 32%, 28% 38%, 36% 28%, 44% 20%, 52% 30%, 60% 22%, 68% 32%, 76% 25%, 84% 35%, 92% 28%, 100% 38%, 100% 100%);
}

.landscape-mid-hills {
    position: absolute;
    bottom: 20%;
    left: 0;
    right: 0;
    height: 35%;
    background: #6b8f5e;
    opacity: 0.55;
    clip-path: polygon(0% 100%, 0% 62%, 8% 50%, 16% 42%, 24% 55%, 32% 38%, 40% 48%, 48% 32%, 56% 45%, 64% 35%, 72% 50%, 80% 40%, 88% 52%, 96% 42%, 100% 50%, 100% 100%);
}

.landscape-near-hills {
    position: absolute;
    bottom: 8%;
    left: 0;
    right: 0;
    height: 30%;
    background: #4a3728;
    opacity: 0.45;
    clip-path: polygon(0% 100%, 0% 70%, 10% 55%, 20% 65%, 30% 50%, 40% 62%, 50% 48%, 60% 60%, 70% 52%, 80% 64%, 90% 55%, 100% 65%, 100% 100%);
}

.landscape-ground {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 10%;
    background: #4a3728;
    opacity: 0.35;
}

.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 40px 24px 100px;
    max-width: 700px;
    margin: 0 auto;
}

.hero-chapter-label {
    font-family: 'Caveat', cursive;
    font-size: 1rem;
    color: #6b8f5e;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.hero-title {
    font-family: 'Gaegu', cursive;
    font-weight: 700;
    font-size: clamp(3rem, 8vw, 5.5rem);
    color: #4a3728;
    line-height: 1.1;
    margin-bottom: 10px;
    text-shadow: 2px 2px 0 rgba(245, 240, 225, 0.6);
}

.hero-subtitle {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: clamp(1.1rem, 3vw, 1.6rem);
    color: #c97b63;
    margin-bottom: 14px;
    letter-spacing: 0.03em;
}

.hero-domain {
    font-family: 'Caveat', cursive;
    font-size: 1rem;
    color: #6b8f5e;
    letter-spacing: 0.18em;
    margin-bottom: 40px;
}

.hero-scroll-hint {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    animation: bounce-hint 2s ease-in-out infinite;
}

.scroll-hint-text {
    font-family: 'Caveat', cursive;
    font-size: 0.9rem;
    color: #c97b63;
    opacity: 0.75;
    letter-spacing: 0.06em;
}

.scroll-arrow {
    font-size: 1.2rem;
    color: #e8c96a;
}

@keyframes bounce-hint {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(6px); }
}

.section-border-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 60px;
    z-index: 2;
}

/* ── Quest Scroll (Main) ──────────────────────────────────── */
.quest-scroll {
    position: relative;
    background: #f5f0e1;
    z-index: 1;
}

/* ── Chapter Structure ────────────────────────────────────── */
.chapter {
    position: relative;
    margin-bottom: 0;
}

.chapter-header {
    position: relative;
    height: 220px;
    overflow: hidden;
    margin-bottom: 0;
}

.chapter-landscape {
    position: absolute;
    inset: 0;
}

.ch-sky {
    position: absolute;
    inset: 0;
}

.ch-sky-dawn {
    background: linear-gradient(to bottom, #fce4c8 0%, #f5d5b0 50%, #eddcb0 100%);
}

.ch-sky-morning {
    background: linear-gradient(to bottom, #b8d8ee 0%, #d4eaf5 50%, #e8f4f0 100%);
}

.ch-sky-noon {
    background: linear-gradient(to bottom, #87bcdc 0%, #a8d4ea 50%, #c8e8f0 100%);
}

.ch-sky-storm {
    background: linear-gradient(to bottom, #6a7c88 0%, #8a9ca8 50%, #aabbcc 100%);
}

.ch-sky-evening {
    background: linear-gradient(to bottom, #e8a878 0%, #f0c490 50%, #f5dca0 100%);
}

.ch-sky-dusk {
    background: linear-gradient(to bottom, #c06848 0%, #d8886a 40%, #e8aaa0 70%, #f0c8b0 100%);
}

.ch-sun {
    position: absolute;
    border-radius: 50%;
    background: #e8c96a;
}

.ch-sun-small {
    width: 40px;
    height: 40px;
    top: 15%;
    left: 60%;
    box-shadow: 0 0 20px rgba(232, 201, 106, 0.6);
}

.ch-sun-rising {
    width: 50px;
    height: 50px;
    top: 10%;
    left: 65%;
    box-shadow: 0 0 30px rgba(232, 201, 106, 0.55);
}

.ch-sun-high {
    width: 55px;
    height: 55px;
    top: 8%;
    left: 68%;
    box-shadow: 0 0 35px rgba(232, 201, 106, 0.5);
}

.ch-sun-setting {
    width: 60px;
    height: 60px;
    bottom: 25%;
    left: 62%;
    box-shadow: 0 0 40px rgba(201, 123, 99, 0.5);
    background: #c97b63;
}

.ch-sun-dusk {
    width: 55px;
    height: 55px;
    bottom: 20%;
    left: 55%;
    box-shadow: 0 0 45px rgba(201, 123, 99, 0.6);
    background: linear-gradient(to bottom, #e8a878, #c97b63);
    transform: scaleY(0.6);
}

.ch-hills {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--hue);
    opacity: var(--opacity);
}

.ch-hills-far {
    height: 60%;
    clip-path: polygon(0% 100%, 0% 55%, 6% 44%, 14% 34%, 22% 44%, 30% 32%, 38% 22%, 46% 34%, 54% 26%, 62% 36%, 70% 28%, 78% 38%, 86% 30%, 94% 40%, 100% 32%, 100% 100%);
}

.ch-hills-mid {
    height: 50%;
    clip-path: polygon(0% 100%, 0% 60%, 8% 48%, 16% 58%, 24% 42%, 32% 54%, 40% 38%, 48% 50%, 56% 40%, 64% 52%, 72% 44%, 80% 56%, 88% 46%, 96% 54%, 100% 46%, 100% 100%);
}

.ch-hills-near {
    height: 35%;
    clip-path: polygon(0% 100%, 0% 65%, 12% 52%, 24% 64%, 36% 50%, 48% 62%, 60% 50%, 72% 60%, 84% 52%, 96% 62%, 100% 56%, 100% 100%);
}

.chapter-header-content {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2;
    padding: 16px;
}

.chapter-number {
    font-size: 1rem;
    color: rgba(245, 240, 225, 0.85);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    margin-bottom: 6px;
    text-shadow: 1px 1px 3px rgba(74, 55, 40, 0.4);
}

.chapter-title {
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 3.5rem);
    color: #f5f0e1;
    text-shadow: 2px 3px 6px rgba(74, 55, 40, 0.45);
    line-height: 1.1;
    margin-bottom: 4px;
}

.chapter-title-en {
    font-size: 1.25rem;
    color: rgba(245, 240, 225, 0.9);
    text-shadow: 1px 1px 3px rgba(74, 55, 40, 0.4);
}

.chapter-border-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 40px;
    z-index: 3;
}

/* ── Chapter Cards ────────────────────────────────────────── */
.chapter-cards {
    max-width: 800px;
    margin: 0 auto;
    padding: 48px 20px 64px;
    position: relative;
    z-index: 2;
}

.quest-card {
    max-width: 65%;
    margin-bottom: 52px;
    position: relative;
}

.card-left {
    margin-left: 10%;
    transform: rotate(var(--rot, -1.5deg));
}

.card-right {
    margin-left: auto;
    margin-right: 10%;
    transform: rotate(var(--rot, 1deg));
}

.card-inner {
    background: #f5f0e1;
    box-shadow: 3px 3px 10px rgba(74, 55, 40, 0.15), 1px 1px 4px rgba(74, 55, 40, 0.08);
    border-radius: 4px;
    padding: 1.6rem 1.5rem 1.4rem;
    position: relative;
    transition: box-shadow 0.3s ease, transform 0.3s ease;
    border: 1px solid rgba(74, 55, 40, 0.08);
}

.quest-card:hover .card-inner {
    box-shadow: 5px 5px 16px rgba(74, 55, 40, 0.22), 2px 2px 6px rgba(74, 55, 40, 0.1);
    transform: translateY(-2px);
}

/* Pin effect on card corner */
.card-inner::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 10px;
    height: 10px;
    background: #c97b63;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(74, 55, 40, 0.3);
}

.card-stage {
    display: block;
    font-size: 0.85rem;
    color: #6b8f5e;
    letter-spacing: 0.08em;
    margin-bottom: 10px;
}

.card-wavy-border {
    width: 100%;
    height: 8px;
    margin-bottom: 12px;
}

.card-wavy-border svg {
    width: 100%;
    height: 100%;
    display: block;
}

.card-heading {
    font-weight: 700;
    font-size: clamp(1.5rem, 3vw, 2.25rem);
    color: #4a3728;
    line-height: 1.15;
    margin-bottom: 2px;
}

.card-subtitle {
    font-size: 1.125rem;
    color: #c97b63;
    margin-bottom: 14px;
}

.card-text {
    font-size: 0.92rem;
    line-height: 1.8;
    color: #4a3728;
}

/* Star decoration */
.card-star {
    position: absolute;
    bottom: 12px;
    right: 14px;
    width: 16px;
    height: 16px;
    background: #e8c96a;
    opacity: 0.6;
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

.card-star.completed {
    opacity: 1;
    transform: scale(1.3);
}

/* Fade-in animation */
.fade-in-card {
    opacity: 0;
    transform: rotate(var(--rot, 0deg)) translateY(24px);
    transition: opacity 0.7s ease, transform 0.7s ease;
}

.fade-in-card.visible {
    opacity: 1;
    transform: rotate(var(--rot, 0deg)) translateY(0);
}

/* ── Footer ────────────────────────────────────────────────── */
.quest-footer {
    position: relative;
    background: #4a3728;
    padding-top: 0;
    overflow: hidden;
}

.footer-landscape {
    position: relative;
    height: 50px;
    overflow: hidden;
}

.footer-border-top {
    display: block;
    width: 100%;
    height: 100%;
    background: #4a3728;
}

.footer-content {
    text-align: center;
    padding: 48px 24px 64px;
    max-width: 640px;
    margin: 0 auto;
}

.footer-stars {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 20px;
}

.footer-star {
    display: inline-block;
    width: 18px;
    height: 18px;
    background: #e8c96a;
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

.footer-ko {
    font-weight: 700;
    font-size: clamp(1.4rem, 3.5vw, 2rem);
    color: #f5f0e1;
    margin-bottom: 6px;
    line-height: 1.2;
}

.footer-en {
    font-size: 1.2rem;
    color: #c97b63;
    margin-bottom: 20px;
}

.footer-desc {
    font-size: 0.88rem;
    color: rgba(245, 240, 225, 0.55);
    line-height: 1.7;
    margin-bottom: 24px;
}

.footer-domain {
    font-size: 0.95rem;
    color: #6b8f5e;
    letter-spacing: 0.2em;
}

/* ── Reduced Motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .fade-in-card {
        opacity: 1;
        transform: rotate(var(--rot, 0deg)) translateY(0);
        transition: none;
    }

    .hero-scroll-hint {
        animation: none;
    }

    #questPath {
        stroke-dasharray: none;
        stroke-dashoffset: 0;
    }

    .quest-path-svg {
        opacity: 0.35;
    }
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
    .quest-path-container {
        display: none;
    }

    .quest-card {
        max-width: 90%;
    }

    .card-left {
        margin-left: auto;
        margin-right: auto;
        transform: rotate(-0.8deg);
    }

    .card-right {
        margin-left: auto;
        margin-right: auto;
        transform: rotate(0.8deg);
    }

    .chapter-header {
        height: 180px;
    }

    .chapter-cards {
        padding: 32px 16px 48px;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: 2.5rem;
    }

    .card-inner {
        padding: 1.2rem 1rem;
    }

    .chapter-header {
        height: 150px;
    }
}
