/* ============================================
   continuum.quest — Styles
   Neomorphism on aged paper, crystalline motifs
   ============================================ */

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

:root {
    --bg-primary: #f0e4d0;
    --bg-secondary: #d9c9a8;
    --neo-light: #fff8ec;
    --neo-shadow: #c5b9a8;
    --crystal-primary: #7b5ea7;
    --crystal-secondary: #4a3270;
    --crystal-glow: #c4b1e0;
    --text-primary: #3d2c1a;
    --text-body: #4a3a28;
    --text-secondary: #8b6e4e;
    --accent: #d4a0b9;
    --text-cream: #e8dcc8;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Libre Baskerville', serif;
    font-size: clamp(1rem, 1.15vw, 1.2rem);
    line-height: 1.75;
    overflow-x: hidden;
    position: relative;
}

/* --- Paper Texture Overlay --- */
#paper-texture {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='noise'%3E%3CfeTurbulence baseFrequency='0.65' numOctaves='4' type='fractalNoise' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
    background-repeat: repeat;
}

/* --- Foxing Spots --- */
#foxing-spots {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    background:
        radial-gradient(circle at 23% 15%, #c5b9a855 0%, transparent 3px),
        radial-gradient(circle at 78% 32%, #c5b9a844 0%, transparent 4px),
        radial-gradient(circle at 12% 58%, #c5b9a833 0%, transparent 3px),
        radial-gradient(circle at 65% 72%, #c5b9a855 0%, transparent 2px),
        radial-gradient(circle at 88% 88%, #c5b9a844 0%, transparent 3px),
        radial-gradient(circle at 34% 42%, #c5b9a833 0%, transparent 4px),
        radial-gradient(circle at 52% 91%, #c5b9a844 0%, transparent 3px),
        radial-gradient(circle at 91% 12%, #c5b9a833 0%, transparent 3px),
        radial-gradient(circle at 45% 67%, #c5b9a844 0%, transparent 2px),
        radial-gradient(circle at 7% 83%, #c5b9a855 0%, transparent 3px),
        radial-gradient(circle at 72% 5%, #c5b9a833 0%, transparent 4px),
        radial-gradient(circle at 18% 95%, #c5b9a844 0%, transparent 3px),
        radial-gradient(circle at 83% 55%, #c5b9a833 0%, transparent 2px),
        radial-gradient(circle at 56% 28%, #c5b9a844 0%, transparent 3px),
        radial-gradient(circle at 38% 78%, #c5b9a855 0%, transparent 4px);
}

/* --- Navigation Pill --- */
#nav-pill {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 100;
    background: var(--bg-primary);
    box-shadow: 4px 4px 8px var(--neo-shadow), -4px -4px 8px var(--neo-light);
    border-radius: 30px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 400ms cubic-bezier(0.23, 1, 0.32, 1);
    cursor: pointer;
    opacity: 0;
}

#nav-pill.visible {
    opacity: 1;
}

.nav-dots {
    display: flex;
    gap: 8px;
}

.nav-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--neo-shadow);
    transition: background 400ms ease;
}

.nav-dot.active {
    background: var(--crystal-primary);
}

.nav-labels {
    display: flex;
    gap: 16px;
    max-width: 0;
    overflow: hidden;
    transition: max-width 500ms cubic-bezier(0.23, 1, 0.32, 1), opacity 300ms ease;
    opacity: 0;
    white-space: nowrap;
}

#nav-pill:hover .nav-labels {
    max-width: 500px;
    opacity: 1;
}

.nav-labels span {
    font-family: 'Zilla Slab', serif;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: color 300ms ease;
}

.nav-labels span:hover {
    color: var(--crystal-primary);
}

/* --- Scenes (General) --- */
.scene {
    position: relative;
    z-index: 2;
}

/* --- Scene 1: The Threshold --- */
.scene-threshold {
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    position: relative;
}

#title-continuum {
    font-family: 'Zilla Slab', serif;
    font-weight: 700;
    font-size: clamp(3rem, 7vw, 6rem);
    color: var(--text-primary);
    letter-spacing: 0.04em;
    position: absolute;
    top: 60%;
    left: 20%;
    transform: translateY(-50%);
}

#title-continuum .letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(30px);
}

#title-continuum .letter.animate-in {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 700ms cubic-bezier(0.23, 1, 0.32, 1),
                transform 700ms cubic-bezier(0.23, 1, 0.32, 1);
}

#threshold-crystal {
    position: absolute;
    top: calc(60% + 0.5em);
    left: calc(20% + 9ch);
    opacity: 0;
    transition: opacity 1.2s ease;
}

#threshold-crystal.visible {
    opacity: 1;
}

#threshold-annotation {
    position: absolute;
    top: calc(60% + 3.5rem);
    left: calc(20% + 9ch + 50px);
    opacity: 0;
    transition: opacity 800ms ease;
    font-family: 'Caveat', cursive;
    font-size: clamp(0.85rem, 1.1vw, 1.1rem);
    color: var(--text-secondary);
    transform: rotate(2deg);
}

#threshold-annotation.visible {
    opacity: 1;
}

#scroll-line {
    position: absolute;
    bottom: 5%;
    left: calc(20% + 9ch + 25px);
    width: 1px;
    height: 0;
    background: var(--text-secondary);
    transition: height 3s ease;
}

#scroll-line.grow {
    height: 80px;
}

/* --- Crystal Clusters --- */
.crystal-cluster {
    position: relative;
}

.crystal-small {
    width: 50px;
    height: 40px;
}

.crystal-small .facet-1 {
    position: absolute;
    width: 20px;
    height: 30px;
    background: linear-gradient(135deg, #7b5ea770, #4a327040);
    clip-path: polygon(50% 0%, 100% 35%, 85% 100%, 15% 100%, 0% 35%);
    border: 1px solid var(--crystal-glow);
    left: 0;
    top: 5px;
}

.crystal-small .facet-2 {
    position: absolute;
    width: 18px;
    height: 28px;
    background: linear-gradient(150deg, #7b5ea780, #4a327050);
    clip-path: polygon(50% 0%, 100% 40%, 80% 100%, 20% 100%, 0% 40%);
    left: 14px;
    top: 0;
    transform: rotate(8deg);
}

.crystal-small .facet-3 {
    position: absolute;
    width: 16px;
    height: 24px;
    background: linear-gradient(120deg, #7b5ea760, #4a327035);
    clip-path: polygon(50% 0%, 100% 30%, 90% 100%, 10% 100%, 0% 30%);
    left: 28px;
    top: 8px;
    transform: rotate(-5deg);
}

.crystal-inverted {
    transform: rotate(180deg);
}

/* Crystal breathe animation */
@keyframes crystal-breathe {
    0% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(1.5deg) scale(1.02); }
    100% { transform: rotate(0deg) scale(1); }
}

.crystal-cluster {
    animation: crystal-breathe 12s ease-in-out infinite;
}

.crystal-inverted {
    animation: none;
    transform: rotate(180deg);
}

/* --- Annotation (Caveat) --- */
.annotation {
    font-family: 'Caveat', cursive;
    font-size: clamp(0.85rem, 1.1vw, 1.1rem);
    color: var(--text-secondary);
}

/* --- Specimen Cards --- */
.specimen-card {
    position: relative;
    padding: clamp(1.5rem, 3vw, 2.5rem);
    border-radius: 12px;
    background: var(--bg-primary);
    opacity: 0;
    transform: translateX(-40px);
    transition: opacity 700ms cubic-bezier(0.23, 1, 0.32, 1),
                transform 700ms cubic-bezier(0.23, 1, 0.32, 1),
                box-shadow 400ms ease;
}

.specimen-card.animate-in {
    opacity: 1;
    transform: translateX(0);
}

.specimen-card:nth-child(even) {
    transform: translateX(40px);
}

.specimen-card:nth-child(even).animate-in {
    transform: translateX(0);
}

.card-extruded {
    box-shadow: 8px 8px 16px var(--neo-shadow), -8px -8px 16px var(--neo-light);
}

.card-extruded:hover {
    box-shadow: 8px 8px 16px var(--neo-shadow), -8px -8px 16px var(--neo-light), 0 0 20px #c4b1e040;
}

.card-inset {
    box-shadow: inset 6px 6px 12px var(--neo-shadow), inset -6px -6px 12px var(--neo-light);
}

/* Card sizes */
.card-large {
    width: clamp(280px, 55vw, 560px);
}

.card-medium {
    width: clamp(280px, 30vw, 400px);
}

.card-small-card {
    width: clamp(200px, 25vw, 320px);
}

.card-final {
    width: 200px;
}

/* Card crystal ornament */
.card-crystal-ornament {
    width: 60px;
    height: 30px;
    margin-bottom: 0.75rem;
}

.card-crystal-ornament svg {
    width: 100%;
    height: 100%;
}

/* --- Specimen Text --- */
.specimen-text {
    font-family: 'Libre Baskerville', serif;
    font-style: italic;
    font-size: clamp(0.95rem, 1.1vw, 1.15rem);
    color: var(--text-body);
    opacity: 0.88;
    line-height: 1.75;
}

.annotation-style {
    font-family: 'Caveat', cursive;
    font-style: normal;
    font-size: clamp(1rem, 1.2vw, 1.3rem);
    transform: rotate(-1deg);
}

/* --- Connecting Lines --- */
.connecting-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

/* --- Scene 2: First Specimens --- */
.scene-specimens {
    min-height: 120vh;
    padding: clamp(8rem, 12vh, 16rem) 0;
    position: relative;
}

.scene-specimens .specimen-card {
    margin-bottom: clamp(4rem, 6vh, 8rem);
}

/* --- Scene 3: The Grand Crystal --- */
.scene-grand-crystal {
    height: 100vh;
    position: relative;
    overflow: hidden;
}

#grand-crystal {
    position: absolute;
    right: 10%;
    top: 50%;
    transform: translateY(-50%);
    width: clamp(300px, 70vw, 900px);
    height: clamp(300px, 60vh, 700px);
}

.grand-1, .grand-2, .grand-3, .grand-4,
.grand-5, .grand-6, .grand-7, .grand-8 {
    position: absolute;
    transition: transform 0.1s linear;
}

.grand-1 {
    width: 35%;
    height: 50%;
    background: linear-gradient(135deg, #4a3270, #4a327060);
    clip-path: polygon(30% 0%, 70% 0%, 100% 35%, 85% 100%, 15% 100%, 0% 35%);
    left: 25%;
    top: 20%;
}

.grand-2 {
    width: 30%;
    height: 55%;
    background: linear-gradient(150deg, #7b5ea790, #4a327050);
    clip-path: polygon(40% 0%, 80% 10%, 100% 45%, 75% 100%, 20% 95%, 0% 40%);
    left: 40%;
    top: 15%;
}

.grand-3 {
    width: 28%;
    height: 45%;
    background: linear-gradient(120deg, #7b5ea770, #c4b1e040);
    clip-path: polygon(50% 0%, 95% 25%, 85% 80%, 40% 100%, 5% 70%, 10% 20%);
    left: 15%;
    top: 30%;
}

.grand-4 {
    width: 25%;
    height: 40%;
    background: linear-gradient(160deg, #c4b1e060, #7b5ea730);
    clip-path: polygon(45% 0%, 100% 30%, 90% 90%, 30% 100%, 0% 60%, 15% 10%);
    left: 55%;
    top: 25%;
}

.grand-5 {
    width: 20%;
    height: 35%;
    background: linear-gradient(135deg, #7b5ea750, #4a327030);
    clip-path: polygon(50% 0%, 100% 40%, 80% 100%, 20% 100%, 0% 40%);
    left: 35%;
    top: 45%;
}

.grand-6 {
    width: 22%;
    height: 38%;
    background: linear-gradient(145deg, #c4b1e050, #4a327025);
    clip-path: polygon(40% 0%, 90% 20%, 100% 65%, 60% 100%, 10% 85%, 0% 30%);
    left: 60%;
    top: 40%;
}

.grand-7 {
    width: 18%;
    height: 30%;
    background: linear-gradient(130deg, #7b5ea740, #c4b1e030);
    clip-path: polygon(50% 0%, 100% 35%, 85% 100%, 15% 100%, 0% 35%);
    left: 20%;
    top: 55%;
}

.grand-8 {
    width: 24%;
    height: 32%;
    background: linear-gradient(155deg, #c4b1e040, #7b5ea720);
    clip-path: polygon(35% 0%, 85% 15%, 100% 55%, 70% 100%, 15% 90%, 0% 40%);
    left: 48%;
    top: 55%;
}

/* Crystal annotations */
.crystal-annotation {
    position: absolute;
    z-index: 5;
    font-family: 'Caveat', cursive;
    font-size: clamp(0.85rem, 1vw, 1.1rem);
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity 800ms ease;
}

.crystal-annotation.visible {
    opacity: 1;
}

.ann-1 {
    left: 8%;
    top: 25%;
    transform: rotate(-2deg);
}

.ann-2 {
    right: 8%;
    top: 40%;
    transform: rotate(1.5deg);
}

.ann-3 {
    left: 12%;
    bottom: 25%;
    transform: rotate(2.5deg);
}

.ann-line {
    display: inline-block;
    width: 40px;
    height: 1px;
    background: var(--text-secondary);
    vertical-align: middle;
    margin-right: 8px;
    opacity: 0.6;
}

.ann-text {
    vertical-align: middle;
}

/* Crystal quote well */
#crystal-quote {
    position: absolute;
    bottom: 10%;
    left: 8%;
    width: clamp(250px, 35vw, 400px);
    padding: clamp(1.5rem, 2.5vw, 2.5rem);
    border-radius: 12px;
    background: var(--bg-primary);
    z-index: 5;
}

#crystal-quote blockquote {
    font-family: 'Zilla Slab', serif;
    font-weight: 600;
    font-size: clamp(1.1rem, 1.8vw, 1.5rem);
    color: var(--text-primary);
    letter-spacing: 0.04em;
    line-height: 1.6;
}

/* --- Scene 4: The Collection --- */
.scene-collection {
    min-height: 150vh;
    padding: clamp(8rem, 12vh, 16rem) 0;
    position: relative;
}

.scene-collection .specimen-card {
    width: clamp(240px, 38vw, 480px);
    margin-bottom: clamp(8rem, 12vh, 16rem);
}

.scene-collection .specimen-card:nth-child(1) { margin-bottom: clamp(4rem, 6vh, 8rem); }
.scene-collection .specimen-card:nth-child(2) { margin-bottom: clamp(5rem, 8vh, 10rem); }
.scene-collection .specimen-card:nth-child(3) { margin-bottom: clamp(6rem, 9vh, 12rem); }
.scene-collection .specimen-card:nth-child(4) { margin-bottom: clamp(7rem, 10vh, 14rem); }
.scene-collection .specimen-card:nth-child(5) { margin-bottom: clamp(8rem, 12vh, 16rem); }
.scene-collection .specimen-card:nth-child(6) { margin-bottom: clamp(9rem, 14vh, 18rem); }
.scene-collection .specimen-card:nth-child(7) { margin-bottom: clamp(10rem, 16vh, 20rem); }

.card-crystal-only {
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-diagram {
    width: 100%;
    max-width: 200px;
    height: auto;
}

/* --- Scene 5: The Vanishing Point --- */
.scene-vanishing {
    height: 80vh;
    position: relative;
    background: linear-gradient(to bottom, var(--bg-primary), var(--bg-secondary));
}

.scene-vanishing .card-final {
    position: absolute;
    left: 70%;
    top: 40%;
    transform: translateX(-50%);
}

.annotation-final {
    font-family: 'Caveat', cursive;
    font-size: clamp(1rem, 1.3vw, 1.3rem);
    color: var(--text-secondary);
    white-space: nowrap;
}

#final-crystal {
    position: absolute;
    bottom: 8%;
    left: 50%;
    transform: translateX(-50%) rotate(180deg);
    animation: none;
}

/* --- Deckled edge on some cards --- */
.scene-specimens .specimen-card:first-child {
    clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 97% 98%, 93% 100%, 88% 97%, 83% 100%, 78% 98%, 73% 100%, 68% 97%, 63% 100%, 58% 98%, 53% 100%, 48% 97%, 43% 100%, 38% 98%, 33% 100%, 28% 97%, 23% 100%, 18% 98%, 13% 100%, 8% 97%, 3% 100%, 0% 98%);
}

/* --- Responsive adjustments --- */
@media (max-width: 768px) {
    .specimen-card {
        width: clamp(240px, 80vw, 400px) !important;
        margin-left: 10% !important;
    }

    #title-continuum {
        left: 10%;
    }

    #grand-crystal {
        right: -10%;
        width: 90vw;
    }

    .crystal-annotation {
        display: none;
    }

    .scene-vanishing .card-final {
        left: 50%;
    }

    #nav-pill {
        top: 1rem;
        right: 1rem;
    }
}
