/* ============================================
   mang.quest — Network Tapestry
   Hand-drawn textile visualization of networks
   ============================================ */

/* --- CSS Custom Properties (Design Palette) --- */
:root {
    --burnt-sienna: #5A2A1A;
    --warm-umber: #3A2A20;
    --linen-cream: #F4ECD8;
    --burnt-orange: #D88040;
    --indigo-thread: #2A4A6A;
    --sage-stitch: #6A8A5A;
    --rose-pink: #C86A7A;

    --font-display: 'Nanum Pen Script', cursive;
    --font-body: 'Noto Serif KR', serif;

    --transition-fade: opacity 0.8s ease, transform 0.8s ease;
    --transition-thread: stroke-dashoffset 1.2s ease-out;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.95rem, 1.2vw, 1.1rem);
    line-height: 1.85;
    color: var(--warm-umber);
    background-color: var(--linen-cream);
    overflow-x: hidden;
    position: relative;
}

/* --- Cross-Stitch Grid Background Pattern --- */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    background-image:
        radial-gradient(circle, var(--warm-umber) 0.5px, transparent 0.5px);
    background-size: 20px 20px;
    opacity: 0.04;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */

.title {
    font-family: var(--font-display);
    font-weight: 400;
    color: var(--burnt-sienna);
}

.title--main {
    font-size: clamp(2rem, 4vw, 3.5rem);
    margin-bottom: 1rem;
    letter-spacing: 0.05em;
    opacity: 0;
    animation: fadeInUp 1.2s ease-out 0.3s forwards;
}

.title--section {
    font-size: clamp(1.4rem, 2.5vw, 2rem);
    margin-bottom: 1.5rem;
}

.subtitle {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(0.9rem, 1.5vw, 1.15rem);
    color: var(--indigo-thread);
    opacity: 0;
    animation: fadeInUp 1s ease-out 0.9s forwards;
    letter-spacing: 0.02em;
}

.body-text {
    font-weight: 300;
    margin-bottom: 1rem;
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeReveal {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes drawThread {
    from {
        stroke-dashoffset: var(--thread-length, 1000);
    }
    to {
        stroke-dashoffset: 0;
    }
}

/* ============================================
   PATCHWORK GRID LAYOUT
   ============================================ */

.patchwork-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: minmax(260px, auto);
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    padding: 4rem 2rem;
}

/* --- Block Base Styles --- */
.block {
    position: relative;
    padding: 2.5rem;
    border: 2px dashed var(--burnt-sienna);
    border-radius: 2px;
    opacity: 0;
    transform: translateY(15px);
    transition: var(--transition-fade);
    overflow: hidden;
}

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

.block:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(58, 42, 32, 0.1);
}

/* --- Block Sizes --- */
.block--large {
    grid-column: span 2;
    grid-row: span 2;
}

.block--wide {
    grid-column: span 3;
    grid-row: span 1;
}

.block--tall {
    grid-column: span 2;
    grid-row: span 2;
}

.block--small {
    grid-column: span 1;
    grid-row: span 1;
}

/* --- Block Content --- */
.block__content {
    position: relative;
    z-index: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* --- Texture Backgrounds --- */
.block[data-texture="linen"] {
    background-color: var(--linen-cream);
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 3px,
            rgba(90, 42, 26, 0.02) 3px,
            rgba(90, 42, 26, 0.02) 4px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 3px,
            rgba(90, 42, 26, 0.02) 3px,
            rgba(90, 42, 26, 0.02) 4px
        );
}

.block[data-texture="canvas"] {
    background-color: #EFE5CC;
    background-image:
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 5px,
            rgba(42, 74, 106, 0.02) 5px,
            rgba(42, 74, 106, 0.02) 6px
        ),
        repeating-linear-gradient(
            -45deg,
            transparent,
            transparent 5px,
            rgba(42, 74, 106, 0.02) 5px,
            rgba(42, 74, 106, 0.02) 6px
        );
}

.block[data-texture="silk"] {
    background-color: #F0E8D4;
    background-image:
        linear-gradient(
            135deg,
            rgba(200, 106, 122, 0.04) 0%,
            transparent 50%,
            rgba(106, 138, 90, 0.04) 100%
        );
}

/* ============================================
   EMBROIDERED FLOWER NODES
   ============================================ */

.node-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-top: 1rem;
}

.node-card {
    text-align: center;
    padding: 1rem;
}

.node-flower {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    position: relative;
    opacity: 0.9;
}

/* Hub Flower - radiating petals */
.node-flower--hub::before {
    content: '';
    position: absolute;
    width: 48px;
    height: 48px;
    top: 8px;
    left: 8px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--burnt-orange) 6px, transparent 6px),
        repeating-conic-gradient(var(--burnt-orange) 0deg 6deg, transparent 6deg 20deg);
    opacity: 0.7;
}

.node-flower--hub::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 24px;
    left: 24px;
    border-radius: 50%;
    background: var(--burnt-orange);
}

/* Leaf Node - simple elegant form */
.node-flower--leaf::before {
    content: '';
    position: absolute;
    width: 40px;
    height: 48px;
    top: 8px;
    left: 12px;
    border: 2px dashed var(--sage-stitch);
    border-radius: 50%;
    opacity: 0.6;
}

.node-flower--leaf::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    top: 26px;
    left: 26px;
    border-radius: 50%;
    background: var(--sage-stitch);
}

/* Bridge Node - balanced symmetry */
.node-flower--bridge::before {
    content: '';
    position: absolute;
    width: 36px;
    height: 36px;
    top: 14px;
    left: 14px;
    border-radius: 50%;
    border: 3px solid var(--indigo-thread);
    box-shadow:
        0 0 0 6px transparent,
        0 0 0 8px var(--indigo-thread);
    opacity: 0.6;
}

.node-flower--bridge::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    top: 25px;
    left: 25px;
    border-radius: 50%;
    background: var(--indigo-thread);
}

.node-title {
    font-family: var(--font-display);
    font-size: clamp(1rem, 1.8vw, 1.3rem);
    color: var(--burnt-sienna);
    margin-bottom: 0.5rem;
}

.node-desc {
    font-size: 0.9rem;
    font-weight: 300;
    color: var(--warm-umber);
}

/* ============================================
   FEATURE LIST (HANDCRAFT ELEMENTS)
   ============================================ */

.feature-list {
    list-style: none;
    margin-top: 1.5rem;
}

.feature-item {
    display: flex;
    align-items: flex-start;
    margin-bottom: 1rem;
    gap: 0.75rem;
}

.feature-marker {
    color: var(--burnt-orange);
    font-weight: bold;
    flex-shrink: 0;
    margin-top: 0.25rem;
}

.feature-text {
    font-weight: 300;
}

/* ============================================
   COLOR PALETTE SWATCHES
   ============================================ */

.palette-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.palette-swatch {
    text-align: center;
}

.swatch-color {
    width: 100%;
    height: 80px;
    border-radius: 2px;
    border: 2px dashed var(--burnt-sienna);
    background-color: var(--swatch-color);
    margin-bottom: 0.75rem;
    opacity: 0.95;
}

.swatch-label {
    font-family: var(--font-display);
    font-size: 0.95rem;
    color: var(--burnt-sienna);
    margin-bottom: 0.25rem;
}

.swatch-code {
    font-size: 0.8rem;
    color: var(--warm-umber);
    font-weight: 300;
}

/* ============================================
   ANIMATION DEMO
   ============================================ */

.animation-demo {
    margin-top: 2rem;
    padding: 2rem;
    border: 2px dashed var(--burnt-orange);
    border-radius: 2px;
    background: rgba(216, 128, 64, 0.04);
    text-align: center;
}

.demo-element {
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: var(--burnt-orange);
    padding: 1rem;
    opacity: 0;
    animation: fadeReveal 0.8s ease forwards;
    animation-delay: 0.5s;
}

/* ============================================
   THREAD CONNECTIONS (SVG)
   ============================================ */

.thread-connections {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.thread-line {
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.3;
}

.thread-line.color-sienna {
    stroke: var(--burnt-sienna);
}

.thread-line.color-orange {
    stroke: var(--burnt-orange);
}

.thread-line.color-indigo {
    stroke: var(--indigo-thread);
}

.thread-line.color-sage {
    stroke: var(--sage-stitch);
}

.thread-line.color-rose {
    stroke: var(--rose-pink);
}

/* ============================================
   HERO SECTION
   ============================================ */

.block--hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background-image: none;
}

.hero-threads {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 0;
}

/* ============================================
   CLOSING SECTION
   ============================================ */

.block--closing {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.closing-threads {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 0;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 1200px) {
    .patchwork-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
        padding: 3rem 2rem;
    }

    .block--large,
    .block--wide {
        grid-column: span 2;
        grid-row: span 1;
    }

    .block--tall {
        grid-column: span 2;
        grid-row: span 1;
    }
}

@media (max-width: 900px) {
    .patchwork-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: minmax(220px, auto);
        gap: 1.25rem;
        padding: 2.5rem 1.5rem;
    }

    .block--large,
    .block--wide,
    .block--tall {
        grid-column: span 2;
        grid-row: span 1;
    }

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

@media (max-width: 600px) {
    .patchwork-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 2rem 1.25rem;
    }

    .block {
        padding: 1.5rem;
    }

    .block--large,
    .block--wide,
    .block--tall,
    .block--small {
        grid-column: span 1;
        grid-row: span 1;
    }

    .title--main {
        font-size: clamp(1.8rem, 8vw, 2.8rem);
    }

    .title--section {
        font-size: clamp(1.2rem, 2vw, 1.6rem);
    }

    .palette-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================
   WOBBLY SVG FILTER (Applied via JS)
   ============================================ */
/* Filter creates hand-drawn effect on thread lines */
