/* =============================================
   underdark.xyz — Digital Grimoire Stylesheet
   Palette: #1A1612 #8B6914 #C9A84C #2C2418
            #E8C96A #3D2E0A #0A0806 #D4C4A0
   Font: Commissioner 300/400/700, Caveat 400
   ============================================= */

/* Google Fonts import handled in HTML */

/* ========================
   Custom Properties / Root
   ======================== */
:root {
    --void: #0A0806;
    --deep-bark: #1A1612;
    --dark-wood: #2C2418;
    --dark-amber: #3D2E0A;
    --dim-gold: #8B6914;
    --gold: #C9A84C;
    --pale-gold: #E8C96A;
    --parchment: #D4C4A0;

    --glass-bg: rgba(26, 22, 18, 0.55);
    --glass-border: rgba(201, 168, 76, 0.30);
    --glass-shadow: 0 8px 48px rgba(0,0,0,0.6), inset 0 1px 0 rgba(232,201,106,0.12);
    --glass-blur: blur(24px) saturate(1.15);

    --font-display: 'Commissioner', sans-serif;
    --font-handwrite: 'Caveat', cursive;
}

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

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

body {
    background-color: var(--void);
    color: var(--parchment);
    font-family: var(--font-display);
    font-weight: 400;
    min-height: 100vh;
    overflow-x: hidden;
    /* Subtle noise texture on body */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
}

/* ========================
   Organic Blob Background
   ======================== */
.blob-field {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.blob {
    position: absolute;
    will-change: clip-path;
}

.blob-1 {
    width: 55vw;
    height: 55vw;
    top: -10%;
    left: -15%;
    background: #3D2E0A;
    opacity: 0.12;
    animation: blob-drift 18s ease-in-out infinite alternate;
    clip-path: polygon(20% 15%, 75% 5%, 95% 40%, 88% 75%, 60% 95%, 15% 85%, 5% 55%);
}

.blob-2 {
    width: 45vw;
    height: 45vw;
    bottom: -5%;
    right: -10%;
    background: #3D2E0A;
    opacity: 0.10;
    animation: blob-drift 18s ease-in-out infinite alternate-reverse;
    animation-delay: 4s;
    clip-path: polygon(30% 10%, 70% 8%, 92% 35%, 85% 70%, 55% 90%, 12% 82%, 3% 48%, 10% 20%);
}

.blob-3 {
    width: 40vw;
    height: 40vw;
    top: 40%;
    left: 30%;
    background: #3D2E0A;
    opacity: 0.08;
    animation: blob-drift 18s ease-in-out infinite alternate;
    animation-delay: 9s;
    clip-path: polygon(15% 20%, 65% 8%, 90% 42%, 80% 78%, 50% 95%, 10% 88%, 2% 52%);
}

.blob-small-1 {
    width: 30vw;
    height: 30vw;
    top: 20%;
    right: 5%;
    background: #C9A84C;
    opacity: 0.05;
    animation: blob-drift 23s ease-in-out infinite alternate;
    animation-delay: 7s;
    clip-path: polygon(25% 10%, 72% 6%, 94% 38%, 86% 72%, 52% 93%, 8% 82%, 4% 44%);
}

.blob-small-2 {
    width: 25vw;
    height: 25vw;
    bottom: 20%;
    left: 10%;
    background: #C9A84C;
    opacity: 0.05;
    animation: blob-drift 23s ease-in-out infinite alternate-reverse;
    animation-delay: 14s;
    clip-path: polygon(18% 18%, 68% 5%, 90% 40%, 83% 74%, 50% 94%, 8% 85%, 2% 50%);
}

@keyframes blob-drift {
    0%   { clip-path: polygon(20% 15%, 75% 5%, 95% 40%, 88% 75%, 60% 95%, 15% 85%, 5% 55%); }
    100% { clip-path: polygon(25% 10%, 80% 8%, 92% 45%, 82% 80%, 55% 92%, 10% 80%, 8% 50%); }
}

/* ========================
   Glass Panel Foundation
   ======================== */
.glass-panel {
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 2px;
    position: relative;
    overflow: hidden;
    animation: border-shimmer var(--shimmer-duration, 8s) ease-in-out infinite;
}

@keyframes border-shimmer {
    0%   { border-color: rgba(139,105,20,0.3); box-shadow: 0 8px 48px rgba(0,0,0,0.6), inset 0 1px 0 rgba(232,201,106,0.12), 0 0 0 rgba(201,168,76,0); }
    50%  { border-color: rgba(232,201,106,0.6); box-shadow: 0 8px 48px rgba(0,0,0,0.6), inset 0 1px 0 rgba(232,201,106,0.12), 0 0 18px rgba(201,168,76,0.15); }
    100% { border-color: rgba(139,105,20,0.3); box-shadow: 0 8px 48px rgba(0,0,0,0.6), inset 0 1px 0 rgba(232,201,106,0.12), 0 0 0 rgba(201,168,76,0); }
}

/* Ink bleed / paper grain texture overlay */
.ink-texture {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='t'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0.79 0 0 0 0 0.66 0 0 0 0 0.3 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23t)' opacity='0.04'/%3E%3C/svg%3E");
    background-size: 200px 200px;
    background-repeat: repeat;
    mix-blend-mode: overlay;
}

/* ========================
   Folios Container
   ======================== */
#folios-container {
    position: relative;
    min-height: 600vh;
    z-index: 1;
    padding-bottom: 80px; /* space for fixed nav */
}

/* ========================
   Individual Folio Sections
   ======================== */
.folio {
    position: relative;
    width: 100%;
}

/* ========================
   Folio I: The Cover
   ======================== */
#folio-i {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
}

.cover-panel {
    width: 60vw;
    min-height: 70vh;
    max-width: 860px;
    min-width: 320px;
    transform: rotate(var(--tilt, -2deg));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 80px;
    /* Override default glass with slightly more transparent for cover */
    background: rgba(201,168,76,0.06);
    border: 1px solid rgba(232,201,106,0.35);
    transition: transform 600ms cubic-bezier(0.23,1,0.32,1);
}

.cover-panel:hover {
    transform: rotate(0deg);
}

.cover-content {
    text-align: center;
    position: relative;
    z-index: 2;
}

.pre-title {
    font-family: var(--font-handwrite);
    font-size: 16px;
    color: var(--gold);
    opacity: 0.8;
    letter-spacing: 0.08em;
    margin-bottom: 16px;
    transform: rotate(-1.5deg);
    display: inline-block;
}

.site-title {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(56px, 8vw, 96px);
    letter-spacing: -0.02em;
    color: var(--pale-gold);
    line-height: 1.0;
    margin-bottom: 24px;
}

.title-dot {
    color: var(--gold);
    opacity: 0.7;
}

.subtitle {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 14px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--parchment);
    opacity: 0.6;
    margin-bottom: 32px;
}

.cover-ornament {
    width: 200px;
    margin: 0 auto;
}

.ornament-line {
    width: 100%;
    display: block;
}

/* Compass rose on cover — floating to the side */
.compass-rose-wrap {
    position: absolute;
    bottom: 15%;
    right: 8%;
    width: 90px;
    opacity: 0.55;
    pointer-events: none;
    transform: rotate(3deg);
}

#compass-rose {
    width: 100%;
    height: auto;
}

/* ========================
   Marginalia
   ======================== */
.marginalia {
    position: absolute;
    font-family: var(--font-handwrite);
    font-size: 13px;
    color: var(--gold);
    opacity: 0.75;
    transform: rotate(var(--tilt, -2deg));
    pointer-events: none;
    white-space: nowrap;
    z-index: 10;
}

@media (max-width: 768px) {
    .marginalia { display: none; }
}

.annotation-inline {
    display: block;
    font-family: var(--font-handwrite);
    font-size: 14px;
    color: var(--gold);
    opacity: 0.7;
    transform: rotate(var(--tilt, -2deg));
    margin-top: 24px;
}

/* ========================
   Folio II: The Manifesto
   ======================== */
#folio-ii {
    min-height: 100vh;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
}

.manifesto-panel-back {
    position: absolute;
    width: 65vw;
    min-height: 420px;
    max-width: 820px;
    min-width: 280px;
    transform: rotate(1.5deg);
    left: 50%;
    top: 50%;
    translate: -52% -45%;
    padding: 40px;
    z-index: 2;
    transition: transform 600ms cubic-bezier(0.23,1,0.32,1);
}

.manifesto-panel-back:hover {
    transform: rotate(0deg);
}

.border-frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
}

.manifesto-panel-front {
    position: relative;
    width: 58vw;
    max-width: 700px;
    min-width: 260px;
    transform: rotate(var(--tilt, -3deg));
    padding: 48px 52px;
    z-index: 4;
    margin-top: 20px;
    transition: transform 600ms cubic-bezier(0.23,1,0.32,1);
}

.manifesto-panel-front:hover {
    transform: rotate(0deg);
}

.folio-header {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(36px, 5vw, 64px);
    letter-spacing: -0.02em;
    color: var(--pale-gold);
    margin-bottom: 24px;
    position: relative;
    z-index: 2;
}

.folio-header-outside {
    position: absolute;
    top: -60px;
    left: 0;
    z-index: 5;
}

.manifesto-ornament {
    margin-bottom: 28px;
    width: 60px;
    position: relative;
    z-index: 2;
}

.manifesto-content {
    position: relative;
    z-index: 2;
}

.body-text {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 15px;
    line-height: 1.8;
    letter-spacing: 0.01em;
    color: var(--parchment);
    margin-bottom: 20px;
}

/* Bracket ornaments */
.bracket-ornament {
    position: absolute;
    width: 40px;
    height: 40px;
    pointer-events: none;
    z-index: 5;
}

.bracket-tl {
    top: 12px;
    left: 12px;
}

.bracket-br {
    bottom: 12px;
    right: 12px;
}

/* ========================
   Folio III: The Works
   ======================== */
#folio-iii {
    min-height: 120vh;
    position: relative;
    padding: 100px 20px 80px;
}

.works-scatter {
    position: relative;
    width: 100%;
    min-height: 90vh;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 28px;
    max-width: 1100px;
    margin: 0 auto;
}

.work-card {
    aspect-ratio: 3/4;
    transform: rotate(var(--tilt, 0deg));
    padding: 28px 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 400ms cubic-bezier(0.23,1,0.32,1), box-shadow 400ms ease;
    cursor: default;
}

.work-card:hover {
    transform: rotate(0deg) scale(1.04);
    box-shadow: 0 16px 60px rgba(0,0,0,0.75), inset 0 1px 0 rgba(232,201,106,0.2);
    z-index: 10;
}

.work-card-content {
    position: relative;
    z-index: 2;
}

.work-medium {
    font-family: var(--font-handwrite);
    font-size: 13px;
    color: var(--gold);
    opacity: 0.75;
    letter-spacing: 0.04em;
    margin-bottom: 12px;
}

.work-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -0.01em;
    color: var(--pale-gold);
    margin-bottom: 14px;
    line-height: 1.3;
}

.work-desc {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 13px;
    line-height: 1.75;
    color: var(--parchment);
    opacity: 0.85;
}

.work-year {
    font-family: var(--font-handwrite);
    font-size: 14px;
    color: var(--gold);
    opacity: 0.65;
    margin-top: 16px;
    display: block;
}

.wax-seal {
    position: absolute;
    bottom: 14px;
    right: 14px;
    width: 48px;
    height: 48px;
    opacity: 0.6;
    z-index: 3;
}

@media (max-width: 900px) {
    .works-scatter {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 600px) {
    .works-scatter {
        grid-template-columns: 1fr;
    }
    .work-card {
        aspect-ratio: unset;
        min-height: 220px;
    }
}

/* ========================
   Folio IV: The Chronicle
   ======================== */
#folio-iv {
    min-height: 60vh;
    position: relative;
    padding: 80px 0 60px;
    overflow: hidden;
}

.chronicle-scroll-wrap {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding: 40px 0 20px;
    cursor: grab;
}

.chronicle-scroll-wrap:active {
    cursor: grabbing;
}

.chronicle-track {
    position: relative;
    width: max-content;
    min-width: 100vw;
    padding: 0 60px;
}

.timeline-line {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 80px;
    translate: 0 -50%;
    pointer-events: none;
    z-index: 0;
}

.timeline-events {
    display: flex;
    gap: 32px;
    align-items: center;
    padding: 40px 0;
    position: relative;
    z-index: 1;
}

.timeline-event {
    scroll-snap-align: center;
    flex-shrink: 0;
}

.event-medallion {
    width: 200px;
    min-height: 180px;
    padding: 24px 20px;
    clip-path: polygon(8% 0%, 92% 0%, 100% 8%, 100% 92%, 92% 100%, 8% 100%, 0% 92%, 0% 8%);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.event-year {
    font-family: var(--font-handwrite);
    font-size: 22px;
    color: var(--gold);
    display: block;
    line-height: 1;
}

.event-text {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 13px;
    line-height: 1.7;
    color: var(--parchment);
    opacity: 0.85;
}

/* ========================
   Folio V: The Gate
   ======================== */
#folio-v {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    position: relative;
}

.gate-panel {
    width: 80vw;
    min-height: 85vh;
    max-width: 1000px;
    padding: 60px 80px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 60px;
    align-items: center;
    transform: rotate(0.5deg);
    transition: transform 600ms cubic-bezier(0.23,1,0.32,1);
}

.gate-panel:hover {
    transform: rotate(0deg);
}

.gate-compass {
    display: flex;
    align-items: center;
    justify-content: center;
}

#gate-compass-rose {
    width: 160px;
    height: 160px;
    opacity: 0.65;
    animation: compass-slow-rotate 60s linear infinite;
}

@keyframes compass-slow-rotate {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.gate-content {
    position: relative;
    z-index: 2;
}

.gate-title {
    margin-bottom: 28px;
}

.gate-text {
    margin-bottom: 20px;
}

.gate-annotation {
    font-family: var(--font-handwrite);
    font-size: 16px;
    color: var(--gold);
    opacity: 0.75;
    transform: rotate(var(--tilt, -2deg));
    display: inline-block;
    margin: 20px 0 24px;
}

.gate-address {
    margin-top: 8px;
    padding-top: 20px;
    border-top: 1px solid rgba(201, 168, 76, 0.2);
}

.gate-address .caveat {
    font-family: var(--font-handwrite);
    font-size: 16px;
    color: var(--parchment);
    opacity: 0.7;
    letter-spacing: 0.02em;
}

@media (max-width: 768px) {
    .gate-panel {
        grid-template-columns: 1fr;
        width: 90vw;
        padding: 40px 28px;
        min-height: auto;
    }
    .gate-compass {
        display: none;
    }
}

/* ========================
   Typography Utilities
   ======================== */
.caveat {
    font-family: var(--font-handwrite);
}

/* ========================
   Fixed Bottom Navigation
   ======================== */
#folio-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    padding: 14px 20px;
    background: rgba(10, 8, 6, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(201, 168, 76, 0.15);
    z-index: 100;
}

.nav-folio {
    font-family: var(--font-handwrite);
    font-size: 18px;
    color: var(--gold);
    opacity: 0.55;
    text-decoration: none;
    transition: opacity 300ms ease, color 300ms ease;
    position: relative;
}

.nav-folio::after {
    content: attr(data-label);
    position: absolute;
    bottom: 100%;
    left: 50%;
    translate: -50% 0;
    font-family: var(--font-handwrite);
    font-size: 11px;
    color: var(--parchment);
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
    transition: opacity 250ms ease;
    padding-bottom: 4px;
}

.nav-folio:hover {
    opacity: 1;
    color: var(--pale-gold);
}

.nav-folio:hover::after {
    opacity: 0.65;
}

.nav-folio.active {
    opacity: 1;
    color: var(--pale-gold);
}

/* ========================
   SVG Draw-On-Scroll System
   ======================== */
.draw-on-scroll {
    animation-play-state: paused;
}

.draw-on-scroll.is-drawing {
    animation-play-state: running;
}

/* Individual animated path elements within SVGs */
.draw-on-scroll path,
.draw-on-scroll circle,
.draw-on-scroll line {
    animation: draw-in 1.8s ease-out forwards paused;
}

.draw-on-scroll.is-drawing path,
.draw-on-scroll.is-drawing circle,
.draw-on-scroll.is-drawing line {
    animation-play-state: running;
}

@keyframes draw-in {
    from { stroke-dashoffset: attr(stroke-dasharray); opacity: 0.2; }
    to   { stroke-dashoffset: 0; opacity: 1; }
}

/* Stagger path animations within an SVG */
.draw-on-scroll path:nth-child(1)  { animation-delay: 0.0s; }
.draw-on-scroll path:nth-child(2)  { animation-delay: 0.15s; }
.draw-on-scroll path:nth-child(3)  { animation-delay: 0.30s; }
.draw-on-scroll path:nth-child(4)  { animation-delay: 0.45s; }
.draw-on-scroll path:nth-child(5)  { animation-delay: 0.60s; }
.draw-on-scroll path:nth-child(6)  { animation-delay: 0.75s; }
.draw-on-scroll path:nth-child(7)  { animation-delay: 0.90s; }
.draw-on-scroll path:nth-child(8)  { animation-delay: 1.05s; }
.draw-on-scroll circle:nth-child(1)  { animation-delay: 0.0s; }
.draw-on-scroll circle:nth-child(2)  { animation-delay: 0.20s; }
.draw-on-scroll circle:nth-child(3)  { animation-delay: 0.40s; }
.draw-on-scroll circle:nth-child(4)  { animation-delay: 0.60s; }
.draw-on-scroll line:nth-child(1)  { animation-delay: 0.10s; }
.draw-on-scroll line:nth-child(2)  { animation-delay: 0.25s; }
.draw-on-scroll line:nth-child(3)  { animation-delay: 0.40s; }
.draw-on-scroll line:nth-child(4)  { animation-delay: 0.55s; }
.draw-on-scroll line:nth-child(5)  { animation-delay: 0.70s; }
.draw-on-scroll line:nth-child(6)  { animation-delay: 0.85s; }
.draw-on-scroll line:nth-child(7)  { animation-delay: 1.00s; }
.draw-on-scroll line:nth-child(8)  { animation-delay: 1.15s; }

/* ========================
   Folio tilt & hover system
   ======================== */
.folio .glass-panel {
    transition: transform 600ms cubic-bezier(0.23,1,0.32,1);
}

/* ========================
   Scrollbar styling
   ======================== */
.chronicle-scroll-wrap::-webkit-scrollbar {
    height: 2px;
}
.chronicle-scroll-wrap::-webkit-scrollbar-track {
    background: rgba(201, 168, 76, 0.05);
}
.chronicle-scroll-wrap::-webkit-scrollbar-thumb {
    background: rgba(201, 168, 76, 0.3);
    border-radius: 1px;
}

/* ========================
   Responsive
   ======================== */
@media (max-width: 768px) {
    .cover-panel {
        width: 90vw;
        padding: 40px 28px;
        min-height: 60vh;
    }

    .manifesto-panel-back,
    .manifesto-panel-front {
        position: relative;
        width: 90vw;
        left: auto;
        top: auto;
        translate: none;
        margin: 0 auto;
    }

    #folio-ii {
        flex-direction: column;
        gap: 24px;
    }

    .folio-header-outside {
        position: static;
        margin-bottom: 20px;
    }

    #folio-iv {
        padding: 60px 0 40px;
    }

    #folio-nav {
        gap: 24px;
    }
}

@media (max-width: 480px) {
    .site-title {
        font-size: 48px;
    }
    .folio-header {
        font-size: 32px;
    }
    .manifesto-panel-front {
        padding: 32px 24px;
    }
}
