/* ============================================
   ARCHETYPOS.DEV - Styles
   Alchemical color system + Jungian archetypes
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --nigredo-void: #0e0b16;
    --albedo-stone: #c8c2d6;
    --citrinitas-gold: #d4a843;
    --rubedo-crimson: #8b2d3a;
    --lapis-depth: #1e1640;
    --quicksilver: #9590a8;
    --parchment-edge: #e8dcc8;
    --ultraviolet-aura: #4a2d7a;
    --lapis-mid: #2a1f3d;
    --annotation: #706690;
}

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

html {
    scroll-behavior: smooth;
    scroll-snap-type: y mandatory;
    overflow-x: hidden;
}

body {
    background-color: var(--nigredo-void);
    color: var(--albedo-stone);
    font-family: 'Crimson Text', Georgia, serif;
    font-size: 17px;
    line-height: 1.75;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- Background Mandala Layer (z:0) --- */
#mandala-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

#mandala-svg {
    width: 90vmin;
    height: 90vmin;
    opacity: 0.3;
    animation: mandala-rotate 3600s linear infinite;
}

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

/* --- Connection Threads Layer (z:2) --- */
#connection-threads {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

#connection-threads line {
    stroke: var(--ultraviolet-aura);
    stroke-width: 0.5;
    stroke-dasharray: 4 2;
    opacity: 0.3;
    transition: opacity 800ms ease-out, stroke 800ms ease-out;
}

#connection-threads line.highlighted {
    stroke: var(--citrinitas-gold);
    opacity: 0.7;
}

#connection-threads line.dimmed {
    opacity: 0.05;
}

/* --- Section 1: The Threshold --- */
#threshold {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    scroll-snap-align: start;
    overflow: hidden;
}

#threshold-content {
    text-align: center;
    position: relative;
    z-index: 1;
}

#title-archetypos {
    font-family: 'Cormorant Garamond', 'Garamond', serif;
    font-weight: 600;
    font-size: clamp(5rem, 12vw, 10rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--albedo-stone);
    line-height: 1.1;
    margin-bottom: 2rem;
}

.title-letter {
    display: inline-block;
    opacity: 0;
    transition: color 600ms ease-out;
    position: relative;
}

.title-letter.visible {
    opacity: 1;
    animation: letter-appear 400ms ease-out forwards;
}

.title-letter.morphing {
    animation: letter-morph 4s ease-in-out forwards;
}

.title-letter.scattered {
    transition: transform 2s ease-out, opacity 2s ease-out;
    opacity: 0;
}

@keyframes letter-appear {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes letter-morph {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); filter: blur(1px); }
    100% { transform: scale(1); }
}

#subtitle {
    font-family: 'EB Garamond', 'Georgia', serif;
    font-style: italic;
    font-size: 20px;
    color: var(--albedo-stone);
    opacity: 0;
    transition: opacity 1.5s ease-in;
    letter-spacing: 0.05em;
}

#subtitle.visible {
    opacity: 1;
}

#scroll-chevron {
    position: absolute;
    bottom: -30vh;
    left: 50%;
    transform: translateX(-50%);
    animation: chevron-pulse 2s ease-in-out infinite;
    opacity: 0;
    transition: opacity 1s ease-in;
}

#scroll-chevron.visible {
    opacity: 1;
}

@keyframes chevron-pulse {
    0%, 100% { opacity: 0.3; transform: translateX(-50%) translateY(0); }
    50% { opacity: 0.8; transform: translateX(-50%) translateY(6px); }
}

/* --- Section 2: The Archive --- */
#archive {
    position: relative;
    z-index: 1;
    scroll-snap-align: start;
    padding: 8vh 5vw 20vh;
    min-height: 100vh;
}

/* Epigraphs floating in negative space */
.epigraph {
    font-family: 'EB Garamond', 'Georgia', serif;
    font-style: italic;
    font-size: 20px;
    color: var(--parchment-edge);
    opacity: 0.4;
    position: absolute;
    max-width: 300px;
    line-height: 1.6;
    z-index: 1;
    pointer-events: none;
}

.epigraph-1 {
    top: 15vh;
    right: 8vw;
}

.epigraph-2 {
    top: 55vh;
    left: 3vw;
}

.epigraph-3 {
    top: 85vh;
    right: 12vw;
}

/* Alchemical Diagrams */
.alchemy-diagram {
    position: absolute;
    width: 120px;
    height: 120px;
    opacity: 0.15;
    z-index: 0;
    pointer-events: none;
}

.diagram-1 {
    top: 30vh;
    left: 2vw;
}

.diagram-2 {
    top: 60vh;
    right: 5vw;
}

.diagram-3 {
    top: 90vh;
    left: 50%;
    transform: translateX(-50%);
}

/* --- Masonry Grid --- */
#masonry-grid {
    column-count: 3;
    column-gap: 24px;
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

@media (max-width: 1100px) {
    #masonry-grid {
        column-count: 2;
    }
}

@media (max-width: 700px) {
    #masonry-grid {
        column-count: 1;
    }
}

/* --- Archetype Blocks --- */
.archetype-block {
    break-inside: avoid;
    background-color: var(--lapis-depth);
    margin-bottom: 24px;
    padding: 28px 24px 32px;
    position: relative;
    box-shadow: inset 1px 1px 3px rgba(0, 0, 0, 0.6), inset -1px -1px 3px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: box-shadow 800ms ease-out;
    overflow: hidden;
}

.archetype-block:hover {
    box-shadow: inset 1px 1px 3px rgba(0, 0, 0, 0.6), inset -1px -1px 3px rgba(0, 0, 0, 0.3), 0 0 30px rgba(74, 45, 122, 0.3);
}

/* Block size variations for masonry feel */
.block-tall .block-inkblot {
    height: 280px;
}

.block-wide .block-inkblot {
    height: 180px;
}

.block-medium .block-inkblot {
    height: 220px;
}

/* Classification code */
.block-classification {
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 12px;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--annotation);
    margin-bottom: 16px;
}

/* Inkblot area */
.block-inkblot {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

.block-inkblot svg {
    width: 100%;
    height: 100%;
    max-width: 200px;
    transition: filter 800ms ease-out;
}

.archetype-block:hover .block-inkblot svg .inkblot-paths {
    filter: none;
}

.archetype-block:hover .block-inkblot svg {
    filter: none;
}

/* Reduce blur on hover */
.archetype-block:hover .block-inkblot svg [filter] {
    filter: url(#blur-hero); /* will be overridden by JS for each */
}

/* Carved text effect for archetype titles */
.block-title {
    font-family: 'Cormorant Garamond', 'Garamond', serif;
    font-weight: 600;
    font-size: clamp(2.5rem, 6vw, 5rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--lapis-depth);
    text-shadow: 1px 1px 0px var(--albedo-stone);
    transition: color 600ms ease-out, text-shadow 600ms ease-out;
    line-height: 1.2;
    margin-bottom: 4px;
}

.archetype-block:hover .block-title {
    color: var(--rubedo-crimson);
    text-shadow: 1px 1px 0px rgba(139, 45, 58, 0.3);
}

/* Hidden description */
.block-description {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 800ms cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 800ms ease-out,
                margin-top 800ms ease-out;
    margin-top: 0;
}

.archetype-block.expanded .block-description {
    max-height: 500px;
    opacity: 1;
    margin-top: 20px;
}

.block-description p {
    font-family: 'Crimson Text', Georgia, serif;
    font-size: 17px;
    line-height: 1.75;
    color: var(--albedo-stone);
}

/* --- Section 3: The Void --- */
#void {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--nigredo-void);
}

#void-content {
    text-align: center;
    opacity: 0;
    transition: opacity 3s ease-in;
}

#void-content.visible {
    opacity: 1;
}

#void-question {
    font-family: 'EB Garamond', 'Georgia', serif;
    font-style: italic;
    font-size: 24px;
    color: var(--albedo-stone);
    letter-spacing: 0.03em;
}

#void-cursor {
    display: inline-block;
    font-family: 'Fira Code', monospace;
    font-size: 24px;
    color: var(--quicksilver);
    animation: cursor-blink 1.06s step-end infinite;
    margin-left: 4px;
    vertical-align: baseline;
}

@keyframes cursor-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Desaturation effect for void section */
body.entering-void {
    animation: desaturate 3s ease-in forwards;
}

@keyframes desaturate {
    from { filter: saturate(1); }
    to { filter: saturate(0); }
}

/* --- Radial Navigation Sigil --- */
#nav-sigil {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    z-index: 100;
    cursor: pointer;
    transition: transform 600ms ease-out, opacity 600ms ease-out;
    opacity: 0.6;
}

#nav-sigil:hover {
    transform: scale(1.1);
    opacity: 1;
}

#nav-sigil svg {
    width: 100%;
    height: 100%;
}

/* --- Radial Menu --- */
#radial-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 600ms ease-out, visibility 600ms ease-out;
}

#radial-menu.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

#radial-menu.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

#radial-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(14, 11, 22, 0.9);
}

#radial-container {
    position: relative;
    width: 400px;
    height: 400px;
}

.radial-item {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 80px;
    margin-left: -40px;
    margin-top: -20px;
    text-align: center;
    cursor: pointer;
    transform: rotate(var(--angle)) translateY(-160px) rotate(calc(-1 * var(--angle)));
    transition: transform 400ms ease-out, color 400ms ease-out;
    opacity: 0;
}

#radial-menu.visible .radial-item {
    opacity: 1;
    transition: opacity 600ms ease-out, transform 400ms ease-out, color 400ms ease-out;
}

.radial-glyph {
    display: block;
    font-size: 24px;
    color: var(--citrinitas-gold);
    margin-bottom: 6px;
    transition: color 400ms ease-out, transform 400ms ease-out;
}

.radial-label {
    display: block;
    font-family: 'Fira Code', monospace;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--quicksilver);
    transition: color 400ms ease-out;
}

.radial-item:hover .radial-glyph {
    color: var(--rubedo-crimson);
    transform: scale(1.3);
}

.radial-item:hover .radial-label {
    color: var(--albedo-stone);
}

.radial-item.active .radial-glyph {
    color: var(--citrinitas-gold);
    animation: glyph-pulse 2s ease-in-out infinite;
}

@keyframes glyph-pulse {
    0%, 100% { filter: drop-shadow(0 0 4px rgba(212, 168, 67, 0.3)); }
    50% { filter: drop-shadow(0 0 12px rgba(212, 168, 67, 0.7)); }
}

/* --- Ambient scroll effects (controlled via JS) --- */
body.scroll-ambient {
    transition: background-color 2s ease-out;
}

/* --- Responsive adjustments --- */
@media (max-width: 768px) {
    #title-archetypos {
        font-size: clamp(3rem, 10vw, 6rem);
    }

    .block-title {
        font-size: clamp(1.8rem, 5vw, 3rem);
    }

    .epigraph {
        display: none;
    }

    #radial-container {
        width: 320px;
        height: 320px;
    }

    .radial-item {
        transform: rotate(var(--angle)) translateY(-120px) rotate(calc(-1 * var(--angle)));
    }

    #nav-sigil {
        bottom: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
    }

    .archetype-block {
        padding: 20px 18px 24px;
    }

    .block-tall .block-inkblot,
    .block-wide .block-inkblot,
    .block-medium .block-inkblot {
        height: 180px;
    }
}

@media (max-width: 480px) {
    #title-archetypos {
        font-size: clamp(2.5rem, 14vw, 4rem);
    }

    .block-title {
        font-size: clamp(1.5rem, 6vw, 2.5rem);
    }

    .block-classification {
        font-size: 10px;
    }

    #void-question {
        font-size: 20px;
        padding: 0 20px;
    }
}

/* --- Utility --- */
.hidden {
    display: none;
}

/* Selection styling */
::selection {
    background: var(--ultraviolet-aura);
    color: var(--parchment-edge);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--nigredo-void);
}

::-webkit-scrollbar-thumb {
    background: var(--lapis-mid);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--quicksilver);
}
