/* ============================================
   lordly.dev — Medieval Scriptorium Styles
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --deep-umber: #2b2520;
    --parchment-smoke: #3d352e;
    --aged-vellum: #f0e4d4;
    --ink-sepia: #4e3827;
    --burnished-gold: #c2956b;
    --wax-red: #a0453e;
    --wax-red-light: #c45a52;
    --wax-red-dark: #8a3a34;
    --candle-amber: #d4a04a;
    --leather-tan: #8b7260;
    --edge-dark: #1e1a16;
}

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

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

body {
    font-family: 'Crimson Pro', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.2rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    color: var(--aged-vellum);
    background-color: var(--deep-umber);
    overflow-x: hidden;
}

/* --- Grain Overlay --- */
#grain-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
    background-repeat: repeat;
}

/* --- Chamber Base --- */
.chamber {
    position: relative;
    min-height: 100vh;
    overflow: hidden;
}

.chamber-tall {
    min-height: 120vh;
}

.chamber-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, var(--deep-umber), var(--edge-dark));
    z-index: 0;
}

.chamber-bg-warm {
    background: radial-gradient(ellipse at center, #332a23, var(--deep-umber));
}

.chamber-content {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* --- Depth Decorative Layer --- */
.depth-decorative {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

.corner-flourish {
    position: absolute;
    opacity: 0.5;
    will-change: transform;
}

.corner-flourish.top-left {
    top: 20px;
    left: 20px;
    animation: flourish-drift-tl 8s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.corner-flourish.top-right {
    top: 20px;
    right: 20px;
    animation: flourish-drift-tr 8s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.corner-flourish.bottom-left {
    bottom: 20px;
    left: 20px;
    animation: flourish-drift-bl 8s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.corner-flourish.bottom-right {
    bottom: 20px;
    right: 20px;
    animation: flourish-drift-br 8s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes flourish-drift-tl {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(2px, 1px); }
    50% { transform: translate(0px, 2px); }
    75% { transform: translate(-1px, 0px); }
}

@keyframes flourish-drift-tr {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(-1px, 2px); }
    50% { transform: translate(-2px, 0px); }
    75% { transform: translate(0px, -1px); }
}

@keyframes flourish-drift-bl {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(1px, -2px); }
    50% { transform: translate(2px, -1px); }
    75% { transform: translate(-1px, 1px); }
}

@keyframes flourish-drift-br {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(-2px, -1px); }
    50% { transform: translate(0px, -2px); }
    75% { transform: translate(1px, 0px); }
}

/* --- Slide Reveal Animation --- */
.slide-reveal {
    clip-path: inset(100% 0 0 0);
    opacity: 0;
    transform: translateY(60px);
    transition: clip-path 700ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                opacity 600ms ease-out,
                transform 600ms ease-out;
}

.slide-reveal.visible {
    clip-path: inset(0 0 0 0);
    opacity: 1;
    transform: translateY(0);
}

/* --- Typography --- */
h1, h2, h3 {
    font-family: 'Bebas Neue', 'Arial Narrow', sans-serif;
    font-weight: 400;
    letter-spacing: 0.08em;
    color: var(--burnished-gold);
    text-transform: uppercase;
}

h1 {
    font-size: clamp(3.5rem, 8vw, 7rem);
}

h2 {
    font-size: clamp(2.5rem, 5vw, 4.5rem);
}

h3 {
    font-size: clamp(1.5rem, 3vw, 2.2rem);
    margin-bottom: 0.75rem;
}

em {
    font-style: italic;
    color: var(--burnished-gold);
}

code {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 400;
    font-size: 0.9em;
    background: rgba(78, 56, 39, 0.12);
    border-left: 3px solid var(--burnished-gold);
    padding: 0.25em 0.6em;
    display: inline-block;
}

/* ============================== */
/* CHAMBER 1: THE GATE            */
/* ============================== */
#chamber-gate {
    display: flex;
    align-items: center;
    justify-content: center;
}

.gate-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding-top: 10vh;
    padding-bottom: 10vh;
}

#shield-crest {
    margin-bottom: 2rem;
}

.gate-title {
    text-align: center;
    color: var(--burnished-gold);
    text-shadow: 0 2px 20px rgba(194, 149, 107, 0.3);
}

/* SVG Drawing Animation */
.draw-svg .draw-path,
.draw-svg .draw-path-circle,
.draw-svg .draw-path-rect,
.draw-svg .draw-path-ellipse {
    opacity: 0;
}

.draw-svg.drawn .draw-path,
.draw-svg.drawn .draw-path-circle,
.draw-svg.drawn .draw-path-rect,
.draw-svg.drawn .draw-path-ellipse {
    opacity: 1;
}

/* ============================== */
/* SECTION DIVIDERS               */
/* ============================== */
.section-divider {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem 0;
    position: relative;
    z-index: 1;
}

.crowned-bracket {
    opacity: 0.6;
}

/* ============================== */
/* CHAMBER 2: THE HALL             */
/* ============================== */
.hall-content {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    min-height: 100vh;
    gap: 2rem;
    padding-top: 8vh;
    padding-bottom: 8vh;
}

.hall-left {
    flex: 0 0 40%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#illuminated-L {
    width: clamp(12rem, 35vw, 22rem);
    height: auto;
}

.hall-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    padding-left: 2rem;
}

.manifesto-col-1 {
    max-width: 65%;
}

.manifesto-col-2 {
    max-width: 45%;
    margin-left: auto;
}

.manifesto-text {
    font-size: clamp(1.05rem, 1.3vw, 1.25rem);
    line-height: 1.8;
    color: var(--aged-vellum);
}

.manifesto-aside {
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    line-height: 1.7;
    color: var(--leather-tan);
}

/* ============================== */
/* CHAMBER 3: THE LIBRARY          */
/* ============================== */
.library-content {
    padding-top: 8vh;
    padding-bottom: 8vh;
}

.library-content .chamber-title {
    text-align: center;
    margin-bottom: 4rem;
}

.manuscript-stack {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
    max-width: 800px;
    margin: 0 auto;
}

.manuscript-panel {
    position: relative;
}

.manuscript-panel.panel-left {
    transform: translateX(-40px);
}

.manuscript-panel.panel-right {
    transform: translateX(40px);
}

.manuscript-panel.panel-left.visible {
    transform: translateX(-40px) translateY(0);
}

.manuscript-panel.panel-right.visible {
    transform: translateX(40px) translateY(0);
}

.panel-inner {
    background: var(--aged-vellum);
    color: var(--ink-sepia);
    padding: 2rem 2.5rem;
    border-radius: 2px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3),
                0 1px 3px rgba(0, 0, 0, 0.2);
    position: relative;
}

.panel-inner h3 {
    color: var(--ink-sepia);
    border-bottom: 1px solid var(--leather-tan);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

.panel-inner p {
    color: var(--ink-sepia);
    margin-bottom: 1rem;
}

.panel-inner em {
    color: var(--wax-red);
}

.code-annotation {
    margin-top: 1rem;
}

.code-annotation code {
    color: var(--ink-sepia);
    background: rgba(78, 56, 39, 0.08);
    border-left-color: var(--wax-red);
    font-size: 0.85em;
}

/* ============================== */
/* CHAMBER 4: THE FORGE            */
/* ============================== */
.forge-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding-top: 8vh;
    padding-bottom: 8vh;
}

.forge-content .chamber-title {
    margin-bottom: 4rem;
}

.workbench {
    width: 100%;
    max-width: 900px;
}

.tool-rack {
    display: flex;
    justify-content: center;
    gap: clamp(1rem, 3vw, 3rem);
    flex-wrap: wrap;
    margin-bottom: 2rem;
}

.tool-hook {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.tool-hook::before {
    content: '';
    width: 2px;
    height: 20px;
    background: var(--leather-tan);
    display: block;
    margin-bottom: -2px;
}

.tool {
    position: relative;
    cursor: pointer;
    transform-origin: 50% 0;
    animation: pendulum 3s ease-in-out infinite;
    animation-play-state: paused;
    transition: filter 0.3s ease;
}

.tool.swinging {
    animation-play-state: running;
}

.tool:hover {
    filter: brightness(1.3);
}

@keyframes pendulum {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(3deg); }
    75% { transform: rotate(-3deg); }
}

.tool-tooltip {
    position: absolute;
    bottom: -45px;
    left: 50%;
    transform: translateX(-50%) scale(0.8);
    background: var(--wax-red);
    color: var(--aged-vellum);
    font-family: 'Crimson Pro', serif;
    font-style: italic;
    font-size: 0.85rem;
    padding: 4px 12px;
    border-radius: 50%;
    width: 80px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    box-shadow: inset 0 1px 4px rgba(0,0,0,0.3),
                0 2px 8px rgba(0,0,0,0.3);
    white-space: nowrap;
}

.tool:hover .tool-tooltip {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

.workbench-surface {
    width: 100%;
}

.workbench-svg {
    width: 100%;
    height: 60px;
}

/* ============================== */
/* CHAMBER 5: THE SEAL             */
/* ============================== */
.seal-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding-top: 8vh;
    padding-bottom: 8vh;
}

.seal-content .chamber-title {
    margin-bottom: 4rem;
}

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

.seal {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, #c45a52, #a0453e 60%, #8a3a34 100%);
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.4),
                inset 0 -1px 4px rgba(255,200,150,0.15),
                0 4px 16px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transform: scale(0.3) rotate(-5deg);
    transition: transform 800ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.seal.stamped {
    transform: scale(1) rotate(0deg);
}

.seal::after {
    content: '';
    position: absolute;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    top: -5px;
    left: -5px;
    filter: url(#wax-edge);
    background: radial-gradient(circle at 40% 35%, rgba(196, 90, 82, 0.6), rgba(160, 69, 62, 0.4) 60%, transparent 100%);
    z-index: -1;
}

.seal-letter {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 3.5rem;
    color: var(--wax-red-dark);
    text-shadow: 1px 1px 0 rgba(255,200,150,0.2),
                 -1px -1px 0 rgba(0,0,0,0.3),
                 0 0 10px rgba(0,0,0,0.2);
    letter-spacing: 0.05em;
}

.contact-line {
    text-align: center;
}

.contact-text {
    font-family: 'Crimson Pro', serif;
    font-variant: small-caps;
    font-size: clamp(0.9rem, 1.2vw, 1.1rem);
    color: var(--leather-tan);
    letter-spacing: 0.1em;
}

/* ============================== */
/* RESPONSIVE                      */
/* ============================== */
@media (max-width: 768px) {
    .hall-content {
        flex-direction: column;
    }

    .hall-left {
        flex: none;
        width: 100%;
    }

    #illuminated-L {
        width: clamp(10rem, 60vw, 18rem);
    }

    .hall-right {
        padding-left: 0;
    }

    .manifesto-col-1,
    .manifesto-col-2 {
        max-width: 100%;
        margin-left: 0;
    }

    .manuscript-panel.panel-left,
    .manuscript-panel.panel-right {
        transform: translateX(0);
    }

    .manuscript-panel.panel-left.visible,
    .manuscript-panel.panel-right.visible {
        transform: translateX(0);
    }

    .tool-rack {
        gap: 1rem;
    }

    .corner-flourish {
        display: none;
    }
}

@media (max-width: 480px) {
    .gate-title {
        font-size: clamp(2.5rem, 12vw, 4rem);
    }

    .panel-inner {
        padding: 1.5rem;
    }
}
