/* archaic.studio - Illuminated Manuscript Scriptorium */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: #F2E8D0;
    background-image:
        radial-gradient(circle at 20% 30%, #D4C4A0 1px, transparent 1px),
        radial-gradient(circle at 60% 70%, #D4C4A0 1px, transparent 1px),
        radial-gradient(circle at 80% 20%, #D4C4A0 1px, transparent 1px),
        radial-gradient(circle at 40% 80%, #D4C4A0 1px, transparent 1px);
    background-size: 200px 200px, 300px 300px, 250px 250px, 180px 180px;
    color: #2B1810;
    font-family: 'EB Garamond', serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.3vw, 1.1rem);
    line-height: 1.85;
    letter-spacing: 0.01em;
    overflow-x: hidden;
}

/* Manuscript Frame */
#manuscript-frame {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 100;
    pointer-events: none;
}

#frame-border {
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.6s ease;
}

#frame-border.visible {
    opacity: 1;
}

.outer-line {
    stroke-dasharray: 5960;
    stroke-dashoffset: 5960;
    transition: stroke-dashoffset 0.8s ease;
}

.outer-line.drawn {
    stroke-dashoffset: 0;
}

.inner-line {
    stroke-dasharray: 5920;
    stroke-dashoffset: 5920;
    transition: stroke-dashoffset 0.6s ease 0.8s;
}

.inner-line.drawn {
    stroke-dashoffset: 0;
}

.corner-knot {
    opacity: 0;
    transition: opacity 1s ease;
}

.corner-knot.visible {
    opacity: 1;
}

.corner-knot path {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
}

.corner-knot.drawn path {
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s ease;
}

.corner-tl { transition-delay: 1.4s; }
.corner-tl.drawn path { transition-delay: 1.4s; }
.corner-tr { transition-delay: 1.6s; }
.corner-tr.drawn path { transition-delay: 1.6s; }
.corner-br { transition-delay: 1.8s; }
.corner-br.drawn path { transition-delay: 1.8s; }
.corner-bl { transition-delay: 2.0s; }
.corner-bl.drawn path { transition-delay: 2.0s; }

/* Left Marginalia */
#left-marginalia {
    position: fixed;
    left: 2%;
    top: 50px;
    width: 18%;
    height: calc(100vh - 100px);
    z-index: 10;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

#vine-scroll {
    width: 60px;
    height: 100%;
    opacity: 0;
    transition: opacity 2s ease 2.5s;
}

#vine-scroll.visible {
    opacity: 1;
}

.vine-main {
    stroke-dasharray: 2500;
    stroke-dashoffset: 2500;
}

.vine-main.drawn {
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 4s ease;
}

.vine-leaf {
    opacity: 0;
    transition: opacity 0.8s ease, transform 0.6s ease;
}

.vine-leaf.visible {
    opacity: 0.4;
}

.vine-leaf.rotated {
    transform: rotate(3deg);
    transform-origin: center bottom;
}

/* Right Marginalia */
#right-marginalia {
    position: fixed;
    right: 3%;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 30px;
    pointer-events: auto;
}

.manicule {
    color: #2B1810;
    opacity: 0.4;
    transition: opacity 0.3s ease, transform 0.2s ease, color 0.3s ease;
    cursor: pointer;
}

.manicule:hover {
    transform: translateX(3px);
}

.manicule.active {
    opacity: 1;
    color: #C9A43E;
}

/* Main Content */
#manuscript-content {
    position: relative;
    width: 55%;
    max-width: 700px;
    margin: 0 auto;
    padding: 120px 0;
    z-index: 20;
}

.manuscript-section {
    margin-bottom: 80px;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.manuscript-section.visible {
    opacity: 1;
}

/* Decorated Initials */
.decorated-initial {
    float: left;
    margin-right: 16px;
    margin-bottom: 8px;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.decorated-initial:hover {
    opacity: 1;
}

.initial-frame {
    display: block;
}

/* Section Headings */
.section-heading {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: #2B1810;
    margin-bottom: 24px;
    display: inline;
    line-height: 1.2;
}

/* Section Text */
.section-text {
    clear: both;
    padding-top: 12px;
}

.section-text p {
    margin-bottom: 1.5em;
    text-align: justify;
    hyphens: auto;
}

.section-text em {
    font-style: italic;
}

/* Rubricated Words */
.rubricated {
    color: #8B2500;
    text-decoration: none;
    border-bottom: 0 solid #8B2500;
    transition: border-bottom-width 0.2s ease;
    cursor: default;
}

.rubricated:hover {
    border-bottom-width: 1px;
}

/* Ornamental Dividers */
.ornamental-divider {
    margin: 60px 0;
    text-align: center;
}

.ornamental-divider svg {
    width: 100%;
    max-width: 500px;
    height: 30px;
}

/* Carpet Page */
.carpet-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 40px 0;
}

#carpet-pattern {
    width: 100%;
    max-width: 600px;
    height: auto;
}

#carpet-pattern circle,
#carpet-pattern path,
#carpet-pattern rect {
    transition: filter 0.3s ease;
}

.carpet-section .carpet-glow {
    position: absolute;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(201,164,62,0.08) 0%, transparent 70%);
    pointer-events: none;
    z-index: 25;
}

/* Carpet color shifting animation */
@keyframes carpetShimmer {
    0%, 100% { filter: saturate(1); }
    50% { filter: saturate(1.05); }
}

.carpet-section.in-view #carpet-pattern {
    animation: carpetShimmer 10s ease-in-out infinite;
}

/* Colophon */
.colophon-text {
    text-align: center;
}

.colophon-dedication {
    font-style: italic;
    color: #4A3728;
    margin: 30px 0;
    padding: 20px 40px;
    border-left: 2px solid #C9A43E;
    border-right: 2px solid #C9A43E;
    text-align: center;
}

.colophon-date {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: 0.2em;
    color: #8B2500;
    text-align: center;
    margin-top: 40px;
}

/* Marginalia annotation text */
.marginalia-text {
    font-family: 'Uncial Antiqua', cursive;
    font-size: 14px;
    color: #8B6914;
    opacity: 0.5;
}

/* Responsive */
@media (max-width: 900px) {
    #manuscript-content {
        width: 80%;
    }
    #left-marginalia {
        display: none;
    }
    #right-marginalia {
        right: 1%;
    }
    .manicule svg {
        width: 18px;
        height: 12px;
    }
}

@media (max-width: 600px) {
    #manuscript-content {
        width: 90%;
        padding: 80px 0;
    }
    #right-marginalia {
        display: none;
    }
    .decorated-initial svg {
        width: 60px;
        height: 60px;
    }
}
