/* ============================================
   ronri.org — Goblincore Cabinet of Logical Curiosities
   ============================================ */

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background-color: #F4EDE0;
    color: #504030;
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    line-height: 1.72;
    font-feature-settings: "onum" 1, "liga" 1;
    overflow-x: hidden;
    position: relative;
}

/* --- Paper Grain Texture Overlay --- */
#grain-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.04;
}

#grain-overlay::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='grain'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23grain)'/%3E%3C/svg%3E");
    background-repeat: repeat;
}

/* --- Root Network SVG --- */
#root-network {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

/* --- Typography --- */

/* Headings — Libre Baskerville */
.section-heading {
    font-family: 'Libre Baskerville', 'Georgia', serif;
    font-weight: 700;
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    letter-spacing: 0.02em;
    color: #3B2F1E;
    line-height: 1.15;
    margin-bottom: 1.5rem;
}

.section-heading-dark {
    color: #C9A84C;
}

/* Specimen Label Font — IM Fell English */
.specimen-label,
.card-title {
    font-family: 'IM Fell English', 'Georgia', serif;
}

/* Body Text */
.body-text {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    line-height: 1.72;
    color: #504030;
    margin-bottom: 1.5rem;
}

.body-text-dark {
    color: #D4C8B0;
}

/* Logic Notation — IBM Plex Mono */
.logic-notation {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.9em;
    color: #5E7A53;
    background: rgba(94, 122, 83, 0.08);
    padding: 0.1em 0.35em;
    border-left: 2px solid #5E7A53;
    border-radius: 0 2px 2px 0;
    white-space: nowrap;
}

.card-notation {
    margin-top: 1rem;
    padding: 0.8rem 1rem;
    background: rgba(94, 122, 83, 0.06);
    border-left: 3px solid #5E7A53;
    border-radius: 0 3px 3px 0;
}

.card-notation code {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.9em;
    color: #5E7A53;
}

/* Contradiction / Falsum marker */
.logic-contradiction {
    color: #8B3A2A;
    border-left-color: #8B3A2A;
    background: rgba(139, 58, 42, 0.06);
}

/* --- Links --- */
a {
    color: #8B6914;
    text-decoration: none;
    background-image: linear-gradient(#8B6914, #8B6914);
    background-size: 0% 1px;
    background-position: 0 100%;
    background-repeat: no-repeat;
    transition: background-size 300ms ease;
}

a:hover {
    background-size: 100% 1px;
}

/* ============================================
   HERO SECTION
   ============================================ */
#hero {
    position: relative;
    width: 100%;
    height: 100vh;
    min-height: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1;
    overflow: hidden;
}

#hero-content {
    text-align: center;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 800ms ease, transform 800ms ease;
}

#hero-content.visible {
    opacity: 1;
    transform: translateY(0);
}

#site-title {
    font-family: 'Libre Baskerville', 'Georgia', serif;
    font-weight: 700;
    font-size: clamp(3rem, 8vw, 6rem);
    color: #3B2F1E;
    letter-spacing: 0.02em;
    line-height: 1.1;
    margin-bottom: 0.3rem;
}

#japanese-subtitle {
    font-family: 'IM Fell English', 'Georgia', serif;
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    color: #6B5B3E;
    letter-spacing: 0.12em;
    margin-bottom: 0.6rem;
}

#tagline {
    font-family: 'IM Fell English', 'Georgia', serif;
    font-style: italic;
    font-size: clamp(1rem, 2vw, 1.4rem);
    color: #6B5B3E;
    letter-spacing: 0.04em;
}

/* --- Hero Bubble --- */
#hero-bubble {
    position: absolute;
    bottom: -120px;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 600ms ease;
}

#hero-bubble.visible {
    opacity: 1;
    animation: heroBubbleRise 8s ease-in-out forwards;
}

.bubble-body {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: radial-gradient(ellipse at 35% 25%, rgba(255,255,255,0.25), rgba(244,237,224,0.08) 50%, rgba(92,64,51,0.05));
    border: 1.5px solid rgba(92,64,51,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 -8px 20px rgba(92,64,51,0.06), 0 4px 20px rgba(92,64,51,0.08);
}

.bubble-reflection {
    position: absolute;
    top: 15px;
    left: 20px;
    width: 18px;
    height: 10px;
    background: rgba(255,255,255,0.45);
    border-radius: 50%;
    transform: rotate(-25deg);
}

.bubble-symbol {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1.6rem;
    color: #3B2F1E;
    opacity: 0.7;
}

@keyframes heroBubbleRise {
    0% {
        bottom: -120px;
        transform: translateX(-50%) translateY(0);
    }
    50% {
        transform: translateX(calc(-50% + 10px)) translateY(0);
    }
    100% {
        bottom: 45vh;
        transform: translateX(calc(-50% - 5px)) translateY(0);
    }
}

/* --- Scroll Chevron --- */
#scroll-chevron {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    animation: chevronPulse 2.5s ease-in-out infinite;
    animation-delay: 2s;
    z-index: 2;
}

@keyframes chevronPulse {
    0%, 100% { opacity: 0.3; transform: translateX(-50%) translateY(0); }
    50% { opacity: 0.7; transform: translateX(-50%) translateY(6px); }
}

/* --- Hero Mushrooms --- */
#hero-mushrooms {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) scale(0);
    transition: transform 600ms cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 1;
}

#hero-mushrooms.visible {
    transform: translateX(-50%) scale(1);
}

/* ============================================
   MUSHROOM CLUSTERS
   ============================================ */
.mushroom-cluster {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 4px;
    padding: 1rem 0;
    position: relative;
    z-index: 2;
}

.cluster-divider {
    margin: 0 auto;
    padding: 1.5rem 0;
}

.mushroom {
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 600ms ease-out;
}

.mushroom-cluster:hover .mushroom {
    transform: scaleY(1.08);
}

.mushroom-cap {
    width: 22px;
    height: 13px;
    border-radius: 50% 50% 4px 4px;
    background: radial-gradient(ellipse at 40% 30%, #8B6914, #5C4033);
    position: relative;
}

.mushroom-cap::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 5px;
    width: 6px;
    height: 3px;
    background: rgba(255,255,255,0.15);
    border-radius: 50%;
}

.mushroom-stem {
    width: 5px;
    height: 12px;
    background: linear-gradient(to right, #6B5B3E, #8B6914, #6B5B3E);
    border-radius: 0 0 2px 2px;
}

/* Mushroom size variations */
.m1 .mushroom-cap { width: 22px; height: 13px; }
.m1 .mushroom-stem { height: 12px; }

.m2 { transform: translateY(-4px); }
.m2 .mushroom-cap { width: 28px; height: 16px; }
.m2 .mushroom-stem { width: 6px; height: 16px; }

.m3 .mushroom-cap { width: 18px; height: 10px; }
.m3 .mushroom-stem { width: 4px; height: 9px; }

.m4 { transform: translateY(-2px) rotate(5deg); }
.m4 .mushroom-cap { width: 16px; height: 9px; }
.m4 .mushroom-stem { width: 3px; height: 8px; }

/* ============================================
   STRATA LINES
   ============================================ */
.strata-line {
    width: 100%;
    height: 30px;
    position: relative;
    z-index: 2;
    margin: 0.5rem 0;
}

.strata-line svg {
    width: 100%;
    height: 100%;
}

.strata-topsoil { opacity: 0.7; }
.strata-clay { opacity: 0.6; }
.strata-stone { opacity: 0.5; border-bottom: 1px solid #4A4A3A; }
.strata-deep { opacity: 0.6; }

/* ============================================
   CONTENT SECTIONS
   ============================================ */
.content-section {
    position: relative;
    z-index: 2;
    padding: 3rem 1.5rem;
}

.section-inner {
    max-width: 680px;
    margin-left: 52%;
    transform: translateX(-50%);
    position: relative;
}

/* --- Specimen Labels --- */
.specimen-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 1rem 0.35rem 1.8rem;
    border: 1px solid #5C4033;
    border-radius: 2px;
    font-family: 'IM Fell English', 'Georgia', serif;
    font-style: italic;
    font-size: clamp(0.85rem, 1.5vw, 1rem);
    color: #6B5B3E;
    letter-spacing: 0.04em;
    margin-bottom: 1rem;
    position: relative;
    background: rgba(244, 237, 224, 0.8);
}

.specimen-label-dark {
    border-color: #C9A84C;
    color: #C9A84C;
    background: rgba(45, 36, 24, 0.6);
}

.label-hole {
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1px solid #5C4033;
    background: #F4EDE0;
}

.specimen-label-dark .label-hole {
    border-color: #C9A84C;
    background: #2D2418;
}

.label-string {
    position: absolute;
    left: 10px;
    top: -12px;
    width: 1px;
    height: 12px;
    background: #5C4033;
    opacity: 0.4;
}

.specimen-label-dark .label-string {
    background: #C9A84C;
}

.label-text {
    user-select: none;
}

/* --- Marginal Notes --- */
.marginal-note {
    position: absolute;
    left: -220px;
    width: 180px;
    font-family: 'IM Fell English', 'Georgia', serif;
    font-style: italic;
    font-size: 0.82rem;
    line-height: 1.5;
    color: #6B5B3E;
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 500ms ease, transform 500ms ease;
}

.marginal-note.visible {
    opacity: 0.75;
    transform: translateX(0);
}

.note-marker {
    display: block;
    font-weight: 400;
    color: #8B6914;
    margin-bottom: 0.25rem;
}

/* --- Specimen Cards --- */
.specimen-card {
    background: #F4EDE0;
    border: 1px solid rgba(92, 64, 51, 0.2);
    padding: 1.8rem 1.5rem 1.5rem;
    margin: 2rem 0;
    position: relative;
    transform: rotate(var(--card-rotation, 0deg));
    transition: transform 500ms ease-out, box-shadow 300ms ease;
    clip-path: polygon(0 4px, 3px 2px, 8px 5px, 15px 0, 22px 3px, 30px 1px, 40px 4px, 52px 0, 65px 3px, 78px 1px, 90px 4px, 100% 0, 100% 100%, 0 100%);
    box-shadow: 2px 3px 10px rgba(59, 47, 30, 0.1);
}

.specimen-card:hover {
    transform: rotate(var(--card-rotation, 0deg)) translateY(-3px);
    box-shadow: 2px 6px 18px rgba(59, 47, 30, 0.18);
}

.card-pin {
    position: absolute;
    top: 12px;
    left: 14px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #8B6914, #5C4033);
    box-shadow: 1px 2px 4px rgba(59, 47, 30, 0.3);
}

.card-title {
    font-family: 'IM Fell English', 'Georgia', serif;
    font-size: clamp(1rem, 2vw, 1.4rem);
    letter-spacing: 0.04em;
    color: #3B2F1E;
    margin-bottom: 0.8rem;
    padding-left: 1.2rem;
}

.card-body {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: clamp(0.95rem, 1.6vw, 1.05rem);
    line-height: 1.68;
    color: #504030;
    margin-bottom: 0.8rem;
}

/* --- Pulse Attention Markers --- */
.pulse-marker {
    position: relative;
    display: inline;
}

.pulse-marker::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120%;
    height: 160%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(201, 168, 76, 0.12), transparent 70%);
    animation: pulseGlow 3s ease-in-out infinite;
    pointer-events: none;
}

@keyframes pulseGlow {
    0%, 100% { transform: translate(-50%, -50%) scale(0.8); opacity: 0.12; }
    50% { transform: translate(-50%, -50%) scale(1.2); opacity: 0.06; }
}

/* ============================================
   THE LOGIC AQUARIUM
   ============================================ */
#aquarium-transition {
    height: 200px;
    background: linear-gradient(to bottom, #F4EDE0, #2D2418);
    position: relative;
    z-index: 2;
}

#logic-aquarium {
    background-color: #2D2418;
    position: relative;
    z-index: 2;
    padding: 4rem 1.5rem;
    min-height: 80vh;
    overflow: hidden;
}

#aquarium-inner,
#aquarium-inner-bottom {
    max-width: 680px;
    margin-left: 52%;
    transform: translateX(-50%);
    position: relative;
    z-index: 3;
}

#aquarium-inner-bottom {
    margin-top: 3rem;
}

#aquarium-transition-out {
    height: 200px;
    background: linear-gradient(to bottom, #2D2418, #F4EDE0);
    position: relative;
    z-index: 2;
}

/* --- Bubble Tank --- */
#bubble-tank {
    position: relative;
    width: 100%;
    height: 400px;
    margin: 2rem 0;
    overflow: hidden;
    z-index: 2;
}

.aquarium-bubble {
    position: absolute;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 35% 25%, rgba(255,255,255,0.18), rgba(201,168,76,0.05) 50%, rgba(45,36,24,0.03));
    border: 1px solid rgba(201, 168, 76, 0.12);
    box-shadow: inset 0 -6px 15px rgba(0,0,0,0.05), 0 2px 10px rgba(0,0,0,0.1);
    will-change: transform, opacity;
}

.aquarium-bubble .bubble-reflection {
    position: absolute;
    top: 20%;
    left: 25%;
    width: 25%;
    height: 14%;
    background: rgba(255,255,255,0.3);
    border-radius: 50%;
    transform: rotate(-25deg);
}

.aquarium-bubble .bubble-symbol {
    font-family: 'IBM Plex Mono', monospace;
    color: #D4C8B0;
    opacity: 0.8;
    z-index: 1;
}

@keyframes bubbleRise {
    0% {
        transform: translateY(420px) translateX(0px);
        opacity: 0;
    }
    5% {
        opacity: 1;
    }
    25% {
        transform: translateY(310px) translateX(var(--drift-x, 10px));
    }
    50% {
        transform: translateY(200px) translateX(calc(var(--drift-x, 10px) * -1));
    }
    75% {
        transform: translateY(90px) translateX(var(--drift-x, 10px));
    }
    95% {
        opacity: 1;
    }
    100% {
        transform: translateY(-40px) translateX(0px);
        opacity: 0;
    }
}

@keyframes bubblePop {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.15); opacity: 0; }
}

/* ============================================
   LOGIC NOTATION HOVER
   ============================================ */
.logic-notation {
    transition: border-left-color 300ms ease;
}

.logic-notation:hover {
    border-left-color: #C9A84C;
}

/* ============================================
   ANIMATION STATES
   ============================================ */
[data-animate] {
    opacity: 0;
    transition: opacity 500ms ease, transform 500ms ease;
}

[data-animate="fade"] {
    opacity: 0;
}

[data-animate="fade-up"] {
    opacity: 0;
    transform: translateY(10px);
}

[data-animate="slide-left"] {
    opacity: 0;
    transform: translateX(-20px);
}

[data-animate="rotate-in"] {
    opacity: 0;
    transform: rotate(0deg) scale(0.97);
}

[data-animate].animated {
    opacity: 1;
    transform: translateY(0) translateX(0) rotate(var(--card-rotation, 0deg)) scale(1);
}

/* Specific fix for fade-only */
[data-animate="fade"].animated {
    opacity: 1;
    transform: none;
}

/* Specific fix for slide-left (marginal notes) */
[data-animate="slide-left"].animated {
    opacity: 0.75;
    transform: translateX(0);
}

/* ============================================
   FOOTER
   ============================================ */
#site-footer {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 4rem 1.5rem 3rem;
    border-top: 1px solid rgba(92, 64, 51, 0.15);
}

.footer-text {
    font-family: 'Libre Baskerville', 'Georgia', serif;
    font-weight: 700;
    font-size: 1.2rem;
    color: #3B2F1E;
    letter-spacing: 0.02em;
    margin-bottom: 0.4rem;
}

.footer-sub {
    font-family: 'IM Fell English', 'Georgia', serif;
    font-style: italic;
    font-size: 0.9rem;
    color: #6B5B3E;
    letter-spacing: 0.04em;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1000px) {
    .section-inner {
        margin-left: 50%;
    }

    .marginal-note {
        position: relative;
        left: 0;
        width: 100%;
        margin-bottom: 1rem;
        padding-left: 1rem;
        border-left: 2px solid #8B6914;
        opacity: 0.75;
        transform: none;
    }

    .marginal-note.visible {
        opacity: 0.75;
        transform: none;
    }
}

@media (max-width: 768px) {
    .section-inner {
        margin-left: auto;
        margin-right: auto;
        transform: none;
        max-width: 90%;
    }

    #aquarium-inner,
    #aquarium-inner-bottom {
        margin-left: auto;
        margin-right: auto;
        transform: none;
        max-width: 90%;
    }

    .specimen-card {
        margin-left: 0;
        margin-right: 0;
    }

    #hero-mushrooms {
        bottom: 100px;
    }
}

@media (max-width: 480px) {
    .section-inner,
    #aquarium-inner,
    #aquarium-inner-bottom {
        max-width: 95%;
    }

    .specimen-card {
        padding: 1.4rem 1rem 1rem;
    }
}
