/* =============================================
   renai.moe — Herbarium Wall
   Cottagecore · Scholarly · Botanical Duotone
   ============================================= */

/* === Google Fonts Import === */
/* Loaded via <link> in HTML */

/* === CSS Custom Properties === */
:root {
    /* Palette */
    --ink:       #2c2418;    /* Deep Walnut Ink — primary dark */
    --parchment: #f5ede0;    /* Aged Parchment — primary light */
    --fern:      #8b7355;    /* Dried Fern — midtone accent */
    --leaf:      #c4a882;    /* Pressed Leaf — warm tan */
    --cream:     #e8d9c0;    /* Cream Paper — card surface */
    --bark:      #4a3728;    /* Bark Brown — dark accent / ribbon */
    --shadow:    #3a2e24;    /* Deep shadow — body text */
    --mid:       #5c3d2e;    /* Mid brown — serif headings */
    /* #ffffff reserved — avoided per DESIGN.md (use #f5ede0 minimum) */

    /* Typography */
    --font-sans:  'DM Sans', 'Inter', sans-serif;
    --font-serif: 'Cormorant Garamond', 'Georgia', serif;
    --font-mono:  'Space Mono', 'Courier New', monospace;

    /* Layout */
    --max-width: 1280px;
    --margin-col-width: 120px;
    --gutter: 16px;
    --row-gap: 20px;
    --running-head-height: 28px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--parchment);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.7;
    min-height: 100vh;
    overflow-x: hidden;
}

/* === Running Head (book header) === */
#running-head {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: var(--running-head-height);
    background-color: var(--parchment);
    border-bottom: 1px solid var(--leaf);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

#running-domain,
#running-section {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--shadow);
    letter-spacing: 0.08em;
    text-transform: lowercase;
}

#running-section {
    text-align: right;
}

/* === Opening Panel === */
#opening-panel {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--parchment);
    overflow: hidden;
    padding-top: var(--running-head-height);
}

/* Header illustration strip (200px) */
#header-illustration-wrap {
    position: absolute;
    top: var(--running-head-height);
    left: 0;
    right: 0;
    height: 200px;
    overflow: hidden;
}

#header-illustration-bg {
    position: absolute;
    inset: 0;
    background-color: var(--parchment);
}

#header-illustration-img {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#header-botanical {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
    /* Ken Burns slow zoom */
    animation: kenBurns 20s ease-in-out infinite alternate;
    /* Duotone effect via filter chain */
    filter: sepia(1) hue-rotate(10deg) saturate(0.7) brightness(0.9);
    mix-blend-mode: multiply;
}

#header-illustration-img::before {
    content: '';
    position: absolute;
    inset: 0;
    background-color: var(--fern);
    z-index: 1;
    mix-blend-mode: multiply;
    opacity: 0.35;
}

/* Fade edges of header illustration */
#header-illustration-img::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to bottom,
        transparent 40%,
        var(--parchment) 100%
    );
    z-index: 2;
}

#header-overlay {
    position: absolute;
    top: var(--running-head-height);
    left: 0;
    right: 0;
    height: 200px;
    background: linear-gradient(
        to right,
        rgba(245, 237, 224, 0.3) 0%,
        transparent 20%,
        transparent 80%,
        rgba(245, 237, 224, 0.3) 100%
    );
    z-index: 3;
    pointer-events: none;
}

/* Site name */
#site-name-wrap {
    position: relative;
    z-index: 10;
    margin-top: 110px;
    text-align: center;
    padding: 0 20px;
}

#site-name {
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: clamp(48px, 8vw, 80px);
    color: var(--ink);
    letter-spacing: -0.02em;
    text-shadow: 2px 2px 0 var(--parchment), -1px -1px 0 var(--parchment);
    line-height: 1;
}

/* Rule below header */
#header-rule {
    width: 100%;
    height: 1px;
    background-color: var(--leaf);
    position: absolute;
    bottom: 0;
    left: 0;
}

/* === Content Layout === */
#content-layout {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    gap: 0;
    padding: 40px 24px 80px;
    padding-left: 0;
}

/* === Left Margin Column === */
#margin-column {
    width: var(--margin-col-width);
    flex-shrink: 0;
    position: relative;
    padding-top: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 80px;
}

/* Binding thread — dotted vertical line */
#binding-thread {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 16px;
    width: 1px;
    border-left: 1px dashed var(--leaf);
    border-spacing: 3px;
    opacity: 0.7;
}

.margin-section-label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
}

.rotated-label {
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 400;
    color: var(--fern);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    transform: rotate(-90deg);
    white-space: nowrap;
    display: block;
}

.marginalia-mark {
    width: 40px;
    opacity: 0.6;
}

.marginalia-mark img {
    width: 100%;
    height: auto;
}

/* === Masonry Wall === */
#masonry-wall {
    flex: 1;
    columns: 3;
    column-gap: var(--gutter);
    padding: 40px 24px 0;
}

/* === Specimen Cards === */
.specimen-card {
    break-inside: avoid;
    margin-bottom: var(--row-gap);
    background-color: var(--cream);
    border: 1px solid var(--leaf);
    border-radius: var(--card-radius, 4px);
    overflow: hidden;
    position: relative;
    /* 3D perspective setup */
    transform-style: preserve-3d;
    transition: box-shadow 0.3s ease, transform 0.4s ease-out;
    cursor: default;
    will-change: transform;
}

/* Card size variants — irregular heights */
.card-tall {
    /* Tall like a hardcover novel — let content fill */
}

.card-short {
    /* Squat like a field guide */
}

.card-medium {
    /* Standard */
}

.card-panoramic {
    /* Wide / panoramic, but column-based so same width */
}

/* Illustration area */
.card-illustration-wrap {
    position: relative;
    overflow: visible; /* bleed beyond boundary */
    background-color: var(--parchment);
    clip-path: inset(0 0 -10px 0); /* allow bottom bleed */
}

.card-tall .card-illustration-wrap {
    height: 260px;
}

.card-short .card-illustration-wrap {
    height: 140px;
}

.card-medium .card-illustration-wrap {
    height: 200px;
}

.card-panoramic .card-illustration-wrap {
    height: 170px;
}

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

.card-illustration {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center top;
    /* Duotone filter: sepia → hue-rotate to push toward walnut ink range */
    filter: sepia(0.8) hue-rotate(8deg) saturate(0.75) brightness(0.92) contrast(1.05);
    /* Bleed effect: slightly overflow bottom */
    transform: translateY(8px) scale(1.04);
    transform-origin: top center;
}

/* Card body */
.card-body {
    padding: 14px 16px 20px;
    position: relative;
    background-color: var(--cream);
}

/* Specimen label tag */
.specimen-label-tag {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--fern);
    padding: 2px 7px;
    margin-bottom: 8px;
}

.tag-text {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--fern);
    letter-spacing: 0.06em;
    text-transform: lowercase;
}

/* Card title */
.card-title {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 400;
    font-size: 24px;
    color: var(--mid);
    line-height: 1.3;
    margin-bottom: 8px;
    letter-spacing: 0.01em;
}

/* Card excerpt */
.card-excerpt {
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 400;
    color: var(--shadow);
    line-height: 1.6;
    /* Max 3 lines with ellipsis */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 10px;
}

/* Card metadata */
.card-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.card-date,
.card-wordcount {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--fern);
    opacity: 0.7;
    letter-spacing: 0.04em;
}

/* Roman numeral index at bottom center */
.card-index {
    text-align: center;
    padding-top: 8px;
    border-top: 1px solid rgba(196, 168, 130, 0.4);
}

.roman-numeral {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--fern);
    opacity: 0.8;
    letter-spacing: 0.1em;
}

/* Card hover: tilt-3D handled by JS, but initial shadow here */
.specimen-card:hover {
    box-shadow:
        4px 8px 24px rgba(44, 36, 24, 0.18),
        1px 2px 6px rgba(44, 36, 24, 0.10);
}

/* Card entering animation — starts invisible, JS triggers */
.specimen-card.card-entering {
    opacity: 0;
    transform: translateY(20px);
}

.specimen-card.card-visible {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

/* === Footer Colophon === */
#colophon {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 40px 24px 60px calc(var(--margin-col-width) + 24px);
}

#colophon-rule {
    width: 100%;
    height: 1px;
    background-color: var(--leaf);
    margin-bottom: 32px;
    opacity: 0.6;
}

#colophon-inner {
    text-align: center;
}

.colophon-text {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 18px;
    color: var(--mid);
    margin-bottom: 6px;
}

.colophon-meta {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--fern);
    opacity: 0.7;
    letter-spacing: 0.06em;
    margin-bottom: 12px;
}

.colophon-year {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--fern);
    opacity: 0.5;
    letter-spacing: 0.12em;
}

/* === Floating Reading Ribbon === */
#reading-ribbon {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 200;
    width: 180px;
    background-color: var(--bark);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Start off-screen right, JS will slide in */
    transform: translateX(220px);
    opacity: 0;
    transition: transform 0.6s ease-out, opacity 0.6s ease-out;
    box-shadow: 0 4px 20px rgba(44, 36, 24, 0.35);
}

#reading-ribbon.ribbon-visible {
    transform: translateX(0);
    opacity: 1;
}

#ribbon-close {
    position: absolute;
    top: 6px;
    right: 8px;
    background: none;
    border: none;
    font-size: 16px;
    color: var(--fern);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    z-index: 1;
}

#ribbon-illustration {
    width: 100%;
    height: 80px;
    overflow: hidden;
    background-color: var(--parchment);
    display: flex;
    align-items: center;
    justify-content: center;
}

#ribbon-illustration img {
    width: 60px;
    height: 80px;
    object-fit: contain;
    filter: sepia(0.6) hue-rotate(5deg) saturate(0.8) brightness(0.85);
}

#ribbon-content {
    padding: 10px 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#ribbon-label {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--fern);
    letter-spacing: 0.08em;
    text-transform: lowercase;
    opacity: 0.9;
}

#ribbon-title {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 14px;
    color: var(--parchment);
    line-height: 1.3;
}

#ribbon-author {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--leaf);
    letter-spacing: 0.05em;
    opacity: 0.8;
}

/* === Animations === */

/* Ken Burns on header botanical */
@keyframes kenBurns {
    0%   { transform: scale(1.0); }
    100% { transform: scale(1.03); }
}

/* === Responsive === */
@media (max-width: 1024px) {
    #masonry-wall {
        columns: 2;
    }

    #margin-column {
        width: 80px;
    }

    :root {
        --margin-col-width: 80px;
    }
}

@media (max-width: 640px) {
    #masonry-wall {
        columns: 1;
        padding: 20px 16px 0;
    }

    #margin-column {
        display: none;
    }

    #content-layout {
        padding-left: 0;
    }

    #site-name {
        font-size: clamp(36px, 10vw, 56px);
    }

    #colophon {
        padding-left: 24px;
    }

    #reading-ribbon {
        width: 160px;
        bottom: 16px;
        right: 16px;
    }
}
