/* ============================================
   archetype.moe — Bauhaus Dreamscape
   Colors: #f0ebe3, #3d2c1f, #7a8b6e, #b8860b, #4a4238, #c4bdb2, #d4a052
   Fonts: Space Mono, DM Sans, Cormorant Garamond
   ============================================ */

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

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

body {
    font-family: 'DM Sans', sans-serif;
    font-weight: 400;
    font-size: 17px;
    line-height: 1.72;
    color: #3d2c1f;
    background-color: #f0ebe3;
    overflow-x: hidden;
}

.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* --- Grid Overlay --- */
.grid-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    pointer-events: none;
    z-index: 2;
    opacity: 0;
    transition: opacity 1.2s ease;
    padding: 0 48px;
}

.grid-overlay.visible {
    opacity: 1;
}

.grid-line {
    border-left: 1px solid rgba(139, 119, 91, 0.08);
    height: 100%;
}

.grid-line:last-child {
    border-right: 1px solid rgba(139, 119, 91, 0.08);
}

.grid-overlay.blurred .grid-line {
    filter: blur(0.5px);
    border-color: rgba(139, 119, 91, 0.05);
    transition: filter 1.5s ease, border-color 1.5s ease;
}

.grid-overlay.heavy-blur .grid-line {
    filter: blur(4px);
    border-color: rgba(139, 119, 91, 0.03);
    transition: filter 2s ease, border-color 2s ease;
}

.grid-overlay.restored .grid-line {
    filter: blur(0);
    border-color: rgba(139, 119, 91, 0.12);
    transition: filter 2s ease, border-color 2s ease;
}

/* --- Noise Overlays --- */
.noise-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 256px 256px;
    background-repeat: repeat;
    mix-blend-mode: multiply;
}

.noise-subtle {
    opacity: 0.04;
}

.noise-medium {
    opacity: 0.10;
}

.noise-heavy {
    opacity: 0.18;
}

/* --- Geometric Sigil (Navigation Icon) --- */
.sigil {
    position: fixed;
    top: 32px;
    left: 32px;
    width: 44px;
    height: 44px;
    z-index: 100;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sigil-square {
    position: absolute;
    width: 36px;
    height: 36px;
    border: 1.5px solid #3d2c1f;
    transition: transform 0.6s ease;
}

.sigil-triangle {
    position: absolute;
    width: 0;
    height: 0;
    border-left: 15px solid transparent;
    border-right: 15px solid transparent;
    border-bottom: 26px solid transparent;
    border-bottom-color: transparent;
    transition: transform 0.6s ease;
}

.sigil-triangle::after {
    content: '';
    position: absolute;
    top: 3px;
    left: -12.5px;
    width: 0;
    height: 0;
    border-left: 12.5px solid transparent;
    border-right: 12.5px solid transparent;
    border-bottom: 21.5px solid #f0ebe3;
}

.sigil-triangle {
    border-bottom-color: #3d2c1f;
    transform: translateY(-2px);
}

.sigil-circle {
    position: absolute;
    width: 18px;
    height: 18px;
    border: 1.5px solid #3d2c1f;
    border-radius: 50%;
    transform: translateY(1px);
}

.sigil:hover .sigil-square {
    transform: rotate(15deg);
}

.sigil:hover .sigil-circle {
    transform: translateY(1px) scale(1.15);
}

/* --- Radial Navigation --- */
.radial-nav {
    position: fixed;
    top: 32px;
    left: 32px;
    z-index: 99;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.radial-nav.open {
    pointer-events: auto;
    opacity: 1;
}

.radial-ring {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-item {
    display: block;
    font-family: 'Space Mono', monospace;
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #3d2c1f;
    text-decoration: none;
    background: rgba(240, 235, 227, 0.92);
    padding: 6px 14px;
    border: 1px solid rgba(61, 44, 31, 0.2);
    white-space: nowrap;
    transition: background 0.3s ease, color 0.3s ease;
}

.nav-item:hover {
    background: #b8860b;
    color: #f0ebe3;
}

.ring-1 {
    transform: translate(60px, -10px);
}

.ring-2 {
    transform: translate(50px, 30px);
}

.ring-3 {
    transform: translate(40px, 70px);
}

.ring-4 {
    transform: translate(30px, 110px);
}

.ring-5 {
    transform: translate(20px, 150px);
}

/* --- Floating Geometric Anchors --- */
.geo-anchor {
    position: fixed;
    z-index: 3;
    pointer-events: none;
    transition: transform 1.2s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.8s ease;
    opacity: 0;
}

.geo-anchor.visible {
    opacity: 1;
}

.geo-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(184, 134, 11, 0.6);
    top: 15%;
    right: 15%;
    animation: breathe 8s ease-in-out infinite, rotate 45s linear infinite;
}

.geo-triangle {
    width: 0;
    height: 0;
    border-left: 22px solid transparent;
    border-right: 22px solid transparent;
    border-bottom: 38px solid rgba(122, 139, 110, 0.7);
    bottom: 15%;
    left: 15%;
    animation: breathe 8s ease-in-out infinite 2s, rotate 45s linear infinite reverse;
}

.geo-square {
    width: 40px;
    height: 40px;
    background: rgba(74, 66, 56, 0.4);
    top: 15%;
    left: 15%;
    animation: breathe 8s ease-in-out infinite 4s, rotate 45s linear infinite;
}

.geo-anchor.centered {
    top: 50% !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translate(-50%, -50%) !important;
}

@keyframes breathe {
    0%, 100% { transform: scale(0.95); }
    50% { transform: scale(1.05); }
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* --- Chapter Base --- */
.chapter {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    display: flex;
    align-items: center;
}

.chapter-content {
    position: relative;
    z-index: 5;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 48px;
}

/* --- Chapter I: The Grid Awakens --- */
.chapter-1 {
    background-color: #f0ebe3;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    animation: heroBreath 12s ease-in-out infinite;
}

@keyframes heroBreath {
    0%, 100% { transform: scale(1.0); }
    50% { transform: scale(1.005); }
}

.hero-title {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: clamp(2rem, 8vw, 8rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #3d2c1f;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    display: flex;
    flex-wrap: wrap;
}

.char {
    display: inline-block;
    filter: blur(20px);
    opacity: 0;
    animation: charReveal 0.4s ease forwards;
    animation-delay: calc(0.6s + var(--i) * 0.08s);
}

@keyframes charReveal {
    from {
        filter: blur(20px);
        opacity: 0;
    }
    to {
        filter: blur(0);
        opacity: 1;
    }
}

.hero-subtitle {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-style: italic;
    font-size: 1.2rem;
    letter-spacing: 0.12em;
    text-transform: lowercase;
    color: rgba(61, 44, 31, 0.4);
    margin-top: 16px;
    grid-column: 2;
    opacity: 0;
    animation: fadeIn 1.2s ease forwards;
    animation-delay: 2s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* --- Chapter II: The Archetypes Emerge --- */
.chapter-2 {
    background-color: #f0ebe3;
}

.f-pattern {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: auto auto auto;
    gap: 32px 48px;
    align-items: start;
}

.f-stroke-1 {
    grid-column: 1 / 5;
    grid-row: 1;
}

.f-stroke-2 {
    grid-column: 1 / 4;
    grid-row: 2;
}

.f-downstroke {
    grid-column: 1 / 3;
    grid-row: 3;
}

.archetype-card {
    position: relative;
    width: 100%;
    max-width: 360px;
    min-height: 320px;
    padding: 40px 32px;
    background: rgba(240, 235, 227, 0.7);
    border: 1px solid rgba(61, 44, 31, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 16px;
}

.card-noise {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.06;
    pointer-events: none;
}

.card-shape {
    position: absolute;
    top: 32px;
    right: 32px;
}

.card-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(184, 134, 11, 0.6);
}

.card-triangle {
    width: 0;
    height: 0;
    border-left: 30px solid transparent;
    border-right: 30px solid transparent;
    border-bottom: 52px solid transparent;
    border-bottom-color: rgba(122, 139, 110, 0.7);
}

.card-square-shape {
    width: 50px;
    height: 50px;
    background: rgba(74, 66, 56, 0.4);
}

.card-title {
    font-family: 'Space Mono', monospace;
    font-weight: 400;
    font-size: clamp(1.4rem, 3vw, 2.4rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #3d2c1f;
    font-variant-numeric: tabular-nums;
    position: relative;
    z-index: 2;
}

.card-desc {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-style: italic;
    font-size: clamp(0.85rem, 1.5vw, 1.1rem);
    letter-spacing: 0.12em;
    text-transform: lowercase;
    color: #7a8b6e;
    line-height: 1.6;
    max-width: 38em;
    position: relative;
    z-index: 2;
}

/* --- Blur-Focus Target --- */
.blur-target {
    filter: blur(12px);
    opacity: 0.3;
    transition: filter 1.2s cubic-bezier(0.16, 1, 0.3, 1), opacity 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.blur-target.in-focus {
    filter: blur(0);
    opacity: 1;
}

/* --- Chapter III: The Mountain Emerges --- */
.chapter-3 {
    background: linear-gradient(to bottom, #f0ebe3, #4a4238);
    align-items: flex-end;
}

.mountain-layers {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60%;
    z-index: 2;
}

.mountain-layer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
}

.mountain-bg {
    height: 40%;
    background: #f0ebe3;
    opacity: 0.3;
    clip-path: polygon(0% 100%, 0% 60%, 8% 45%, 18% 55%, 28% 30%, 38% 50%, 48% 20%, 55% 35%, 65% 15%, 72% 40%, 80% 25%, 88% 45%, 95% 35%, 100% 50%, 100% 100%);
}

.mountain-mid {
    height: 50%;
    background: #c4bdb2;
    clip-path: polygon(0% 100%, 0% 70%, 5% 55%, 12% 65%, 22% 40%, 30% 55%, 42% 30%, 50% 45%, 58% 25%, 68% 50%, 75% 35%, 85% 55%, 92% 40%, 100% 60%, 100% 100%);
}

.mountain-fg {
    height: 35%;
    background: #4a4238;
    clip-path: polygon(0% 100%, 0% 65%, 10% 50%, 20% 60%, 30% 35%, 40% 55%, 50% 30%, 60% 50%, 70% 40%, 80% 55%, 90% 45%, 100% 55%, 100% 100%);
}

.chapter-3-content {
    position: relative;
    z-index: 5;
    padding-bottom: 15vh;
    text-align: center;
}

.mountain-text {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: clamp(1.1rem, 2.5vw, 1.6rem);
    letter-spacing: 0.06em;
    color: #f0ebe3;
    max-width: 700px;
    margin: 0 auto;
    line-height: 1.8;
}

/* --- Chapter IV: Dissolution --- */
.chapter-4 {
    background-color: #4a4238;
    align-items: center;
    justify-content: center;
}

.dissolution-content {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(3, auto);
    gap: 24px;
    min-height: 60vh;
    align-items: center;
}

.floating-fragment {
    transition: filter 2.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 2.4s ease;
}

.floating-fragment p {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-style: italic;
    letter-spacing: 0.12em;
    text-transform: lowercase;
    color: #c4bdb2;
    line-height: 1.6;
}

.frag-1 {
    grid-column: 1 / 4;
    grid-row: 1;
    transform: translate(12px, -8px);
}

.frag-1 p {
    font-size: clamp(1.2rem, 2.5vw, 2rem);
    color: #f0ebe3;
    opacity: 0.9;
}

.frag-2 {
    grid-column: 4 / 7;
    grid-row: 1;
    transform: translate(-20px, 16px);
}

.frag-2 p {
    font-size: clamp(0.9rem, 1.5vw, 1.2rem);
    opacity: 0.6;
}

.frag-3 {
    grid-column: 2 / 5;
    grid-row: 2;
    transform: translate(30px, -12px);
}

.frag-3 p {
    font-size: clamp(1.4rem, 3vw, 2.4rem);
    color: #d4a052;
    opacity: 0.85;
}

.frag-4 {
    grid-column: 1 / 3;
    grid-row: 3;
    transform: translate(-8px, 20px);
}

.frag-4 p {
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    opacity: 0.5;
}

.frag-5 {
    grid-column: 3 / 6;
    grid-row: 3;
    transform: translate(16px, -6px);
}

.frag-5 p {
    font-size: clamp(1rem, 1.8vw, 1.4rem);
    opacity: 0.7;
}

.frag-6 {
    grid-column: 5 / 7;
    grid-row: 2;
    transform: translate(-12px, 10px);
}

.frag-6 p {
    font-size: clamp(0.9rem, 1.4vw, 1.1rem);
    opacity: 0.55;
}

/* Composite Sigil */
.composite-sigil {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120px;
    height: 120px;
    z-index: 4;
    opacity: 0;
    transition: opacity 1.5s ease;
}

.composite-sigil.visible {
    opacity: 1;
}

.comp-square {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100px;
    height: 100px;
    border: 1.5px solid #d4a052;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 40px rgba(212, 160, 82, 0.3);
}

.comp-triangle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -55%);
    width: 0;
    height: 0;
    border-left: 40px solid transparent;
    border-right: 40px solid transparent;
    border-bottom: 70px solid transparent;
    border-bottom-color: rgba(212, 160, 82, 0.4);
}

.comp-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 1.5px solid #d4a052;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 25px rgba(212, 160, 82, 0.25);
}

/* --- Chapter V: Return to Light --- */
.chapter-5 {
    background: linear-gradient(to bottom, #4a4238, #f0ebe3 40%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.return-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 24px;
    padding: 0 48px;
}

.return-sigil {
    position: relative;
    width: 100px;
    height: 100px;
    margin-bottom: 32px;
}

.ret-square {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 80px;
    height: 80px;
    border: 1.5px solid #3d2c1f;
    transform: translate(-50%, -50%);
}

.ret-triangle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -55%);
    width: 0;
    height: 0;
    border-left: 32px solid transparent;
    border-right: 32px solid transparent;
    border-bottom: 56px solid transparent;
    border-bottom-color: rgba(61, 44, 31, 0.3);
}

.ret-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1.5px solid #3d2c1f;
    transform: translate(-50%, -50%);
}

.return-title {
    font-family: 'Space Mono', monospace;
    font-weight: 400;
    font-size: clamp(1.4rem, 3vw, 2rem);
    letter-spacing: 0.06em;
    color: #3d2c1f;
}

.return-whisper {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-style: italic;
    font-size: clamp(0.85rem, 1.5vw, 1.1rem);
    letter-spacing: 0.12em;
    text-transform: lowercase;
    color: rgba(61, 44, 31, 0.5);
    max-width: 500px;
    line-height: 1.7;
}

.return-spacer {
    height: 20vh;
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    .char {
        animation: fadeIn 0.4s ease forwards;
        animation-delay: calc(0.6s + var(--i) * 0.04s);
    }

    .blur-target {
        filter: none;
        opacity: 0.3;
        transition: opacity 0.8s ease;
    }

    .blur-target.in-focus {
        filter: none;
        opacity: 1;
    }

    .geo-circle,
    .geo-triangle,
    .geo-square {
        animation: none;
    }

    .chapter-1 {
        animation: none;
    }

    @keyframes charReveal {
        from { opacity: 0; }
        to { opacity: 1; }
    }
}

/* --- Mobile Adaptation --- */
@media (max-width: 768px) {
    .grid-overlay {
        grid-template-columns: repeat(3, 1fr);
        padding: 0 24px;
    }

    .grid-line:nth-child(n+4):not(:last-child) {
        display: none;
    }

    .chapter-content {
        padding: 0 24px;
    }

    .hero-title {
        font-size: clamp(2rem, 10vw, 4rem);
    }

    .f-pattern {
        grid-template-columns: repeat(2, 1fr);
        gap: 24px;
    }

    .f-stroke-1 {
        grid-column: 1 / -1;
    }

    .f-stroke-2 {
        grid-column: 1 / -1;
    }

    .f-downstroke {
        grid-column: 1 / -1;
    }

    .archetype-card {
        max-width: 100%;
        min-height: 260px;
    }

    .geo-circle {
        width: 29px;
        height: 29px;
    }

    .geo-triangle {
        border-left-width: 13px;
        border-right-width: 13px;
        border-bottom-width: 23px;
    }

    .geo-square {
        width: 24px;
        height: 24px;
    }

    .dissolution-content {
        grid-template-columns: 1fr 1fr;
    }

    .frag-1 { grid-column: 1 / -1; grid-row: 1; }
    .frag-2 { grid-column: 1 / -1; grid-row: 2; }
    .frag-3 { grid-column: 1 / -1; grid-row: 3; }
    .frag-4 { grid-column: 1; grid-row: 4; }
    .frag-5 { grid-column: 2; grid-row: 4; }
    .frag-6 { grid-column: 1 / -1; grid-row: 5; }

    .sigil {
        top: 16px;
        left: 16px;
    }

    .ring-1 { transform: translate(50px, -5px); }
    .ring-2 { transform: translate(40px, 30px); }
    .ring-3 { transform: translate(30px, 65px); }
    .ring-4 { transform: translate(20px, 100px); }
    .ring-5 { transform: translate(10px, 135px); }

    .mountain-text {
        max-width: 90%;
    }
}
