/* ============================================
   archetypic.dev — Styles
   A surrealist dreamscape portal
   ============================================ */

/* --- CSS Custom Properties (Animated) --- */
@property --grad-x1 {
    syntax: '<percentage>';
    initial-value: 20%;
    inherits: false;
}
@property --grad-y1 {
    syntax: '<percentage>';
    initial-value: 30%;
    inherits: false;
}
@property --grad-x2 {
    syntax: '<percentage>';
    initial-value: 70%;
    inherits: false;
}
@property --grad-y2 {
    syntax: '<percentage>';
    initial-value: 60%;
    inherits: false;
}
@property --grad-x3 {
    syntax: '<percentage>';
    initial-value: 50%;
    inherits: false;
}
@property --grad-y3 {
    syntax: '<percentage>';
    initial-value: 80%;
    inherits: false;
}
@property --grad-x4 {
    syntax: '<percentage>';
    initial-value: 85%;
    inherits: false;
}
@property --grad-y4 {
    syntax: '<percentage>';
    initial-value: 20%;
    inherits: false;
}
@property --grad-x5 {
    syntax: '<percentage>';
    initial-value: 10%;
    inherits: false;
}
@property --grad-y5 {
    syntax: '<percentage>';
    initial-value: 70%;
    inherits: false;
}
@property --grad-x6 {
    syntax: '<percentage>';
    initial-value: 60%;
    inherits: false;
}
@property --grad-y6 {
    syntax: '<percentage>';
    initial-value: 15%;
    inherits: false;
}

/* --- Color Palette Reference ---
   Void:            #0B0E1A
   Parchment:       #F0E6D3
   Muted Gold:      #C8BDA8
   Aurora Teal:     #6FCFBF
   Aurora Violet:   #9B7ECF
   Dream Rose:      #CF7E8B
   Deep Indigo:     #161B33
   Filament Silver: #A0A8BF
   -------------------------------- */

:root {
    --color-void: #0B0E1A;
    --color-parchment: #F0E6D3;
    --color-muted-gold: #C8BDA8;
    --color-aurora-teal: #6FCFBF;
    --color-aurora-violet: #9B7ECF;
    --color-dream-rose: #CF7E8B;
    --color-deep-indigo: #161B33;
    --color-filament-silver: #A0A8BF;
}

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

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

body {
    background-color: #0B0E1A;
    color: #C8BDA8;
    font-family: 'Outfit', sans-serif;
    font-weight: 300;
    font-size: clamp(0.95rem, 1.8vw, 1.15rem);
    line-height: 1.75;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Deep Layer: Gradient Mesh --- */
.deep-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -2;
    animation: meshDrift1 120s ease-in-out infinite,
               meshDrift2 90s ease-in-out infinite,
               meshDrift3 100s ease-in-out infinite,
               meshDrift4 80s ease-in-out infinite,
               meshDrift5 110s ease-in-out infinite,
               meshDrift6 95s ease-in-out infinite;
    background:
        radial-gradient(ellipse 50% 50% at var(--grad-x1) var(--grad-y1), rgba(111, 207, 191, 0.18) 0%, transparent 70%),
        radial-gradient(ellipse 45% 55% at var(--grad-x2) var(--grad-y2), rgba(155, 126, 207, 0.15) 0%, transparent 65%),
        radial-gradient(ellipse 55% 45% at var(--grad-x3) var(--grad-y3), rgba(207, 126, 139, 0.12) 0%, transparent 60%),
        radial-gradient(ellipse 40% 50% at var(--grad-x4) var(--grad-y4), rgba(111, 207, 191, 0.10) 0%, transparent 55%),
        radial-gradient(ellipse 50% 40% at var(--grad-x5) var(--grad-y5), rgba(155, 126, 207, 0.12) 0%, transparent 60%),
        radial-gradient(ellipse 45% 45% at var(--grad-x6) var(--grad-y6), rgba(207, 126, 139, 0.10) 0%, transparent 55%),
        #0B0E1A;
}

@keyframes meshDrift1 {
    0%, 100% { --grad-x1: 20%; --grad-y1: 30%; }
    25% { --grad-x1: 45%; --grad-y1: 15%; }
    50% { --grad-x1: 65%; --grad-y1: 55%; }
    75% { --grad-x1: 30%; --grad-y1: 70%; }
}
@keyframes meshDrift2 {
    0%, 100% { --grad-x2: 70%; --grad-y2: 60%; }
    25% { --grad-x2: 40%; --grad-y2: 80%; }
    50% { --grad-x2: 25%; --grad-y2: 40%; }
    75% { --grad-x2: 80%; --grad-y2: 25%; }
}
@keyframes meshDrift3 {
    0%, 100% { --grad-x3: 50%; --grad-y3: 80%; }
    25% { --grad-x3: 75%; --grad-y3: 50%; }
    50% { --grad-x3: 30%; --grad-y3: 20%; }
    75% { --grad-x3: 60%; --grad-y3: 65%; }
}
@keyframes meshDrift4 {
    0%, 100% { --grad-x4: 85%; --grad-y4: 20%; }
    25% { --grad-x4: 55%; --grad-y4: 45%; }
    50% { --grad-x4: 20%; --grad-y4: 75%; }
    75% { --grad-x4: 70%; --grad-y4: 35%; }
}
@keyframes meshDrift5 {
    0%, 100% { --grad-x5: 10%; --grad-y5: 70%; }
    25% { --grad-x5: 35%; --grad-y5: 30%; }
    50% { --grad-x5: 80%; --grad-y5: 55%; }
    75% { --grad-x5: 45%; --grad-y5: 85%; }
}
@keyframes meshDrift6 {
    0%, 100% { --grad-x6: 60%; --grad-y6: 15%; }
    25% { --grad-x6: 25%; --grad-y6: 60%; }
    50% { --grad-x6: 75%; --grad-y6: 85%; }
    75% { --grad-x6: 90%; --grad-y6: 40%; }
}

/* Gradient mesh color shift overlays for chamber dominance */
.deep-layer::before,
.deep-layer::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 2s ease;
    pointer-events: none;
}

.deep-layer.dominant-violet::before {
    background: radial-gradient(ellipse 60% 60% at 50% 50%, rgba(155, 126, 207, 0.2) 0%, transparent 70%);
    opacity: 1;
}

.deep-layer.dominant-rose::before {
    background: radial-gradient(ellipse 60% 60% at 50% 50%, rgba(207, 126, 139, 0.2) 0%, transparent 70%);
    opacity: 1;
}

.deep-layer.dominant-teal::before {
    background: radial-gradient(ellipse 60% 60% at 50% 50%, rgba(111, 207, 191, 0.15) 0%, transparent 70%);
    opacity: 1;
}

.deep-layer.dominant-all::before {
    background:
        radial-gradient(ellipse 40% 40% at 30% 40%, rgba(111, 207, 191, 0.18) 0%, transparent 70%),
        radial-gradient(ellipse 40% 40% at 70% 30%, rgba(155, 126, 207, 0.18) 0%, transparent 70%),
        radial-gradient(ellipse 40% 40% at 50% 70%, rgba(207, 126, 139, 0.18) 0%, transparent 70%);
    opacity: 1;
}

/* --- Near Layer: Filaments --- */
.near-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10;
    pointer-events: none;
}

.filament {
    fill: none;
    stroke: #A0A8BF;
    stroke-width: 1;
    opacity: 0.25;
    stroke-linecap: round;
}

/* --- Constellation Navigation --- */
#constellation-nav {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    align-items: center;
}

.nav-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #A0A8BF;
    border: none;
    cursor: pointer;
    position: relative;
    opacity: 0.4;
    transition: opacity 0.6s ease, transform 0.3s ease, box-shadow 0.6s ease;
}

.nav-dot:hover {
    opacity: 0.8;
    transform: scale(1.4);
}

.nav-dot.active {
    opacity: 1;
    box-shadow: 0 0 12px rgba(111, 207, 191, 0.6), 0 0 24px rgba(111, 207, 191, 0.3);
    background: #6FCFBF;
    animation: dotPulse 3s ease-in-out infinite;
}

@keyframes dotPulse {
    0%, 100% { box-shadow: 0 0 12px rgba(111, 207, 191, 0.6), 0 0 24px rgba(111, 207, 191, 0.3); }
    50% { box-shadow: 0 0 18px rgba(111, 207, 191, 0.8), 0 0 36px rgba(111, 207, 191, 0.5); }
}

.nav-tooltip {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    white-space: nowrap;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: #6FCFBF;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, right 0.3s ease;
}

.nav-dot:hover .nav-tooltip {
    opacity: 1;
    right: 24px;
}

/* --- Middle Layer: Content --- */
.middle-layer {
    position: relative;
    z-index: 1;
}

/* --- Chamber Base --- */
.chamber {
    min-height: 120vh;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.chamber-content {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 1200px;
    padding: 2rem;
}

/* --- Sigils --- */
.sigil {
    position: absolute;
    z-index: 1;
    opacity: 0.08;
    pointer-events: none;
}

.sigil-threshold,
.sigil-return {
    width: 50vw;
    height: 50vw;
    max-width: 500px;
    max-height: 500px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.sigil-mirror {
    width: 55vw;
    height: 55vw;
    max-width: 550px;
    max-height: 550px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.sigil-forge {
    width: 45vw;
    height: 45vw;
    max-width: 480px;
    max-height: 480px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.sigil-library {
    width: 50vw;
    height: 50vw;
    max-width: 520px;
    max-height: 520px;
    top: 25%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Sigil stroke animation */
.sigil line,
.sigil circle,
.sigil polygon,
.sigil rect,
.sigil path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 3s ease-in-out;
}

.chamber.in-view .sigil line,
.chamber.in-view .sigil circle,
.chamber.in-view .sigil polygon,
.chamber.in-view .sigil rect,
.chamber.in-view .sigil path {
    stroke-dashoffset: 0;
}

/* --- Typography --- */
h1, h2 {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-style: italic;
    color: #F0E6D3;
    letter-spacing: 0.08em;
    line-height: 1.1;
    text-shadow: 0 0 40px rgba(111, 207, 191, 0.3);
}

h2 {
    font-size: clamp(2.2rem, 6vw, 5rem);
    margin-bottom: 1rem;
}

p {
    max-width: 38ch;
    color: #C8BDA8;
}

/* --- Cards --- */
.card {
    background: rgba(22, 27, 51, 0.7);
    clip-path: var(--clip);
    padding: clamp(2rem, 4vw, 3.5rem);
    border: none;
    position: relative;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: transform 1.2s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Card outline effect via box-shadow and before pseudo */
.card::before {
    content: '';
    position: absolute;
    inset: 0;
    clip-path: inherit;
    border: 1px solid rgba(160, 168, 191, 0.15);
    pointer-events: none;
    transition: border-color 0.6s ease, box-shadow 0.6s ease;
}

.card:hover::before {
    border-color: rgba(111, 207, 191, 0.5);
    box-shadow: inset 0 0 30px rgba(111, 207, 191, 0.08);
}

.card-label {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: #6FCFBF;
    display: block;
    margin-bottom: 0.75rem;
}

/* --- Card entrance animations --- */
.card {
    opacity: 0;
    transform: translateX(80px) rotate(3deg) scale(0.92);
}

.card.card-mirror-right,
.card.card-forge-2 {
    transform: translateX(-80px) rotate(-3deg) scale(0.92);
}

.card.card-forge-3 {
    transform: translateY(60px) rotate(-5deg) scale(0.92);
}

.card.card-library {
    transform: translateY(60px) scale(0.95);
    opacity: 0;
}

.chamber.in-view .card {
    opacity: 1;
    transform: translateX(0) rotate(var(--rotate, 0deg)) scale(1);
}

/* Staggered entrance for forge cards */
.chamber.in-view .card-forge-1 {
    transition-delay: 0s;
}
.chamber.in-view .card-forge-2 {
    transition-delay: 0.4s;
}
.chamber.in-view .card-forge-3 {
    transition-delay: 0.8s;
}

/* --- Chamber 1: The Threshold --- */
.threshold-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 80vh;
}

.threshold-title {
    font-size: clamp(4rem, 12vw, 10rem);
    color: #F0E6D3;
    text-shadow: 0 0 60px rgba(111, 207, 191, 0.35), 0 0 120px rgba(111, 207, 191, 0.15);
    margin-bottom: 1.5rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 2s ease, transform 2s ease;
}

.chamber.in-view .threshold-title {
    opacity: 1;
    transform: translateY(0);
}

.threshold-subtitle {
    font-family: 'Outfit', sans-serif;
    font-weight: 300;
    font-size: clamp(1rem, 2.5vw, 1.4rem);
    color: #C8BDA8;
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 2s ease 0.6s, transform 2s ease 0.6s;
    max-width: none;
}

.chamber.in-view .threshold-subtitle {
    opacity: 1;
    transform: translateY(0);
}

.scroll-chevron {
    position: absolute;
    bottom: 4vh;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    animation: chevronPulse 2.5s ease-in-out infinite;
}

.chevron-arrow {
    display: block;
    width: 24px;
    height: 24px;
    border-right: 2px solid #A0A8BF;
    border-bottom: 2px solid #A0A8BF;
    transform: rotate(45deg);
    opacity: 0.5;
}

@keyframes chevronPulse {
    0%, 100% { opacity: 0.3; transform: translateX(-50%) translateY(0); }
    50% { opacity: 0.7; transform: translateX(-50%) translateY(8px); }
}

/* --- Chamber 2: The Mirror --- */
.mirror-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3rem;
    min-height: 80vh;
}

.card-mirror-left,
.card-mirror-right {
    flex: 0 1 420px;
    min-height: 320px;
}

/* --- Chamber 3: The Forge --- */
.forge-content {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 2.5rem;
    min-height: 80vh;
}

.card-forge-1 {
    flex: 0 1 360px;
    transform: rotate(-3deg);
    align-self: flex-start;
    margin-top: 5vh;
}

.card-forge-2 {
    flex: 0 1 340px;
    transform: rotate(5deg);
    align-self: center;
}

.card-forge-3 {
    flex: 0 1 350px;
    transform: rotate(-7deg);
    align-self: flex-end;
    margin-bottom: 5vh;
}

/* --- Chamber 4: The Library --- */
.library-content {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    min-height: 80vh;
    padding-bottom: 10vh;
}

.card-library {
    width: 70vw;
    max-width: 900px;
}

.library-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2.5rem;
}

.library-columns p {
    max-width: none;
}

/* --- Chamber 5: The Return --- */
.return-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    text-align: center;
    min-height: 80vh;
    padding-bottom: 15vh;
}

.return-filament-up {
    width: 2px;
    height: 200px;
    margin-bottom: 3rem;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 2s ease 0.3s, transform 2s ease 0.3s;
}

.chamber.in-view .return-filament-up {
    opacity: 0.4;
    transform: translateY(0);
}

.return-filament-svg {
    width: 100%;
    height: 100%;
}

.return-filament-svg line {
    stroke: #A0A8BF;
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    transition: stroke-dashoffset 2.5s ease;
}

.chamber.in-view .return-filament-svg line {
    stroke-dashoffset: 0;
}

.return-title {
    font-size: clamp(3rem, 10vw, 8rem);
    color: #F0E6D3;
    text-shadow: 0 0 60px rgba(111, 207, 191, 0.35), 0 0 120px rgba(111, 207, 191, 0.15);
    margin-bottom: 1.5rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 2s ease 0.5s, transform 2s ease 0.5s;
}

.chamber.in-view .return-title {
    opacity: 1;
    transform: translateY(0);
}

.return-subtitle {
    font-family: 'Outfit', sans-serif;
    font-weight: 300;
    font-size: clamp(1rem, 2.5vw, 1.4rem);
    color: #C8BDA8;
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 2s ease 1s, transform 2s ease 1s;
    max-width: none;
}

.chamber.in-view .return-subtitle {
    opacity: 1;
    transform: translateY(0);
}

/* --- Blur-focus transition between chambers --- */
.middle-layer {
    transition: filter 0.3s ease;
}

.middle-layer.blur-transition {
    filter: blur(4px);
}

/* --- All nav dots glow in final chamber --- */
.nav-all-glow .nav-dot {
    opacity: 1;
    box-shadow: 0 0 12px rgba(111, 207, 191, 0.5), 0 0 24px rgba(111, 207, 191, 0.25);
    background: #6FCFBF;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .mirror-content {
        flex-direction: column;
        gap: 2rem;
    }

    .card-mirror-left,
    .card-mirror-right {
        flex: 0 1 auto;
        width: 85vw;
    }

    .forge-content {
        flex-direction: column;
        align-items: center;
    }

    .card-forge-1,
    .card-forge-2,
    .card-forge-3 {
        flex: 0 1 auto;
        width: 85vw;
        margin-top: 0;
        margin-bottom: 0;
    }

    .card-library {
        width: 90vw;
    }

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

    #constellation-nav {
        top: 1rem;
        right: 1rem;
        gap: 0.9rem;
    }

    .nav-tooltip {
        display: none;
    }
}
