/* === RESET & BASE === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-snap-type: y proximity;
}

body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    background-color: #0a1628;
    color: #8a9bb5;
    /* palette: #1a2d4a crystal-surface, #3d5a80 crystal-edge */
    font-family: 'Instrument Sans', sans-serif;
    font-weight: 400;
    line-height: 1.7;
}

/* === FONTS === */
.caveat {
    font-family: 'Caveat', cursive;
    letter-spacing: 0.02em;
}

.mono {
    font-family: 'Azeret Mono', monospace;
    font-weight: 300;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: #4a6a8f;
}

/* === PARTICLE CANVAS === */
#particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* === LAYERS === */
.layer {
    position: relative;
    min-height: 100vh;
    width: 100vw;
    z-index: 1;
    scroll-snap-align: start;
}

.layer::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40%;
    pointer-events: none;
    z-index: 2;
}

.layer-0::after {
    background: linear-gradient(to bottom, transparent, rgba(10, 22, 40, 0.3));
}

.layer-1::after {
    background: linear-gradient(to bottom, transparent, rgba(10, 22, 40, 0.45));
}

.layer-2::after {
    background: linear-gradient(to bottom, transparent, rgba(10, 22, 40, 0.55));
}

.layer-3::after {
    background: linear-gradient(to bottom, transparent, rgba(10, 22, 40, 0.7));
}

/* === LAYER 0 — SIGNAL RECEPTION === */
.layer-0 {
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, #0d1f3c 0%, #0a1628 70%);
}

.layer-0 .crystal-container {
    display: flex;
    align-items: center;
    justify-content: center;
}

.crystal-center {
    animation: slowRotate 30s linear infinite;
    transform-origin: center center;
    filter: drop-shadow(0 0 15px rgba(61, 90, 128, 0.2));
    opacity: 0.7;
}

@keyframes slowRotate {
    0% { transform: perspective(800px) rotateY(0deg) rotateX(5deg); }
    50% { transform: perspective(800px) rotateY(180deg) rotateX(-5deg); }
    100% { transform: perspective(800px) rotateY(360deg) rotateX(5deg); }
}

.domain-name {
    position: absolute;
    bottom: 12vh;
    left: 5vw;
    font-family: 'Caveat', cursive;
    font-size: clamp(2rem, 5vw, 4rem);
    font-weight: 700;
    color: #b8a04a;
    letter-spacing: 0.02em;
    text-shadow: 0 0 8px rgba(200, 212, 232, 0.3);
    animation: pulseGlow 4s ease-in-out infinite;
    z-index: 3;
}

@keyframes pulseGlow {
    0%, 100% { text-shadow: 0 0 8px rgba(200, 212, 232, 0.3); }
    50% { text-shadow: 0 0 16px rgba(200, 212, 232, 0.5), 0 0 30px rgba(184, 160, 74, 0.15); }
}

.scroll-hint {
    position: absolute;
    bottom: 4vh;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    opacity: 0.4;
    animation: hintFade 3s ease-in-out infinite;
    z-index: 3;
}

.scroll-hint-text {
    font-family: 'Azeret Mono', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #4a6a8f;
}

.scroll-arrow {
    animation: bobDown 2s ease-in-out infinite;
}

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

@keyframes bobDown {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(4px); }
}

/* === LAYER 1 — FIRST REFRACTION === */
.layer-1 {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 10vh;
    background: radial-gradient(ellipse at 50% 30%, #0d1f3c 0%, #0a1628 60%);
}

.refraction-line {
    position: absolute;
    top: 45%;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(to right, transparent 5%, #c8d4e8 30%, #8a9bb5 50%, #c8d4e8 70%, transparent 95%);
    opacity: 0.25;
    box-shadow: 0 0 20px rgba(200, 212, 232, 0.15);
}

.layer-1 .crystal-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 2vw;
    padding: 0 10vw;
}

.crystal-col-1 { transform: perspective(800px) rotateY(-8deg); opacity: 0.6; align-self: flex-end; }
.crystal-col-2 { transform: perspective(800px) rotateY(3deg); opacity: 0.75; align-self: flex-end; }
.crystal-col-3 { transform: perspective(800px) rotateY(-5deg); opacity: 0.85; align-self: flex-end; }
.crystal-col-4 { transform: perspective(800px) rotateY(6deg); opacity: 0.7; align-self: flex-end; }
.crystal-col-5 { transform: perspective(800px) rotateY(-3deg); opacity: 0.55; align-self: flex-end; }

.layer-1 .crystal-container svg {
    animation: gentleSway 20s ease-in-out infinite;
    filter: drop-shadow(0 0 8px rgba(61, 90, 128, 0.15));
}

.layer-1 .crystal-container svg:nth-child(2) { animation-delay: -4s; }
.layer-1 .crystal-container svg:nth-child(3) { animation-delay: -8s; }
.layer-1 .crystal-container svg:nth-child(4) { animation-delay: -12s; }
.layer-1 .crystal-container svg:nth-child(5) { animation-delay: -16s; }

@keyframes gentleSway {
    0%, 100% { transform: perspective(800px) rotateY(var(--base-ry, 0deg)); }
    50% { transform: perspective(800px) rotateY(calc(var(--base-ry, 0deg) + 8deg)); }
}

.layer-text {
    position: relative;
    z-index: 3;
    text-align: center;
    max-width: 600px;
    padding: 0 2rem;
}

.layer-1-text {
    margin-bottom: 5vh;
}

/* === FROST TEXT === */
.frost-text {
    font-family: 'Caveat', cursive;
    font-size: clamp(1.8rem, 4vw, 3.5rem);
    font-weight: 500;
    color: #c8d4e8;
    text-shadow: 0 0 8px rgba(200, 212, 232, 0.3);
    margin-bottom: 1rem;
    transition: text-shadow 0.4s ease-out;
}

.frost-text:hover {
    text-shadow: 0 0 20px rgba(200, 212, 232, 0.6);
}

.body-text {
    font-family: 'Instrument Sans', sans-serif;
    font-size: clamp(0.875rem, 1.2vw, 1.1rem);
    font-weight: 400;
    line-height: 1.7;
    color: #8a9bb5;
}

/* === LAYER 2 — THE ARCHIVE === */
.layer-2 {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 120vh;
    background: radial-gradient(ellipse at 40% 50%, rgba(26, 45, 74, 0.3) 0%, #0a1628 50%);
}

.archive-cluster {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    max-width: 900px;
    padding: 2rem;
    margin-bottom: 4rem;
}

.crystal-node {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
    transition: transform 0.6s ease, filter 0.6s ease;
}

.crystal-node svg {
    filter: drop-shadow(0 0 6px rgba(61, 90, 128, 0.1));
    transition: filter 0.4s ease;
}

.crystal-node:hover svg {
    filter: drop-shadow(0 0 18px rgba(138, 155, 181, 0.35));
}

.crystal-node:hover {
    transform: scale(1.05);
    z-index: 5;
}

.crystal-node:hover ~ .crystal-node {
    transform: translateX(4px);
}

.node-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    white-space: nowrap;
    opacity: 0.7;
    transition: opacity 0.4s ease, color 0.4s ease;
}

.crystal-node:hover .node-label {
    opacity: 1;
    color: #8a9bb5;
}

.node-1 { transform: translate(-10px, -20px); }
.node-2 { transform: translate(15px, 30px); }
.node-3 { transform: translate(-25px, 10px); }
.node-4 { transform: translate(20px, -15px); }
.node-5 { transform: translate(-5px, 25px); }
.node-6 { transform: translate(10px, -10px); }

.crystal-node:hover.node-1 { transform: translate(-10px, -20px) scale(1.05); }
.crystal-node:hover.node-2 { transform: translate(15px, 30px) scale(1.05); }
.crystal-node:hover.node-3 { transform: translate(-25px, 10px) scale(1.05); }
.crystal-node:hover.node-4 { transform: translate(20px, -15px) scale(1.05); }
.crystal-node:hover.node-5 { transform: translate(-5px, 25px) scale(1.05); }
.crystal-node:hover.node-6 { transform: translate(10px, -10px) scale(1.05); }

.layer-2-text {
    z-index: 3;
}

/* === LAYER 3 — DEEP SIGNAL === */
.layer-3 {
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, #0d1f3c 0%, #0a1628 50%, #070f1e 100%);
}

.layer-3 .crystal-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3vw;
    opacity: 0.6;
}

.deep-crystal-1 {
    animation: slowRotate 40s linear infinite;
    filter: drop-shadow(0 0 20px rgba(61, 90, 128, 0.2));
}

.deep-crystal-2 {
    animation: slowRotate 35s linear infinite reverse;
    filter: drop-shadow(0 0 15px rgba(61, 90, 128, 0.15));
}

.deep-crystal-3 {
    animation: slowRotate 45s linear infinite;
    filter: drop-shadow(0 0 12px rgba(61, 90, 128, 0.12));
}

.pulse-light {
    animation: pulseLightAnim 3s ease-in-out infinite;
}

.deep-crystal-2 .pulse-light { animation-delay: -1s; }
.deep-crystal-3 .pulse-light { animation-delay: -2s; }

@keyframes pulseLightAnim {
    0%, 100% { opacity: 0.3; r: 3; }
    50% { opacity: 0.8; r: 6; }
}

.deep-signal-text {
    position: absolute;
    bottom: 10vh;
    left: 0;
    width: 100%;
    text-align: center;
    z-index: 3;
    padding: 0 2rem;
}

.deep-final {
    font-size: clamp(1.2rem, 2.5vw, 2rem);
    color: #b8a04a;
    text-shadow: 0 0 12px rgba(184, 160, 74, 0.25);
    animation: pulseGlow 5s ease-in-out infinite;
}

/* === GLITCH LINES === */
.glitch-lines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.glitch-line {
    position: absolute;
    left: 0;
    width: 100%;
    height: 1px;
    background: #c8d4e8;
    opacity: 0;
    animation: glitchFlash 100ms linear forwards;
}

@keyframes glitchFlash {
    0% { opacity: 0.6; }
    50% { opacity: 0.8; }
    100% { opacity: 0; }
}

/* === LAYER REVEAL ANIMATIONS === */
.layer {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.layer.visible {
    opacity: 1;
    transform: translateY(0);
}

.layer-0 {
    opacity: 1;
    transform: translateY(0);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .layer-1 .crystal-container {
        gap: 1vw;
        padding: 0 5vw;
    }

    .layer-1 .crystal-container svg {
        width: 40px;
        height: auto;
    }

    .archive-cluster {
        gap: 0.8rem;
        padding: 1rem;
    }

    .crystal-node svg {
        width: 80%;
        height: auto;
    }

    .layer-3 .crystal-container {
        gap: 1vw;
    }

    .deep-crystal-1 { width: 180px; height: auto; }
    .deep-crystal-2 { width: 140px; height: auto; }
    .deep-crystal-3 { width: 110px; height: auto; }

    .node-1, .node-2, .node-3, .node-4, .node-5, .node-6 {
        transform: none;
    }

    .crystal-node:hover.node-1,
    .crystal-node:hover.node-2,
    .crystal-node:hover.node-3,
    .crystal-node:hover.node-4,
    .crystal-node:hover.node-5,
    .crystal-node:hover.node-6 {
        transform: scale(1.05);
    }
}
