/* layer2.wiki - Sunken Archives of the Protocol Scribes */
/* Colors and Typography from DESIGN.md */

:root {
    --bg-abyss: #0B0E1A;
    --surface-parchment: #E8DCC8;
    --text-ink: #2A2520;
    --accent-teal: #00D4AA;
    --accent-violet: #6B4CE6;
    --annotation: #7B8FA3;
    --fish-coral: #FF6B4A;
    --parchment-shadow: #C4A882;
}

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

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

body {
    font-family: 'Cormorant Garamond', Georgia, serif;
    background: linear-gradient(
        to bottom,
        #0d1025 0%,
        #0B0E1A 20%,
        #090c17 50%,
        #070a14 80%,
        #050810 100%
    );
    background-attachment: fixed;
    color: var(--text-ink);
    min-height: 500vh;
    overflow-x: hidden;
}

/* Chapter / Section Base */
.chapter {
    min-height: 100vh;
    display: grid;
    place-items: center;
    scroll-snap-align: start;
    position: relative;
    overflow: hidden;
    padding: 60px 24px;
}

/* Section Gaps with magnetic diamonds */
.section-gap {
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
}

.magnetic-diamond {
    width: 12px;
    height: 12px;
    border: 1px solid var(--accent-teal);
    transform: rotate(45deg);
    transition: transform 0.6s ease, box-shadow 0.6s ease;
    opacity: 0.6;
}

.magnetic-diamond.magnetic-active {
    transform: rotate(45deg) scale(1.3);
    box-shadow: 0 0 20px rgba(0, 212, 170, 0.5);
    opacity: 1;
}

.magnetic-diamond.magnetic-pulsing {
    animation: diamond-pulse 2s ease-in-out infinite;
}

@keyframes diamond-pulse {
    0%, 100% { box-shadow: 0 0 8px rgba(0, 212, 170, 0.2); }
    50% { box-shadow: 0 0 16px rgba(0, 212, 170, 0.4); }
}

/* Manuscript Panel - Parchment Texture */
.manuscript-panel {
    background:
        radial-gradient(ellipse 180px 120px at 20% 30%, rgba(196, 168, 130, 0.25), transparent),
        radial-gradient(ellipse 100px 80px at 75% 60%, rgba(196, 168, 130, 0.2), transparent),
        radial-gradient(ellipse 150px 100px at 50% 80%, rgba(196, 168, 130, 0.15), transparent),
        radial-gradient(ellipse 60px 60px at 85% 15%, rgba(196, 168, 130, 0.3), transparent),
        radial-gradient(ellipse 90px 70px at 10% 70%, rgba(196, 168, 130, 0.18), transparent),
        conic-gradient(from 45deg at 50% 50%, rgba(196, 168, 130, 0.005), transparent, rgba(196, 168, 130, 0.005), transparent),
        linear-gradient(135deg, #E8DCC8, #C4A882 40%, #E8DCC8 60%, #C4A882 85%, #E8DCC8);
    position: relative;
}

/* ---- SECTION 1: THE SURFACE ---- */
#section-surface .chapter-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 60px;
}

.manuscript-panel-title {
    padding: 60px 80px;
    text-align: center;
    clip-path: polygon(2px 0, calc(100% - 3px) 2px, 100% calc(100% - 1px), 1px calc(100% - 3px));
    box-shadow: 4px 6px 24px rgba(42, 37, 32, 0.3), inset 0 0 60px rgba(196, 168, 130, 0.1);
}

.domain-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(4rem, 10vw, 8rem);
    letter-spacing: -0.03em;
    color: var(--text-ink);
    line-height: 1;
    margin-bottom: 16px;
}

.subtitle {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-style: italic;
    font-size: clamp(1rem, 2.5vw, 1.4rem);
    color: var(--annotation);
    letter-spacing: 0.05em;
}

.scroll-chevron {
    animation: chevron-bob 2.5s ease-in-out infinite;
    opacity: 0.7;
}

@keyframes chevron-bob {
    0%, 100% { transform: translateY(0); opacity: 0.5; }
    50% { transform: translateY(8px); opacity: 0.9; }
}

/* ---- SECTION 2: THE FOUNDATION ---- */
.chapter-two-col {
    display: grid;
    grid-template-columns: 40% 60%;
    gap: 40px;
    max-width: 1100px;
    width: 100%;
    align-items: center;
}

.col-manuscript {
    display: flex;
    align-items: center;
}

.manuscript-panel-foundation {
    padding: 40px 32px;
    clip-path: polygon(0 1px, calc(100% - 2px) 0, 100% calc(100% - 2px), 3px 100%);
    box-shadow: 3px 4px 20px rgba(42, 37, 32, 0.25);
}

.section-heading {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(1.5rem, 3vw, 2.2rem);
    color: var(--text-ink);
    letter-spacing: -0.02em;
    margin-bottom: 20px;
}

.body-text {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 18px;
    line-height: 1.7;
    font-weight: 400;
    color: var(--text-ink);
    margin-bottom: 16px;
}

.body-text em {
    font-weight: 600;
    font-style: italic;
}

.annotation {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 14px;
    line-height: 1.5;
    letter-spacing: 0.02em;
    color: var(--annotation);
    margin-top: 12px;
}

.col-circuit {
    display: flex;
    justify-content: center;
    align-items: center;
}

.circuit-svg {
    width: 100%;
    max-width: 350px;
    height: auto;
}

.circuit-node {
    opacity: 0;
    transition: opacity 0.8s ease;
}

.circuit-node.visible {
    opacity: 1;
}

.circuit-path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 2s ease-in-out;
}

.circuit-path.visible {
    stroke-dashoffset: 0;
}

/* ---- SECTION 3: SCALING PROTOCOLS ---- */
.chapter-narrow {
    max-width: 640px;
    width: 100%;
}

.chapter-narrow .section-heading {
    text-align: center;
    margin-bottom: 48px;
}

.manuscript-entry {
    padding: 32px 28px;
    margin-bottom: 32px;
    position: relative;
    background:
        radial-gradient(ellipse 120px 80px at 15% 25%, rgba(196, 168, 130, 0.2), transparent),
        radial-gradient(ellipse 80px 60px at 80% 70%, rgba(196, 168, 130, 0.15), transparent),
        radial-gradient(ellipse 60px 40px at 60% 20%, rgba(196, 168, 130, 0.25), transparent),
        linear-gradient(135deg, #E8DCC8, #C4A882 35%, #E8DCC8 65%, #C4A882);
    box-shadow: 2px 3px 16px rgba(42, 37, 32, 0.2);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.manuscript-entry.visible {
    opacity: 1;
    transform: translateY(0);
}

.manuscript-entry-1 {
    clip-path: polygon(1px 0, 100% 2px, calc(100% - 2px) calc(100% - 1px), 0 calc(100% - 3px));
}

.manuscript-entry-2 {
    clip-path: polygon(0 1px, calc(100% - 1px) 0, 100% calc(100% - 2px), 2px 100%);
}

.manuscript-entry-3 {
    clip-path: polygon(2px 0, 100% 1px, calc(100% - 3px) calc(100% - 2px), 0 100%);
}

.manuscript-entry-4 {
    clip-path: polygon(0 2px, calc(100% - 2px) 0, 100% calc(100% - 1px), 1px calc(100% - 2px));
}

.protocol-name {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.3rem;
    color: var(--accent-violet);
    letter-spacing: -0.01em;
    margin-bottom: 12px;
}

/* ---- SECTION 4: DEEP ARCHIVE ---- */
.chapter-archive {
    max-width: 900px;
    width: 100%;
}

.section-heading-archive {
    text-align: center;
    margin-bottom: 48px;
    color: var(--surface-parchment);
}

.archive-panels {
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: relative;
}

.archive-panel {
    padding: 36px 32px;
    position: relative;
    box-shadow: 4px 6px 24px rgba(42, 37, 32, 0.3), -2px -2px 8px rgba(196, 168, 130, 0.1);
    opacity: 0;
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.archive-panel.visible {
    opacity: 1;
}

.archive-panel-1 {
    transform: rotate(1deg) translateX(-10px);
    clip-path: polygon(3px 0, 100% 1px, calc(100% - 1px) calc(100% - 2px), 0 calc(100% - 1px));
}

.archive-panel-1.visible {
    transform: rotate(1deg) translateX(-10px);
}

.archive-panel-2 {
    transform: rotate(-0.5deg) translateX(15px);
    clip-path: polygon(0 2px, calc(100% - 2px) 0, 100% calc(100% - 3px), 2px 100%);
}

.archive-panel-2.visible {
    transform: rotate(-0.5deg) translateX(15px);
}

.archive-panel-3 {
    transform: rotate(0.8deg) translateX(-5px);
    clip-path: polygon(1px 0, 100% 3px, calc(100% - 3px) calc(100% - 1px), 0 calc(100% - 2px));
}

.archive-panel-3.visible {
    transform: rotate(0.8deg) translateX(-5px);
}

/* ---- SECTION 5: COLOPHON ---- */
.chapter-colophon {
    min-height: 60vh;
}

.chapter-colophon-inner {
    text-align: center;
    max-width: 500px;
}

.colophon-rule {
    margin-bottom: 32px;
}

.colophon-rule-bottom {
    margin-top: 32px;
    margin-bottom: 0;
}

.ink-rule {
    width: 100%;
    max-width: 400px;
    height: auto;
}

.colophon-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--surface-parchment);
    margin-bottom: 16px;
    font-variant: small-caps;
}

.colophon-text {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 16px;
    line-height: 1.7;
    color: var(--annotation);
    margin-bottom: 20px;
}

.colophon-timestamp {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
    color: var(--annotation);
    letter-spacing: 0.02em;
    opacity: 0.7;
}

/* ---- FISH ANIMATIONS ---- */
.fish {
    position: absolute;
    pointer-events: none;
    will-change: transform;
}

.fish-1 {
    top: 20%;
    right: 8%;
    opacity: 0.5;
    animation: swim-x-1 12s ease-in-out infinite, swim-y-1 16s ease-in-out infinite;
}

.fish-2 {
    bottom: 15%;
    left: 5%;
    opacity: 0.4;
    animation: swim-x-2 9s ease-in-out infinite, swim-y-2 14s ease-in-out infinite;
}

.fish-3 {
    top: 12%;
    right: 6%;
    opacity: 0.45;
    animation: swim-x-3 14s ease-in-out infinite, swim-y-3 18s ease-in-out infinite;
}

.fish-4 {
    bottom: 25%;
    left: 8%;
    opacity: 0.5;
    animation: swim-x-4 8s ease-in-out infinite, swim-y-4 12s ease-in-out infinite;
}

.fish-5 {
    bottom: 10%;
    right: 10%;
    opacity: 0.4;
    animation: swim-x-5 11s ease-in-out infinite, swim-y-5 15s ease-in-out infinite;
}

.fish-6 {
    top: 18%;
    left: 12%;
    opacity: 0.5;
    animation: swim-x-6 10s ease-in-out infinite, swim-y-6 13s ease-in-out infinite;
}

.fish-7 {
    bottom: 20%;
    right: 8%;
    opacity: 0.45;
    animation: swim-x-7 13s ease-in-out infinite, swim-y-7 17s ease-in-out infinite;
}

.fish-8 {
    top: 30%;
    left: 10%;
    opacity: 0.4;
    animation: swim-x-8 15s ease-in-out infinite, swim-y-8 19s ease-in-out infinite;
}

@keyframes swim-x-1 { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(30px); } }
@keyframes swim-y-1 { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes swim-x-2 { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(-25px); } }
@keyframes swim-y-2 { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(8px); } }
@keyframes swim-x-3 { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(20px); } }
@keyframes swim-y-3 { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
@keyframes swim-x-4 { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(-18px); } }
@keyframes swim-y-4 { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(6px); } }
@keyframes swim-x-5 { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(28px); } }
@keyframes swim-y-5 { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes swim-x-6 { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(-22px); } }
@keyframes swim-y-6 { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(10px); } }
@keyframes swim-x-7 { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(15px); } }
@keyframes swim-y-7 { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes swim-x-8 { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(-30px); } }
@keyframes swim-y-8 { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(9px); } }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    .chapter-two-col {
        grid-template-columns: 1fr;
        gap: 32px;
    }

    .manuscript-panel-title {
        padding: 40px 32px;
    }

    .chapter-narrow {
        padding: 0 16px;
    }

    .archive-panel-1 { transform: rotate(0.5deg); }
    .archive-panel-2 { transform: rotate(-0.3deg); }
    .archive-panel-3 { transform: rotate(0.4deg); }
    .archive-panel-1.visible { transform: rotate(0.5deg); }
    .archive-panel-2.visible { transform: rotate(-0.3deg); }
    .archive-panel-3.visible { transform: rotate(0.4deg); }

    .fish { display: none; }
}
