/* ========================================
   archaic.works - Celestial Cartography
   Hexagonal Honeycomb / Luxury Occultism
   ======================================== */

/* --- CSS Custom Properties --- */
:root {
    --bg-void: #0B0B1A;
    --lattice: #2A2A5E;
    --surface-primary: #1E1433;
    --surface-secondary: #2D2250;
    --text-primary: #D4C5A9;
    --text-secondary: #8A8498;
    --text-emphasis: #C4B8D8;
    --accent-warm: #C9944A;
    --accent-glow: #E8D48B;
    --wash-a: #1A2744;
    --wash-b: #2B1A3D;

    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Instrument Serif', serif;
    --font-symbols: 'Noto Sans Symbols 2', sans-serif;

    --elastic-enter: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --elastic-hover: cubic-bezier(0.175, 0.885, 0.32, 1.275);

    --hex-primary-size: 280px;
    --hex-secondary-size: 180px;
    --hex-micro-size: 60px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-void);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.75;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- SVG Filters (hidden) --- */
.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* --- Noise Overlay --- */
#noise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
    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='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    background-repeat: repeat;
}

/* --- Logo Mark --- */
#logo-mark {
    position: fixed;
    top: 24px;
    left: 24px;
    z-index: 100;
    opacity: 0;
    transition: opacity 1.5s ease 3s;
}

body.loaded #logo-mark {
    opacity: 1;
}

/* --- Scroll Indicator --- */
#scroll-indicator {
    position: fixed;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 16px;
    opacity: 0;
    transition: opacity 1.5s ease 3s;
}

body.loaded #scroll-indicator {
    opacity: 1;
}

.scroll-dot {
    width: 12px;
    height: 14px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background-color: var(--lattice);
    transition: background-color 0.6s var(--elastic-hover), transform 0.6s var(--elastic-hover);
    cursor: pointer;
}

.scroll-dot.active {
    background-color: var(--accent-glow);
    transform: scale(1.3);
}

/* --- Chambers (Sections) --- */
.chamber {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* --- Opening Section --- */
#opening {
    height: 100vh;
    position: relative;
}

#opening-star {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    z-index: 10;
}

body.loaded #opening-star {
    animation: fadeInStar 1s ease 0.6s forwards;
}

@keyframes fadeInStar {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* --- Lattice Intro Lines --- */
#lattice-intro {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
}

.lattice-line {
    stroke: var(--lattice);
    stroke-width: 0.5;
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
}

body.loaded .lattice-line {
    animation: drawLine 2s ease 1.2s forwards;
}

@keyframes drawLine {
    to { stroke-dashoffset: 0; }
}

/* --- Chamber Titles --- */
.chamber-title-wrap {
    text-align: center;
    margin-bottom: 60px;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s var(--elastic-enter);
}

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

.chamber-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 56px;
    letter-spacing: 0.08em;
    color: var(--text-primary);
    margin-bottom: 12px;
    text-transform: uppercase;
}

.chamber-subtitle {
    font-family: var(--font-body);
    font-size: 17px;
    color: var(--text-secondary);
    font-style: italic;
}

/* --- Honeycomb Clusters --- */
.honeycomb-cluster {
    position: relative;
    width: 100%;
    max-width: 900px;
    height: 700px;
    margin: 0 auto;
}

.cluster-charts {
    max-width: 1000px;
    height: 900px;
}

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

.constellation-line {
    stroke: var(--lattice);
    stroke-width: 0.5;
    opacity: 0.3;
    animation: pulseLine 8s ease-in-out infinite;
}

.constellation-line:nth-child(2n) {
    animation-delay: -2s;
}

.constellation-line:nth-child(3n) {
    animation-delay: -4s;
}

.constellation-line:nth-child(5n) {
    animation-delay: -6s;
}

@keyframes pulseLine {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.6; }
}

/* --- Hexagonal Cells --- */
.hex {
    position: absolute;
    z-index: 2;
    left: var(--hex-x);
    top: var(--hex-y);
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
    transition: transform 0.7s var(--elastic-enter), opacity 0.5s ease;
}

.hex.visible {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.hex-primary {
    width: var(--hex-primary-size);
    height: calc(var(--hex-primary-size) * 1.1547);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}

.hex-secondary {
    width: var(--hex-secondary-size);
    height: calc(var(--hex-secondary-size) * 1.1547);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}

.hex-micro {
    width: var(--hex-micro-size);
    height: calc(var(--hex-micro-size) * 1.1547);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}

/* --- Hex Inner --- */
.hex-inner {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.hex-primary .hex-inner {
    background: var(--surface-primary);
    box-shadow: inset 0 0 40px rgba(11, 11, 26, 0.3);
}

.hex-secondary .hex-inner {
    background: var(--surface-secondary);
}

.hex-micro .hex-inner {
    background: var(--surface-primary);
}

/* --- Watercolor Bleed (behind clip-path) --- */
.hex-bleed {
    position: absolute;
    top: -8px;
    left: -8px;
    width: calc(100% + 16px);
    height: calc(100% + 16px);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: radial-gradient(ellipse at center, var(--wash-a) 0%, transparent 70%);
    filter: blur(8px);
    opacity: 0.4;
    z-index: -1;
}

/* --- Watercolor Washes --- */
.watercolor-wash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 40% 40%, var(--wash-a) 0%, var(--wash-b) 60%, transparent 100%);
    filter: url(#watercolor);
    opacity: 0.7;
    mix-blend-mode: screen;
}

.watercolor-wash.wash-alt {
    background: radial-gradient(ellipse at 60% 30%, var(--wash-b) 0%, var(--wash-a) 50%, transparent 100%);
}

.watercolor-wash.wash-b {
    background: radial-gradient(ellipse at 30% 60%, #1A2744 0%, #2D2250 50%, transparent 100%);
}

.watercolor-wash.wash-c {
    background: radial-gradient(ellipse at 50% 50%, #2B1A3D 0%, #1A2744 60%, transparent 100%);
}

/* --- Star Maps (SVG inside hexagons) --- */
.star-map {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.6s ease 0.2s;
}

.hex.visible .star-map {
    opacity: 1;
}

/* --- Orbital Rings --- */
.orbital-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 110%;
    height: 110%;
    z-index: 3;
    animation: orbitSpin 40s linear infinite;
    pointer-events: none;
}

.orbital-ring-slow {
    animation-duration: 60s;
}

.orbital-ring-reverse {
    animation-direction: reverse;
    animation-duration: 55s;
}

@keyframes orbitSpin {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Orbital rings in meridian section */
.orbit-spin {
    animation: orbitSpinSimple 40s linear infinite;
    transform-origin: center;
}

.orbit-spin-reverse {
    animation: orbitSpinSimple 40s linear infinite reverse;
    transform-origin: center;
}

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

/* --- Hex Labels (Secondary cells) --- */
.hex-label {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 20px;
    letter-spacing: 0.08em;
    color: var(--text-primary);
    text-transform: uppercase;
    display: block;
    text-align: center;
}

.hex-date {
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
    display: block;
    text-align: center;
}

/* --- Glyphs (Micro hexagons & decorative) --- */
.glyph {
    font-family: var(--font-symbols);
    font-size: 14px;
    color: var(--lattice);
    line-height: 1;
}

.glyph-large {
    font-family: var(--font-symbols);
    font-size: 24px;
    color: var(--lattice);
    line-height: 1;
}

/* --- Hex Hover States --- */
.hex-primary:hover,
.hex-secondary:hover {
    cursor: pointer;
}

.hex-primary::after,
.hex-secondary::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(232, 212, 139, 0.3) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    transition: width 0.6s var(--elastic-hover), height 0.6s var(--elastic-hover);
    pointer-events: none;
    z-index: 10;
}

.hex-primary:hover::after,
.hex-secondary:hover::after {
    width: 120%;
    height: 120%;
}

.hex-primary:hover {
    transform: translate(-50%, -50%) scale(1.03) !important;
    transition: transform 0.6s var(--elastic-hover);
}

.hex-secondary:hover {
    transform: translate(-50%, -50%) scale(1.03) !important;
    transition: transform 0.6s var(--elastic-hover);
}

/* --- Chamber Telescope Transition --- */
.chamber.telescope-out {
    transition: transform 0.6s ease, filter 0.6s ease;
}

.chamber.telescope-out .honeycomb-cluster {
    transform: scale(0.95);
    filter: blur(1px);
    transition: transform 0.6s ease, filter 0.6s ease;
}

.honeycomb-cluster {
    transition: transform 0.6s ease, filter 0.6s ease;
}

/* --- Meridian Section --- */
.meridian-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 60px;
    max-width: 1100px;
    width: 100%;
    padding: 40px 20px;
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 1s ease, transform 1s var(--elastic-enter);
}

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

.meridian-orbital {
    flex-shrink: 0;
    width: 200px;
    opacity: 0.6;
}

.meridian-text {
    max-width: 560px;
    flex: 1;
}

.meridian-body {
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.75;
    color: var(--text-secondary);
    margin-bottom: 28px;
}

.meridian-emphasis {
    color: var(--text-emphasis);
    font-style: italic;
}

.meridian-glyph-row {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin: 40px 0;
    opacity: 0.5;
}

/* --- Closing Section --- */
#closing {
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 40px;
}

#closing-star {
    opacity: 0;
    transition: opacity 1.5s ease;
}

#closing-star.visible {
    opacity: 1;
}

.closing-text {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 18px;
    letter-spacing: 0.15em;
    color: var(--text-primary);
    text-transform: lowercase;
    opacity: 0;
    transition: opacity 1.5s ease 0.5s;
}

#closing-star.visible ~ .closing-text {
    opacity: 0.6;
}

/* --- Hex click pulse --- */
@keyframes hexPulse {
    0% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.02); }
    100% { transform: translate(-50%, -50%) scale(1); }
}

.hex.pulse {
    animation: hexPulse 0.4s var(--elastic-hover);
}

/* --- Responsive --- */
@media (max-width: 900px) {
    :root {
        --hex-primary-size: 200px;
        --hex-secondary-size: 130px;
        --hex-micro-size: 45px;
    }

    .chamber-title {
        font-size: 36px;
    }

    .honeycomb-cluster {
        height: 550px;
    }

    .cluster-charts {
        height: 750px;
    }

    .meridian-content {
        flex-direction: column;
        gap: 30px;
    }

    .meridian-orbital {
        width: 150px;
    }

    .meridian-orbital-left,
    .meridian-orbital-right {
        display: none;
    }
}

@media (max-width: 600px) {
    :root {
        --hex-primary-size: 150px;
        --hex-secondary-size: 100px;
        --hex-micro-size: 36px;
    }

    .chamber-title {
        font-size: 28px;
    }

    .chamber-subtitle {
        font-size: 14px;
    }

    .honeycomb-cluster {
        height: 450px;
    }

    .cluster-charts {
        height: 620px;
    }

    .hex-label {
        font-size: 14px;
    }

    .hex-date {
        font-size: 11px;
    }

    #scroll-indicator {
        right: 12px;
    }

    #logo-mark {
        top: 16px;
        left: 16px;
    }

    .meridian-body {
        font-size: 15px;
    }

    .meridian-glyph-row {
        gap: 20px;
    }

    .glyph-large {
        font-size: 18px;
    }
}
