/* =============================================
   a6c.quest — Surrealist Cryptographic Labyrinth
   Chamber-based architecture with thermal gradient
   ============================================= */

:root {
    --void: #0b0b14;
    --deep: #0f1b3d;
    --stone: #2a2a3e;
    --blood: #6b1d38;
    --amber: #c8952e;
    --signal: #1de9b6;
    --text: #e8e4dc;
    --whisper: #9e8fb8;

    --font-display: 'Orbitron', sans-serif;
    --font-body: 'Crimson Pro', serif;
    --font-mono: 'Fira Code', monospace;
    --font-glyph: 'Noto Sans Symbols 2', sans-serif;

    --bg-hue: 230;
}

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

html {
    scroll-behavior: smooth;
    scroll-snap-type: y proximity;
    overflow-x: hidden;
}

body {
    background-color: var(--void);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 18px;
    line-height: 1.75;
    overflow-x: hidden;
}

/* --- HUD Navigation --- */
.hud-nav {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.depth-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.depth-numeral {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 700;
    color: var(--stone);
    letter-spacing: 0.15em;
    transition: color 0.3s ease, transform 0.2s ease;
}

.depth-numeral:hover {
    color: var(--signal);
    transform: scale(1.12);
}

.depth-bar {
    width: 3px;
    height: 80px;
    background: var(--stone);
    position: relative;
    border-radius: 2px;
    overflow: hidden;
}

.depth-fill {
    width: 100%;
    background: var(--signal);
    position: absolute;
    bottom: 0;
    height: 0%;
    transition: height 0.4s ease;
    border-radius: 2px;
}

.sonar-ping {
    width: 3px;
    height: 3px;
    background: var(--signal);
    border-radius: 50%;
    position: absolute;
    bottom: 0;
    left: 0;
    opacity: 0;
    animation: sonarPing 2s ease-out infinite;
}

@keyframes sonarPing {
    0% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(4); }
}

/* --- Margin Coordinates --- */
.margin-coord {
    position: fixed;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--whisper);
    opacity: 0.3;
    z-index: 50;
    writing-mode: vertical-rl;
    letter-spacing: 0.1em;
}

.left-coord { left: 10px; top: 50%; transform: translateY(-50%) rotate(180deg); }
.right-coord { right: 10px; bottom: 20%; }

/* --- Chambers (shared) --- */
.chamber {
    min-height: 100vh;
    scroll-snap-align: start;
    position: relative;
}

/* --- CIPHER GATE --- */
.cipher-gate {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cipher-split {
    display: flex;
    width: 90%;
    max-width: 1100px;
    gap: 4rem;
    align-items: center;
}

.cipher-left {
    flex: 1;
    display: flex;
    justify-content: center;
}

.polyhedron-container {
    width: 280px;
    height: 280px;
}

.polyhedron {
    width: 100%;
    height: 100%;
    animation: polyRotate 20s linear infinite;
}

@keyframes polyRotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.cipher-right {
    flex: 1;
}

.cipher-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 12px;
    max-width: 360px;
}

.cipher-cell {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    background: var(--deep);
    border: 1px solid var(--stone);
    transition: transform 0.4s ease, border-color 0.3s ease;
}

.cipher-cell::before {
    content: '';
    position: absolute;
    inset: -2px;
    background: conic-gradient(from 0deg, var(--signal), transparent 25%, transparent 75%, var(--signal));
    animation: borderSpin 3s linear infinite;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cipher-cell:hover::before {
    opacity: 1;
}

@keyframes borderSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.cipher-cell:hover {
    transform: scale(1.8);
    border-color: var(--signal);
    z-index: 10;
}

.cipher-char {
    font-family: var(--font-display);
    font-size: 48px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.15em;
    transition: opacity 0.3s ease;
}

.cipher-glyph {
    font-family: var(--font-glyph);
    font-size: 36px;
    color: var(--signal);
    position: absolute;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cipher-cell:hover .cipher-char { opacity: 0.3; }
.cipher-cell:hover .cipher-glyph { opacity: 1; }

.cipher-subtitle {
    margin-top: 2rem;
    font-family: var(--font-body);
    font-size: 16px;
    color: var(--whisper);
    font-style: italic;
}

/* --- Section Divider --- */
.section-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 3rem 0;
}

.divider-dash {
    width: 40px;
    height: 1px;
}

.divider-dash.burgundy { background: var(--blood); }
.divider-dash.amber { background: var(--amber); }
.divider-dash.teal { background: var(--signal); }

.compass-rose {
    width: 24px;
    height: 24px;
    animation: compassSpin 60s linear infinite;
}

@keyframes compassSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- MAP ROOM --- */
.map-room {
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding: 5vh 5vw;
}

.map-split {
    display: flex;
    width: 100%;
    gap: 3rem;
    align-items: flex-start;
}

.map-terrain {
    flex: 0 0 65%;
}

.terrain-svg {
    width: 100%;
    height: auto;
}

.map-journal {
    flex: 0 0 30%;
    padding: 1.5rem;
}

.journal-title {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.2em;
    color: var(--amber);
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--stone);
    padding-bottom: 0.5rem;
}

.journal-entry {
    margin-bottom: 2rem;
    padding-left: 1rem;
    border-left: 2px solid var(--stone);
}

.entry-date {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--amber);
    letter-spacing: 0.1em;
    display: block;
    margin-bottom: 0.5rem;
}

.journal-entry p {
    font-family: var(--font-body);
    font-size: 16px;
    color: var(--text);
    line-height: 1.7;
}

.margin-note {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--whisper);
    font-style: italic;
    display: block;
    margin-top: 0.5rem;
    opacity: 0.7;
}

/* --- THE DESCENT --- */
.descent {
    min-height: 200vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10vh 0;
}

.descent-corridor {
    display: flex;
    width: 80%;
    max-width: 1000px;
    margin: 0 auto;
    transition: width 0.3s ease;
    position: relative;
}

.fractal-margin {
    flex: 0 0 60px;
    position: relative;
    overflow: hidden;
}

.fractal-margin::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(60deg, transparent, transparent 10px, rgba(158, 143, 184, 0.08) 10px, rgba(158, 143, 184, 0.08) 11px),
        repeating-linear-gradient(-60deg, transparent, transparent 10px, rgba(158, 143, 184, 0.06) 10px, rgba(158, 143, 184, 0.06) 11px),
        repeating-linear-gradient(0deg, transparent, transparent 15px, rgba(158, 143, 184, 0.04) 15px, rgba(158, 143, 184, 0.04) 16px);
}

.descent-content {
    flex: 1;
    padding: 4rem 3rem;
    display: flex;
    flex-direction: column;
    gap: 4rem;
}

.carved-text {
    font-family: var(--font-body);
    font-size: 20px;
    line-height: 1.8;
    color: var(--text);
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.8s ease, transform 0.8s ease;
    position: relative;
    padding-left: 1.5rem;
    border-left: 2px solid var(--blood);
}

.carved-text.visible {
    opacity: 0.9;
    transform: scale(1);
}

/* --- THE ARCHIVE --- */
.archive {
    min-height: 150vh;
    padding: 10vh 5vw;
}

.archive-title {
    font-family: var(--font-display);
    font-size: 36px;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--amber);
    text-align: center;
    margin-bottom: 4rem;
}

.archive-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    max-width: 1000px;
    margin: 0 auto;
}

.artifact-card {
    background: var(--deep);
    border: 1px solid var(--stone);
    padding: 2rem;
    position: relative;
    cursor: pointer;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-style: preserve-3d;
    perspective: 800px;
}

.artifact-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.artifact-card:hover {
    border-color: var(--signal);
    box-shadow: 0 0 20px rgba(29, 233, 182, 0.1);
}

/* Marble veining texture */
.artifact-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 30%, rgba(42, 42, 62, 0.3) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 70%, rgba(42, 42, 62, 0.2) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.card-face {
    position: relative;
    z-index: 1;
}

.card-lg { grid-column: span 2; }
.card-md { grid-column: span 1; }
.card-sm { grid-column: span 1; }

.artifact-label {
    font-family: var(--font-display);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.2em;
    color: var(--amber);
    display: block;
    margin-bottom: 1rem;
}

.artifact-code {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--signal);
    line-height: 1.6;
    white-space: pre;
}

.artifact-data {
    font-family: var(--font-mono);
    font-size: 16px;
    color: var(--text);
    line-height: 1.8;
}

.artifact-data.mono {
    font-size: 14px;
    color: var(--whisper);
}

.artifact-text {
    font-family: var(--font-body);
    font-size: 16px;
    color: var(--text);
    line-height: 1.7;
}

.artifact-diagram {
    width: 100px;
    height: 100px;
    display: block;
    margin: 0 auto;
}

/* --- THE SIGNAL --- */
.signal {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.signal-void {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 400px;
    height: 400px;
}

.signal-ring {
    position: absolute;
    border: 1px solid var(--signal);
    border-radius: 50%;
    opacity: 0;
}

.ring-1 {
    width: 60px;
    height: 60px;
    animation: signalPulse 2s ease-out infinite;
}

.ring-2 {
    width: 60px;
    height: 60px;
    animation: signalPulse 2s ease-out infinite 0.8s;
}

.ring-3 {
    width: 60px;
    height: 60px;
    animation: signalPulse 2s ease-out infinite 1.6s;
}

@keyframes signalPulse {
    0% { width: 0; height: 0; opacity: 0.6; }
    100% { width: 400px; height: 400px; opacity: 0; }
}

.signal-coordinate {
    position: relative;
    text-align: center;
    z-index: 10;
}

.coord-value {
    font-family: var(--font-display);
    font-size: clamp(48px, 10vw, 96px);
    font-weight: 700;
    color: var(--signal);
    letter-spacing: 0.2em;
    display: block;
    text-shadow: 0 0 40px rgba(29, 233, 182, 0.4);
}

.coord-label {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--whisper);
    letter-spacing: 0.2em;
    display: block;
    margin-top: 1rem;
}

.scattered-fragment {
    position: absolute;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--whisper);
    opacity: 0.4;
    letter-spacing: 0.1em;
}

.frag-1 { top: 15%; left: 8%; }
.frag-2 { top: 20%; right: 10%; }
.frag-3 { bottom: 20%; left: 12%; }
.frag-4 { bottom: 15%; right: 8%; }

/* --- Sonar Ring Interaction --- */
.sonar-click-ring {
    position: fixed;
    border: 1px solid var(--signal);
    border-radius: 50%;
    pointer-events: none;
    z-index: 9998;
    animation: sonarExpand 0.8s ease-out forwards;
}

@keyframes sonarExpand {
    0% { width: 0; height: 0; opacity: 0.4; }
    100% { width: 200px; height: 200px; opacity: 0; margin-left: -100px; margin-top: -100px; }
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .cipher-split, .map-split {
        flex-direction: column;
    }

    .map-terrain { flex: 1; }
    .map-journal { flex: 1; }

    .archive-grid {
        grid-template-columns: 1fr;
    }

    .card-lg { grid-column: span 1; }

    .cipher-grid {
        max-width: 280px;
        margin: 0 auto;
    }

    .margin-coord { display: none; }

    .descent-corridor {
        width: 95%;
    }

    .fractal-margin { flex: 0 0 20px; }
}
