/* ==========================================================================
   reiwa.boo - Dark Academia / Meiji-era Library
   ========================================================================== */

:root {
    /* Palette */
    --bg-parchment-dark: #1C1915;
    --surface-folio: #272320;
    --text-primary: #D4C8B0;
    --text-secondary: #8A7E6B;
    --accent-warm: #C4873B;
    --accent-cool: #2E3F6E;
    --highlight: #E8C87A;
    --mountain-slate: #4A5568;

    /* Typography */
    --font-display: 'Cormorant Garamond', 'Georgia', serif;
    --font-body: 'Source Serif 4', 'Georgia', serif;
    --font-caption: 'Alegreya Sans SC', 'Helvetica Neue', sans-serif;

    /* Spacing (24px baseline grid) */
    --baseline: 1.5rem; /* 24px */
    --manuscript-width: 680px;
    --manuscript-offset: 8%;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-parchment-dark);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.15vw, 1.2rem);
    line-height: 1.75;
    letter-spacing: 0.005em;
    overflow-x: hidden;
}

/* ==========================================================================
   Mountain Sigil Navigation
   ========================================================================== */

#sigil-nav {
    position: fixed;
    top: calc(var(--baseline) * 1.5);
    left: calc(var(--baseline) * 1.5);
    z-index: 100;
    background: rgba(28, 25, 21, 0.7);
    border: none;
    border-radius: 50%;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 400ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                box-shadow 400ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

#sigil-nav:hover {
    transform: scale(1.15);
    box-shadow: 0 0 16px rgba(196, 135, 59, 0.35);
}

#sigil-nav svg {
    width: 28px;
    height: 28px;
}

/* ==========================================================================
   Marginal Navigation (Desktop)
   ========================================================================== */

#marginal-nav {
    position: fixed;
    right: calc(var(--baseline) * 2);
    top: 50%;
    transform: translateY(-50%);
    z-index: 90;
    display: none;
}

@media (min-width: 769px) {
    #marginal-nav {
        display: block;
    }
}

#marginal-nav ul {
    list-style: none;
}

#marginal-nav li {
    margin-bottom: var(--baseline);
}

#marginal-nav a {
    font-family: var(--font-caption);
    font-weight: 500;
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-secondary);
    text-decoration: none;
    padding-left: 12px;
    border-left: 2px solid transparent;
    transition: color 400ms ease, border-color 400ms ease, text-shadow 400ms ease;
    display: block;
}

#marginal-nav a:hover {
    color: var(--text-primary);
}

#marginal-nav a.active {
    color: var(--highlight);
    border-left-color: var(--accent-warm);
    text-shadow: 0 0 8px rgba(196, 135, 59, 0.3);
}

/* ==========================================================================
   Hero Section
   ========================================================================== */

#hero {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Mountain background - CSS generated */
.hero-mountain-overlay {
    position: absolute;
    inset: 0;
    background:
        /* Mountain silhouette layers */
        linear-gradient(175deg, transparent 30%, var(--accent-cool) 55%, var(--bg-parchment-dark) 80%),
        /* Base dark */
        linear-gradient(180deg, #0d0b09 0%, var(--accent-cool) 40%, var(--bg-parchment-dark) 100%);
    background-attachment: fixed;
    z-index: 1;
}

@media (max-width: 768px) {
    .hero-mountain-overlay {
        background-attachment: scroll;
    }
}

/* Mountain ridgeline glow */
.hero-ridgeline {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

.hero-ridgeline::before {
    content: '';
    position: absolute;
    top: 38%;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(
        90deg,
        transparent 5%,
        var(--accent-warm) 15%,
        transparent 25%,
        var(--accent-warm) 35%,
        transparent 45%,
        var(--accent-warm) 55%,
        transparent 65%,
        var(--accent-warm) 75%,
        transparent 85%,
        var(--accent-warm) 90%,
        transparent 95%
    );
    filter: blur(6px);
    opacity: 0.6;
    clip-path: polygon(
        0% 50%,
        5% 55%,
        12% 40%,
        20% 60%,
        28% 30%,
        35% 50%,
        42% 20%,
        50% 10%,
        58% 25%,
        65% 45%,
        72% 35%,
        78% 55%,
        85% 40%,
        92% 60%,
        100% 50%
    );
}

.hero-ridgeline::after {
    content: '';
    position: absolute;
    top: 38%;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent 5%,
        var(--accent-warm) 15%,
        transparent 25%,
        var(--accent-warm) 35%,
        transparent 45%,
        var(--accent-warm) 55%,
        transparent 65%,
        var(--accent-warm) 75%,
        transparent 85%,
        var(--accent-warm) 90%,
        transparent 95%
    );
    opacity: 0.9;
    clip-path: polygon(
        0% 50%,
        5% 55%,
        12% 40%,
        20% 60%,
        28% 30%,
        35% 50%,
        42% 20%,
        50% 10%,
        58% 25%,
        65% 45%,
        72% 35%,
        78% 55%,
        85% 40%,
        92% 60%,
        100% 50%
    );
}

/* Hero Content */
.hero-content {
    position: relative;
    z-index: 5;
    text-align: center;
    padding: 0 var(--baseline);
}

.hero-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(3.5rem, 10vw, 8rem);
    letter-spacing: -0.02em;
    line-height: 1.05;
    color: var(--text-primary);
    mix-blend-mode: soft-light;
    text-shadow: 0 0 40px rgba(196, 135, 59, 0.15);
    will-change: opacity, transform;
}

.hero-subtitle {
    font-family: var(--font-caption);
    font-weight: 500;
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-top: var(--baseline);
}

.hero-fade-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 30vh;
    background: linear-gradient(to bottom, transparent, var(--bg-parchment-dark));
    z-index: 3;
    pointer-events: none;
}

/* ==========================================================================
   Folio Sections
   ========================================================================== */

.folio {
    position: relative;
    min-height: 80vh;
    padding: calc(var(--baseline) * 6) 0;
    background-color: var(--bg-parchment-dark);
    overflow: hidden;
}

.folio-inner {
    position: relative;
    max-width: var(--manuscript-width);
    margin-left: calc(50% - var(--manuscript-width) / 2 - var(--manuscript-offset));
    padding: 0 calc(var(--baseline) * 1.5);
    z-index: 2;
}

@media (max-width: 768px) {
    .folio-inner {
        margin-left: auto;
        margin-right: auto;
        max-width: 90%;
    }
}

/* Folio Numeral Watermark */
.folio-numeral {
    position: absolute;
    top: calc(var(--baseline) * 4);
    left: calc(50% - var(--manuscript-width) / 2 - var(--manuscript-offset) - 4rem);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 6rem;
    color: var(--text-secondary);
    opacity: 0.08;
    line-height: 1;
    z-index: 1;
    pointer-events: none;
    user-select: none;
}

@media (max-width: 768px) {
    .folio-numeral {
        left: 1rem;
        font-size: 4rem;
    }
}

/* Folio Title */
.folio-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(2rem, 5vw, 3.5rem);
    letter-spacing: -0.02em;
    line-height: 1.05;
    color: var(--text-primary);
    margin-bottom: calc(var(--baseline) * 2);
}

/* Folio Content */
.folio-content p {
    margin-bottom: var(--baseline);
    color: var(--text-primary);
}

.folio-content em {
    font-style: italic;
    color: var(--highlight);
}

/* Ruled Lines */
.ruled-line {
    width: 100%;
    height: 1px;
    background-color: var(--text-secondary);
    opacity: 0.3;
    margin: calc(var(--baseline) * 1.5) 0;
}

/* Foxing Marks */
.foxing-marks {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.foxing-mark {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, var(--text-secondary) 0%, transparent 70%);
    opacity: 0.15;
}

/* Folio fade-in animation */
.folio-inner,
.plate-content {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 800ms ease-out, transform 800ms ease-out;
}

.folio-inner.visible,
.plate-content.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ==========================================================================
   Plate Sections (Full-width dividers)
   ========================================================================== */

.plate {
    position: relative;
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--surface-folio);
    overflow: hidden;
}

.plate-content {
    position: relative;
    z-index: 5;
    text-align: center;
    padding: calc(var(--baseline) * 4) calc(var(--baseline) * 2);
    max-width: 800px;
}

/* Pull Quotes */
.pull-quote {
    position: relative;
    transform: scale(0.97);
    transition: transform 400ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.pull-quote:hover {
    transform: scale(1.0);
}

.pull-quote p {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    line-height: 1.3;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.quote-mark {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(3rem, 6vw, 5rem);
    color: var(--accent-warm);
    line-height: 0.5;
    display: block;
    text-shadow: 0 0 12px rgba(196, 135, 59, 0.4);
    transition: text-shadow 400ms ease;
}

.pull-quote:hover .quote-mark {
    text-shadow: 0 0 20px rgba(196, 135, 59, 0.65);
}

.quote-mark-close {
    text-align: right;
    margin-top: calc(var(--baseline) * 0.5);
}

/* Plate Mountain Visual */
.plate-mountain {
    min-height: 80vh;
}

.plate-mountain-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg,
        #0d0b09 0%,
        var(--accent-cool) 35%,
        var(--mountain-slate) 55%,
        var(--surface-folio) 80%,
        var(--bg-parchment-dark) 100%
    );
    z-index: 1;
}

.plate-mountain-ridgeline {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

.plate-mountain-ridgeline::before {
    content: '';
    position: absolute;
    top: 42%;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(
        90deg,
        transparent 2%,
        var(--accent-warm) 10%,
        transparent 20%,
        var(--accent-warm) 30%,
        transparent 40%,
        var(--accent-warm) 48%,
        var(--accent-warm) 52%,
        transparent 60%,
        var(--accent-warm) 70%,
        transparent 80%,
        var(--accent-warm) 88%,
        transparent 98%
    );
    filter: blur(6px);
    opacity: 0.5;
    clip-path: polygon(
        0% 60%,
        8% 50%,
        15% 55%,
        22% 35%,
        30% 50%,
        38% 25%,
        45% 15%,
        50% 5%,
        55% 15%,
        62% 30%,
        70% 45%,
        78% 35%,
        85% 50%,
        92% 45%,
        100% 55%
    );
}

.plate-mountain-ridgeline::after {
    content: '';
    position: absolute;
    top: 42%;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent 2%,
        var(--accent-warm) 10%,
        transparent 20%,
        var(--accent-warm) 30%,
        transparent 40%,
        var(--accent-warm) 48%,
        var(--accent-warm) 52%,
        transparent 60%,
        var(--accent-warm) 70%,
        transparent 80%,
        var(--accent-warm) 88%,
        transparent 98%
    );
    opacity: 0.8;
    clip-path: polygon(
        0% 60%,
        8% 50%,
        15% 55%,
        22% 35%,
        30% 50%,
        38% 25%,
        45% 15%,
        50% 5%,
        55% 15%,
        62% 30%,
        70% 45%,
        78% 35%,
        85% 50%,
        92% 45%,
        100% 55%
    );
}

.plate-mountain-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 30%, var(--bg-parchment-dark) 95%);
    z-index: 3;
}

.plate-caption {
    font-family: var(--font-caption);
    font-weight: 500;
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

/* Plate Sigil Divider */
.plate-sigil {
    min-height: 30vh;
    background-color: var(--bg-parchment-dark);
}

.mountain-divider {
    width: 120px;
    height: auto;
    opacity: 0.5;
}

/* Final Plate */
.plate-final {
    min-height: 50vh;
    background-color: var(--bg-parchment-dark);
    flex-direction: column;
}

.final-domain {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(2rem, 5vw, 4rem);
    letter-spacing: -0.02em;
    line-height: 1.05;
    color: var(--text-primary);
    margin-bottom: var(--baseline);
}

.final-tagline {
    font-family: var(--font-caption);
    font-weight: 500;
    font-size: 1.5rem;
    letter-spacing: 0.2em;
    color: var(--text-secondary);
}

/* ==========================================================================
   Scale-Hover Interactions
   ========================================================================== */

.folio-content p {
    transform: scale(1);
    transition: transform 400ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ==========================================================================
   Link Styles
   ========================================================================== */

a {
    color: var(--highlight);
    text-decoration: none;
    transition: color 300ms ease, box-shadow 300ms ease;
}

a:hover {
    color: var(--accent-warm);
    box-shadow: 0 0 8px rgba(196, 135, 59, 0.3);
}

/* ==========================================================================
   Scrollbar Styling
   ========================================================================== */

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-parchment-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--mountain-slate);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ==========================================================================
   Mobile Adjustments
   ========================================================================== */

@media (max-width: 480px) {
    .hero-subtitle {
        font-size: 0.65rem;
    }

    .folio {
        padding: calc(var(--baseline) * 3) 0;
    }

    .plate {
        min-height: 50vh;
    }

    .plate-mountain {
        min-height: 60vh;
    }

    .pull-quote p {
        font-size: clamp(1.2rem, 4vw, 1.8rem);
    }

    .quote-mark {
        font-size: clamp(2rem, 8vw, 3.5rem);
    }
}

@media (max-width: 768px) {
    #marginal-nav {
        display: none;
    }

    .hero-title {
        mix-blend-mode: normal;
    }
}
