/* === RESET & BASE === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-snap-type: y mandatory;
    overflow-y: scroll;
    scroll-behavior: smooth;
}

body {
    background: #1a120b;
    color: #d4b896;
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    letter-spacing: 0.04em;
    line-height: 1.7;
    overflow-x: hidden;
}

/* === GRAIN OVERLAY === */
#grain-canvas-wrap {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    mix-blend-mode: overlay;
    opacity: 0.06;
}

#grain {
    width: 100%;
    height: 100%;
    display: block;
}

/* === SPORE CONTAINER === */
#spore-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

.spore {
    position: absolute;
    border-radius: 50%;
    background: #d4b896;
    opacity: 0.15;
}

/* === CHAMBERS === */
.chamber {
    width: 100%;
    min-height: 100vh;
    height: 100vh;
    scroll-snap-align: start;
    position: relative;
    overflow: hidden;
}

/* === CHAMBER 1: TERMINAL === */
#chamber-1 {
    background: #1a120b;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.terminal-block {
    max-width: 700px;
    width: 90%;
}

.terminal-line {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(0.95rem, 1.5vw, 1.2rem);
    color: #d4b896;
    line-height: 2;
    white-space: nowrap;
    overflow: hidden;
    min-height: 1.7em;
}

.cursor {
    color: #d4a24e;
    animation: blink 530ms step-end infinite;
    font-family: 'Share Tech Mono', monospace;
}

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

.descend-arrow {
    margin-top: 40px;
    opacity: 1;
    transition: opacity 1.5s ease;
    animation: pulse-arrow 2.5s ease-in-out infinite;
}

.descend-arrow.hidden {
    opacity: 0;
}

@keyframes pulse-arrow {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(8px); }
}

/* === CHAMBER 2: CATALOGUE === */
#chamber-2 {
    background: #1a120b;
    display: flex;
    align-items: stretch;
}

.catalogue-layout {
    display: flex;
    width: 100%;
    height: 100%;
}

.catalogue-title-col {
    width: 40%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.catalogue-title {
    font-family: 'Major Mono Display', monospace;
    font-size: clamp(3rem, 8vw, 7rem);
    color: #c2703e;
    letter-spacing: 0.08em;
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

.catalogue-entries {
    width: 60%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 2rem 2rem 2rem 0;
}

.dossier-strip {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    height: 60px;
    border-bottom: 1px solid #3d2b1a;
    padding: 0 1rem;
    transition: background 0.3s ease;
    flex-shrink: 0;
}

.dossier-strip:first-child {
    border-top: 1px solid #3d2b1a;
}

.dossier-strip:hover {
    background: rgba(139, 69, 19, 0.15);
}

.archive-num {
    font-family: 'Major Mono Display', monospace;
    font-size: clamp(1.2rem, 2vw, 1.8rem);
    color: #c2703e;
    letter-spacing: 0.08em;
    min-width: 3.5em;
}

.puzzle-title {
    font-family: 'Share Tech Mono', monospace;
    color: #d4b896;
    font-size: clamp(0.7rem, 1vw, 0.9rem);
    white-space: nowrap;
    min-width: 10em;
}

.difficulty {
    display: flex;
    gap: 3px;
    min-width: 5em;
}

.difficulty .mushroom-icon {
    width: 14px;
    height: 16px;
    fill: #8b4513;
}

.dossier-desc {
    font-family: 'Share Tech Mono', monospace;
    color: #d4b896;
    opacity: 0.6;
    font-size: clamp(0.65rem, 0.9vw, 0.8rem);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-height: 1em;
}

/* === CHAMBER 3: SPECIMEN WALL === */
#chamber-3 {
    background: #2d1f14;
}

.trunk-line {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 100%;
    z-index: 1;
}

#trunk-path {
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    transition: stroke-dashoffset 2s ease;
}

#chamber-3.visible #trunk-path {
    stroke-dashoffset: 0;
}

.specimen-labels {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

.specimen-label {
    position: absolute;
    border: 1px solid #3d2b1a;
    padding: 0.6rem 1.2rem;
    background: rgba(26, 18, 11, 0.7);
    opacity: 0;
    transition: opacity 0.6s ease;
}

.specimen-label.visible {
    opacity: 1;
}

.label-text {
    font-family: 'Caveat', cursive;
    color: #7a9a6b;
    font-size: clamp(0.9rem, 1.5vw, 1.2rem);
    font-weight: 400;
    white-space: nowrap;
}

.branch-line {
    position: absolute;
    top: 50%;
    width: 100px;
    height: 10px;
    opacity: 0.5;
}

.specimen-label[style*="left:12%"] .branch-line,
.specimen-label[style*="left:8%"] .branch-line,
.specimen-label[style*="left:18%"] .branch-line,
.specimen-label[style*="left:25%"] .branch-line {
    right: -100px;
}

.specimen-label[style*="left:62%"] .branch-line,
.specimen-label[style*="left:55%"] .branch-line,
.specimen-label[style*="left:58%"] .branch-line {
    left: -100px;
}

/* === CHAMBER 4: DEEP ARCHIVE === */
#chamber-4 {
    background: #1a120b;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 3rem 2rem;
    overflow-y: auto;
}

.archive-log {
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
}

.log-line {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(0.75rem, 1vw, 0.9rem);
    color: #d4b896;
    line-height: 1.8;
    padding: 0.3rem 0;
    position: relative;
}

.log-meta {
    color: #d4b896;
    opacity: 0.4;
}

.annotation-parent {
    position: relative;
}

.margin-annotation {
    position: absolute;
    right: -220px;
    top: 0;
    font-family: 'Caveat', cursive;
    color: #7a9a6b;
    font-size: clamp(0.9rem, 1.2vw, 1.1rem);
    transform: rotate(-1.5deg);
    width: 200px;
    line-height: 1.4;
}

.redacted {
    background: #2d1f14;
    color: #2d1f14;
    padding: 0 4px;
    cursor: pointer;
    transition: all 2s ease;
    filter: blur(2px);
    user-select: none;
}

.redacted.revealed {
    background: transparent;
    color: #d4b896;
    filter: blur(0);
}

.archive-end {
    max-width: 900px;
    width: 100%;
    margin: 2rem auto 0;
    font-family: 'Share Tech Mono', monospace;
    color: #d4b896;
}

/* === TREE RING NAV === */
#tree-ring-nav {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 1000;
    cursor: pointer;
}

#tree-ring-nav .ring {
    transition: all 0.3s ease;
    cursor: pointer;
}

#tree-ring-nav .ring.active {
    stroke: #d4a24e;
    filter: drop-shadow(0 0 4px #d4a24e);
}

#tree-ring-nav .ring[data-chamber="4"].active {
    fill: #d4a24e;
    stroke: #d4a24e;
    filter: drop-shadow(0 0 4px #d4a24e);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .catalogue-layout {
        flex-direction: column;
    }

    .catalogue-title-col {
        width: 100%;
        height: auto;
        padding: 1rem;
    }

    .catalogue-title {
        writing-mode: horizontal-tb;
        font-size: clamp(2rem, 6vw, 4rem);
    }

    .catalogue-entries {
        width: 100%;
        padding: 0 1rem 1rem;
    }

    .dossier-strip {
        flex-wrap: wrap;
        height: auto;
        padding: 0.5rem;
        gap: 0.5rem;
    }

    .margin-annotation {
        position: static;
        display: block;
        transform: rotate(-1deg);
        width: 100%;
        margin-top: 0.3rem;
    }
}
