/* ============================================
   martialaw.quest — Styles
   ============================================ */

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

:root {
    --color-charcoal: #1a1209;
    --color-deep-umber: #2b1810;
    --color-dark-brown: #3d2b1f;
    --color-bronze: #8b6240;
    --color-copper: #c2703a;
    --color-amber: #d4882e;
    --color-gold: #c9a86c;
    --color-parchment: #f0e6d8;
    --color-warm-parchment: #f5dcc3;

    --font-display: 'Playfair Display', serif;
    --font-body: 'Cormorant Garamond', serif;
    --font-ui: 'Inter', sans-serif;
}

html {
    scroll-behavior: smooth;
    background-color: var(--color-charcoal);
}

body {
    font-family: var(--font-body);
    color: var(--color-parchment);
    background-color: var(--color-charcoal);
    overflow-x: hidden;
    line-height: 1.7;
}

/* --- Noise Overlay --- */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' 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='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 1000;
    opacity: 0.5;
}

/* --- Timeline Spine --- */
.timeline-spine {
    position: fixed;
    left: calc(8% + 55% / 2);
    top: 0;
    bottom: 0;
    width: 1px;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        var(--color-copper) 15%,
        var(--color-gold) 50%,
        var(--color-copper) 85%,
        transparent 100%
    );
    opacity: 0;
    z-index: 10;
    transition: opacity 0.8s ease;
}

.timeline-spine.visible {
    opacity: 0.2;
}

/* --- Opening Section --- */
.section--opening {
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    background: radial-gradient(ellipse at 50% 40%, #2b1810 0%, #1a1209 70%);
}

.seal--hero {
    position: absolute;
    width: clamp(250px, 40vw, 500px);
    height: clamp(250px, 40vw, 500px);
    opacity: 0;
    animation: sealFadeIn 3s ease 0.5s forwards;
}

.seal__svg {
    width: 100%;
    height: 100%;
}

@keyframes sealFadeIn {
    from { opacity: 0; transform: scale(0.9) rotate(-5deg); }
    to { opacity: 1; transform: scale(1) rotate(0deg); }
}

.seal__rays {
    animation: raysSpin 60s linear infinite;
    transform-origin: 100px 100px;
}

@keyframes raysSpin {
    to { transform: rotate(360deg); }
}

.opening__title {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(4rem, 10vw, 8rem);
    letter-spacing: 0.08em;
    color: var(--color-warm-parchment);
    opacity: 0;
    animation: titleReveal 2s ease 0.3s forwards;
    z-index: 2;
    text-align: center;
}

@keyframes titleReveal {
    from { opacity: 0; letter-spacing: 0.15em; }
    to { opacity: 1; letter-spacing: 0.08em; }
}

.opening__subtitle {
    font-family: var(--font-ui);
    font-weight: 300;
    font-size: clamp(0.75rem, 1.5vw, 1rem);
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--color-gold);
    margin-top: 1.5rem;
    opacity: 0;
    animation: subtitleFade 1.5s ease 2s forwards;
    z-index: 2;
}

@keyframes subtitleFade {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 0.7; transform: translateY(0); }
}

.opening__scroll-indicator {
    position: absolute;
    bottom: 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0;
    animation: subtitleFade 1s ease 3s forwards;
}

.scroll-line {
    display: block;
    width: 1px;
    height: 40px;
    background: linear-gradient(to bottom, var(--color-gold), transparent);
    animation: scrollPulse 2s ease-in-out infinite;
}

@keyframes scrollPulse {
    0%, 100% { opacity: 0.3; transform: scaleY(1); }
    50% { opacity: 0.7; transform: scaleY(1.3); }
}

/* --- Chapter Sections --- */
.section--chapter {
    position: relative;
    min-height: 100vh;
    padding: 10vh 5%;
    display: flex;
    gap: 2rem;
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.section--chapter.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Serpentine layout: odd left-biased, even right-biased */
.section--odd {
    flex-direction: row;
    padding-left: 8%;
    padding-right: 15%;
}

.section--even {
    flex-direction: row-reverse;
    padding-left: 15%;
    padding-right: 8%;
}

.section__content {
    flex: 0 0 55%;
    position: relative;
}

.section__seal {
    position: absolute;
    top: -2rem;
    right: -3rem;
    width: 120px;
    height: 120px;
    opacity: 0.5;
}

.seal__svg--small {
    width: 100%;
    height: 100%;
}

.section__number {
    display: block;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(0.9rem, 1.2vw, 1.1rem);
    color: var(--color-copper);
    letter-spacing: 0.15em;
    margin-bottom: 0.75rem;
    opacity: 0.6;
}

.section__heading {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.2rem, 5vw, 4rem);
    letter-spacing: 0.02em;
    color: var(--color-warm-parchment);
    margin-bottom: 2rem;
    line-height: 1.15;
}

.section__body {
    position: relative;
}

.body-text {
    font-family: var(--font-body);
    font-size: clamp(1.05rem, 1.3vw, 1.25rem);
    font-weight: 400;
    line-height: 1.8;
    color: var(--color-parchment);
    margin-bottom: 1.5rem;
    opacity: 0.85;
}

.body-text em {
    font-style: italic;
    color: var(--color-gold);
}

/* --- Margin Notes --- */
.section__margin-note {
    flex: 0 0 20%;
    padding-top: 6rem;
    align-self: flex-start;
    position: sticky;
    top: 30vh;
}

.margin-note__label {
    display: block;
    font-family: var(--font-ui);
    font-weight: 500;
    font-size: 0.65rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--color-copper);
    margin-bottom: 0.5rem;
    opacity: 0.6;
}

.margin-note__text {
    display: block;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 400;
    font-style: italic;
    line-height: 1.6;
    color: var(--color-gold);
    opacity: 0.5;
    border-left: 1px solid var(--color-copper);
    padding-left: 1rem;
}

/* --- Section Dividers (implied by background shifts) --- */
.section--odd {
    background: linear-gradient(
        135deg,
        rgba(43, 24, 16, 0.4) 0%,
        transparent 60%
    );
}

.section--even {
    background: linear-gradient(
        225deg,
        rgba(61, 43, 31, 0.3) 0%,
        transparent 60%
    );
}

/* Brass rule between chapters */
.section--chapter::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20%;
    right: 20%;
    height: 1px;
    background: linear-gradient(
        to right,
        transparent,
        var(--color-bronze) 30%,
        var(--color-gold) 50%,
        var(--color-bronze) 70%,
        transparent
    );
    opacity: 0.2;
}

/* --- Closing Section --- */
.section--closing {
    height: 60vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    background: radial-gradient(ellipse at 50% 60%, #2b1810 0%, #1a1209 70%);
}

.closing__seal {
    width: 200px;
    height: 200px;
    margin-bottom: 2rem;
    animation: sealFadeIn 2s ease forwards;
}

.seal__svg--large {
    width: 100%;
    height: 100%;
}

.closing__text {
    font-family: var(--font-ui);
    font-weight: 300;
    font-size: 0.8rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--color-gold);
    opacity: 0.4;
}

.closing__year {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.2em;
    color: var(--color-bronze);
    opacity: 0.3;
    margin-top: 0.5rem;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .section--chapter {
        flex-direction: column;
        padding: 8vh 6% 8vh 6%;
    }

    .section--odd,
    .section--even {
        flex-direction: column;
        padding-left: 6%;
        padding-right: 6%;
    }

    .section__content {
        flex: 1 1 auto;
    }

    .section__margin-note {
        flex: 1 1 auto;
        position: relative;
        top: auto;
        padding-top: 1.5rem;
        margin-top: 1rem;
        border-top: 1px solid rgba(194, 112, 58, 0.15);
    }

    .timeline-spine {
        left: 3%;
    }

    .section__seal {
        display: none;
    }
}
