/* ============================================
   sora.quest — Dark-Academia Sky Atlas
   ============================================ */

/* Custom Properties */
:root {
    --bg-primary: #0b1a2b;
    --bg-secondary: #132d46;
    --accent-warm: #d4a04a;
    --accent-warm-hover: #e0b05a;
    --accent-cool: #3e8e9c;
    --text-primary: #e8e0d4;
    --text-muted: #6a8fa7;
    --grid-line: #1e3a54;
    --highlight: #c47d5a;
    --spacing-section: 80px;
    --gutter-width: 120px;
    --content-max: 520px;
}

/* 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: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.1vw, 1.15rem);
    line-height: 1.72;
    overflow-x: hidden;
    position: relative;
}

/* Noise Overlay */
.noise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
}

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

h1, h2 {
    font-family: 'Albert Sans', sans-serif;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: var(--text-primary);
}

.site-title {
    font-size: clamp(3rem, 7vw, 6rem);
    line-height: 1.05;
}

.site-subtitle {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(1rem, 1.5vw, 1.2rem);
    color: var(--text-muted);
    margin-top: 12px;
}

.section-heading {
    font-size: clamp(1.8rem, 4vw, 3rem);
    margin-bottom: 32px;
    font-weight: 700;
}

/* Annotation typography */
.section-number,
.annotation-mark,
.footer-label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* ============================================
   Links
   ============================================ */

.text-link {
    color: var(--accent-warm);
    text-decoration: none;
    position: relative;
    cursor: pointer;
}

.text-link::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 0;
    height: 1px;
    background-color: var(--accent-warm-hover);
    transition: width 200ms ease;
}

.text-link:hover {
    color: var(--accent-warm-hover);
}

.text-link:hover::after {
    width: 100%;
}

/* ============================================
   Opening Observatory
   ============================================ */

.observatory {
    position: relative;
    height: 100vh;
    min-height: 600px;
    background: var(--bg-primary);
    overflow: hidden;
}

.collage-hero {
    position: absolute;
    top: 10%;
    left: 55%;
    width: 350px;
    height: 350px;
}

.collage-hero .collage-base {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    border-radius: 50%;
}

.collage-hero .collage-grid {
    position: absolute;
    inset: -20px;
    background-image:
        repeating-linear-gradient(30deg, var(--grid-line) 0px, var(--grid-line) 1px, transparent 1px, transparent 40px);
    opacity: 0.5;
    mix-blend-mode: screen;
}

.collage-hero .celestial-circle {
    position: absolute;
    width: 300px;
    height: 300px;
    top: 10%;
    left: 10%;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent-warm) 0%, transparent 70%);
    opacity: 0.5;
    border: 1px solid var(--accent-cool);
    transition: box-shadow 400ms ease;
}

.collage-hero .celestial-circle:hover {
    box-shadow: 0 0 40px rgba(62, 142, 156, 0.3);
    border-color: var(--accent-cool);
}

.collage-hero .grid-fragments {
    position: absolute;
    top: 75%;
    left: -30%;
}

.collage-hero .fragment {
    display: block;
    height: 1px;
    background: var(--grid-line);
    margin-bottom: 16px;
}

.collage-hero .f1 { width: 120px; }
.collage-hero .f2 { width: 200px; }
.collage-hero .f3 { width: 80px; }
.collage-hero .f4 { width: 150px; }

.hero-content {
    position: absolute;
    left: 15%;
    top: 70%;
    transform: translateY(-50%);
}

.horizon-line {
    margin-top: 24px;
    height: 1px;
    background: var(--accent-warm);
    width: 0;
    transition: width 1.2s ease-out 0.5s;
}

.observatory.visible .horizon-line {
    width: calc(85vw - 15%);
}

.hero-gutter {
    position: absolute;
    left: 4%;
    top: 50%;
}

/* ============================================
   Section Layout
   ============================================ */

.codex-section {
    position: relative;
    min-height: 80vh;
    padding: var(--spacing-section) 0;
    /* Zoom-focus initial state */
    transform: scale(0.96);
    opacity: 0.4;
    filter: blur(2px);
    transition: transform 600ms ease-out, opacity 600ms ease-out, filter 600ms ease-out;
}

.codex-section.in-view {
    transform: scale(1);
    opacity: 1;
    filter: blur(0);
}

.section-grid {
    display: grid;
    grid-template-columns: var(--gutter-width) 1fr minmax(300px, var(--content-max)) 1fr;
    gap: 0;
    align-items: start;
    padding: 0 24px;
    min-height: 60vh;
}

.section-grid.reversed {
    grid-template-columns: var(--gutter-width) 1fr minmax(300px, var(--content-max)) 1fr;
}

/* Annotation Gutter */
.annotation-gutter {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-top: 8px;
}

.grid-fragment-small {
    display: block;
    width: 40px;
    height: 1px;
    background: var(--grid-line);
    margin-top: 12px;
}

/* Content */
.section-content {
    max-width: var(--content-max);
}

.section-content p {
    margin-bottom: 20px;
    max-width: var(--content-max);
}

/* Section placement in normal grid */
.section-grid > .annotation-gutter { grid-column: 1; }
.section-grid > .section-spacer-left { grid-column: 2; }
.section-grid > .section-content { grid-column: 3; }
.section-grid > .section-visual.right-visual { grid-column: 4; }

/* Reversed layout */
.section-grid.reversed > .annotation-gutter { grid-column: 1; }
.section-grid.reversed > .section-visual.left-visual { grid-column: 2; }
.section-grid.reversed > .section-content { grid-column: 3; }
.section-grid.reversed > .section-spacer-right { grid-column: 4; }

/* ============================================
   Section Dividers
   ============================================ */

.section-divider {
    position: relative;
    height: 1px;
    margin: var(--spacing-section) var(--gutter-width);
}

.section-divider::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 1px;
    width: 100%;
    background: var(--grid-line);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 800ms ease-in-out;
}

.codex-section.in-view .section-divider::after {
    transform: scaleX(1);
}

/* ============================================
   Collage Compositions
   ============================================ */

.collage-composition {
    position: relative;
    width: 100%;
    min-height: 300px;
    height: 400px;
}

.collage-composition .collage-base {
    position: absolute;
    inset: 0;
    background: linear-gradient(160deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    border-radius: 4px;
}

.collage-composition .collage-base.angle2 {
    background: linear-gradient(220deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

.collage-composition .collage-base.angle3 {
    background: linear-gradient(45deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
}

.collage-composition .collage-grid {
    position: absolute;
    inset: 0;
    background-image:
        repeating-linear-gradient(0deg, var(--grid-line) 0px, var(--grid-line) 1px, transparent 1px, transparent 50px),
        repeating-linear-gradient(90deg, var(--grid-line) 0px, var(--grid-line) 1px, transparent 1px, transparent 50px);
    opacity: 0.4;
    mix-blend-mode: screen;
}

.collage-composition .collage-grid.rotated {
    transform: rotate(15deg) scale(1.2);
}

.collage-composition .collage-grid.rotated-alt {
    transform: rotate(-30deg) scale(1.3);
}

/* Celestial Circles */
.collage-composition .celestial-circle {
    position: absolute;
    border-radius: 50%;
    transition: box-shadow 400ms ease, border-color 400ms ease;
}

.celestial-circle.small {
    width: 80px;
    height: 80px;
    top: 20%;
    left: 60%;
}

.celestial-circle.tiny {
    width: 40px;
    height: 40px;
    top: 70%;
    left: 30%;
}

.celestial-circle.medium {
    width: 150px;
    height: 150px;
    top: 25%;
    left: 40%;
}

.celestial-circle.large {
    width: 250px;
    height: 250px;
    top: 10%;
    left: 20%;
}

.celestial-circle.amber {
    background: radial-gradient(circle, var(--accent-warm) 0%, transparent 70%);
    border: 1px solid var(--accent-cool);
    opacity: 0.5;
}

.celestial-circle.teal {
    background: radial-gradient(circle, var(--accent-cool) 0%, transparent 70%);
    border: 1px solid var(--accent-warm);
    opacity: 0.4;
}

.celestial-circle:hover {
    box-shadow: 0 0 30px rgba(62, 142, 156, 0.3);
}

/* Book Edges */
.book-edges {
    position: absolute;
    bottom: 15%;
    left: 10%;
    display: flex;
    gap: 3px;
}

.book-edges span {
    display: block;
    width: 8px;
    height: 60px;
    background: var(--bg-secondary);
    opacity: 0.6;
}

.book-edges span:nth-child(even) {
    height: 80px;
    background: var(--grid-line);
    opacity: 0.8;
}

.book-edges span:nth-child(3n) {
    height: 100px;
    opacity: 0.4;
}

/* Horizon Accent */
.horizon-accent {
    position: absolute;
    top: 33%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--accent-warm);
    opacity: 0.6;
}

.horizon-accent.bottom {
    top: auto;
    bottom: 33%;
}

/* Strata Layers */
.strata-layers {
    position: absolute;
    inset: 10%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.stratum {
    height: 2px;
    border-radius: 1px;
}

.stratum.s1 {
    background: linear-gradient(90deg, transparent, var(--accent-warm), transparent);
    opacity: 0.7;
}

.stratum.s2 {
    background: linear-gradient(90deg, transparent, var(--accent-cool), transparent);
    opacity: 0.5;
}

.stratum.s3 {
    background: linear-gradient(90deg, transparent, var(--text-muted), transparent);
    opacity: 0.4;
}

.stratum.s4 {
    background: linear-gradient(90deg, transparent, var(--highlight), transparent);
    opacity: 0.3;
}

/* Constellation Dots */
.constellation-dots {
    position: absolute;
    inset: 0;
}

.star {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--text-primary);
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(232, 224, 212, 0.5);
}

.star::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 12px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 1px solid var(--grid-line);
}

/* Marginalia Marks */
.marginalia-marks {
    position: absolute;
    inset: 0;
}

.marginalia-marks .mark {
    position: absolute;
    font-family: 'IBM Plex Mono', monospace;
    color: var(--text-muted);
    opacity: 0.4;
    font-size: 1.5rem;
}

.mark.m1 { top: 15%; left: 20%; font-size: 2rem; opacity: 0.3; }
.mark.m2 { top: 35%; left: 65%; font-size: 1.2rem; opacity: 0.5; }
.mark.m3 { top: 55%; left: 30%; font-size: 1.8rem; opacity: 0.25; }
.mark.m4 { top: 70%; left: 75%; font-size: 1rem; opacity: 0.6; }
.mark.m5 { top: 85%; left: 45%; font-size: 1.4rem; opacity: 0.35; }

/* Grid Fragments in collages */
.collage-composition .grid-fragments {
    position: absolute;
    bottom: 20%;
    left: 10%;
}

.collage-composition .fragment {
    display: block;
    height: 1px;
    background: var(--grid-line);
    margin-bottom: 12px;
}

.collage-composition .f1 { width: 100px; }
.collage-composition .f2 { width: 60px; }

/* ============================================
   Footer
   ============================================ */

.codex-footer {
    padding: 60px 24px 80px;
    margin-top: 40px;
}

.footer-grid {
    display: grid;
    grid-template-columns: var(--gutter-width) 1fr;
    gap: 0;
}

.footer-gutter {
    padding-top: 8px;
}

.footer-line {
    height: 1px;
    background: var(--grid-line);
    margin-bottom: 32px;
}

.footer-index {
    display: flex;
    gap: 24px;
    align-items: baseline;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.footer-domain {
    font-family: 'Albert Sans', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    color: var(--accent-warm);
    letter-spacing: 0.03em;
}

.footer-value {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.06em;
}

.footer-colophon {
    font-family: 'Source Serif 4', Georgia, serif;
    font-style: italic;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 900px) {
    :root {
        --gutter-width: 60px;
        --spacing-section: 48px;
    }

    .section-grid,
    .section-grid.reversed {
        grid-template-columns: var(--gutter-width) 1fr;
        gap: 24px;
    }

    .section-grid > .section-spacer-left,
    .section-grid.reversed > .section-spacer-right {
        display: none;
    }

    .section-grid > .section-content,
    .section-grid.reversed > .section-content {
        grid-column: 2;
    }

    .section-grid > .section-visual,
    .section-grid.reversed > .section-visual {
        grid-column: 2;
        max-height: 300px;
    }

    .collage-hero {
        width: 200px;
        height: 200px;
        top: 8%;
        left: 60%;
    }

    .collage-hero .celestial-circle {
        width: 180px;
        height: 180px;
    }

    .hero-content {
        left: 10%;
    }

    .footer-grid {
        grid-template-columns: var(--gutter-width) 1fr;
    }
}

@media (max-width: 600px) {
    :root {
        --gutter-width: 40px;
    }

    .collage-hero {
        left: 50%;
        width: 160px;
        height: 160px;
    }

    .hero-content {
        left: 8%;
        top: 65%;
    }

    .collage-composition {
        height: 250px;
        min-height: 200px;
    }
}
