/* lugubrious.dev — A Memorial to Broken Software
   Dark academia × sepia history. Mournful, literary, dignified. */

:root {
    --primary: #1a1818;
    --secondary: #2a2626;
    --text: #c8bfb0;
    --accent: #8b5e3c;
    --dim: #5a5450;
    --vignette: rgba(0, 0, 0, 0.4);
    --highlight: #d4a574;

    --display: "Cormorant Garamond", "Cormorant", Lora, Georgia, "Times New Roman", serif;
    --body: "Crimson Text", "Lora", Georgia, "Times New Roman", serif;
    --meta: "Karla", "Inter", system-ui, sans-serif;
}

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

html {
    background-color: var(--primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: var(--body);
    font-size: 1rem;
    line-height: 1.85;
    color: var(--text);
    background-color: var(--primary);
    background-image:
        radial-gradient(circle at 20% 10%, rgba(139, 94, 60, 0.05), transparent 55%),
        radial-gradient(circle at 80% 90%, rgba(139, 94, 60, 0.04), transparent 60%);
    background-attachment: fixed;
    overflow-x: hidden;
    min-height: 100vh;
}

/* A faint paper grain — pure CSS noise via tiny dotted gradients */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        radial-gradient(rgba(200, 191, 176, 0.025) 1px, transparent 1px),
        radial-gradient(rgba(200, 191, 176, 0.015) 1px, transparent 1px);
    background-size: 3px 3px, 7px 7px;
    background-position: 0 0, 1px 2px;
    mix-blend-mode: overlay;
    z-index: 1;
    opacity: 0.6;
}

main, footer {
    position: relative;
    z-index: 2;
}

/* ----------------------------- The Elegy (Hero) ----------------------------- */

.elegy {
    background: var(--primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 4rem 1.5rem 6rem;
    text-align: center;
    overflow: hidden;
}

.elegy::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 40%, transparent 30%, rgba(0, 0, 0, 0.4) 100%);
    pointer-events: none;
}

.elegy-inner {
    position: relative;
    z-index: 2;
    max-width: 60ch;
    margin-top: -10vh;
    padding: 0 1rem;
    animation: flicker 3s ease-in-out infinite;
}

.elegy-overline {
    font-family: var(--meta);
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0.4em;
    text-transform: uppercase;
    color: var(--dim);
    margin-bottom: 2.5rem;
}

.elegy-title {
    font-family: var(--display);
    font-weight: 600;
    font-size: clamp(2.4rem, 6vw, 4.6rem);
    color: var(--text);
    letter-spacing: 0.08em;
    line-height: 1.05;
    text-shadow: 0 2px 24px rgba(0, 0, 0, 0.6);
}

.elegy-title .dot {
    color: var(--accent);
    font-style: italic;
    padding: 0 0.04em;
}

.elegy-aphorism {
    font-family: var(--display);
    font-style: italic;
    font-weight: 400;
    font-size: clamp(1rem, 1.6vw, 1.25rem);
    color: var(--dim);
    margin-top: 1.4rem;
    letter-spacing: 0.02em;
}

.elegy-meta {
    font-family: var(--meta);
    font-size: 0.75rem;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: var(--dim);
    margin-top: 2.2rem;
    opacity: 0.75;
}

.elegy-year {
    color: var(--accent);
}

.elegy-scroll-hint {
    position: absolute;
    bottom: 2.4rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.7rem;
    font-family: var(--meta);
    font-size: 0.7rem;
    letter-spacing: 0.3em;
    text-transform: lowercase;
    color: var(--dim);
}

.elegy-rule {
    width: 1px;
    height: 48px;
    background: linear-gradient(to bottom, var(--dim), transparent);
    animation: drip 3.6s ease-in-out infinite;
}

/* ------------------------ Ornamental rules (dividers) ----------------------- */

.ornamental-rule {
    border: none;
    height: 1px;
    background-color: var(--dim);
    opacity: 0.4;
    width: min(76%, 1100px);
    margin: 5rem auto;
    position: relative;
}

.ornamental-rule::before,
.ornamental-rule::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 9px;
    height: 9px;
    background: var(--primary);
    border: 1px solid var(--accent);
    transform: translate(-50%, -50%) rotate(45deg);
    left: 50%;
}

.ornamental-rule::after {
    width: 3px;
    height: 3px;
    background: var(--accent);
    border: none;
    transform: translate(-50%, -50%) rotate(45deg);
}

.ornamental-rule.small {
    width: min(40%, 320px);
    margin: 3rem auto;
}

/* ------------------------- The Catalogue of Errors ------------------------- */

.catalogue {
    padding: 5rem 1.5rem 4rem;
}

.catalogue-header {
    margin-left: 12vw;
    max-width: 60ch;
    margin-bottom: 4rem;
}

.catalogue-eyebrow,
.readings-eyebrow,
.vigil-eyebrow,
.ledger-eyebrow,
.memorial-eyebrow {
    font-family: var(--meta);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.42em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 1rem;
}

.catalogue-heading,
.readings-heading,
.vigil-heading,
.ledger-heading,
.memorial-heading {
    font-family: var(--display);
    font-weight: 600;
    font-size: clamp(1.8rem, 3.4vw, 2.6rem);
    color: var(--text);
    letter-spacing: 0.04em;
    line-height: 1.15;
    margin-bottom: 1.2rem;
}

.catalogue-heading::before {
    content: "\2020";
    color: var(--accent);
    font-family: var(--display);
    margin-right: 0.5rem;
    font-style: italic;
}

.catalogue-lede,
.readings-foot,
.vigil-lede,
.memorial-lede {
    font-family: var(--body);
    font-size: 1.05rem;
    font-style: italic;
    color: var(--dim);
    max-width: 56ch;
}

.entries {
    list-style: none;
}

.entry {
    margin-left: 12vw;
    margin-right: max(8vw, 2rem);
    padding: 2rem 0;
    border-bottom: 1px solid rgba(90, 84, 80, 0.3);
    max-width: 60ch;
    transition: padding-left 0.5s ease, opacity 0.5s ease, transform 0.5s ease;
    opacity: 0.55;
    transform: translateY(8px);
}

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

.entry:hover {
    padding-left: 0.6rem;
}

.entry-date {
    font-family: var(--meta);
    font-size: 0.78rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--dim);
    margin-bottom: 0.6rem;
}

.entry-title {
    font-family: var(--display);
    font-weight: 600;
    font-size: 1.55rem;
    color: var(--text);
    letter-spacing: 0.02em;
    line-height: 1.25;
    margin-bottom: 0.9rem;
}

.entry-title::before {
    content: "\2020 ";
    color: var(--accent);
    font-style: italic;
    margin-right: 0.35rem;
}

.entry-body {
    font-family: var(--body);
    font-weight: 400;
    font-size: 1.05rem;
    line-height: 1.85;
    color: var(--text);
}

.entry-tags {
    margin-top: 1rem;
    font-family: var(--meta);
    font-size: 0.72rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--dim);
}

.entry-tags em {
    color: var(--accent);
    font-style: italic;
    font-weight: 500;
}

/* --------------------------- Readings (aphorisms) -------------------------- */

.readings {
    padding: 4rem 1.5rem;
    background-color: var(--secondary);
    border-top: 1px solid rgba(90, 84, 80, 0.25);
    border-bottom: 1px solid rgba(90, 84, 80, 0.25);
}

.readings-inner {
    max-width: 60ch;
    margin-left: 12vw;
}

.readings-list {
    list-style: none;
    margin: 2rem 0 1.2rem;
}

.readings-list li {
    font-family: var(--display);
    font-style: italic;
    font-weight: 400;
    font-size: 1.2rem;
    line-height: 1.7;
    color: var(--text);
    padding: 0.9rem 0 0.9rem 2rem;
    position: relative;
    border-bottom: 1px dashed rgba(90, 84, 80, 0.22);
    transition: color 0.6s ease, transform 0.6s ease;
}

.readings-list li::before {
    content: "\2020";
    position: absolute;
    left: 0;
    top: 0.95rem;
    color: var(--accent);
    font-family: var(--display);
    font-style: normal;
    font-size: 1.2rem;
}

.readings-list li:last-child {
    border-bottom: none;
}

.readings-list li.is-current {
    color: var(--highlight);
    transform: translateX(0.4rem);
}

.readings-foot {
    font-family: var(--meta);
    font-size: 0.78rem;
    font-style: italic;
    color: var(--dim);
    letter-spacing: 0.08em;
    margin-top: 1rem;
}

/* ------------------------------- The Vigil --------------------------------- */

.vigil {
    padding: 5rem 1.5rem;
}

.vigil-inner {
    margin-left: 12vw;
    margin-right: max(8vw, 2rem);
    max-width: 64ch;
}

.vigil-frame {
    margin-top: 2.4rem;
    padding: 2.4rem 2rem;
    background: linear-gradient(180deg, rgba(42, 38, 38, 0.85), rgba(26, 24, 24, 0.85));
    border: 1px solid rgba(90, 84, 80, 0.4);
    box-shadow:
        inset 0 0 60px rgba(0, 0, 0, 0.6),
        0 1px 0 rgba(212, 165, 116, 0.08);
    position: relative;
}

.vigil-frame::before,
.vigil-frame::after {
    content: "\2020";
    position: absolute;
    color: var(--accent);
    font-family: var(--display);
    font-size: 1.4rem;
    line-height: 1;
}

.vigil-frame::before {
    top: -0.7rem;
    left: 1.4rem;
    background: var(--primary);
    padding: 0 0.5rem;
}

.vigil-frame::after {
    bottom: -0.7rem;
    right: 1.4rem;
    background: var(--primary);
    padding: 0 0.5rem;
    transform: rotate(180deg);
}

.vigil-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: 0.65rem 0;
    border-bottom: 1px dashed rgba(90, 84, 80, 0.25);
    flex-wrap: wrap;
}

.vigil-row:last-of-type {
    border-bottom: none;
}

.vigil-label {
    font-family: var(--meta);
    font-size: 0.72rem;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--dim);
}

.vigil-value {
    font-family: var(--display);
    font-weight: 600;
    font-size: 1.15rem;
    color: var(--text);
    letter-spacing: 0.04em;
}

.vigil-candle-strip {
    display: flex;
    justify-content: center;
    gap: 1.6rem;
    margin: 2rem 0 1.4rem;
    padding: 1.2rem 0;
    border-top: 1px solid rgba(90, 84, 80, 0.25);
    border-bottom: 1px solid rgba(90, 84, 80, 0.25);
}

.candle {
    position: relative;
    width: 6px;
    height: 38px;
    background: linear-gradient(180deg, #c8bfb0 0%, #8a7f72 60%, #5a5450 100%);
    border-radius: 1px;
    opacity: 0.35;
    transition: opacity 0.5s ease;
}

.candle::after {
    content: "";
    position: absolute;
    top: -2px;
    left: 50%;
    width: 1px;
    height: 5px;
    background: var(--dim);
    transform: translateX(-50%);
}

.candle.is-lit {
    opacity: 1;
}

.flame {
    position: absolute;
    top: -16px;
    left: 50%;
    width: 8px;
    height: 14px;
    border-radius: 50% 50% 45% 45% / 60% 60% 40% 40%;
    background: radial-gradient(ellipse at 50% 70%, #f3d9a8 0%, #d4a574 50%, #8b5e3c 95%);
    box-shadow: 0 0 18px rgba(212, 165, 116, 0.55), 0 0 6px rgba(212, 165, 116, 0.85);
    transform: translateX(-50%);
    transform-origin: 50% 100%;
    opacity: 0;
    transition: opacity 0.4s ease;
    animation: flicker-flame 1.6s ease-in-out infinite;
}

.candle.is-lit .flame {
    opacity: 1;
}

.vigil-button {
    display: inline-flex;
    align-items: baseline;
    gap: 0.7rem;
    margin-top: 0.6rem;
    padding: 0.85rem 1.6rem;
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--text);
    font-family: var(--display);
    font-size: 1rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 0.5s ease, color 0.5s ease, letter-spacing 0.5s ease, box-shadow 0.5s ease;
}

.vigil-button:hover {
    background: rgba(139, 94, 60, 0.12);
    color: var(--highlight);
    letter-spacing: 0.22em;
    box-shadow: 0 0 24px rgba(212, 165, 116, 0.18);
}

.vigil-button-mark {
    color: var(--accent);
    font-size: 1.1rem;
    font-style: italic;
}

.vigil-button-foot {
    font-family: var(--display);
    font-style: italic;
    color: var(--dim);
    margin-top: 0.9rem;
    font-size: 0.95rem;
    transition: color 0.6s ease;
}

.vigil-button-foot.is-warm {
    color: var(--highlight);
}

/* --------------------------------- Ledger ---------------------------------- */

.ledger {
    padding: 4rem 1.5rem 5rem;
}

.ledger-inner {
    margin-left: 12vw;
    margin-right: max(8vw, 2rem);
    max-width: 60ch;
}

.ledger-list {
    list-style: none;
    margin-top: 2rem;
    counter-reset: ledger;
}

.ledger-list li {
    counter-increment: ledger;
    padding: 1.4rem 0 1.4rem 0.4rem;
    border-bottom: 1px solid rgba(90, 84, 80, 0.25);
    display: grid;
    grid-template-columns: 5.5rem 1fr;
    gap: 1.2rem;
    align-items: baseline;
}

.ledger-list li::before {
    content: counter(ledger, upper-roman) " \2020";
    grid-column: 1 / -1;
    font-family: var(--meta);
    font-size: 0.7rem;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.3rem;
}

.ledger-stamp {
    font-family: var(--display);
    font-style: italic;
    font-size: 1.6rem;
    color: var(--accent);
    letter-spacing: 0.04em;
    line-height: 1;
}

.ledger-body {
    font-family: var(--body);
    font-size: 1.02rem;
    line-height: 1.8;
    color: var(--text);
}

/* -------------------------------- Memorial --------------------------------- */

.memorial {
    background: var(--primary);
    padding: 6rem 1.5rem 5rem;
    text-align: center;
    position: relative;
    border-top: 1px solid rgba(90, 84, 80, 0.25);
}

.memorial::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(ellipse at 50% 0%, rgba(139, 94, 60, 0.06), transparent 60%);
}

.memorial-inner {
    max-width: 60ch;
    margin: 0 auto;
    position: relative;
}

.memorial-eyebrow {
    margin-left: auto;
    margin-right: auto;
}

.memorial-heading {
    margin-bottom: 1.4rem;
}

.memorial-lede {
    margin: 0 auto;
    text-align: center;
}

.memorial-list {
    list-style: none;
    margin: 3rem auto 2rem;
    padding: 0;
}

.memorial-list li {
    font-family: var(--display);
    font-style: italic;
    font-weight: 400;
    font-size: 1.05rem;
    color: var(--dim);
    opacity: 0.6;
    padding: 0.55rem 0;
    transition: opacity 0.6s ease, color 0.6s ease, letter-spacing 0.6s ease;
    letter-spacing: 0.02em;
    line-height: 1.5;
}

.memorial-list li:hover {
    opacity: 1;
    color: var(--text);
    letter-spacing: 0.04em;
}

.memorial-name {
    color: var(--text);
    font-style: normal;
    font-weight: 600;
    margin-right: 0.6rem;
}

.memorial-dates {
    color: var(--dim);
    font-family: var(--meta);
    font-style: normal;
    font-size: 0.78rem;
    letter-spacing: 0.16em;
    margin-right: 0.6rem;
}

.memorial-note {
    color: var(--dim);
    font-size: 0.95rem;
    display: inline-block;
}

.memorial-prayer {
    font-family: var(--display);
    font-style: italic;
    font-size: 1.05rem;
    color: var(--dim);
    margin: 2rem auto 1.6rem;
    max-width: 50ch;
    line-height: 1.7;
}

.memorial-sign {
    font-family: var(--display);
    font-size: 0.95rem;
    color: var(--accent);
    letter-spacing: 0.32em;
    margin-top: 2rem;
    opacity: 0.85;
}

/* ------------------------------- Animations -------------------------------- */

@keyframes flicker {
    0%, 100% { opacity: 0.92; }
    20% { opacity: 0.96; }
    40% { opacity: 0.88; }
    50% { opacity: 1; }
    60% { opacity: 0.94; }
    80% { opacity: 0.9; }
}

@keyframes flicker-flame {
    0%, 100% {
        transform: translateX(-50%) scale(1, 1) rotate(-1deg);
        filter: brightness(1);
    }
    25% {
        transform: translateX(-50%) scale(0.96, 1.05) rotate(1deg);
        filter: brightness(1.08);
    }
    50% {
        transform: translateX(-50%) scale(1.04, 0.95) rotate(-2deg);
        filter: brightness(0.95);
    }
    75% {
        transform: translateX(-50%) scale(0.98, 1.02) rotate(2deg);
        filter: brightness(1.05);
    }
}

@keyframes drip {
    0%, 100% { opacity: 0.3; transform: scaleY(1); }
    50% { opacity: 1; transform: scaleY(1.15); }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ------------------------------- Responsive ------------------------------- */

@media (max-width: 720px) {
    .catalogue-header,
    .entry,
    .readings-inner,
    .vigil-inner,
    .ledger-inner {
        margin-left: 6vw;
        margin-right: 6vw;
    }

    .elegy-inner {
        margin-top: -6vh;
    }

    .ledger-list li {
        grid-template-columns: 1fr;
        gap: 0.4rem;
    }

    .vigil-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.2rem;
    }

    .ornamental-rule {
        margin: 3.5rem auto;
        width: 80%;
    }
}

@media (max-width: 460px) {
    .elegy-overline,
    .elegy-meta {
        letter-spacing: 0.28em;
    }

    .vigil-frame {
        padding: 2rem 1.2rem;
    }

    .memorial {
        padding: 4rem 1.2rem;
    }

    .memorial-list li {
        font-size: 1rem;
    }
}
