/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --parchment: #FDFAF4;
    --rose: #8D2B4A;
    --amber: #D4952B;
    --gold: #F0C864;
    --warm-gray: #8A8078;
    --ink: #2A2520;
    --cream: #F5F0E8;
    --teal: #2B8D8D;

    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;

    --radius-blob: 32px;
    --radius-blob-lg: 48px;
}

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

body {
    font-family: var(--font-body);
    background-color: var(--parchment);
    color: var(--ink);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    line-height: 1.6;
}

/* ===== GRAIN OVERLAY ===== */
.grain-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    pointer-events: none;
    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)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
}

/* ===== AMBIENT BLOBS ===== */
.ambient-blob {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.15;
    pointer-events: none;
    z-index: 0;
    animation: blob-drift 20s ease-in-out infinite alternate;
}

.ambient-blob--1 {
    width: 600px;
    height: 600px;
    background: var(--amber);
    top: -10%;
    left: -5%;
}

.ambient-blob--2 {
    width: 500px;
    height: 500px;
    background: var(--teal);
    bottom: -10%;
    right: -5%;
    animation-delay: -7s;
}

.ambient-blob--3 {
    width: 400px;
    height: 400px;
    background: var(--rose);
    top: 40%;
    left: 50%;
    animation-delay: -14s;
}

@keyframes blob-drift {
    0% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -20px) scale(1.05); }
    66% { transform: translate(-20px, 30px) scale(0.95); }
    100% { transform: translate(10px, 10px) scale(1.02); }
}

/* ===== CIRCUIT TRACES ===== */
.circuit-traces {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    width: 100%;
    height: 100%;
}

.trace {
    fill: none;
    stroke: var(--teal);
    stroke-width: 1px;
    opacity: 0.12;
    stroke-linecap: square;
}

.trace-node {
    fill: var(--teal);
    opacity: 0.15;
}

/* ===== HEADER ===== */
.site-header {
    position: relative;
    z-index: 10;
    text-align: center;
    padding: clamp(3rem, 8vh, 6rem) 2rem clamp(2rem, 4vh, 3rem);
}

.site-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
}

.title-kanji {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 6vw, 5rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--ink);
    line-height: 1.1;
}

.title-romaji {
    font-family: var(--font-mono);
    font-size: clamp(0.75rem, 1.5vw, 1rem);
    font-weight: 400;
    color: var(--warm-gray);
    letter-spacing: 0.2em;
    text-transform: lowercase;
}

.thesis-statement {
    font-family: var(--font-body);
    font-size: clamp(0.9rem, 1.8vw, 1.15rem);
    color: var(--warm-gray);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.7;
    font-weight: 400;
}

/* ===== BLOCK FIELD ===== */
.block-field {
    position: relative;
    z-index: 10;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
    padding: 2rem clamp(1.5rem, 4vw, 4rem);
    max-width: 1400px;
    margin: 0 auto;
}

/* ===== THEOREM BLOCKS ===== */
.theorem-block {
    position: relative;
    background: var(--cream);
    border-radius: var(--radius-blob);
    padding: 0;
    overflow: hidden;
    transition: transform 0.5s cubic-bezier(0.23, 1, 0.32, 1),
                box-shadow 0.5s cubic-bezier(0.23, 1, 0.32, 1);
    box-shadow:
        inset 2px 2px 8px rgba(42, 37, 32, 0.06),
        0 4px 20px rgba(42, 37, 32, 0.04);
    cursor: default;
}

.theorem-block:hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow:
        inset 2px 2px 8px rgba(42, 37, 32, 0.06),
        0 12px 40px rgba(42, 37, 32, 0.08);
}

.theorem-block--large {
    grid-column: span 2;
}

.theorem-block--small {
    grid-column: span 1;
}

.theorem-block--medium {
    grid-column: span 1;
}

.block-inner {
    position: relative;
    z-index: 2;
    padding: clamp(1.5rem, 3vw, 2.5rem);
}

.block-header {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.theorem-number {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--teal);
    letter-spacing: 0.05em;
}

.theorem-title {
    font-family: var(--font-display);
    font-size: clamp(1.25rem, 2.5vw, 1.75rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--ink);
    line-height: 1.2;
}

.theorem-body {
    font-family: var(--font-body);
    font-size: clamp(0.85rem, 1.2vw, 0.95rem);
    color: var(--warm-gray);
    line-height: 1.75;
    margin-bottom: 1.25rem;
}

.theorem-tag {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--rose);
    background: rgba(141, 43, 74, 0.08);
    padding: 0.25rem 0.75rem;
    border-radius: 100px;
    letter-spacing: 0.04em;
}

/* ===== VACUUM GLOW ===== */
.vacuum-glow {
    position: absolute;
    bottom: -30px;
    right: -30px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--gold) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.6s ease;
    pointer-events: none;
    z-index: 1;
}

.theorem-block:hover .vacuum-glow {
    opacity: 0.25;
}

/* ===== FOOTER ===== */
.site-footer {
    position: relative;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3rem clamp(1.5rem, 4vw, 4rem);
    max-width: 1400px;
    margin: 2rem auto 0;
    border-top: 1px solid rgba(42, 37, 32, 0.08);
}

.footer-mark {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--warm-gray);
    letter-spacing: 0.05em;
}

.footer-year {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--warm-gray);
}

/* ===== BLOCK ENTRANCE ANIMATION ===== */
.theorem-block {
    opacity: 0;
    transform: translateY(30px);
}

.theorem-block.visible {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.8s cubic-bezier(0.23, 1, 0.32, 1),
                transform 0.8s cubic-bezier(0.23, 1, 0.32, 1),
                box-shadow 0.5s cubic-bezier(0.23, 1, 0.32, 1);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .block-field {
        grid-template-columns: 1fr;
    }

    .theorem-block--large {
        grid-column: span 1;
    }

    .site-header {
        padding: 2rem 1.5rem 1.5rem;
    }
}

@media (max-width: 480px) {
    .block-field {
        padding: 1rem;
        gap: 16px;
    }

    .theorem-block {
        border-radius: 24px;
    }
}
