/* ============================================================
   persona.quest — Styles
   Colors:
     Void:       #0C0B1D
     Parchment:  #F2E9D8
     Shadow:     #4A2D6B
     Gold:       #E8B84B
     Orchid:     #C490D1 (annotations)
     Teal:       #3D8B8B
     Coral:      #E07A73
     Ash:        #D4CFC6 (muted)
   Fonts:
     Fraunces (display, headings)
     Commissioner (body)
     Caveat (annotations)
   ============================================================ */

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

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

body {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    background: #0C0B1D;
    color: #F2E9D8;
    overflow-x: hidden;
    line-height: 1.6;
}

/* --- Central Axis Line --- */
#central-axis {
    position: fixed;
    top: 0;
    left: 50%;
    width: 2px;
    height: 100vh;
    pointer-events: none;
    z-index: 100;
    transform: translateX(-50%);
}

#axis-path {
    fill: none;
    stroke: #C490D1;
    stroke-width: 1;
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 0.05s linear;
}

/* --- Section Indicators --- */
#section-indicators {
    position: fixed;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.indicator {
    width: 20px;
    height: 20px;
    cursor: pointer;
    opacity: 0.35;
    transition: opacity 0.4s ease, transform 0.3s ease;
}

.indicator:hover {
    opacity: 0.7;
    transform: scale(1.15);
}

.indicator.active {
    opacity: 1;
}

.indicator.active svg ellipse,
.indicator.active svg circle {
    fill: #E8B84B;
}

/* --- Sections (shared) --- */
.section {
    position: relative;
    min-height: 100vh;
    width: 100%;
    overflow: hidden;
}

/* --- Constellation dots --- */
.constellation {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

.dot {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #E8B84B;
    opacity: 0.5;
    animation: dotPulse 4s ease-in-out infinite alternate;
}

.dot:nth-child(2n) {
    width: 3px;
    height: 3px;
    opacity: 0.35;
    animation-delay: -1.5s;
}

.dot:nth-child(3n) {
    width: 5px;
    height: 5px;
    opacity: 0.6;
    animation-delay: -2.8s;
    animation-duration: 5s;
}

@keyframes dotPulse {
    0%   { opacity: 0.25; transform: scale(0.8); }
    100% { opacity: 0.7;  transform: scale(1.2); }
}

/* --- Torn Edge Dividers --- */
.torn-edge {
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 40px;
    z-index: 10;
}

.torn-edge svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* --- Annotations (Caveat) --- */
.annotation {
    font-family: 'Caveat', cursive;
    color: #C490D1;
    font-size: clamp(1.1rem, 1.5vw, 1.6rem);
    font-weight: 400;
    letter-spacing: 0.02em;
}

/* ============================================================
   SECTION 1: THE SURFACE (Hero)
   ============================================================ */
#surface {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #0C0B1D;
    position: relative;
}

.surface-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    min-height: 100vh;
    position: relative;
    z-index: 5;
}

.surface-left,
.surface-right {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.surface-left {
    justify-content: flex-end;
    padding-right: 1.5rem;
}

.surface-right {
    justify-content: flex-start;
    padding-left: 1.5rem;
}

.hero-title {
    font-family: 'Fraunces', serif;
    font-optical-sizing: auto;
    font-weight: 900;
    font-variation-settings: 'wonk' 1, 'opsz' 144;
    font-size: clamp(3rem, 8vw, 8rem);
    line-height: 1;
    letter-spacing: -0.02em;
    color: #F2E9D8;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 1s ease, transform 1s ease;
}

.hero-title.visible {
    opacity: 1;
    transform: translateY(0);
}

.hero-title-left {
    color: #F2E9D8;
    text-align: right;
}

.hero-title-right {
    color: #E8B84B;
    text-align: left;
}

.hero-mask-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(400px, 50vw);
    height: min(500px, 65vh);
    z-index: 3;
    pointer-events: none;
}

#hero-mask {
    width: 100%;
    height: 100%;
}

#hero-mask ellipse {
    opacity: 0.3;
}

#hero-mask .mask-contour {
    fill: none;
    stroke: #E8B84B;
    stroke-width: 0.6;
    opacity: 0;
    animation: contourFade 8s ease-in-out infinite alternate;
}

#hero-mask .mask-contour:nth-child(2) { animation-delay: -2s; }
#hero-mask .mask-contour:nth-child(3) { animation-delay: -4s; }
#hero-mask .mask-contour:nth-child(4) { animation-delay: -6s; }
#hero-mask .mask-contour:nth-child(5) { animation-delay: -1s; }

@keyframes contourFade {
    0%   { opacity: 0;   }
    30%  { opacity: 0.6; }
    70%  { opacity: 0.6; }
    100% { opacity: 0;   }
}

.surface-subtitle {
    position: absolute;
    bottom: 12vh;
    left: 50%;
    transform: translateX(-50%) rotate(-2deg);
    z-index: 6;
    text-align: center;
    opacity: 0;
    transition: opacity 1.2s ease 0.6s;
}

.surface-subtitle.visible {
    opacity: 1;
}

/* ============================================================
   SECTION 2: MASK GALLERY (Horizontal scroll)
   ============================================================ */
#mask-gallery {
    background: #0C0B1D;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 4rem 0;
    position: relative;
}

.gallery-header {
    text-align: center;
    margin-bottom: 3rem;
    z-index: 5;
    position: relative;
}

.gallery-scroll-container {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    z-index: 5;
    position: relative;
}

.gallery-scroll-container::-webkit-scrollbar {
    display: none;
}

.gallery-track {
    display: flex;
    gap: 0;
    padding: 2rem calc(50vw - 30vw);
    width: max-content;
}

.archetype-panel {
    flex: 0 0 60vw;
    max-width: 600px;
    min-height: 70vh;
    scroll-snap-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2.5rem;
    border-radius: 4px;
    position: relative;
    margin: 0 -2.5vw;
    opacity: 0.4;
    transform: scale(0.92);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.archetype-panel.in-view {
    opacity: 1;
    transform: scale(1);
}

.archetype-panel[data-bg="dark"] {
    background: #0C0B1D;
    border: 1px solid rgba(232, 184, 75, 0.12);
}

.archetype-panel[data-bg="shadow"] {
    background: #4A2D6B;
}

.archetype-mask {
    width: min(200px, 40vw);
    height: auto;
    margin-bottom: 2rem;
    opacity: 0.85;
}

.archetype-name {
    font-family: 'Fraunces', serif;
    font-weight: 900;
    font-variation-settings: 'wonk' 1, 'opsz' 48;
    font-size: clamp(1.8rem, 3vw, 2.8rem);
    color: #F2E9D8;
    margin-bottom: 0.75rem;
    text-align: center;
}

.archetype-desc {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: clamp(0.95rem, 1.2vw, 1.15rem);
    color: #D4CFC6;
    text-align: center;
    max-width: 360px;
    line-height: 1.65;
}

.archetype-bar {
    position: absolute;
    bottom: 0;
    left: 10%;
    width: 80%;
    height: 3px;
    border-radius: 2px;
}

/* ============================================================
   SECTION 3: MIRROR CHAMBER (Rorschach)
   ============================================================ */
#mirror-chamber {
    background: #0C0B1D;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.mirror-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    max-width: 900px;
    gap: 2rem;
    padding: 0 2rem;
    margin-bottom: 3rem;
    z-index: 5;
    position: relative;
}

.mirror-left {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-end;
    text-align: right;
    padding-right: 2rem;
}

.mirror-right {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding-left: 2rem;
}

.mirror-heading {
    font-family: 'Fraunces', serif;
    font-weight: 900;
    font-variation-settings: 'wonk' 1, 'opsz' 48;
    font-size: clamp(2rem, 4vw, 3.5rem);
    color: #F2E9D8;
    margin-bottom: 1rem;
}

.mirror-text {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    color: #D4CFC6;
    line-height: 1.7;
    max-width: 380px;
}

.rorschach-container {
    width: min(600px, 80vw);
    height: min(600px, 80vw);
    position: relative;
    z-index: 5;
}

#rorschach-canvas {
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

/* ============================================================
   SECTION 4: THE ARCHIVE (Timeline)
   ============================================================ */
#archive {
    background: #0C0B1D;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8rem 2rem;
    position: relative;
}

.archive-header {
    text-align: center;
    margin-bottom: 4rem;
    z-index: 5;
    position: relative;
}

.archive-heading {
    font-family: 'Fraunces', serif;
    font-weight: 900;
    font-variation-settings: 'wonk' 1, 'opsz' 48;
    font-size: clamp(2rem, 4vw, 3.5rem);
    color: #F2E9D8;
    margin-bottom: 0.75rem;
}

.archive-timeline {
    position: relative;
    width: 100%;
    max-width: 900px;
    z-index: 5;
}

.archive-line {
    position: absolute;
    left: 50%;
    top: 0;
    width: 1px;
    height: 100%;
    background: linear-gradient(to bottom, transparent, #C490D1 10%, #C490D1 90%, transparent);
    transform: translateX(-50%);
}

.archive-card {
    position: relative;
    width: 42%;
    background: rgba(74, 45, 107, 0.25);
    border: 1px solid rgba(196, 144, 209, 0.15);
    border-radius: 4px;
    padding: 2rem 2rem 2.5rem;
    margin-bottom: 3rem;
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.7s ease, transform 0.7s ease, box-shadow 0.3s ease;
}

.archive-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.archive-card:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 24px rgba(12, 11, 29, 0.5);
}

.archive-card-left {
    margin-left: 0;
    margin-right: auto;
}

.archive-card-right {
    margin-left: auto;
    margin-right: 0;
}

.archive-card .micro-mask {
    margin-bottom: 1rem;
}

.card-title {
    font-family: 'Fraunces', serif;
    font-weight: 700;
    font-variation-settings: 'wonk' 1, 'opsz' 32;
    font-size: clamp(1.2rem, 1.8vw, 1.5rem);
    color: #F2E9D8;
    margin-bottom: 0.6rem;
}

.card-text {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: clamp(0.9rem, 1.1vw, 1.05rem);
    color: #D4CFC6;
    line-height: 1.65;
    margin-bottom: 0.8rem;
}

.card-annotation {
    display: block;
    opacity: 0;
    transition: opacity 0.4s ease;
    transform: rotate(-1.5deg);
}

.archive-card:hover .card-annotation {
    opacity: 1;
}

/* ============================================================
   SECTION 5: INTEGRATION (Finale)
   ============================================================ */
#integration {
    background: #0C0B1D;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.integration-backdrop {
    position: absolute;
    inset: 0;
    background: radial-gradient(
        ellipse 60% 60% at 50% 50%,
        rgba(232, 184, 75, 0.06) 0%,
        rgba(196, 144, 209, 0.04) 30%,
        rgba(61, 139, 139, 0.03) 50%,
        rgba(224, 122, 115, 0.02) 70%,
        transparent 100%
    );
    z-index: 1;
}

.integration-content {
    position: relative;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

#integration-mask {
    width: min(350px, 60vw);
    height: auto;
    margin-bottom: 3rem;
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 1.5s ease, transform 1.5s ease;
}

#integration-mask.visible {
    opacity: 1;
    transform: scale(1);
}

.integration-line {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 1.5s ease;
}

#integration-mask.visible .integration-line {
    stroke-dashoffset: 0;
}

.integration-title {
    font-family: 'Fraunces', serif;
    font-weight: 900;
    font-variation-settings: 'wonk' 1, 'opsz' 144;
    font-size: clamp(3rem, 7vw, 7rem);
    color: #F2E9D8;
    letter-spacing: -0.02em;
    margin-bottom: 1rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1.2s ease 0.5s, transform 1.2s ease 0.5s;
}

.integration-title.visible {
    opacity: 1;
    transform: translateY(0);
}

.integration-subtitle {
    opacity: 0;
    transition: opacity 1.2s ease 1s;
}

.integration-subtitle.visible {
    opacity: 1;
}

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

    .surface-left,
    .surface-right {
        justify-content: center;
        padding: 0.5rem 1rem;
        min-height: auto;
    }

    .surface-left {
        align-items: flex-end;
        padding-bottom: 0;
    }

    .surface-right {
        align-items: flex-start;
        padding-top: 0;
    }

    .hero-title-left,
    .hero-title-right {
        text-align: center;
    }

    .hero-mask-container {
        width: 65vw;
        height: 55vh;
    }

    .gallery-track {
        padding: 2rem 20vw;
    }

    .archetype-panel {
        flex: 0 0 80vw;
    }

    .mirror-grid {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .mirror-left,
    .mirror-right {
        align-items: center;
        text-align: center;
        padding: 0;
    }

    .archive-card {
        width: 80%;
    }

    .archive-card-left,
    .archive-card-right {
        margin-left: auto;
        margin-right: auto;
    }

    #section-indicators {
        right: 12px;
    }
}
