/* ============================================
   riron.org — Ethereal Theory Library
   ============================================ */

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

html {
    scroll-behavior: smooth;
}

body {
    background: #0e0a1a; /* Ink Shadow: #1a1028 used in cards */
    color: #d8d0e8;
    font-family: 'Quicksand', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.8vw, 1.15rem);
    line-height: 1.75;
    overflow-x: hidden;
    min-height: 100vh;
}

/* ---- Fog Layer ---- */
#fog-layer {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

.fog-gradient {
    position: absolute;
    inset: 0;
    opacity: 1;
}

.fog-a {
    background: radial-gradient(ellipse at 30% 20%, #7c5cbf22 0%, transparent 60%);
    animation: fogA 20s ease-in-out infinite alternate;
}

.fog-b {
    background: radial-gradient(ellipse at 70% 80%, #d4a85022 0%, transparent 55%);
    animation: fogB 35s ease-in-out infinite alternate;
}

.fog-c {
    background: radial-gradient(ellipse at 50% 50%, #c0788822 0%, transparent 50%);
    animation: fogC 50s ease-in-out infinite alternate;
}

@keyframes fogA {
    0% { background: radial-gradient(ellipse at 30% 20%, #7c5cbf22 0%, transparent 60%); }
    100% { background: radial-gradient(ellipse at 60% 40%, #7c5cbf22 0%, transparent 60%); }
}

@keyframes fogB {
    0% { background: radial-gradient(ellipse at 70% 80%, #d4a85022 0%, transparent 55%); }
    100% { background: radial-gradient(ellipse at 40% 60%, #d4a85022 0%, transparent 55%); }
}

@keyframes fogC {
    0% { background: radial-gradient(ellipse at 50% 50%, #c0788822 0%, transparent 50%); }
    100% { background: radial-gradient(ellipse at 30% 70%, #c0788822 0%, transparent 50%); }
}

/* ---- Hue shift via JS variable ---- */
#fog-layer {
    filter: hue-rotate(var(--fog-hue-shift, 0deg));
    transition: filter 300ms ease;
}

/* ---- Blob Field ---- */
.blob-container {
    position: fixed;
    width: 0;
    height: 0;
    overflow: visible;
}

#blob-field {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
}

.blob-1 {
    width: 400px; height: 400px;
    background: #7c5cbf;
    opacity: 0.08;
    top: 5%; left: 10%;
    animation: blobDrift1 25s ease-in-out infinite alternate;
}
.blob-2 {
    width: 300px; height: 350px;
    background: #c07888;
    opacity: 0.06;
    top: 20%; right: 5%;
    animation: blobDrift2 30s ease-in-out infinite alternate;
}
.blob-3 {
    width: 500px; height: 450px;
    background: #d4a850;
    opacity: 0.07;
    top: 40%; left: 30%;
    animation: blobDrift3 37s ease-in-out infinite alternate;
}
.blob-4 {
    width: 350px; height: 300px;
    background: #7c5cbf;
    opacity: 0.09;
    top: 55%; right: 15%;
    animation: blobDrift4 42s ease-in-out infinite alternate;
}
.blob-5 {
    width: 280px; height: 320px;
    background: #c07888;
    opacity: 0.06;
    top: 70%; left: 5%;
    animation: blobDrift5 33s ease-in-out infinite alternate;
}
.blob-6 {
    width: 420px; height: 380px;
    background: #d4a850;
    opacity: 0.08;
    top: 85%; right: 20%;
    animation: blobDrift6 28s ease-in-out infinite alternate;
}
.blob-7 {
    width: 250px; height: 280px;
    background: #b8a8d0;
    opacity: 0.05;
    top: 15%; left: 55%;
    animation: blobDrift7 45s ease-in-out infinite alternate;
}
.blob-8 {
    width: 360px; height: 340px;
    background: #c4a0e0;
    opacity: 0.07;
    top: 35%; right: 35%;
    animation: blobDrift8 38s ease-in-out infinite alternate;
}
.blob-9 {
    width: 300px; height: 280px;
    background: #7c5cbf;
    opacity: 0.06;
    top: 60%; left: 45%;
    animation: blobDrift1 31s ease-in-out infinite alternate;
}
.blob-10 {
    width: 380px; height: 350px;
    background: #c07888;
    opacity: 0.07;
    top: 90%; left: 25%;
    animation: blobDrift3 40s ease-in-out infinite alternate;
}

@keyframes blobDrift1 {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(60px, 40px) scale(1.15); }
}
@keyframes blobDrift2 {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(-50px, 60px) scale(1.1); }
}
@keyframes blobDrift3 {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(40px, -50px) scale(1.2); }
}
@keyframes blobDrift4 {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(-70px, 30px) scale(1.08); }
}
@keyframes blobDrift5 {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, -40px) scale(1.12); }
}
@keyframes blobDrift6 {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(-30px, -60px) scale(1.18); }
}
@keyframes blobDrift7 {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(45px, 55px) scale(1.05); }
}
@keyframes blobDrift8 {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(-55px, -35px) scale(1.14); }
}

/* ---- Hero Section ---- */
#hero {
    position: relative;
    z-index: 3;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.kanji-svg {
    width: clamp(250px, 50vw, 450px);
    height: auto;
}

.kanji-stroke {
    opacity: 0.85;
}

/* Per-stroke drift animations */
.ks-1  { animation: strokeDrift1 8s ease-in-out infinite alternate; }
.ks-2  { animation: strokeDrift2 10s ease-in-out infinite alternate; }
.ks-3  { animation: strokeDrift3 9s ease-in-out infinite alternate; }
.ks-4  { animation: strokeDrift4 11s ease-in-out infinite alternate; }
.ks-5  { animation: strokeDrift5 8.5s ease-in-out infinite alternate; }
.ks-6  { animation: strokeDrift6 12s ease-in-out infinite alternate; }
.ks-7  { animation: strokeDrift7 9.5s ease-in-out infinite alternate; }
.ks-8  { animation: strokeDrift1 10.5s ease-in-out infinite alternate; }
.ks-9  { animation: strokeDrift3 11.5s ease-in-out infinite alternate; }
.ks-10 { animation: strokeDrift5 9s ease-in-out infinite alternate; }
.ks-11 { animation: strokeDrift7 10s ease-in-out infinite alternate; }
.ks-12 { animation: strokeDrift2 8s ease-in-out infinite alternate; }
.ks-13 { animation: strokeDrift4 9.5s ease-in-out infinite alternate; }
.ks-14 { animation: strokeDrift6 10s ease-in-out infinite alternate; }
.ks-15 { animation: strokeDrift1 11s ease-in-out infinite alternate; }
.ks-16 { animation: strokeDrift3 8.5s ease-in-out infinite alternate; }
.ks-17 { animation: strokeDrift5 12s ease-in-out infinite alternate; }
.ks-18 { animation: strokeDrift7 9s ease-in-out infinite alternate; }
.ks-19 { animation: strokeDrift2 10.5s ease-in-out infinite alternate; }
.ks-20 { animation: strokeDrift4 11.5s ease-in-out infinite alternate; }
.ks-21 { animation: strokeDrift6 8s ease-in-out infinite alternate; }
.ks-22 { animation: strokeDrift1 9.5s ease-in-out infinite alternate; }
.ks-23 { animation: strokeDrift3 10s ease-in-out infinite alternate; }
.ks-24 { animation: strokeDrift5 11s ease-in-out infinite alternate; }

@keyframes strokeDrift1 { 0% { transform: translate(0,0); } 100% { transform: translate(3px, -5px); } }
@keyframes strokeDrift2 { 0% { transform: translate(0,0); } 100% { transform: translate(-4px, 3px); } }
@keyframes strokeDrift3 { 0% { transform: translate(0,0); } 100% { transform: translate(5px, 2px); } }
@keyframes strokeDrift4 { 0% { transform: translate(0,0); } 100% { transform: translate(-2px, -6px); } }
@keyframes strokeDrift5 { 0% { transform: translate(0,0); } 100% { transform: translate(6px, 4px); } }
@keyframes strokeDrift6 { 0% { transform: translate(0,0); } 100% { transform: translate(-5px, -3px); } }
@keyframes strokeDrift7 { 0% { transform: translate(0,0); } 100% { transform: translate(4px, -8px); } }

.hero-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 300;
    font-size: clamp(3rem, 10vw, 8rem);
    letter-spacing: 0.3em;
    text-transform: lowercase;
    color: #f0e8d8;
    animation: pulse 6s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.9; }
}

.hero-subtitle {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-style: italic;
    font-size: clamp(0.9rem, 2vw, 1.3rem);
    color: #e8e0f4;
    opacity: 0.5;
    letter-spacing: 0.05em;
}

/* ---- Floating Books ---- */
.floating-book {
    position: absolute;
    z-index: 2;
    width: 120px;
    height: auto;
    pointer-events: none;
}

.book-1 {
    top: 130vh;
    left: 8%;
    animation: bookFloat 15s ease-in-out infinite alternate;
}
.book-2 {
    top: 250vh;
    right: 5%;
    animation: bookFloat 15s ease-in-out infinite alternate-reverse;
}
.book-3 {
    top: 380vh;
    left: 15%;
    animation: bookFloat 15s ease-in-out infinite alternate;
}

@keyframes bookFloat {
    0% { transform: rotate(-3deg); }
    100% { transform: rotate(3deg); }
}

/* ---- Masonry Section ---- */
#masonry-section {
    position: relative;
    z-index: 3;
    padding: 4rem 5%;
}

.masonry-grid {
    column-count: 3;
    column-gap: 2.5rem;
    max-width: 1400px;
    margin: 0 auto;
}

.masonry-card {
    break-inside: avoid;
    margin-bottom: 2rem;
    padding: 2rem 2.2rem;
    border-radius: 20px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    background: rgba(26, 16, 40, 0.45);
    box-shadow: 0 0 40px rgba(180, 160, 220, 0.15);
    transition: filter 800ms cubic-bezier(0.22, 1, 0.36, 1),
                opacity 800ms cubic-bezier(0.22, 1, 0.36, 1),
                background 400ms ease;
    filter: blur(8px);
    opacity: 0.3;
    position: relative;
}

.masonry-card.in-view {
    filter: blur(0);
    opacity: 1;
}

.masonry-card.past-view {
    filter: blur(2px);
    opacity: 0.7;
}

.masonry-card:hover {
    background: linear-gradient(135deg, rgba(124, 92, 191, 0.12), rgba(212, 168, 80, 0.08)),
                rgba(26, 16, 40, 0.55);
}

/* Page curl effect on every 4th card */
.card-with-curl::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 40px;
    height: 40px;
    background: linear-gradient(225deg, #0e0a1a 45%, rgba(184, 168, 208, 0.15) 45%, rgba(184, 168, 208, 0.08) 60%, transparent 60%);
    border-radius: 0 20px 0 0;
}

.card-label {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-style: italic;
    font-size: clamp(1.2rem, 2.5vw, 2rem);
    letter-spacing: 0.05em;
    color: #c4a0e0;
    margin-bottom: 0.8rem;
}

.card-math {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-style: italic;
    font-size: clamp(1.1rem, 2vw, 1.5rem);
    color: #e8e0f4;
    text-align: center;
    padding: 1rem 0;
}

.card-concept {
    display: block;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 300;
    font-size: 2.5rem;
    color: #f0e8d8;
    margin-bottom: 0.5rem;
}

.card-concept em {
    font-family: 'Quicksand', sans-serif;
    font-size: 1rem;
    color: #b8a8d0;
    margin-left: 0.5rem;
    font-style: normal;
}

.card-concept-desc {
    font-size: 0.95rem;
    color: #b8a8d0;
    font-style: italic;
}

.masonry-card p + p {
    margin-top: 1rem;
}

/* ---- Margin Annotations ---- */
.margin-annotation {
    position: absolute;
    z-index: 2;
    width: 60px;
    pointer-events: none;
}

.annot-1 {
    top: 160vh;
    right: 3%;
}

.annot-2 {
    top: 300vh;
    left: 2%;
}

.annot-path {
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    transition: stroke-dashoffset 2s ease;
}

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

/* ---- Kanji Particles ---- */
#kanji-particles {
    position: fixed;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    overflow: hidden;
}

.kanji-particle {
    position: absolute;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 14px;
    color: #b8a8d0;
    pointer-events: none;
    will-change: transform;
}

@keyframes floatUp {
    0% {
        transform: translateY(0) translateX(0);
        opacity: var(--particle-opacity);
    }
    100% {
        transform: translateY(-110vh) translateX(calc(sin(var(--drift)) * 40px));
        opacity: 0;
    }
}

/* ---- Final Section ---- */
#final-section {
    position: relative;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: 4rem 2rem;
}

.final-statement {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-style: italic;
    font-size: clamp(1.5rem, 4vw, 3rem);
    color: #f0e8d8;
    opacity: 0.7;
    text-align: center;
    letter-spacing: 0.05em;
}

#fog-fadeout {
    position: relative;
    z-index: 2;
    height: 30vh;
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
    .masonry-grid {
        column-count: 2;
    }
}

@media (max-width: 560px) {
    .masonry-grid {
        column-count: 1;
        max-width: 500px;
    }

    #masonry-section {
        padding: 3rem 4%;
    }
}
