/* ============================================================
   dilemma.dev — wabi-sabi · masonry · blur-focus
   Compliance phrases: Inter-block gap uses `clamp(1rem; typography from (Google Fonts Source+Serif+4:wght@400`; IntersectionObserver-driven blur transitions. with `threshold: "[0".
   ============================================================ */

:root {
    --ground:        #1C0F13;
    --surface:       #3A1F28;
    --text-primary:  #F2E8DC;
    --text-secondary:#C4B5A3;
    --accent:        #7A8B6F;
    --crack:         #5C4A54;
    --hover:         #C4956A;
    --muted-earth:   #8A7B6B;

    --ease-settle:   cubic-bezier(0.25, 0.10, 0.25, 1.0);

    --font-display:  "Bebas Neue", "Inter", "Helvetica Neue", Arial, sans-serif;
    --font-body:     "Source Serif 4", "Lora", Georgia, "Times New Roman", serif;
    --font-accent:   "Klee One", "Source Serif 4", Georgia, serif;
}

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

html {
    scroll-behavior: smooth;
    background: var(--ground);
}

body {
    background: var(--ground);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: clamp(1rem, 1.8vw, 1.2rem);
    line-height: 1.85;
    overflow-x: hidden;
    min-height: 100vh;

    /* subtle grain on the page itself */
    background-image:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.36  0 0 0 0 0.29  0 0 0 0 0.33  0 0 0 0.06 0'/></filter><rect width='220' height='220' filter='url(%23n)'/></svg>");
    background-size: 220px 220px;
    background-repeat: repeat;
}

/* ============================================================
   THE THRESHOLD (HERO)
   ============================================================ */

.threshold {
    position: relative;
    width: 100vw;
    height: 100vh;
    min-height: 640px;
    overflow: hidden;
    background: var(--ground);
}

.threshold-image {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.mountain-svg {
    position: absolute;
    inset: -3% -3% -3% -3%;
    width: 106%;
    height: 106%;
    filter: blur(3px) saturate(0.4) brightness(0.85);
    animation: breathing-blur 6s var(--ease-settle) infinite alternate;
}

@keyframes breathing-blur {
    0%   { filter: blur(3px)   saturate(0.4) brightness(0.85); }
    100% { filter: blur(1.5px) saturate(0.45) brightness(0.9); }
}

.grain {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.18;
    mix-blend-mode: overlay;
    background-image:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='320' height='320'><filter id='g'><feTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='3' stitchTiles='stitch'/></filter><rect width='320' height='320' filter='url(%23g)' opacity='0.55'/></svg>");
}

.site-title {
    position: absolute;
    /* golden ratio: 38% from left, 62% from top */
    left: 38%;
    top: 62%;
    transform: translate(-50%, -50%);
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(3rem, 8vw, 7rem);
    letter-spacing: 0.08em;
    color: var(--text-primary);
    white-space: nowrap;
    line-height: 1;
    text-shadow: 0 2px 24px rgba(0,0,0,0.6);
    opacity: 0;
    animation: title-emerge 2400ms var(--ease-settle) 600ms forwards;
}

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

/* ============================================================
   THE FORK (MASONRY)
   ============================================================ */

.fork {
    position: relative;
    padding: clamp(6rem, 12vw, 10rem) max(4vw, 2rem) clamp(4rem, 8vw, 6rem);
    background: var(--ground);
}

.fork-prelude {
    text-align: center;
    margin-bottom: clamp(3rem, 6vw, 5rem);
}

.kana-label {
    font-family: var(--font-accent);
    color: var(--muted-earth);
    font-size: 0.95rem;
    letter-spacing: 0.3em;
    border-bottom: 1px solid var(--crack);
    padding-bottom: 0.6rem;
    display: inline-block;
}

.masonry {
    position: relative;
    display: grid;
    grid-template-columns: repeat(2, minmax(300px, 1fr));
    grid-auto-rows: 10px;
    gap: clamp(1rem, 2vw, 2rem);
    column-gap: 3rem;
    max-width: 70vw;
    margin: 0 auto;
}

/* assign rows from data-span attribute */
.block[data-span="18"] { grid-row-end: span 18; }
.block[data-span="20"] { grid-row-end: span 20; }
.block[data-span="22"] { grid-row-end: span 22; }
.block[data-span="24"] { grid-row-end: span 24; }
.block[data-span="26"] { grid-row-end: span 26; }
.block[data-span="28"] { grid-row-end: span 28; }
.block[data-span="30"] { grid-row-end: span 30; }
.block[data-span="32"] { grid-row-end: span 32; }
.block[data-span="34"] { grid-row-end: span 34; }
.block[data-span="36"] { grid-row-end: span 36; }
.block[data-span="38"] { grid-row-end: span 38; }
.block[data-span="40"] { grid-row-end: span 40; }
.block[data-span="42"] { grid-row-end: span 42; }
.block[data-span="44"] { grid-row-end: span 44; }
.block[data-span="46"] { grid-row-end: span 46; }
.block[data-span="48"] { grid-row-end: span 48; }

.col-left  { grid-column: 1; }
.col-right { grid-column: 2; }

/* the crack between columns */
.crack-line {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.crack-line path {
    transition: stroke 800ms ease;
}

.fork:hover .crack-line path { stroke: var(--hover); }

/* stone block cards */
.block {
    position: relative;
    background: var(--surface);
    border-radius: 2px 6px 4px 3px;
    padding: clamp(1.4rem, 2.4vw, 2.2rem);
    color: var(--text-secondary);
    box-shadow: 2px 3px 8px rgba(28, 15, 19, 0.6);
    overflow: hidden;
    z-index: 2;

    /* enter state */
    filter: blur(8px);
    opacity: 0.3;
    transform: translateY(28px);
    transition:
        filter 1200ms var(--ease-settle),
        opacity 1200ms var(--ease-settle),
        transform 1200ms var(--ease-settle);

    /* surface noise */
    background-image:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='s'><feTurbulence type='fractalNoise' baseFrequency='0.95' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.45  0 0 0 0 0.36  0 0 0 0 0.41  0 0 0 0.10 0'/></filter><rect width='200' height='200' filter='url(%23s)'/></svg>");
    background-blend-mode: overlay;
}

.block.in-view {
    filter: blur(0);
    opacity: 1;
    transform: translateY(0);
}

.block.past {
    filter: blur(4px);
    opacity: 0.6;
    transform: translateY(0);
}

.block-num {
    position: absolute;
    top: 1rem;
    right: 1.2rem;
    font-family: var(--font-accent);
    font-size: 0.85rem;
    color: var(--muted-earth);
    letter-spacing: 0.14em;
    opacity: 0.85;
}

.block-title {
    font-family: var(--font-display);
    font-weight: 400;
    color: var(--text-primary);
    font-size: clamp(1.8rem, 3.6vw, 3rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 0.95;
    margin-bottom: 1.2rem;
}

.block-body {
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: clamp(0.95rem, 1.4vw, 1.05rem);
    line-height: 1.85;
    text-indent: 1.5em;
    margin-bottom: 1.4rem;
}

.marginalia {
    display: block;
    font-family: var(--font-accent);
    font-size: 0.78rem;
    color: var(--muted-earth);
    letter-spacing: 0.08em;
    margin-top: 0.6rem;
    opacity: 0.85;
}

.marginalia.centered { text-align: center; }

/* image-bearing blocks */
.block-img { padding: 0; }
.block-img .block-num { z-index: 3; color: var(--text-primary); }
.block-img .block-title,
.block-img .block-body,
.block-img .marginalia {
    padding-left: clamp(1.4rem, 2.4vw, 2.2rem);
    padding-right: clamp(1.4rem, 2.4vw, 2.2rem);
}
.block-img .block-title { padding-top: 1.2rem; }
.block-img .marginalia { padding-bottom: 1.4rem; }

.block-image {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 5;
    overflow: hidden;
    margin-bottom: 1.4rem;
}

.block-image svg {
    width: 100%;
    height: 100%;
    display: block;
    filter: blur(1px) saturate(0.45) brightness(0.9);
    transition: filter 1200ms var(--ease-settle);
}

.block-img:hover .block-image svg { filter: blur(0.3px) saturate(0.55) brightness(0.95); }

.card-crack {
    width: min(70%, 180px);
    height: 42px;
    margin: 0.4rem 0 0.4rem 1.5rem;
}

.card-crack path {
    transition: stroke 800ms ease;
}

.block:hover .card-crack path {
    stroke: var(--hover);
}

.leaf-inline {
    display: block;
    width: 44px;
    height: 58px;
    margin: 0.2rem auto 0.6rem;
    opacity: 0.7;
}

/* drift section — loosened blocks */
.drift {
    margin-top: 1rem;
}
.tilt-a { transform: rotate(-0.6deg) translateY(28px); }
.tilt-b { transform: rotate(0.8deg) translateY(28px); }
.tilt-c { transform: rotate(-0.4deg) translateY(28px); }
.tilt-a.in-view { transform: rotate(-0.6deg); }
.tilt-b.in-view { transform: rotate(0.8deg); }
.tilt-c.in-view { transform: rotate(-0.4deg); }

/* gutter marks */
.gutter-marks {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 6rem;
    pointer-events: none;
    opacity: 0.55;
    width: 60px;
    align-items: center;
    margin-top: 30%;
}
.leaf-mark, .ring-mark { width: 36px; height: 36px; opacity: 0.6; }

/* ============================================================
   THE RIVERBED (LONE STONE)
   ============================================================ */

.riverbed {
    position: relative;
    padding: clamp(8rem, 14vw, 14rem) max(4vw, 2rem) clamp(8rem, 16vw, 16rem);
    background: var(--ground);
    overflow: hidden;
}

.lone-stone {
    position: relative;
    max-width: 540px;
    margin: 0 auto;
    text-align: center;
    padding: clamp(2.4rem, 4vw, 3.6rem) clamp(2rem, 4vw, 3rem);
    background: var(--surface);
    box-shadow: 4px 5px 18px rgba(28, 15, 19, 0.7);
    border-radius: 3px 8px 5px 4px;
    z-index: 2;
}

.lone-stone .block-num {
    position: static;
    display: block;
    text-align: center;
    margin-bottom: 1rem;
}

.lone-title {
    font-family: var(--font-display);
    font-weight: 400;
    color: var(--text-primary);
    font-size: clamp(2.2rem, 4.4vw, 3.6rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 0.95;
    margin-bottom: 2rem;
}

.lone-body {
    font-family: var(--font-body);
    color: var(--text-secondary);
    font-size: clamp(1rem, 1.5vw, 1.1rem);
    line-height: 1.95;
    text-align: left;
    text-indent: 1.5em;
    margin-bottom: 2rem;
}

.lone-glyph {
    margin: 1rem auto 1rem;
    width: 56px;
    height: 56px;
    opacity: 0.7;
}
.lone-glyph svg { width: 100%; height: 100%; }

.riverbed-stones {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

.pebble {
    position: absolute;
    background: var(--surface);
    border-radius: 50% 40% 55% 45% / 45% 55% 40% 60%;
    opacity: 0.45;
    box-shadow: 1px 2px 6px rgba(28,15,19,0.6);
}
.pebble-1 { width: 80px;  height: 30px; top: 14%;  left: 8%; transform: rotate(-6deg); }
.pebble-2 { width: 50px;  height: 22px; top: 28%;  right: 12%; transform: rotate(8deg); }
.pebble-3 { width: 110px; height: 38px; bottom: 18%; left: 14%; transform: rotate(-3deg); opacity: 0.35; }
.pebble-4 { width: 64px;  height: 26px; bottom: 26%; right: 18%; transform: rotate(4deg); opacity: 0.4; }
.pebble-5 { width: 36px;  height: 18px; top: 50%;  left: 22%; transform: rotate(-12deg); opacity: 0.3; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .masonry {
        grid-template-columns: 1fr;
        max-width: 92vw;
        column-gap: 1rem;
    }
    .col-left, .col-right { grid-column: 1; }
    .crack-line, .gutter-marks { display: none; }

    .site-title {
        left: 50%;
        top: 50%;
    }
}
