:root {
    /* Ethereal Blue Marble Palette */
    --bg-deep: #0a0e1a;
    --bg-surface: #131829;
    --text-primary: #e8ecf4;
    --accent-blue: #6b8cce;
    --accent-azure: #a3b8d8;
    --accent-gold: #c4a96a;
    --marble-vein: #d4dae8;
    --error-red: #c85a5a;

    /* Spacing based on golden ratio */
    --base: 1rem;
    --phi: 1.618;
    --space-sm: calc(var(--base) * 0.618);
    --space-md: var(--base);
    --space-lg: calc(var(--base) * 1.618);
    --space-xl: calc(var(--base) * 2.618);
    --space-xxl: calc(var(--base) * 4.236);
}

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

html {
    scroll-behavior: smooth;
    scroll-snap-type: y proximity;
}

body {
    background-color: var(--bg-deep);
    color: var(--text-primary);
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.25rem);
    letter-spacing: 0.01em;
    line-height: 1.72;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* ============================
   SECTION BASE
   ============================ */

.section {
    position: relative;
    width: 100vw;
    min-height: 100vh;
    overflow: hidden;
    scroll-snap-align: start;
}

.section--armory {
    background-color: var(--bg-deep);
}

.section--arsenal {
    background-color: var(--bg-surface);
}

.section--thesis {
    background-color: var(--bg-deep);
}

.section--proof {
    background-color: var(--bg-surface);
}

.section--seal {
    background-color: var(--bg-deep);
}

/* ============================
   MARBLE OVERLAY
   ============================ */

.marble-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background:
        linear-gradient(23deg, transparent 48%, rgba(212, 218, 232, 0.04) 49%, rgba(212, 218, 232, 0.04) 49.5%, transparent 50%),
        linear-gradient(67deg, transparent 47%, rgba(212, 218, 232, 0.03) 48%, rgba(212, 218, 232, 0.03) 48.8%, transparent 49%),
        linear-gradient(41deg, transparent 49%, rgba(212, 218, 232, 0.05) 49.5%, rgba(212, 218, 232, 0.05) 50%, transparent 50.5%),
        linear-gradient(73deg, transparent 46%, rgba(212, 218, 232, 0.02) 47%, rgba(212, 218, 232, 0.02) 47.5%, transparent 48%),
        linear-gradient(15deg, transparent 50%, rgba(212, 218, 232, 0.035) 50.5%, rgba(212, 218, 232, 0.035) 51%, transparent 51.5%),
        linear-gradient(55deg, transparent 48.5%, rgba(212, 218, 232, 0.025) 49%, rgba(212, 218, 232, 0.025) 49.3%, transparent 49.8%);
    animation: vein-shift 20s ease-in-out infinite alternate;
}

@keyframes vein-shift {
    0% {
        background-position: 0 0, 0 0, 0 0, 0 0, 0 0, 0 0;
    }
    100% {
        background-position: 3px 2px, -2px 3px, 1px -1px, -3px 2px, 2px -2px, -1px 1px;
    }
}

/* ============================
   MANUSCRIPT GRID
   ============================ */

.manuscript-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent calc(1.618rem * 1.5 - 1px),
            rgba(212, 218, 232, 0.03) calc(1.618rem * 1.5 - 1px),
            rgba(212, 218, 232, 0.03) calc(1.618rem * 1.5)
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent calc(100vw * 0.382 - 1px),
            rgba(212, 218, 232, 0.02) calc(100vw * 0.382 - 1px),
            rgba(212, 218, 232, 0.02) calc(100vw * 0.382)
        );
}

/* ============================
   SECTION CONTENT
   ============================ */

.section-content {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: var(--space-xxl);
}

.section-content--split {
    flex-direction: row;
    align-items: stretch;
}

.section-content--split-reverse {
    flex-direction: row;
    align-items: stretch;
}

.section-content--centered {
    align-items: center;
    text-align: center;
}

/* ============================
   TYPOGRAPHY
   ============================ */

.section-heading {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 600;
    font-size: clamp(3rem, 7vw, 6.5rem);
    letter-spacing: 0.02em;
    line-height: 1.05;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
}

.section-label {
    font-family: 'Zen Kaku Gothic New', sans-serif;
    font-weight: 500;
    font-size: clamp(0.75rem, 0.9vw, 0.875rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    line-height: 1.4;
    color: var(--accent-azure);
    margin-bottom: var(--space-md);
}

.body-text {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.25rem);
    letter-spacing: 0.01em;
    line-height: 1.72;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
    max-width: 55ch;
}

.body-text:last-child {
    margin-bottom: 0;
}

.label-text {
    font-family: 'Zen Kaku Gothic New', sans-serif;
    font-weight: 500;
    font-size: clamp(0.75rem, 0.9vw, 0.875rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    line-height: 1.4;
    color: var(--accent-azure);
}

/* ============================
   SECTION 1: THE ARMORY (HERO)
   ============================ */

.section--armory .section-content {
    align-items: flex-end;
    justify-content: flex-end;
    padding-bottom: 10vh;
}

.hero-divider {
    position: absolute;
    top: 61.8%;
    left: 20vw;
    width: 60vw;
    height: 1px;
    background-color: rgba(232, 236, 244, 0.3);
}

.hero-kanji-wrap {
    width: 76.4%;
    max-width: 800px;
}

.hero-kanji-svg {
    width: 100%;
    height: auto;
}

.kanji-stroke {
    font-family: 'Zen Kaku Gothic New', sans-serif;
    font-size: 180px;
    font-weight: 500;
    fill: none;
    stroke: var(--text-primary);
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
}

.kanji-fill {
    font-family: 'Zen Kaku Gothic New', sans-serif;
    font-size: 180px;
    font-weight: 500;
    fill: var(--text-primary);
    opacity: 0;
}

/* Kanji stroke animation */
.kanji-char--1 .kanji-stroke { animation: brush-draw 2.4s 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards; }
.kanji-char--2 .kanji-stroke { animation: brush-draw 2.4s 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards; }
.kanji-char--3 .kanji-stroke { animation: brush-draw 2.4s 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards; }
.kanji-char--4 .kanji-stroke { animation: brush-draw 2.4s 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards; }

.kanji-char--1 .kanji-fill { animation: brush-fill 0.4s 2.7s ease forwards; }
.kanji-char--2 .kanji-fill { animation: brush-fill 0.4s 3.0s ease forwards; }
.kanji-char--3 .kanji-fill { animation: brush-fill 0.4s 3.3s ease forwards; }
.kanji-char--4 .kanji-fill { animation: brush-fill 0.4s 3.6s ease forwards; }

@keyframes brush-draw {
    0% { stroke-dashoffset: 800; }
    100% { stroke-dashoffset: 0; }
}

@keyframes brush-fill {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

.hero-romanized {
    margin-top: var(--space-lg);
    text-align: right;
}

.hanko-corner {
    position: absolute;
    top: var(--space-xxl);
    left: var(--space-xxl);
}

.hanko-small {
    width: 48px;
    height: 48px;
}

/* ============================
   SECTION 2: THE ARSENAL
   ============================ */

.arsenal-left {
    width: 38.2%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-xxl);
}

.arsenal-right {
    width: 61.8%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vertical-text-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3em;
    margin-bottom: var(--space-xl);
}

.vertical-char {
    font-family: 'Zen Kaku Gothic New', sans-serif;
    font-size: clamp(1.5rem, 2.5vw, 2.5rem);
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.3;
    letter-spacing: 0;
}

.manuscript-illustration {
    width: 80%;
    max-width: 500px;
    height: auto;
}

/* ============================
   SECTION 3: THE THESIS
   ============================ */

.section--thesis .section-content {
    align-items: flex-end;
}

.thesis-text-block {
    width: 40%;
    padding-right: var(--space-xxl);
}

/* ============================
   SECTION 4: THE PROOF
   ============================ */

.proof-left {
    width: 35%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: var(--space-xxl);
}

.proof-right {
    width: 65%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.shield-illustration {
    width: 70%;
    max-width: 400px;
    height: auto;
}

/* ============================
   SECTION 5: THE SEAL (FOOTER)
   ============================ */

.seal-content {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hanko-large {
    width: 200px;
    height: 200px;
    margin-bottom: var(--space-xl);
}

.seal-domain {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 600;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    letter-spacing: 0.02em;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
}

.seal-statement {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.1vw, 1.1rem);
    font-style: italic;
    color: var(--accent-azure);
    letter-spacing: 0.01em;
}

/* ============================
   ANIMATIONS - SLIDE IN / FADE
   ============================ */

.slide-in-left {
    opacity: 0;
    transform: translateX(-60px);
    transition: opacity 800ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 800ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.slide-in-right {
    opacity: 0;
    transform: translateX(60px);
    transition: opacity 800ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 800ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.fade-in-delayed {
    opacity: 0;
    transition: opacity 600ms ease;
    transition-delay: 200ms;
}

.slide-in-left.is-visible,
.slide-in-right.is-visible {
    opacity: 1;
    transform: translateX(0);
}

.fade-in-delayed.is-visible {
    opacity: 1;
}

/* ============================
   SHAKE ERROR ANIMATION
   ============================ */

@keyframes shake-error {
    0%, 100% { transform: translateX(0); }
    10% { transform: translateX(-4px); }
    20% { transform: translateX(4px); }
    30% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    50% { transform: translateX(-3px); }
    60% { transform: translateX(3px); }
    70% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
    90% { transform: translateX(-1px); }
}

.section.is-shaking .section-content {
    animation: shake-error 400ms ease-in-out;
}

.section.is-shaking .section-heading,
.section.is-shaking .hero-kanji-wrap {
    animation: opacity-pulse 400ms ease-in-out;
}

@keyframes opacity-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ============================
   NOISE OVERLAY
   ============================ */

.section::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    filter: url(#marble-noise);
    opacity: 0.15;
    mix-blend-mode: soft-light;
    pointer-events: none;
    z-index: 1;
}

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

@media (max-width: 768px) {
    .section-content {
        padding: var(--space-lg);
    }

    .section-content--split,
    .section-content--split-reverse {
        flex-direction: column;
    }

    .arsenal-left,
    .arsenal-right,
    .proof-left,
    .proof-right {
        width: 100%;
    }

    .arsenal-left {
        padding: var(--space-lg);
        flex-direction: row;
        align-items: center;
        gap: var(--space-lg);
    }

    .vertical-text-column {
        flex-direction: row;
        flex-wrap: wrap;
        margin-bottom: 0;
    }

    .thesis-text-block {
        width: 100%;
        padding-right: 0;
    }

    .section--armory .section-content {
        align-items: center;
        justify-content: center;
        padding-bottom: var(--space-xxl);
    }

    .hero-kanji-wrap {
        width: 95%;
    }

    .hero-romanized {
        text-align: center;
    }

    .hanko-corner {
        top: var(--space-lg);
        left: var(--space-lg);
    }

    .hero-divider {
        left: 10vw;
        width: 80vw;
    }

    .section--thesis .section-content {
        align-items: center;
    }

    .proof-right {
        padding: var(--space-lg);
    }
}
