/* ========================================
   namu.style — Aurora Through the Canopy
   ======================================== */

/* -- Custom Properties -- */
:root {
    --aurora-midnight: #0a0e1f;
    --borealis-jade: #3ddc97;
    --twilight-plum: #7b5ea7;
    --amber-core: #d4a053;
    --hanji-white: #f7f3eb;
    --charred-oak: #2c1810;
    --lichen-silver: #a8b5a0;
    --dawn-blush: #e87da0;

    --font-display: 'Caveat', cursive;
    --font-body: 'Libre Baskerville', serif;
    --font-accent: 'Noto Sans KR', sans-serif;

    --scroll-progress: 0;
    --bg-r: 247; --bg-g: 243; --bg-b: 235;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-weight: 400;
    color: var(--charred-oak);
    background-color: rgb(var(--bg-r), var(--bg-g), var(--bg-b));
    line-height: 1.75;
    overflow-x: hidden;
    transition: background-color 0.1s linear;
}

/* -- Trunk Line -- */
.trunk-line {
    position: fixed;
    left: 61.8%;
    top: 0;
    width: 1px;
    height: 100vh;
    background: rgba(168, 181, 160, 0.2);
    z-index: 100;
    pointer-events: none;
}

.trunk-line-fill {
    width: 100%;
    height: calc(var(--scroll-progress) * 100%);
    background: linear-gradient(180deg, var(--borealis-jade), var(--twilight-plum));
    transition: height 0.05s linear;
}

/* -- Crown Opening -- */
.crown {
    position: relative;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.crown-watermark {
    position: absolute;
    font-family: var(--font-display);
    font-size: 15vw;
    color: var(--charred-oak);
    opacity: 0.03;
    animation: drift 60s linear infinite;
    pointer-events: none;
    user-select: none;
}

.crown-character {
    position: relative;
    width: clamp(280px, 50vw, 600px);
    height: clamp(350px, 62vh, 750px);
}

.hero-svg {
    width: 100%;
    height: 100%;
}

.hero-svg .stroke {
    stroke-width: 18;
    stroke-linecap: round;
    fill: none;
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
}

.stroke-1 {
    stroke: var(--borealis-jade);
    animation: draw-stroke 0.8s ease-out 0.2s forwards;
}
.stroke-2 {
    stroke: url(#auroraGrad);
    stroke: var(--borealis-jade);
    animation: draw-stroke 1.0s ease-out 0.8s forwards;
}
.stroke-3 {
    stroke: var(--twilight-plum);
    animation: draw-stroke 0.7s ease-out 1.5s forwards;
}
.stroke-4 {
    stroke: var(--twilight-plum);
    animation: draw-stroke 0.7s ease-out 1.9s forwards;
}

@keyframes draw-stroke {
    to { stroke-dashoffset: 0; }
}

.crown-title {
    position: absolute;
    bottom: 15%;
    right: 12%;
    text-align: right;
    opacity: 0;
    animation: fade-in 1s ease-out 2.8s forwards;
}

.domain-name {
    display: block;
    font-family: var(--font-body);
    font-size: clamp(1rem, 1.5vw, 1.4rem);
    letter-spacing: 0.15em;
    color: var(--charred-oak);
}

.domain-subtitle {
    display: block;
    font-family: var(--font-accent);
    font-weight: 300;
    font-size: clamp(0.75rem, 0.9vw, 0.85rem);
    color: var(--lichen-silver);
    margin-top: 0.3em;
}

@keyframes fade-in {
    to { opacity: 1; }
}

/* -- Ring Sections -- */
.ring-section {
    position: relative;
    padding-block: clamp(4rem, 10vh, 8rem);
}

.ring-grid {
    display: grid;
    grid-template-columns: [branch-left] 1fr [trunk-start] minmax(320px, 55ch) [trunk-end] 1fr [branch-right];
    margin-inline-start: clamp(2rem, 8vw, 12rem);
    gap: 2rem;
    align-items: start;
}

.ring-counter {
    position: absolute;
    left: clamp(1rem, 4vw, 4rem);
    top: clamp(4rem, 10vh, 8rem);
    font-family: var(--font-accent);
    font-weight: 300;
    color: var(--lichen-silver);
    opacity: 0;
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    text-align: center;
}

.ring-counter.visible {
    opacity: 1;
}

.ring-number {
    display: block;
    font-family: var(--font-display);
    font-size: clamp(2rem, 4vw, 3.5rem);
    color: var(--amber-core);
    line-height: 1;
}

.ring-label {
    display: block;
    font-size: clamp(0.65rem, 0.8vw, 0.75rem);
    margin-top: 0.5em;
}

/* Ring content positioning */
.ring-content {
    position: relative;
    grid-column: trunk-start / trunk-end;
    opacity: 0;
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.ring-content--left {
    transform: translateX(-30px);
}

.ring-content--right {
    transform: translateX(30px);
}

.ring-content.visible {
    opacity: 1;
    transform: translateX(0);
}

.ring-glow {
    position: absolute;
    top: -2rem;
    left: -3rem;
    width: 200%;
    height: 200px;
    background: radial-gradient(ellipse at center, rgba(61, 220, 151, 0.15) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
}

.ring-heading {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--charred-oak);
    margin-bottom: 0.5em;
    line-height: 1.2;
}

.heading-en {
    font-family: var(--font-body);
    font-style: italic;
    font-size: 0.45em;
    color: var(--lichen-silver);
    vertical-align: middle;
}

.ring-intro {
    font-size: clamp(1.1rem, 1.3vw, 1.25rem);
    line-height: 1.6;
    color: var(--charred-oak);
    margin-bottom: 1.5em;
}

.ring-body {
    font-size: clamp(1rem, 1.1vw, 1.15rem);
    line-height: 1.75;
    margin-bottom: 1.5em;
    color: var(--charred-oak);
}

/* Branch Elements */
.branch-element {
    position: sticky;
    top: 30vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    opacity: 0;
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.branch-element--left {
    grid-column: branch-left / trunk-start;
    justify-self: end;
    transform: translateX(-30px);
}

.branch-element--right {
    grid-column: trunk-end / branch-right;
    justify-self: start;
    transform: translateX(30px);
}

.branch-element.visible {
    opacity: 1;
    transform: translateX(0);
}

.branch-annotation {
    font-family: var(--font-accent);
    font-weight: 300;
    font-size: clamp(0.7rem, 0.85vw, 0.8rem);
    color: var(--lichen-silver);
    text-align: center;
    line-height: 1.5;
}

.branch-annotation em {
    font-family: var(--font-body);
    font-style: italic;
    font-size: 0.9em;
}

/* L-System Canvas */
.lsystem-canvas {
    max-width: 250px;
    height: auto;
    opacity: 0.15;
}

/* Lattice Pattern */
.lattice-pattern {
    width: 200px;
    height: 200px;
    background:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 18px,
            rgba(123, 94, 167, 0.08) 18px,
            rgba(123, 94, 167, 0.08) 19px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 18px,
            rgba(61, 220, 151, 0.08) 18px,
            rgba(61, 220, 151, 0.08) 19px
        ),
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 25px,
            rgba(212, 160, 83, 0.05) 25px,
            rgba(212, 160, 83, 0.05) 26px
        );
    border: 1px solid rgba(44, 24, 16, 0.08);
}

/* Concentric Rings */
.concentric-rings {
    position: relative;
    width: 200px;
    height: 200px;
}

.c-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 1px solid rgba(44, 24, 16, 0.08);
}

.c-ring-1  { width: 20px;  height: 16px;  border-radius: 50% 48% 52% 45%; }
.c-ring-2  { width: 40px;  height: 32px;  border-radius: 48% 52% 45% 50%; }
.c-ring-3  { width: 60px;  height: 48px;  border-radius: 52% 45% 50% 48%; }
.c-ring-4  { width: 78px;  height: 65px;  border-radius: 45% 50% 48% 52%; }
.c-ring-5  { width: 95px;  height: 80px;  border-radius: 50% 47% 53% 46%; }
.c-ring-6  { width: 112px; height: 94px;  border-radius: 47% 53% 46% 50%; }
.c-ring-7  { width: 130px; height: 108px; border-radius: 53% 46% 50% 47%; }
.c-ring-8  { width: 148px; height: 124px; border-radius: 46% 50% 47% 53%; }
.c-ring-9  { width: 168px; height: 142px; border-radius: 50% 48% 52% 45%; }
.c-ring-10 { width: 190px; height: 165px; border-radius: 48% 52% 45% 50%; }

/* -- Section Dividers -- */
.section-divider {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem 0;
}

.divider-svg {
    width: 200px;
    height: auto;
    overflow: visible;
}

/* Ring divider animation */
.ring-ellipse {
    fill: none;
    stroke: var(--lichen-silver);
    stroke-width: 0.5;
    opacity: 0.4;
    animation: ring-pulse 4s ease-in-out infinite;
}

.ring-e1 { animation-delay: 0s; }
.ring-e2 { animation-delay: 0.4s; }
.ring-e3 { animation-delay: 0.8s; }
.ring-e4 { animation-delay: 1.2s; }
.ring-e5 { animation-delay: 1.6s; }

@keyframes ring-pulse {
    0%, 100% { opacity: 0.2; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.05); }
}

/* Leaf divider animation */
.leaf {
    fill: var(--lichen-silver);
    opacity: 0;
    animation: leaf-fall 5s ease-in-out infinite;
}

.leaf-1 { animation-delay: 0s; }
.leaf-2 { animation-delay: 0.8s; }
.leaf-3 { animation-delay: 1.6s; }
.leaf-4 { animation-delay: 2.4s; }
.leaf-5 { animation-delay: 3.2s; }

@keyframes leaf-fall {
    0% { opacity: 0; transform: translateY(-10px) rotate(0deg); }
    20% { opacity: 0.5; }
    80% { opacity: 0.3; }
    100% { opacity: 0; transform: translateY(15px) rotate(45deg); }
}

/* Branch divider */
.branch-line {
    stroke: var(--lichen-silver);
    stroke-width: 1;
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    animation: draw-branch 3s ease-out forwards;
}

.bl-1 { animation-delay: 0s; }
.bl-2 { animation-delay: 1s; }
.bl-3 { animation-delay: 1.5s; }

.branch-node {
    fill: var(--borealis-jade);
    opacity: 0;
    animation: node-appear 0.5s ease-out forwards;
}

.branch-node:nth-child(4) { animation-delay: 1.5s; }
.branch-node:nth-child(5) { animation-delay: 2s; }
.branch-node:nth-child(6) { animation-delay: 1s; }

@keyframes draw-branch {
    to { stroke-dashoffset: 0; }
}

@keyframes node-appear {
    to { opacity: 0.7; }
}

/* -- Root System -- */
.root-system {
    position: relative;
    min-height: 100vh;
    background: var(--aurora-midnight);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.root-watermark {
    position: absolute;
    font-family: var(--font-display);
    font-size: 20vw;
    color: var(--hanji-white);
    opacity: 0.03;
    animation: drift 60s linear infinite reverse;
    pointer-events: none;
    user-select: none;
    top: 10%;
}

.root-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.root-nodes {
    position: relative;
    width: 100%;
    height: 60vh;
    z-index: 2;
}

.root-node {
    position: absolute;
    left: var(--node-x);
    top: var(--node-y);
    transform: translate(-50%, -50%);
    text-align: center;
    opacity: 0;
    transition: opacity 1.2s ease-out;
}

.root-node.visible {
    opacity: 1;
}

.node-glow {
    display: block;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--dawn-blush) 0%, transparent 70%);
    opacity: 0.5;
    animation: glow-pulse 3s ease-in-out infinite;
    margin: 0 auto 0.5rem;
}

.root-node:nth-child(2) .node-glow {
    background: radial-gradient(circle, var(--borealis-jade) 0%, transparent 70%);
}

.root-node:nth-child(3) .node-glow {
    background: radial-gradient(circle, var(--twilight-plum) 0%, transparent 70%);
}

.root-node:nth-child(4) .node-glow {
    background: radial-gradient(circle, var(--amber-core) 0%, transparent 70%);
}

@keyframes glow-pulse {
    0%, 100% { transform: scale(1); opacity: 0.4; }
    50% { transform: scale(1.3); opacity: 0.7; }
}

.node-text {
    font-family: var(--font-accent);
    font-weight: 500;
    font-size: clamp(0.9rem, 1.2vw, 1.1rem);
    color: var(--hanji-white);
    letter-spacing: 0.05em;
}

.root-footer {
    position: relative;
    z-index: 2;
    padding-bottom: 3rem;
    text-align: center;
}

.root-domain {
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 2.5vw, 2rem);
    font-weight: 700;
    color: var(--hanji-white);
    letter-spacing: 0.1em;
    opacity: 0.8;
}

/* -- Watermark drift animation -- */
@keyframes drift {
    0% { transform: translateX(0); }
    50% { transform: translateX(3vw); }
    100% { transform: translateX(0); }
}

/* -- Reduced Motion -- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* -- Responsive -- */
@media (max-width: 768px) {
    .trunk-line {
        display: none;
    }

    .ring-grid {
        display: flex;
        flex-direction: column;
        margin-inline-start: 1.5rem;
        margin-inline-end: 1.5rem;
        gap: 1.5rem;
    }

    .ring-counter {
        position: relative;
        left: auto;
        top: auto;
    }

    .branch-element {
        position: relative;
        top: auto;
        order: -1;
    }

    .branch-element--left,
    .branch-element--right {
        justify-self: center;
    }

    .crown-title {
        right: 5%;
        bottom: 10%;
    }

    .ring-content--left,
    .ring-content--right {
        transform: translateY(20px);
    }

    .ring-content.visible {
        transform: translateY(0);
    }

    .branch-element--left,
    .branch-element--right {
        transform: translateY(20px);
    }

    .branch-element.visible {
        transform: translateY(0);
    }
}
