/* =============================================
   luminary.dev - Art-Deco Celestial Observatory
   ============================================= */

/* CSS Custom Properties */
:root {
    --void-indigo: #0B0E2D;
    --deep-obsidian: #060818;
    --astrolabe-gold: #C9A84C;
    --nebula-teal: #2A7B88;
    --pale-starlight: #E8E3D3;
    --muted-constellation: #8B8A80;
    --supernova-rose: #A3496B;
    --twilight-violet: #3D2E6B;

    --font-display: 'Poiret One', cursive;
    --font-heading: 'Cinzel', serif;
    --font-body: 'Libre Baskerville', serif;

    --margin-frame: 48px;
    --hex-gap: 16px;

    --ease-gravitational: cubic-bezier(0.25, 0.1, 0.25, 1.0);
    --duration-reveal: 1200ms;
    --duration-border: 800ms;
    --duration-sunburst: 600ms;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--void-indigo);
    color: var(--pale-starlight);
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.75;
    letter-spacing: 0.02em;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Canvas Nebula Background */
#nebula-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* Star Field Layer */
#star-field {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

#star-field .star {
    position: absolute;
    border-radius: 50%;
    background-color: var(--pale-starlight);
}

#star-field .star--pulsing {
    animation: starPulse var(--pulse-duration, 5s) ease-in-out infinite;
}

@keyframes starPulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1.0; }
}

/* Constellation lines in star field */
#star-field .constellation-line {
    position: absolute;
    height: 1px;
    background-color: var(--astrolabe-gold);
    opacity: 0.12;
    transform-origin: 0 0;
    pointer-events: none;
}

/* =============================================
   Typography
   ============================================= */

.hero-title {
    font-family: var(--font-display);
    font-size: clamp(3rem, 8vw, 7rem);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--astrolabe-gold);
    line-height: 1.1;
    text-align: center;
}

.hero-subtitle {
    font-family: var(--font-heading);
    font-size: clamp(0.9rem, 2vw, 1.3rem);
    font-weight: 400;
    letter-spacing: 0.08em;
    color: var(--pale-starlight);
    opacity: 0.85;
    margin-top: 1.5rem;
    text-align: center;
}

.section-heading {
    font-family: var(--font-heading);
    font-size: clamp(1.2rem, 3vw, 2rem);
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--pale-starlight);
    margin-bottom: 1.2rem;
}

.section-body {
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.75;
    letter-spacing: 0.02em;
    color: var(--pale-starlight);
    opacity: 0.85;
}

.cell-number {
    display: block;
    font-family: var(--font-display);
    font-size: clamp(2rem, 5vw, 3.5rem);
    letter-spacing: 0.1em;
    color: var(--astrolabe-gold);
    line-height: 1.2;
}

.cell-label {
    display: block;
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted-constellation);
    margin-top: 0.5rem;
}

/* Celestial Map Labels */
.constellation-label {
    font-family: 'Cinzel', serif;
    font-size: 8px;
    fill: var(--muted-constellation);
    letter-spacing: 0.1em;
}

/* =============================================
   Viewport Sections
   ============================================= */

.viewport-section {
    position: relative;
    z-index: 2;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--margin-frame);
}

/* =============================================
   Hero Hexagonal Frame
   ============================================= */

.hex-frame--hero {
    position: relative;
    width: min(80vw, 600px);
    height: min(69.3vw, 520px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.hex-border {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.hex-border-line {
    fill: none;
    stroke: var(--astrolabe-gold);
    stroke-width: 1;
    opacity: 0.6;
    stroke-dasharray: 2200;
    stroke-dashoffset: 2200;
    animation: drawHexBorder var(--duration-border) var(--ease-gravitational) 0.5s forwards;
}

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

.hex-vertex {
    fill: var(--deep-obsidian);
    stroke: var(--astrolabe-gold);
    stroke-width: 1;
    opacity: 0;
    animation: fadeIn 600ms var(--ease-gravitational) 1.3s forwards;
}

@keyframes fadeIn {
    to { opacity: 0.8; }
}

.hex-content--hero {
    position: relative;
    z-index: 2;
    padding: 2rem;
    opacity: 0;
    transform: scale(0.92);
    animation: heroReveal var(--duration-reveal) var(--ease-gravitational) 0.8s forwards;
}

@keyframes heroReveal {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Scroll Indicator */
.scroll-indicator {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    height: 60px;
    overflow: hidden;
}

.scroll-indicator-line {
    width: 1px;
    height: 100%;
    background: linear-gradient(to bottom, transparent, var(--astrolabe-gold), transparent);
    animation: scrollPulse 2.5s ease-in-out infinite;
}

@keyframes scrollPulse {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(100%); }
}

/* =============================================
   Honeycomb Clusters
   ============================================= */

.honeycomb-cluster {
    position: relative;
    display: grid;
    gap: var(--hex-gap);
    max-width: 900px;
    width: 100%;
}

.honeycomb-cluster--left {
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: auto auto;
    justify-self: start;
    padding-right: 10%;
}

.honeycomb-cluster--right {
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: auto auto;
    justify-self: end;
    padding-left: 10%;
}

.hex-cell {
    position: relative;
}

.hex-cell--large {
    grid-column: 1 / 3;
    grid-row: 1 / 3;
}

.hex-cell--small-1 {
    grid-column: 3;
    grid-row: 1;
}

.hex-cell--small-2 {
    grid-column: 3;
    grid-row: 2;
}

.hex-cell--micro {
    display: none;
}

.hex-clip {
    position: relative;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: linear-gradient(135deg, rgba(11, 14, 45, 0.9), rgba(6, 8, 24, 0.95));
    width: 100%;
    padding-top: 115.47%; /* Height ratio for hexagon */
}

.hex-cell--large .hex-clip {
    padding-top: 86.6%; /* Wider hexagon */
}

.hex-cell-border {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: transparent;
    box-shadow: inset 0 0 0 1px rgba(201, 168, 76, 0.6);
}

.hex-cell-border::before {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    bottom: -1px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    border: 1px solid rgba(201, 168, 76, 0.6);
}

.hex-cell-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 75%;
    text-align: center;
}

.hex-cell--large .hex-cell-content {
    width: 80%;
    text-align: left;
}

/* Micro sunburst */
.micro-sunburst {
    width: 48px;
    height: 48px;
}

/* =============================================
   Sunburst Divider
   ============================================= */

.sunburst-divider {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem var(--margin-frame);
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.sunburst-svg {
    width: 100%;
    max-width: 240px;
    height: auto;
}

.sunburst-line-h {
    stroke: var(--astrolabe-gold);
    stroke-width: 1;
    opacity: 0.5;
}

.sunburst-ray {
    stroke: var(--astrolabe-gold);
    stroke-width: 1;
    opacity: 0.6;
}

.sunburst-hex {
    fill: none;
    stroke: var(--astrolabe-gold);
    stroke-width: 1;
    opacity: 0.7;
}

/* Sunburst animation */
.sunburst-divider.revealed .sunburst-ray {
    animation: rayExtend var(--duration-sunburst) var(--ease-gravitational) forwards;
}

@keyframes rayExtend {
    from {
        stroke-dasharray: 40;
        stroke-dashoffset: 40;
    }
    to {
        stroke-dasharray: 40;
        stroke-dashoffset: 0;
    }
}

.sunburst-divider.revealed .sunburst-line-h {
    animation: lineExtend 800ms var(--ease-gravitational) forwards;
}

@keyframes lineExtend {
    from {
        stroke-dasharray: 100;
        stroke-dashoffset: 100;
    }
    to {
        stroke-dasharray: 100;
        stroke-dashoffset: 0;
    }
}

/* =============================================
   Celestial Map
   ============================================= */

.celestial-map-container {
    position: relative;
    width: min(80vw, 600px);
    height: min(80vw, 600px);
}

.celestial-map-svg {
    width: 100%;
    height: 100%;
}

/* =============================================
   Vanishing Point
   ============================================= */

#vanishing-point {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
}

.vanishing-hex {
    width: 60px;
    height: 52px;
    transition: all 2s var(--ease-gravitational);
}

.vanishing-hex-svg {
    width: 100%;
    height: 100%;
}

.vanishing-hex-border {
    fill: none;
    stroke: var(--astrolabe-gold);
    stroke-width: 1;
    opacity: 0.6;
}

.vanishing-hex .hex-vertex {
    opacity: 0.6;
    animation: none;
}

.vanishing-domain {
    font-family: var(--font-display);
    font-size: clamp(0.8rem, 2vw, 1.1rem);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--astrolabe-gold);
    opacity: 0.6;
    margin-top: 2rem;
}

/* =============================================
   Reveal Animations
   ============================================= */

.reveal-element {
    opacity: 0;
    transform: scale(0.92);
    transition: opacity var(--duration-reveal) var(--ease-gravitational),
                transform var(--duration-reveal) var(--ease-gravitational);
}

.reveal-element.revealed {
    opacity: 1;
    transform: scale(1);
}

/* Stagger for honeycomb children */
.honeycomb-cluster.revealed .hex-cell--large {
    opacity: 1;
    transform: scale(1);
    transition-delay: 0ms;
}

.honeycomb-cluster.revealed .hex-cell--small-1 {
    opacity: 1;
    transform: scale(1);
    transition-delay: 200ms;
}

.honeycomb-cluster.revealed .hex-cell--small-2 {
    opacity: 1;
    transform: scale(1);
    transition-delay: 400ms;
}

.honeycomb-cluster.revealed .hex-cell--micro {
    opacity: 1;
    transform: scale(1);
    transition-delay: 600ms;
}

.honeycomb-cluster .hex-cell {
    opacity: 0;
    transform: scale(0.92);
    transition: opacity var(--duration-reveal) var(--ease-gravitational),
                transform var(--duration-reveal) var(--ease-gravitational);
}

/* =============================================
   Hex Cell Hover (Nebula Teal glow)
   ============================================= */

.hex-cell .hex-clip {
    transition: box-shadow 600ms var(--ease-gravitational);
}

.hex-cell:hover .hex-clip {
    filter: drop-shadow(0 0 20px rgba(42, 123, 136, 0.3));
}

.hex-cell:hover .hex-cell-border::before {
    border-color: var(--nebula-teal);
}

/* =============================================
   Responsive: Below 768px
   ============================================= */

@media (max-width: 768px) {
    :root {
        --margin-frame: 24px;
    }

    .honeycomb-cluster {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .hex-cell--large {
        grid-column: 1;
        grid-row: auto;
    }

    .hex-cell--small-1,
    .hex-cell--small-2 {
        grid-column: 1;
        grid-row: auto;
        max-width: 200px;
        margin: 0 auto;
    }

    .hex-cell--micro {
        display: none;
    }

    .hex-frame--hero {
        width: 90vw;
        height: 78vw;
    }

    .hero-title {
        font-size: clamp(2rem, 10vw, 4rem);
    }

    .celestial-map-container {
        width: 90vw;
        height: 90vw;
    }

    .section-heading {
        text-align: center;
    }

    .hex-cell--large .hex-cell-content {
        text-align: center;
    }
}

/* =============================================
   Very small screens
   ============================================= */

@media (max-width: 480px) {
    .viewport-section {
        padding: 16px;
        min-height: auto;
        padding-top: 60px;
        padding-bottom: 60px;
    }

    .hero-title {
        letter-spacing: 0.08em;
    }

    .hex-cell--small-1,
    .hex-cell--small-2 {
        max-width: 160px;
    }
}
