/* ============================================
   mujun.works - Victorian Patent Office Manuscript
   ============================================ */
:root {
    --midnight-sapphire: #0F1B3D;
    --claret-velvet: #4A0A2E;
    --antique-gilt: #C9A84C;
    --aged-parchment: #E8DCC0;
    --victorian-green: #1A5C3A;
    --crown-purple: #6B2D7B;
    --garnet-blood: #8B1A2B;
    --tarnished-silver: #7A7B7E;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
    background: var(--midnight-sapphire);
    color: var(--aged-parchment);
    font-family: 'EB Garamond', Georgia, 'Times New Roman', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.25rem);
    line-height: 1.75;
    overflow-x: hidden;
}

/* --- Grain Overlay --- */
.grain-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    background-size: 200px 200px;
    opacity: 0.06;
    transition: opacity 0.3s ease;
}

/* --- Frame Thread --- */
.frame-thread {
    position: fixed;
    left: clamp(0.5rem, 2vw, 2rem);
    top: 0;
    width: 40px;
    height: 100vh;
    z-index: 100;
    pointer-events: none;
}
#threadPath {
    stroke-dasharray: 8000;
    stroke-dashoffset: 8000;
    transition: stroke-dashoffset 0.1s linear;
}

/* --- Corner Brackets --- */
.corner-bracket {
    position: absolute;
    width: 80px;
    height: 80px;
    z-index: 2;
}
.corner-tl { top: clamp(1rem, 3vw, 3rem); left: clamp(1rem, 3vw, 3rem); }
.corner-tr { top: clamp(1rem, 3vw, 3rem); right: clamp(1rem, 3vw, 3rem); }
.corner-bl { bottom: clamp(1rem, 3vw, 3rem); left: clamp(1rem, 3vw, 3rem); }
.corner-br { bottom: clamp(1rem, 3vw, 3rem); right: clamp(1rem, 3vw, 3rem); }
.draw-path {
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    transition: stroke-dashoffset 2.5s cubic-bezier(0.25, 0.1, 0.25, 1);
}
.plate.visible .draw-path {
    stroke-dashoffset: 0;
}

/* --- Plate Base --- */
.plate {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(3rem, 6vw, 6rem) clamp(2rem, 8vw, 10rem);
    overflow: hidden;
}

/* --- Section Connectors --- */
.section-connector {
    display: flex;
    justify-content: center;
    padding: 2rem 0;
    opacity: 0;
    transition: opacity 1s ease;
}
.section-connector.visible {
    opacity: 1;
}
.fleuron {
    width: 40px;
    height: 20px;
}

/* --- Typography --- */
.body-text {
    font-family: 'EB Garamond', Georgia, serif;
    font-size: clamp(1rem, 1.2vw, 1.25rem);
    line-height: 1.75;
    color: var(--aged-parchment);
    margin-bottom: 0;
}
.body-text.indent {
    text-indent: 1.5em;
}
.body-text + .body-text {
    margin-top: 0;
}
.italic {
    font-style: italic;
}
.drop-cap {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 600;
    float: left;
    font-size: 4em;
    line-height: 0.75;
    padding-right: 0.08em;
    padding-top: 0.06em;
    color: var(--antique-gilt);
}
.section-label {
    font-family: 'Cinzel', Georgia, serif;
    font-weight: 400;
    font-size: clamp(0.7rem, 1vw, 0.9rem);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--tarnished-silver);
    display: block;
    margin: 2rem 0 1rem;
}

/* ============================
   PLATE 1: THE TITLE PAGE
   ============================ */
.plate-title {
    background: var(--midnight-sapphire);
    flex-direction: column;
    min-height: 100vh;
}
.plate-title::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(74, 10, 46, 0.15) 0%, transparent 70%);
    pointer-events: none;
}
.title-content {
    text-align: center;
    z-index: 1;
}
.title-main {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 300;
    font-size: clamp(4rem, 12vw, 10rem);
    letter-spacing: 0.12em;
    line-height: 1.1;
    color: var(--aged-parchment);
}
.title-rule {
    margin: 1.5rem auto;
    width: 300px;
    max-width: 60vw;
}
.title-rule-svg {
    width: 100%;
    height: 2px;
}
.draw-line {
    transition: x1 1.5s ease-out 0.5s, x2 1.5s ease-out 0.5s;
}
.plate-title.visible .draw-line {
    x: 0;
}
.title-sub {
    font-family: 'Cinzel', Georgia, serif;
    font-weight: 400;
    font-size: clamp(0.9rem, 2vw, 1.8rem);
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--tarnished-silver);
}

/* ============================
   PLATE 2: THE PREMISE
   ============================ */
.plate-premise {
    background: var(--claret-velvet);
    min-height: 90vh;
}
.plate-premise::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(15, 27, 61, 0.2) 0%, transparent 70%);
    pointer-events: none;
}

/* --- Z-Pattern Content --- */
.z-content {
    display: flex;
    gap: clamp(2rem, 4vw, 4rem);
    width: 100%;
    max-width: 1100px;
    align-items: flex-start;
}
.z-content--odd {
    flex-direction: row;
}
.z-content--even {
    flex-direction: row-reverse;
}
.z-text {
    flex: 1;
    opacity: 0;
    transform: translateY(25px);
    transition: opacity 1.5s ease-out, transform 1.5s ease-out;
}
.z-text.visible {
    opacity: 1;
    transform: translateY(0);
}
.z-ornament {
    flex: 0 0 35%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(25px);
    transition: opacity 1.5s ease-out 0.3s, transform 1.5s ease-out 0.3s;
}
.z-ornament.visible {
    opacity: 1;
    transform: translateY(0);
}
.blob-ornament {
    width: 100%;
    max-width: 300px;
    animation: blob-rotate 120s linear infinite;
}
@keyframes blob-rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ============================
   PLATE 3: THE CRAFT
   ============================ */
.plate-craft {
    background: var(--midnight-sapphire);
    min-height: 100vh;
}
.plate-craft::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 30% 50%, rgba(74, 10, 46, 0.1) 0%, transparent 60%);
    pointer-events: none;
}

/* Filigree Rule */
.filigree-rule {
    margin: 2.5rem 0;
    opacity: 0;
    transition: opacity 1s ease;
}
.filigree-rule.visible {
    opacity: 1;
}
.filigree-rule svg {
    width: 100%;
    max-width: 400px;
    height: 12px;
}

/* ============================
   PLATE 4: THE COLLECTION
   ============================ */
.plate-collection {
    min-height: 90vh;
    padding: clamp(3rem, 6vw, 6rem) clamp(2rem, 6vw, 8rem);
}
.collection-split {
    display: flex;
    width: 100%;
    max-width: 1100px;
    gap: 0;
}
.collection-left {
    flex: 0 0 40%;
    background: var(--midnight-sapphire);
    padding: clamp(2rem, 4vw, 4rem);
    display: flex;
    align-items: center;
}
.collection-right {
    flex: 0 0 calc(60% - 2px);
    background: var(--claret-velvet);
    padding: clamp(2rem, 4vw, 4rem);
    display: flex;
    align-items: center;
}
.collection-right::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(15, 27, 61, 0.15) 0%, transparent 70%);
    pointer-events: none;
}
.collection-divider {
    flex: 0 0 2px;
    position: relative;
}
.divider-svg {
    width: 2px;
    height: 100%;
    min-height: 400px;
}

/* Collection entries */
.collection-list,
.collection-descriptions {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1.5s ease-out, transform 1.5s ease-out;
}
.collection-list.visible,
.collection-descriptions.visible {
    opacity: 1;
    transform: translateY(0);
}
.collection-entry {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    padding: 0.5rem 0;
}
.entry-label {
    font-family: 'Cinzel', Georgia, serif;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.1em;
    color: var(--antique-gilt);
    flex-shrink: 0;
}
.entry-title {
    font-family: 'Cinzel', Georgia, serif;
    font-weight: 400;
    font-size: clamp(0.8rem, 1.1vw, 1rem);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--aged-parchment);
}
.entry-connector {
    width: 40px;
    height: 1px;
    background: var(--tarnished-silver);
    opacity: 0.3;
    margin: 0.3rem 0 0.3rem 2.5rem;
}
.collection-descriptions .body-text {
    margin-bottom: 1.2rem;
    font-size: clamp(0.92rem, 1.1vw, 1.1rem);
    opacity: 0.85;
}

/* ============================
   PLATE 5: THE TESTAMENT
   ============================ */
.plate-testament {
    background: var(--crown-purple);
    min-height: 100vh;
}
.plate-testament::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(15, 27, 61, 0.2) 0%, transparent 60%);
    pointer-events: none;
}
.testament-quote {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1.5rem;
    opacity: 0;
    transform: translateY(25px);
    transition: opacity 1.5s ease-out, transform 1.5s ease-out;
}
.testament-quote.visible {
    opacity: 1;
    transform: translateY(0);
}
.quote-mark {
    width: 40px;
    height: 40px;
}
.quote-mark--close {
    align-self: flex-end;
}
.testament-text {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 600;
    font-size: clamp(1.5rem, 3vw, 2.8rem);
    line-height: 1.35;
    color: var(--aged-parchment);
}
.testament-attribution {
    font-family: 'EB Garamond', Georgia, serif;
    font-style: italic;
    font-size: clamp(0.9rem, 1.1vw, 1.1rem);
    color: var(--tarnished-silver);
}
.blob-ornament--complex {
    animation-duration: 180s;
}

/* ============================
   PLATE 6: THE COLOPHON
   ============================ */
.plate-colophon {
    background: var(--midnight-sapphire);
    min-height: 60vh;
    flex-direction: column;
    gap: 2rem;
}
.printers-ornament {
    opacity: 0;
    transition: opacity 1.5s ease;
}
.printers-ornament.visible {
    opacity: 1;
}
.printers-ornament svg {
    width: 120px;
    height: 30px;
}
.colophon-text {
    text-align: center;
    max-width: 500px;
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 1.5s ease-out, transform 1.5s ease-out;
}
.colophon-text.visible {
    opacity: 1;
    transform: translateY(0);
}
.colophon-body {
    font-family: 'EB Garamond', Georgia, serif;
    font-style: italic;
    font-size: 0.95rem;
    line-height: 1.75;
    color: var(--aged-parchment);
    opacity: 0.8;
    margin-bottom: 1.5rem;
}
.colophon-mark {
    font-family: 'Cinzel', Georgia, serif;
    font-weight: 400;
    font-size: 0.8rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--tarnished-silver);
}
.colophon-rule {
    width: 200px;
    opacity: 0;
    transition: opacity 1.5s ease;
}
.colophon-rule.visible {
    opacity: 1;
}
.colophon-rule svg {
    width: 100%;
    height: 2px;
}

/* ============================
   RESPONSIVE
   ============================ */
@media (max-width: 900px) {
    .z-content--odd,
    .z-content--even {
        flex-direction: column;
    }
    .z-ornament {
        flex: 0 0 auto;
        max-width: 200px;
        margin: 0 auto;
    }
    .collection-split {
        flex-direction: column;
    }
    .collection-left,
    .collection-right {
        flex: none;
        width: 100%;
    }
    .collection-divider {
        display: none;
    }
    .frame-thread {
        display: none;
    }
    .corner-bracket {
        width: 50px;
        height: 50px;
    }
}
