/* ============================================
   reiwa.bar -- Navy-Metallic Maximalist Scholarly Salon
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    /* Palette */
    --ink-navy: #0d1526;
    --deep-indigo: #141e33;
    --slate-navy: #1a2744;
    --midnight: #0b1120;
    --pearl-silver: #c8ceda;
    --silver-fog: #8a9bb5;
    --burnished-gold: #c9a84c;
    --aged-brass: #a08035;
    --pale-gold: #e8d48b;
    --steel-blue: #5b7faa;
    --candlelight-amber: #d4923a;
    --muted-vermillion: #b04a3a;

    /* Typography */
    --font-body: 'Source Serif 4', 'Georgia', serif;
    --font-display: 'Cormorant Garamond', 'Garamond', serif;
    --font-annotation: 'Alegreya Sans', 'Helvetica Neue', sans-serif;
    --font-mono: 'JetBrains Mono', 'Courier New', monospace;

    /* Sizing */
    --body-size: clamp(1rem, 1.1vw + 0.6rem, 1.15rem);
    --hero-size: clamp(2.5rem, 5.5vw, 5rem);
    --heading-size: clamp(1.6rem, 3vw, 2.4rem);

    /* Gradients */
    --metallic-shimmer: linear-gradient(135deg, #c9a84c 0%, #e8d48b 40%, #a08035 70%, #c9a84c 100%);
    --navy-depth: radial-gradient(ellipse at var(--grad-x, 30%) var(--grad-y, 40%), #1a2744 0%, #0d1526 60%, #0b1120 100%);

    /* Scroll */
    --scroll-y: 0;
}

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

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

body {
    font-family: var(--font-body);
    font-size: var(--body-size);
    font-weight: 400;
    line-height: 1.72;
    color: var(--pearl-silver);
    background-color: var(--ink-navy);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Bokeh Near (body level, static) --- */
.bokeh-near {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(circle at 15% 20%, rgba(212,146,58,0.018) 0%, transparent 50%),
        radial-gradient(circle at 75% 60%, rgba(212,146,58,0.015) 0%, transparent 50%),
        radial-gradient(circle at 50% 80%, rgba(212,146,58,0.02) 0%, transparent 50%),
        radial-gradient(circle at 30% 50%, rgba(212,146,58,0.012) 0%, transparent 50%);
}

/* --- Scroll Progress Bar --- */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 2px;
    background: var(--metallic-shimmer);
    background-size: 200% 100%;
    animation: shimmer 4s ease-in-out infinite;
    z-index: 1000;
    transition: width 0.1s linear;
}

/* --- Folio Header --- */
.folio-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 8vh;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 3vw;
    z-index: 100;
    background: linear-gradient(to bottom, rgba(13,21,38,0.95) 0%, rgba(13,21,38,0.7) 70%, transparent 100%);
    pointer-events: none;
}

.folio-title {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 0.95rem;
    letter-spacing: 0.06em;
    text-transform: lowercase;
    color: var(--pearl-silver);
    font-variant: small-caps;
}

.folio-rule {
    flex: 1;
    height: 1px;
    background-color: var(--silver-fog);
    margin: 0 2vw;
    position: relative;
    opacity: 0.4;
}

.folio-rule .diamond {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 8px;
    height: 8px;
    background-color: var(--burnished-gold);
    transform: translate(-50%, -50%) rotate(45deg);
}

.folio-section {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 0.85rem;
    letter-spacing: 0.06em;
    text-transform: lowercase;
    color: var(--silver-fog);
    font-variant: small-caps;
}

/* --- Spread Sections --- */
.spread {
    position: relative;
    min-height: 100vh;
    background: var(--navy-depth);
    scroll-snap-align: start;
    overflow: hidden;
}

/* Bokeh Far Layer */
.spread .bokeh-far {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    transform: translateY(calc(var(--scroll-y) * -0.03px));
    background:
        radial-gradient(circle at 10% 15%, rgba(232,212,139,0.04) 0%, transparent 50%),
        radial-gradient(circle at 85% 25%, rgba(232,212,139,0.035) 0%, transparent 50%),
        radial-gradient(circle at 25% 70%, rgba(232,212,139,0.045) 0%, transparent 50%),
        radial-gradient(circle at 65% 80%, rgba(232,212,139,0.03) 0%, transparent 50%),
        radial-gradient(circle at 45% 40%, rgba(232,212,139,0.05) 0%, transparent 50%),
        radial-gradient(circle at 90% 60%, rgba(232,212,139,0.04) 0%, transparent 50%),
        radial-gradient(circle at 5% 50%, rgba(232,212,139,0.035) 0%, transparent 50%),
        radial-gradient(circle at 70% 10%, rgba(232,212,139,0.04) 0%, transparent 50%);
}

/* Bokeh Mid Layer */
.spread .bokeh-mid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
    transform: translateY(calc(var(--scroll-y) * -0.06px));
    background:
        radial-gradient(circle at 20% 30%, rgba(201,168,76,0.025) 0%, transparent 50%),
        radial-gradient(circle at 70% 50%, rgba(201,168,76,0.02) 0%, transparent 50%),
        radial-gradient(circle at 40% 75%, rgba(201,168,76,0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(201,168,76,0.025) 0%, transparent 50%),
        radial-gradient(circle at 55% 60%, rgba(201,168,76,0.02) 0%, transparent 50%);
}

/* Warm Vignette overlay */
.spread::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
    background: radial-gradient(circle at var(--grad-x, 50%) var(--grad-y, 30%), rgba(212,146,58,0.06) 0%, transparent 50%);
}

/* --- Hero Spread --- */
.hero-spread {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ink-navy);
    z-index: 5;
}

.hero-candle-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0px;
    height: 0px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(212,146,58,0.15) 0%, rgba(201,168,76,0.05) 40%, transparent 70%);
    transform: translate(-50%, -50%);
    z-index: 4;
    opacity: 0;
    transition: width 1s ease-out, height 1s ease-out, opacity 0.8s ease-out;
}

.hero-candle-glow.active {
    width: 500px;
    height: 500px;
    opacity: 1;
}

.hero-content {
    position: relative;
    z-index: 10;
    text-align: center;
}

.hero-title {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: var(--hero-size);
    letter-spacing: 0.06em;
    color: var(--pearl-silver);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.hero-title.visible {
    opacity: 1;
    transform: translateY(0);
}

.hero-subtitle {
    font-family: var(--font-annotation);
    font-weight: 400;
    font-size: 1.1rem;
    color: var(--silver-fog);
    letter-spacing: 0.03em;
    margin-top: 1rem;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.8s ease-out 0.4s, transform 0.8s ease-out 0.4s;
}

.hero-subtitle.visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- Spread Grid (Magazine Layout) --- */
.spread-grid {
    position: relative;
    z-index: 10;
    display: grid;
    grid-template-columns: 5fr 3vw 5fr;
    gap: 0;
    max-width: 1400px;
    margin: 0 auto;
    padding: 12vh 3vw 8vh;
    min-height: 100vh;
    align-content: start;
}

@media (min-width: 1200px) {
    .spread-grid {
        grid-template-columns: 5fr 3vw 6fr;
    }
}

/* --- Left Page --- */
.left-page {
    padding-right: 2vw;
}

.left-page .body-text p {
    text-align: justify;
    hyphens: auto;
    -webkit-hyphens: auto;
    margin-bottom: 0;
}

.left-page .body-text p + p {
    text-indent: 1.5em;
}

/* --- Drop Cap --- */
.drop-cap-paragraph::first-letter {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 4.5em;
    float: left;
    line-height: 0.8;
    margin-right: 0.3em;
    margin-top: 0.05em;
    background: var(--metallic-shimmer);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: shimmer 4s ease-in-out infinite;
}

/* --- Headings --- */
.section-heading {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: var(--heading-size);
    letter-spacing: 0.03em;
    color: var(--pearl-silver);
    margin-bottom: 1.5rem;
    position: relative;
}

.ink-stroke-underline {
    position: relative;
    display: inline-block;
}

.ink-stroke-underline::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0%;
    height: 2px;
    background: var(--metallic-shimmer);
    background-size: 200% 100%;
    animation: shimmer 4s ease-in-out infinite;
    transition: width 1.2s ease-out;
}

.ink-stroke-underline.revealed::after {
    width: 100%;
}

/* --- Pull Quotes --- */
.pull-quote {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.8em;
    line-height: 1.35;
    color: var(--pearl-silver);
    border-left: 3px solid var(--burnished-gold);
    padding: 1em 1.5em;
    margin: 2rem 0 2rem -2vw;
    transform: rotate(-1.5deg);
    position: relative;
}

.pull-quote-mark {
    color: var(--burnished-gold);
    font-size: 1.2em;
}

.pull-quote-right {
    font-size: 1.3em;
    margin: 1.5rem 0;
    transform: rotate(0deg);
    border-left: 2px solid var(--aged-brass);
}

/* --- Gutter --- */
.gutter {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 12vh;
    gap: 1.5rem;
    position: relative;
    background-color: var(--midnight);
    border-left: 1px solid rgba(138,155,181,0.1);
    border-right: 1px solid rgba(138,155,181,0.1);
}

.gutter-candle {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.candle-icon {
    opacity: 0.6;
}

.candle-flame {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 20px;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    background: radial-gradient(ellipse at center bottom, var(--pale-gold) 0%, var(--burnished-gold) 40%, var(--candlelight-amber) 70%, transparent 100%);
    box-shadow:
        0 0 40px 10px rgba(201,168,76,0.06),
        0 0 80px 20px rgba(212,146,58,0.03);
    animation: flameFlicker 1.5s ease-in-out infinite alternate;
}

.folio-number {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--silver-fog);
    width: 28px;
    height: 28px;
    border: 1px solid var(--silver-fog);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
}

.gutter-rule {
    width: 1px;
    flex: 1;
    min-height: 100px;
    background: linear-gradient(to bottom, var(--burnished-gold) 0%, var(--aged-brass) 50%, transparent 100%);
    opacity: 0.3;
}

.wax-drip {
    width: 14px;
    height: 14px;
    border-radius: 60% 40% 55% 45% / 50% 60% 40% 50%;
    background-color: var(--aged-brass);
    opacity: 0.15;
    pointer-events: none;
    margin-bottom: 2rem;
}

/* --- Right Page --- */
.right-page {
    padding-left: 2vw;
    font-family: var(--font-annotation);
    font-size: 0.85em;
    color: var(--silver-fog);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding-top: 0;
}

.annotation {
    border-left: 2px dashed var(--silver-fog);
    padding-left: 1em;
    opacity: 0.85;
}

.annotation-label {
    font-family: var(--font-annotation);
    font-weight: 500;
    font-size: 0.85em;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--burnished-gold);
    margin-bottom: 0.3em;
}

.annotation p {
    line-height: 1.6;
}

.annotation em {
    font-style: italic;
    color: var(--pearl-silver);
}

/* --- Media Cards --- */
.media-card {
    background-color: var(--deep-indigo);
    border: 1px solid var(--slate-navy);
    padding: 8px;
    box-shadow: 4px 4px 0 0 rgba(10,17,32,0.4);
    transition: border-color 0.4s ease, box-shadow 0.4s ease;
}

.media-card:hover {
    border-color: var(--aged-brass);
    box-shadow: 6px 6px 0 0 rgba(10,17,32,0.5);
}

.media-card-inner {
    overflow: hidden;
}

.media-card-content {
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-placeholder {
    width: 100%;
    height: auto;
    display: block;
}

/* --- Data Tables --- */
.data-table {
    overflow-x: auto;
}

.data-table table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-annotation);
    font-size: 0.85em;
}

.data-table thead tr {
    background-color: var(--slate-navy);
}

.data-table th {
    font-weight: 500;
    letter-spacing: 0.02em;
    padding: 0.6em 0.8em;
    text-align: left;
    color: var(--burnished-gold);
    border-bottom: 1px solid var(--aged-brass);
    font-size: 0.9em;
    text-transform: uppercase;
}

.data-table td {
    padding: 0.5em 0.8em;
    border-bottom: 1px solid rgba(138,155,181,0.1);
    color: var(--silver-fog);
}

.data-table tbody tr:hover {
    background-color: rgba(26,39,68,0.5);
}

/* --- Spread Transition --- */
.spread-transition {
    height: 20vh;
    background: linear-gradient(to bottom, var(--ink-navy) 0%, var(--midnight) 50%, var(--ink-navy) 100%);
    position: relative;
}

.spread-transition::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
    width: 6px;
    height: 6px;
    background-color: var(--burnished-gold);
    opacity: 0.4;
}

/* --- Decorative Rules --- */
.decorative-rule {
    width: 100%;
    height: 1px;
    background-color: var(--burnished-gold);
    position: relative;
    margin: 2rem 0;
    opacity: 0.4;
}

.decorative-rule::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 8px;
    height: 8px;
    background-color: var(--burnished-gold);
    transform: translate(-50%, -50%) rotate(45deg);
}

/* --- Links --- */
a {
    color: var(--steel-blue);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
    transition: color 0.3s ease, text-decoration-color 0.3s ease;
}

a:hover {
    color: var(--pale-gold);
    text-decoration-color: var(--burnished-gold);
}

/* --- Colophon Footer --- */
.colophon {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 6vh;
    background-color: var(--midnight);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 3vw;
    z-index: 100;
    border-top: 1px solid rgba(138,155,181,0.1);
}

.colophon-domain {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    text-transform: lowercase;
    font-variant: small-caps;
    color: var(--silver-fog);
}

.colophon-rule {
    flex: 1;
    height: 1px;
    background-color: var(--silver-fog);
    margin: 0 2vw;
    opacity: 0.2;
}

.colophon-indicator {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--silver-fog);
    opacity: 0.7;
}

/* --- Shimmer Animation --- */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* --- Flame Flicker Animation --- */
@keyframes flameFlicker {
    0% {
        transform: translateX(-50%) scale(1) rotate(-2deg);
        opacity: 0.85;
    }
    25% {
        transform: translateX(-50%) scale(1.05, 1.1) rotate(1deg);
        opacity: 0.95;
    }
    50% {
        transform: translateX(-50%) scale(0.95, 1.05) rotate(-1deg);
        opacity: 0.8;
    }
    75% {
        transform: translateX(-50%) scale(1.02, 0.98) rotate(2deg);
        opacity: 0.9;
    }
    100% {
        transform: translateX(-50%) scale(1, 1.08) rotate(-1.5deg);
        opacity: 0.88;
    }
}

/* --- Section Transition Effect --- */
.spread {
    transition: transform 0.3s ease-out;
}

.spread.transitioning {
    transform: perspective(1200px) rotateX(2deg);
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    .candle-flame {
        animation: none;
        opacity: 0.8;
    }
    .drop-cap-paragraph::first-letter {
        animation: none;
        background-position: 0 0;
    }
    .ink-stroke-underline::after {
        transition: none;
        width: 100%;
    }
    .scroll-progress {
        animation: none;
    }
    .bokeh-far, .bokeh-mid {
        transform: none !important;
    }
    html {
        scroll-snap-type: none;
    }
}

/* --- Responsive: Single Column Below 768px --- */
@media (max-width: 768px) {
    .folio-header {
        position: relative;
        height: auto;
        padding: 1.5rem 5vw;
        background: var(--ink-navy);
    }

    .spread-grid {
        grid-template-columns: 1fr;
        padding: 6vh 5vw;
        gap: 0;
    }

    .gutter {
        flex-direction: row;
        padding: 2rem 0;
        gap: 1rem;
        align-items: center;
        justify-content: center;
        border-left: none;
        border-right: none;
        border-top: 1px solid rgba(138,155,181,0.1);
        border-bottom: 1px solid rgba(138,155,181,0.1);
        background-color: transparent;
        margin: 2rem 0;
    }

    .gutter-rule {
        width: 60px;
        height: 1px;
        min-height: auto;
        background: linear-gradient(to right, transparent, var(--burnished-gold), transparent);
        flex: none;
    }

    .wax-drip {
        display: none;
    }

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

    .right-page {
        padding-left: 0;
        border-left: none;
        margin-top: 0;
    }

    .right-page .annotation {
        margin-left: 1rem;
    }

    .pull-quote {
        margin-left: 0;
        transform: none;
        font-size: 1.4em;
    }

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

    .colophon {
        position: relative;
        height: auto;
        padding: 1.5rem 5vw;
    }

    .spread-transition {
        height: 10vh;
    }
}

/* --- Medium screens --- */
@media (min-width: 769px) and (max-width: 1199px) {
    .spread-grid {
        grid-template-columns: 1fr 3vw 1fr;
        padding: 10vh 3vw 8vh;
    }
}

/* --- Selection --- */
::selection {
    background-color: var(--slate-navy);
    color: var(--pale-gold);
}
