/* ==========================================
   layer-2.wiki — Styles
   Mid-century aerospace design bureau aesthetic
   ========================================== */

/* --- CSS Custom Properties --- */
:root {
    /* Palette */
    --deep-midnight: #0b1222;
    --slate-abyss: #151d30;
    --ink-wash: #1c2842;
    --signal-aqua: #4ecdc4;
    --atomic-coral: #ff6b6b;
    --warm-brass: #c9a96e;
    --chalk-white: #e8edf3;
    --haze-gray: #8899aa;
    --phosphor-teal: #2a7a72;

    /* Typography */
    --font-display: 'Nunito', sans-serif;
    --font-body: 'Karla', sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;

    /* Spacing */
    --page-padding: clamp(1.5rem, 4vw, 3.5rem);
}

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

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--deep-midnight);
    color: var(--chalk-white);
    font-family: var(--font-body);
    font-size: clamp(0.95rem, 1.8vw, 1.1rem);
    line-height: 1.72;
    overflow-x: hidden;
}

.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* --- Noise Texture Overlay --- */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
    opacity: 0.4;
}

/* ===========================================
   HERO / ENTRY SECTION
   =========================================== */
.hero-section {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--deep-midnight);
    overflow: hidden;
}

/* --- Organic Blobs --- */
.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    z-index: 0;
    opacity: 0;
    will-change: transform, border-radius;
}

.blob-1 {
    width: 40vw;
    height: 40vw;
    left: 20%;
    top: 30%;
    background: var(--signal-aqua);
    animation: blobMorph1 20s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite, blobFadeIn 1.2s 0.3s ease-out forwards;
}

.blob-2 {
    width: 55vw;
    height: 55vw;
    left: 60%;
    top: 50%;
    background: var(--phosphor-teal);
    animation: blobMorph2 25s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite, blobFadeIn2 1.2s 0.3s ease-out forwards;
    transform: translate(-50%, -50%);
}

@keyframes blobFadeIn {
    from { opacity: 0; }
    to { opacity: 0.10; }
}

@keyframes blobFadeIn2 {
    from { opacity: 0; }
    to { opacity: 0.08; }
}

@keyframes blobMorph1 {
    0%, 100% { border-radius: 42% 58% 62% 38% / 45% 55% 45% 55%; }
    25% { border-radius: 55% 45% 38% 62% / 58% 42% 58% 42%; }
    50% { border-radius: 38% 62% 55% 45% / 42% 58% 42% 58%; }
    75% { border-radius: 62% 38% 45% 55% / 55% 45% 55% 45%; }
}

@keyframes blobMorph2 {
    0%, 100% { border-radius: 58% 42% 45% 55% / 62% 38% 62% 38%; }
    25% { border-radius: 42% 58% 55% 45% / 38% 62% 38% 62%; }
    50% { border-radius: 55% 45% 62% 38% / 45% 55% 45% 55%; }
    75% { border-radius: 45% 55% 38% 62% / 55% 45% 55% 45%; }
}

/* --- Hero Content --- */
.hero-content {
    position: relative;
    z-index: 1;
    text-align: center;
    padding-top: 0;
    margin-top: -12vh;
}

.hero-title {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(2.8rem, 7vw, 6rem);
    letter-spacing: 0.03em;
    color: var(--chalk-white);
    clip-path: inset(0 100% 0 0);
    animation: titleReveal 0.9s 0.6s cubic-bezier(0.77, 0, 0.175, 1) forwards;
}

@keyframes titleReveal {
    from { clip-path: inset(0 100% 0 0); }
    to { clip-path: inset(0 0% 0 0); }
}

.hero-subtitle {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: clamp(0.75rem, 1.4vw, 0.9rem);
    letter-spacing: 0.06em;
    color: var(--signal-aqua);
    margin-top: 30px;
    opacity: 0;
    transform: translateY(12px);
    animation: subtitleFadeUp 0.6s 1.2s ease-out forwards;
}

@keyframes subtitleFadeUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Scroll Chevron --- */
.scroll-chevron {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
    opacity: 0;
    animation: chevronAppear 0.5s 2s ease-out forwards, chevronPulse 2s 2.5s ease-in-out infinite;
}

@keyframes chevronAppear {
    from { opacity: 0; }
    to { opacity: 0.7; }
}

@keyframes chevronPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* ===========================================
   MAIN THREE-COLUMN LAYOUT
   =========================================== */
.main-layout {
    display: grid;
    grid-template-columns: 1fr 2.4fr 0.8fr;
    gap: 0;
    padding: var(--page-padding);
    padding-left: calc(var(--page-padding) * 0.7);
    padding-right: var(--page-padding);
    min-height: 100vh;
    position: relative;
}

/* ===========================================
   INDEX RAIL (Left Column)
   =========================================== */
.index-rail {
    position: sticky;
    top: var(--page-padding);
    height: fit-content;
    max-height: calc(100vh - var(--page-padding) * 2);
    padding: 1.5rem 1rem 1.5rem 0;
    border-right: 1px solid rgba(201, 169, 110, 0.15);
}

.rail-header {
    margin-bottom: 2rem;
}

.rail-label {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.15em;
    color: var(--haze-gray);
    text-transform: uppercase;
}

.rail-nav {
    list-style: none;
}

.rail-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0.65rem 0.5rem;
    cursor: pointer;
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.rail-item:hover {
    transform: translateX(4px);
}

.rail-number {
    font-family: var(--font-mono);
    font-size: clamp(0.75rem, 1.4vw, 0.9rem);
    letter-spacing: 0.06em;
    color: var(--signal-aqua);
    min-width: 2.2rem;
    flex-shrink: 0;
}

.rail-dots {
    flex: 1;
    height: 1px;
    margin: 0 0.5rem;
    background: radial-gradient(circle, var(--warm-brass) 1px, transparent 1px);
    background-size: 8px 1px;
    opacity: 0.5;
    min-width: 20px;
}

.rail-name {
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--haze-gray);
    white-space: nowrap;
    transition: color 0.3s ease;
}

.rail-item.active .rail-name {
    color: var(--chalk-white);
    font-weight: 600;
}

.rail-indicator {
    position: absolute;
    right: -1px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: var(--signal-aqua);
    border-radius: 2px;
    transition: height 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), top 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.rail-item.active .rail-indicator {
    height: 70%;
}

/* ===========================================
   CONTENT STAGE (Center Column)
   =========================================== */
.content-stage {
    padding: 0 clamp(1.5rem, 3vw, 3rem);
}

/* --- Content Section --- */
.content-section {
    padding: 3rem 0;
    position: relative;
}

.section-reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.section-reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

.section-heading {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    letter-spacing: 0.05em;
    color: var(--chalk-white);
    margin-bottom: 1.5rem;
    position: relative;
}

.section-body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.95rem, 1.8vw, 1.1rem);
    line-height: 1.72;
    color: var(--chalk-white);
    max-width: 62ch;
    margin-bottom: 1.2rem;
}

.section-body strong,
.section-body b {
    font-weight: 600;
}

/* --- Dotted Rule --- */
.dotted-rule {
    width: 100%;
    height: 1px;
    margin: 2rem 0;
    background: radial-gradient(circle, var(--warm-brass) 1px, transparent 1px);
    background-size: 8px 1px;
    opacity: 0.5;
}

/* --- Content Card --- */
.content-card {
    background: var(--slate-abyss);
    border: 1px solid rgba(201, 169, 110, 0.12);
    border-radius: 6px;
    padding: 1.5rem;
    margin-top: 0.5rem;
    position: relative;
    transition: border-color 0.4s ease;
}

.content-card:hover {
    border-color: rgba(201, 169, 110, 0.35);
}

.card-label {
    font-family: var(--font-mono);
    font-size: clamp(0.7rem, 1.2vw, 0.8rem);
    letter-spacing: 0.08em;
    color: var(--signal-aqua);
    display: block;
    margin-bottom: 0.6rem;
    text-transform: uppercase;
}

.card-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 0.95rem;
    line-height: 1.65;
    color: var(--haze-gray);
}

/* ===========================================
   PANORAMIC SECTIONS
   =========================================== */
.panoramic-section {
    grid-column: 1 / -1;
    margin-left: calc(var(--page-padding) * -1);
    margin-right: calc(var(--page-padding) * -1);
    width: 100vw;
    min-height: 50vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--deep-midnight);
    position: relative;
    overflow: hidden;
    padding: 4rem var(--page-padding);
}

.panoramic-content {
    position: relative;
    z-index: 1;
    text-align: center;
    max-width: 800px;
}

.panoramic-statement {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(1.8rem, 5vw, 3.5rem);
    letter-spacing: 0.03em;
    color: var(--chalk-white);
    line-height: 1.3;
}

/* Panoramic Blobs */
.blob-panoramic-1,
.blob-panoramic-2,
.blob-panoramic-3 {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    z-index: 0;
    will-change: transform, border-radius;
}

.blob-panoramic-1 {
    width: 45vw;
    height: 45vw;
    left: 15%;
    top: 20%;
    background: var(--signal-aqua);
    opacity: 0.08;
    animation: blobMorph1 22s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
}

.blob-panoramic-2 {
    width: 50vw;
    height: 50vw;
    right: 10%;
    top: 30%;
    background: var(--phosphor-teal);
    opacity: 0.06;
    animation: blobMorph2 18s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
}

.blob-panoramic-3 {
    width: 40vw;
    height: 40vw;
    left: 30%;
    top: 25%;
    background: var(--signal-aqua);
    opacity: 0.09;
    animation: blobMorph1 24s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
}

/* ===========================================
   ANNOTATION GUTTER (Right Column)
   =========================================== */
.annotation-gutter {
    position: sticky;
    top: var(--page-padding);
    height: fit-content;
    max-height: calc(100vh - var(--page-padding) * 2);
    overflow-y: auto;
    padding: 1.5rem 0 1.5rem 1rem;
    border-left: 1px solid rgba(201, 169, 110, 0.1);

    /* Hide scrollbar */
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.annotation-gutter::-webkit-scrollbar {
    display: none;
}

.annotation-group {
    display: none;
    flex-direction: column;
    gap: 1.2rem;
}

.annotation-group.visible {
    display: flex;
}

.annotation {
    padding: 0;
}

.annotation-label {
    font-family: var(--font-mono);
    font-size: clamp(0.65rem, 1.1vw, 0.75rem);
    letter-spacing: 0.08em;
    color: var(--warm-brass);
    text-transform: uppercase;
    display: block;
    margin-bottom: 0.35rem;
}

.annotation-text {
    font-family: var(--font-body);
    font-size: 0.82rem;
    line-height: 1.55;
    color: var(--haze-gray);
}

.annotation-diagram {
    padding: 0.5rem 0;
    display: flex;
    justify-content: center;
}

.annotation-diagram svg {
    opacity: 0.7;
    transition: opacity 0.4s ease;
}

.annotation-diagram:hover svg {
    opacity: 1;
}

/* ===========================================
   STARBURST DECORATIONS
   =========================================== */
.starburst {
    display: inline-block;
    width: 28px;
    height: 28px;
    position: relative;
    margin-bottom: 0.8rem;
    animation: starburstRotate 60s linear infinite;
}

.starburst::before,
.starburst::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    transform: translate(-50%, -50%);
}

.starburst::before {
    background:
        linear-gradient(0deg, transparent 46%, var(--signal-aqua) 46%, var(--signal-aqua) 54%, transparent 54%),
        linear-gradient(90deg, transparent 46%, var(--signal-aqua) 46%, var(--signal-aqua) 54%, transparent 54%),
        linear-gradient(45deg, transparent 46%, var(--signal-aqua) 46%, var(--signal-aqua) 54%, transparent 54%),
        linear-gradient(-45deg, transparent 46%, var(--signal-aqua) 46%, var(--signal-aqua) 54%, transparent 54%);
    opacity: 0.6;
}

.starburst::after {
    transform: translate(-50%, -50%) rotate(22.5deg);
    background:
        linear-gradient(0deg, transparent 46%, var(--signal-aqua) 46%, var(--signal-aqua) 54%, transparent 54%),
        linear-gradient(90deg, transparent 46%, var(--signal-aqua) 46%, var(--signal-aqua) 54%, transparent 54%),
        linear-gradient(45deg, transparent 46%, var(--signal-aqua) 46%, var(--signal-aqua) 54%, transparent 54%),
        linear-gradient(-45deg, transparent 46%, var(--signal-aqua) 46%, var(--signal-aqua) 54%, transparent 54%);
    opacity: 0.35;
}

@keyframes starburstRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ===========================================
   FOOTER
   =========================================== */
.site-footer {
    padding: 3rem var(--page-padding);
    background: var(--deep-midnight);
}

.footer-content {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
}

.footer-dotted-rule {
    width: 100%;
    height: 1px;
    margin-bottom: 2rem;
    background: radial-gradient(circle, var(--warm-brass) 1px, transparent 1px);
    background-size: 8px 1px;
    opacity: 0.3;
}

.footer-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}

.footer-domain {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1rem;
    color: var(--chalk-white);
    letter-spacing: 0.03em;
}

.footer-dots {
    flex: 0 0 80px;
    height: 1px;
    margin: 0 1rem;
    background: radial-gradient(circle, var(--warm-brass) 1px, transparent 1px);
    background-size: 8px 1px;
    opacity: 0.5;
}

.footer-tagline {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    color: var(--haze-gray);
}

/* ===========================================
   MAGNETIC HOVER EFFECTS
   =========================================== */
.magnetic-target {
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
}

.magnetic-target.releasing {
    transition: transform 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
}

/* ===========================================
   SCROLL REVEAL
   =========================================== */
.panoramic-section {
    opacity: 0;
    transform: scale(0.97);
    transition: opacity 1s ease-out, transform 1s ease-out;
}

.panoramic-section.visible {
    opacity: 1;
    transform: scale(1);
}

/* ===========================================
   RESPONSIVE (Below 768px)
   =========================================== */
@media (max-width: 768px) {
    .main-layout {
        grid-template-columns: 1fr;
        padding: 1rem;
    }

    /* Index Rail becomes horizontal tab bar */
    .index-rail {
        position: sticky;
        top: 0;
        z-index: 100;
        background: var(--deep-midnight);
        border-right: none;
        border-bottom: 1px solid rgba(201, 169, 110, 0.15);
        padding: 0.8rem 0;
        max-height: none;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    .index-rail::-webkit-scrollbar { display: none; }

    .rail-header { display: none; }

    .rail-nav {
        display: flex;
        gap: 0.25rem;
        white-space: nowrap;
    }

    .rail-item {
        padding: 0.4rem 0.8rem;
        flex-direction: row;
        gap: 0.3rem;
    }

    .rail-dots { display: none; }

    .rail-indicator {
        position: absolute;
        bottom: -2px;
        left: 50%;
        transform: translateX(-50%);
        right: auto;
        top: auto;
        width: 0;
        height: 2px;
    }

    .rail-item.active .rail-indicator {
        width: 80%;
        height: 2px;
    }

    /* Annotation Gutter folds inline */
    .annotation-gutter {
        display: none;
    }

    /* Panoramic adjustments */
    .panoramic-section {
        margin-left: -1rem;
        margin-right: -1rem;
        min-height: 35vh;
    }

    .panoramic-statement {
        font-size: clamp(1.4rem, 6vw, 2.2rem);
    }

    .content-stage {
        padding: 0 0.5rem;
    }

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

/* ===========================================
   SELECTION STYLES
   =========================================== */
::selection {
    background: var(--signal-aqua);
    color: var(--deep-midnight);
}

/* ===========================================
   LINK STYLES
   =========================================== */
a {
    color: var(--signal-aqua);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--atomic-coral);
}
