/* alth.ing - Dark Academia / Viking Manuscript */
/* Palette: #f5edd6, #e8dcc8, #2c1810, #8b2500, #c5a45a, #3a3a38, #6b6b66, #b8a990, #c0392b */

:root {
    --vellum: #f5edd6;
    --foxing: #e8dcc8;
    --ink: #2c1810;
    --rubric: #8b2500;
    --gold: #c5a45a;
    --stone-dark: #3a3a38;
    --stone-light: #6b6b66;
    --rule: #b8a990;
    --seal-red: #c0392b;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--stone-dark);
    color: var(--ink);
    font-family: 'Crimson Pro', serif;
    font-weight: 400;
    line-height: 1.75;
    overflow-x: hidden;
}

/* ============================
   PHASE 1: THE MANUSCRIPT OPENS
   ============================ */

.phase-opening {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: radial-gradient(ellipse at 50% 40%, var(--vellum) 0%, var(--foxing) 60%, #ddd0b8 100%);
}

/* Stone cover that splits open */
.stone-cover {
    position: absolute;
    inset: 0;
    background: var(--stone-dark);
    z-index: 10;
    animation: stoneSplit 2s ease-out forwards;
}

@keyframes stoneSplit {
    0% {
        clip-path: inset(0 0 0 0);
        opacity: 1;
    }
    30% {
        clip-path: inset(0 49.5% 0 49.5%);
        opacity: 1;
    }
    60% {
        clip-path: inset(0 49.5% 0 49.5%);
        opacity: 0.8;
    }
    100% {
        clip-path: inset(0 50% 0 50%);
        opacity: 0;
    }
}

/* Crack of light in the center */
.crack-light {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 100%;
    background: linear-gradient(to bottom, transparent 5%, var(--vellum) 30%, #fff8e8 50%, var(--vellum) 70%, transparent 95%);
    z-index: 11;
    animation: crackExpand 2s ease-out forwards;
    opacity: 0;
}

@keyframes crackExpand {
    0% {
        width: 0;
        opacity: 0;
    }
    10% {
        width: 2px;
        opacity: 1;
    }
    50% {
        width: 6px;
        opacity: 1;
    }
    80% {
        width: 100vw;
        opacity: 0.6;
    }
    100% {
        width: 100vw;
        opacity: 0;
    }
}

/* Parchment surface revealed */
.parchment-reveal {
    position: relative;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0;
    animation: parchmentFade 1.2s ease-out 1.5s forwards;
}

@keyframes parchmentFade {
    from { opacity: 0; transform: scale(0.97); }
    to { opacity: 1; transform: scale(1); }
}

/* Parchment grain texture overlay */
.phase-opening::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(ellipse at 20% 30%, rgba(200,180,140,0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 60%, rgba(180,160,120,0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(190,170,130,0.08) 0%, transparent 40%);
    pointer-events: none;
    z-index: 2;
}

.hero-content {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
}

/* Illuminated Initial */
.illuminated-initial {
    flex-shrink: 0;
    opacity: 0;
    animation: initialAppear 0.8s ease-out 2.2s forwards;
}

@keyframes initialAppear {
    from { opacity: 0; }
    to { opacity: 1; }
}

.initial-svg .knot-border-outer {
    animation: drawBorder 1.5s ease-out 2.4s forwards;
}

.initial-svg .knot-border-inner {
    animation: drawBorderInner 1.5s ease-out 2.8s forwards;
}

@keyframes drawBorder {
    to { stroke-dashoffset: 0; }
}

@keyframes drawBorderInner {
    to { stroke-dashoffset: 0; }
}

.initial-svg .corner-knot {
    animation: knotAppear 0.4s ease-out forwards;
    animation-delay: 3.5s;
}

@keyframes knotAppear {
    from { opacity: 0; transform: scale(0); }
    to { opacity: 1; transform: scale(1); }
}

.initial-svg .knot-fill {
    animation: drawKnotFill 2s ease-out 3.2s forwards;
}

@keyframes drawKnotFill {
    0% { stroke-dashoffset: 400; opacity: 0; }
    10% { opacity: 0.4; }
    100% { stroke-dashoffset: 0; opacity: 0.4; }
}

.initial-svg .letter-a {
    animation: letterReveal 1s ease-out 3.8s forwards;
}

.initial-svg .letter-a-gold {
    animation: letterReveal 1s ease-out 4s forwards;
}

@keyframes letterReveal {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Brand title */
.title-block {
    padding-bottom: 0.5rem;
    opacity: 0;
    animation: titleFade 1.2s ease-out 4.2s forwards;
}

@keyframes titleFade {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.brand-name {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: clamp(2.5rem, 7vw, 4.5rem);
    color: var(--ink);
    letter-spacing: 0.08em;
    line-height: 1;
}

.brand-subtitle {
    font-family: 'EB Garamond', serif;
    font-style: italic;
    font-size: 0.95rem;
    color: var(--rule);
    margin-top: 0.5rem;
    letter-spacing: 0.03em;
}

/* Ruled lines with diamond terminals */
.ruled-line {
    width: 220px;
    height: 1px;
    background: var(--rule);
    margin-top: 3rem;
    position: relative;
    opacity: 0;
    animation: ruleFade 0.8s ease-out 4.8s forwards;
}

@keyframes ruleFade {
    from { opacity: 0; width: 0; }
    to { opacity: 1; width: 220px; }
}

.ruled-line::before,
.ruled-line::after {
    content: '';
    position: absolute;
    top: -3px;
    width: 7px;
    height: 7px;
    background: var(--gold);
    transform: rotate(45deg);
}

.ruled-line::before { left: -4px; }
.ruled-line::after { right: -4px; }

/* Runic markers */
.runic-markers {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    opacity: 0;
    animation: runicFade 0.6s ease-out 5.2s forwards;
}

@keyframes runicFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.runic-mark {
    font-size: 0.7rem;
    color: var(--gold);
    opacity: 0.6;
}

/* ============================
   KNOTWORK BAND DIVIDERS
   ============================ */

.knotwork-band {
    width: 100%;
    overflow: hidden;
    background: var(--foxing);
    padding: 1rem 0;
    position: relative;
}

.knotwork-band-svg {
    width: 100%;
    height: 30px;
    display: block;
}

.knotwork-path,
.knotwork-path-under {
    transition: stroke-dashoffset 2s ease-out;
}

.knotwork-band.animate .knotwork-path,
.knotwork-band.animate .knotwork-path-under {
    stroke-dashoffset: 0;
}

.knot-node {
    opacity: 0;
    transition: opacity 0.5s ease-out 1.5s;
}

.knotwork-band.animate .knot-node {
    opacity: 1;
}

/* ============================
   PHASE 2: THE TEXT FLOWS
   ============================ */

.phase-text {
    position: relative;
    background: var(--vellum);
    background-image:
        radial-gradient(ellipse at 30% 20%, rgba(232,220,200,0.8) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 70%, rgba(232,220,200,0.6) 0%, transparent 40%),
        radial-gradient(ellipse at 50% 50%, rgba(245,237,214,1) 0%, rgba(232,220,200,0.4) 100%);
    padding: 5rem 2rem;
    overflow: hidden;
}

/* Foxing spots */
.foxing-spot {
    position: absolute;
    border-radius: 50% 40% 60% 45%;
    background: radial-gradient(ellipse, #b8a070 0%, transparent 70%);
    pointer-events: none;
}

/* Corner flourishes */
.corner-flourish {
    position: absolute;
    pointer-events: none;
}

.corner-flourish.top-left { top: 1.5rem; left: 1.5rem; }
.corner-flourish.top-right { top: 1.5rem; right: 1.5rem; }
.corner-flourish.bottom-left { bottom: 1.5rem; left: 1.5rem; }
.corner-flourish.bottom-right { bottom: 1.5rem; right: 1.5rem; }

/* Manuscript grid: margins + columns + gutter */
.manuscript-grid {
    display: grid;
    grid-template-columns: 120px 1fr 1px 1fr 120px;
    gap: 0;
    max-width: 1100px;
    margin: 0 auto;
    align-items: start;
}

/* Margin columns */
.margin-column {
    padding: 0 0.75rem;
}

.margin-note {
    font-family: 'EB Garamond', serif;
    font-style: italic;
    font-size: 0.75rem;
    color: var(--rule);
    line-height: 1.4;
    margin-bottom: 1.5rem;
}

.margin-note .runic-mark {
    display: block;
    margin-bottom: 0.3rem;
    font-size: 0.6rem;
}

.right-margin {
    text-align: right;
}

.right-margin .runic-mark {
    display: block;
    margin-top: 0.3rem;
}

/* Manuscript columns */
.manuscript-column {
    padding: 0 2rem;
}

/* Column gutter with ornamental line */
.column-gutter {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    min-height: 100%;
    padding: 0;
}

.gutter-line {
    flex: 1;
    width: 1px;
    background: var(--rule);
    min-height: 60px;
}

.gutter-knot {
    width: 6px;
    height: 6px;
    background: var(--gold);
    transform: rotate(45deg);
    flex-shrink: 0;
    margin: 0.3rem 0;
}

/* Chapter headings */
.chapter-heading {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: 1.3rem;
    color: var(--ink);
    letter-spacing: 0.08em;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 0.3rem;
}

.heading-text {
    padding-top: 0.6rem;
}

/* Illuminated drop caps */
.illuminated-drop {
    flex-shrink: 0;
    display: inline-block;
}

.drop-svg {
    display: block;
}

/* Manuscript body text */
.manuscript-body {
    font-family: 'Crimson Pro', serif;
    font-size: 0.95rem;
    line-height: 1.75;
    color: var(--ink);
    margin-bottom: 1.2rem;
    text-align: justify;
    hyphens: auto;
}

/* Text fade line-by-line effect via gradient mask */
.text-fade {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

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

/* Scroll reveal animations */
.scroll-reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.9s ease-out, transform 0.9s ease-out;
}

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

/* ============================
   PHASE 3: THE SEAL
   ============================ */

.phase-seal {
    position: relative;
    background: var(--foxing);
    background-image:
        radial-gradient(ellipse at 50% 30%, rgba(245,237,214,0.6) 0%, transparent 60%),
        radial-gradient(ellipse at 50% 50%, var(--foxing) 0%, #d8cdb5 100%);
    padding: 6rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
}

.seal-container {
    margin-bottom: 3rem;
}

/* Wax Seal */
.wax-seal {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, var(--seal-red), var(--rubric) 70%, #6b1a00);
    box-shadow:
        2px 3px 10px rgba(0, 0, 0, 0.5),
        inset 0 -3px 6px rgba(0, 0, 0, 0.35),
        inset 0 2px 4px rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.6s ease;
}

.wax-seal::before {
    content: '';
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.15);
}

.wax-seal::after {
    content: '';
    position: absolute;
    width: 80%;
    height: 80%;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.08);
}

.wax-seal:hover {
    transform: scale(1.08);
    box-shadow:
        3px 5px 14px rgba(0, 0, 0, 0.55),
        inset 0 -3px 6px rgba(0, 0, 0, 0.35),
        inset 0 2px 4px rgba(255, 255, 255, 0.1);
}

.wax-seal.pressed {
    transform: scale(0.92);
    box-shadow:
        1px 1px 4px rgba(0, 0, 0, 0.5),
        inset 0 -4px 8px rgba(0, 0, 0, 0.5),
        inset 0 3px 6px rgba(255, 255, 255, 0.05);
}

.seal-surface {
    display: flex;
    align-items: center;
    justify-content: center;
}

.seal-emblem {
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.wax-seal.pressed .seal-emblem {
    opacity: 1;
}

/* Seal proclamation */
.seal-proclamation {
    max-width: 600px;
    text-align: center;
}

.seal-rule-top,
.seal-rule-bottom {
    width: 160px;
    margin: 0 auto 2rem auto;
    animation: none;
    opacity: 1;
}

.seal-rule-bottom {
    margin: 2rem auto 0 auto;
}

.proclamation-text {
    font-family: 'Crimson Pro', serif;
    font-size: 1.05rem;
    line-height: 1.85;
    color: var(--ink);
    font-style: italic;
}

/* ============================
   PHASE 4: THE STONE
   ============================ */

.phase-stone {
    position: relative;
    min-height: 60vh;
    background: linear-gradient(to bottom, var(--foxing) 0%, var(--stone-dark) 15%, var(--stone-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8rem 2rem;
    overflow: hidden;
}

.stone-texture-overlay {
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(ellipse at 30% 40%, rgba(100,100,90,0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 60%, rgba(80,80,70,0.1) 0%, transparent 40%),
        radial-gradient(ellipse at 50% 80%, rgba(60,60,55,0.08) 0%, transparent 50%);
    pointer-events: none;
}

.stone-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2.5rem;
}

.stone-text {
    text-align: center;
}

/* Carved text with bevel effect */
.carved-text {
    font-family: 'Cinzel', serif;
    font-weight: 400;
    font-size: clamp(1rem, 2.5vw, 1.4rem);
    color: var(--stone-light);
    line-height: 1.8;
    text-shadow:
        1px 1px 0 rgba(0, 0, 0, 0.5),
        -1px -1px 0 rgba(120, 120, 110, 0.2),
        0 0 8px rgba(0, 0, 0, 0.3);
    letter-spacing: 0.04em;
}

.stone-divider {
    display: flex;
    align-items: center;
    justify-content: center;
}

.stone-diamond {
    font-size: 0.6rem;
    color: var(--stone-light);
    opacity: 0.3;
}

.stone-brand {
    text-align: center;
}

.stone-brandname {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.3em;
    color: var(--stone-light);
    opacity: 0.35;
    text-transform: uppercase;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.4);
}

.stone-year {
    font-family: 'EB Garamond', serif;
    font-style: italic;
    font-size: 0.7rem;
    color: var(--stone-light);
    opacity: 0.25;
    margin-top: 0.3rem;
    letter-spacing: 0.15em;
}

/* ============================
   RESPONSIVE
   ============================ */

@media (max-width: 900px) {
    .manuscript-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
        padding: 0 1rem;
    }

    .margin-column {
        display: none;
    }

    .column-gutter {
        flex-direction: row;
        width: 100%;
        min-height: auto;
        gap: 0;
        padding: 1rem 0;
    }

    .gutter-line {
        flex: 1;
        height: 1px;
        width: auto;
        min-height: auto;
    }

    .gutter-knot {
        margin: 0 0.3rem;
    }

    .manuscript-column {
        padding: 0;
    }

    .phase-text {
        padding: 3rem 1.5rem;
    }

    .corner-flourish {
        display: none;
    }
}

@media (max-width: 600px) {
    .hero-content {
        flex-direction: column;
        align-items: center;
    }

    .title-block {
        text-align: center;
    }

    .brand-name {
        font-size: 2.2rem;
    }

    .phase-seal {
        padding: 4rem 1.5rem;
    }

    .phase-stone {
        padding: 5rem 1.5rem;
    }

    .carved-text {
        font-size: 0.95rem;
    }
}
