/* ============================================================
   archetype.boo - Gold-Black-Luxury Cyberpunk Scriptorium
   ============================================================ */

/* CSS Custom Properties */
:root {
    --void-black: #050507;
    --chamber-black: #0A0A0F;
    --bronze-shadow: #2A2218;
    --tarnished-gold: #5A5040;
    --parchment-gold: #D4B896;
    --scholarly-gold: #C9A84C;
    --electric-amber: #F0C040;
    --signal-gold: #FFD700;
    --tarnished-gold-warm: #B8976A;

    --font-display: 'Dela Gothic One', sans-serif;
    --font-decorative: 'Cinzel Decorative', serif;
    --font-body: 'Cormorant Garamond', serif;
    --font-mono: 'JetBrains Mono', monospace;

    --gold-gradient: linear-gradient(180deg, #C9A84C 0%, #F0C040 50%, #C9A84C 100%);
    --gold-glow: 0 0 30px rgba(201, 168, 76, 0.08);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    background: var(--void-black);
    color: var(--parchment-gold);
    font-family: var(--font-body);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Text Selection */
::selection {
    background: var(--scholarly-gold);
    color: var(--void-black);
}

::-moz-selection {
    background: var(--scholarly-gold);
    color: var(--void-black);
}

/* SVG Filters (hidden) */
.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* ============================================================
   Progress Indicator
   ============================================================ */
.progress-indicator {
    position: fixed;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.progress-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--gold-gradient);
    opacity: 0.4;
}

.progress-node {
    position: relative;
    width: 16px;
    height: 16px;
    margin: 16px 0;
    cursor: pointer;
    z-index: 1;
}

.node-hex {
    width: 100%;
    height: 100%;
    background: var(--void-black);
    border: 1px solid var(--scholarly-gold);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    transition: background 0.4s ease, box-shadow 0.4s ease;
}

.progress-node.active .node-hex {
    background: var(--scholarly-gold);
    box-shadow: 0 0 8px rgba(201, 168, 76, 0.6);
    animation: nodePulse 2s ease-in-out infinite;
}

@keyframes nodePulse {
    0%, 100% { box-shadow: 0 0 0px rgba(201, 168, 76, 0.4); }
    50% { box-shadow: 0 0 8px rgba(201, 168, 76, 0.6); }
}

/* ============================================================
   Chambers (Main Scroll Container)
   ============================================================ */
.chambers {
    width: 100vw;
    height: 100vh;
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    scrollbar-width: none;
}

.chambers::-webkit-scrollbar {
    display: none;
}

.chamber {
    width: 100vw;
    height: 100vh;
    position: relative;
    scroll-snap-align: start;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 48px;
}

.chamber::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--chamber-black);
    opacity: 0;
    pointer-events: none;
    z-index: 0;
}

/* Noise overlay via pseudo-element */
.chamber::after {
    content: '';
    position: absolute;
    inset: -50%;
    width: 200%;
    height: 200%;
    background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 256px 256px;
    opacity: 0.04;
    pointer-events: none;
    z-index: 1;
    animation: grainShift 0.1s steps(2) infinite;
    mix-blend-mode: overlay;
}

@keyframes grainShift {
    0% { transform: translate(0, 0); }
    50% { transform: translate(-3px, -3px); }
    100% { transform: translate(2px, 1px); }
}

.chamber-content {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 1200px;
}

/* Section backgrounds */
.chamber-vestibule {
    background: var(--void-black);
}

.chamber-index {
    background: var(--void-black);
}

.chamber-reading {
    background: var(--chamber-black);
}

.chamber-crystallography {
    background: var(--void-black);
}

.chamber-colophon {
    background: var(--chamber-black);
}

/* Noise density variations */
.chamber-vestibule::after { opacity: 0.06; }
.chamber-index::after { opacity: 0.05; }
.chamber-reading::after { opacity: 0.03; }
.chamber-crystallography::after { opacity: 0.08; }
.chamber-colophon::after { opacity: 0.04; }

/* Static burst on section enter */
.chamber.static-burst::after {
    opacity: 0.15;
    transition: opacity 0.2s ease;
}

/* ============================================================
   Corner Ornaments
   ============================================================ */
.corner-ornament {
    position: absolute;
    width: 24px;
    height: 24px;
    z-index: 3;
    transition: transform 0.3s ease;
}

.corner-top-left {
    top: 24px;
    left: 24px;
}

.corner-bottom-right {
    bottom: 24px;
    right: 24px;
}

.corner-top-left::before,
.corner-top-left::after {
    content: '';
    position: absolute;
    background: var(--scholarly-gold);
}

.corner-top-left::before {
    top: 0;
    left: 0;
    width: 24px;
    height: 1px;
    transform-origin: left center;
    transform: rotate(0deg);
}

.corner-top-left::after {
    top: 0;
    left: 0;
    width: 1px;
    height: 24px;
    transform-origin: top center;
}

.corner-bottom-right::before,
.corner-bottom-right::after {
    content: '';
    position: absolute;
    background: var(--scholarly-gold);
}

.corner-bottom-right::before {
    bottom: 0;
    right: 0;
    width: 24px;
    height: 1px;
}

.corner-bottom-right::after {
    bottom: 0;
    right: 0;
    width: 1px;
    height: 24px;
}

/* ============================================================
   Fracture Lines
   ============================================================ */
.fracture-line {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    z-index: 3;
}

.fracture-line::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 30%;
    height: 1px;
    background: var(--scholarly-gold);
    transform: skewY(-1deg);
}

.fracture-line::after {
    content: '';
    position: absolute;
    top: -1px;
    left: 32%;
    width: 25%;
    height: 1px;
    background: var(--scholarly-gold);
    transform: skewY(2deg);
}

/* Additional fracture segments via box-shadow trick */
.fracture-line {
    background: linear-gradient(
        to right,
        transparent 0%,
        transparent 58%,
        var(--scholarly-gold) 60%,
        var(--scholarly-gold) 78%,
        transparent 78.5%,
        transparent 82%,
        var(--scholarly-gold) 83%,
        var(--scholarly-gold) 100%
    );
    height: 1px;
    transform-origin: center;
}

/* ============================================================
   Section Titles
   ============================================================ */
.section-title {
    font-family: var(--font-display);
    font-size: clamp(48px, 8vw, 120px);
    color: var(--scholarly-gold);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-align: center;
    margin-bottom: 48px;
    line-height: 1.1;
}

.section-title .char {
    display: inline-block;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.section-title.revealed .char {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================================
   Chamber 1: The Vestibule
   ============================================================ */
.vestibule-content {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.vestibule-title {
    font-family: var(--font-body);
    font-size: clamp(48px, 8vw, 96px);
    font-weight: 400;
    color: var(--scholarly-gold);
    letter-spacing: 0.15em;
    text-align: center;
    line-height: 1;
}

.vestibule-title .char {
    display: inline-block;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

.vestibule-title.revealed .char {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================================
   Chamber 2: The Index Chamber
   ============================================================ */
.chamber-index .chamber-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.sigil-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    max-width: calc(100vw - 30vw);
    margin: 0 auto;
}

.sigil-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.hex-frame {
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    border: none;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    margin-bottom: 12px;
}

.hex-frame::before {
    content: '';
    position: absolute;
    inset: 0;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: transparent;
    border: 1px solid var(--scholarly-gold);
    /* Use outline trick for hex border */
}

/* Hex border using SVG background */
.hex-frame::after {
    content: '';
    position: absolute;
    inset: -1px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: var(--scholarly-gold);
    z-index: -1;
}

.hex-frame {
    background: var(--void-black);
    margin: 1px;
}

.sigil-svg {
    width: 80px;
    height: 80px;
}

.sigil-label {
    font-family: var(--font-decorative);
    font-size: 14px;
    font-weight: 700;
    color: var(--tarnished-gold-warm);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-align: center;
    transition: color 0.2s ease;
}

.sigil-cell:hover .hex-frame {
    transform: rotate(30deg);
    box-shadow: 0 0 20px rgba(240, 192, 64, 0.15);
}

.sigil-cell:hover .sigil-svg circle,
.sigil-cell:hover .sigil-svg line,
.sigil-cell:hover .sigil-svg path,
.sigil-cell:hover .sigil-svg polygon,
.sigil-cell:hover .sigil-svg polyline {
    stroke: var(--electric-amber);
    transition: stroke 0.2s ease;
}

.sigil-cell:hover .sigil-label {
    color: var(--electric-amber);
}

/* ============================================================
   Chambers 3-5: The Reading Room
   ============================================================ */
.reading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.reading-column {
    max-width: 680px;
    margin: 0 auto;
    text-align: left;
}

.reading-column p {
    font-family: var(--font-body);
    font-size: 19px;
    font-weight: 400;
    color: var(--parchment-gold);
    line-height: 1.85;
    margin-bottom: 2.5em;
}

.pull-quote {
    position: relative;
    margin: 3em -10vw;
    padding: 2em 10vw;
    border-top: 1px solid var(--scholarly-gold);
    border-bottom: 1px solid var(--scholarly-gold);
}

.pull-quote-mark {
    font-family: var(--font-decorative);
    font-size: 64px;
    color: var(--scholarly-gold);
    position: absolute;
    top: -8px;
    left: 10vw;
    line-height: 1;
    opacity: 0.6;
}

.pull-quote blockquote {
    font-family: var(--font-decorative);
    font-size: clamp(20px, 2.5vw, 28px);
    font-weight: 700;
    color: var(--scholarly-gold);
    letter-spacing: 0.02em;
    line-height: 1.5;
    text-align: center;
    padding-top: 16px;
}

/* Fade-in for reading elements */
.reading-column p,
.pull-quote {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

.chamber.revealed .reading-column p,
.chamber.revealed .pull-quote {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================================
   Chamber 6: The Crystallography Lab
   ============================================================ */
.chamber-crystallography .chamber-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.icosahedron-container {
    width: 300px;
    height: 300px;
    perspective: 800px;
    perspective-origin: 50% 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icosahedron {
    width: 200px;
    height: 200px;
    position: relative;
    transform-style: preserve-3d;
    animation: icoRotate 30s linear infinite;
}

@keyframes icoRotate {
    0% { transform: rotateX(0deg) rotateY(0deg); }
    100% { transform: rotateX(360deg) rotateY(360deg); }
}

.ico-face {
    position: absolute;
    width: 0;
    height: 0;
    border-style: solid;
    transform-origin: center;
    backface-visibility: visible;
    opacity: 0.3;
    transition: opacity 0.3s ease;
}

/* Icosahedron faces - approximated triangular wireframe faces */
/* Top cap - 5 faces */
.face-0  { border-width: 0 38px 66px 38px; border-color: transparent transparent rgba(201,168,76,0.05) transparent; transform: translate3d(62px, 0px, 0px) rotateX(-26.57deg) rotateY(0deg); outline: 1px solid var(--scholarly-gold); }
.face-1  { border-width: 0 38px 66px 38px; border-color: transparent transparent rgba(201,168,76,0.05) transparent; transform: translate3d(81px, 20px, -59px) rotateX(-26.57deg) rotateY(72deg); outline: 1px solid var(--scholarly-gold); }
.face-2  { border-width: 0 38px 66px 38px; border-color: transparent transparent rgba(201,168,76,0.05) transparent; transform: translate3d(43px, 20px, -95px) rotateX(-26.57deg) rotateY(144deg); outline: 1px solid var(--scholarly-gold); }
.face-3  { border-width: 0 38px 66px 38px; border-color: transparent transparent rgba(201,168,76,0.05) transparent; transform: translate3d(5px, 20px, -59px) rotateX(-26.57deg) rotateY(216deg); outline: 1px solid var(--scholarly-gold); }
.face-4  { border-width: 0 38px 66px 38px; border-color: transparent transparent rgba(201,168,76,0.05) transparent; transform: translate3d(24px, 0px, 0px) rotateX(-26.57deg) rotateY(288deg); outline: 1px solid var(--scholarly-gold); }

/* Middle band - 10 faces */
.face-5  { border-width: 66px 38px 0 38px; border-color: rgba(201,168,76,0.05) transparent transparent transparent; transform: translate3d(62px, 66px, 0px) rotateX(26.57deg) rotateY(36deg); outline: 1px solid var(--scholarly-gold); }
.face-6  { border-width: 66px 38px 0 38px; border-color: rgba(201,168,76,0.05) transparent transparent transparent; transform: translate3d(81px, 66px, -59px) rotateX(26.57deg) rotateY(108deg); outline: 1px solid var(--scholarly-gold); }
.face-7  { border-width: 66px 38px 0 38px; border-color: rgba(201,168,76,0.05) transparent transparent transparent; transform: translate3d(43px, 66px, -95px) rotateX(26.57deg) rotateY(180deg); outline: 1px solid var(--scholarly-gold); }
.face-8  { border-width: 66px 38px 0 38px; border-color: rgba(201,168,76,0.05) transparent transparent transparent; transform: translate3d(5px, 66px, -59px) rotateX(26.57deg) rotateY(252deg); outline: 1px solid var(--scholarly-gold); }
.face-9  { border-width: 66px 38px 0 38px; border-color: rgba(201,168,76,0.05) transparent transparent transparent; transform: translate3d(24px, 66px, 0px) rotateX(26.57deg) rotateY(324deg); outline: 1px solid var(--scholarly-gold); }

/* Bottom cap - 5 faces */
.face-10 { border-width: 0 38px 66px 38px; border-color: transparent transparent rgba(201,168,76,0.05) transparent; transform: translate3d(62px, 66px, 0px) rotateX(153.43deg) rotateY(0deg); outline: 1px solid var(--scholarly-gold); }
.face-11 { border-width: 0 38px 66px 38px; border-color: transparent transparent rgba(201,168,76,0.05) transparent; transform: translate3d(81px, 86px, -59px) rotateX(153.43deg) rotateY(72deg); outline: 1px solid var(--scholarly-gold); }
.face-12 { border-width: 0 38px 66px 38px; border-color: transparent transparent rgba(201,168,76,0.05) transparent; transform: translate3d(43px, 86px, -95px) rotateX(153.43deg) rotateY(144deg); outline: 1px solid var(--scholarly-gold); }
.face-13 { border-width: 0 38px 66px 38px; border-color: transparent transparent rgba(201,168,76,0.05) transparent; transform: translate3d(5px, 86px, -59px) rotateX(153.43deg) rotateY(216deg); outline: 1px solid var(--scholarly-gold); }
.face-14 { border-width: 0 38px 66px 38px; border-color: transparent transparent rgba(201,168,76,0.05) transparent; transform: translate3d(24px, 66px, 0px) rotateX(153.43deg) rotateY(288deg); outline: 1px solid var(--scholarly-gold); }

/* Extra faces for visual complexity */
.face-15 { border-width: 0 38px 66px 38px; border-color: transparent transparent rgba(201,168,76,0.03) transparent; transform: translate3d(43px, 33px, -48px) rotateX(60deg) rotateY(0deg); outline: 1px solid rgba(201,168,76,0.6); }
.face-16 { border-width: 0 38px 66px 38px; border-color: transparent transparent rgba(201,168,76,0.03) transparent; transform: translate3d(43px, 33px, -48px) rotateX(60deg) rotateY(72deg); outline: 1px solid rgba(201,168,76,0.6); }
.face-17 { border-width: 0 38px 66px 38px; border-color: transparent transparent rgba(201,168,76,0.03) transparent; transform: translate3d(43px, 33px, -48px) rotateX(60deg) rotateY(144deg); outline: 1px solid rgba(201,168,76,0.6); }
.face-18 { border-width: 0 38px 66px 38px; border-color: transparent transparent rgba(201,168,76,0.03) transparent; transform: translate3d(43px, 33px, -48px) rotateX(60deg) rotateY(216deg); outline: 1px solid rgba(201,168,76,0.6); }
.face-19 { border-width: 0 38px 66px 38px; border-color: transparent transparent rgba(201,168,76,0.03) transparent; transform: translate3d(43px, 33px, -48px) rotateX(60deg) rotateY(288deg); outline: 1px solid rgba(201,168,76,0.6); }

.floor-reflection {
    width: 300px;
    height: 60px;
    margin-top: 40px;
    background: linear-gradient(to bottom, rgba(201, 168, 76, 0.06) 0%, transparent 100%);
    border-radius: 50%;
    filter: blur(20px);
}

/* ============================================================
   Chamber 7: The Colophon
   ============================================================ */
.colophon-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.colophon-grid {
    max-width: 600px;
    width: 100%;
}

.colophon-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid rgba(90, 80, 64, 0.3);
}

.colophon-row:last-child {
    border-bottom: none;
}

.colophon-key {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--tarnished-gold);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    flex-shrink: 0;
    margin-right: 24px;
}

.colophon-value {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--parchment-gold);
    letter-spacing: 0.02em;
    text-align: right;
}

/* ============================================================
   Link Styles
   ============================================================ */
a {
    color: var(--scholarly-gold);
    text-decoration: none;
    background-image: linear-gradient(var(--scholarly-gold), var(--scholarly-gold));
    background-size: 0% 1px;
    background-position: 0% 100%;
    background-repeat: no-repeat;
    transition: background-size 0.3s ease;
}

a:hover {
    background-size: 100% 1px;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    .chamber {
        padding: 24px;
    }

    .vestibule-title {
        font-size: clamp(32px, 10vw, 64px);
    }

    .section-title {
        font-size: clamp(32px, 8vw, 64px);
    }

    .sigil-grid {
        max-width: calc(100vw - 10vw);
        gap: 1px;
    }

    .hex-frame {
        width: 80px;
        height: 80px;
    }

    .sigil-svg {
        width: 52px;
        height: 52px;
    }

    .sigil-label {
        font-size: 10px;
    }

    .reading-column {
        max-width: 100%;
    }

    .reading-column p {
        font-size: 16px;
    }

    .pull-quote {
        margin: 2em -24px;
        padding: 1.5em 24px;
    }

    .pull-quote-mark {
        left: 24px;
    }

    .progress-indicator {
        right: 12px;
    }

    .progress-node {
        width: 10px;
        height: 10px;
        margin: 12px 0;
    }

    .icosahedron-container {
        width: 200px;
        height: 200px;
    }

    .icosahedron {
        width: 140px;
        height: 140px;
    }

    .colophon-row {
        flex-direction: column;
        gap: 4px;
    }

    .colophon-value {
        text-align: left;
    }
}
