/* =============================================
   mujun.wiki — Fairycore Botanical Encyclopedia
   ============================================= */

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

:root {
    --enchanted-canopy: #1a3a2a;
    --fern-shadow: #2a5a40;
    --card-border: #2a4a3a;
    --moss-veil: #4a7a5a;
    --foxglove-thorn: #8b4a6b;
    --petal-blush: #c47a98;
    --pressed-vellum: #f5f0e6;
    --aged-linen: #eae3d0;
    --deep-loam: #2a2a24;
    --weathered-ink: #5a5a50;
    --morning-dew: #a8d8b8;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Lora', Georgia, serif;
    background: var(--pressed-vellum);
    color: var(--deep-loam);
    overflow-x: hidden;
    line-height: 1.72;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
}

/* --- Dappled Light Overlay --- */
#dappled-light {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    background:
        radial-gradient(circle at 30% 20%, rgba(168,216,184,0.08) 0%, transparent 50%),
        radial-gradient(circle at 70% 60%, rgba(168,216,184,0.06) 0%, transparent 45%),
        radial-gradient(circle at 50% 80%, rgba(196,122,152,0.04) 0%, transparent 40%),
        radial-gradient(circle at 15% 70%, rgba(168,216,184,0.05) 0%, transparent 50%),
        radial-gradient(circle at 85% 30%, rgba(196,122,152,0.05) 0%, transparent 45%);
    animation: dappled-shift 60s ease-in-out infinite alternate;
    will-change: background-position;
}

@keyframes dappled-shift {
    0% { background-position: 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%; }
    50% { background-position: 5% 8%, -3% 5%, 4% -3%, -5% 4%, 3% -6%; }
    100% { background-position: -3% -5%, 6% -4%, -5% 6%, 4% -3%, -6% 5%; }
}

/* --- Spore Gate (Hero) --- */
#spore-gate {
    position: relative;
    height: 100vh;
    min-height: 600px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.spore-gate-wash {
    position: absolute;
    inset: 0;
    background: linear-gradient(165deg, #1a3a2a 0%, #2a5a40 40%, #f5f0e6 100%);
    z-index: 0;
}

.kanji {
    position: absolute;
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: clamp(5rem, 15vw, 12rem);
    z-index: 2;
    opacity: 0.85;
    transition: opacity 0.6s ease;
}

.kanji-spear {
    left: 8%;
    top: 50%;
    transform: translateY(-50%);
    color: var(--petal-blush);
    text-shadow: 0 0 60px rgba(196,122,152,0.3);
}

.kanji-shield {
    right: 8%;
    top: 50%;
    transform: translateY(-50%);
    color: var(--morning-dew);
    text-shadow: 0 0 60px rgba(168,216,184,0.3);
}

#vine-hero {
    position: absolute;
    width: 60%;
    height: auto;
    z-index: 1;
    opacity: 0.7;
}

.vine-path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 1.2s ease-out;
}

.vine-leaf, .vine-thorn {
    transition: opacity 0.8s ease-out 0.4s;
}

.spore-subtitle {
    position: absolute;
    bottom: 12%;
    z-index: 3;
    text-align: center;
    width: 100%;
}

.classification {
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(0.7rem, 1.2vw, 0.85rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--pressed-vellum);
    opacity: 0.7;
}

.scroll-vine-waypoint {
    position: absolute;
    bottom: 0;
    width: 1px;
    height: 1px;
}

/* --- Watercolor Wash Layers --- */
.watercolor-wash {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    filter: url(#watercolor-distort);
}

.wash-1::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 500px 400px at 20% 30%, rgba(196,122,152,0.12) 0%, transparent 70%),
        radial-gradient(ellipse 600px 350px at 70% 50%, rgba(74,122,90,0.1) 0%, transparent 65%),
        radial-gradient(ellipse 300px 250px at 50% 80%, rgba(168,216,184,0.08) 0%, transparent 60%);
    filter: url(#watercolor-distort);
}

.wash-2::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 400px 300px at 40% 40%, rgba(139,74,107,0.1) 0%, transparent 65%),
        radial-gradient(ellipse 500px 400px at 60% 60%, rgba(74,122,90,0.08) 0%, transparent 70%);
    filter: url(#watercolor-distort);
}

.wash-3::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 700px 500px at 30% 20%, rgba(42,90,64,0.1) 0%, transparent 65%),
        radial-gradient(ellipse 400px 300px at 75% 70%, rgba(196,122,152,0.08) 0%, transparent 60%),
        radial-gradient(ellipse 350px 250px at 50% 50%, rgba(168,216,184,0.06) 0%, transparent 55%);
    filter: url(#watercolor-distort);
}

/* --- Specimen Collection --- */
#specimen-collection {
    position: relative;
    padding: 6rem 2rem 4rem;
    min-height: 100vh;
}

.specimen-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1rem;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* --- Specimen Cards --- */
.specimen-card {
    background: rgba(245, 240, 230, 0.85);
    padding: 2rem 2rem 1.5rem;
    position: relative;
    cursor: default;
    transition: z-index 0s, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    box-shadow: inset 0 0 30px rgba(42,42,36,0.08), 0 4px 20px rgba(26,58,42,0.1);
    border-left: 2px solid #2a4a3a;
    z-index: 1;
}

.specimen-card:hover {
    z-index: 10;
    box-shadow: inset 0 0 30px rgba(42,42,36,0.08), 0 8px 30px rgba(26,58,42,0.18);
}

.specimen-card.expanded {
    z-index: 20;
    transform: rotate(0deg) !important;
}

/* Torn-edge clip paths */
.card-1 {
    grid-column: 1 / 6;
    transform: rotate(-1.8deg);
    clip-path: polygon(2% 0%, 98% 1%, 100% 3%, 99% 97%, 97% 100%, 3% 99%, 0% 97%, 1% 2%);
    margin-top: 0;
}

.card-2 {
    grid-column: 6 / 12;
    transform: rotate(2.1deg);
    clip-path: polygon(0% 2%, 97% 0%, 100% 2%, 99% 98%, 96% 100%, 2% 98%, 0% 96%, 1% 3%);
    margin-top: 3rem;
}

.card-3 {
    grid-column: 3 / 9;
    transform: rotate(-0.7deg);
    clip-path: polygon(1% 1%, 99% 0%, 100% 4%, 98% 99%, 100% 97%, 1% 100%, 0% 98%, 2% 2%);
    margin-top: -2rem;
}

.card-4 {
    grid-column: 2 / 7;
    transform: rotate(1.5deg);
    clip-path: polygon(0% 1%, 96% 0%, 100% 2%, 99% 96%, 97% 100%, 4% 99%, 0% 97%, 1% 3%);
    margin-top: 1rem;
}

.card-5 {
    grid-column: 5 / 11;
    transform: rotate(-2deg);
    clip-path: polygon(2% 0%, 100% 2%, 98% 98%, 100% 100%, 1% 99%, 0% 96%, 3% 1%);
    margin-top: -1.5rem;
}

.card-6 {
    grid-column: 3 / 10;
    transform: rotate(0.9deg);
    clip-path: polygon(1% 2%, 97% 0%, 100% 3%, 99% 97%, 95% 100%, 2% 99%, 0% 95%, 0% 1%);
    margin-top: 2rem;
}

/* Card watercolor header */
.card-watercolor {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 140px;
    background: radial-gradient(ellipse at 30% 20%, rgba(196,122,152,0.25) 0%, rgba(74,122,90,0.15) 40%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.card-illustration {
    position: relative;
    z-index: 1;
    margin-bottom: 1rem;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-illustration svg {
    width: 160px;
    height: 100px;
    mix-blend-mode: multiply;
}

.card-title {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    letter-spacing: 0.02em;
    color: var(--foxglove-thorn);
    margin-bottom: 0.4rem;
    position: relative;
    z-index: 1;
}

.card-classification {
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(0.7rem, 1.2vw, 0.85rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--weathered-ink);
    display: block;
    margin-bottom: 0.8rem;
    position: relative;
    z-index: 1;
}

.card-expand {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.2rem;
    color: var(--moss-veil);
    background: none;
    border: 1px solid var(--moss-veil);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, color 0.3s ease, background 0.3s ease;
    position: relative;
    z-index: 1;
    line-height: 1;
}

.card-expand:hover {
    background: var(--moss-veil);
    color: var(--pressed-vellum);
}

.specimen-card.expanded .card-expand {
    transform: rotate(45deg);
    background: var(--foxglove-thorn);
    border-color: var(--foxglove-thorn);
    color: var(--pressed-vellum);
}

.card-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    z-index: 1;
}

.specimen-card.expanded .card-body {
    max-height: 400px;
}

.card-body p {
    padding-top: 1rem;
    font-family: 'Lora', serif;
    font-style: italic;
    line-height: 1.72;
    color: var(--deep-loam);
}

/* --- Pressed Flower Divider --- */
.pressed-flower-divider {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    padding: 3rem 0;
}

.pressed-flower {
    width: 80px;
    height: 120px;
    position: relative;
}

.pressed-flower::before,
.pressed-flower::after {
    content: '';
    position: absolute;
    width: 30px;
    height: 45px;
    border-radius: 50%;
    background: rgba(196,122,152,0.15);
}

.pressed-flower::before {
    top: 10px;
    left: 50%;
    transform: translateX(-50%) rotate(0deg);
}

.pressed-flower::after {
    top: 10px;
    left: 50%;
    transform: translateX(-50%) rotate(72deg);
}

/* Additional petals via box-shadow on a pseudo */
.pressed-flower-divider::before {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--moss-veil);
    border-radius: 50%;
    opacity: 0.4;
}

/* --- Thorn & Leaf Interlude --- */
#thorn-leaf-interlude {
    position: relative;
    min-height: 80vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6rem 2rem;
}

#thorn-leaf-knot {
    width: clamp(200px, 30vw, 300px);
    height: auto;
    margin-bottom: 3rem;
}

.knot-path {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    transition: stroke-dashoffset 1.5s ease-out;
}

.knot-path.drawn {
    stroke-dashoffset: 0;
}

.interlude-text {
    font-family: 'Lora', serif;
    font-style: italic;
    font-size: clamp(1.1rem, 2vw, 1.4rem);
    color: var(--weathered-ink);
    text-align: center;
    max-width: 500px;
    line-height: 1.8;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease 0.6s, transform 0.8s ease 0.6s;
}

.interlude-text.visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- Root System --- */
#root-system {
    position: relative;
    padding: 4rem 2rem 6rem;
    min-height: 100vh;
}

.root-pattern {
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(87deg, rgba(42,90,64,0.04) 0px, transparent 1px, transparent 20px),
        repeating-linear-gradient(177deg, rgba(42,90,64,0.04) 0px, transparent 1px, transparent 20px);
    pointer-events: none;
    z-index: 0;
}

.root-grid .specimen-card {
    box-shadow: inset 0 0 30px rgba(42,42,36,0.1), 0 6px 24px rgba(26,58,42,0.14);
}

/* --- The Pressing (Closing) --- */
#the-pressing {
    position: relative;
    height: 100vh;
    min-height: 600px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    overflow: hidden;
}

.pressing-wash {
    position: absolute;
    inset: 0;
    background: linear-gradient(165deg, #f5f0e6 0%, #2a5a40 60%, #1a3a2a 100%);
    z-index: 0;
}

.pressing-cards {
    position: relative;
    z-index: 1;
    width: 200px;
    height: 260px;
}

.pressing-card {
    position: absolute;
    width: 200px;
    height: 260px;
    background: rgba(245,240,230,0.6);
    box-shadow: 0 2px 15px rgba(26,58,42,0.15);
    transition: transform 1s ease, opacity 1s ease;
}

.pc-1 {
    transform: rotate(-3deg) translate(-10px, -5px);
    clip-path: polygon(2% 0%, 98% 1%, 100% 3%, 99% 97%, 97% 100%, 3% 99%, 0% 97%, 1% 2%);
}

.pc-2 {
    transform: rotate(2deg) translate(5px, 3px);
    clip-path: polygon(0% 2%, 97% 0%, 100% 2%, 99% 98%, 96% 100%, 2% 98%, 0% 96%, 1% 3%);
    opacity: 0.8;
}

.pc-3 {
    transform: rotate(-1deg) translate(-3px, 8px);
    clip-path: polygon(1% 1%, 99% 0%, 100% 4%, 98% 99%, 100% 97%, 1% 100%, 0% 98%, 2% 2%);
    opacity: 0.6;
}

.pressing-cards.pressed .pc-1,
.pressing-cards.pressed .pc-2,
.pressing-cards.pressed .pc-3 {
    transform: rotate(0deg) translate(0, 0);
    opacity: 0.4;
}

.pressing-domain {
    position: relative;
    z-index: 2;
    text-align: center;
    margin-top: 3rem;
}

.domain-name {
    display: block;
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: clamp(2rem, 5vw, 3.5rem);
    color: var(--pressed-vellum);
    letter-spacing: 0.04em;
    opacity: 0.9;
}

.domain-kanji {
    display: block;
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: clamp(1.2rem, 3vw, 2rem);
    color: var(--petal-blush);
    opacity: 0.7;
    margin-top: 0.5rem;
}

/* --- Page Vine SVG --- */
#page-vine {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
    display: none; /* enabled via JS if desired */
}

/* --- Mobile Responsive --- */
@media (max-width: 768px) {
    .specimen-grid {
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
    }

    .specimen-card {
        margin-top: 0 !important;
    }

    .card-1 { transform: rotate(-0.5deg); }
    .card-2 { transform: rotate(0.5deg); }
    .card-3 { transform: rotate(-0.3deg); }
    .card-4 { transform: rotate(0.4deg); }
    .card-5 { transform: rotate(-0.5deg); }
    .card-6 { transform: rotate(0.3deg); }

    .kanji-spear { left: 5%; font-size: clamp(4rem, 12vw, 8rem); }
    .kanji-shield { right: 5%; font-size: clamp(4rem, 12vw, 8rem); }

    #vine-hero { width: 80%; }

    .specimen-card.expanded {
        transform: rotate(0deg) !important;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .specimen-grid {
        grid-template-columns: repeat(8, 1fr);
    }

    .card-1 { grid-column: 1 / 5; }
    .card-2 { grid-column: 4 / 8; }
    .card-3 { grid-column: 2 / 7; }
    .card-4 { grid-column: 1 / 5; }
    .card-5 { grid-column: 4 / 8; }
    .card-6 { grid-column: 2 / 7; }
}

/* --- Selection highlight --- */
::selection {
    background: var(--morning-dew);
    color: var(--deep-loam);
}
