/* =============================================
   lugubrious.dev - Melancholic Cottagecore Aesthetic
   ============================================= */

/* CSS Custom Properties */
:root {
    --bg-primary: #f5ede0;
    --bg-secondary: #ede5d5;
    --bg-tertiary: #f0e6d2;
    --text-primary: #4a3f35;
    --text-secondary: #7a6e5f;
    --accent-botanical: #6b8f5e;
    --accent-warm: #c4a882;
    --accent-melancholy: #8b4049;
    --accent-lavender: #9a7eb5;
    --foxing: #d4c4a8;

    --font-display: 'Cormorant Garamond', 'Georgia', serif;
    --font-body: 'Lora', 'Georgia', serif;
    --font-accent: 'Space Grotesk', 'Helvetica Neue', sans-serif;
    --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

    --elastic: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --ease-gentle: cubic-bezier(0.25, 0.1, 0.25, 1);
}

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

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

body {
    font-family: var(--font-body);
    color: var(--text-primary);
    background-color: var(--bg-primary);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(212, 196, 168, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(212, 196, 168, 0.04) 0%, transparent 40%),
        radial-gradient(ellipse at 60% 80%, rgba(212, 196, 168, 0.03) 0%, transparent 45%),
        radial-gradient(ellipse at 10% 90%, rgba(212, 196, 168, 0.02) 0%, transparent 35%),
        radial-gradient(ellipse at 90% 70%, rgba(212, 196, 168, 0.03) 0%, transparent 40%);
    line-height: 1.75;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Paper grain texture overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
    background-size: 256px 256px;
}

/* Page Wrapper */
#page-wrapper {
    position: relative;
    z-index: 1;
    transition: background-color 0.8s var(--elastic);
}

/* =============================================
   COMPASS ROSE NAVIGATION
   ============================================= */
#compass-nav {
    position: fixed;
    top: 24px;
    left: 24px;
    z-index: 1000;
}

.compass-icon {
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.4s ease, transform 0.4s var(--elastic);
}

#compass-nav:hover .compass-icon {
    opacity: 1;
    transform: rotate(15deg);
}

.nav-links {
    list-style: none;
    position: absolute;
    top: 50px;
    left: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.4s var(--elastic);
    background: rgba(245, 237, 224, 0.95);
    padding: 12px 20px;
    border: 0.5px solid #8b7355;
    min-width: 160px;
}

#compass-nav:hover .nav-links {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.nav-links li {
    margin: 8px 0;
}

.nav-links a {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 300;
    color: var(--text-secondary);
    text-decoration: none;
    letter-spacing: 0.04em;
    transition: color 0.3s ease;
    display: block;
    padding: 2px 0;
}

.nav-links a:hover {
    color: var(--accent-botanical);
}

.nav-links a.active {
    color: var(--text-primary);
    font-weight: 600;
}

.nav-links a:visited {
    color: var(--accent-lavender);
}

.nav-links a:visited.active {
    color: var(--text-primary);
}

/* =============================================
   SECTIONS - General
   ============================================= */
.section {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(60px, 10vh, 120px) clamp(24px, 15vw, 200px);
}

.section-title {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(28px, 4vw, 56px);
    letter-spacing: 0.04em;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 16px;
}

.section-subtitle {
    font-family: var(--font-accent);
    font-weight: 400;
    font-size: 13px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: clamp(40px, 6vh, 80px);
}

/* =============================================
   SECTION 1: THE COVER
   ============================================= */
#cover {
    min-height: 100vh;
    flex-direction: column;
}

.cover-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 100vh;
    padding: 60px 20px;
}

.domain-title {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(36px, 6vw, 96px);
    letter-spacing: 0.12em;
    color: var(--text-primary);
    text-align: center;
    position: relative;
    z-index: 2;
}

.letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(20px);
}

.letter.dot {
    color: var(--accent-melancholy);
}

.letter.animate {
    animation: letterDrop 0.6s var(--elastic) forwards;
}

@keyframes letterDrop {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.title-underline {
    margin-top: 12px;
    overflow: hidden;
    position: relative;
    z-index: 2;
}

.underline-svg {
    max-width: 80vw;
}

.underline-path {
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    transition: stroke-dashoffset 0.8s ease 0.9s;
}

.underline-path.animate {
    stroke-dashoffset: 0;
}

.cover-flower {
    position: absolute;
    bottom: 5vh;
    left: 10vw;
    opacity: 0.7;
    z-index: 1;
}

.lavender-svg .botanical-path {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
}

.lavender-svg.animate .botanical-path {
    animation: drawPath 1.5s var(--elastic) forwards;
}

@keyframes drawPath {
    0% {
        stroke-dashoffset: 500;
    }
    100% {
        stroke-dashoffset: 0;
    }
}

/* =============================================
   BOTANICAL DIVIDERS
   ============================================= */
.botanical-divider {
    display: flex;
    justify-content: center;
    padding: clamp(20px, 4vh, 40px) 0;
    opacity: 0.6;
}

/* =============================================
   SECTION 2: THE INSCRIPTION
   ============================================= */
#inscription {
    min-height: 80vh;
    background-color: var(--bg-secondary);
}

.inscription-content {
    max-width: 700px;
    text-align: center;
    padding: clamp(60px, 10vh, 120px) 20px;
}

.inscription-line {
    font-family: var(--font-body);
    font-style: italic;
    font-size: clamp(18px, 3vw, 36px);
    line-height: 1.6;
    color: var(--text-primary);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s var(--elastic);
    margin-bottom: 8px;
}

.inscription-line.visible {
    opacity: 1;
    transform: translateY(0);
}

.inscription-attribution {
    font-family: var(--font-accent);
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-top: clamp(30px, 4vh, 60px);
    opacity: 0;
    transition: opacity 0.6s ease 0.5s;
}

.inscription-attribution.visible {
    opacity: 0.7;
}

/* =============================================
   SECTION 3: THE HERBARIUM
   ============================================= */
#herbarium {
    min-height: 120vh;
    background-color: var(--bg-primary);
}

.herbarium-content {
    max-width: 640px;
    width: 100%;
    padding: clamp(40px, 6vh, 80px) 20px;
}

.specimen-card {
    margin-bottom: clamp(60px, 8vh, 120px);
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.4s ease, transform 0.6s var(--elastic);
}

.specimen-card.visible {
    opacity: 1;
    transform: scale(1);
}

.specimen-illustration {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
    opacity: 0.8;
}

.specimen-illustration .botanical-path {
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
}

.specimen-card.visible .botanical-path {
    animation: drawPath 1.5s var(--elastic) forwards;
}

.specimen-frame {
    border: 0.5px solid var(--accent-warm);
    padding: clamp(24px, 3vw, 40px);
    background: rgba(237, 229, 213, 0.4);
    position: relative;
}

.specimen-frame::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    right: 4px;
    bottom: 4px;
    border: 0.5px solid rgba(139, 115, 85, 0.3);
    pointer-events: none;
}

.specimen-name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(20px, 2.5vw, 30px);
    letter-spacing: 0.04em;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.specimen-description {
    font-family: var(--font-body);
    font-size: clamp(15px, 1.6vw, 18px);
    line-height: 1.75;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.specimen-meta {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    border-top: 0.5px solid var(--accent-warm);
    padding-top: 12px;
}

.specimen-label,
.specimen-date {
    font-family: var(--font-accent);
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
}


/* =============================================
   SECTION 4: THE MARGINALIA
   ============================================= */
#marginalia {
    min-height: 100vh;
    background-color: var(--bg-tertiary);
}

.marginalia-content {
    max-width: 700px;
    width: 100%;
    padding: clamp(40px, 6vh, 80px) 20px;
}

.margin-note {
    margin-bottom: clamp(40px, 5vh, 70px);
    padding: clamp(20px, 3vw, 32px);
    border-left: 2px solid var(--accent-warm);
    background: rgba(245, 237, 224, 0.3);
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 0.5s ease, transform 0.6s var(--elastic);
}

.margin-note.visible {
    opacity: 1;
    transform: translateY(0);
}

.margin-note.offset-left {
    margin-left: 0;
    margin-right: clamp(20px, 5vw, 40px);
}

.margin-note.offset-right {
    margin-left: clamp(20px, 5vw, 40px);
    margin-right: 0;
}

/* Preserve the inline rotation from HTML but add visibility transform */
.margin-note.visible.offset-left {
    transform: rotate(-0.5deg) translateY(0);
}

.margin-note.visible.offset-right {
    transform: rotate(0.4deg) translateY(0);
}

.note-text {
    font-family: var(--font-body);
    font-style: italic;
    font-size: clamp(15px, 1.8vw, 19px);
    line-height: 1.7;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.note-text code {
    font-family: var(--font-mono);
    font-style: normal;
    font-size: 0.85em;
    background: var(--bg-secondary);
    border-left: 2px solid var(--accent-warm);
    padding: 2px 8px;
    display: inline;
}

.note-annotation {
    font-family: var(--font-accent);
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
    display: block;
    text-align: right;
}

/* =============================================
   SECTION 5: THE COLOPHON
   ============================================= */
#colophon {
    min-height: 60vh;
    background-color: var(--bg-secondary);
}

.colophon-content {
    max-width: 600px;
    width: 100%;
    text-align: center;
    padding: clamp(40px, 6vh, 80px) 20px clamp(80px, 10vh, 140px);
}

.colophon-details {
    margin-top: clamp(30px, 4vh, 60px);
}

.colophon-block {
    margin-bottom: clamp(30px, 4vh, 50px);
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 0.5s ease, transform 0.6s var(--elastic);
}

.colophon-block.visible {
    opacity: 1;
    transform: translateY(0);
}

.colophon-heading {
    font-family: var(--font-accent);
    font-weight: 500;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.colophon-text {
    font-family: var(--font-body);
    font-size: clamp(14px, 1.6vw, 17px);
    line-height: 1.75;
    color: var(--text-primary);
}

.colophon-text em {
    color: var(--accent-botanical);
    font-style: italic;
}

.wax-seal-container {
    display: flex;
    justify-content: center;
    margin: clamp(30px, 5vh, 60px) 0;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.5s ease, transform 0.6s var(--elastic);
}

.wax-seal-container.visible {
    opacity: 1;
    transform: scale(1);
}

.wax-seal {
    filter: drop-shadow(0 2px 4px rgba(139, 64, 73, 0.2));
}

.colophon-contact {
    margin-top: clamp(20px, 3vh, 40px);
    opacity: 0;
    transition: opacity 0.6s ease;
}

.colophon-contact.visible {
    opacity: 1;
}

.envelope-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.envelope-icon:hover {
    opacity: 1;
}

.contact-text {
    font-family: var(--font-body);
    font-style: italic;
    font-size: clamp(13px, 1.4vw, 16px);
    line-height: 1.7;
    color: var(--text-secondary);
}

.ink-splatters {
    display: flex;
    justify-content: center;
    margin-top: clamp(30px, 4vh, 50px);
    opacity: 0.5;
}

/* =============================================
   SCROLL ANIMATIONS - Visibility states
   ============================================= */
.section-title,
.section-subtitle {
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 0.5s ease, transform 0.6s var(--elastic);
}

.section-title.visible,
.section-subtitle.visible {
    opacity: 1;
    transform: translateY(0);
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 768px) {
    .section {
        padding: clamp(40px, 8vh, 80px) 24px;
    }

    .cover-flower {
        left: 5vw;
        bottom: 3vh;
        opacity: 0.5;
    }

    .cover-flower svg {
        width: 140px;
        height: 210px;
    }

    .margin-note.offset-left,
    .margin-note.offset-right {
        margin-left: 0;
        margin-right: 0;
    }

    #compass-nav {
        top: 16px;
        left: 16px;
    }

    .specimen-meta {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .domain-title {
        font-size: clamp(28px, 8vw, 48px);
        letter-spacing: 0.08em;
    }

    .cover-flower {
        opacity: 0.3;
    }

    .inscription-line {
        font-size: clamp(16px, 4vw, 24px);
    }
}

/* =============================================
   SELECTION STYLE
   ============================================= */
::selection {
    background: rgba(154, 126, 181, 0.2);
    color: var(--text-primary);
}

/* =============================================
   LINK STYLES
   ============================================= */
a {
    color: var(--accent-botanical);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.3s ease, color 0.3s ease;
}

a:hover {
    border-bottom-color: var(--accent-botanical);
}

a:visited {
    color: var(--accent-lavender);
}
