/* ============================================
   desca.dev - Dark Academia as Punk Manifesto
   ============================================ */

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background-color: #0d0c0f;
    color: #e8dcc8;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: clamp(1rem, 1.4vw, 1.2rem);
    line-height: 1.85;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ---- Candle Flicker Ambient ---- */
.candle-flicker {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    background: radial-gradient(ellipse at 50% 20%, rgba(122, 104, 64, 0.03) 0%, transparent 60%);
    animation: candleFlicker 4s ease-in-out infinite alternate;
}

@keyframes candleFlicker {
    0% { opacity: 0.6; transform: scale(1); }
    25% { opacity: 1; transform: scale(1.02); }
    50% { opacity: 0.7; transform: scale(0.98); }
    75% { opacity: 0.9; transform: scale(1.01); }
    100% { opacity: 0.5; transform: scale(1); }
}

/* ---- Navigation ---- */
.nav-symbol {
    position: fixed;
    top: 2rem;
    left: 2rem;
    z-index: 1000;
    cursor: pointer;
}

.mercury-glyph {
    font-size: 1.8rem;
    color: #7a6840;
    display: block;
    transition: color 0.3s ease, transform 0.3s ease;
}

.nav-symbol:hover .mercury-glyph {
    color: #e8dcc8;
    transform: rotate(15deg);
}

.nav-overlay {
    position: absolute;
    top: 3rem;
    left: 0;
    background: #24202b;
    border: 1px solid #7a6840;
    padding: 2rem 2.5rem;
    min-width: 280px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.4s ease, transform 0.4s ease, visibility 0.4s;
}

.nav-symbol:hover .nav-overlay,
.nav-overlay.is-active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.nav-title {
    font-family: 'Space Grotesk', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.75rem;
    color: #6a5c50;
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.nav-index ul {
    list-style: none;
}

.nav-index li {
    margin-bottom: 0.8rem;
}

.nav-index a {
    display: flex;
    align-items: baseline;
    text-decoration: none;
    color: #e8dcc8;
    font-family: 'Cormorant Garamond', serif;
    font-size: 1rem;
    transition: color 0.3s;
}

.nav-index a:hover {
    color: #c0392b;
}

.nav-label {
    white-space: nowrap;
}

.nav-dots {
    flex: 1;
    border-bottom: 1px dotted #6a5c50;
    margin: 0 0.5rem;
    position: relative;
    top: -4px;
}

.nav-page {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    color: #8b6f4e;
}

/* ---- Hero Section ---- */
.hero-section {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    z-index: 1;
}

.hero-border {
    position: absolute;
    inset: 2rem;
    border: 2px double #7a6840;
    pointer-events: none;
    z-index: 2;
}

.hero-border-corner {
    position: absolute;
    width: 24px;
    height: 24px;
    border-color: #7a6840;
}

.hero-border-corner--tl {
    top: -2px;
    left: -2px;
    border-top: 3px solid #7a6840;
    border-left: 3px solid #7a6840;
}

.hero-border-corner--tr {
    top: -2px;
    right: -2px;
    border-top: 3px solid #7a6840;
    border-right: 3px solid #7a6840;
}

.hero-border-corner--bl {
    bottom: -2px;
    left: -2px;
    border-bottom: 3px solid #7a6840;
    border-left: 3px solid #7a6840;
}

.hero-border-corner--br {
    bottom: -2px;
    right: -2px;
    border-bottom: 3px solid #7a6840;
    border-right: 3px solid #7a6840;
}

.hero-content {
    text-align: center;
    z-index: 3;
    position: relative;
}

.hero-title {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(3rem, 8vw, 7rem);
    color: #e8dcc8;
    letter-spacing: 0.02em;
    margin-bottom: 1.5rem;
    display: inline-block;
}

.hero-title .letter {
    display: inline-block;
    opacity: 0;
    animation: letterAssemble 1.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.hero-title .letter[data-index='0'] { animation-delay: 0ms; }
.hero-title .letter[data-index='1'] { animation-delay: 80ms; }
.hero-title .letter[data-index='2'] { animation-delay: 160ms; }
.hero-title .letter[data-index='3'] { animation-delay: 240ms; }
.hero-title .letter[data-index='4'] { animation-delay: 320ms; }
.hero-title .letter[data-index='5'] { animation-delay: 400ms; }
.hero-title .letter[data-index='6'] { animation-delay: 480ms; }
.hero-title .letter[data-index='7'] { animation-delay: 560ms; }
.hero-title .letter[data-index='8'] { animation-delay: 640ms; }

@keyframes letterAssemble {
    0% {
        opacity: 0;
        transform: translate(var(--scatter-x, 0), var(--scatter-y, 0)) rotate(var(--scatter-r, 0deg));
    }
    100% {
        opacity: 1;
        transform: translate(0, 0) rotate(0deg);
    }
}

.hero-title .letter.settled {
    animation: letterSettle 3s ease-in-out infinite alternate;
}

@keyframes letterSettle {
    0% { transform: rotate(0deg) translateY(0); }
    33% { transform: rotate(-0.5deg) translateY(-1px); }
    66% { transform: rotate(0.3deg) translateY(0.5px); }
    100% { transform: rotate(-0.2deg) translateY(-0.5px); }
}

.hero-subtitle {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(1rem, 2vw, 1.4rem);
    font-style: italic;
    color: #b8a890;
    opacity: 0;
    animation: subtitleFadeIn 1.5s ease forwards;
    animation-delay: 1.2s;
    letter-spacing: 0.05em;
}

@keyframes subtitleFadeIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---- 3D Book ---- */
.hero-book {
    position: absolute;
    right: 12%;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    perspective: 800px;
}

.book-3d {
    width: 140px;
    height: 190px;
    position: relative;
    transform-style: preserve-3d;
    animation: bookRotate 30s linear infinite;
}

@keyframes bookRotate {
    from { transform: rotateY(0deg) rotateX(-5deg); }
    to { transform: rotateY(360deg) rotateX(-5deg); }
}

.book-face {
    position: absolute;
    backface-visibility: visible;
}

.book-front {
    width: 140px;
    height: 190px;
    background: #24202b;
    border: 2px solid #7a6840;
    transform: translateZ(15px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.book-spine-edge {
    position: absolute;
    left: 0;
    top: 0;
    width: 4px;
    height: 100%;
    background: #7a6840;
}

.book-cover-detail {
    text-align: center;
    color: #7a6840;
}

.book-ornament-top,
.book-ornament-bottom {
    font-size: 1.2rem;
    line-height: 1;
}

.book-cover-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.6rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    margin: 0.5rem 0;
    color: #e8dcc8;
}

.book-spine {
    width: 30px;
    height: 190px;
    background: #1a1720;
    border: 1px solid #7a6840;
    transform: rotateY(-90deg) translateZ(0px) translateX(-15px);
}

.book-top {
    width: 140px;
    height: 30px;
    background: #e8dcc8;
    transform: rotateX(90deg) translateZ(0px) translateY(-15px);
    opacity: 0.3;
}

.book-right {
    width: 140px;
    height: 190px;
    background: #1a1720;
    transform: translateZ(-15px);
    border: 1px solid #6a5c50;
}

/* ---- Page Curl ---- */
.page-curl {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 80px;
    background: linear-gradient(to top, #1a1720 0%, transparent 100%);
    z-index: 4;
}

.page-curl::before {
    content: '';
    position: absolute;
    bottom: 0;
    right: 5%;
    width: 120px;
    height: 60px;
    background: linear-gradient(135deg, transparent 40%, #24202b 40%, #24202b 50%, #1a1720 50%);
    transform: perspective(200px) rotateX(-5deg);
    border-top: 1px solid #7a6840;
    opacity: 0.5;
}

/* ---- Section Grid ---- */
.section-grid {
    display: grid;
    grid-template-columns: minmax(60px, 1fr) minmax(0, 8fr) minmax(60px, 1fr);
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.margin-left,
.margin-right {
    position: relative;
    padding: 2rem 0.5rem;
}

.content-column {
    padding: 4rem 2rem;
}

.content-column--wide {
    max-width: 75ch;
    justify-self: center;
}

.content-column--narrow {
    max-width: 45ch;
    justify-self: center;
}

/* ---- Alchemy Glyphs ---- */
.alchemy-glyph {
    width: 40px;
    height: 55px;
    display: block;
    margin: 2rem auto;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.alchemy-glyph.is-visible {
    opacity: 1;
}

.svg-draw {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 2s ease;
}

.is-visible .svg-draw {
    stroke-dashoffset: 0;
}

/* ---- Ink Splatters ---- */
.ink-splatter {
    width: 30px;
    height: 30px;
    border-radius: 50% 40% 60% 35%;
    background: #1a1720;
    position: absolute;
}

.ink-splatter--1 {
    top: 20%;
    right: 0;
    width: 25px;
    height: 20px;
}

.ink-splatter--2 {
    top: 55%;
    right: 10px;
    width: 18px;
    height: 22px;
    border-radius: 35% 55% 45% 50%;
}

.ink-splatter--3 {
    top: 30%;
    right: 5px;
    width: 22px;
    height: 18px;
    border-radius: 45% 55% 40% 50%;
}

/* ---- Thesis Section ---- */
.thesis-section {
    position: relative;
    min-height: 100vh;
    z-index: 1;
    padding: 4rem 0;
}

.thesis-text {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(1.2rem, 1.8vw, 1.5rem);
    line-height: 2;
    color: #e8dcc8;
    text-indent: 2em;
    hyphens: auto;
}

.thesis-text .word {
    display: inline-block;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.5s ease, transform 0.5s ease;
    margin-right: 0.25em;
}

.thesis-text .word.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* ---- Fleuron Divider ---- */
.fleuron-divider {
    text-align: center;
    font-size: 1.8rem;
    color: #7a6840;
    padding: 3rem 0;
    opacity: 0.7;
}

/* ---- Evidence Section ---- */
.evidence-section {
    position: relative;
    min-height: 150vh;
    z-index: 1;
    padding: 4rem 0;
}

.evidence-entry {
    margin-bottom: 5rem;
    position: relative;
    padding: 2.5rem;
    background: rgba(36, 32, 43, 0.3);
    border-left: 2px solid #7a6840;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

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

.entry-date {
    font-family: 'Space Grotesk', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.75rem;
    color: #6a5c50;
    display: block;
    margin-bottom: 0.8rem;
    font-weight: 500;
}

.entry-title {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(1.5rem, 3vw, 2.2rem);
    color: #e8dcc8;
    margin-bottom: 1rem;
    line-height: 1.3;
}

.entry-body {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(1rem, 1.4vw, 1.2rem);
    line-height: 1.85;
    color: #b8a890;
    margin-bottom: 1.5rem;
}

.entry-body code {
    font-family: 'Space Grotesk', sans-serif;
    background: rgba(26, 23, 32, 0.6);
    padding: 0.1em 0.4em;
    font-size: 0.9em;
    color: #e8dcc8;
}

.entry-annotation {
    font-family: 'Caveat', cursive;
    font-size: clamp(0.8rem, 1.1vw, 0.95rem);
    color: #8b6f4e;
    display: block;
    transform: rotate(-1.5deg);
    margin-top: 1rem;
    padding-left: 1rem;
    border-left: 1px solid rgba(139, 111, 78, 0.3);
    line-height: 1.5;
}

/* ---- 3D Objects ---- */
.object-3d {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 3rem 0;
    perspective: 600px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.object-3d.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Astrolabe */
.astrolabe {
    width: 120px;
    height: 120px;
    position: relative;
    animation: slowRotateAstrolabe 30s linear infinite;
}

@keyframes slowRotateAstrolabe {
    from { transform: rotateZ(0deg); }
    to { transform: rotateZ(360deg); }
}

.astrolabe-ring {
    position: absolute;
    border: 1.5px solid #7a6840;
    border-radius: 50%;
}

.astrolabe-ring--outer {
    width: 120px;
    height: 120px;
    top: 0;
    left: 0;
}

.astrolabe-ring--middle {
    width: 80px;
    height: 80px;
    top: 20px;
    left: 20px;
    border-style: dashed;
}

.astrolabe-ring--inner {
    width: 40px;
    height: 40px;
    top: 40px;
    left: 40px;
}

.astrolabe-pointer {
    position: absolute;
    width: 2px;
    height: 60px;
    background: #7a6840;
    top: 0;
    left: 59px;
    transform-origin: bottom center;
    animation: pointerSwing 8s ease-in-out infinite alternate;
}

@keyframes pointerSwing {
    from { transform: rotate(-30deg); }
    to { transform: rotate(30deg); }
}

/* Skull (Memento Mori) */
.skull {
    width: 80px;
    height: 90px;
    position: relative;
    animation: skullFloat 6s ease-in-out infinite alternate;
}

@keyframes skullFloat {
    from { transform: translateY(0) rotateY(0deg); }
    to { transform: translateY(-8px) rotateY(10deg); }
}

.skull-cranium {
    width: 70px;
    height: 60px;
    border: 2px solid #7a6840;
    border-radius: 50% 50% 40% 40%;
    position: absolute;
    top: 0;
    left: 5px;
}

.skull-jaw {
    width: 50px;
    height: 25px;
    border: 2px solid #7a6840;
    border-top: none;
    border-radius: 0 0 40% 40%;
    position: absolute;
    top: 50px;
    left: 15px;
}

.skull-eye {
    width: 16px;
    height: 14px;
    border: 1.5px solid #7a6840;
    border-radius: 50%;
    position: absolute;
    top: 25px;
}

.skull-eye--left { left: 15px; }
.skull-eye--right { left: 48px; }

.skull-nose {
    width: 8px;
    height: 10px;
    border-left: 1.5px solid #7a6840;
    border-right: 1.5px solid #7a6840;
    border-bottom: 1.5px solid #7a6840;
    border-radius: 0 0 30% 30%;
    position: absolute;
    top: 38px;
    left: 36px;
}

/* ---- Manifesto Section ---- */
.manifesto-section {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    z-index: 1;
    padding: 4rem 0;
}

.manifesto-text {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(2rem, 5vw, 4rem);
    color: #e8dcc8;
    line-height: 1.3;
    text-align: center;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 1s ease, transform 1s ease;
}

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

.m-word {
    display: inline-block;
    margin: 0 0.15em;
}

.manifesto-text.is-visible .m-word {
    animation: manifestoShake 4s ease-in-out infinite alternate;
}

@keyframes manifestoShake {
    0% { transform: rotate(0deg) translateY(0); }
    20% { transform: rotate(-0.8deg) translateY(-1px); }
    40% { transform: rotate(0.5deg) translateY(1px); }
    60% { transform: rotate(-0.3deg) translateY(-0.5px); }
    80% { transform: rotate(0.6deg) translateY(0.5px); }
    100% { transform: rotate(-0.4deg) translateY(-1px); }
}

.accent-word {
    color: #9e2a2b;
    text-shadow: 0 0 20px rgba(158, 42, 43, 0.4), 0 0 40px rgba(158, 42, 43, 0.2);
    animation: fireGlow 2s ease-in-out infinite alternate !important;
}

@keyframes fireGlow {
    0% {
        text-shadow: 0 0 20px rgba(158, 42, 43, 0.4), 0 0 40px rgba(158, 42, 43, 0.2);
    }
    50% {
        text-shadow: 0 0 30px rgba(192, 57, 43, 0.6), 0 0 60px rgba(158, 42, 43, 0.3), 0 0 80px rgba(158, 42, 43, 0.1);
    }
    100% {
        text-shadow: 0 0 15px rgba(158, 42, 43, 0.3), 0 0 35px rgba(158, 42, 43, 0.15);
    }
}

/* ---- Colophon Section ---- */
.colophon-section {
    position: relative;
    min-height: 50vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    padding: 4rem 0;
    transition: background-color 1s ease;
}

.colophon-section.fade-dark {
    background-color: #000000;
}

.colophon-content {
    text-align: center;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1s ease, transform 1s ease;
}

.colophon-content.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.colophon-symbol {
    font-size: 2.5rem;
    color: #7a6840;
    margin-bottom: 2rem;
    opacity: 0.6;
}

.colophon-text {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: 0.95rem;
    line-height: 2.2;
    color: #8b6f4e;
}

.colophon-text em {
    font-size: 1.2rem;
    color: #e8dcc8;
    font-style: italic;
}

.colophon-year {
    font-family: 'Space Grotesk', sans-serif;
    letter-spacing: 0.2em;
    font-size: 0.75rem;
    color: #6a5c50;
}

.colophon-note {
    font-size: 0.85rem;
    color: #6a5c50;
}

.colophon-ornament {
    font-size: 1.5rem;
    color: #7a6840;
    margin-top: 2rem;
    opacity: 0.4;
}

/* ---- Reveal Animation Base ---- */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .hero-book {
        display: none;
    }

    .section-grid {
        grid-template-columns: 40px 1fr 40px;
    }

    .margin-left,
    .margin-right {
        padding: 1rem 0.25rem;
    }

    .alchemy-glyph {
        width: 28px;
        height: 38px;
    }

    .content-column {
        padding: 2rem 1rem;
    }

    .content-column--narrow {
        max-width: 100%;
    }

    .hero-border {
        inset: 1rem;
    }

    .nav-symbol {
        top: 1rem;
        left: 1rem;
    }

    .evidence-entry {
        padding: 1.5rem;
    }

    .entry-annotation {
        position: relative;
        margin-top: 1rem;
    }
}

@media (max-width: 480px) {
    .section-grid {
        grid-template-columns: 1fr;
    }

    .margin-left,
    .margin-right {
        display: none;
    }

    .hero-title {
        font-size: clamp(2.5rem, 12vw, 4rem);
    }
}
