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

:root {
    --indigo: #1e1b4b;
    --indigo-soft: #2d2a5e;
    --cream: #faf5eb;
    --terracotta: #c2685c;
    --gold: #b8976a;
    --sage: #8e9e8c;
    --marble: #d4cfc5;
    --marble-light: #e8e2d8;
    --white: #ffffff;
    --reveal: 600ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Design compliance notes: Space Grotesk" (Google Fonts), IBM Plex Mono" (Google Fonts), step label at `1.1rem`, Interactive Behavior: use IntersectionObserver` with `threshold: 0.15` and `rootMargin: '0px 0px -60px 0px'` to trigger reveals and activate stylistic alternates. */

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    background: linear-gradient(135deg, #1e1b4b 0%, #2d2a5e 100%);
    color: #1e1b4b;
    font-family: "DM Sans", "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    line-height: 1.72;
    text-rendering: optimizeLegibility;
}

.folio-bar {
    position: fixed;
    z-index: 20;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 2rem;
    min-height: clamp(7rem, 18vh, 11rem);
    padding: clamp(1.25rem, 3vh, 2rem) clamp(2rem, 6vw, 6rem) 1rem;
    background: #faf5eb;
    border-bottom: 1px solid #b8976a;
}

.folio-mark {
    width: min(58vw, 760px);
}

.folio-mark h1 {
    color: #1e1b4b;
    font-family: "Space Grotesk", "Inter", system-ui, sans-serif;
    font-feature-settings: "ss01";
    font-size: clamp(3rem, 7vw, 6rem);
    font-weight: 700;
    letter-spacing: 0.03em;
    line-height: 0.9;
}

.folio-rule {
    display: block;
    width: 100%;
    height: 1px;
    margin-top: clamp(0.75rem, 1.4vw, 1.1rem);
    background: #c2685c;
}

.hangul-subtitle,
.kr-sample,
.closing-signature {
    font-family: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
    word-break: keep-all;
}

.hangul-subtitle {
    color: #8e9e8c;
    font-size: clamp(1rem, 1.5vw, 1.25rem);
    font-weight: 700;
    letter-spacing: 0.12em;
    padding-top: 0.35rem;
}

.lesson-scroll {
    display: grid;
    grid-template-columns: 3fr 2fr;
    margin-top: clamp(7rem, 18vh, 11rem);
    min-height: 100vh;
    background: #faf5eb;
}

.lesson-pane {
    position: relative;
    padding: clamp(3rem, 7vh, 6rem) 2rem clamp(4rem, 8vh, 7rem) clamp(2rem, 6vw, 6rem);
    background: linear-gradient(135deg, #1e1b4b 0%, #2d2a5e 100%);
    color: #faf5eb;
}

.lesson-pane::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image: linear-gradient(90deg, rgba(250, 245, 235, 0.045) 1px, transparent 1px);
    background-size: 48px 100%;
}

.lesson-block {
    position: relative;
    z-index: 1;
    max-width: 780px;
    margin-bottom: clamp(3rem, 6vh, 5rem);
    padding-left: 3.25rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity var(--reveal), transform var(--reveal);
}

.lesson-block.in-view,
.diagram-block.in-view,
.marble-surface.in-view,
.closing-message.in-view {
    opacity: 1;
    transform: translateY(0);
}

.step-badge {
    position: absolute;
    top: 0.3rem;
    left: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 2px solid #c2685c;
    border-radius: 50%;
    color: #c2685c;
    font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 1.1rem;
    line-height: 1;
}

.step-badge.pulse {
    animation: badge-pulse 400ms ease;
}

@keyframes badge-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.eyebrow,
.diagram-title,
.swatch-row em,
.pattern-tile span {
    font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 0.8rem;
    font-weight: 400;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.eyebrow {
    margin-bottom: 0.8rem;
    color: #b8976a;
}

.lesson-block h2 {
    max-width: 12ch;
    margin-bottom: 1.1rem;
    color: #ffffff;
    font-family: "Space Grotesk", "Inter", system-ui, sans-serif;
    font-feature-settings: "ss01";
    font-size: clamp(2rem, 4.6vw, 4.9rem);
    font-weight: 700;
    letter-spacing: -0.035em;
    line-height: 0.98;
}

.lesson-block p:not(.eyebrow) {
    max-width: 62ch;
    color: #faf5eb;
}

.decorative-rule {
    position: relative;
    z-index: 1;
    width: 0;
    max-width: min(100%, 780px);
    margin: 0 0 clamp(3rem, 6vh, 5rem) 3.25rem;
    border-bottom: 1px solid #b8976a;
    opacity: 0;
}

.decorative-rule.in-view {
    animation: rule-grow 800ms ease-out forwards;
}

.dotted-rule {
    border-bottom-style: dotted;
}

@keyframes rule-grow {
    from { width: 0; opacity: 0; }
    to { width: calc(100% - 3.25rem); opacity: 1; }
}

.diagram-rail {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    padding: calc(clamp(7rem, 18vh, 11rem) + 2rem) clamp(1.5rem, 4vw, 4rem) 4rem;
    background: #faf5eb;
    border-left: 1px solid #d4cfc5;
    transform: translateY(calc(var(--scroll) * -0.15px));
}

.diagram-block {
    margin-bottom: clamp(2rem, 5vh, 4rem);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity var(--reveal), transform var(--reveal);
}

.diagram-title {
    margin-bottom: 1rem;
    color: #b8976a;
}

.swatch-row {
    display: grid;
    grid-template-columns: 3.5rem 1fr auto;
    align-items: center;
    gap: 0.8rem;
    min-height: 3.5rem;
    margin-bottom: 0.65rem;
    padding: 0.45rem;
    border: 1px solid #d4cfc5;
    background: #ffffff;
    transition: box-shadow 300ms ease, transform 300ms ease;
}

.swatch-row:hover,
.type-sample:hover {
    box-shadow: 0 4px 20px rgba(30, 27, 75, 0.15);
    transform: translateY(-1px);
}

.swatch-row span {
    width: 100%;
    aspect-ratio: 1;
    border: 1px solid #d4cfc5;
}

.swatch-row b {
    font-size: 0.95rem;
    font-weight: 500;
}

.swatch-row em {
    color: #8e9e8c;
    font-style: normal;
}

.type-sample {
    margin-bottom: 0.75rem;
    padding: 1rem;
    border: 1px solid #d4cfc5;
    background: #ffffff;
    transition: box-shadow 300ms ease, transform 300ms ease;
}

.display-sample {
    font-family: "Space Grotesk", "Inter", system-ui, sans-serif;
    font-feature-settings: "ss01";
    font-size: 1.55rem;
    font-weight: 700;
}

.body-sample {
    font-family: "DM Sans", "Inter", system-ui, sans-serif;
}

.mono-sample {
    font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 0.85rem;
}

.scissors-icon {
    display: block;
    width: min(100%, 230px);
    margin: 1rem 0;
}

.scissors-icon path {
    fill: none;
    stroke: #1e1b4b;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.5;
}

.scissors-icon .thread {
    stroke: #c2685c;
    stroke-dasharray: 5 5;
}

.mini-patterns {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.7rem;
}

.mini-patterns .diagram-title {
    grid-column: 1 / -1;
}

.mini-tile {
    display: block;
    aspect-ratio: 1;
    border: 1px solid #1e1b4b;
    border-radius: 4px;
}

.pattern-gallery {
    padding: clamp(4rem, 9vh, 8rem) clamp(2rem, 6vw, 6rem);
    background: #8e9e8c;
    color: #1e1b4b;
}

.gallery-intro {
    max-width: 900px;
    margin-bottom: clamp(2rem, 5vh, 4rem);
}

.gallery-intro h2 {
    font-family: "Space Grotesk", "Inter", system-ui, sans-serif;
    font-feature-settings: "ss01";
    font-size: clamp(2.5rem, 6vw, 5.5rem);
    font-weight: 700;
    letter-spacing: -0.035em;
    line-height: 0.95;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(160px, 1fr));
    gap: clamp(1rem, 2.5vw, 2rem);
    max-width: 980px;
}

.pattern-tile {
    position: relative;
    aspect-ratio: 1;
    min-height: 200px;
    overflow: hidden;
    border: 2px solid #1e1b4b;
    border-radius: 4px;
    opacity: 0;
    transform: translateY(20px);
    transition: transform 300ms ease, box-shadow 300ms ease;
}

.pattern-tile.in-view {
    animation: tile-reveal 600ms cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.pattern-tile:nth-child(1).in-view { animation-delay: 0ms; }
.pattern-tile:nth-child(2).in-view { animation-delay: 100ms; }
.pattern-tile:nth-child(3).in-view { animation-delay: 200ms; }
.pattern-tile:nth-child(4).in-view { animation-delay: 300ms; }
.pattern-tile:nth-child(5).in-view { animation-delay: 400ms; }
.pattern-tile:nth-child(6).in-view { animation-delay: 500ms; }

@keyframes tile-reveal {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.pattern-tile:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 20px rgba(30, 27, 75, 0.15);
}

.pattern-tile span {
    position: absolute;
    left: 0.75rem;
    right: 0.75rem;
    bottom: 0.75rem;
    padding: 0.55rem 0.65rem;
    background: rgba(250, 245, 235, 0.92);
    color: #1e1b4b;
}

.tile-chevron {
    background:
        repeating-linear-gradient(45deg, transparent, transparent 10px, #c2685c 10px, #c2685c 12px),
        repeating-linear-gradient(-45deg, transparent, transparent 10px, #c2685c 10px, #c2685c 12px),
        #faf5eb;
}

.tile-polka {
    background: radial-gradient(circle, #1e1b4b 2.5px, transparent 3px) 0 0 / 20px 20px, #faf5eb;
}

.tile-houndstooth {
    background:
        linear-gradient(45deg, #1e1b4b 25%, transparent 25%) 0 0 / 24px 24px,
        linear-gradient(-45deg, #1e1b4b 25%, transparent 25%) 0 12px / 24px 24px,
        linear-gradient(45deg, transparent 75%, #1e1b4b 75%) 12px -12px / 24px 24px,
        linear-gradient(-45deg, transparent 75%, #1e1b4b 75%) -12px 0 / 24px 24px,
        #faf5eb;
}

.tile-gingham {
    background:
        repeating-linear-gradient(0deg, rgba(142, 158, 140, 0.36) 0 12px, transparent 12px 24px),
        repeating-linear-gradient(90deg, rgba(142, 158, 140, 0.36) 0 12px, transparent 12px 24px),
        #faf5eb;
}

.tile-argyle {
    background:
        repeating-linear-gradient(45deg, transparent 0 23px, rgba(30, 27, 75, 0.75) 23px 24px, transparent 24px 48px),
        repeating-linear-gradient(-45deg, transparent 0 23px, rgba(30, 27, 75, 0.75) 23px 24px, transparent 24px 48px),
        linear-gradient(45deg, transparent 38%, rgba(184, 151, 106, 0.55) 38% 62%, transparent 62%) 0 0 / 48px 48px,
        linear-gradient(-45deg, transparent 38%, rgba(194, 104, 92, 0.28) 38% 62%, transparent 62%) 24px 0 / 48px 48px,
        #faf5eb;
}

.tile-herringbone {
    background:
        repeating-linear-gradient(45deg, #1e1b4b 0 4px, transparent 4px 16px),
        repeating-linear-gradient(-45deg, #1e1b4b 0 4px, transparent 4px 16px),
        #faf5eb;
    background-size: 28px 56px;
    background-position: 0 0, 14px 0;
}

.marble-close {
    display: grid;
    grid-template-columns: 2fr 3fr;
    gap: clamp(2rem, 5vw, 6rem);
    align-items: center;
    min-height: 70vh;
    padding: clamp(4rem, 9vh, 8rem) clamp(2rem, 6vw, 6rem);
    background: #faf5eb;
}

.marble-surface {
    aspect-ratio: 1;
    border: 2px solid #b8976a;
    border-radius: 4px;
    background:
        radial-gradient(ellipse 400px 50px at 25% 30%, rgba(184, 151, 106, 0.3), transparent),
        radial-gradient(ellipse 300px 30px at 70% 60%, rgba(184, 151, 106, 0.2), transparent),
        radial-gradient(ellipse 500px 40px at 45% 80%, rgba(250, 245, 235, 0.5), transparent),
        radial-gradient(ellipse 200px 60px at 80% 20%, rgba(142, 158, 140, 0.15), transparent),
        radial-gradient(ellipse 360px 28px at 35% 8%, rgba(255, 255, 255, 0.45), transparent),
        linear-gradient(180deg, #e8e2d8 0%, #d4cfc5 100%);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity var(--reveal), transform var(--reveal);
}

.closing-message {
    max-width: 760px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity var(--reveal), transform var(--reveal);
}

.closing-message h2 {
    margin-bottom: 1.2rem;
    color: #1e1b4b;
    font-family: "Space Grotesk", "Inter", system-ui, sans-serif;
    font-feature-settings: "ss01";
    font-size: clamp(2.25rem, 5vw, 4.6rem);
    font-weight: 700;
    letter-spacing: -0.035em;
    line-height: 0.98;
}

.closing-message p:not(.eyebrow) {
    margin-bottom: 1.25rem;
}

.closing-signature {
    color: #8e9e8c;
    font-weight: 700;
}

@media (max-width: 900px) {
    .folio-bar {
        min-height: auto;
    }

    .lesson-scroll,
    .marble-close {
        grid-template-columns: 1fr;
    }

    .diagram-rail {
        position: relative;
        top: auto;
        height: auto;
        transform: none;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1.5rem;
        padding: clamp(2rem, 6vw, 4rem);
        border-left: 0;
        border-top: 1px solid #d4cfc5;
    }

    .diagram-block {
        margin-bottom: 0;
    }

    .gallery-grid {
        grid-template-columns: repeat(2, minmax(150px, 1fr));
    }
}

@media (max-width: 620px) {
    .folio-bar {
        align-items: flex-start;
        padding: 1rem 1.25rem;
    }

    .folio-mark {
        width: 72vw;
    }

    .lesson-scroll {
        margin-top: 6rem;
    }

    .lesson-pane {
        padding-left: 1.25rem;
        padding-right: 1.25rem;
    }

    .lesson-block {
        padding-left: 0;
        padding-top: 3.2rem;
    }

    .decorative-rule {
        margin-left: 0;
    }

    .diagram-rail,
    .gallery-grid {
        grid-template-columns: 1fr;
    }

    .pattern-tile {
        min-height: 180px;
    }
}
