/* ==========================================================================
   mujun.cafe — between two moments
   Palette: Warm-Earthy
     #1A1410 charcoal kiln   (background deep)
     #211A12 ember dim       (re-stoked kiln)
     #2C2218 smoked cedar    (background mid / blob)
     #3D3025 clay slip       (surface)
     #A67B5B raw umber       (accent deep)
     #C2703E ember glow      (accent warm)
     #C4A882 tea stain       (secondary text)
     #D9C8B4 fog veil        (atmospheric)
     #E8D5C4 warm parchment  (primary text)
   Fonts: Quicksand (display), Nunito (body), Caveat (whisper)
   ========================================================================== */

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

:root {
    --charcoal-kiln: #1A1410;
    --ember-dim:     #211A12;
    --smoked-cedar:  #2C2218;
    --clay-slip:     #3D3025;
    --raw-umber:     #A67B5B;
    --ember-glow:    #C2703E;
    --tea-stain:     #C4A882;
    --fog-veil:      #D9C8B4;
    --parchment:     #E8D5C4;

    --font-display: "Quicksand", "Inter", system-ui, sans-serif;
    --font-body:    "Nunito", "Inter", system-ui, sans-serif;
    --font-whisper: "Caveat", "Inter", cursive;

    --ease-soft: cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--charcoal-kiln);
    color: var(--parchment);
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 17px;
    line-height: 1.85;
    overflow-x: hidden;
    min-height: 100vh;
    position: relative;
}

.svg-defs {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* ==========================================================================
   Living grain surface — analog film running through a projector
   ========================================================================== */
.grain-field {
    position: fixed;
    inset: -10%;
    pointer-events: none;
    z-index: 90;
    opacity: 0.06;
    background-image:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' seed='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.92  0 0 0 0 0.84  0 0 0 0 0.71  0 0 0 0.6 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
    background-size: 240px 240px;
    animation: grain-shift 0.42s steps(6) infinite, grain-pulse 11s ease-in-out infinite;
    mix-blend-mode: screen;
}

@keyframes grain-shift {
    0%   { transform: translate(0,    0); }
    16%  { transform: translate(-6%,  3%); }
    32%  { transform: translate(4%,  -5%); }
    48%  { transform: translate(-3%, -8%); }
    64%  { transform: translate(8%,   2%); }
    80%  { transform: translate(-5%,  6%); }
    100% { transform: translate(2%,  -4%); }
}

@keyframes grain-pulse {
    0%, 100% { opacity: 0.05; }
    50%      { opacity: 0.075; }
}

/* ==========================================================================
   Background wash — drives subtle scroll-tied warmth shifts
   ========================================================================== */
.background-wash {
    position: fixed;
    inset: 0;
    z-index: -2;
    pointer-events: none;
    background:
        radial-gradient(ellipse at 20% 18%, rgba(194, 112, 62, 0.045) 0%, rgba(194, 112, 62, 0) 55%),
        radial-gradient(ellipse at 80% 60%, rgba(166, 123, 91, 0.04) 0%, rgba(166, 123, 91, 0) 60%),
        linear-gradient(180deg, var(--charcoal-kiln) 0%, var(--ember-dim) 60%, #15100D 100%);
    transition: background-color 800ms var(--ease-soft);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(ellipse 120% 80% at 50% 110%, rgba(194, 112, 62, 0.06) 0%, rgba(194, 112, 62, 0) 70%),
        radial-gradient(ellipse 90% 60% at 50% -10%, rgba(217, 200, 180, 0.025) 0%, rgba(217, 200, 180, 0) 70%);
}

/* ==========================================================================
   Drifting blobs — slow living shapes behind content
   ========================================================================== */
.blob-layer {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
}

.blob {
    position: absolute;
    width: 400px;
    height: 400px;
    filter: blur(32px);
    opacity: 0;
    transition: opacity 1600ms var(--ease-soft);
    will-change: transform;
}

.blob.active { opacity: 1; }

.blob-1 {
    top: 8%;
    left: -6%;
    width: 320px;
    height: 320px;
    opacity: 0.55;
    animation: drift-1 48s ease-in-out infinite;
}

.blob-2 {
    top: 35%;
    right: -4%;
    width: 380px;
    height: 380px;
    opacity: 0.45;
    animation: drift-2 56s ease-in-out infinite;
}

.blob-3 {
    bottom: 12%;
    left: 18%;
    width: 220px;
    height: 220px;
    opacity: 0.12;
    filter: blur(40px);
    animation: drift-3 38s ease-in-out infinite;
}

.blob-4 {
    top: 60%;
    left: 8%;
    width: 280px;
    height: 280px;
    opacity: 0.5;
    animation: drift-4 44s ease-in-out infinite;
}

.blob-5 {
    top: 78%;
    right: 10%;
    width: 180px;
    height: 180px;
    opacity: 0.1;
    filter: blur(30px);
    animation: drift-5 52s ease-in-out infinite;
}

@keyframes drift-1 {
    0%, 100% { transform: translate(0, 0) rotate(0deg) scale(1); }
    33%      { transform: translate(28px, 22px) rotate(8deg) scale(1.04); }
    66%      { transform: translate(-18px, 36px) rotate(-6deg) scale(0.98); }
}

@keyframes drift-2 {
    0%, 100% { transform: translate(0, 0) rotate(0deg) scale(1); }
    50%      { transform: translate(-32px, -24px) rotate(-12deg) scale(1.05); }
}

@keyframes drift-3 {
    0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.10; }
    50%      { transform: translate(20px, -28px) scale(1.08); opacity: 0.16; }
}

@keyframes drift-4 {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25%      { transform: translate(18px, -14px) rotate(4deg); }
    75%      { transform: translate(-22px, 18px) rotate(-3deg); }
}

@keyframes drift-5 {
    0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.08; }
    50%      { transform: translate(-26px, 30px) scale(1.1); opacity: 0.14; }
}

/* ==========================================================================
   Section scaffolding — field placement, ma negative space
   ========================================================================== */
.narrative {
    position: relative;
    z-index: 1;
}

.section {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.threshold       { min-height: 100vh; }
.breath-first    { min-height: 100vh; }
.vessels-first   { min-height: 120vh; }
.breath-second   { min-height: 80vh; }
.contradiction   { min-height: 150vh; }
.breath-third    { min-height: 100vh; }
.offering        { min-height: 130vh; }
.final-breath    { min-height: 100vh; }
.vanishing       { min-height: 60vh; }

/* ==========================================================================
   Section 1 — The Threshold
   ========================================================================== */
.threshold {
    display: flex;
    align-items: center;
    justify-content: center;
}

.threshold-inner {
    text-align: center;
    padding: 0 24px;
    position: relative;
}

.domain-mark {
    position: relative;
    display: inline-block;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(56px, 9vw, 96px);
    letter-spacing: 0.08em;
    color: var(--parchment);
    line-height: 1;
    margin-bottom: 36px;
    opacity: 0;
    animation: domain-emerge 3000ms var(--ease-soft) 1800ms forwards;
}

.domain-mark-text {
    position: relative;
    display: inline-block;
    background: linear-gradient(180deg, #F2DFCF 0%, #E8D5C4 50%, #D5BFAA 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 2px 24px rgba(232, 213, 196, 0.18);
}

.domain-mark-mask {
    position: absolute;
    inset: -8px -16px;
    pointer-events: none;
    background-image:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' seed='5' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.1  0 0 0 0 0.08  0 0 0 0 0.06  0 0 0 1 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
    background-size: 200px 200px;
    mix-blend-mode: multiply;
    opacity: 0.2;
    animation: mask-shift 0.9s steps(4) infinite, mask-clear 2400ms var(--ease-soft) 2200ms forwards;
}

@keyframes domain-emerge {
    0%   { opacity: 0; filter: blur(14px); transform: translateY(8px); letter-spacing: 0.18em; }
    100% { opacity: 1; filter: blur(0);    transform: translateY(0);   letter-spacing: 0.08em; }
}

@keyframes mask-shift {
    0%   { transform: translate(0, 0); }
    100% { transform: translate(-12%, 6%); }
}

@keyframes mask-clear {
    0%   { opacity: 0.2; }
    100% { opacity: 0;   }
}

.threshold-whisper {
    font-family: var(--font-whisper);
    font-weight: 400;
    font-size: 18px;
    color: var(--raw-umber);
    opacity: 0;
    letter-spacing: 0.02em;
    animation: whisper-fade 2400ms var(--ease-soft) 4400ms forwards;
}

@keyframes whisper-fade {
    0%   { opacity: 0; transform: translateY(10px); }
    100% { opacity: 0.7; transform: translateY(0); }
}

/* ==========================================================================
   Breath sections — emptiness as content
   ========================================================================== */
.breath {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.breath-blob {
    position: absolute;
    border-radius: 60% 40% 55% 45% / 50% 60% 40% 50%;
    background: var(--smoked-cedar);
    opacity: 0;
    filter: blur(28px);
    animation: blob-fade-in 2400ms var(--ease-soft) forwards, blob-float 36s ease-in-out infinite;
}

.breath-blob.warm {
    background: var(--ember-glow);
}

.breath-blob.pulse {
    animation: blob-fade-in 2400ms var(--ease-soft) forwards, blob-float 42s ease-in-out infinite, blob-warm-pulse 9s ease-in-out infinite;
}

.breath-blob-1 {
    width: 240px;
    height: 240px;
    bottom: 12%;
    right: 12%;
    --target-opacity: 0.4;
}

.breath-blob-2 {
    width: 180px;
    height: 180px;
    top: 32%;
    left: 38%;
    --target-opacity: 0.13;
}

.breath-blob-3 {
    width: 320px;
    height: 320px;
    top: 30%;
    left: 42%;
    --target-opacity: 0.12;
    filter: blur(40px);
}

@keyframes blob-fade-in {
    to { opacity: var(--target-opacity, 0.4); }
}

@keyframes blob-float {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33%      { transform: translate(20px, -16px) rotate(6deg); }
    66%      { transform: translate(-14px, 22px) rotate(-4deg); }
}

@keyframes blob-warm-pulse {
    0%, 100% { opacity: 0.08; }
    50%      { opacity: 0.18; }
}

/* ==========================================================================
   Horizon lines — atmospheric layers in misty mountains
   ========================================================================== */
.horizon-line {
    position: absolute;
    left: 8%;
    right: 8%;
    height: 1px;
    background: linear-gradient(90deg, rgba(196, 168, 130, 0) 0%, rgba(196, 168, 130, 0.15) 30%, rgba(196, 168, 130, 0.15) 70%, rgba(196, 168, 130, 0) 100%);
    pointer-events: none;
    transform: scaleX(0.3);
    opacity: 0;
    transition: opacity 1800ms var(--ease-soft), transform 1800ms var(--ease-soft);
}

.horizon-line.active,
.section.in-view .horizon-line {
    opacity: 1;
    transform: scaleX(1);
}

.horizon-1 { bottom: 16%; }
.horizon-2 { top: 30%; }
.horizon-3 { top: 70%; }
.horizon-4 { bottom: 12%; left: 18%; right: 18%; }
.horizon-5 { top: 50%; left: 22%; right: 22%; }

/* ==========================================================================
   Vessel — card flip embodying mujun (hidden contradiction)
   ========================================================================== */
.vessels {
    position: relative;
}

.vessel {
    position: absolute;
    left: var(--vessel-x, 25%);
    top: var(--vessel-y, 20%);
    width: clamp(280px, 32vw, 460px);
    height: 320px;
    perspective: 1200px;
    cursor: pointer;
    z-index: 2;
}

.vessel-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 600ms var(--ease-soft), box-shadow 600ms var(--ease-soft);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    border-radius: 6px;
}

.vessel:hover .vessel-inner,
.vessel.flipped .vessel-inner {
    transform: rotateY(180deg);
}

.vessel:hover .vessel-inner,
.vessel.flipping .vessel-inner {
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.45);
}

.vessel-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 6px;
    padding: 38px 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid rgba(196, 168, 130, 0.18);
}

.vessel-front {
    background: var(--smoked-cedar);
    background-image:
        radial-gradient(ellipse at 30% 25%, rgba(194, 112, 62, 0.06) 0%, rgba(194, 112, 62, 0) 60%),
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='4' seed='9' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.92  0 0 0 0 0.84  0 0 0 0 0.71  0 0 0 1 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
    background-size: auto, 180px 180px;
    background-blend-mode: normal, overlay;
}

.vessel-front::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='4' seed='9' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.92  0 0 0 0 0.84  0 0 0 0 0.71  0 0 0 1 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
    background-size: 180px 180px;
    opacity: 0.12;
    mix-blend-mode: overlay;
    pointer-events: none;
}

.vessel-back {
    background: var(--clay-slip);
    transform: rotateY(180deg);
}

.vessel-back::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' seed='12' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.92  0 0 0 0 0.84  0 0 0 0 0.71  0 0 0 1 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
    background-size: 180px 180px;
    opacity: 0.08;
    mix-blend-mode: overlay;
    pointer-events: none;
}

.vessel-front-label {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(28px, 3vw, 38px);
    letter-spacing: 0.1em;
    color: var(--parchment);
    text-align: center;
    position: relative;
    z-index: 1;
}

.vessel-back-text {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 16px;
    line-height: 1.85;
    color: var(--tea-stain);
    text-align: left;
    position: relative;
    z-index: 1;
    opacity: 0.92;
}

.vessel-prompt {
    position: absolute;
    bottom: -34px;
    right: 12px;
    font-family: var(--font-whisper);
    font-size: 16px;
    color: var(--raw-umber);
    opacity: 0.55;
    letter-spacing: 0.04em;
    pointer-events: none;
    transition: opacity 400ms var(--ease-soft);
}

.vessel:hover .vessel-prompt {
    opacity: 0.9;
}

/* ==========================================================================
   Whisper blocks — small fragments alone in vast space
   ========================================================================== */
.whisper {
    position: absolute;
    left: var(--whisper-x, 60%);
    top: var(--whisper-y, 60%);
    width: 320px;
    max-width: 80vw;
    font-family: var(--font-whisper);
    font-size: 22px;
    line-height: 1.55;
    color: var(--tea-stain);
    -webkit-mask-image: radial-gradient(ellipse at center, rgba(0, 0, 0, 1) 35%, rgba(0, 0, 0, 0) 100%);
    mask-image: radial-gradient(ellipse at center, rgba(0, 0, 0, 1) 35%, rgba(0, 0, 0, 0) 100%);
    z-index: 2;
    opacity: 0.85;
}

.whisper.centered {
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    font-size: clamp(22px, 2.4vw, 30px);
    width: 540px;
}

/* ==========================================================================
   Dot constellations — scattered tea leaves
   ========================================================================== */
.dot-constellation {
    position: absolute;
    pointer-events: none;
    z-index: 1;
}

.constellation-a {
    top: 50%;
    left: 50%;
    width: 200px;
    height: 80px;
}

.constellation-b {
    top: 38%;
    left: 38%;
    width: 240px;
    height: 120px;
}

.dot {
    position: absolute;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--ember-glow);
    opacity: 0.22;
}

.constellation-a .dot:nth-child(1) { top: 10%;  left:  8%; width: 4px; height: 4px; }
.constellation-a .dot:nth-child(2) { top: 30%;  left: 32%; }
.constellation-a .dot:nth-child(3) { top: 60%;  left: 52%; width: 2px; height: 2px; }
.constellation-a .dot:nth-child(4) { top: 75%;  left: 78%; }
.constellation-a .dot:nth-child(5) { top: 22%;  left: 90%; width: 4px; height: 4px; }

.constellation-b .dot:nth-child(1) { top: 14%;  left:  6%; width: 4px; height: 4px; }
.constellation-b .dot:nth-child(2) { top: 32%;  left: 24%; }
.constellation-b .dot:nth-child(3) { top: 50%;  left: 44%; width: 2px; height: 2px; }
.constellation-b .dot:nth-child(4) { top: 60%;  left: 60%; width: 3px; height: 3px; }
.constellation-b .dot:nth-child(5) { top: 72%;  left: 76%; }
.constellation-b .dot:nth-child(6) { top: 38%;  left: 88%; width: 4px; height: 4px; }
.constellation-b .dot:nth-child(7) { top: 88%;  left: 92%; width: 2px; height: 2px; }

/* ==========================================================================
   Reveal-on-scroll — soft fade up over 800ms
   ========================================================================== */
.reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 800ms var(--ease-soft), transform 800ms var(--ease-soft);
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

.whisper.reveal.visible { opacity: 0.85; }
.whisper.centered.reveal.visible { opacity: 0.85; transform: translate(-50%, -50%); }
.whisper.centered.reveal { transform: translate(-50%, calc(-50% + 20px)); }

/* ==========================================================================
   Section 9 — The Vanishing
   ========================================================================== */
.vanishing {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, transparent 0%, #100C09 100%);
}

.vanishing-inner {
    text-align: center;
    padding: 80px 24px;
}

.domain-mark-vanish {
    font-size: clamp(40px, 6vw, 64px);
    margin-bottom: 28px;
    opacity: 0.85;
    transition: opacity 1500ms var(--ease-soft), filter 1500ms var(--ease-soft);
}

.domain-mark-vanish.fading {
    opacity: 0.18;
    filter: blur(8px);
}

.contact {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 14px;
    color: var(--tea-stain);
    opacity: 0.55;
    letter-spacing: 0.04em;
}

.contact-line + .contact-line {
    margin-top: 8px;
}

/* ==========================================================================
   Background warmth steps — driven by data-active-section on body
   ========================================================================== */
body[data-active-section="6"] .background-wash,
body[data-active-section="7"] .background-wash {
    background:
        radial-gradient(ellipse at 20% 18%, rgba(194, 112, 62, 0.07) 0%, rgba(194, 112, 62, 0) 55%),
        radial-gradient(ellipse at 80% 60%, rgba(166, 123, 91, 0.05) 0%, rgba(166, 123, 91, 0) 60%),
        linear-gradient(180deg, var(--ember-dim) 0%, #1B140F 100%);
}

body[data-active-section="8"] .background-wash,
body[data-active-section="9"] .background-wash {
    background:
        radial-gradient(ellipse at 50% 50%, rgba(194, 112, 62, 0.04) 0%, rgba(194, 112, 62, 0) 60%),
        linear-gradient(180deg, #15100C 0%, #0E0A07 100%);
}

/* ==========================================================================
   Responsive — preserve ma but allow content to breathe on small screens
   ========================================================================== */
@media (max-width: 720px) {
    .vessel {
        position: relative;
        left: auto !important;
        top: auto !important;
        width: min(86vw, 420px);
        height: 280px;
        margin: 80px auto;
    }

    .vessels-first,
    .contradiction,
    .offering {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 80px 0;
    }

    .whisper {
        position: relative;
        left: auto !important;
        top: auto !important;
        margin: 60px auto;
        text-align: center;
    }

    .whisper.centered {
        position: relative;
        transform: none;
        margin: 0 auto;
    }

    .whisper.centered.reveal { transform: translateY(20px); }
    .whisper.centered.reveal.visible { transform: translateY(0); }

    .dot-constellation { display: none; }

    .vessels-first   { min-height: auto; }
    .contradiction   { min-height: auto; }
    .offering        { min-height: auto; }

    .domain-mark { font-size: 56px; }
    .threshold-whisper { font-size: 16px; }
    .vessel-front-label { font-size: 26px; }
    .vessel-back-text { font-size: 15px; }
}
