/* ===========================================
   TRANSACTOLOGY.COM — Victorian Neon Reliquary
   =========================================== */

/* CSS Custom Properties */
:root {
    --bg-primary: #0a0a12;
    --bg-secondary: #1a1410;
    --bg-tertiary: #1e1812;
    --neon-rose: #ff2d6f;
    --neon-lime: #39ff14;
    --neon-violet: #b347d9;
    --text-parchment: #d4c5a9;
    --text-brass: #8a7e6b;
    --gold: #ffb700;
    --hex-size: 340px;
    --hex-clip: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-parchment);
    font-family: 'Cormorant Garamond', serif;
    font-size: 18px;
    line-height: 1.7;
    overflow-x: hidden;
}

/* ---- Floating Particles ---- */
#particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.particle {
    position: absolute;
    clip-path: var(--hex-clip);
    opacity: 0.35;
    will-change: transform;
}

/* ---- Pulse Animations ---- */
@keyframes neonPulse {
    0%, 100% { opacity: 0.85; }
    50% { opacity: 1; }
}

@keyframes borderGlow {
    0%, 100% { box-shadow: 0 0 4px var(--neon-rose), inset 0 0 4px rgba(255,45,111,0.1); }
    50% { box-shadow: 0 0 12px var(--neon-rose), inset 0 0 8px rgba(255,45,111,0.15); }
}

@keyframes compassSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes brightnessPulse {
    0%, 100% { filter: brightness(0.9); }
    50% { filter: brightness(1.1); }
}

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

@keyframes floatUp {
    0% { transform: translateY(0) scale(1); opacity: 0.35; }
    50% { opacity: 0.5; }
    100% { transform: translateY(-100vh) scale(0.5); opacity: 0; }
}

/* ---- Minimap ---- */
#minimap {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
}

.minimap-hex {
    width: 28px;
    height: 32px;
    clip-path: var(--hex-clip);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.3s, box-shadow 0.3s;
    border: none;
}

.minimap-hex span {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 8px;
    color: var(--text-brass);
    transition: color 0.3s;
}

.minimap-hex:hover,
.minimap-hex.active {
    background: var(--neon-rose);
}

.minimap-hex:hover span,
.minimap-hex.active span {
    color: var(--bg-primary);
}

/* ---- Vestibule ---- */
.vestibule {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
}

.vestibule-hex {
    width: min(90vw, 800px);
    aspect-ratio: 1 / 1.1;
    clip-path: var(--hex-clip);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(42,32,22,0.4) 0%, transparent 50%),
        repeating-conic-gradient(#1a1410 0% 25%, #1e1812 0% 50%);
    background-size: 100% 100%, 3px 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    filter: contrast(1.05) brightness(0.95);
}

.vestibule-content {
    text-align: center;
    padding: 40px;
}

.compass-rose {
    animation: compassSpin 720s linear infinite, brightnessPulse 2s ease-in-out infinite;
    margin-bottom: 30px;
}

.vestibule-title {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(2.8rem, 8vw, 6.5rem);
    letter-spacing: -0.02em;
    line-height: 1.05;
    color: var(--neon-rose);
    text-shadow: 0 0 20px var(--neon-rose), 0 0 60px rgba(255,45,111,0.3);
    animation: neonPulse 2s ease-in-out infinite;
    margin-bottom: 15px;
}

.vestibule-subtitle {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(1rem, 2.5vw, 1.6rem);
    font-style: italic;
    color: var(--text-brass);
    letter-spacing: 0.15em;
    margin-bottom: 25px;
}

.divider-svg {
    max-width: 80%;
    height: auto;
}

/* ---- Ornament SVG Path Draw ---- */
.ornament-path {
    stroke-dasharray: var(--path-length, 1000);
    stroke-dashoffset: var(--path-length, 1000);
    transition: stroke-dashoffset 1.2s ease-out;
}

.ornament-path.drawn {
    stroke-dashoffset: 0;
}

/* ---- Chapters Honeycomb Grid ---- */
.chapters-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    padding: 60px 20px;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
}

.hex-cell {
    width: var(--hex-size);
    height: calc(var(--hex-size) * 1.15);
    clip-path: var(--hex-clip);
    cursor: pointer;
    transition: transform 0.6s cubic-bezier(0.23,1,0.32,1), opacity 0.6s;
    will-change: transform, opacity;
    flex-shrink: 0;
}

.hex-cell:nth-child(even) {
    margin-top: 60px;
}

.hex-inner {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 50px 30px 30px;
    text-align: center;
    position: relative;
    animation: borderGlow 2s ease-in-out infinite;
}

/* Leather Textures */
.leather-dark {
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(42,32,22,0.4) 0%, transparent 50%),
        repeating-conic-gradient(#1a1410 0% 25%, #1e1812 0% 50%);
    background-size: 100% 100%, 3px 3px;
    background-color: var(--bg-secondary);
    filter: contrast(1.05) brightness(0.95);
    box-shadow: inset 0 0 40px rgba(0,0,0,0.6), inset 0 0 2px rgba(212,197,169,0.1);
}

.cartouche {
    position: absolute;
    top: 20px;
}

.chapter-num {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    font-weight: 300;
    color: var(--text-brass);
    letter-spacing: 0.2em;
    margin-bottom: 8px;
    position: absolute;
    top: 35px;
}

.chapter-icon {
    margin-bottom: 10px;
    opacity: 0.8;
}

.chapter-title {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    color: var(--neon-lime);
    text-shadow: 0 0 15px var(--neon-lime), 0 0 40px rgba(57,255,20,0.2);
    letter-spacing: -0.02em;
    line-height: 1.1;
    margin-bottom: 12px;
    animation: neonPulse 2s ease-in-out infinite;
}

.chapter-text {
    font-family: 'Cormorant Garamond', serif;
    font-size: 0.95rem;
    line-height: 1.65;
    color: var(--text-parchment);
    max-width: 260px;
}

/* Hex cell hover */
.hex-cell:hover {
    transform: scale(1.05);
    z-index: 10;
}

/* Expanded state */
.hex-cell.expanded {
    position: fixed;
    top: 5%;
    left: 5%;
    width: 90vw;
    height: 90vh;
    z-index: 50;
    clip-path: var(--hex-clip);
    transition: all 0.8s cubic-bezier(0.23,1,0.32,1);
    margin-top: 0;
}

.hex-cell.expanded .hex-inner {
    justify-content: center;
    padding: 80px 60px;
}

.hex-cell.expanded .chapter-title {
    font-size: clamp(2.5rem, 5vw, 4rem);
}

.hex-cell.expanded .chapter-text {
    font-size: 1.2rem;
    max-width: 600px;
    line-height: 1.8;
}

.hex-cell.dimmed {
    opacity: 0.1;
    pointer-events: none;
}

/* ---- Ledger Section ---- */
.ledger-section {
    padding: 80px 40px;
    position: relative;
    z-index: 2;
    text-align: center;
}

.ledger-title {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(2rem, 4vw, 3.5rem);
    color: var(--gold);
    text-shadow: 0 0 20px var(--gold), 0 0 50px rgba(255,183,0,0.2);
    margin-bottom: 20px;
    animation: neonPulse 2s ease-in-out infinite;
}

.engraver-rule {
    display: block;
    margin: 0 auto 40px;
    max-width: 90%;
    height: auto;
}

.ledger-scroll {
    display: flex;
    flex-wrap: nowrap;
    gap: 30px;
    overflow-x: auto;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    padding: 20px 40px;
    -webkit-overflow-scrolling: touch;
}

.ledger-scroll::-webkit-scrollbar {
    height: 4px;
}

.ledger-scroll::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.ledger-scroll::-webkit-scrollbar-thumb {
    background: var(--gold);
    border-radius: 2px;
}

.ledger-entry {
    min-width: 300px;
    max-width: 340px;
    flex-shrink: 0;
    scroll-snap-align: center;
    padding: 30px;
    text-align: left;
    clip-path: var(--hex-clip);
    aspect-ratio: 1 / 1.15;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.gilded {
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(42,32,22,0.4) 0%, transparent 50%),
        repeating-conic-gradient(#1a1410 0% 25%, #1e1812 0% 50%);
    background-size: 100% 100%, 3px 3px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--gold);
    box-shadow: 0 0 8px rgba(255,183,0,0.15);
}

.ledger-num {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 1.4rem;
    color: var(--gold);
    display: block;
    margin-bottom: 12px;
    text-shadow: 0 0 10px var(--gold);
}

.ledger-text {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text-parchment);
    text-align: center;
    max-width: 260px;
}

/* ---- Colophon ---- */
.colophon {
    padding: 60px 20px 40px;
    text-align: center;
    position: relative;
    z-index: 2;
}

.colophon-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-brass);
    letter-spacing: 0.1em;
    margin-top: 20px;
}

.colophon-date {
    font-family: 'Playfair Display', serif;
    font-style: italic;
    font-size: 0.9rem;
    color: var(--neon-violet);
    margin-top: 8px;
    text-shadow: 0 0 10px var(--neon-violet);
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    :root {
        --hex-size: min(90vw, 340px);
    }

    .chapters-grid {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }

    .hex-cell:nth-child(even) {
        margin-top: 0;
    }

    #minimap {
        right: 8px;
    }

    .minimap-hex {
        width: 22px;
        height: 25px;
    }

    .minimap-hex span {
        font-size: 6px;
    }

    .ledger-entry {
        min-width: 260px;
    }

    .hex-cell.expanded {
        top: 2%;
        left: 2%;
        width: 96vw;
        height: 96vh;
    }
}
