/* ============================================
   PPEBBL.com - Wabi-sabi Stone Design
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    /* Palette */
    --bg-primary: #F2EDE3;       /* Warm limestone */
    --bg-deep: #2A2520;          /* River silt */
    --text-primary: #3D3830;     /* Basalt gray */
    --text-secondary: #8A8279;   /* Weathered granite */
    --accent-warm: #C67B4E;      /* Terracotta vein */
    --accent-cool: #7BA68A;      /* Celadon glaze */
    --accent-precious: #D4A84B;  /* Amber fossil */
    --crack-lines: #E8E2D8;      /* Chalk white */

    /* Temperature shift properties (driven by JS) */
    --bg-warm: #F2EDE3;
    --bg-cool: #2A2520;
    --scroll-progress: 0;
    --current-bg: #F2EDE3;

    /* Typography */
    --font-display: 'Cormorant Garamond', Georgia, serif;
    --font-body: 'Libre Baskerville', 'Times New Roman', serif;
    --font-mono: 'DM Mono', 'Courier New', monospace;

    /* Animation */
    --ease-natural: cubic-bezier(0.25, 0.1, 0.25, 1.0);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 1.05rem;
    line-height: 1.85;
    color: var(--text-primary);
    background-color: var(--current-bg);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Grain Texture Overlay --- */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    filter: url(#grain);
    opacity: 0.04;
    mix-blend-mode: multiply;
}

/* --- Navigation: Pebble Dots --- */
#pebble-nav {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 1000;
}

.nav-cluster {
    display: flex;
    gap: 8px;
    align-items: center;
    transition: gap 0.6s var(--ease-spring);
}

.nav-cluster:hover {
    gap: 24px;
}

.nav-dot {
    width: 10px;
    height: 10px;
    border: none;
    cursor: pointer;
    position: relative;
    transition: all 0.6s var(--ease-spring);
    background: none;
    padding: 0;
}

.nav-dot::before {
    content: '';
    display: block;
    width: 10px;
    height: 10px;
    border-radius: 60% 40% 55% 45% / 50% 60% 40% 50%;
    transition: transform 0.6s var(--ease-spring);
}

.dot-terracotta::before { background-color: var(--accent-warm); }
.dot-celadon::before { background-color: var(--accent-cool); }
.dot-amber::before { background-color: var(--accent-precious); }
.dot-basalt::before { background-color: var(--text-primary); }

.nav-cluster:hover .nav-dot::before {
    transform: scale(1.3);
}

.nav-label {
    position: absolute;
    top: 50%;
    right: calc(100% + 10px);
    transform: translateY(-50%);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 300;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.5s var(--ease-natural);
    pointer-events: none;
}

.nav-cluster:hover .nav-label {
    opacity: 1;
}

/* --- Ripple Container --- */
#ripple-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 998;
    overflow: hidden;
}

.ripple {
    position: absolute;
    border-radius: 50%;
    border: 1px solid var(--accent-cool);
    opacity: 0;
    transform: scale(0);
    animation: ripple-expand 3.5s var(--ease-natural) forwards;
}

@keyframes ripple-expand {
    0% {
        transform: scale(0);
        opacity: 0.08;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

/* ============================================
   SECTION 1: GENESIS - Opening stillness
   ============================================ */
.section-genesis {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-primary);
    position: relative;
    overflow: hidden;
}

.genesis-stone {
    width: 180px;
    height: 160px;
    background: linear-gradient(135deg, #C8C0B4 0%, #A8A095 40%, #B8B0A5 70%, #9A9288 100%);
    border-radius: 73% 27% 62% 38% / 45% 55% 68% 32%;
    position: relative;
    opacity: 0;
    animation: stone-fade-in 2s var(--ease-natural) 0.5s forwards;
    box-shadow:
        inset 3px 5px 15px rgba(0,0,0,0.1),
        inset -2px -3px 10px rgba(255,255,255,0.15);
    transition: border-radius 2s var(--ease-natural);
}

.genesis-stone:hover {
    border-radius: 58% 42% 48% 52% / 62% 38% 55% 45%;
}

@keyframes stone-fade-in {
    0% { opacity: 0; transform: scale(0.95); }
    100% { opacity: 1; transform: scale(1); }
}

/* Stone crack lines */
.stone-crack {
    position: absolute;
    top: 50%;
    width: 0;
    height: 1px;
    background: var(--crack-lines);
    transition: width 1.5s var(--ease-natural);
}

.stone-crack-left {
    right: 50%;
    transform-origin: right center;
}

.stone-crack-right {
    left: 50%;
    transform-origin: left center;
}

.genesis-stone.cracked .stone-crack-left {
    width: 50%;
}

.genesis-stone.cracked .stone-crack-right {
    width: 50%;
}

/* ============================================
   SECTION 2: FRACTURE - Wordmark reveal
   ============================================ */
.section-fracture {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-primary);
    position: relative;
    padding: 10vh 2rem;
}

.fracture-container {
    text-align: center;
    position: relative;
    width: 100%;
    max-width: 900px;
}

.crack-line {
    width: 100%;
    height: 20px;
    margin: 1.5rem 0;
    overflow: visible;
}

.crack-line svg {
    width: 100%;
    height: 20px;
}

.crack-path {
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    transition: stroke-dashoffset 2s var(--ease-natural);
}

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

.wordmark {
    font-family: var(--font-display);
    font-weight: 400;
    font-style: italic;
    font-size: clamp(3rem, 7vw, 8vw);
    letter-spacing: 0.15em;
    color: var(--text-primary);
    display: inline-block;
}

.wordmark .letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.8s var(--ease-natural);
    transition-delay: calc(var(--delay) * 120ms);
}

.wordmark.revealed .letter {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================
   SECTION 3: CURRENT - Meandering river
   ============================================ */
.section-current {
    padding: 15vh 0;
    background-color: var(--bg-primary);
    position: relative;
    overflow: hidden;
}

.river-column {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 2rem;
    position: relative;
    transition: margin-left 1.2s var(--ease-natural), margin-right 1.2s var(--ease-natural);
}

/* Water divider SVGs */
.water-divider {
    width: 80%;
    margin: 4rem auto;
    height: 10px;
    overflow: visible;
}

.water-divider svg {
    width: 100%;
    height: 10px;
}

.water-path {
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
    transition: stroke-dashoffset 1.8s var(--ease-natural);
}

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

/* Stone content blocks */
.stone-block {
    padding: 3rem 2.5rem;
    margin-bottom: 2rem;
    position: relative;
    background: rgba(242, 237, 227, 0.4);
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 1.2s var(--ease-natural), transform 1.2s var(--ease-natural);
}

.stone-block.visible {
    opacity: 1;
    transform: translateY(0);
}

.stone-block-1 {
    border-radius: 68% 32% 57% 43% / 52% 48% 62% 38%;
}

.stone-block-2 {
    border-radius: 42% 58% 35% 65% / 60% 40% 55% 45%;
}

.stone-block-3 {
    border-radius: 55% 45% 70% 30% / 38% 62% 45% 55%;
}

.stone-block-4 {
    border-radius: 38% 62% 48% 52% / 55% 45% 35% 65%;
}

.stone-block:hover {
    transition: border-radius 2s var(--ease-natural);
}

.stone-block-1:hover { border-radius: 52% 48% 43% 57% / 62% 38% 48% 52%; }
.stone-block-2:hover { border-radius: 58% 42% 65% 35% / 40% 60% 45% 55%; }
.stone-block-3:hover { border-radius: 45% 55% 30% 70% / 62% 38% 55% 45%; }
.stone-block-4:hover { border-radius: 62% 38% 52% 48% / 45% 55% 65% 35%; }

/* Crack overlay decoration for stone blocks */
.stone-block::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: inherit;
    background: linear-gradient(
        135deg,
        transparent 30%,
        rgba(232, 226, 216, 0.15) 31%,
        rgba(232, 226, 216, 0.15) 31.5%,
        transparent 32%,
        transparent 60%,
        rgba(232, 226, 216, 0.1) 61%,
        rgba(232, 226, 216, 0.1) 61.3%,
        transparent 62%
    );
    pointer-events: none;
}

.section-title {
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 400;
    font-size: clamp(1.8rem, 3.5vw, 3.5vw);
    letter-spacing: 0.05em;
    color: var(--text-primary);
    margin-bottom: 1.2rem;
    line-height: 1.2;
}

.body-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 1.05rem;
    line-height: 1.85;
    color: var(--text-primary);
}

/* Drift states for meandering column */
.stone-block[data-drift="left"] {
    margin-left: -5%;
}

.stone-block[data-drift="right"] {
    margin-left: 5%;
}

/* ============================================
   SECTION 4: STRATA - Geological layers
   ============================================ */
.section-strata {
    position: relative;
    padding: 15vh 0;
    min-height: 150vh;
    overflow: hidden;
}

/* Background strata layers */
.strata-layer {
    position: absolute;
    left: 0;
    right: 0;
    pointer-events: none;
}

.strata-layer-1 {
    top: 0;
    height: 25%;
    background: linear-gradient(180deg, var(--bg-primary) 0%, #EDE6DA 100%);
}

.strata-layer-2 {
    top: 20%;
    height: 25%;
    background: linear-gradient(180deg, #EDE6DA 0%, #DDD5C8 100%);
}

.strata-layer-3 {
    top: 40%;
    height: 25%;
    background: linear-gradient(180deg, #DDD5C8 0%, #C4BAA8 100%);
}

.strata-layer-4 {
    top: 60%;
    height: 25%;
    background: linear-gradient(180deg, #C4BAA8 0%, #9A9080 100%);
}

.strata-layer-5 {
    top: 80%;
    height: 25%;
    background: linear-gradient(180deg, #9A9080 0%, #5A5248 100%);
}

.strata-content {
    position: relative;
    z-index: 2;
    max-width: 650px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Fossil blocks with erosion clip-paths */
.fossil-block {
    padding: 3.5rem 3rem;
    margin-bottom: 6rem;
    position: relative;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 1.2s var(--ease-natural), transform 1.2s var(--ease-natural), clip-path 1.5s var(--ease-natural);
}

.fossil-block.visible {
    opacity: 1;
    transform: translateY(0);
}

.fossil-block-1 {
    background: rgba(242, 237, 227, 0.7);
    clip-path: polygon(3% 0%, 98% 2%, 100% 8%, 97% 25%, 100% 42%, 99% 58%, 96% 75%, 100% 88%, 98% 100%, 2% 98%, 0% 85%, 3% 68%, 0% 50%, 2% 32%, 0% 18%, 1% 5%);
}

.fossil-block-2 {
    background: rgba(237, 230, 218, 0.75);
    clip-path: polygon(2% 3%, 97% 0%, 100% 12%, 98% 30%, 100% 48%, 97% 65%, 100% 80%, 99% 97%, 3% 100%, 0% 82%, 2% 62%, 0% 45%, 1% 28%, 0% 10%);
}

.fossil-block-3 {
    background: rgba(221, 213, 200, 0.8);
    clip-path: polygon(1% 2%, 99% 0%, 100% 15%, 97% 35%, 100% 55%, 98% 72%, 100% 90%, 97% 100%, 2% 98%, 0% 78%, 3% 58%, 0% 40%, 2% 22%, 0% 8%);
}

.fossil-block.revealed {
    clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%);
}

.fossil-label {
    font-family: var(--font-mono);
    font-weight: 300;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 0.8rem;
    text-transform: uppercase;
}

.strata-crack-divider {
    width: 100%;
    height: 30px;
    margin: 2rem 0;
    overflow: visible;
}

.strata-crack-divider svg {
    width: 100%;
    height: 30px;
}

.strata-crack {
    stroke-dasharray: 1500;
    stroke-dashoffset: 1500;
    transition: stroke-dashoffset 2.5s var(--ease-natural);
}

.strata-crack.drawn {
    stroke-dashoffset: 0;
}

/* Strata section text color shift */
.section-strata .fossil-block-3 .section-title,
.section-strata .fossil-block-3 .body-text {
    color: #F2EDE3;
}

.section-strata .fossil-block-3 .fossil-label {
    color: #C4BAA8;
}

/* ============================================
   SECTION 5: POOL - Tidal pool cluster
   ============================================ */
.section-pool {
    min-height: 100vh;
    position: relative;
    background: linear-gradient(180deg, #5A5248 0%, #3D3830 30%, #2A2520 100%);
    overflow: hidden;
    padding: 10vh 0;
}

.pool-container {
    position: relative;
    width: 90%;
    max-width: 1000px;
    height: 80vh;
    margin: 0 auto;
}

.pool-stone {
    position: absolute;
    padding: 2rem 2.5rem;
    cursor: default;
    transition: transform 0.6s var(--ease-spring);
    opacity: 0;
    transform: translateY(20px);
}

.pool-stone.visible {
    opacity: 1;
    transform: translateY(0);
}

.pool-stone-1 {
    left: 12%;
    top: 15%;
    background: rgba(198, 123, 78, 0.2);
    border-radius: 65% 35% 58% 42% / 48% 52% 60% 40%;
    max-width: 260px;
}

.pool-stone-2 {
    left: 55%;
    top: 5%;
    background: rgba(123, 166, 138, 0.2);
    border-radius: 45% 55% 38% 62% / 55% 45% 65% 35%;
    max-width: 240px;
}

.pool-stone-3 {
    left: 30%;
    top: 42%;
    background: rgba(212, 168, 75, 0.2);
    border-radius: 55% 45% 68% 32% / 42% 58% 35% 65%;
    max-width: 280px;
}

.pool-stone-4 {
    left: 65%;
    top: 38%;
    background: rgba(242, 237, 227, 0.12);
    border-radius: 48% 52% 42% 58% / 62% 38% 52% 48%;
    max-width: 230px;
}

.pool-stone-5 {
    left: 8%;
    top: 68%;
    background: rgba(138, 130, 121, 0.2);
    border-radius: 58% 42% 52% 48% / 38% 62% 45% 55%;
    max-width: 250px;
}

.pool-stone-6 {
    left: 52%;
    top: 72%;
    background: rgba(123, 166, 138, 0.15);
    border-radius: 42% 58% 62% 38% / 52% 48% 38% 62%;
    max-width: 230px;
}

/* Hover displacement on neighboring stones */
.pool-stone:hover {
    z-index: 5;
}

.pool-stone-1:hover ~ .pool-stone-2 { transform: translate(8px, -5px); }
.pool-stone-1:hover ~ .pool-stone-3 { transform: translate(-5px, 8px); }

.pool-stone-2:hover ~ .pool-stone-3 { transform: translate(5px, 8px); }
.pool-stone-2:hover ~ .pool-stone-4 { transform: translate(10px, -3px); }

.pool-stone-3:hover ~ .pool-stone-4 { transform: translate(8px, 5px); }
.pool-stone-3:hover ~ .pool-stone-5 { transform: translate(-8px, 5px); }

.pool-stone-4:hover ~ .pool-stone-5 { transform: translate(-5px, 8px); }
.pool-stone-4:hover ~ .pool-stone-6 { transform: translate(8px, -5px); }

.pool-stone-5:hover ~ .pool-stone-6 { transform: translate(5px, -8px); }

.pool-title {
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 400;
    font-size: 1.6rem;
    letter-spacing: 0.08em;
    color: var(--crack-lines);
    margin-bottom: 0.6rem;
}

.pool-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 0.95rem;
    line-height: 1.75;
    color: var(--text-secondary);
}

/* ============================================
   SECTION 6: STILLNESS - Return to silence
   ============================================ */
.section-stillness {
    height: 80vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-deep);
    position: relative;
    gap: 4rem;
    overflow: hidden;
}

.final-stone {
    width: 120px;
    height: 110px;
    background: linear-gradient(135deg, #6A6258 0%, #524A42 40%, #5E564E 70%, #48413A 100%);
    border-radius: 58% 42% 48% 52% / 62% 38% 55% 45%;
    opacity: 0;
    transform: scale(0.9) rotate(15deg);
    transition: opacity 2s var(--ease-natural), transform 2s var(--ease-natural), border-radius 2s var(--ease-natural);
    box-shadow:
        inset 2px 3px 10px rgba(0,0,0,0.2),
        inset -1px -2px 8px rgba(255,255,255,0.05);
}

.final-stone.visible {
    opacity: 1;
    transform: scale(1) rotate(15deg);
}

.final-stone:hover {
    border-radius: 42% 58% 55% 45% / 52% 48% 38% 62%;
}

.closing-phrase {
    opacity: 0;
    transition: opacity 2.5s var(--ease-natural);
    transition-delay: 1s;
}

.closing-phrase.visible {
    opacity: 1;
}

.mono-text {
    font-family: var(--font-mono);
    font-weight: 300;
    font-size: 0.8rem;
    letter-spacing: 0.12em;
    color: var(--text-secondary);
    text-transform: lowercase;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .genesis-stone {
        width: 130px;
        height: 115px;
    }

    .wordmark {
        font-size: clamp(2.5rem, 10vw, 5rem);
    }

    .river-column {
        max-width: 100%;
        padding: 0 1.5rem;
    }

    .stone-block {
        padding: 2rem 1.8rem;
        margin-left: 0 !important;
    }

    .section-title {
        font-size: clamp(1.5rem, 6vw, 2.2rem);
    }

    .pool-container {
        height: auto;
        min-height: 120vh;
    }

    .pool-stone {
        position: relative;
        left: auto !important;
        top: auto !important;
        max-width: 100% !important;
        margin-bottom: 2rem;
    }

    .strata-content {
        padding: 0 1.5rem;
    }

    .fossil-block {
        padding: 2.5rem 2rem;
    }

    #pebble-nav {
        top: 1rem;
        right: 1rem;
    }
}

@media (max-width: 480px) {
    .genesis-stone {
        width: 100px;
        height: 90px;
    }

    .stone-block {
        padding: 1.5rem 1.2rem;
        border-radius: 30% 70% 40% 60% / 50% 50% 50% 50% !important;
    }

    .fossil-block {
        padding: 2rem 1.5rem;
    }

    .pool-stone {
        padding: 1.5rem 1.8rem;
    }
}
