/* =========================================================
   munju.wiki — An Encyclopedia of Firsts
   Editorial reference clarity with retro vintage warmth.
   ========================================================= */

:root {
    --c-bg: #fdf6e3;          /* Archive Cream */
    --c-text: #2c2c2c;        /* Index Black */
    --c-accent: #bf4040;      /* Archive Red */
    --c-link: #3b5998;        /* Reference Blue */
    --c-card: #f0e6d0;        /* Card Parchment */
    --c-faded: #8b7d6b;       /* Faded Ink */
    --c-line: #d4c4a8;        /* Timeline Line */

    --font-display: "Vollkorn", Georgia, "Times New Roman", serif;
    --font-body: "Merriweather Sans", "Helvetica Neue", Arial, sans-serif;
    --font-mono: "Courier Prime", "Courier New", monospace;

    --sidebar-w: 240px;
    --content-max: 720px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    background: var(--c-bg);
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 0.9rem;
    line-height: 1.75;
    color: var(--c-text);
    background: var(--c-bg);
    background-image:
        radial-gradient(ellipse at top left, rgba(212, 196, 168, 0.18), transparent 60%),
        radial-gradient(ellipse at bottom right, rgba(191, 64, 64, 0.05), transparent 60%);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---------- Page grid ---------- */
.page {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

/* ===========================================================
   Sidebar
   =========================================================== */
.sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    background: var(--c-card);
    border-right: 1px solid var(--c-line);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-inner {
    padding: 2rem 1.6rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    min-height: 100%;
}

/* ----- Brand ----- */
.brand {
    border-bottom: 1px solid var(--c-line);
    padding-bottom: 1.5rem;
}

.brand-mark {
    display: inline-flex;
    gap: 4px;
    margin-bottom: 0.9rem;
}

.brand-glyph {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--c-accent);
    color: var(--c-accent);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: 2px;
    background: var(--c-bg);
}

.brand-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.5rem;
    line-height: 1.1;
    color: var(--c-text);
    letter-spacing: -0.01em;
}

.brand-dot {
    color: var(--c-accent);
}

.brand-tag {
    margin-top: 0.4rem;
    font-family: var(--font-body);
    font-size: 0.78rem;
    color: var(--c-faded);
    font-style: italic;
    line-height: 1.4;
}

.brand-meta {
    margin-top: 0.6rem;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--c-faded);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* ----- Era nav ----- */
.era-nav-title,
.stats-title {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--c-faded);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    margin-bottom: 0.9rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px dashed var(--c-line);
}

.era-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.era-link {
    display: grid;
    grid-template-columns: 22px 1fr;
    grid-template-rows: auto auto;
    column-gap: 6px;
    padding: 0.55rem 0.5rem 0.55rem 0.4rem;
    text-decoration: none;
    color: var(--c-faded);
    font-variant: small-caps;
    letter-spacing: 0.1em;
    border-left: 2px solid transparent;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
    border-radius: 0 2px 2px 0;
}

.era-link:hover {
    color: var(--c-text);
    background: rgba(212, 196, 168, 0.35);
}

.era-link.active {
    color: var(--c-accent);
    border-left-color: var(--c-accent);
    background: rgba(191, 64, 64, 0.06);
}

.era-link.active .era-name {
    font-weight: 600;
}

.era-num {
    grid-row: 1 / span 2;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--c-accent);
    letter-spacing: 0;
    align-self: center;
}

.era-name {
    grid-column: 2;
    grid-row: 1;
    font-family: var(--font-body);
    font-size: 0.86rem;
    line-height: 1.2;
}

.era-range {
    grid-column: 2;
    grid-row: 2;
    font-family: var(--font-mono);
    font-size: 0.66rem;
    color: var(--c-faded);
    letter-spacing: 0.04em;
    text-transform: none;
    font-variant: normal;
}

/* ----- Archive stats ----- */
.archive-stats {
    border-top: 1px solid var(--c-line);
    padding-top: 1.5rem;
}

.stats-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: 1px dotted var(--c-line);
    padding-bottom: 0.35rem;
    gap: 0.5rem;
}

.stat-row dt {
    font-family: var(--font-body);
    font-size: 0.78rem;
    color: var(--c-faded);
}

.stat-row dd {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--c-text);
    text-align: right;
}

/* ----- Sidebar footer ----- */
.sidebar-footer {
    margin-top: auto;
    padding-top: 1.2rem;
    border-top: 1px solid var(--c-line);
    font-family: var(--font-mono);
    font-size: 0.66rem;
    color: var(--c-faded);
    text-align: center;
    letter-spacing: 0.06em;
    line-height: 1.6;
}

.sidebar-footer .ref-code {
    margin-top: 0.4rem;
    color: var(--c-accent);
    letter-spacing: 0.18em;
}

/* ===========================================================
   Content
   =========================================================== */
.content {
    padding: 4rem 3rem 5rem;
    max-width: calc(var(--content-max) + 6rem);
    width: 100%;
}

/* ----- Content header ----- */
.content-header {
    margin-bottom: 3.5rem;
    border-bottom: 1px solid var(--c-line);
    padding-bottom: 2rem;
    max-width: var(--content-max);
}

.overline {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--c-accent);
    letter-spacing: 0.22em;
    text-transform: uppercase;
    margin-bottom: 0.6rem;
}

.page-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    line-height: 1.15;
    letter-spacing: -0.01em;
    color: var(--c-text);
    margin-bottom: 0.9rem;
}

.page-lede {
    font-family: var(--font-body);
    font-size: 0.98rem;
    line-height: 1.75;
    color: var(--c-text);
    max-width: 60ch;
    font-weight: 300;
}

/* ----- Search ----- */
.search-shell {
    margin-top: 2rem;
}

.search {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    background: var(--c-bg);
    border: 1px solid var(--c-line);
    border-radius: 3px;
    padding: 0.7rem 0.9rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search:focus-within {
    border-color: var(--c-accent);
    box-shadow: 0 0 0 3px rgba(191, 64, 64, 0.08);
}

.search-icon {
    color: var(--c-faded);
    display: inline-flex;
    align-items: center;
}

.search:focus-within .search-icon {
    color: var(--c-accent);
}

.search-input {
    flex: 1;
    border: none;
    background: transparent;
    font-family: var(--font-body);
    font-size: 0.92rem;
    color: var(--c-text);
    outline: none;
    padding: 0;
}

.search-input::placeholder {
    color: var(--c-faded);
    font-style: italic;
}

.search-hint {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--c-faded);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    white-space: nowrap;
    padding-left: 0.7rem;
    border-left: 1px solid var(--c-line);
}

.search-empty {
    margin-top: 0.9rem;
    padding: 0.9rem 1rem;
    background: rgba(191, 64, 64, 0.06);
    border: 1px dashed var(--c-accent);
    border-radius: 3px;
    color: var(--c-accent);
    font-size: 0.85rem;
    font-style: italic;
}

.search-empty[hidden] {
    display: none;
}

/* ===========================================================
   Era sections
   =========================================================== */
.era-section {
    margin-bottom: 4rem;
    max-width: var(--content-max);
    scroll-margin-top: 1rem;
}

.era-section.dimmed > .timeline > .timeline-entry:not(.match) {
    display: none;
}

.era-section.no-match {
    display: none;
}

.era-heading {
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    align-items: baseline;
    gap: 0.9rem;
    margin-bottom: 2rem;
}

.era-roman {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--c-accent);
    letter-spacing: 0.12em;
}

.era-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.6rem;
    color: var(--c-text);
    letter-spacing: 0.02em;
}

.era-rule {
    height: 1px;
    background: var(--c-line);
    align-self: center;
}

.era-range-label {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--c-faded);
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

/* ===========================================================
   Timeline
   =========================================================== */
.timeline {
    position: relative;
    padding-left: 60px;
    list-style: none;
}

/* The vertical line */
.timeline::before {
    content: "";
    position: absolute;
    left: 20px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background: var(--c-line);
}

.timeline-entry {
    position: relative;
    margin-bottom: 1.5rem;
}

.timeline-entry:last-child {
    margin-bottom: 0;
}

/* Date marker dot — positioned on the line at left:14px from .timeline */
.timeline-dot {
    position: absolute;
    left: -46px;
    top: 0.85rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--c-accent);
    border: 2px solid var(--c-bg);
    box-shadow: 0 0 0 1px var(--c-line);
    z-index: 2;
    transition: transform 0.25s ease, background 0.25s ease;
}

.timeline-entry:hover .timeline-dot {
    transform: scale(1.25);
    background: #a83232;
}

.timeline-date {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--c-faded);
    letter-spacing: 0.04em;
    margin-bottom: 0.4rem;
    padding-left: 0.1rem;
}

/* ----- Entry card ----- */
.entry-card {
    background: var(--c-card);
    border: 1px solid var(--c-line);
    border-radius: 4px;
    padding: 1.5rem;
    box-shadow: 0 1px 0 rgba(212, 196, 168, 0.5);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.timeline-entry:hover .entry-card {
    border-color: var(--c-faded);
    box-shadow: 0 2px 0 rgba(139, 125, 107, 0.4), 0 0 0 1px rgba(212, 196, 168, 0.5);
    transform: translateX(2px);
}

.entry-head {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    margin-bottom: 0.6rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px dashed var(--c-line);
}

.first-badge {
    display: inline-block;
    color: var(--c-accent);
    border: 1px solid var(--c-accent);
    border-radius: 2px;
    padding: 0.1rem 0.4rem;
    font-size: 0.65rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    font-family: var(--font-body);
    font-weight: 600;
    background: rgba(191, 64, 64, 0.04);
}

.entry-cat {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--c-faded);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.entry-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(1.5rem, 3.5vw, 2.4rem);
    line-height: 1.2;
    color: var(--c-text);
    margin: 0.4rem 0 0.4rem;
    letter-spacing: -0.005em;
}

.entry-meta {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    color: var(--c-faded);
    letter-spacing: 0.04em;
    margin-bottom: 0.9rem;
}

.meta-sep {
    margin: 0 0.35rem;
    color: var(--c-line);
}

.entry-body {
    font-family: var(--font-body);
    font-size: 0.92rem;
    line-height: 1.75;
    color: var(--c-text);
    margin-bottom: 0.8rem;
}

.entry-body em {
    color: var(--c-link);
    font-style: italic;
}

.entry-body code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--c-bg);
    border: 1px solid var(--c-line);
    padding: 0.05rem 0.35rem;
    border-radius: 2px;
    color: var(--c-link);
}

.entry-sig {
    font-family: var(--font-body);
    font-size: 0.84rem;
    line-height: 1.65;
    color: var(--c-faded);
    border-top: 1px solid var(--c-line);
    padding-top: 0.7rem;
    font-style: italic;
}

.sig-label {
    font-family: var(--font-display);
    font-style: normal;
    font-weight: 600;
    color: var(--c-text);
    margin-right: 0.25rem;
    font-variant: small-caps;
    letter-spacing: 0.05em;
}

/* highlighted search match */
.entry-card mark {
    background: rgba(191, 64, 64, 0.18);
    color: var(--c-text);
    padding: 0 2px;
    border-radius: 1px;
}

/* ===========================================================
   Footer
   =========================================================== */
.content-footer {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--c-line);
    max-width: var(--content-max);
    text-align: center;
}

.colophon-line {
    width: 80px;
    height: 1px;
    background: var(--c-accent);
    margin: 0 auto 1.5rem;
}

.colophon {
    font-family: var(--font-body);
    font-size: 0.84rem;
    line-height: 1.8;
    color: var(--c-faded);
    font-style: italic;
    max-width: 56ch;
    margin: 0 auto 1.5rem;
}

.colophon-label {
    font-family: var(--font-display);
    font-style: normal;
    font-weight: 600;
    font-variant: small-caps;
    letter-spacing: 0.06em;
    color: var(--c-text);
    margin-right: 0.2rem;
}

.swatch-inline {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin: 0 1px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    vertical-align: baseline;
}

.ref-code-footer {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--c-accent);
    letter-spacing: 0.22em;
    text-transform: uppercase;
}

/* ===========================================================
   To-top button
   =========================================================== */
.to-top {
    position: fixed;
    right: 2rem;
    bottom: 2rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.5rem 0.85rem;
    background: var(--c-card);
    border: 1px solid var(--c-line);
    color: var(--c-faded);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: 3px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity 0.25s ease, transform 0.25s ease, color 0.2s ease, border-color 0.2s ease;
}

.to-top.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.to-top:hover {
    color: var(--c-accent);
    border-color: var(--c-accent);
}

/* ===========================================================
   Responsive
   =========================================================== */
@media (max-width: 900px) {
    .page {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: relative;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--c-line);
    }

    .sidebar-inner {
        gap: 1.5rem;
        padding: 1.6rem 1.4rem;
    }

    .content {
        padding: 2.5rem 1.6rem 4rem;
    }

    .timeline {
        padding-left: 36px;
    }

    .timeline::before {
        left: 8px;
    }

    .timeline-dot {
        left: -34px;
    }

    .era-heading {
        grid-template-columns: auto auto 1fr;
    }

    .era-range-label {
        grid-column: 1 / -1;
        margin-top: -0.3rem;
    }
}

@media (max-width: 480px) {
    .content {
        padding: 2rem 1.1rem 3rem;
    }

    .entry-card {
        padding: 1.2rem;
    }

    .to-top {
        right: 1rem;
        bottom: 1rem;
    }
}
