/* ============================================
   relativity.studio - Styles
   Pixel-Art Terracotta Observatory
   ============================================ */

/* --- PALETTE --- */
:root {
    --baked-clay: #D4836A;
    --kiln-dark: #3B1F14;
    --solar-gold: #E8B84B;
    --observatory-blue: #4A7B9D;
    --parchment: #F5E6D3;
    --charred-umber: #2C1810;
    --nebula-rose: #C75B7A;
    --tile-line: #A0654F;

    --tile: 16px;
    --gutter: 32px;
    --max-width: 1024px;
    --section-gap: 48px;
}

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

html {
    font-size: 16px;
    scroll-behavior: auto;
    image-rendering: pixelated;
}

body {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    line-height: 1.65;
    color: var(--parchment);
    background-color: var(--kiln-dark);
    overflow-x: hidden;
}

/* --- PIXEL GRID OVERLAY --- */
#pixel-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    background-image:
        repeating-linear-gradient(
            to right,
            var(--tile-line) 0px,
            var(--tile-line) 1px,
            transparent 1px,
            transparent 16px
        ),
        repeating-linear-gradient(
            to bottom,
            var(--tile-line) 0px,
            var(--tile-line) 1px,
            transparent 1px,
            transparent 16px
        );
    opacity: 0.06;
}

/* --- TYPOGRAPHY --- */
.site-title {
    font-family: 'Alfa Slab One', serif;
    font-weight: 400;
    font-size: clamp(2.5rem, 7vw, 5rem);
    letter-spacing: 0.04em;
    color: var(--parchment);
    line-height: 1.1;
}

.title-dot {
    color: var(--solar-gold);
}

.section-title {
    font-family: 'Zilla Slab', serif;
    font-weight: 600;
    font-size: clamp(1.25rem, 3vw, 2rem);
    letter-spacing: 0.02em;
    color: var(--parchment);
    margin-bottom: var(--gutter);
}

.pixel-font {
    font-family: 'Silkscreen', monospace;
    font-size: 16px;
    letter-spacing: 0.05em;
}

h3, .card-title, .chart-entry-title, .archive-title {
    font-family: 'Zilla Slab', serif;
    font-weight: 600;
    font-size: clamp(1.125rem, 2.5vw, 1.5rem);
    letter-spacing: 0.02em;
    color: var(--parchment);
}

p, .card-body, .chart-entry-body, .archive-body {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.125rem);
    line-height: 1.65;
    color: var(--parchment);
}

/* --- PIXEL-ART BORDER (box-shadow stacking) --- */
.pixel-border {
    box-shadow:
        2px 0 0 0 var(--tile-line),
        -2px 0 0 0 var(--tile-line),
        0 2px 0 0 var(--tile-line),
        0 -2px 0 0 var(--tile-line),
        4px 0 0 0 var(--tile-line),
        -4px 0 0 0 var(--tile-line),
        0 4px 0 0 var(--tile-line),
        0 -4px 0 0 var(--tile-line);
}

/* --- SECTIONS --- */
.section {
    position: relative;
    min-height: 100vh;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--section-gap) var(--gutter);
}

.section-number {
    color: var(--tile-line);
    margin-bottom: var(--tile);
}

/* ============================================
   SECTION 1: OBSERVATORY HEADER
   ============================================ */
#observatory {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    position: relative;
    overflow: hidden;
}

.starfield {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.observatory-content {
    position: relative;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: var(--gutter);
}

.shutter {
    flex: 1;
}

.site-tagline {
    color: var(--tile-line);
    margin-top: var(--tile);
}

.telescope-container {
    flex: 0 0 auto;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.telescope-svg {
    image-rendering: pixelated;
}

/* Macro stars */
.macro-star {
    position: absolute;
    z-index: 1;
    animation: starPulse 3s ease-in-out infinite;
}

.macro-star-1 {
    top: 15%;
    right: 20%;
}

.macro-star-2 {
    bottom: 25%;
    left: 10%;
}

@keyframes starPulse {
    0%, 100% { transform: scale(1.0); }
    50% { transform: scale(1.05); }
}

/* Scroll hint */
.scroll-hint {
    position: absolute;
    bottom: var(--section-gap);
    left: 50%;
    transform: translateX(-50%);
    color: var(--tile-line);
    z-index: 2;
    text-align: center;
}

.scroll-arrow {
    display: inline-block;
    animation: arrowBounce 1.5s steps(3) infinite;
}

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

/* ============================================
   SECTION 2: STAR CHART
   ============================================ */
#star-chart {
    background-color: var(--kiln-dark);
}

.star-chart-layout {
    display: flex;
    gap: var(--gutter);
    align-items: flex-start;
}

.constellation-panel {
    flex: 0 0 60%;
    max-width: 60%;
}

.constellation-svg {
    width: 100%;
    height: auto;
    image-rendering: auto;
}

.constellation-line {
    stroke-dasharray: 8 8;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 0.8s ease;
}

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

.star-node {
    image-rendering: pixelated;
}

.chart-text-panel {
    flex: 0 0 40%;
    max-width: 40%;
    display: flex;
    flex-direction: column;
    gap: var(--section-gap);
}

.chart-entry {
    padding: var(--gutter);
    background-color: rgba(43, 24, 16, 0.6);
    box-shadow:
        2px 0 0 0 var(--tile-line),
        -2px 0 0 0 var(--tile-line),
        0 2px 0 0 var(--tile-line),
        0 -2px 0 0 var(--tile-line),
        4px 0 0 0 var(--tile-line),
        -4px 0 0 0 var(--tile-line),
        0 4px 0 0 var(--tile-line),
        0 -4px 0 0 var(--tile-line);
}

.chart-entry-title {
    margin-bottom: 8px;
}

.chart-entry-coord {
    color: var(--observatory-blue);
    margin-bottom: var(--tile);
    font-size: 12px;
}

.chart-entry-body {
    color: var(--parchment);
    opacity: 0.85;
}

/* ============================================
   SECTION 3: COSMIC LABORATORY
   ============================================ */
#cosmic-lab {
    background-color: var(--charred-umber);
}

.lab-workbench {
    display: flex;
    gap: var(--gutter);
    justify-content: center;
    flex-wrap: wrap;
}

.experiment-card {
    flex: 0 0 288px;
    max-width: 288px;
    padding: var(--gutter);
    background-color: var(--kiln-dark);
    box-shadow:
        2px 0 0 0 var(--tile-line),
        -2px 0 0 0 var(--tile-line),
        0 2px 0 0 var(--tile-line),
        0 -2px 0 0 var(--tile-line),
        4px 0 0 0 var(--tile-line),
        -4px 0 0 0 var(--tile-line),
        0 4px 0 0 var(--tile-line),
        0 -4px 0 0 var(--tile-line);
    text-align: center;
}

.card-header {
    color: var(--solar-gold);
    margin-bottom: var(--tile);
    font-size: 14px;
}

.experiment-shape {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: var(--gutter);
    image-rendering: pixelated;
}

.experiment-shape svg {
    image-rendering: pixelated;
}

.card-title {
    margin-bottom: 8px;
}

.card-body {
    opacity: 0.85;
    font-size: clamp(0.875rem, 1.5vw, 1rem);
}

/* ============================================
   SECTION 4: CELESTIAL ARCHIVE
   ============================================ */
#celestial-archive {
    background-color: var(--kiln-dark);
}

.archive-layout {
    display: flex;
    gap: var(--gutter);
    position: relative;
}

.archive-entries {
    flex: 0 0 75%;
    max-width: 75%;
    display: flex;
    flex-direction: column;
    gap: var(--gutter);
}

.archive-card {
    padding: var(--gutter);
    background-color: rgba(43, 24, 16, 0.5);
    box-shadow:
        2px 0 0 0 var(--tile-line),
        -2px 0 0 0 var(--tile-line),
        0 2px 0 0 var(--tile-line),
        0 -2px 0 0 var(--tile-line),
        4px 0 0 0 var(--tile-line),
        -4px 0 0 0 var(--tile-line),
        0 4px 0 0 var(--tile-line),
        0 -4px 0 0 var(--tile-line);
}

.archive-date {
    color: var(--observatory-blue);
    margin-bottom: 8px;
    font-size: 12px;
}

.archive-title {
    color: var(--solar-gold);
    margin-bottom: 8px;
}

.archive-body {
    opacity: 0.85;
}

.archive-floating-stars {
    flex: 0 0 25%;
    max-width: 25%;
    position: relative;
    min-height: 400px;
}

/* Floating star in archive sidebar */
.floating-star {
    position: absolute;
    pointer-events: none;
}

.floating-star svg {
    image-rendering: pixelated;
}

/* ============================================
   FOOTER
   ============================================ */
.section-footer {
    background-color: var(--charred-umber);
    padding: var(--section-gap) var(--gutter);
    text-align: center;
}

.footer-content {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--gutter);
}

.footer-text {
    color: var(--tile-line);
    font-size: 14px;
}

.footer-stars svg {
    animation: starPulse 3s ease-in-out infinite;
}

/* ============================================
   SLIDE-REVEAL ANIMATIONS
   ============================================ */
.slide-left {
    opacity: 0;
    transform: translateX(-100px);
    transition: opacity 600ms cubic-bezier(0.34, 1.56, 0.64, 1),
                transform 600ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.slide-right {
    opacity: 0;
    transform: translateX(100px);
    transition: opacity 600ms cubic-bezier(0.34, 1.56, 0.64, 1),
                transform 600ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.slide-up {
    opacity: 0;
    transform: translateY(80px);
    transition: opacity 600ms cubic-bezier(0.34, 1.56, 0.64, 1),
                transform 600ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.slide-left.revealed,
.slide-right.revealed,
.slide-up.revealed {
    opacity: 1;
    transform: translate(0, 0);
}

/* ============================================
   STAR TWINKLING (steps() for pixel-art snap)
   ============================================ */
@keyframes twinkle1 {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.8; }
}

@keyframes twinkle2 {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 0.2; }
}

@keyframes twinkle3 {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 0.4; }
}

.micro-star {
    position: absolute;
    background-color: var(--solar-gold);
    image-rendering: pixelated;
}

.micro-star.rose {
    background-color: var(--nebula-rose);
}

.medium-star {
    position: absolute;
    image-rendering: pixelated;
}

/* ============================================
   MORPH ANIMATIONS FOR EXPERIMENT SHAPES
   ============================================ */
@keyframes morphDiamond {
    0%, 100% {
        d: path("M64,8 L120,64 L64,120 L8,64 Z");
    }
    33% {
        d: path("M64,16 L112,32 L96,112 L16,96 Z");
    }
    66% {
        d: path("M48,8 L120,48 L80,120 L8,80 Z");
    }
}

@keyframes morphCircleRadius {
    0%, 100% { r: 48; }
    50% { r: 36; }
}

@keyframes morphRectangle {
    0%, 100% {
        x: 16; y: 16; width: 96; height: 96;
    }
    33% {
        x: 8; y: 32; width: 112; height: 64;
    }
    66% {
        x: 32; y: 8; width: 64; height: 112;
    }
}

#morph-poly-1 {
    animation: morphDiamond 8s ease-in-out infinite;
}

#morph-circle-2 {
    animation: morphCircleRadius 6s ease-in-out infinite;
}

#morph-rect-3 {
    animation: morphRectangle 7s ease-in-out infinite;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .observatory-content {
        flex-direction: column;
        text-align: center;
    }

    .telescope-container {
        justify-content: center;
    }

    .star-chart-layout {
        flex-direction: column;
    }

    .constellation-panel,
    .chart-text-panel {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .lab-workbench {
        flex-direction: column;
        align-items: center;
    }

    .experiment-card {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .archive-layout {
        flex-direction: column;
    }

    .archive-entries {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .archive-floating-stars {
        display: none;
    }
}
