/* martiallaw.quest — flat folk-art monochrome picture-book */

:root {
    --paper: #F4EFE3;
    --charcoal: #1B1A18;
    --brown-grey: #3A3833;
    --ash: #7A766C;
    --bone: #C9C2B0;

    --font-display: "Fraunces", "Lora", Georgia, serif;
    --font-body: "Nunito", "Inter", system-ui, sans-serif;
    --font-mono: "JetBrains Mono", "Space Mono", monospace;
    --font-korean: "Gowun Batang", "Nunito", serif;

    --frame-radius: 28px;
    --frame-stroke: 1.5px;
}

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

html, body {
    background-color: var(--paper);
    color: var(--charcoal);
    font-family: var(--font-body);
    font-weight: 500;
    line-height: 1.72;
    overflow: hidden;
    height: 100%;
    width: 100%;
}

body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100vh;
    padding: 32px 24px;
    position: relative;
}

/* ====== Chapter dots above frame ====== */
.dots {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: var(--ash);
    border: none;
    padding: 0;
    cursor: pointer;
    transition: background-color 700ms ease, transform 300ms cubic-bezier(.22,.61,.36,1);
}

.dot.active {
    background-color: var(--charcoal);
    transform: scale(1.25);
}

.dot.visited {
    background-color: var(--brown-grey);
}

/* ====== The stage / theatre frame ====== */
.stage {
    position: relative;
    width: 100%;
    max-width: 880px;
    aspect-ratio: 16 / 10;
    min-height: 78vh;
    border: var(--frame-stroke) solid var(--charcoal);
    border-radius: var(--frame-radius);
    overflow: hidden;
    background-color: var(--paper);
    cursor: none;
}

.track {
    position: absolute;
    top: 0;
    left: 0;
    width: 1200vw;
    max-width: 10560px; /* 12 * 880px */
    height: 100%;
    display: flex;
    will-change: transform;
}

.scene {
    position: relative;
    flex: 0 0 auto;
    width: 100vw;
    max-width: 880px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.composition {
    width: 100%;
    height: 100%;
    max-width: 520px;
    max-height: 520px;
}

.bg-shapes {
    transition: opacity 800ms ease;
}

.focal, .focal-ring, .focal-group {
    transition: opacity 800ms ease;
}

/* ====== Loader ====== */
.loader {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--paper);
    transition: opacity 1100ms ease;
}

.loader.hidden {
    opacity: 0;
    pointer-events: none;
}

.loader-svg {
    width: 30%;
    max-width: 180px;
    animation: pebble-breathe 2200ms ease-in-out infinite;
}

@keyframes pebble-breathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(0.94); }
}

/* ====== Cursor pebble ====== */
.cursor-pebble {
    position: absolute;
    width: 12px;
    height: 12px;
    pointer-events: none;
    z-index: 40;
    transform: translate(-50%, -50%);
    transition: width 300ms cubic-bezier(.22,.61,.36,1),
                height 300ms cubic-bezier(.22,.61,.36,1),
                opacity 600ms ease;
    opacity: 0;
}

.cursor-pebble.visible { opacity: 1; }

.cursor-pebble.large {
    width: 18px;
    height: 18px;
}

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

/* ====== Exit pebble ====== */
.exit-pebble {
    position: absolute;
    bottom: 16px;
    right: 18px;
    width: 22px;
    height: 22px;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 800ms ease, transform 400ms ease;
    z-index: 35;
}

.exit-pebble.visible {
    opacity: 1;
    pointer-events: auto;
}

.exit-pebble:hover {
    transform: scale(1.15);
}

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

/* ====== Caption below frame ====== */
.caption {
    margin-top: 22px;
    max-width: 34ch;
    text-align: center;
    transition: opacity 380ms ease;
}

.caption.fading { opacity: 0; }

.chapter-title {
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 500;
    font-size: clamp(2.2rem, 4.6vw, 3.6rem);
    letter-spacing: -0.012em;
    line-height: 1.04;
    color: var(--charcoal);
    font-variation-settings: "opsz" 144, "SOFT" 100, "WONK" 0;
    margin-bottom: 12px;
}

.chapter-body {
    font-family: var(--font-body);
    font-weight: 500;
    font-size: clamp(1.02rem, 1.16vw, 1.18rem);
    line-height: 1.72;
    color: var(--brown-grey);
    margin-bottom: 12px;
}

.chapter-body .ko {
    font-family: var(--font-korean);
    font-style: italic;
    font-weight: 400;
}

.chapter-meta {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 11px;
    color: var(--ash);
    letter-spacing: 0.06em;
}

.chapter-meta .kst,
.chapter-meta .article {
    color: var(--ash);
}

/* ====== Page footer (wordmark + bell) ====== */
.page-footer {
    position: absolute;
    bottom: 16px;
    left: 18px;
    right: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    pointer-events: none;
}

.wordmark {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--brown-grey);
    letter-spacing: 0.04em;
    pointer-events: auto;
}

.bell {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    pointer-events: auto;
    opacity: 0.7;
    transition: opacity 400ms ease, transform 300ms ease;
}

.bell:hover {
    opacity: 1;
    transform: scale(1.1);
}

.bell.on svg path {
    stroke: var(--charcoal);
}

/* ====== Leaf-drift animation (scene 8) ====== */
.leaf-drift path {
    animation: leaf-drift 14s linear infinite;
    transform-origin: center;
}

.leaf-drift path:nth-child(1) { animation-delay: 0s; }
.leaf-drift path:nth-child(2) { animation-delay: -2s; }
.leaf-drift path:nth-child(3) { animation-delay: -4s; }
.leaf-drift path:nth-child(4) { animation-delay: -6s; }
.leaf-drift path:nth-child(5) { animation-delay: -8s; }
.leaf-drift path:nth-child(6) { animation-delay: -10s; }

@keyframes leaf-drift {
    0%   { transform: translate(0, 0) rotate(0deg); opacity: 0.55; }
    50%  { transform: translate(8px, 14px) rotate(8deg); opacity: 0.45; }
    100% { transform: translate(0, 0) rotate(0deg); opacity: 0.55; }
}

/* Loader pebble breathe */
#loader-pebble {
    transform-origin: center;
}

/* ====== Mobile: stack vertically ====== */
@media (max-width: 720px) {
    html, body {
        overflow: auto;
        height: auto;
    }

    body {
        display: block;
    }

    .page {
        height: auto;
        min-height: 100vh;
        padding: 20px 14px 70px;
    }

    .stage {
        width: 100%;
        max-width: 100%;
        aspect-ratio: auto;
        min-height: auto;
        border: none;
        border-radius: 0;
        overflow: visible;
        background-color: transparent;
        cursor: auto;
    }

    .track {
        position: relative;
        width: 100%;
        max-width: 100%;
        flex-direction: column;
        height: auto;
    }

    .scene {
        width: 100%;
        max-width: 100%;
        height: auto;
        aspect-ratio: 16 / 11;
        border: var(--frame-stroke) solid var(--charcoal);
        border-radius: var(--frame-radius);
        margin-bottom: 24px;
        background-color: var(--paper);
    }

    .composition {
        max-width: 380px;
        max-height: 380px;
    }

    .dots,
    .caption,
    .page-footer {
        display: none;
    }

    .cursor-pebble,
    .exit-pebble {
        display: none;
    }

    .loader {
        display: none;
    }

    .scene::after {
        content: attr(data-mobile-caption);
        display: block;
        position: absolute;
        bottom: 10px;
        left: 0;
        right: 0;
        text-align: center;
        font-family: var(--font-body);
        font-size: 0.95rem;
        color: var(--brown-grey);
        padding: 0 16px;
    }
}
