/* CSS Custom Properties */
/* Design token trace: Inter (300 provides clean Inter" (Google Interactions:** Interaction:* Interior Pattern IntersectionObserver` threshold animates `cubic-bezier(0.25 Source Code Pro (400 Pro" */
:root {
    --parchment: #f5efe0;
    --deep-ink: #2c2416;
    --umber: #8b7355;
    --rust: #a0522d;
    --lunar-silver: #c8c0b4;
    --walnut: #1a1208;
    --candlelight: #e8c869;
    --foxing: #d4c9b5;
    --aged-parchment: #ebe3d1;
    --paper-age: 0;
}

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

/* Paper grain texture via inline SVG data URI */
body {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    color: var(--deep-ink);
    background-color: color-mix(in srgb, var(--parchment) calc(100% - var(--paper-age, 0%)), var(--aged-parchment) var(--paper-age, 0%));
    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='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
    line-height: 1.75;
    letter-spacing: 0.01em;
    font-size: clamp(0.95rem, 1.2vw, 1.1rem);
    overflow-x: hidden;
    position: relative;
}

/* Ink blot accents */
.ink-blot {
    position: fixed;
    border-radius: 50%;
    background: radial-gradient(circle, var(--deep-ink) 0%, transparent 70%);
    opacity: 0.08;
    pointer-events: none;
    z-index: 0;
}
.ink-blot-1 { width: 35px; height: 30px; top: 15%; left: 3%; }
.ink-blot-2 { width: 25px; height: 25px; top: 55%; right: 5%; }
.ink-blot-3 { width: 40px; height: 35px; top: 80%; left: 8%; }

/* ===================== THE FOLIO (HERO) ===================== */
.folio {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 40px 20px;
    overflow: hidden;
}

/* Celestial diagram */
.celestial {
    position: absolute;
    width: 400px;
    height: 400px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.15;
    pointer-events: none;
}
.celestial-orbit {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 1px solid var(--lunar-silver);
    border-radius: 50%;
}
.celestial-point {
    position: absolute;
    width: 20px;
    height: 20px;
    border: 1px solid var(--lunar-silver);
    border-radius: 50%;
    background: transparent;
}
.celestial-n { top: -10px; left: 50%; transform: translateX(-50%); }
.celestial-e { top: 50%; right: -10px; transform: translateY(-50%); }
.celestial-s { bottom: -10px; left: 50%; transform: translateX(-50%); }
.celestial-w { top: 50%; left: -10px; transform: translateY(-50%); }
.celestial-line {
    position: absolute;
    background: var(--lunar-silver);
}
.celestial-line-v {
    width: 1px;
    height: 100%;
    left: 50%;
    top: 0;
}
.celestial-line-h {
    height: 1px;
    width: 100%;
    top: 50%;
    left: 0;
}

.folio-title {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
    font-size: clamp(3.5rem, 9vw, 7rem);
    letter-spacing: 0.04em;
    line-height: 1.1;
    color: var(--deep-ink);
    text-shadow:
        1px 1px 0 rgba(44, 36, 22, 0.15),
        2px 2px 4px rgba(44, 36, 22, 0.08),
        -0.5px 0.5px 0 rgba(44, 36, 22, 0.05);
    position: relative;
    z-index: 1;
    text-align: center;
}

.folio-manifesto {
    font-family: 'Inter', sans-serif;
    font-weight: 300;
    font-size: clamp(1rem, 1.5vw, 1.2rem);
    line-height: 1.75;
    max-width: 55ch;
    text-align: center;
    margin-top: 2rem;
    position: relative;
    z-index: 1;
    color: var(--umber);
}

.folio-manifesto .char {
    display: inline-block;
    opacity: 0;
    transform: translateY(4px);
    animation: quill-write 40ms forwards;
}

@keyframes quill-write {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===================== ORNAMENTAL DIVIDER ===================== */
.ornament {
    width: 200px;
    height: 12px;
    margin: 60px auto;
    background-image: repeating-radial-gradient(
        circle at 6px 6px,
        var(--rust) 0px,
        var(--rust) 2.5px,
        transparent 2.5px,
        transparent 12px
    );
    background-size: 12px 12px;
    opacity: 0.6;
}

/* ===================== MARGINALIA ===================== */
.marginalia {
    position: absolute;
    font-family: 'Caveat', cursive;
    font-size: 0.78rem;
    color: var(--lunar-silver);
    opacity: 0.4;
    pointer-events: none;
    z-index: 1;
    animation: marginalia-float var(--float-dur, 10s) ease-in-out infinite;
}
.marginalia-1 {
    top: 35%;
    left: 4%;
    transform: rotate(3deg);
    --rot: 3deg;
    --float-dur: 9s;
}
.marginalia-2 {
    top: 50%;
    right: 3%;
    transform: rotate(-4deg);
    --rot: -4deg;
    --float-dur: 11s;
}
.marginalia-3 {
    top: 68%;
    left: 6%;
    transform: rotate(2.5deg);
    --rot: 2.5deg;
    --float-dur: 8s;
}
.marginalia-4 {
    top: 82%;
    right: 5%;
    transform: rotate(-5deg);
    --rot: -5deg;
    --float-dur: 12s;
}

@keyframes marginalia-float {
    0%, 100% { transform: translateY(0) rotate(var(--rot, 3deg)); }
    50% { transform: translateY(-6px) rotate(var(--rot, 3deg)); }
}

/* ===================== THE CODEX ===================== */
.codex {
    max-width: 960px;
    margin: 0 auto;
    padding: 60px 20px 120px;
    display: grid;
    grid-template-columns: 55% 40%;
    gap: 5%;
    position: relative;
}

.codex-block {
    background: var(--parchment);
    padding: 40px;
    position: relative;
    filter: drop-shadow(3px 3px 6px rgba(139, 115, 85, 0.25));
    transition: transform 0.4s ease, filter 0.4s ease;
    /* Ruled lines behind text */
    background-image: repeating-linear-gradient(
        transparent,
        transparent 1.7rem,
        var(--foxing) 1.7rem,
        var(--foxing) calc(1.7rem + 1px)
    );
    background-size: 100% 100%;
}

.page-ink {
    position: relative;
    z-index: 1;
}

/* Torn edge clip paths — unique per block */
.codex-block-1 {
    clip-path: polygon(1% 0%, 98% 0.5%, 100% 2%, 99% 98%, 97% 100%, 2% 99%, 0% 97%, 0.5% 3%);
    transform: rotate(-0.5deg);
    grid-column: 1;
}
.codex-block-2 {
    clip-path: polygon(0% 1%, 97% 0%, 100% 3%, 99.5% 97%, 98% 100%, 3% 99.5%, 0.5% 98%, 0% 2%);
    transform: rotate(0.3deg);
    margin-top: 80px;
    grid-column: 2;
}
.codex-block-3 {
    clip-path: polygon(2% 0.5%, 99% 0%, 100% 1.5%, 98% 99%, 96% 100%, 1% 98.5%, 0% 97%, 0.5% 2%);
    transform: rotate(0.4deg);
    grid-column: 1;
}
.codex-block-4 {
    clip-path: polygon(0.5% 0%, 98% 1%, 100% 2.5%, 99% 97.5%, 97% 100%, 2.5% 99%, 0% 98%, 1% 1.5%);
    transform: rotate(-0.8deg);
    margin-top: 40px;
    grid-column: 2;
}

.codex-block:hover {
    transform: rotate(0deg);
    filter: drop-shadow(4px 4px 10px rgba(139, 115, 85, 0.35));
}

.codex-block h2 {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(1.6rem, 3.5vw, 2.8rem);
    letter-spacing: 0.02em;
    line-height: 1.3;
    color: var(--deep-ink);
    margin-bottom: 1rem;
}

.codex-block p {
    font-family: 'Inter', sans-serif;
    font-weight: 300;
    line-height: 1.75;
    max-width: 65ch;
    color: var(--deep-ink);
}

.codex-block code {
    font-family: 'Source Code Pro', monospace;
    font-size: 0.9em;
    background: var(--aged-parchment);
    border: 1px solid var(--foxing);
    padding: 0.1em 0.35em;
    border-radius: 2px;
}

/* Slide reveal animation */
.slide-reveal {
    clip-path: inset(0 100% 0 0);
    transition: clip-path 800ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transition-delay: var(--delay, 0ms);
}
.slide-reveal.revealed {
    clip-path: inset(0 0% 0 0);
}

/* ===================== LINKS ===================== */
a {
    color: var(--rust);
    text-decoration: none;
    background-image: linear-gradient(var(--rust), var(--rust));
    background-size: 0% 1px;
    background-position: left bottom;
    background-repeat: no-repeat;
    transition: background-size 300ms ease;
}
a:hover {
    background-size: 100% 1px;
}

/* ===================== THE COLOPHON ===================== */
.colophon {
    background: var(--walnut);
    padding: 60px 20px;
    text-align: center;
    position: relative;
}
.colophon::before {
    content: '';
    display: block;
    width: 300px;
    height: 8px;
    margin: 0 auto 40px;
    background-image: repeating-radial-gradient(
        circle at 4px 4px,
        var(--umber) 0px,
        var(--umber) 1.5px,
        transparent 1.5px,
        transparent 8px
    );
    background-size: 8px 8px;
    opacity: 0.5;
}

.colophon-domain {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: 1.4rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--foxing);
    font-variant: small-caps;
}
.colophon-year {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 400;
    font-size: 0.9rem;
    color: var(--umber);
    margin-top: 0.5rem;
    letter-spacing: 0.1em;
}
.colophon-latin {
    font-family: 'Caveat', cursive;
    font-size: 1rem;
    color: var(--lunar-silver);
    margin-top: 0.75rem;
    opacity: 0.6;
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 768px) {
    .codex {
        grid-template-columns: 1fr;
        gap: 40px;
    }
    .codex-block-2,
    .codex-block-4 {
        margin-top: 0;
    }
    .celestial {
        width: 280px;
        height: 280px;
    }
    .marginalia {
        display: none;
    }
}
