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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background-color: #f5ede0;
    color: #3b322a;
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    line-height: 1.75;
    overflow-x: hidden;
    position: relative;
}

/* Grain overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    filter: url(#grain);
    opacity: 0.04;
    pointer-events: none;
    z-index: 1000;
}

.grain-filter {
    position: absolute;
    width: 0;
    height: 0;
}

/* === FLOATING KOREAN CHARACTERS === */
.floating-chars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.float-char {
    position: absolute;
    font-family: 'Roboto Slab', serif;
    font-weight: 300;
    font-size: clamp(4rem, 12vw, 10rem);
    opacity: 0.06;
    color: #3b322a;
    will-change: transform;
    animation: float-drift 30s linear infinite;
}

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

.float-char:nth-child(2n) {
    animation-duration: 25s;
    animation-direction: reverse;
}

.float-char:nth-child(3n) {
    animation-duration: 35s;
}

/* === PROGRESS INDICATOR === */
.progress-track {
    position: fixed;
    top: 0;
    right: 2vw;
    width: 2px;
    height: 100vh;
    background: rgba(196, 181, 160, 0.3);
    z-index: 500;
}

.progress-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: #8b6914;
    transition: height 100ms linear;
}

.progress-diamond {
    position: absolute;
    left: 50%;
    transform: translateX(-50%) scale(1);
    color: #c4b5a0;
    font-size: 10px;
    line-height: 1;
    transition: color 0.4s ease;
}

.progress-diamond.active {
    color: #d4a843;
    animation: diamond-pulse 2s ease-in-out infinite;
}

@keyframes diamond-pulse {
    0%, 100% { transform: translateX(-50%) scale(1); }
    50% { transform: translateX(-50%) scale(1.3); }
}

/* === CHAPTERS (SHARED) === */
.chapter {
    position: relative;
    min-height: 100vh;
    width: 100%;
    overflow: hidden;
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 800ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 800ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.chapter.visible {
    opacity: 1;
    transform: translateY(0);
}

.chapter-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 100%;
    height: 100vh;
    padding-left: 8vw;
    padding-right: 4vw;
    position: relative;
}

.chapter-label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.7rem, 1vw, 0.85rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #8b6914;
    display: block;
}

.chapter-title {
    font-family: 'Roboto Slab', serif;
    font-weight: 700;
    font-size: clamp(2.2rem, 6vw, 5rem);
    letter-spacing: 0.04em;
    color: #2d2118;
    line-height: 1.1;
}

/* === CHAPTER 1: HERO === */
.chapter-hero {
    background: #f5ede0;
}

.chapter-hero .chapter-grid {
    align-items: start;
}

.z-path-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.15;
    z-index: 2;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

#zPath {
    stroke-dasharray: 2400;
    stroke-dashoffset: 2400;
    transition: stroke-dashoffset 0.05s linear;
}

.hero-title {
    grid-column: 2 / 7;
    grid-row: 2 / 4;
    z-index: 5;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.domain-name {
    font-family: 'Roboto Slab', serif;
    font-weight: 300;
    font-size: clamp(3rem, 10vw, 8rem);
    letter-spacing: -0.02em;
    color: #2d2118;
    line-height: 1;
}

.hero-meta {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.7rem, 1vw, 0.85rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #8b6914;
    margin-top: 1rem;
}

.hero-subtitle {
    grid-column: 7 / 12;
    grid-row: 6 / 8;
    z-index: 5;
    display: flex;
    align-items: flex-end;
}

.subtitle-text {
    font-family: 'Source Serif 4', serif;
    font-weight: 600;
    font-size: clamp(1rem, 2vw, 1.5rem);
    color: #3b322a;
    line-height: 1.6;
}

/* Diagonal thread lines */
.diagonal-thread {
    position: absolute;
    width: 200%;
    height: 1px;
    background: #c4b5a0;
    transform-origin: center;
    pointer-events: none;
    z-index: 1;
}

.diagonal-hero {
    top: 55%;
    left: -20%;
    transform: rotate(25deg);
}

.diagonal-question {
    top: 40%;
    left: -10%;
    transform: rotate(-15deg);
}

.diagonal-archive {
    bottom: 10%;
    left: -20%;
    transform: rotate(20deg);
}

/* === CHAPTER 2: THE QUESTION === */
.chapter-question {
    background: #f5ede0;
}

.question-text {
    grid-column: 7 / 12;
    grid-row: 1 / 4;
    z-index: 5;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1rem;
}

.photo-cluster {
    grid-column: 1 / 6;
    grid-row: 4 / 9;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.photo-frame {
    width: 160px;
    height: 180px;
    border: 6px solid #c4b5a0;
    border-bottom-width: 24px;
    background: #f5ede0;
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                box-shadow 0.4s ease;
    will-change: transform;
    position: relative;
    opacity: 0;
    transform: translateY(20px);
}

.photo-frame.frame-visible {
    opacity: 1;
}

.photo-frame:hover {
    transform: rotate(0deg) translateY(-8px) !important;
    box-shadow: 0 12px 32px rgba(45, 33, 24, 0.25);
}

.photo-inner {
    width: 100%;
    height: 100%;
    filter: grayscale(40%);
}

.gradient-a {
    background: linear-gradient(135deg, #c4b5a0 0%, #a0522d 30%, #6b7c5e 60%, #8b6914 100%);
}

.gradient-b {
    background: linear-gradient(200deg, #d4a843 0%, #3b322a 40%, #a0522d 70%, #c4b5a0 100%);
}

.gradient-c {
    background: linear-gradient(45deg, #6b7c5e 0%, #c4b5a0 35%, #2d2118 70%, #d4a843 100%);
}

.gradient-d {
    background: linear-gradient(310deg, #8b6914 0%, #6b7c5e 30%, #c4b5a0 60%, #a0522d 100%);
}

.photo-caption {
    position: absolute;
    bottom: -20px;
    left: 6px;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.6rem;
    letter-spacing: 0.04em;
    color: #3b322a;
    opacity: 0.7;
}

.mini-frame {
    width: 100%;
    height: 100px;
    border-width: 4px;
    border-bottom-width: 16px;
}

/* === CHAPTER 3: THE ARCHIVE === */
.chapter-archive {
    background: #f5ede0;
}

.chapter-archive .chapter-grid {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-top: 4vh;
    padding-bottom: 4vh;
    height: auto;
    min-height: 100vh;
}

.archive-label {
    margin-bottom: 2rem;
}

.archive-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    z-index: 5;
}

.archive-cell {
    background: rgba(196, 181, 160, 0.2);
    border: 1px solid #c4b5a0;
    padding: 2rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 600ms ease, transform 600ms ease, background 300ms ease;
}

.archive-cell.cell-visible {
    opacity: 1;
    transform: translateY(0);
}

.archive-cell:hover {
    background: rgba(196, 181, 160, 0.4);
}

.cell-large {
    grid-column: span 2;
    grid-row: span 2;
}

.cell-medium {
    grid-column: span 2;
}

.cell-small {
    grid-column: span 1;
}

.cell-empty {
    background: transparent;
    border: none;
    opacity: 1;
}

.archive-title {
    font-family: 'Roboto Slab', serif;
    font-weight: 700;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    color: #2d2118;
    margin-bottom: 0.75rem;
}

.archive-body {
    font-family: 'Source Serif 4', serif;
    font-weight: 400;
    color: #3b322a;
    line-height: 1.75;
}

.archive-meta {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.7rem, 1vw, 0.85rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #8b6914;
    display: block;
    margin-bottom: 0.5rem;
}

.archive-note {
    font-family: 'Source Serif 4', serif;
    font-weight: 400;
    font-size: 0.9rem;
    color: #3b322a;
    opacity: 0.8;
}

/* === CHAPTER 4: THE CONNECTION === */
.chapter-connection {
    background: #2d2118;
}

.chapter-connection .chapter-grid {
    display: flex;
    align-items: stretch;
    padding: 0;
    gap: 0;
}

.split-panel {
    width: 50%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem;
    will-change: transform;
    transition: transform 1s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.panel-left {
    background: linear-gradient(135deg, #2d2118 0%, #3b322a 50%, #a0522d 100%);
    transform: translateX(-10vw);
}

.panel-right {
    background: linear-gradient(225deg, #2d2118 0%, #3b322a 50%, #6b7c5e 100%);
    transform: translateX(10vw);
}

.panel-left.panels-visible {
    transform: translateX(0);
}

.panel-right.panels-visible {
    transform: translateX(4px);
}

.panel-content {
    max-width: 400px;
}

.panel-title {
    font-family: 'Roboto Slab', serif;
    font-weight: 700;
    font-size: clamp(2rem, 4vw, 3.5rem);
    color: #f5ede0;
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin-bottom: 1.5rem;
}

.panel-text {
    font-family: 'Source Serif 4', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.5vw, 1.2rem);
    color: #c4b5a0;
    line-height: 1.75;
}

.chapter-connection .chapter-label {
    margin-bottom: 1rem;
    color: #d4a843;
}

.connection-meta {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.7rem, 1vw, 0.85rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #d4a843;
    display: block;
    margin-top: 2rem;
    opacity: 0.7;
}

/* === SCATTERED DOTS === */
.scattered-dots {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.dot {
    position: absolute;
    border-radius: 50%;
    background: #d4a843;
    opacity: 0.12;
}

/* === TEXT HOVER EFFECT === */
.chapter-title,
.archive-title,
.subtitle-text,
.panel-title,
.archive-body,
.panel-text {
    transition: color 300ms ease;
}

.chapter-title:hover,
.archive-title:hover,
.subtitle-text:hover {
    color: #8b6914;
}

.panel-title:hover {
    color: #d4a843;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .chapter-grid {
        padding-left: 5vw;
        padding-right: 5vw;
    }

    .hero-title {
        grid-column: 1 / -1;
        grid-row: 2 / 4;
    }

    .hero-subtitle {
        grid-column: 1 / -1;
        grid-row: 5 / 7;
    }

    .question-text {
        grid-column: 1 / -1;
        grid-row: 1 / 3;
    }

    .photo-cluster {
        grid-column: 1 / -1;
        grid-row: 3 / 9;
    }

    .photo-frame {
        width: 120px;
        height: 140px;
    }

    .archive-grid {
        grid-template-columns: 1fr 1fr;
    }

    .cell-large {
        grid-column: span 2;
        grid-row: span 1;
    }

    .cell-medium {
        grid-column: span 2;
    }

    .split-panel {
        padding: 2rem;
    }

    .chapter-connection .chapter-grid {
        flex-direction: column;
    }

    .split-panel {
        width: 100%;
        min-height: 50vh;
    }
}
