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

html {
    scroll-behavior: smooth;
}

body {
    background: #0d1f15;
    color: #e8dcc4;
    font-family: 'Lora', serif;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.72;
    overflow-x: hidden;
}

/* === WATERMARK === */
.watermark {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-12deg);
    font-family: 'Playfair Display SC', serif;
    font-size: 35vw;
    color: #c4a35a;
    opacity: 0.018;
    pointer-events: none;
    z-index: 0;
    white-space: nowrap;
}

/* === SECTION INDICATOR === */
.section-indicator {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 3rem;
    height: 3rem;
    border: 1px solid #c4a35a;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    background: rgba(13, 31, 21, 0.8);
}

.section-numeral {
    font-family: 'Courier Prime', monospace;
    color: #c4a35a;
    font-size: 1rem;
}

/* === SECTION BASE === */
.section {
    position: relative;
    width: 100vw;
    z-index: 1;
}

/* === SECTION 1: ARMORY GATE === */
.armory-gate {
    height: 100vh;
    background: linear-gradient(175deg, #0d1f15 0%, #1a3a2a 40%, #2d5e3f 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.grain-overlay {
    position: absolute;
    inset: 0;
    opacity: 0.05;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    pointer-events: none;
}

.filigree {
    position: absolute;
    width: 200px;
    height: 200px;
    z-index: 2;
}

.filigree path {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    animation: drawFiligree 2s ease-in-out forwards;
    filter: drop-shadow(0 0 4px rgba(196, 163, 90, 0.3));
}

@keyframes drawFiligree {
    to { stroke-dashoffset: 0; }
}

.filigree-tl { top: 0; left: 0; }
.filigree-tr { top: 0; right: 0; }
.filigree-bl { bottom: 0; left: 0; }
.filigree-br { bottom: 0; right: 0; }

.gate-content {
    text-align: center;
    z-index: 3;
}

.gate-title {
    font-family: 'Playfair Display SC', serif;
    font-weight: 900;
    font-size: clamp(3rem, 8vw, 6rem);
    letter-spacing: 0.2em;
    color: #e8dcc4;
    line-height: 1.05;
    margin-bottom: 0.5rem;
}

.gate-tld {
    font-family: 'Courier Prime', monospace;
    font-size: 1rem;
    letter-spacing: 0.5em;
    color: #c4a35a;
    display: block;
    margin-bottom: 1.5rem;
}

.gate-subtitle {
    font-family: 'Playfair Display SC', serif;
    font-size: 2rem;
    color: #c4a35a;
    opacity: 0.7;
}

.gate-epigraph {
    position: absolute;
    top: 61.8%;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Lora', serif;
    font-style: italic;
    font-size: clamp(0.9rem, 1.2vw, 1.1rem);
    color: #e8dcc4;
    opacity: 0.8;
    text-align: center;
    max-width: 600px;
    z-index: 3;
}

/* === SECTION 2: CABINET === */
.cabinet-section {
    min-height: 100vh;
    position: relative;
}

.cabinet-dark {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 38.2%;
    background: #0d1f15;
}

.cabinet-light {
    position: absolute;
    top: 38.2%;
    left: 0;
    right: 0;
    bottom: 0;
    background: #f0e8d8;
}

.cabinet-divider {
    position: absolute;
    top: 38.2%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    z-index: 5;
    height: 30px;
}

.ornamental-rule {
    width: 100%;
    height: 30px;
    display: block;
}

.cabinet-cards {
    position: relative;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem;
    padding: 15vh 2rem 10vh;
}

.cabinet-card {
    width: 280px;
    background: #f0e8d8;
    border: 1px solid #c4a35a;
    padding: 2rem;
    position: relative;
    clip-path: polygon(0 0, calc(100% - 20px) 0, 100% 20px, 100% 100%, 0 100%);
    filter: sepia(0.15) contrast(1.05);
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

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

.card-code {
    position: absolute;
    top: 0.75rem;
    right: 1.5rem;
    font-family: 'Courier Prime', monospace;
    font-size: clamp(0.75rem, 0.9vw, 0.85rem);
    color: #8b6234;
}

.card-heading {
    font-family: 'Vollkorn', serif;
    font-weight: 600;
    font-size: clamp(1.1rem, 2.5vw, 1.4rem);
    color: #2a1f12;
    margin-bottom: 0.75rem;
    letter-spacing: 0.08em;
}

.card-body {
    font-family: 'Lora', serif;
    font-size: clamp(0.85rem, 1vw, 0.95rem);
    color: #2a1f12;
    line-height: 1.7;
}

/* === SECTION 3: OPTICAL TABLE === */
.optical-section {
    height: 100vh;
    background: #1a3a2a;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.lens-container {
    position: relative;
    width: 600px;
    height: 600px;
}

.lens {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.3);
    opacity: 0.2;
    transition: transform 1.2s cubic-bezier(0.16, 1, 0.3, 1), opacity 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.lens.focused {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.lens-ring {
    position: absolute;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.lens-ring-outer {
    width: 300px;
    height: 300px;
    border: 3px solid #4a8c5e;
}

.lens-ring-2 {
    width: 220px;
    height: 220px;
    border: 1px solid rgba(196, 163, 90, 0.4);
}

.lens-ring-3 {
    width: 160px;
    height: 160px;
    border: 1px solid rgba(196, 163, 90, 0.4);
}

.lens-ring-inner {
    width: 80px;
    height: 80px;
    border: 1px solid rgba(196, 163, 90, 0.4);
}

.lens-crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    background: rgba(196, 163, 90, 0.25);
}

.lens-crosshair-h {
    width: 300px;
    height: 1px;
    transform: translate(-50%, -50%);
}

.lens-crosshair-v {
    width: 1px;
    height: 300px;
    transform: translate(-50%, -50%);
}

.radial-lines {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.8s ease 1.2s;
}

.lens.focused ~ .radial-lines {
    opacity: 1;
}

.radial-text {
    position: absolute;
    width: 140px;
    text-align: center;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.radial-text.visible {
    opacity: 1;
    transform: translateY(0);
}

.radial-label {
    font-family: 'Vollkorn', serif;
    font-weight: 600;
    font-size: 0.9rem;
    color: #c4a35a;
    margin-bottom: 0.3rem;
    letter-spacing: 0.08em;
}

.radial-text p {
    font-family: 'Lora', serif;
    font-size: 0.75rem;
    color: #e8dcc4;
    line-height: 1.5;
    opacity: 0.85;
}

.radial-n { top: -10px; left: 50%; transform: translateX(-50%) translateY(30px); }
.radial-ne { top: 40px; right: -30px; }
.radial-e { top: 50%; right: -60px; transform: translateY(-50%); }
.radial-se { bottom: 40px; right: -30px; }
.radial-s { bottom: -10px; left: 50%; transform: translateX(-50%) translateY(30px); }
.radial-sw { bottom: 40px; left: -30px; }
.radial-w { top: 50%; left: -60px; transform: translateY(-50%); }
.radial-nw { top: 40px; left: -30px; }

.radial-n.visible { transform: translateX(-50%) translateY(0); }
.radial-e.visible { transform: translateY(-50%); }
.radial-s.visible { transform: translateX(-50%) translateY(0); }
.radial-w.visible { transform: translateY(-50%); }

/* === SECTION 4: ARCHIVE STACK === */
.archive-section {
    min-height: 150vh;
    padding: 10vh 0;
}

.archive-panel {
    min-height: 60vh;
    padding: 4rem 8vw;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    max-width: 800px;
    margin: 0 auto 2rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    transition: transform 0.8s cubic-bezier(0.33, 1, 0.68, 1);
}

.panel-1 { background: #0d1f15; transform: rotate(-0.5deg); }
.panel-2 { background: #1a3a2a; transform: rotate(0.4deg); }
.panel-3 { background: #f0e8d8; color: #2a1f12; transform: rotate(-0.3deg); }
.panel-4 { background: #2d5e3f; transform: rotate(0.6deg); }
.panel-5 { background: #0d1f15; transform: rotate(-0.8deg); }

.archive-panel.settled {
    transform: rotate(0deg);
}

.panel-icon {
    width: 60px;
    height: 60px;
    margin-bottom: 1.5rem;
}

.panel-heading {
    font-family: 'Playfair Display SC', serif;
    font-weight: 900;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    letter-spacing: 0.18em;
    line-height: 1.05;
    margin-bottom: 1.5rem;
}

.panel-body {
    font-family: 'Lora', serif;
    line-height: 1.72;
    text-indent: 2.5em;
    max-width: 60ch;
}

.panel-3 .panel-heading { color: #2a1f12; }
.panel-3 .panel-icon path,
.panel-3 .panel-icon line { stroke: #8b6234; }

/* === SECTION 5: COLOPHON === */
.colophon-section {
    min-height: 40vh;
    background: #0d1f15;
    padding: 4rem 4vw;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.colophon-rule {
    width: 100%;
    margin-bottom: 3rem;
}

.colophon-text {
    column-count: 3;
    column-gap: 3rem;
    max-width: 1200px;
    margin-bottom: 3rem;
    color: #e8dcc4;
    font-size: clamp(0.85rem, 1vw, 0.95rem);
}

.colophon-text p {
    text-indent: 2.5em;
    margin-bottom: 0;
}

.colophon-fleuron {
    font-size: 2rem;
    color: #c4a35a;
    margin-bottom: 1.5rem;
    text-align: center;
}

.colophon-mark {
    font-family: 'Courier Prime', monospace;
    letter-spacing: 0.3em;
    color: #c4a35a;
    text-align: center;
    font-size: 0.85rem;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .lens-container {
        width: 90vw;
        height: 90vw;
    }

    .lens-ring-outer { width: 200px; height: 200px; }
    .lens-ring-2 { width: 150px; height: 150px; }
    .lens-ring-3 { width: 100px; height: 100px; }
    .lens-ring-inner { width: 50px; height: 50px; }
    .lens-crosshair-h { width: 200px; }
    .lens-crosshair-v { height: 200px; }

    .radial-text {
        position: relative;
        width: 100%;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
        transform: none !important;
        margin: 1rem 0;
    }

    .radial-text.visible { transform: none !important; }

    .lens-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        height: auto;
    }

    .radial-lines { display: none; }

    .lens {
        position: relative;
        top: auto;
        left: auto;
        transform: scale(0.3);
        margin-bottom: 2rem;
    }

    .lens.focused { transform: scale(1); }

    .optical-section {
        height: auto;
        min-height: 100vh;
        padding: 4rem 2rem;
    }

    .cabinet-cards {
        flex-direction: column;
        align-items: center;
    }

    .archive-panel {
        transform: rotate(0deg) !important;
    }

    .colophon-text {
        column-count: 1;
    }

    .filigree {
        width: 120px;
        height: 120px;
    }
}

@media (max-width: 1024px) and (min-width: 769px) {
    .colophon-text {
        column-count: 2;
    }
}
