/* ============================================
   a6c.xyz — Surreal-Cinematic Descent
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --primary-ground: #0C0B0F;
    --secondary-ground: #1A1722;
    --bone-white: #E8E4DC;
    --muted-clay: #B8AFA3;
    --dark-umber: #6B5F53;
    --signal-amber: #C9873A;
    --deep-indigo: #2E2752;
    --deep-indigo-60: rgba(46, 39, 82, 0.6);
    --shadow-color: rgba(12, 11, 15, 0.4);
    --shadow-inverted: -8px -8px 20px rgba(12, 11, 15, 0.4);
}

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

html {
    scroll-behavior: smooth;
}

/* --- Body & Coordinate Grid --- */
body {
    background: var(--primary-ground);
    color: var(--muted-clay);
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.6vw, 1.25rem);
    line-height: 1.72;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-font-smoothing: antialiased;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        repeating-linear-gradient(
            to right,
            rgba(26, 23, 34, 0.15) 0px,
            rgba(26, 23, 34, 0.15) 1px,
            transparent 1px,
            transparent 60px
        ),
        repeating-linear-gradient(
            to bottom,
            rgba(26, 23, 34, 0.15) 0px,
            rgba(26, 23, 34, 0.15) 1px,
            transparent 1px,
            transparent 60px
        );
    transition: opacity 0.6s ease;
}

body.warped::before {
    background:
        repeating-linear-gradient(
            to right,
            rgba(46, 39, 82, 0.25) 0px,
            rgba(46, 39, 82, 0.25) 2px,
            transparent 2px,
            transparent 60px
        ),
        repeating-linear-gradient(
            to bottom,
            rgba(46, 39, 82, 0.25) 0px,
            rgba(46, 39, 82, 0.25) 2px,
            transparent 2px,
            transparent 60px
        );
    -webkit-mask-image: radial-gradient(ellipse 60% 50% at 50% 50%, rgba(0,0,0,1) 0%, rgba(0,0,0,0) 100%);
    mask-image: radial-gradient(ellipse 60% 50% at 50% 50%, rgba(0,0,0,1) 0%, rgba(0,0,0,0) 100%);
}

/* --- Ruled Lines --- */
.ruled-lines {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}

.ruled-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(107, 95, 83, 0.3);
}

/* --- Navigation Dots --- */
.nav-dots {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 1000;
}

.dot-cluster {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-end;
}

.pulse-dot {
    position: relative;
    width: 6px;
    height: 6px;
    border: none;
    padding: 0;
    cursor: pointer;
    background: radial-gradient(circle, var(--signal-amber) 0%, var(--signal-amber) 50%, transparent 50%);
    border-radius: 50%;
    animation: dotPulse 4s ease-in-out infinite;
    animation-delay: var(--dot-delay);
    box-shadow: var(--shadow-inverted);
    display: flex;
    align-items: center;
}

.pulse-dot .dot-label {
    position: absolute;
    right: 16px;
    white-space: nowrap;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0.06em;
    color: var(--dark-umber);
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 200ms ease, transform 200ms ease;
    transition-delay: 200ms;
    pointer-events: none;
}

.dot-cluster:hover .pulse-dot .dot-label {
    opacity: 1;
    transform: translateX(0);
}

@keyframes dotPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

/* --- Strata Wrapper --- */
.strata-wrapper {
    perspective: 1200px;
    overflow-y: auto;
    overflow-x: hidden;
    height: 100vh;
    scroll-snap-type: y mandatory;
    position: relative;
    z-index: 2;
}

.strata-container {
    transform-style: preserve-3d;
    transition: transform 600ms cubic-bezier(0.23, 1, 0.32, 1);
}

/* --- Stratum Base --- */
.stratum {
    width: 100%;
    min-height: 100vh;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    scroll-snap-align: start;
    transform: translateZ(calc(var(--stratum-index) * -100px));
    background: var(--secondary-ground);
}

.stratum-inner {
    width: 100%;
    max-width: 1200px;
    padding: 4rem 2rem;
    position: relative;
}

/* Overlap: each stratum except the first has negative top margin */
.stratum:not(:first-child) {
    margin-top: -15vh;
}

/* --- Stratum 1: Surface --- */
.stratum-surface {
    background: transparent;
    z-index: 5;
}

.stratum-surface .stratum-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    position: relative;
}

.coordinate-label {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(3rem, 8vw, 7rem);
    letter-spacing: 0.12em;
    color: var(--bone-white);
    text-transform: none;
    position: relative;
    z-index: 2;
    text-shadow: -4px -4px 16px rgba(12, 11, 15, 0.5);
}

.horizon-line {
    position: absolute;
    top: 62%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--dark-umber);
    opacity: 0.4;
}

.translucent-plane {
    position: absolute;
    width: 80%;
    text-align: center;
    opacity: 0.12;
    transition: opacity 0.8s ease;
}

.translucent-plane .plane-text {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 600;
    font-style: italic;
    font-size: clamp(1rem, 2vw, 1.5rem);
    color: var(--muted-clay);
    line-height: 1.72;
}

.plane-1 {
    top: 30%;
    left: 10%;
    transform: translateZ(-40px);
}

.plane-2 {
    top: 50%;
    left: 10%;
    transform: translateZ(-80px);
}

.plane-3 {
    top: 70%;
    left: 10%;
    transform: translateZ(-120px);
}

/* --- Stratum 2: Membrane --- */
.stratum-membrane {
    background: rgba(26, 23, 34, 0.85);
    z-index: 4;
}

.stratum-membrane .stratum-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.dissolving-paragraph {
    max-width: 640px;
    text-align: justify;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 600;
    font-style: italic;
    font-size: clamp(1rem, 1.6vw, 1.25rem);
    line-height: 1.72;
    color: var(--muted-clay);
}

.dw {
    display: inline;
    animation: dissolve calc(8s + var(--delay)) ease-in-out infinite;
    animation-delay: var(--delay);
}

@keyframes dissolve {
    0%, 100% { opacity: 0.08; }
    50% { opacity: 1; }
}

/* --- Stratum 3: Architecture --- */
.stratum-architecture {
    background: rgba(26, 23, 34, 0.9);
    z-index: 3;
}

.stratum-architecture .stratum-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.broken-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, auto);
    gap: 1.5rem;
    width: 100%;
    max-width: 900px;
}

.grid-cell {
    background: var(--deep-indigo-60);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    padding: 2rem;
    transform: rotate(var(--rotation));
    box-shadow: var(--shadow-inverted);
    border: 1px solid rgba(107, 95, 83, 0.15);
    transition: transform 0.4s ease;
}

.grid-cell:hover {
    transform: rotate(0deg);
}

.cell-label {
    display: block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0.06em;
    color: var(--dark-umber);
    margin-bottom: 0.75rem;
}

.cell-text {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.4vw, 1.1rem);
    line-height: 1.72;
    color: var(--muted-clay);
}

/* --- Stratum 4: Archive --- */
.stratum-archive {
    background: rgba(26, 23, 34, 0.92);
    z-index: 2;
}

.stratum-archive .stratum-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.timeline {
    position: relative;
    width: 100%;
    max-width: 700px;
    padding: 4rem 0;
}

.timeline-rule {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 1px;
    background: var(--signal-amber);
    transform: translateX(-50%);
    animation: rulePulse 8s ease-in-out infinite;
}

@keyframes rulePulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.8; }
}

.timeline-entry {
    position: relative;
    width: 45%;
    margin-bottom: 3rem;
    box-shadow: var(--shadow-inverted);
    padding: 1.5rem;
    background: rgba(26, 23, 34, 0.5);
    border: 1px solid rgba(107, 95, 83, 0.12);
}

.entry-left {
    margin-right: auto;
    text-align: right;
}

.entry-right {
    margin-left: auto;
    text-align: left;
}

.timestamp {
    display: block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0.06em;
    color: var(--dark-umber);
    margin-bottom: 0.5rem;
}

.entry-text {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.4vw, 1.1rem);
    line-height: 1.72;
    color: var(--muted-clay);
}

/* --- Stratum 5: Void --- */
.stratum-void {
    background: var(--primary-ground);
    z-index: 1;
}

.stratum-void .stratum-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.void-glyph {
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(3rem, 6vw, 5rem);
    color: var(--bone-white);
    opacity: 0.6;
    animation: voidRotate 90s linear infinite;
}

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

/* --- Active Stratum Highlight for Nav --- */
.pulse-dot.active {
    background: radial-gradient(circle, var(--signal-amber) 0%, var(--signal-amber) 60%, transparent 60%);
    width: 8px;
    height: 8px;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .broken-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .grid-cell {
        transform: rotate(0deg);
    }

    .timeline-entry {
        width: 80%;
    }

    .entry-left,
    .entry-right {
        margin-left: auto;
        margin-right: auto;
        text-align: left;
    }

    .nav-dots {
        top: 1rem;
        right: 1rem;
    }

    .translucent-plane {
        width: 90%;
        left: 5%;
    }
}

@media (max-width: 480px) {
    .coordinate-label {
        font-size: clamp(2rem, 12vw, 4rem);
    }

    .dissolving-paragraph {
        text-align: left;
    }

    .stratum-inner {
        padding: 2rem 1rem;
    }
}
