/* ============================================
   nonri.xyz — Pixel-Art Celestial Design
   Palette: Gradient (cold violet/magenta)
   Fonts: Bebas Neue, Space Grotesk, Press Start 2P
   ============================================ */

:root {
    --grid: 4px;
    --bg-primary: #0a0a12;
    --bg-secondary: #12122a;
    --gradient-start: #7b2ff7;
    --gradient-mid: #b24bf3;
    --gradient-end: #ff2d95;
    --text-primary: #e8e6f0;
    --text-secondary: #8a8899;
    --accent-warm: #ffb830;
    --surface-grain: #1a1a2e;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 400;
    font-size: clamp(0.875rem, 2vw, 1.125rem);
    line-height: 1.7;
    overflow-x: hidden;
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='16' viewBox='0 0 12 16'%3E%3Crect x='0' y='0' width='4' height='4' fill='%230a0a12'/%3E%3Crect x='0' y='0' width='4' height='12' fill='%23e8e6f0'/%3E%3Crect x='4' y='4' width='4' height='4' fill='%23e8e6f0'/%3E%3Crect x='8' y='8' width='4' height='4' fill='%23e8e6f0'/%3E%3Crect x='4' y='8' width='4' height='4' fill='%23e8e6f0'/%3E%3Crect x='0' y='12' width='4' height='4' fill='%23e8e6f0'/%3E%3C/svg%3E") 0 0, auto;
    -webkit-font-smoothing: antialiased;
    font-feature-settings: 'tnum';
    border-radius: 0;
}

/* ============================================
   Grain Overlay
   ============================================ */
.grain {
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    opacity: 0.12;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    background-size: 200px 200px;
    mix-blend-mode: overlay;
    animation: grain-shift 0.3s steps(4) infinite;
}

@keyframes grain-shift {
    0% { transform: translate(0, 0); }
    25% { transform: translate(-8px, 4px); }
    50% { transform: translate(4px, -8px); }
    75% { transform: translate(-4px, -4px); }
    100% { transform: translate(8px, 8px); }
}

/* ============================================
   Starfield
   ============================================ */
.starfield {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.pixel-star {
    position: absolute;
    background-color: var(--text-primary);
    animation: star-pulse var(--pulse-dur, 3s) steps(2) infinite alternate;
}

@keyframes star-pulse {
    0% { opacity: 0.3; }
    100% { opacity: 1; }
}

/* ============================================
   Navigation FAB
   ============================================ */
.nav-fab {
    position: fixed;
    bottom: calc(var(--grid) * 8);
    right: calc(var(--grid) * 8);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: calc(var(--grid) * 4);
}

.nav-btn {
    width: calc(var(--grid) * 12);
    height: calc(var(--grid) * 12);
    background: var(--bg-secondary);
    border: 2px solid var(--gradient-start);
    border-radius: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: none;
    animation: nav-glow 3s steps(4) infinite alternate;
    padding: 0;
}

.nav-btn:hover {
    border-color: var(--gradient-end);
    background: var(--bg-primary);
}

@keyframes nav-glow {
    0% { box-shadow: 0 0 8px rgba(123, 47, 247, 0.2); }
    50% { box-shadow: 0 0 16px rgba(178, 75, 243, 0.3); }
    100% { box-shadow: 0 0 8px rgba(255, 45, 149, 0.2); }
}

/* ============================================
   Sections Common
   ============================================ */
.section {
    position: relative;
    min-height: 100vh;
    width: 100%;
}

.section-label {
    font-family: 'Press Start 2P', cursive;
    font-size: clamp(0.5rem, 1.5vw, 0.75rem);
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    position: absolute;
    top: calc(var(--grid) * 8);
    left: calc(var(--grid) * 8);
    opacity: 0.6;
}

/* ============================================
   Section 1: The Void
   ============================================ */
.section-void {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    z-index: 1;
    position: relative;
}

.void-content {
    text-align: center;
    position: relative;
    z-index: 2;
}

.logotype {
    font-family: 'Bebas Neue', sans-serif;
    font-weight: 400;
    font-size: clamp(3rem, 10vw, 8rem);
    letter-spacing: 0.12em;
    text-rendering: geometricPrecision;
    -webkit-font-smoothing: none;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-mid), var(--gradient-end));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    box-shadow: none;
    position: relative;
    display: inline-block;
}

.logotype::after {
    content: '';
    position: absolute;
    inset: -40px;
    background: radial-gradient(ellipse at center, rgba(123, 47, 247, 0.15) 0%, transparent 70%);
    z-index: -1;
    pointer-events: none;
}

.logo-char {
    display: inline-block;
    opacity: 0;
    transform: translateY(calc(var(--grid) * 1));
}

.logo-char.revealed {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.08s steps(2), transform 0.08s steps(2);
    transition-delay: calc(var(--i) * 0.08s);
}

.subtitle {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    margin-top: calc(var(--grid) * 6);
    min-height: 1.5em;
}

.sub-char {
    opacity: 0;
}

.sub-char.revealed {
    opacity: 1;
}

.scroll-indicator {
    position: absolute;
    bottom: calc(var(--grid) * -40);
    left: 50%;
    transform: translateX(-50%);
    animation: bounce-arrow 1s steps(2) infinite;
    opacity: 0;
}

.scroll-indicator.visible {
    opacity: 0.6;
}

@keyframes bounce-arrow {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(calc(var(--grid) * 1)); }
}

/* ============================================
   Constellation SVG
   ============================================ */
.constellation-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 300vh;
    z-index: 2;
    pointer-events: none;
}

.constellation-path {
    fill: none;
    stroke: url(#pathGradient);
    stroke-width: 1.5;
    stroke-linecap: square;
    stroke-dasharray: var(--path-length, 1000);
    stroke-dashoffset: var(--path-length, 1000);
}

.constellation-path.drawn {
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   Section 2: The Map
   ============================================ */
.section-map {
    position: relative;
    z-index: 3;
}

.constellation-container {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.glyph {
    position: absolute;
    width: 280px;
    background: var(--bg-secondary);
    border: 2px solid;
    border-image: linear-gradient(135deg, #7b2ff7, #ff2d95) 1;
    padding: calc(var(--grid) * 6);
    box-shadow: 0 0 30px rgba(123, 47, 247, 0.08);
    border-radius: 0;
    opacity: 0;
    transform: translateY(calc(var(--grid) * 4));
}

.glyph.visible {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.4s steps(4), transform 0.4s steps(4);
}

/* Pentagonal star placement */
.glyph[data-glyph="1"] {
    top: 8%;
    left: 50%;
    transform: translateX(-50%) translateY(calc(var(--grid) * 4));
}
.glyph[data-glyph="1"].visible {
    transform: translateX(-50%) translateY(0);
}

.glyph[data-glyph="2"] {
    top: 30%;
    right: 8%;
}

.glyph[data-glyph="3"] {
    bottom: 12%;
    right: 18%;
}

.glyph[data-glyph="4"] {
    bottom: 12%;
    left: 18%;
}

.glyph[data-glyph="5"] {
    top: 30%;
    left: 8%;
}

.glyph-icon {
    margin-bottom: calc(var(--grid) * 3);
}

.glyph-heading {
    font-family: 'Bebas Neue', sans-serif;
    font-weight: 400;
    font-size: clamp(1.4rem, 4vw, 3.5rem);
    letter-spacing: 0.12em;
    text-rendering: geometricPrecision;
    -webkit-font-smoothing: none;
    color: var(--text-primary);
    margin-bottom: calc(var(--grid) * 2);
    line-height: 1.1;
}

.glyph-text {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Supernova burst */
.supernova {
    position: absolute;
    width: 0;
    height: 0;
    border-radius: 0;
    pointer-events: none;
    z-index: 5;
    opacity: 0;
}

.supernova.burst {
    animation: supernova-explode 0.6s steps(6) forwards;
}

@keyframes supernova-explode {
    0% {
        width: 0;
        height: 0;
        opacity: 1;
        background: radial-gradient(circle, #7b2ff7, transparent);
    }
    33% {
        width: 100px;
        height: 100px;
        margin-left: -50px;
        margin-top: -50px;
        opacity: 0.8;
        background: radial-gradient(circle, #ff2d95, transparent);
    }
    66% {
        width: 200px;
        height: 200px;
        margin-left: -100px;
        margin-top: -100px;
        opacity: 0.4;
        background: radial-gradient(circle, #ffb830, transparent);
    }
    100% {
        width: 200px;
        height: 200px;
        margin-left: -100px;
        margin-top: -100px;
        opacity: 0;
        background: radial-gradient(circle, transparent, transparent);
    }
}

/* ============================================
   Section 3: The Signal
   ============================================ */
.section-signal {
    position: relative;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: calc(var(--grid) * 20) 0;
}

.signal-tower-container {
    position: relative;
    width: 320px;
    height: 480px;
    margin: 0 auto;
}

.signal-tower {
    width: 320px;
    height: 480px;
    display: grid;
    grid-template-columns: repeat(80, 4px);
    grid-template-rows: repeat(120, 4px);
    position: relative;
    overflow: hidden;
}

.tower-pixel {
    width: 4px;
    height: 4px;
    opacity: 0;
}

.tower-pixel.revealed {
    opacity: 1;
    transition: opacity 0.03s steps(1);
}

/* Signal waves */
.signal-wave {
    position: absolute;
    border: 2px solid;
    border-image: linear-gradient(135deg, #7b2ff7, #ff2d95) 1;
    opacity: 0;
    pointer-events: none;
}

.signal-wave-1 {
    width: 80px;
    height: 80px;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
}

.signal-wave-2 {
    width: 140px;
    height: 140px;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
}

.signal-wave-3 {
    width: 200px;
    height: 200px;
    top: -80px;
    left: 50%;
    transform: translateX(-50%);
}

.signal-wave.active {
    animation: wave-pulse 2s steps(4) infinite;
}

@keyframes wave-pulse {
    0% { opacity: 0.6; transform: translateX(-50%) scale(1); }
    50% { opacity: 0.2; transform: translateX(-50%) scale(1.2); }
    100% { opacity: 0.6; transform: translateX(-50%) scale(1); }
}

.signal-wave-2.active {
    animation-delay: 0.4s;
}

.signal-wave-3.active {
    animation-delay: 0.8s;
}

/* Orbit Glyphs */
.orbit-container {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 600px;
    height: 600px;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.orbit-glyph {
    position: absolute;
    background: var(--bg-secondary);
    border: 1px solid;
    border-image: linear-gradient(135deg, #7b2ff7, #ff2d95) 1;
    padding: calc(var(--grid) * 2) calc(var(--grid) * 3);
    opacity: 0;
}

.orbit-glyph.orbiting {
    opacity: 1;
    animation-play-state: running;
}

.orbit-glyph-1 {
    top: 0;
    left: 50%;
    animation: orbit-1 60s linear infinite paused;
}

.orbit-glyph-2 {
    top: 50%;
    right: 0;
    animation: orbit-2 60s linear infinite paused;
    animation-delay: -20s;
}

.orbit-glyph-3 {
    bottom: 0;
    left: 30%;
    animation: orbit-3 60s linear infinite paused;
    animation-delay: -40s;
}

@keyframes orbit-1 {
    0% { transform: rotate(0deg) translateX(240px) rotate(0deg); }
    100% { transform: rotate(360deg) translateX(240px) rotate(-360deg); }
}

@keyframes orbit-2 {
    0% { transform: rotate(0deg) translateX(200px) rotate(0deg); }
    100% { transform: rotate(360deg) translateX(200px) rotate(-360deg); }
}

@keyframes orbit-3 {
    0% { transform: rotate(0deg) translateX(280px) rotate(0deg); }
    100% { transform: rotate(360deg) translateX(280px) rotate(-360deg); }
}

.orbit-label {
    font-family: 'Press Start 2P', cursive;
    font-size: clamp(0.5rem, 1.5vw, 0.625rem);
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* End Transmission */
.end-transmission {
    margin-top: calc(var(--grid) * 20);
    text-align: center;
    opacity: 1;
    transition: opacity 0.3s steps(4);
}

.end-text {
    font-family: 'Press Start 2P', cursive;
    font-size: clamp(0.5rem, 1.5vw, 0.75rem);
    letter-spacing: 0.08em;
    color: var(--text-secondary);
}

/* ============================================
   Responsive: Mobile
   ============================================ */
@media (max-width: 768px) {
    .constellation-container {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: calc(var(--grid) * 8);
        padding: calc(var(--grid) * 20) calc(var(--grid) * 4);
        height: auto;
    }

    .glyph {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
        transform: none !important;
        width: calc(100% - calc(var(--grid) * 8));
    }

    .glyph[data-glyph="1"] { margin-left: 8%; }
    .glyph[data-glyph="2"] { margin-left: 16%; }
    .glyph[data-glyph="3"] { margin-left: 24%; }
    .glyph[data-glyph="4"] { margin-left: 8%; }
    .glyph[data-glyph="5"] { margin-left: 16%; }

    .glyph.visible {
        transform: none !important;
    }

    .orbit-container {
        display: none;
    }

    .signal-tower-container {
        width: 240px;
        height: 360px;
    }

    .signal-tower {
        width: 240px;
        height: 360px;
        grid-template-columns: repeat(60, 4px);
        grid-template-rows: repeat(90, 4px);
    }

    .nav-fab {
        bottom: calc(var(--grid) * 4);
        right: calc(var(--grid) * 4);
    }

    .section-label {
        top: calc(var(--grid) * 4);
        left: calc(var(--grid) * 4);
    }
}

/* ============================================
   Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .grain {
        animation: none;
    }

    .pixel-star {
        animation: none;
        opacity: 0.6;
    }

    .supernova {
        display: none;
    }

    .signal-wave {
        animation: none;
    }

    .orbit-glyph {
        animation: none;
    }

    .nav-btn {
        animation: none;
    }

    .scroll-indicator {
        animation: none;
    }
}
