/* ============================================================
   hwagryul.com — Light-Academia Archival Design
   Palette: Vellum White, Warm Linen, Aged Parchment,
            Bibliophile Brown, Reading Sepia, Foxed Brass,
            Gilt Edge, Library Burgundy, Vellum Shadow
   Fonts: Cormorant Garamond, Source Serif 4, EB Garamond
   ============================================================ */

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

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

body {
    background-color: #faf6ee;
    color: #3a2e22;
    font-family: 'Source Serif 4', 'Georgia', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.72;
    letter-spacing: 0.005em;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Navigation --- */
#site-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background-color: #faf6ee;
    border-bottom: 1px solid #d4c8b4;
    transition: height 0.4s ease, backdrop-filter 0.4s ease, background-color 0.4s ease;
    height: 64px;
}

#site-nav.scrolled {
    height: 48px;
    background-color: rgba(250, 246, 238, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.nav-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 clamp(20px, 3vw, 48px);
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-title {
    font-family: 'EB Garamond', 'Georgia', serif;
    font-variant: small-caps;
    font-feature-settings: 'smcp', 'onum';
    font-size: 1.1rem;
    letter-spacing: 0.12em;
    color: #3a2e22;
    text-decoration: none;
    transition: color 0.4s ease;
}

.nav-title:hover {
    color: #c4a055;
}

.nav-links {
    list-style: none;
    display: flex;
    gap: clamp(16px, 2.5vw, 36px);
}

.nav-links li a {
    font-family: 'Source Serif 4', 'Georgia', serif;
    font-size: 0.85rem;
    font-weight: 400;
    color: #6b5d4e;
    text-decoration: none;
    letter-spacing: 0.005em;
    position: relative;
    background-image: linear-gradient(#c4a055, #c4a055);
    background-size: 0% 1px;
    background-repeat: no-repeat;
    background-position: 0 100%;
    transition: color 0.35s ease, background-size 0.35s ease;
}

.nav-links li a:hover {
    color: #3a2e22;
    background-size: 100% 1px;
}

/* --- Frontispiece (Hero) --- */
.frontispiece {
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #faf6ee;
    position: relative;
    overflow: hidden;
}

.frontispiece-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

.frontispiece-content.fade-out {
    transform: translateY(-30vh);
    opacity: 0;
}

.hero-rule {
    width: 200px;
    height: 1px;
    background-color: #a89070;
    margin-bottom: 32px;
    transform: scaleX(0);
    transition: transform 0.9s cubic-bezier(0.33, 0, 0.2, 1);
}

.hero-rule.animate {
    transform: scaleX(1);
}

.hero-title {
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-weight: 600;
    font-size: clamp(2.8rem, 7vw, 6rem);
    color: #3a2e22;
    letter-spacing: -0.015em;
    line-height: 1.15;
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 1.1s ease, transform 1.1s ease;
}

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

.hero-subtitle {
    font-family: 'Source Serif 4', 'Georgia', serif;
    font-weight: 300;
    font-size: 1rem;
    color: #6b5d4e;
    letter-spacing: 0.08em;
    margin-top: 16px;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.hero-subtitle.animate {
    opacity: 1;
}

.hero-fleuron {
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-size: 2rem;
    color: #a89070;
    opacity: 0;
    margin-top: 24px;
    transition: opacity 0.8s ease;
}

.hero-fleuron.animate {
    opacity: 0.25;
}

.scroll-hint {
    position: absolute;
    bottom: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    opacity: 0;
    transition: opacity 1s ease;
}

.scroll-hint.animate {
    opacity: 0.4;
}

.scroll-hint-text {
    font-family: 'EB Garamond', 'Georgia', serif;
    font-variant: small-caps;
    font-feature-settings: 'smcp';
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    color: #a89070;
}

.scroll-hint-line {
    width: 1px;
    height: 32px;
    background-color: #a89070;
    animation: scrollPulse 2s ease-in-out infinite;
}

@keyframes scrollPulse {
    0%, 100% { opacity: 0.2; transform: scaleY(0.6); }
    50% { opacity: 0.6; transform: scaleY(1); }
}

/* --- Section Ornament (Fleuron between clusters) --- */
.section-ornament {
    text-align: center;
    padding: 7.5vh 0;
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-size: 2rem;
    color: #a89070;
    opacity: 0.3;
    transition: opacity 0.6s ease, color 0.6s ease;
}

.section-ornament:hover {
    opacity: 0.5;
    color: #c4a055;
}

/* --- Double Rule --- */
.double-rule {
    width: 60%;
    max-width: 600px;
    margin: 0 auto;
    padding: 4px 0;
    position: relative;
}

.double-rule::before,
.double-rule::after {
    content: '';
    display: block;
    height: 1px;
    background-color: #a89070;
    opacity: 0.4;
}

.double-rule::before {
    margin-bottom: 4px;
}

/* --- Bento Cluster --- */
.bento-cluster {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 clamp(20px, 3vw, 48px);
    min-height: 85vh;
}

/* --- Bento Grid (First Folio) --- */
.bento-grid-first {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-auto-rows: minmax(120px, auto);
    gap: clamp(12px, 1.5vw, 24px);
}

/* Folio Cell: 3col x 2row */
.folio-cell {
    grid-column: 1 / 4;
    grid-row: 1 / 3;
    min-height: 360px;
}

/* Spine Cells */
.bento-grid-first .spine-cell:nth-of-type(2) {
    grid-column: 4 / 5;
    grid-row: 1 / 3;
}

.bento-grid-first .spine-cell:nth-of-type(3) {
    grid-column: 5 / 6;
    grid-row: 1 / 3;
}

/* Bookplate Cells */
.bento-grid-first .bookplate-cell:nth-of-type(4) {
    grid-column: 6 / 7;
    grid-row: 1 / 2;
}

.bento-grid-first .bookplate-cell:nth-of-type(5) {
    grid-column: 6 / 7;
    grid-row: 2 / 3;
}

/* Spine Cell 3 */
.bento-grid-first .spine-cell:nth-of-type(6) {
    grid-column: 6 / 7;
    grid-row: 1 / 3;
    display: none;
}

/* Marginalia Strip: 6col x 1row */
.bento-grid-first .marginalia-strip {
    grid-column: 1 / 7;
    grid-row: 3 / 4;
}

/* --- Bento Grid (Second — Marginalia Section) --- */
.bento-grid-second {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-auto-rows: minmax(100px, auto);
    gap: clamp(12px, 1.5vw, 24px);
}

/* Row 1: two bookplate-sm + spine + wide-folio starts */
.bento-grid-second .bookplate-cell-sm:nth-of-type(1) {
    grid-column: 1 / 3;
    grid-row: 1 / 2;
}

.bento-grid-second .bookplate-cell-sm:nth-of-type(2) {
    grid-column: 3 / 5;
    grid-row: 1 / 2;
}

.bento-grid-second .spine-cell:nth-of-type(3) {
    grid-column: 5 / 6;
    grid-row: 1 / 3;
}

/* Wide Folio Cell: 4col x 1row */
.wide-folio-cell {
    grid-column: 1 / 5;
    grid-row: 2 / 3;
    min-height: 240px;
}

/* Row 3: bookplate-sm + spine + bookplate-sm + spine */
.bento-grid-second .bookplate-cell-sm:nth-of-type(5) {
    grid-column: 1 / 3;
    grid-row: 3 / 4;
}

.bento-grid-second .spine-cell:nth-of-type(6) {
    grid-column: 3 / 4;
    grid-row: 3 / 4;
}

.bento-grid-second .bookplate-cell-sm:nth-of-type(7) {
    grid-column: 4 / 6;
    grid-row: 3 / 4;
}

.bento-grid-second .spine-cell:nth-of-type(8) {
    grid-column: 6 / 7;
    grid-row: 1 / 4;
}

/* Marginalia Strip */
.bento-grid-second .marginalia-strip {
    grid-column: 1 / 7;
    grid-row: 4 / 5;
}

/* --- Bento Cell Base --- */
.bento-cell {
    background-color: #f0e8d8;
    position: relative;
    overflow: hidden;
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.6s cubic-bezier(0.25, 0.1, 0.25, 1),
                transform 0.6s cubic-bezier(0.25, 0.1, 0.25, 1),
                box-shadow 0.4s ease;
    box-shadow: 0 2px 12px #d8cebb33;
}

.bento-cell.visible {
    opacity: 1;
    transform: translateY(0);
}

.bento-cell:hover {
    box-shadow: 0 4px 20px #d8cebb55;
    background-color: #e4d8c4;
}

/* --- Folio Cell --- */
.folio-cell {
    background-color: #f7f2e8;
}

.folio-overlay {
    width: 100%;
    height: 100%;
    padding: 16px;
}

.folio-inner-border {
    width: 100%;
    height: 100%;
    border: 1px solid #a89070;
    padding: clamp(20px, 3vw, 40px);
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    transition: border-color 0.4s ease;
}

.folio-cell:hover .folio-inner-border,
.wide-folio-cell:hover .folio-inner-border {
    border-color: #c4a055;
}

.folio-text {
    font-family: 'Source Serif 4', 'Georgia', serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    line-height: 1.72;
    color: #3a2e22;
    margin-bottom: 1em;
}

.folio-text-secondary {
    font-family: 'Source Serif 4', 'Georgia', serif;
    font-weight: 300;
    font-size: clamp(0.88rem, 1vw, 1rem);
    line-height: 1.72;
    color: #6b5d4e;
}

/* --- Drop Capital --- */
.drop-capital {
    float: left;
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-weight: 700;
    font-size: 3.8em;
    line-height: 0.78;
    color: #6e2c3a;
    margin-right: 0.15em;
    margin-top: 0.05em;
    shape-outside: margin-box;
    opacity: 0;
    transform: scale(1.3) translateY(-8px);
    transition: opacity 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
                transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.drop-capital.animate {
    opacity: 1;
    transform: scale(1) translateY(0);
}

/* --- Spine Cell --- */
.spine-cell {
    background-color: #f7f2e8;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    position: relative;
    border-left: 1px solid transparent;
    transition: border-color 0.3s ease, background-color 0.4s ease, box-shadow 0.4s ease;
}

.spine-cell-alt {
    background-color: #ede6d6;
}

.spine-cell:hover {
    border-left-color: #c4a055;
}

.spine-label {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-family: 'EB Garamond', 'Georgia', serif;
    font-variant: small-caps;
    font-feature-settings: 'smcp', 'onum';
    font-size: 0.9rem;
    letter-spacing: 0.12em;
    color: #6b5d4e;
    transition: color 0.3s ease;
}

.spine-cell:hover .spine-label {
    color: #3a2e22;
}

/* --- Bookplate Cell --- */
.bookplate-cell,
.bookplate-cell-sm {
    padding: clamp(16px, 2vw, 28px);
    background-color: #f0e8d8;
}

.bookplate-border {
    width: 100%;
    height: 100%;
    border: 1px double #b8a898;
    padding: clamp(14px, 1.5vw, 24px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
}

.bookplate-stamp {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #f0e8d8;
    border: 1px double #a89070;
    padding: 4px 12px;
    margin-bottom: 12px;
    align-self: flex-start;
}

.bookplate-stamp span {
    font-family: 'EB Garamond', 'Georgia', serif;
    font-variant: small-caps;
    font-feature-settings: 'smcp', 'onum';
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    color: #6b5d4e;
}

.bookplate-quote {
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(1.05rem, 1.5vw, 1.3rem);
    line-height: 1.5;
    color: #3a2e22;
    margin-bottom: 8px;
}

.bookplate-cite {
    font-family: 'Source Serif 4', 'Georgia', serif;
    font-size: 0.8rem;
    font-weight: 300;
    color: #6b5d4e;
    font-style: normal;
}

.cell-body {
    font-family: 'Source Serif 4', 'Georgia', serif;
    font-weight: 400;
    font-size: clamp(0.88rem, 1vw, 0.95rem);
    line-height: 1.65;
    color: #3a2e22;
}

/* --- Wide Folio Cell --- */
.wide-folio-cell {
    background-color: #f7f2e8;
    padding: 16px;
}

.wide-folio-cell .folio-inner-border {
    padding: clamp(20px, 2.5vw, 36px);
}

/* --- Marginal Annotation --- */
.marginal-annotation {
    position: absolute;
    right: -4px;
    top: 50%;
    transform: translateY(-50%) rotate(-2deg);
    font-family: 'EB Garamond', 'Georgia', serif;
    font-style: italic;
    font-size: 0.75rem;
    color: #6b5d4e;
    opacity: 0.5;
    cursor: help;
    transition: opacity 0.3s ease;
}

.marginal-annotation:hover {
    opacity: 0.85;
}

.marginal-annotation::after {
    content: attr(data-annotation);
    position: absolute;
    right: 16px;
    top: -8px;
    width: 200px;
    padding: 8px 12px;
    background-color: #f0e8d8;
    border: 1px solid #b8a898;
    font-family: 'EB Garamond', 'Georgia', serif;
    font-style: italic;
    font-size: 0.72rem;
    color: #6b5d4e;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    line-height: 1.5;
    z-index: 10;
}

.marginal-annotation:hover::after {
    opacity: 1;
}

/* --- Marginalia Strip --- */
.marginalia-strip {
    background-color: #faf6ee;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: clamp(12px, 1.5vw, 20px) clamp(16px, 2vw, 32px);
    border-top: 1px solid #d4c8b4;
    border-bottom: 1px solid #d4c8b4;
}

.marginalia-text {
    font-family: 'Source Serif 4', 'Georgia', serif;
    font-weight: 300;
    font-size: 0.82rem;
    color: #6b5d4e;
    font-style: italic;
}

.marginalia-divider {
    color: #a89070;
    font-size: 0.8rem;
    opacity: 0.5;
}

/* --- Colophon (Footer) --- */
.colophon {
    min-height: 50vh;
    background-color: #f0e8d8;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(48px, 8vh, 96px) clamp(20px, 5vw, 80px);
    margin-top: 7.5vh;
}

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

.colophon-fleuron {
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-size: 1.6rem;
    color: #a89070;
    opacity: 0.35;
    margin-bottom: 20px;
}

.colophon-content .colophon-fleuron:last-child {
    margin-bottom: 0;
    margin-top: 20px;
}

.colophon-title {
    font-family: 'EB Garamond', 'Georgia', serif;
    font-variant: small-caps;
    font-feature-settings: 'smcp', 'onum';
    font-size: 1.2rem;
    letter-spacing: 0.15em;
    color: #3a2e22;
    margin-bottom: 16px;
}

.colophon-double-rule {
    width: 120px;
    margin: 20px auto;
    position: relative;
    padding: 4px 0;
}

.colophon-double-rule::before,
.colophon-double-rule::after {
    content: '';
    display: block;
    height: 1px;
    background-color: #a89070;
    opacity: 0.4;
}

.colophon-double-rule::before {
    margin-bottom: 4px;
}

.colophon-text {
    font-family: 'Source Serif 4', 'Georgia', serif;
    font-weight: 300;
    font-size: 0.9rem;
    line-height: 1.72;
    color: #6b5d4e;
    margin-bottom: 12px;
}

.colophon-domain {
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-weight: 600;
    font-size: 1.4rem;
    color: #3a2e22;
    letter-spacing: -0.015em;
    margin-top: 8px;
}

.colophon-year {
    font-family: 'EB Garamond', 'Georgia', serif;
    font-variant: small-caps;
    font-feature-settings: 'smcp', 'onum';
    font-size: 0.85rem;
    letter-spacing: 0.2em;
    color: #a89070;
    margin-top: 8px;
}

/* --- Link Hover Effect (Global) --- */
a {
    color: #3a2e22;
    text-decoration: none;
    transition: color 0.4s ease;
}

a:hover {
    color: #c4a055;
}

/* --- All Color Transitions --- */
* {
    transition-timing-function: ease;
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .bento-grid-first {
        grid-template-columns: repeat(3, 1fr);
        grid-auto-rows: minmax(100px, auto);
    }

    .folio-cell {
        grid-column: 1 / 4;
        grid-row: 1 / 2;
        min-height: 300px;
    }

    .bento-grid-first .spine-cell:nth-of-type(2) {
        grid-column: 1 / 2;
        grid-row: 2 / 3;
    }

    .bento-grid-first .spine-cell:nth-of-type(3) {
        grid-column: 2 / 3;
        grid-row: 2 / 3;
    }

    .bento-grid-first .bookplate-cell:nth-of-type(4) {
        grid-column: 3 / 4;
        grid-row: 2 / 3;
    }

    .bento-grid-first .bookplate-cell:nth-of-type(5) {
        grid-column: 1 / 4;
        grid-row: 3 / 4;
    }

    .bento-grid-first .marginalia-strip {
        grid-column: 1 / 4;
        grid-row: 4 / 5;
    }

    .bento-grid-second {
        grid-template-columns: repeat(3, 1fr);
    }

    .bento-grid-second .bookplate-cell-sm:nth-of-type(1) {
        grid-column: 1 / 2;
        grid-row: 1 / 2;
    }

    .bento-grid-second .bookplate-cell-sm:nth-of-type(2) {
        grid-column: 2 / 4;
        grid-row: 1 / 2;
    }

    .bento-grid-second .spine-cell:nth-of-type(3) {
        grid-column: 3 / 4;
        grid-row: 2 / 3;
    }

    .wide-folio-cell {
        grid-column: 1 / 3;
        grid-row: 2 / 3;
    }

    .bento-grid-second .bookplate-cell-sm:nth-of-type(5) {
        grid-column: 1 / 2;
        grid-row: 3 / 4;
    }

    .bento-grid-second .spine-cell:nth-of-type(6) {
        grid-column: 2 / 3;
        grid-row: 3 / 4;
    }

    .bento-grid-second .bookplate-cell-sm:nth-of-type(7) {
        grid-column: 3 / 4;
        grid-row: 3 / 4;
    }

    .bento-grid-second .spine-cell:nth-of-type(8) {
        display: none;
    }

    .bento-grid-second .marginalia-strip {
        grid-column: 1 / 4;
        grid-row: 4 / 5;
    }

    .nav-links {
        gap: 12px;
    }
}

@media (max-width: 600px) {
    .bento-grid-first,
    .bento-grid-second {
        grid-template-columns: 1fr;
        grid-auto-rows: auto;
    }

    .folio-cell,
    .bento-grid-first .spine-cell:nth-of-type(2),
    .bento-grid-first .spine-cell:nth-of-type(3),
    .bento-grid-first .bookplate-cell:nth-of-type(4),
    .bento-grid-first .bookplate-cell:nth-of-type(5),
    .bento-grid-first .marginalia-strip {
        grid-column: 1 / -1;
        grid-row: auto;
    }

    .bento-grid-second .bookplate-cell-sm:nth-of-type(1),
    .bento-grid-second .bookplate-cell-sm:nth-of-type(2),
    .bento-grid-second .spine-cell:nth-of-type(3),
    .wide-folio-cell,
    .bento-grid-second .bookplate-cell-sm:nth-of-type(5),
    .bento-grid-second .spine-cell:nth-of-type(6),
    .bento-grid-second .bookplate-cell-sm:nth-of-type(7),
    .bento-grid-second .spine-cell:nth-of-type(8),
    .bento-grid-second .marginalia-strip {
        grid-column: 1 / -1;
        grid-row: auto;
    }

    .spine-cell {
        min-height: 80px;
    }

    .spine-label {
        writing-mode: horizontal-tb;
    }

    .nav-links {
        display: none;
    }

    #site-nav {
        height: 48px;
    }

    .folio-cell {
        min-height: 280px;
    }

    .wide-folio-cell {
        min-height: 200px;
    }
}
