/* ============================================
   mystical.quest - Mid-Century Crystal Sanctuary
   Palette: Duotone with Crystalline Accents
   Typography: EB Garamond, Jost, Cormorant Garamond
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --quartz-white: #FAF6F0;
    --obsidian-teal: #1A3A3A;
    --tourmaline-teal: #2D6A6A;
    --amber-facet: #D4A853;
    --sandstone: #E8DFD0;
    --rose-quartz: #E8B4B8;
    --malachite-deep: #0D4D4D;
    --citrine-bright: #F0C75E;

    --font-display: 'EB Garamond', serif;
    --font-body: 'Jost', sans-serif;
    --font-accent: 'Cormorant Garamond', serif;

    --ease-crystal: cubic-bezier(0.16, 1, 0.3, 1);
    --prismatic-gradient: linear-gradient(135deg, #E8B4B8, #F0C75E, #2D6A6A, #D4A853, #E8B4B8);
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    background-color: var(--quartz-white);
    color: var(--obsidian-teal);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Entry Overlay --- */
#entry-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--quartz-white);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.8s ease, visibility 0.8s ease;
}

#entry-overlay.fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

#crystal-entry {
    width: 60vmin;
    height: 60vmin;
    max-width: 500px;
    max-height: 500px;
}

#entry-pulse {
    opacity: 0;
    transition: opacity 0.3s ease;
}

#entry-pulse.visible {
    opacity: 1;
    animation: pulse-glow 0.6s ease-in-out;
}

@keyframes pulse-glow {
    0% { r: 2; opacity: 1; }
    50% { r: 6; opacity: 0.8; }
    100% { r: 3; opacity: 1; }
}

.crystal-line {
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    transition: stroke-dashoffset 1.5s var(--ease-crystal);
}

.crystal-line.drawn {
    stroke-dashoffset: 0;
}

/* --- Crystal Frame (Scroll-Growing) --- */
#crystal-frame {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 50;
    pointer-events: none;
}

.frame-line {
    transition: opacity 0.6s ease;
}

/* --- Hero Section --- */
#hero {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(3rem, 8vh, 6rem);
    background-color: var(--quartz-white);
    overflow: hidden;
}

/* Subtle terrazzo-like texture on hero */
#hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(circle at 20% 30%, var(--tourmaline-teal) 1px, transparent 1px),
        radial-gradient(circle at 60% 70%, var(--tourmaline-teal) 0.8px, transparent 0.8px),
        radial-gradient(circle at 80% 20%, var(--tourmaline-teal) 1.2px, transparent 1.2px),
        radial-gradient(circle at 40% 80%, var(--tourmaline-teal) 0.6px, transparent 0.6px),
        radial-gradient(circle at 10% 60%, var(--tourmaline-teal) 1px, transparent 1px),
        radial-gradient(circle at 90% 50%, var(--tourmaline-teal) 0.7px, transparent 0.7px),
        radial-gradient(circle at 50% 10%, var(--tourmaline-teal) 0.9px, transparent 0.9px),
        radial-gradient(circle at 70% 40%, var(--tourmaline-teal) 1.1px, transparent 1.1px),
        radial-gradient(circle at 30% 50%, var(--tourmaline-teal) 0.5px, transparent 0.5px);
    background-size: 200px 200px, 180px 180px, 220px 220px, 160px 160px, 190px 190px, 210px 210px, 170px 170px, 230px 230px, 150px 150px;
    opacity: 0.02;
    pointer-events: none;
}

.hero-content {
    text-align: center;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.8s var(--ease-crystal), transform 0.8s var(--ease-crystal);
    z-index: 2;
}

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

.hero-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(3.5rem, 9vw, 8rem);
    color: var(--obsidian-teal);
    letter-spacing: 0.02em;
    line-height: 1.1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.15em;
}

.title-word {
    display: inline-block;
}

.title-starburst {
    display: inline-block;
    animation: spin-slow 20s linear infinite;
    flex-shrink: 0;
    width: clamp(20px, 3vw, 36px);
    height: clamp(20px, 3vw, 36px);
}

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

.hero-subtitle {
    font-family: var(--font-accent);
    font-weight: 300;
    font-style: italic;
    font-size: clamp(1.4rem, 2.8vw, 2.2rem);
    color: var(--tourmaline-teal);
    letter-spacing: 0.04em;
    margin-top: clamp(1rem, 2vh, 1.5rem);
    opacity: 0;
    transition: opacity 0.8s ease 0.4s;
}

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

/* --- Crystalline Dividers --- */
.crystal-divider {
    width: 100%;
    padding: 0.5rem 0;
    overflow: hidden;
}

.crystal-divider svg {
    width: 100%;
    height: 20px;
    display: block;
}

.divider-path {
    stroke-dasharray: 2000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 1s var(--ease-crystal);
}

.divider-path.drawn {
    stroke-dashoffset: 0;
}

.crystal-divider.flash .divider-path {
    stroke: url(#prismatic) !important;
}

/* Prismatic flash effect */
.crystal-divider.flashing .divider-path {
    animation: prismatic-flash 0.2s ease-in-out;
}

@keyframes prismatic-flash {
    0% { stroke-opacity: 1; filter: none; }
    50% { stroke-opacity: 1; filter: brightness(1.6) saturate(1.8); }
    100% { stroke-opacity: 1; filter: none; }
}

/* --- Content Sections --- */
.content-section {
    padding: clamp(6rem, 12vh, 10rem) 0;
    position: relative;
}

.content-section.alt-bg {
    background-color: var(--sandstone);
}

/* Subtle leaf-vein texture on alt sections */
.content-section.alt-bg::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(45deg, transparent 48%, var(--tourmaline-teal) 49%, var(--tourmaline-teal) 50%, transparent 51%),
        linear-gradient(-30deg, transparent 48%, var(--tourmaline-teal) 49%, var(--tourmaline-teal) 50%, transparent 51%);
    background-size: 300px 300px, 250px 250px;
    opacity: 0.015;
    pointer-events: none;
}

/* --- F-Pattern Layout --- */
.f-pattern-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: clamp(2rem, 4vw, 4rem);
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 clamp(2rem, 4vw, 4rem);
}

.reading-rail {
    margin-left: clamp(0rem, 4vw, 6rem);
    max-width: 680px;
}

/* --- Typography --- */
.section-heading {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    color: var(--obsidian-teal);
    letter-spacing: 0.02em;
    line-height: 1.3;
    margin-bottom: clamp(1.5rem, 3vh, 2.5rem);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s var(--ease-crystal), transform 0.5s var(--ease-crystal);
}

.section-heading.revealed {
    opacity: 1;
    transform: translateY(0);
}

.body-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.75;
    color: var(--obsidian-teal);
    margin-bottom: clamp(1rem, 2vh, 1.5rem);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s var(--ease-crystal), transform 0.3s var(--ease-crystal);
}

.body-text.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* --- Specimen Cards --- */
.specimen-cards {
    display: flex;
    flex-direction: column;
    gap: clamp(1.5rem, 3vh, 2.5rem);
    margin: clamp(2rem, 4vh, 3.5rem) 0;
}

.specimen-card {
    background: var(--quartz-white);
    clip-path: polygon(0 0, calc(100% - 24px) 0, 100% 24px, 100% 100%, 0 100%);
    box-shadow: 4px 8px 24px rgba(26, 58, 58, 0.08);
    position: relative;
    opacity: 0;
    transform: translateX(30px) scale(0.95);
    transition: opacity 0.5s var(--ease-crystal), transform 0.5s var(--ease-crystal), box-shadow 0.3s ease;
}

.specimen-card.revealed {
    opacity: 1;
    transform: translateX(0) scale(1);
}

.specimen-card:hover {
    transform: translateY(-4px) scale(1);
    box-shadow: 6px 12px 32px rgba(26, 58, 58, 0.12);
}

/* Cut corner prismatic flash on hover */
.specimen-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 34px;
    height: 34px;
    clip-path: polygon(0 0, 100% 0, 100% 100%);
    background: var(--prismatic-gradient);
    background-size: 300% 300%;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.specimen-card:hover::after {
    opacity: 1;
    animation: prismatic-move 2s linear infinite;
}

@keyframes prismatic-move {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.alt-bg .specimen-card {
    background: var(--quartz-white);
}

.card-inner {
    padding: clamp(1.5rem, 3vw, 2.5rem);
}

.starburst-marker {
    margin-bottom: 0.75rem;
    animation: spin-slow 20s linear infinite;
    display: inline-block;
}

.starburst-marker:hover {
    animation-duration: 2s;
}

.card-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(1.3rem, 2.5vw, 1.8rem);
    color: var(--obsidian-teal);
    letter-spacing: 0.02em;
    line-height: 1.3;
    margin-bottom: 0.5rem;
}

.card-text {
    font-family: var(--font-body);
    font-weight: 400;
    line-height: 1.75;
    color: var(--obsidian-teal);
    margin-bottom: 1rem;
}

.card-label {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 0.85rem;
    color: var(--tourmaline-teal);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.wide-card {
    max-width: 100%;
}

/* --- Specimen Shelf --- */
.specimen-shelf {
    display: flex;
    flex-direction: column;
    gap: clamp(2rem, 4vh, 3rem);
    padding-top: clamp(2rem, 4vh, 3rem);
    align-items: flex-start;
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.5s var(--ease-crystal) 0.2s, transform 0.5s var(--ease-crystal) 0.2s;
}

.specimen-shelf.revealed {
    opacity: 1;
    transform: translateX(0);
}

/* --- Pull Quotes --- */
.pull-quote {
    position: relative;
    padding: 1.5rem 0;
    border-left: 2px solid var(--amber-facet);
    padding-left: 1.5rem;
}

.quote-text {
    font-family: var(--font-accent);
    font-weight: 300;
    font-style: italic;
    font-size: clamp(1.4rem, 2.8vw, 2.2rem);
    color: var(--amber-facet);
    letter-spacing: 0.04em;
    line-height: 1.4;
}

/* --- Hexagonal Grid --- */
.hex-cluster {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-width: 180px;
}

.hex-cluster.offset {
    margin-top: 1rem;
}

.hex-cluster.large {
    max-width: 220px;
}

.hex-item {
    width: 48px;
    height: 48px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: var(--hex-fill);
    transition: transform 0.3s var(--ease-crystal);
}

.hex-item:hover {
    transform: scale(1.15);
}

.specimen-label {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 0.8rem;
    color: var(--tourmaline-teal);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* --- Starburst Decorations --- */
.starburst-decoration {
    animation: spin-slow 20s linear infinite;
    display: inline-block;
}

.starburst-decoration:hover {
    animation-duration: 2s;
}

.starburst-decoration.large svg {
    width: 80px;
    height: 80px;
}

/* --- Journey Steps --- */
.journey-steps {
    display: flex;
    flex-direction: column;
    gap: clamp(1.5rem, 3vh, 2.5rem);
    margin: clamp(2rem, 4vh, 3.5rem) 0;
}

.journey-step {
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 0.5s var(--ease-crystal), transform 0.5s var(--ease-crystal);
}

.journey-step.revealed {
    opacity: 1;
    transform: translateY(0);
}

.step-marker {
    flex-shrink: 0;
    margin-top: 0.25rem;
    animation: spin-slow 20s linear infinite;
}

.step-marker:hover {
    animation-duration: 2s;
}

.step-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(1.2rem, 2vw, 1.5rem);
    color: var(--obsidian-teal);
    letter-spacing: 0.02em;
    margin-bottom: 0.35rem;
}

.step-text {
    font-family: var(--font-body);
    font-weight: 400;
    line-height: 1.75;
    color: var(--obsidian-teal);
}

/* --- Links --- */
a {
    color: var(--tourmaline-teal);
    text-decoration: none;
    position: relative;
    transition: color 0.3s ease;
}

a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--prismatic-gradient);
    background-size: 300% 100%;
    animation: prismatic-move 2s linear infinite;
    transition: width 0.3s ease;
}

a:hover {
    color: var(--amber-facet);
}

a:hover::after {
    width: 100%;
}

/* --- Footer --- */
#site-footer {
    background-color: var(--malachite-deep);
    padding: clamp(4rem, 8vh, 6rem) clamp(2rem, 4vw, 4rem);
    text-align: center;
}

.footer-content {
    max-width: 600px;
    margin: 0 auto;
}

.footer-crystal {
    margin-bottom: 2rem;
    opacity: 0.6;
}

.footer-crystal svg {
    display: block;
    margin: 0 auto;
}

.footer-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(1.8rem, 3.5vw, 2.8rem);
    color: var(--quartz-white);
    letter-spacing: 0.02em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.1em;
    margin-bottom: 0.75rem;
}

.footer-starburst {
    display: inline-block;
    animation: spin-slow 20s linear infinite;
    flex-shrink: 0;
}

.footer-tagline {
    font-family: var(--font-accent);
    font-weight: 300;
    font-style: italic;
    font-size: clamp(1.1rem, 2vw, 1.4rem);
    color: var(--amber-facet);
    letter-spacing: 0.04em;
    margin-bottom: 2rem;
}

.footer-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.footer-link {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 0.95rem;
    color: var(--sandstone);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    position: relative;
    padding-left: 0;
    transition: color 0.3s ease, padding-left 0.2s ease;
}

.footer-link::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background-color: var(--citrine-bright);
    opacity: 0;
    transition: opacity 0.2s ease, left 0.2s ease;
}

.footer-link:hover {
    color: var(--citrine-bright);
    padding-left: 8px;
}

.footer-link:hover::before {
    opacity: 1;
    left: -4px;
}

.footer-link::after {
    bottom: -3px;
    height: 1px;
}

.footer-copy {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 0.85rem;
    color: var(--tourmaline-teal);
    letter-spacing: 0.02em;
}

/* --- Mobile Adaptation --- */
@media (max-width: 768px) {
    .f-pattern-layout {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .reading-rail {
        margin-left: 0;
        max-width: 100%;
    }

    .specimen-shelf {
        width: 100%;
        background-color: var(--sandstone);
        padding: clamp(2rem, 4vh, 3rem);
        margin-top: clamp(2rem, 4vh, 3rem);
        clip-path: polygon(0 0, calc(100% - 20px) 0, 100% 20px, 100% 100%, 0 100%);
        transform: translateX(0);
    }

    .alt-bg .specimen-shelf {
        background-color: var(--quartz-white);
    }

    .hex-cluster {
        max-width: 100%;
        justify-content: center;
    }

    .hex-cluster.large {
        max-width: 100%;
    }

    .hero-title {
        flex-wrap: wrap;
    }

    .specimen-card {
        transform: translateX(0) scale(0.95);
    }

    .specimen-card.revealed {
        transform: translateX(0) scale(1);
    }

    .journey-step {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .footer-nav {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
    }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .crystal-line {
        stroke-dashoffset: 0;
    }

    .divider-path {
        stroke-dashoffset: 0;
    }

    .hero-content,
    .hero-subtitle,
    .section-heading,
    .body-text,
    .specimen-card,
    .specimen-shelf,
    .journey-step {
        opacity: 1;
        transform: none;
    }
}
