/* ========================================== */
/* BADA.QUEST - STYLES */
/* A digital grimoire of poisonous plants */
/* ========================================== */

/* ========== ROOT & DEFAULTS ========== */

:root {
    --bg-primary: #0E0B0F;      /* Abyss */
    --bg-secondary: #1A1221;    /* Nightshade */
    --accent-primary: #6B1F2A;  /* Dried Blood */
    --accent-secondary: #7D4E6B; /* Foxglove */
    --text-primary: #D8C8B0;    /* Vellum */
    --text-muted: #9A8E7E;      /* Faded Ink */
    --specimen-bg: #F2EAD8;     /* Aged Cream */
    --botanical-line: #2A3B2A;  /* Hemlock Green */
    --danger-marker: #C43A5C;   /* Belladonna */
    --vine-dark: #1C2B1A;       /* Yew Dark */
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Lora', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.75;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    overflow-x: hidden;
    position: relative;
}

/* ========== GRAIN OVERLAY ========== */

#grain-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
    background-repeat: repeat;
}

/* ========== VINE PROGRESS INDICATOR ========== */

#vine-progress {
    position: fixed;
    left: 0;
    top: 0;
    width: 40px;
    height: 100vh;
    z-index: 10;
    pointer-events: none;
}

#vine-stem {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 0.1s linear;
}

.vine-element {
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

.vine-element.visible {
    opacity: 1;
}

/* ========== PLATE STRUCTURE ========== */

.plate {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
    background-color: var(--bg-secondary);
    transition: background-color 1.2s ease-in-out;
    padding: 4rem 2rem;
    margin-left: 40px;
}

.plate-inner {
    max-width: 1000px;
    width: 100%;
    position: relative;
    z-index: 2;
}

/* ========== PLATE I: TITLE FOLIO ========== */

#plate-i {
    background-color: var(--bg-secondary);
}

.title-folio {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 70vh;
}

.folio-rings {
    position: absolute;
    width: 100%;
    text-align: center;
}

.folio-ring {
    position: relative;
    margin: 1rem 0;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-family: 'Playfair Display', serif;
    font-weight: 700;
}

.ring-outer {
    font-size: clamp(2rem, 4vw, 3rem);
    color: var(--text-muted);
    opacity: 0.6;
    letter-spacing: 0.15em;
}

.ring-mid {
    font-size: clamp(0.9rem, 1.1vw, 1rem);
    color: var(--text-primary);
    letter-spacing: 0.08em;
    margin: 2rem 0;
}

.ring-inner {
    font-size: clamp(1.6rem, 3.5vw, 2.8rem);
    color: var(--text-primary);
    font-style: italic;
    letter-spacing: 0.04em;
    font-weight: 700;
}

.folio-mandala {
    position: relative;
    width: 300px;
    height: 300px;
    margin: 0 auto;
    margin-top: 3rem;
}

.folio-mandala svg {
    width: 100%;
    height: 100%;
}

/* ========== SVG DRAWING ANIMATION ========== */

.draw-path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
}

.draw-path.animate {
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 2.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.color-wash {
    opacity: 0;
    transition: opacity 1s ease-in-out;
}

.color-wash.animate {
    opacity: var(--target-opacity, 0.15);
}

/* ========== PLATE II: EXPEDITION MAP ========== */

#plate-ii {
    background-color: #161020;
}

.plate-title {
    font-family: 'Playfair Display', serif;
    font-size: clamp(1.6rem, 3.5vw, 2.8rem);
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 0.5rem;
    letter-spacing: 0.08em;
    margin-top: 15vh;
}

.plate-subtitle {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-style: italic;
    font-size: clamp(0.95rem, 1.2vw, 1.1rem);
    color: var(--text-muted);
    text-align: center;
    letter-spacing: 0.06em;
    margin-bottom: 3rem;
    margin-top: 0.5em;
}

.latin-name {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-style: italic;
    color: var(--accent-primary);
    letter-spacing: 0.06em;
}

.expedition-layout {
    display: grid;
    grid-template-columns: 60% 40%;
    gap: 3rem;
    align-items: center;
}

.map-column {
    position: relative;
}

.map-column svg {
    width: 100%;
    max-height: 500px;
}

.journal-column {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.journal-entry {
    position: relative;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--accent-secondary);
    border-bottom: 1px solid rgba(125, 78, 107, 0.3);
}

.entry-date {
    display: block;
    font-size: clamp(0.85rem, 1vw, 0.95rem);
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 0.8rem;
}

.journal-entry p {
    max-width: 38em;
}

.journal-entry:last-child {
    border-bottom: none;
}

.faded-text {
    color: var(--text-muted);
    opacity: 0.85;
}

/* ========== PLATE III: SPECIMEN GALLERY ========== */

#plate-iii {
    background-color: #120D18;
}

.specimen-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 2rem;
    padding: 2rem 0;
    perspective: 1000px;
}

.specimen-card {
    background-color: var(--specimen-bg);
    padding: 1.5rem;
    position: relative;
    border: 1px solid var(--text-muted);
    border: 1px solid rgba(154, 142, 126, 0.4);
    aspect-ratio: 1 / 1.3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0.8rem;
    overflow: hidden;
    transform: rotate(var(--rotation, 0deg)) translateX(var(--offset-x, 0px)) translateY(var(--offset-y, 0px));
    transition: transform 1.5s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.specimen-card.grid-layout {
    transform: rotate(0deg) translateX(0) translateY(0);
}

/* Foxing texture on specimen cards */
.specimen-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(circle, var(--text-muted) 1px, transparent 1px);
    background-size: 40px 40px;
    background-position: random();
    opacity: 0.05;
    pointer-events: none;
    z-index: 0;
}

.specimen-card > * {
    position: relative;
    z-index: 1;
}

.danger-badge {
    position: absolute;
    top: 0.8rem;
    right: 0.8rem;
    background-color: var(--danger-marker);
    color: var(--specimen-bg);
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Cormorant Garamond', serif;
    font-size: 1rem;
    font-weight: 300;
    font-style: italic;
    z-index: 2;
}

.specimen-illustration {
    width: 100%;
    max-width: 180px;
    height: auto;
    aspect-ratio: 1 / 1.2;
    margin: 1rem 0;
}

.specimen-name {
    font-size: clamp(0.9rem, 1.1vw, 1rem);
    text-align: center;
    color: var(--accent-primary);
    margin-top: 0.5rem;
}

.specimen-common {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
}

.collection-stamp {
    position: absolute;
    bottom: 0.8rem;
    left: 0.8rem;
    width: 50px;
    height: 50px;
    opacity: 0.6;
    z-index: 1;
}

.collection-stamp svg {
    width: 100%;
    height: 100%;
}

/* ========== PLATE IV: MARGINALIA ========== */

#plate-iv {
    background-color: #0D0910;
}

.marginalia-layout {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    gap: 2rem;
    align-items: flex-start;
    margin-top: 3rem;
}

.margin-left,
.margin-right {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.margin-note {
    opacity: 0;
    transform: translateX(-10px) rotate(-1.5deg);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

.margin-note.reveal {
    opacity: 1;
    transform: translateX(0) rotate(-1.5deg);
}

.margin-right .margin-note {
    text-align: right;
}

.margin-right .margin-note.reveal {
    transform: translateX(0) rotate(1.5deg);
}

.note-text {
    font-family: 'Caveat', cursive;
    font-size: clamp(0.85rem, 1vw, 1rem);
    color: var(--accent-secondary);
    line-height: 1.5;
    display: block;
}

.journal-main {
    display: flex;
    align-items: center;
    justify-content: center;
}

.journal-page {
    max-width: 38em;
}

.journal-page p {
    margin-bottom: 1.5rem;
    text-align: justify;
}

.journal-page p:last-child {
    margin-bottom: 0;
}

/* ========== PLATE V: FINAL ENTRY ========== */

#plate-v {
    background-color: #0A0608;
}

.plate-title-final {
    color: var(--text-primary);
    text-shadow: 0 0 20px rgba(212, 58, 92, 0.2);
}

.final-entry-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    align-items: center;
    margin-top: 3rem;
}

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

.final-illustration svg {
    width: 100%;
    max-width: 400px;
    height: auto;
}

.final-text {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.final-entry-text {
    max-width: 38em;
    font-size: clamp(0.95rem, 1.1vw, 1.05rem);
    line-height: 1.8;
    color: var(--text-primary);
    font-style: italic;
}

.final-classification {
    grid-column: 1 / -1;
    text-align: center;
    margin-top: 2rem;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    color: var(--danger-marker);
    letter-spacing: 0.08em;
}

/* ========== RESPONSIVE ========== */

@media (max-width: 768px) {
    .expedition-layout {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .marginalia-layout {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .final-entry-layout {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .plate {
        margin-left: 30px;
    }

    #vine-progress {
        width: 30px;
    }

    .specimen-gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }

    .margin-left,
    .margin-right {
        gap: 1rem;
    }

    .margin-note {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 0.95rem;
    }

    .plate {
        padding: 2rem 1rem;
        margin-left: 20px;
    }

    #vine-progress {
        width: 20px;
    }

    .specimen-gallery {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .marginalia-layout {
        grid-template-columns: 1fr;
    }

    .plate-title {
        font-size: 1.4rem;
    }
}

/* ========== PRINT STYLES ========== */

@media print {
    #vine-progress,
    #grain-overlay {
        display: none;
    }

    .plate {
        page-break-inside: avoid;
        margin-left: 0;
    }
}
