/* ============================================================
   mores.quest - Abyssal Zen Observatory
   ============================================================ */

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

:root {
    /* Palette -- Ocean Deep */
    --abyss-black: #0a0e17;
    --hadal-navy: #0c1a3a;
    --pressure-indigo: #0f0a2e;
    --trench-black: #050811;
    --hadal-floor: #030508;
    --sonar-cyan: #2dd4bf;
    --biolume-green: #0fa968;
    --phosphor-blue: #3b82f6;
    --ghost-white: #e8edf5;
    --kelp-gray: #7a8ba0;
    --sediment: #3d4a5c;

    /* Typography scale */
    --font-display: 'Zen Kaku Gothic New', sans-serif;
    --font-body: 'Cormorant Garamond', serif;
    --font-mono: 'IBM Plex Mono', monospace;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-weight: 300;
    color: var(--ghost-white);
    background-color: var(--abyss-black);
    overflow-x: hidden;
    transition: background-color 2s cubic-bezier(0.16, 1, 0.3, 1);
    /* Scan lines overlay */
    background-image: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent 3px,
        rgba(61, 74, 92, 0.03) 3px,
        rgba(61, 74, 92, 0.03) 4px
    );
}

/* Font utility classes */
.font-display {
    font-family: var(--font-display);
    font-weight: 400;
}

.font-body {
    font-family: var(--font-body);
    font-weight: 300;
}

.font-mono {
    font-family: var(--font-mono);
    font-weight: 300;
}

/* --- Layout Grid --- */
.layer {
    display: grid;
    grid-template-columns: 1fr min(72ch, 90vw) 1fr;
    position: relative;
}

.layer > * {
    grid-column: 2;
}

/* Sentinel elements for scroll observer */
.sentinel {
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

/* --- Depth Indicator --- */
.depth-indicator {
    position: fixed;
    right: 16px;
    top: 10vh;
    height: 80vh;
    width: 2px;
    background: linear-gradient(to bottom, var(--trench-black), var(--sonar-cyan));
    z-index: 100;
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

.depth-indicator.visible {
    opacity: 0.2;
}

.depth-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--trench-black);
    transform-origin: bottom;
    transition: none;
}

/* ============================================================
   Layer 0: Surface (0-100vh)
   ============================================================ */
.layer-surface {
    min-height: 100vh;
    background-color: var(--abyss-black);
    align-content: center;
    justify-items: center;
}

.layer-surface .layer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    grid-column: 1 / -1;
}

.hero-title {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(2rem, 5vw, 4.5rem);
    letter-spacing: 0.15em;
    line-height: 1.1;
    color: var(--ghost-white);
    opacity: 0;
    transform: translateY(12px);
    animation: heroFadeIn 1200ms cubic-bezier(0.16, 1, 0.3, 1) 600ms forwards;
}

@keyframes heroFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sonar-line {
    width: 0;
    height: 1px;
    background-color: var(--sonar-cyan);
    opacity: 0;
    margin-top: 2rem;
    animation:
        sonarExpand 2000ms cubic-bezier(0.16, 1, 0.3, 1) 1800ms forwards,
        sonarPulse 4s ease-in-out 3800ms infinite;
}

@keyframes sonarExpand {
    to {
        width: min(400px, 60vw);
        opacity: 0.3;
    }
}

@keyframes sonarPulse {
    0%, 100% { opacity: 0.15; }
    50% { opacity: 0.35; }
}

/* ============================================================
   Layer 1: Thermocline (100vh-250vh)
   ============================================================ */
.layer-thermocline {
    min-height: 150vh;
    position: relative;
    overflow: hidden;
}

.current-field {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    grid-column: 1 / -1;
    overflow: hidden;
    pointer-events: none;
}

.current-line {
    position: absolute;
    height: 1px;
    background-color: var(--sonar-cyan);
    animation: drift linear infinite;
    will-change: transform;
}

@keyframes drift {
    from { transform: translateX(100vw); }
    to { transform: translateX(-100%); }
}

.transmission-fragments {
    grid-column: 2;
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 15vh;
    padding: 20vh 0;
}

.transmission {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(0.7rem, 1.2vw, 0.9rem);
    letter-spacing: 0.25em;
    line-height: 1.85;
    color: var(--ghost-white);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1200ms cubic-bezier(0.16, 1, 0.3, 1),
                transform 1200ms cubic-bezier(0.16, 1, 0.3, 1);
    text-transform: lowercase;
}

.transmission.visible {
    opacity: 0.4;
    transform: translateY(0);
}

/* Sonar Ping Transition */
.sonar-ping-container {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 30vh;
    position: relative;
}

.sonar-ping-svg {
    width: min(300px, 60vw);
    height: min(300px, 60vw);
}

.ping-ring {
    fill: none;
    stroke: var(--sonar-cyan);
    stroke-width: 0.5;
    opacity: 0;
}

.ping-ring-1 {
    animation: pingExpand 4s ease-out infinite;
}

.ping-ring-2 {
    animation: pingExpand 4s ease-out 1s infinite;
}

.ping-ring-3 {
    animation: pingExpand 4s ease-out 2s infinite;
}

.ping-ring-4 {
    animation: pingExpand 4s ease-out 3s infinite;
}

@keyframes pingExpand {
    0% {
        r: 0;
        opacity: 0.4;
    }
    100% {
        r: 200;
        opacity: 0;
    }
}

/* ============================================================
   Layer 2: Mesopelagic (250vh-450vh)
   ============================================================ */
.layer-mesopelagic {
    min-height: 200vh;
    padding: 10vh 0;
    position: relative;
}

/* Grid overlay background */
.layer-mesopelagic::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    grid-column: 1 / -1;
    background-image:
        repeating-linear-gradient(
            to right,
            rgba(61, 74, 92, 0.05) 0px,
            rgba(61, 74, 92, 0.05) 1px,
            transparent 1px,
            transparent 80px
        ),
        repeating-linear-gradient(
            to bottom,
            rgba(61, 74, 92, 0.05) 0px,
            rgba(61, 74, 92, 0.05) 1px,
            transparent 1px,
            transparent 60px
        );
    pointer-events: none;
    z-index: 0;
}

/* Specimen Cards */
.specimen-card {
    position: relative;
    z-index: 1;
    margin: 20vh auto;
    max-width: min(72ch, 90vw);
    border: 1px solid transparent;
    padding: 2rem;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 800ms cubic-bezier(0.16, 1, 0.3, 1),
                transform 800ms cubic-bezier(0.16, 1, 0.3, 1),
                border-color 800ms cubic-bezier(0.16, 1, 0.3, 1);
    background-color: rgba(12, 26, 58, 0.3);
}

.specimen-card.visible {
    opacity: 1;
    transform: translateY(0);
    border-color: rgba(45, 212, 191, 0.15);
}

.specimen-coord {
    font-family: var(--font-mono);
    font-weight: 300;
    font-size: clamp(0.6rem, 0.9vw, 0.75rem);
    letter-spacing: 0.08em;
    color: var(--kelp-gray);
    opacity: 0;
    transition: opacity 600ms ease 500ms;
    text-transform: uppercase;
}

.specimen-card.visible .specimen-coord {
    opacity: 0.5;
}

.specimen-coord-bottom {
    text-align: right;
    margin-top: 1rem;
}

.specimen-inner {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2rem;
    margin-top: 1.5rem;
}

@media (max-width: 768px) {
    .specimen-inner {
        grid-template-columns: 1fr;
    }
}

.specimen-viz {
    aspect-ratio: 16 / 9;
    position: relative;
    opacity: 0;
    transition: opacity 600ms ease 300ms;
}

.specimen-card.visible .specimen-viz {
    opacity: 1;
}

.specimen-viz-svg {
    width: 100%;
    height: 100%;
}

.specimen-text {
    opacity: 0;
    transition: opacity 600ms ease 500ms;
}

.specimen-card.visible .specimen-text {
    opacity: 1;
}

.specimen-title {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    letter-spacing: 0.15em;
    line-height: 1.1;
    color: var(--ghost-white);
    margin-bottom: 1.2rem;
}

.specimen-body {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(0.95rem, 1.4vw, 1.15rem);
    line-height: 1.85;
    letter-spacing: 0.02em;
    color: var(--ghost-white);
    max-width: 64ch;
}

.axis-label {
    font-family: var(--font-mono);
    font-weight: 300;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* Pressure Readings */
.pressure-reading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 10vh;
    position: relative;
    z-index: 1;
}

.pressure-bar {
    width: 60%;
    height: 1px;
    background-color: var(--sonar-cyan);
    opacity: 0.12;
    animation: pressureBreathe 6s cubic-bezier(0.37, 0, 0.63, 1) infinite;
}

@keyframes pressureBreathe {
    0%, 100% { width: 60%; }
    50% { width: 100%; }
}

/* ============================================================
   Layer 3: Bathypelagic (450vh-600vh)
   ============================================================ */
.layer-bathypelagic {
    min-height: 150vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.network-container {
    grid-column: 1 / -1;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 5vh 2rem;
    text-align: center;
}

.network-title {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    letter-spacing: 0.15em;
    line-height: 1.1;
    color: var(--ghost-white);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 800ms cubic-bezier(0.16, 1, 0.3, 1),
                transform 800ms cubic-bezier(0.16, 1, 0.3, 1);
    margin-bottom: 4vh;
}

.network-title.visible {
    opacity: 0.6;
    transform: translateY(0);
}

.network-graph {
    width: 100%;
    height: auto;
    max-height: 80vh;
}

.net-node {
    transition: opacity 400ms cubic-bezier(0.16, 1, 0.3, 1);
}

.net-label {
    font-family: var(--font-mono);
    font-weight: 300;
    letter-spacing: 0.08em;
    transition: opacity 400ms ease 200ms;
}

.net-edge {
    stroke-dasharray: 4 2;
}

/* Network pulse circles */
.net-pulse {
    fill: var(--sonar-cyan);
    opacity: 0.6;
}

/* ============================================================
   Layer 4: Hadal Floor (600vh-700vh)
   ============================================================ */
.layer-hadal {
    min-height: 100vh;
    align-content: center;
    justify-items: center;
}

.layer-hadal .layer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    grid-column: 1 / -1;
}

.hadal-title {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(2rem, 5vw, 4.5rem);
    letter-spacing: 0.15em;
    line-height: 1.1;
    color: var(--ghost-white);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 1200ms cubic-bezier(0.16, 1, 0.3, 1),
                transform 1200ms cubic-bezier(0.16, 1, 0.3, 1);
}

.hadal-title.visible {
    opacity: 1;
    transform: translateY(0);
}

.hadal-sonar-line {
    width: 0;
    height: 1px;
    background-color: var(--sonar-cyan);
    margin-top: 2rem;
    opacity: 0;
    transition: width 2000ms cubic-bezier(0.16, 1, 0.3, 1),
                opacity 2000ms cubic-bezier(0.16, 1, 0.3, 1);
}

.hadal-sonar-line.visible {
    width: min(400px, 60vw);
    opacity: 0.3;
    animation: sonarPulse 4s ease-in-out infinite;
}

/* ============================================================
   Body depth states (controlled by JS)
   ============================================================ */
body.depth-0 {
    background-color: var(--abyss-black);
}

body.depth-1 {
    background-color: var(--hadal-navy);
}

body.depth-2 {
    background-color: var(--pressure-indigo);
}

body.depth-3 {
    background-color: var(--trench-black);
}

body.depth-4 {
    background-color: var(--hadal-floor);
}

/* ============================================================
   Scrollbar
   ============================================================ */
::-webkit-scrollbar {
    width: 0;
    background: transparent;
}

/* ============================================================
   Selection
   ============================================================ */
::selection {
    background: rgba(45, 212, 191, 0.2);
    color: var(--ghost-white);
}
