/* ============================================
   MMIDDL.com — Design System
   Wabi-sabi / Kintsugi / Ma (negative space)
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    /* Palette */
    --primary-ground: #f5f0e8;
    --deep-earth: #2c2416;
    --kintsugi-gold: #c4973b;
    --stone-gray: #9b9283;
    --celadon-glaze: #8faa96;
    --crack-shadow: #d4cbbf;
    --kiln-charcoal: #4a3f31;
    --warm-gray: #8a7e6b;

    /* Typography */
    --font-display: 'Cormorant Garamond', 'Georgia', serif;
    --font-body: 'Source Serif 4', 'Georgia', serif;
    --font-accent: 'Caveat', cursive;

    /* Layout */
    --column-width: 55vw;
    --column-offset: 0%;
}

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

html {
    scroll-behavior: auto;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--primary-ground);
    color: var(--deep-earth);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 18px;
    line-height: 1.85;
    overflow-x: hidden;
    position: relative;
}

/* --- SVG Filters (hidden) --- */
.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* --- Paper Grain Overlay --- */
.paper-grain {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.04;
    filter: url(#grain);
    mix-blend-mode: multiply;
}

/* --- Hairline Fractures Background --- */
.fractures-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.fracture {
    fill: none;
    stroke: var(--crack-shadow);
    stroke-width: 0.8;
    opacity: 0;
    transition: opacity 1.5s ease-in-out;
}

.fracture.visible {
    opacity: 0.4;
}

.fracture-initial {
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    opacity: 0.4;
    transition: stroke-dashoffset 1.5s ease-in-out;
}

.fracture-initial.drawn {
    stroke-dashoffset: 0;
}

/* --- Navigation Wordmark --- */
.nav-wordmark {
    position: fixed;
    top: 28px;
    left: 36px;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.8s ease-in-out;
    pointer-events: none;
}

.nav-wordmark.visible {
    opacity: 1;
    pointer-events: auto;
}

.nav-wordmark-text {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: 20px;
    letter-spacing: 0.15em;
    color: var(--kiln-charcoal);
}

/* --- Section: Stillness --- */
.section-stillness {
    position: relative;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.stillness-center {
    text-align: center;
}

.wordmark {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(56px, 8vw, 96px);
    letter-spacing: 0.5em;
    color: var(--deep-earth);
    transition: letter-spacing 2s cubic-bezier(0.25, 0.1, 0.25, 1);
    user-select: none;
}

.wordmark.settled {
    letter-spacing: 0.15em;
}

/* --- Kintsugi Seams --- */
.kintsugi-seam {
    position: relative;
    width: 100%;
    height: 80px;
    z-index: 10;
    margin: 2vh 0;
}

.kintsugi-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.kintsugi-path {
    fill: none;
    stroke: var(--kintsugi-gold);
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 2s cubic-bezier(0.25, 0.1, 0.25, 1);
}

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

/* --- Content Columns --- */
.content-column {
    position: relative;
    z-index: 10;
    margin: 0 auto;
    padding: 6vh 0;
    width: var(--column-width);
    transition: width 0.3s ease-out;
}

.content-wide {
    max-width: 70vw;
    min-width: 40vw;
}

.content-narrow {
    max-width: 40vw;
    min-width: 30vw;
    width: 40vw;
}

.content-final {
    max-width: 35vw;
    min-width: 28vw;
    width: 35vw;
}

/* Drift offset */
.content-column[data-drift="left"] {
    margin-left: calc(50% - var(--column-width) / 2 - 4%);
    margin-right: auto;
}

.content-column[data-drift="right"] {
    margin-left: auto;
    margin-right: calc(50% - var(--column-width) / 2 - 4%);
}

/* --- Body Text --- */
.body-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 18px;
    line-height: 1.85;
    color: var(--deep-earth);
    text-indent: 2.5em;
}

.statement-text {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(28px, 3.5vw, 44px);
    line-height: 1.4;
    text-indent: 0;
    color: var(--kiln-charcoal);
    padding: 4vh 0;
}

/* --- Floating Islands --- */
.floating-island {
    position: relative;
    z-index: 10;
    width: clamp(180px, 18vw, 240px);
    padding: 20px 24px;
    border: 1px solid var(--crack-shadow);
    background-color: var(--primary-ground);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23g)' opacity='0.08'/%3E%3C/svg%3E");
    opacity: 0.3;
    filter: blur(4px);
    transition: opacity 1.2s ease-in-out, filter 1.2s ease-in-out;
}

.floating-island.revealed {
    opacity: 1;
    filter: blur(0px);
}

.island-right {
    margin-left: auto;
    margin-right: 6vw;
}

.island-left {
    margin-left: 6vw;
    margin-right: auto;
}

.floating-island[data-rotate="2.1"] {
    transform: rotate(2.1deg);
}

.floating-island[data-rotate="-1.8"] {
    transform: rotate(-1.8deg);
}

.floating-island[data-rotate="1.3"] {
    transform: rotate(1.3deg);
}

.floating-island[data-rotate="-2.5"] {
    transform: rotate(-2.5deg);
}

.annotation-text {
    font-family: var(--font-accent);
    font-weight: 400;
    font-size: 17px;
    line-height: 1.5;
    color: var(--warm-gray);
}

/* --- Section: First Crack --- */
.section-firstcrack {
    position: relative;
    z-index: 10;
    padding: 8vh 0;
}

/* --- Section: The River --- */
.section-river {
    position: relative;
    z-index: 10;
    padding: 8vh 0;
}

/* --- Section: The Clearing --- */
.section-clearing {
    position: relative;
    z-index: 10;
    padding: 8vh 0;
}

/* --- Terminal Clearing --- */
.terminal-clearing {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 80vh;
    position: relative;
}

.breathing-circle {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--celadon-glaze);
    opacity: 0;
    transition: opacity 1s ease-in-out;
}

.breathing-circle.active {
    animation: breathe 4s ease-in-out infinite;
}

@keyframes breathe {
    0%, 100% {
        opacity: 0.2;
    }
    50% {
        opacity: 0.8;
    }
}

.closing-text {
    font-family: var(--font-accent);
    font-weight: 400;
    font-size: 16px;
    color: var(--crack-shadow);
    margin-top: 40px;
    letter-spacing: 0.05em;
    opacity: 0;
    transition: opacity 2s ease-in-out;
}

.closing-text.visible {
    opacity: 0.6;
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .wordmark {
        font-size: clamp(36px, 10vw, 64px);
    }

    .content-column,
    .content-wide,
    .content-narrow,
    .content-final {
        width: 85vw;
        max-width: 85vw;
        min-width: 85vw;
    }

    .content-column[data-drift="left"],
    .content-column[data-drift="right"] {
        margin-left: auto;
        margin-right: auto;
    }

    .floating-island {
        width: clamp(160px, 50vw, 240px);
        margin-left: auto;
        margin-right: 8vw;
    }

    .island-left {
        margin-left: 8vw;
        margin-right: auto;
    }

    .statement-text {
        font-size: clamp(22px, 5vw, 36px);
    }

    .terminal-clearing {
        height: 60vh;
    }
}

@media (max-width: 600px) {
    .wordmark {
        font-size: clamp(28px, 12vw, 48px);
        letter-spacing: 0.3em;
    }

    .wordmark.settled {
        letter-spacing: 0.08em;
    }

    .body-text {
        font-size: 16px;
        text-indent: 1.5em;
    }

    .content-column,
    .content-wide,
    .content-narrow,
    .content-final {
        width: 90vw;
        max-width: 90vw;
        min-width: 90vw;
        padding: 4vh 0;
    }

    .floating-island {
        width: 70vw;
        margin-left: auto;
        margin-right: auto;
    }

    .island-left {
        margin-left: auto;
    }

    .nav-wordmark {
        top: 16px;
        left: 20px;
    }

    .nav-wordmark-text {
        font-size: 16px;
    }
}
