/* ============================================
   hanun.ai - Scholarly Naturalism
   Korean Seowon-inspired Research Library
   ============================================ */

/* === CSS Custom Properties === */
:root {
    --inkstone-black: #12100E;
    --hanji-cream: #F5F0E8;
    --warm-charcoal: #3C3632;
    --vermillion-seal: #C8372D;
    --aged-indigo: #2E4057;
    --pine-mist: #A8B5A0;
    --ink-wash-gray: #8C8278;
    --gold-leaf: #B8963E;

    --font-display: 'Cormorant Garamond', Georgia, serif;
    --font-body: 'Lora', Georgia, serif;
    --font-mono: 'DM Mono', 'Courier New', monospace;

    --scroll-y: 0;
}

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

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

body {
    font-family: var(--font-body);
    background-color: var(--hanji-cream);
    color: var(--inkstone-black);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Paper grain texture overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    background:
        radial-gradient(ellipse at 50% 50%, transparent 60%, rgba(60,54,50,0.04) 100%);
}

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

/* === Entry Overlay === */
#entry-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--inkstone-black);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 1200ms ease;
}

#entry-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

#entry-overlay.hidden {
    display: none;
}

#entry-line {
    width: 40vw;
    height: 1px;
    background-color: var(--gold-leaf);
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 1000ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

#entry-line.animate {
    transform: scaleX(1);
}

#entry-title {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(2.2rem, 5vw, 4rem);
    letter-spacing: 0.08em;
    color: var(--hanji-cream);
    opacity: 0;
    transform: translateY(15px);
    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);
    margin-top: 20px;
}

#entry-title.animate {
    opacity: 1;
    transform: translateY(0);
}

#entry-subtitle {
    font-family: var(--font-body);
    font-style: italic;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.8vw, 1.1rem);
    color: rgba(245, 240, 232, 0.7);
    opacity: 0;
    transform: translateY(15px);
    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);
    margin-top: 12px;
}

#entry-subtitle.animate {
    opacity: 1;
    transform: translateY(0);
}

/* === Navigation === */
#main-nav {
    position: fixed;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 9000;
    display: flex;
    flex-direction: column;
    gap: 16px;
    opacity: 0;
    transition: opacity 600ms ease;
}

#main-nav.visible {
    opacity: 1;
}

.nav-link {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    text-decoration: none;
    color: var(--warm-charcoal);
    font-family: var(--font-body);
    font-weight: 600;
    font-variant: small-caps;
    font-size: clamp(0.85rem, 1.5vw, 0.95rem);
    letter-spacing: 0.14em;
    padding: 4px 8px;
    transition: color 250ms ease;
}

.nav-seal {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%) scale(0);
    width: 28px;
    height: 28px;
    background-color: var(--vermillion-seal);
    border-radius: 4px;
    opacity: 0;
    transition: transform 250ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                opacity 200ms ease;
    z-index: -1;
}

.nav-link:hover .nav-seal {
    transform: translateY(-50%) scale(1) rotate(-3deg);
    opacity: 1;
}

.nav-link:hover {
    color: var(--hanji-cream);
}

.nav-link:hover .nav-text {
    position: relative;
    z-index: 1;
}

/* === Spread Layout === */
.spread {
    position: relative;
    min-height: 100vh;
    overflow: hidden;
}

.spread-grid {
    display: grid;
    grid-template-columns: 1fr 2px 1fr;
    min-height: 100vh;
    position: relative;
    z-index: 2;
}

/* === Gutter Line === */
.gutter-line {
    background-color: rgba(60, 54, 50, 0.15);
    height: 100%;
    display: none;
}

@media (min-width: 1200px) {
    .gutter-line {
        display: block;
    }
}

.gutter-line-light {
    background-color: rgba(245, 240, 232, 0.15);
}

/* === Hero Section === */
#hero {
    position: relative;
    height: 100vh;
}

.parallax-bg {
    position: absolute;
    top: -20%;
    left: 0;
    width: 100%;
    height: 140%;
    z-index: 0;
    will-change: transform;
}

.hero-photo {
    width: 100%;
    height: 100%;
    background:
        linear-gradient(135deg,
            #1a1f15 0%,
            #0f1a0b 20%,
            #12200e 40%,
            #0a1508 60%,
            #1a2515 80%,
            #0d140a 100%
        );
    background-size: cover;
    background-position: center;
    filter: contrast(1.08) saturate(0.9) brightness(0.97);
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom,
        rgba(18,16,14,0.75) 0%,
        rgba(18,16,14,0.55) 40%,
        rgba(18,16,14,0.80) 100%
    );
}

.hero-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 60px 48px 60px 32px;
    position: relative;
    z-index: 2;
}

.hero-title {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(2.8rem, 7vw, 6rem);
    letter-spacing: -0.01em;
    color: var(--hanji-cream);
    line-height: 1.1;
    margin-bottom: 16px;
}

.hero-tagline {
    font-family: var(--font-body);
    font-style: italic;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    color: rgba(245, 240, 232, 0.7);
    line-height: 1.78;
    max-width: 38ch;
    margin-bottom: 24px;
}

.hero-intro {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    color: rgba(245, 240, 232, 0.85);
    line-height: 1.78;
    max-width: 38ch;
    margin-top: 16px;
}

/* === Folio Strip === */
.folio-strip {
    height: 48px;
    display: flex;
    align-items: center;
    padding: 0 48px;
    gap: 16px;
    background-color: var(--hanji-cream);
    position: relative;
    z-index: 5;
}

.folio-number {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: clamp(0.7rem, 1.2vw, 0.85rem);
    letter-spacing: 0.06em;
    color: var(--gold-leaf);
}

.folio-section-title {
    font-family: var(--font-body);
    font-weight: 600;
    font-variant: small-caps;
    font-size: 11px;
    letter-spacing: 0.18em;
    color: var(--warm-charcoal);
}

.folio-rule {
    flex: 1;
    height: 1px;
    background-color: rgba(60, 54, 50, 0.3);
}

/* === Content Spreads === */
.spread-content {
    background-color: var(--hanji-cream);
    position: relative;
}

.text-page {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 80px 48px;
    position: relative;
}

.image-page {
    position: relative;
    overflow: hidden;
}

.spread-image {
    width: 100%;
    height: 100%;
    min-height: 500px;
    filter: contrast(1.08) saturate(0.9) brightness(0.97);
    background-size: cover;
    background-position: center;
}

/* Photographic backgrounds using CSS gradients as placeholders */
#image-pine-forest {
    background:
        linear-gradient(160deg,
            #1a2e1a 0%,
            #2d4a2d 25%,
            #1a3a1a 45%,
            #3d5a3d 60%,
            #0f1f0f 80%,
            #1a2a1a 100%
        );
}

#image-mountain-mist {
    background:
        linear-gradient(180deg,
            #8c9aa0 0%,
            #6b7b82 15%,
            #4a5a62 30%,
            #3a4a52 50%,
            #2a3a42 70%,
            #1a2a32 85%,
            #12100E 100%
        );
}

#image-stone-path {
    background:
        linear-gradient(170deg,
            #5a5048 0%,
            #4a4038 20%,
            #3a3028 40%,
            #2a2018 60%,
            #1a1008 80%,
            #12100E 100%
        );
}

#image-bamboo-light {
    background:
        linear-gradient(150deg,
            #d4c8a8 0%,
            #8a9a70 20%,
            #5a7a40 40%,
            #3a5a20 60%,
            #2a4a10 80%,
            #1a3a08 100%
        );
}

.spread-image-fullbleed {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    filter: contrast(1.08) saturate(0.9) brightness(0.97);
    background-size: cover;
    background-position: center;
}

#image-stone-path {
    background:
        linear-gradient(170deg,
            #5a5048 0%,
            #4a4038 20%,
            #3a3028 40%,
            #2a2018 60%,
            #1a1008 80%,
            #12100E 100%
        );
}

.immersive-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom,
        rgba(18,16,14,0.7) 0%,
        rgba(18,16,14,0.5) 40%,
        rgba(18,16,14,0.75) 100%
    );
    z-index: 1;
}

.spread-immersive .spread-grid {
    position: relative;
    z-index: 2;
}

/* === Typography === */
.section-heading {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(1.6rem, 3.5vw, 2.8rem);
    letter-spacing: -0.01em;
    color: var(--inkstone-black);
    line-height: 1.2;
    margin-bottom: 20px;
}

.heading-inverted {
    color: var(--hanji-cream);
}

.body-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    line-height: 1.78;
    color: var(--inkstone-black);
    max-width: 38ch;
    margin-bottom: 20px;
}

.text-inverted {
    color: rgba(245, 240, 232, 0.9);
}

.text-page-inverted {
    color: var(--hanji-cream);
}

/* === Brush Stroke Rule === */
.brush-stroke-rule {
    width: 120px;
    height: 3px;
    background-color: rgba(140, 130, 120, 0.4);
    clip-path: polygon(0% 40%, 2% 0%, 98% 0%, 100% 40%, 98% 100%, 2% 100%);
    margin-bottom: 28px;
}

.brush-stroke-light {
    background-color: rgba(245, 240, 232, 0.4);
}

/* === Seal Mark === */
.seal-mark {
    width: 36px;
    height: 36px;
    background-color: var(--vermillion-seal);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 18px;
    color: white;
    box-shadow: 2px 2px 0 rgba(18,16,14,0.15);
    margin-bottom: 20px;
    position: relative;
}

/* === Pull Quotes === */
.pull-quote {
    position: relative;
    padding: 40px 0 20px 0;
    margin: 32px 0;
}

.pull-quote p {
    font-family: var(--font-display);
    font-weight: 400;
    font-style: italic;
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    letter-spacing: 0.02em;
    line-height: 1.35;
    color: var(--inkstone-black);
    max-width: 38ch;
    transition: color 400ms ease, transform 400ms ease;
}

.pull-quote-mark {
    position: absolute;
    top: -20px;
    left: -10px;
    font-family: var(--font-display);
    font-size: 8rem;
    color: rgba(200, 55, 45, 0.15);
    line-height: 1;
    pointer-events: none;
}

.pull-quote-large p {
    color: var(--hanji-cream);
    font-size: clamp(2rem, 4.5vw, 3.5rem);
}

.pull-quote-large .pull-quote-mark {
    color: rgba(200, 55, 45, 0.2);
}

.pull-quote-page {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    padding: 80px 48px;
}

/* Pull-quote zoom-focus effect */
.pull-quote.in-focus p {
    color: var(--inkstone-black);
    transform: scale(1);
}

.pull-quote.not-in-focus p {
    transform: scale(0.97);
}

/* === Publication Entries === */
.publication-entry {
    padding: 20px 0;
    border-bottom: 1px solid rgba(60, 54, 50, 0.12);
    margin-bottom: 4px;
}

.publication-entry:last-child {
    border-bottom: none;
}

.pub-date {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: clamp(0.7rem, 1.2vw, 0.85rem);
    letter-spacing: 0.06em;
    color: rgba(60, 54, 50, 0.6);
    display: block;
    margin-bottom: 4px;
}

.pub-title {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: clamp(1.1rem, 2vw, 1.4rem);
    color: var(--inkstone-black);
    line-height: 1.35;
    margin-bottom: 4px;
}

.pub-venue {
    font-family: var(--font-body);
    font-weight: 400;
    font-style: italic;
    font-size: clamp(0.8rem, 1.4vw, 0.9rem);
    color: var(--aged-indigo);
    line-height: 1.5;
}

/* === Botanical SVG === */
.botanical-svg {
    position: absolute;
    pointer-events: none;
    z-index: 1;
    opacity: 0.8;
}

.botanical-pine {
    width: 120px;
    right: -20px;
    top: 10%;
}

.botanical-bamboo {
    width: 100px;
    left: -10px;
    bottom: 5%;
}

.botanical-plum {
    width: 130px;
    right: 5%;
    bottom: 0;
}

.botanical-chrysanthemum-inline {
    width: 150px;
    height: 150px;
    position: relative;
    margin-top: 40px;
    opacity: 0.6;
}

.botanical-path {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 2500ms cubic-bezier(0.4, 0, 0.2, 1);
}

.botanical-path.drawn {
    stroke-dashoffset: 0;
}

.botanical-path.filled {
    fill: rgba(168, 181, 160, 0.05);
    transition: fill 500ms ease;
}

/* === Slide Reveal Animation === */
.slide-reveal {
    opacity: 0;
    transform: translateY(60px);
    transition: opacity 700ms ease-out, transform 700ms ease-out;
}

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

/* Staggered reveals */
.spread-grid .image-page.slide-reveal {
    transition-delay: 0ms;
}

.spread-grid .text-page.slide-reveal {
    transition-delay: 200ms;
}

/* === Colophon / Footer === */
#colophon {
    background-color: var(--hanji-cream);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20vh 48px;
}

.colophon-content {
    text-align: center;
    max-width: 500px;
}

.colophon-seal {
    width: 64px;
    height: 64px;
    background-color: var(--vermillion-seal);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 32px auto;
    box-shadow: 3px 3px 0 rgba(18,16,14,0.15);
}

.seal-character {
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 600;
    color: white;
}

.colophon-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    letter-spacing: -0.01em;
    color: var(--inkstone-black);
    margin-bottom: 16px;
}

.colophon-content .brush-stroke-rule {
    margin: 0 auto 28px auto;
}

.colophon-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.95rem, 1.6vw, 1.05rem);
    line-height: 1.78;
    color: var(--inkstone-black);
    margin-bottom: 40px;
}

.colophon-details {
    margin-bottom: 32px;
}

.colophon-meta {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: clamp(0.7rem, 1.2vw, 0.85rem);
    letter-spacing: 0.06em;
    color: rgba(60, 54, 50, 0.6);
    line-height: 2;
}

.colophon-line {
    width: 60px;
    height: 1px;
    background-color: var(--gold-leaf);
    margin: 0 auto;
}

/* === Responsive: Below 1200px === */
@media (max-width: 1199px) {
    .spread-grid {
        grid-template-columns: 1fr;
    }

    .gutter-line {
        display: none;
    }

    .image-page {
        min-height: 50vh;
    }

    .spread-image {
        min-height: 50vh;
    }

    .text-page {
        padding: 60px 32px;
    }

    .hero-content {
        padding: 60px 32px;
    }

    .spread-immersive .spread-grid .verso {
        padding: 60px 32px;
    }

    .pull-quote-page {
        padding: 60px 32px;
    }

    .botanical-svg {
        opacity: 0.4;
    }

    #main-nav {
        right: 12px;
    }

    .nav-text {
        display: none;
    }

    .nav-link::after {
        content: '';
        display: block;
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background-color: var(--warm-charcoal);
        transition: background-color 250ms ease;
    }

    .nav-link:hover::after {
        background-color: var(--vermillion-seal);
    }

    .nav-link:hover .nav-seal {
        display: none;
    }
}

/* === Responsive: Below 768px === */
@media (max-width: 767px) {
    .text-page {
        padding: 48px 24px;
    }

    .hero-content {
        padding: 48px 24px;
    }

    .folio-strip {
        padding: 0 24px;
    }

    .botanical-svg {
        display: none;
    }

    #main-nav {
        position: fixed;
        right: auto;
        left: 0;
        top: auto;
        bottom: 0;
        width: 100%;
        transform: none;
        flex-direction: row;
        justify-content: center;
        gap: 0;
        background-color: rgba(245, 240, 232, 0.95);
        padding: 8px 0;
        border-top: 1px solid rgba(60, 54, 50, 0.1);
    }

    .nav-link {
        padding: 8px 12px;
    }

    .nav-text {
        display: block;
        font-size: 0.7rem;
    }

    .nav-link::after {
        display: none;
    }

    .nav-seal {
        display: none;
    }

    .nav-link:hover {
        color: var(--vermillion-seal);
    }

    .pull-quote-page {
        padding: 48px 24px;
    }

    #colophon {
        padding: 15vh 24px;
    }

    .spread-immersive .spread-grid .verso {
        padding: 48px 24px;
    }
}

/* === Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
    .slide-reveal {
        opacity: 1;
        transform: none;
        transition: none;
    }

    #entry-line {
        transform: scaleX(1);
        transition: none;
    }

    #entry-title,
    #entry-subtitle {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .botanical-path {
        stroke-dasharray: none;
        stroke-dashoffset: 0;
        transition: none;
    }

    .parallax-bg {
        position: absolute;
        transform: none !important;
    }
}

/* === Dimming effect for pull-quote focus === */
.spread-content.dimmed .text-page:not(:has(.pull-quote.in-focus)),
.spread-content.dimmed .image-page {
    opacity: 0.85;
    filter: blur(1px);
    transition: opacity 400ms ease, filter 400ms ease;
}
