/* ===================================================
   archetypic.dev - Surreal Dreamscape
   A descent through Jungian layers of consciousness
   =================================================== */

/* --- Phase Palette CSS Variables --- */
:root {
    /* Phase 1 - Persona (default) */
    --bg: #f0ece2;
    --text: #2d2a32;
    --accent: #7c5e99;

    /* Persistent colors */
    --link-hover: #d4a843;
    --code-bg: rgba(0, 0, 0, 0.3);
    --border-color: rgba(124, 94, 153, 0.2);

    /* Phase palettes stored for JS interpolation */
    --phase1-bg: #f0ece2;
    --phase1-text: #2d2a32;
    --phase1-accent: #7c5e99;

    --phase2-bg: #1e1b2e;
    --phase2-text: #b8b0c8;
    --phase2-accent: #c44e3f;

    --phase3-bg: #0f1a2e;
    --phase3-text: #8ec8d8;
    --phase3-accent: #d4a843;

    --phase4-bg: #0a0a14;
    --phase4-text: #e8e0f0;
    --phase4-accent: #ffffff;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Questrial', sans-serif;
    font-size: 1rem;
    line-height: 1.75;
    font-weight: 400;
    background-color: var(--bg);
    color: var(--text);
    overflow-x: hidden;
    transition: background-color 0.05s linear, color 0.05s linear;
}

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

/* --- Typography --- */
h1, h2, h3 {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
}

h2 {
    font-size: clamp(2rem, 5vw, 5rem);
    margin-bottom: 0.5em;
}

h3 {
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    margin-bottom: 0.4em;
}

code, .code-snippet {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    font-feature-settings: "liga" 1;
    background: var(--code-bg);
    padding: 0.15em 0.5em;
    border-radius: 3px;
    color: var(--accent);
    display: inline-block;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--link-hover);
}

/* --- Fixed Navigation Dots --- */
#nav-dots {
    position: fixed;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    z-index: 1000;
}

.nav-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--border-color);
    z-index: -1;
}

.nav-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--accent);
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.6s ease, border-color 0.6s ease;
    color: var(--accent);
    padding: 0;
}

.nav-dot.active {
    background-color: var(--accent);
    color: var(--bg);
}

.nav-dot svg {
    display: block;
}

/* --- Floating Symbols --- */
#floating-symbols {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
    overflow: hidden;
}

.float-symbol {
    position: absolute;
    font-size: 1.5rem;
    opacity: 0.12;
    animation: floatDrift 30s ease-in-out infinite;
}

.float-symbol:nth-child(1) {
    left: 10%;
    top: 20%;
    animation-delay: 0s;
    animation-duration: 25s;
}

.float-symbol:nth-child(2) {
    left: 75%;
    top: 50%;
    animation-delay: -7s;
    animation-duration: 35s;
}

.float-symbol:nth-child(3) {
    left: 40%;
    top: 70%;
    animation-delay: -14s;
    animation-duration: 40s;
}

@keyframes floatDrift {
    0%, 100% {
        transform: translate(0, 0) rotate(0deg);
    }
    25% {
        transform: translate(40px, -60px) rotate(5deg);
    }
    50% {
        transform: translate(-30px, -20px) rotate(-3deg);
    }
    75% {
        transform: translate(20px, 40px) rotate(2deg);
    }
}

/* --- Noise Overlay --- */
.noise-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.06;
    filter: url(#noise);
    pointer-events: none;
    z-index: 1;
}

/* ===================================================
   THE THRESHOLD (Hero)
   =================================================== */
.section-hero {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.archway-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: breathe 8s ease-in-out infinite;
}

@keyframes breathe {
    0%, 100% { transform: translate(-50%, -50%) scale(1.0); }
    50% { transform: translate(-50%, -50%) scale(1.008); }
}

.archway-layer {
    position: absolute;
    border: 1px solid var(--accent);
    transform: rotate(calc(var(--depth) * 0.6deg));
    opacity: calc(1 - (var(--depth) - 1) * 0.06);
}

.archway-layer:nth-child(1)  { width: 70vmin; height: 85vmin; }
.archway-layer:nth-child(2)  { width: 64vmin; height: 78vmin; }
.archway-layer:nth-child(3)  { width: 58vmin; height: 71vmin; }
.archway-layer:nth-child(4)  { width: 52vmin; height: 64vmin; }
.archway-layer:nth-child(5)  { width: 46vmin; height: 57vmin; }
.archway-layer:nth-child(6)  { width: 40vmin; height: 50vmin; }
.archway-layer:nth-child(7)  { width: 34vmin; height: 43vmin; }
.archway-layer:nth-child(8)  { width: 28vmin; height: 36vmin; }
.archway-layer:nth-child(9)  { width: 22vmin; height: 29vmin; }
.archway-layer:nth-child(10) { width: 16vmin; height: 22vmin; }
.archway-layer:nth-child(11) { width: 10vmin; height: 15vmin; }
.archway-layer:nth-child(12) {
    width: 6vmin;
    height: 10vmin;
    background: rgba(0, 0, 0, 0.3);
}

.hero-text {
    position: relative;
    z-index: 10;
    text-align: center;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeReveal 2s ease-out 0.5s forwards;
}

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

.hero-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(2rem, 5vw, 5rem);
    font-weight: 300;
    letter-spacing: 0.05em;
    opacity: 0.85;
    color: var(--text);
}

.hero-subtitle {
    font-family: 'Questrial', sans-serif;
    font-size: clamp(0.9rem, 1.5vw, 1.2rem);
    margin-top: 1rem;
    opacity: 0.6;
    letter-spacing: 0.1em;
}

/* ===================================================
   PHASE SECTIONS - Common
   =================================================== */
.phase-section {
    position: relative;
    min-height: 100vh;
    padding: clamp(4rem, 8vh, 8rem) clamp(2rem, 5vw, 6rem);
    display: flex;
    align-items: center;
    justify-content: center;
}

.phase-content {
    position: relative;
    z-index: 2;
    max-width: 1100px;
    width: 100%;
}

.phase-title {
    text-align: center;
    color: var(--text);
    letter-spacing: 0.04em;
}

.phase-subtitle {
    text-align: center;
    font-style: italic;
    opacity: 0.6;
    margin-bottom: 3rem;
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
}

/* Mini archway section headers */
.section-archway-header {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.mini-archway {
    position: relative;
    width: 60px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mini-arch-layer {
    position: absolute;
    border: 1px solid var(--accent);
    transform: rotate(calc(var(--depth) * 0.6deg));
    opacity: 0.5;
}

.mini-arch-layer:nth-child(1) { width: 50px; height: 70px; }
.mini-arch-layer:nth-child(2) { width: 36px; height: 52px; }
.mini-arch-layer:nth-child(3) { width: 22px; height: 34px; }

/* ===================================================
   PHASE 1: PERSONA - Clean, structured, sharp
   =================================================== */
.persona-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
}

.persona-card {
    padding: 2rem;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.04);
    transition: transform 0.3s ease, border-color 0.3s ease;
}

.persona-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
}

.persona-card h3 {
    color: var(--accent);
}

.persona-card p {
    margin-bottom: 1rem;
    opacity: 0.85;
}

/* ===================================================
   TRANSITION ZONES
   =================================================== */
.transition-zone {
    position: relative;
    height: 200vh;
    overflow: hidden;
}

.transition-noise {
    opacity: 0.07;
    animation: noiseShift 10s ease-in-out infinite alternate;
}

@keyframes noiseShift {
    0% { transform: scale(1) translate(0, 0); }
    100% { transform: scale(1.1) translate(10px, 10px); }
}

/* ===================================================
   PHASE 2: SHADOW - Asymmetric, dark, unsettling
   =================================================== */
.shadow-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2.5rem;
    max-width: 800px;
    margin: 0 auto;
}

.shadow-card {
    position: relative;
    padding: 2rem;
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.15);
}

/* Shadow double effect */
.shadow-card::after {
    content: '';
    position: absolute;
    inset: 0;
    transform: translate(6px, 6px);
    border: 1px solid var(--accent);
    opacity: 0.15;
    z-index: -1;
    background: var(--accent);
    mix-blend-mode: multiply;
}

/* Slight asymmetric misalignment */
.shadow-card:nth-child(1) { transform: translateX(-2px); }
.shadow-card:nth-child(2) { transform: translateX(3px); }
.shadow-card:nth-child(3) { transform: translateX(-1px) rotate(-0.2deg); }

.shadow-card h3 {
    color: var(--accent);
}

.shadow-card p {
    margin-bottom: 1rem;
    opacity: 0.85;
}

/* ===================================================
   THE MIRROR ZONE
   =================================================== */
.mirror-section {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.mirror-original {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 4rem 2rem;
}

.mirror-content-inner {
    max-width: 700px;
    margin: 0 auto;
}

.mirror-text {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(1.4rem, 3vw, 2.4rem);
    font-weight: 300;
    font-style: italic;
    line-height: 1.6;
    color: var(--text);
}

.mirror-attribution {
    display: block;
    margin-top: 1.5rem;
    font-family: 'Questrial', sans-serif;
    font-size: 0.9rem;
    opacity: 0.5;
}

/* Reflection pool - dark water */
.reflection-pool {
    width: 100%;
    height: 4px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(124, 94, 153, 0.15) 20%,
        rgba(124, 94, 153, 0.25) 50%,
        rgba(124, 94, 153, 0.15) 80%,
        transparent 100%
    );
    margin: 1rem 0;
}

/* Reflected content */
.mirror-reflected {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 4rem 2rem;
    transform: scaleY(-1);
    opacity: 0.2;
    mask-image: linear-gradient(to bottom, rgba(0,0,0,0.5) 0%, transparent 80%);
    -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,0.5) 0%, transparent 80%);
}

.mirror-gradient-mask {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(to bottom, transparent 0%, var(--bg) 80%);
    pointer-events: none;
    z-index: 3;
}

/* ===================================================
   PHASE 3: ANIMA/ANIMUS - Split, dualistic, mirrored
   =================================================== */
.anima-split {
    display: flex;
    gap: 0;
    align-items: stretch;
}

.anima-left,
.anima-right {
    flex: 1;
    padding: 2.5rem;
}

.anima-left {
    text-align: right;
    border-right: none;
}

.anima-right {
    text-align: left;
    border-left: none;
}

.anima-divider {
    width: 1px;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        var(--accent) 30%,
        var(--accent) 70%,
        transparent 100%
    );
    flex-shrink: 0;
}

.anima-left h3,
.anima-right h3 {
    color: var(--accent);
}

.anima-left p,
.anima-right p {
    opacity: 0.85;
    margin-bottom: 1rem;
}

/* ===================================================
   PHASE 4: SELF - Centered, resolved, harmonious
   =================================================== */
#self {
    display: flex;
    align-items: center;
    justify-content: center;
}

.mandala-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 500px;
    height: 500px;
    z-index: 0;
    opacity: 0.15;
}

.mandala {
    position: relative;
    width: 100%;
    height: 100%;
    animation: mandala-spin 120s linear infinite;
}

@keyframes mandala-spin {
    to { transform: rotate(360deg); }
}

.mandala-line {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--accent) 20%,
        var(--accent) 80%,
        transparent 100%
    );
    transform-origin: center center;
    transform: translate(-50%, -50%) rotate(calc(var(--i) * 30deg));
    mix-blend-mode: screen;
}

.mandala-line::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60%;
    height: 60%;
    border: 1px solid var(--accent);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.3;
}

.self-content {
    position: relative;
    z-index: 2;
    text-align: center;
    max-width: 700px;
}

.self-centered p {
    margin-bottom: 1.5rem;
    opacity: 0.85;
}

.self-cta {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.self-glyph {
    font-family: 'Noto Sans Symbols 2', sans-serif;
    font-size: 2.5rem;
    display: block;
    margin-bottom: 1rem;
    color: var(--accent);
}

.self-final {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(1.2rem, 2vw, 1.6rem);
    font-weight: 300;
    font-style: italic;
    opacity: 0.7;
    margin-bottom: 1.5rem;
}

/* ===================================================
   RESPONSIVE
   =================================================== */
@media (max-width: 768px) {
    .persona-grid {
        grid-template-columns: 1fr;
    }

    .anima-split {
        flex-direction: column;
    }

    .anima-left {
        text-align: left;
        border-right: none;
    }

    .anima-divider {
        width: 100%;
        height: 1px;
        background: linear-gradient(
            to right,
            transparent 0%,
            var(--accent) 30%,
            var(--accent) 70%,
            transparent 100%
        );
    }

    /* Simplify archway to 6 layers on mobile */
    .archway-layer:nth-child(n+7) {
        display: none;
    }

    /* Simplify mirror zone on mobile */
    .mirror-reflected {
        display: none;
    }

    /* Nav dots at bottom on mobile */
    #nav-dots {
        top: auto;
        bottom: 16px;
        right: 50%;
        transform: translateX(50%);
        flex-direction: row;
    }

    .nav-line {
        top: 50%;
        bottom: auto;
        left: 0;
        right: 0;
        width: auto;
        height: 1px;
    }

    .mandala-container {
        width: 300px;
        height: 300px;
    }
}

@media (max-width: 480px) {
    .phase-section {
        padding: 3rem 1.5rem;
    }

    .persona-card,
    .shadow-card {
        padding: 1.5rem;
    }
}

/* ===================================================
   SELECTION
   =================================================== */
::selection {
    background: var(--accent);
    color: var(--bg);
}
