/* =========================================
   senggack.com - Hanbok-Inspired Textile Design
   Korean Traditional Dress & Textile Arts
   ========================================= */

/* --- CSS Custom Properties --- */
:root {
    --bg-primary: #1B1040;
    --bg-secondary: #0D0A1A;
    --accent-crimson: #C62828;
    --accent-gold: #B8860B;
    --accent-jade: #00695C;
    --text-primary: #F5F0E8;
    --text-secondary: #D4C5A9;
    --seam-bronze: #8B7355;
    --font-display: 'Noto Serif KR', serif;
    --font-body: 'Cormorant Garamond', serif;
    --font-accent: 'IBM Plex Sans', sans-serif;
}

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

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

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-weight: 400;
    line-height: 1.85;
    font-size: clamp(1rem, 1.6vw, 1.2rem);
    overflow-x: hidden;
    position: relative;
}

/* --- Hanji Paper Texture Overlay --- */
.hanji-texture {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6' height='6'%3E%3Crect width='1' height='1' x='0' y='0' fill='%23F5F0E8' opacity='0.5'/%3E%3Crect width='1' height='1' x='3' y='1' fill='%23D4C5A9' opacity='0.3'/%3E%3Crect width='1' height='1' x='1' y='3' fill='%23F5F0E8' opacity='0.4'/%3E%3Crect width='1' height='1' x='4' y='4' fill='%23D4C5A9' opacity='0.2'/%3E%3Crect width='1' height='1' x='2' y='5' fill='%23F5F0E8' opacity='0.35'/%3E%3Crect width='1' height='1' x='5' y='2' fill='%23D4C5A9' opacity='0.25'/%3E%3C/svg%3E");
    background-repeat: repeat;
}

/* --- Scroll Progress Thread --- */
.scroll-thread {
    position: fixed;
    top: 0;
    right: 20px;
    width: 2px;
    height: 100vh;
    background-color: rgba(139, 115, 85, 0.2);
    z-index: 999;
}

.scroll-thread-fill {
    width: 100%;
    height: 0%;
    background-color: var(--accent-gold);
    transition: height 0.15s linear;
}

/* --- Home Knot Anchor --- */
.home-knot {
    position: fixed;
    top: 24px;
    left: 24px;
    z-index: 998;
    text-decoration: none;
    opacity: 0.6;
    transition: opacity 0.6s ease-out;
}

.home-knot:hover {
    opacity: 1;
}

.home-knot svg {
    display: block;
}

/* --- Panel System --- */
.panel {
    position: relative;
    min-height: 100vh;
    width: 100%;
    display: flex;
    align-items: center;
    overflow: hidden;
    margin-top: -6px;
    z-index: 1;
}

.panel:first-child {
    margin-top: 0;
}

.panel-opening {
    background-color: var(--bg-primary);
    z-index: 5;
}

.panel-culture {
    background-color: var(--bg-secondary);
    z-index: 4;
}

.panel-gallery {
    background-color: var(--bg-primary);
    z-index: 3;
}

.panel-detail {
    background-color: var(--bg-secondary);
    z-index: 2;
}

.panel-closing {
    background-color: var(--bg-primary);
    z-index: 1;
    justify-content: center;
}

/* --- Seam Dividers --- */
.seam-divider {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 10;
}

/* --- Vertical Labels --- */
.vertical-label {
    position: absolute;
    writing-mode: vertical-rl;
    font-family: var(--font-display);
    font-weight: 300;
    font-size: 0.85rem;
    color: var(--accent-gold);
    letter-spacing: 0.1em;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.8s ease-out;
}

.vertical-label.revealed {
    opacity: 1;
}

.vertical-label-left {
    left: 40px;
    top: 50%;
    transform: translateY(-50%);
}

/* --- Panel 1: Opening --- */
.jogakbo-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.jogakbo-patch {
    opacity: 0;
    fill-opacity: 0.1;
    transition: opacity 1.2s ease-out;
}

.jogakbo-patch.visible {
    opacity: 1;
}

.opening-content {
    position: relative;
    z-index: 2;
    width: 55%;
    padding-left: 12%;
}

.domain-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.2rem, 7vw, 4.5rem);
    letter-spacing: 0.06em;
    color: var(--text-primary);
    line-height: 1.2;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1s ease-out, transform 1s ease-out;
}

.domain-title.revealed {
    opacity: 1;
    transform: translateY(0);
}

.maedeup-hero {
    margin-top: 2.5rem;
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 1.2s ease-out 0.5s, transform 1.2s ease-out 0.5s;
}

.maedeup-hero.revealed {
    opacity: 1;
    transform: translateY(0);
}

.maedeup-knot {
    width: 60px;
    height: 80px;
}

.knot-path {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    transition: stroke-dashoffset 2.5s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.maedeup-hero.revealed .knot-path {
    stroke-dashoffset: 0;
}

/* --- Panel 2: Cultural Context --- */
.thread-line {
    position: absolute;
    right: 15%;
    top: 0;
    width: 60px;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.thread-path {
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    transition: stroke-dashoffset 2s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.thread-line.draw .thread-path {
    stroke-dashoffset: 0;
}

.panel-content {
    position: relative;
    z-index: 2;
    width: 55%;
    padding: 4rem 3rem;
}

.content-left {
    margin-left: 12%;
}

.content-right {
    margin-left: auto;
    margin-right: 12%;
}

.section-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.8rem, 4vw, 3rem);
    letter-spacing: 0.06em;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    line-height: 1.3;
}

.body-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.6vw, 1.2rem);
    line-height: 1.85;
    color: var(--text-secondary);
    margin-bottom: 1.2rem;
}

.accent-metadata {
    font-family: var(--font-accent);
    font-weight: 300;
    font-size: 0.8rem;
    color: var(--accent-gold);
    letter-spacing: 0.08em;
    display: inline-block;
    margin-top: 1rem;
    opacity: 0.8;
}

/* Reveal animations for content */
[data-reveal] {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

[data-reveal].revealed {
    opacity: 1;
    transform: translateY(0);
}

/* --- Panel 3: Textile Gallery --- */
.gallery-layout {
    display: flex;
    width: 100%;
    padding: 2rem 5% 2rem 8%;
    gap: 4%;
    align-items: center;
    position: relative;
    z-index: 2;
}

.gallery-jogakbo {
    flex: 0 0 56%;
    position: relative;
}

.jogakbo-gallery-svg {
    width: 100%;
    height: auto;
}

.gallery-patch {
    fill-opacity: 0.12;
    cursor: pointer;
    transition: fill-opacity 0.6s ease-out;
}

.gallery-patch:hover {
    fill-opacity: 0.28;
}

.patch-tooltip {
    position: absolute;
    background-color: var(--bg-secondary);
    border: 1px solid var(--seam-bronze);
    color: var(--text-primary);
    font-family: var(--font-accent);
    font-weight: 300;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 6px 14px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease-out;
    white-space: nowrap;
    z-index: 20;
}

.patch-tooltip.visible {
    opacity: 1;
}

.gallery-text {
    flex: 1;
    padding-left: 2%;
}

/* --- Panel 4: Detail / Maedeup --- */
.dancheong-border {
    position: absolute;
    left: 0;
    width: 100%;
    height: 16px;
    z-index: 10;
    background-image:
        repeating-linear-gradient(
            90deg,
            var(--accent-crimson) 0px,
            var(--accent-crimson) 16px,
            transparent 16px,
            transparent 20px,
            var(--accent-jade) 20px,
            var(--accent-jade) 36px,
            transparent 36px,
            transparent 40px,
            var(--accent-crimson) 40px,
            var(--accent-crimson) 48px,
            transparent 48px,
            transparent 52px,
            var(--accent-gold) 52px,
            var(--accent-gold) 60px,
            transparent 60px,
            transparent 64px
        );
    opacity: 0.5;
}

.dancheong-top {
    top: 0;
}

.dancheong-bottom {
    bottom: 30px;
}

.detail-layout {
    display: flex;
    width: 100%;
    padding: 4rem 8%;
    gap: 6%;
    align-items: center;
    position: relative;
    z-index: 2;
}

.detail-knot {
    flex: 0 0 40%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.large-maedeup {
    width: 100%;
    max-width: 320px;
    height: auto;
}

.knot-draw {
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
    transition: stroke-dashoffset 3s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.knot-draw-circle {
    stroke-dasharray: 60;
    stroke-dashoffset: 60;
    transition: stroke-dashoffset 3s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.detail-knot.revealed .knot-draw,
.detail-knot.revealed .knot-draw-circle {
    stroke-dashoffset: 0;
}

.detail-text {
    flex: 1;
}

/* --- Panel 5: Closing --- */
.jogakbo-closing {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.closing-patch {
    fill-opacity: 0.12;
    opacity: 1;
    transition: opacity 1.5s ease-out;
}

.closing-patch.faded {
    opacity: 0;
}

.closing-content {
    position: relative;
    z-index: 2;
    width: 70%;
    margin: 0 auto;
    text-align: center;
    padding: 2rem;
}

.closing-text {
    font-family: var(--font-body);
    font-weight: 500;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    color: var(--text-secondary);
    line-height: 1.8;
    letter-spacing: 0.03em;
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 1.5s ease-out 1.2s, transform 1.5s ease-out 1.2s;
}

.closing-content.revealed .closing-text {
    opacity: 1;
    transform: translateY(0);
}

.closing-line {
    width: 60px;
    height: 1px;
    background-color: var(--accent-gold);
    margin: 2.5rem auto 0;
    opacity: 0;
    transform: scaleX(0);
    transition: opacity 1.2s ease-out 2s, transform 1.2s ease-out 2s;
}

.closing-content.revealed .closing-line {
    opacity: 0.6;
    transform: scaleX(1);
}

/* --- Responsive Adjustments --- */
@media (max-width: 900px) {
    .vertical-label {
        display: none;
    }

    .opening-content {
        width: 80%;
        padding-left: 8%;
    }

    .panel-content {
        width: 85%;
        padding: 3rem 2rem;
    }

    .content-left {
        margin-left: 5%;
    }

    .gallery-layout {
        flex-direction: column;
        padding: 3rem 5%;
    }

    .gallery-jogakbo {
        flex: none;
        width: 100%;
        margin-bottom: 2rem;
    }

    .gallery-text {
        padding-left: 0;
    }

    .detail-layout {
        flex-direction: column;
        padding: 3rem 5%;
    }

    .detail-knot {
        flex: none;
        width: 60%;
        margin-bottom: 2rem;
    }

    .scroll-thread {
        right: 10px;
    }

    .home-knot {
        top: 16px;
        left: 16px;
    }
}

@media (max-width: 600px) {
    .opening-content {
        width: 90%;
        padding-left: 5%;
    }

    .panel-content {
        width: 92%;
    }

    .content-left {
        margin-left: 4%;
    }

    .detail-knot {
        width: 80%;
    }

    .closing-content {
        width: 90%;
    }
}
