/* ============================================================
   ncbd.dev — pastoral-romantic generative
   Monochrome ink-wash. Handwritten. Watercolor. Urban pastoral.
   ============================================================ */

:root {
    --paper: #F2F0EC;
    --light-wash: #D4D0CB;
    --mid-wash: #9B9590;
    --shadow-wash: #6B6560;
    --graphite: #4A4A4A;
    --ink: #2E2E2E;
    --deep-ink: #1A1A1A;
    --wet-ink: #0D0D0D;

    --font-display: "Caveat", "Brush Script MT", cursive;
    --font-hand: "Kalam", "Comic Sans MS", cursive;
    --font-serif: "Source Serif 4", "Iowan Old Style", "Charter", Georgia, serif;

    --elastic: cubic-bezier(0.34, 1.56, 0.64, 1);
    --soft: cubic-bezier(0.4, 0.0, 0.2, 1);

    --spine-shift: 0px;
}

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

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

body {
    font-family: var(--font-serif);
    background-color: var(--paper);
    background-image:
        radial-gradient(ellipse 90% 60% at 30% 20%, rgba(155, 149, 144, 0.06), transparent 60%),
        radial-gradient(ellipse 70% 50% at 80% 70%, rgba(74, 74, 74, 0.04), transparent 65%),
        radial-gradient(ellipse 50% 40% at 50% 50%, rgba(212, 208, 203, 0.18), transparent 70%);
    color: var(--ink);
    overflow-x: hidden;
    min-height: 100vh;
    line-height: 1.7;
    letter-spacing: 0.005em;
    position: relative;
}

.svg-defs {
    position: absolute;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* Paper grain overlay — subtle multiply over everything */
.paper-grain {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    opacity: 0.045;
    mix-blend-mode: multiply;
    background-image:
        repeating-linear-gradient(
            27deg,
            transparent 0px,
            transparent 1px,
            rgba(26, 26, 26, 0.4) 1px,
            rgba(26, 26, 26, 0.4) 2px,
            transparent 2px,
            transparent 4px
        ),
        repeating-linear-gradient(
            -63deg,
            transparent 0px,
            transparent 1px,
            rgba(26, 26, 26, 0.3) 1px,
            rgba(26, 26, 26, 0.3) 2px,
            transparent 2px,
            transparent 5px
        ),
        radial-gradient(circle at 25% 30%, rgba(26, 26, 26, 0.05) 0.5px, transparent 1.5px),
        radial-gradient(circle at 75% 70%, rgba(26, 26, 26, 0.05) 0.5px, transparent 1.5px);
    background-size: 7px 7px, 11px 11px, 3px 3px, 5px 5px;
}

/* Rain canvas — top-most generative layer */
.rain-canvas {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 3;
    will-change: transform;
}

/* ============================================================
   Walk container — vertical narrative
   ============================================================ */
.walk {
    display: grid;
    grid-template-columns: 1fr min(720px, 90vw) 1fr;
    width: 100%;
    position: relative;
    z-index: 1;
}

.walk > * {
    grid-column: 2;
}

/* ============================================================
   SCENE: arrival + departure
   ============================================================ */
.scene {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    position: relative;
    padding: clamp(60px, 10vh, 140px) clamp(20px, 3vw, 40px);
}

.bloom-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.85;
}

.scene-arrival {
    text-align: center;
}

.arrival-content,
.departure-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(20px, 3vh, 36px);
}

.metadata {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(13px, 1vw, 16px);
    color: var(--mid-wash);
    letter-spacing: 0.04em;
    transform: rotate(-1deg);
}

.top-meta {
    margin-bottom: clamp(20px, 4vh, 40px);
    opacity: 0;
    animation: fadeInGentle 1.2s var(--soft) 0.2s forwards;
}

/* ============================================================
   Display title — handwritten by hand
   ============================================================ */
.display-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(54px, 9vw, 112px);
    line-height: 1.05;
    letter-spacing: -0.01em;
    color: var(--deep-ink);
    transform: rotate(-1.2deg);
    position: relative;
    min-height: 1.2em;
    display: inline-block;
}

.display-title .char {
    display: inline-block;
    opacity: 0;
    transform: translateY(20px) rotate(-3deg);
    animation: handwrite 0.6s var(--elastic) forwards;
}

.display-title .char.space {
    width: 0.35em;
}

@keyframes handwrite {
    0% {
        opacity: 0;
        transform: translateY(24px) rotate(-6deg) scale(0.85);
        filter: blur(2px);
    }
    60% {
        opacity: 0.9;
        filter: blur(0.5px);
    }
    100% {
        opacity: 1;
        transform: translateY(0) rotate(0deg) scale(1);
        filter: blur(0);
    }
}

@keyframes fadeInGentle {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.opening-line {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: clamp(17px, 1.4vw, 21px);
    color: var(--ink);
    max-width: 560px;
    line-height: 1.7;
    letter-spacing: 0.005em;
    opacity: 0;
    animation: fadeInGentle 0.9s var(--soft) 1.6s forwards;
    text-align: center;
}

.scroll-cue {
    margin-top: clamp(40px, 7vh, 80px);
    color: var(--mid-wash);
    font-family: var(--font-hand);
    font-size: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    opacity: 0;
    animation: fadeInGentle 1s var(--soft) 2.6s forwards;
}

.cue-arrow {
    font-size: 22px;
    animation: bob 2.6s ease-in-out infinite;
    color: var(--graphite);
}

@keyframes bob {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(8px); }
}

/* ============================================================
   Skyline
   ============================================================ */
.skyline-wrap {
    width: min(1000px, 95%);
    margin-top: clamp(20px, 4vh, 50px);
    position: relative;
}

.skyline {
    width: 100%;
    height: clamp(120px, 18vh, 220px);
    overflow: visible;
}

.skyline-path {
    stroke-dasharray: 4000;
    stroke-dashoffset: 4000;
    animation: drawSkyline 3s var(--soft) 1.4s forwards;
}

.skyline-final {
    stroke-dasharray: 4000;
    stroke-dashoffset: 4000;
}

.scene-departure.in-view .skyline-final {
    animation: drawSkyline 3.4s var(--soft) 0.4s forwards;
}

@keyframes drawSkyline {
    to { stroke-dashoffset: 0; }
}

.horizon-line {
    opacity: 0;
    animation: fadeInGentle 1.2s var(--soft) 3.5s forwards;
}

/* ============================================================
   Curb space — breath between sketches
   ============================================================ */
.curb {
    height: clamp(120px, 15vh, 200px);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.curb-line {
    width: clamp(160px, 30%, 360px);
    height: 12px;
    opacity: 0.55;
}

/* ============================================================
   Sketch — the content card
   ============================================================ */
.sketch {
    position: relative;
    padding: clamp(24px, 5vh, 60px) clamp(8px, 2vw, 24px);
    display: flex;
    justify-content: center;
}

.sketch-card {
    --shift: 0px;
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 680px;
    background-color: rgba(242, 240, 236, 0.62);
    backdrop-filter: blur(0.5px);
    padding: clamp(32px, 5vw, 64px) clamp(28px, 5vw, 56px);
    transform: translateX(var(--shift));
    border: 1px solid transparent;
    transition: border-color 0.6s var(--soft), transform 0.7s var(--elastic), box-shadow 0.6s var(--soft);
    /* torn-paper edges via clip-path — populated by JS */
    clip-path: var(--torn-clip, polygon(
        0 2%, 4% 0, 12% 1%, 22% 0, 33% 2%, 45% 0, 58% 1%, 70% 0, 82% 2%, 92% 0, 100% 1.5%,
        100% 98%, 96% 100%, 86% 99%, 74% 100%, 62% 98%, 50% 100%, 38% 99%, 26% 100%, 14% 98%, 4% 100%, 0 99%
    ));

    opacity: 0;
    transform: translateX(var(--shift)) translateY(40px) scale(0.97);
}

.sketch-card.in-view {
    opacity: 1;
    transform: translateX(var(--shift)) translateY(0) scale(1);
}

.sketch-card:hover {
    border-color: var(--light-wash);
    box-shadow: 0 18px 48px -28px rgba(107, 101, 96, 0.4);
}

.sketch-card-right {
    transform: translateX(var(--shift)) translateY(40px) scale(0.97);
}

.sketch-card-wide {
    max-width: 760px;
}

/* Two-column layout for streetlamp + content */
.sketch-card-right {
    display: grid;
    grid-template-columns: clamp(60px, 10%, 90px) 1fr;
    gap: clamp(20px, 3vw, 40px);
    align-items: start;
}

.card-flank {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 8px;
}

.streetlamp {
    width: 60px;
    height: clamp(160px, 30vh, 220px);
    overflow: visible;
}

.lamp-glow {
    animation: glowPulse 4.6s ease-in-out infinite;
    transform-origin: center;
    transform-box: fill-box;
}

@keyframes glowPulse {
    0%, 100% { opacity: 0.18; r: 14; }
    50%      { opacity: 0.28; r: 18; }
}

/* ============================================================
   Sketch typography
   ============================================================ */
.caption {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(14px, 1.1vw, 17px);
    color: var(--mid-wash);
    margin-bottom: clamp(8px, 1.5vh, 14px);
    transform: rotate(-0.6deg);
    letter-spacing: 0.02em;
}

.sketch-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(36px, 5vw, 64px);
    line-height: 1.12;
    letter-spacing: -0.01em;
    color: var(--deep-ink);
    margin-bottom: clamp(16px, 3vh, 28px);
    transform: rotate(-0.8deg);
}

.sketch-title em {
    font-family: var(--font-hand);
    font-style: normal;
    font-weight: 400;
    color: var(--graphite);
    font-size: 0.78em;
    display: inline-block;
    transform: rotate(0.6deg) translateY(-2px);
}

.sketch-body {
    font-family: var(--font-serif);
    font-size: clamp(16px, 1.2vw, 19px);
    line-height: 1.78;
    color: var(--ink);
    margin-bottom: clamp(16px, 2.5vh, 24px);
    text-wrap: pretty;
    hyphens: auto;
}

.sketch-body:last-of-type {
    margin-bottom: clamp(12px, 2vh, 18px);
}

.annotation {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(13px, 1vw, 16px);
    color: var(--shadow-wash);
    transform: rotate(-1deg);
    margin-top: clamp(10px, 2vh, 18px);
    letter-spacing: 0.03em;
}

.annotation.centered {
    text-align: center;
    transform: rotate(0.4deg);
}

/* ============================================================
   Pigeons — corner accents
   ============================================================ */
.corner-pigeon {
    width: 60px;
    height: 40px;
    position: absolute;
    overflow: visible;
}

.corner-pigeon-tl {
    top: -22px;
    left: 12%;
    transform: rotate(-6deg);
    animation: pigeonHop 7s var(--elastic) infinite;
}

@keyframes pigeonHop {
    0%, 90%, 100% { transform: rotate(-6deg) translateY(0); }
    45%           { transform: rotate(-6deg) translateY(-4px); }
}

.quote-pigeons {
    width: clamp(160px, 28%, 220px);
    height: 60px;
    margin: 0 auto clamp(16px, 3vh, 28px);
    display: block;
    overflow: visible;
}

.pigeon-pair {
    transform-origin: center;
    transform-box: fill-box;
    animation: gentlePulse 5s ease-in-out infinite;
}

.pigeon-pair:nth-child(2) { animation-delay: 0.7s; }
.pigeon-pair:nth-child(3) { animation-delay: 1.4s; }

@keyframes gentlePulse {
    0%, 100% { opacity: 0.85; }
    50%      { opacity: 1; }
}

/* ============================================================
   Window grid
   ============================================================ */
.window-grid {
    width: clamp(180px, 50%, 280px);
    height: auto;
    margin: clamp(10px, 2vh, 18px) 0 clamp(16px, 3vh, 26px);
    overflow: visible;
}

.grid-cells rect {
    transition: opacity 1.2s var(--soft);
}

/* ============================================================
   Quote card
   ============================================================ */
.sketch-quote {
    text-align: center;
}

.big-quote {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(28px, 4vw, 46px);
    line-height: 1.32;
    color: var(--deep-ink);
    letter-spacing: -0.005em;
    position: relative;
    padding: clamp(8px, 2vh, 18px) 0 clamp(16px, 3vh, 24px);
    transform: rotate(-0.5deg);
}

.big-quote em {
    font-family: var(--font-hand);
    font-style: normal;
    font-weight: 700;
    color: var(--graphite);
    display: inline-block;
    transform: rotate(0.6deg);
}

.quote-mark {
    font-family: var(--font-serif);
    font-size: 1.2em;
    color: var(--shadow-wash);
    line-height: 0;
    vertical-align: -0.3em;
    margin-right: 0.1em;
    display: inline-block;
    transform: scale(2);
    transform-origin: center;
    opacity: 0.5;
}

/* ============================================================
   Fire escape, subway, manhole motifs
   ============================================================ */
.fire-escape {
    position: absolute;
    top: 12%;
    right: -20px;
    width: 60px;
    height: 220px;
    opacity: 0.55;
    z-index: 0;
    overflow: visible;
}

.subway-fragment {
    width: 100%;
    max-width: 600px;
    height: auto;
    margin: clamp(12px, 2.5vh, 22px) 0;
    overflow: visible;
}

.subway-path {
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    transition: stroke-dashoffset 2.8s var(--soft);
}

.in-view .subway-path {
    stroke-dashoffset: 0;
}

.subway-path-thin {
    opacity: 0;
    transition: opacity 1.6s var(--soft) 1.6s;
}

.in-view .subway-path-thin {
    opacity: 1;
}

.stations circle {
    transform-origin: center;
    transform-box: fill-box;
    opacity: 0;
    transition: opacity 0.6s var(--elastic);
}

.in-view .stations circle:nth-child(1) { transition-delay: 1.1s; opacity: 1; }
.in-view .stations circle:nth-child(2) { transition-delay: 1.6s; opacity: 1; }
.in-view .stations circle:nth-child(3) { transition-delay: 2.1s; opacity: 1; }
.in-view .stations circle:nth-child(4) { transition-delay: 2.6s; opacity: 1; }

.manhole {
    width: clamp(140px, 30%, 200px);
    height: auto;
    margin: clamp(10px, 2vh, 18px) 0 clamp(20px, 3vh, 28px);
    display: block;
    overflow: visible;
    animation: slowSpin 60s linear infinite;
}

@keyframes slowSpin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.manhole text {
    /* Counter-rotate the label so it stays readable as the disc spins */
    transform-origin: 100px 100px;
    animation: slowCounter 60s linear infinite;
}

@keyframes slowCounter {
    from { transform: rotate(0deg); }
    to   { transform: rotate(-360deg); }
}

/* ============================================================
   Departure scene — puddle reflection
   ============================================================ */
.scene-departure {
    text-align: center;
    margin-bottom: 0;
}

.skyline-departure {
    margin-top: clamp(30px, 5vh, 60px);
}

.puddle-reflection {
    margin-top: -2px;
    transform: scaleY(-1);
    -webkit-mask-image: linear-gradient(to top, rgba(0,0,0,0.25) 0%, rgba(0,0,0,0.1) 50%, transparent 95%);
            mask-image: linear-gradient(to top, rgba(0,0,0,0.25) 0%, rgba(0,0,0,0.1) 50%, transparent 95%);
    opacity: 0.55;
    filter: blur(1.8px);
    animation: shimmer 4s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { filter: blur(1.5px); transform: scaleY(-1) translateX(0); }
    50%      { filter: blur(3px); transform: scaleY(-1) translateX(2px); }
}

.signature {
    font-family: var(--font-display);
    font-size: clamp(18px, 1.5vw, 22px);
    color: var(--graphite);
    margin-top: clamp(40px, 7vh, 80px);
    letter-spacing: 0.04em;
    transform: rotate(-1deg);
}

.departure-title {
    transform: rotate(-1.5deg);
}

/* ============================================================
   Compass nav — bottom-right
   ============================================================ */
.compass-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 64px;
    height: 64px;
    border: none;
    background: rgba(242, 240, 236, 0.85);
    backdrop-filter: blur(8px);
    border-radius: 50%;
    cursor: pointer;
    z-index: 50;
    padding: 4px;
    box-shadow: 0 8px 28px -12px rgba(13, 13, 13, 0.25);
    transition: transform 0.6s var(--elastic);
}

.compass-toggle:hover {
    transform: rotate(45deg) scale(1.06);
}

.compass-svg {
    width: 100%;
    height: 100%;
}

.compass-needle {
    transform-origin: 30px 30px;
    transform-box: fill-box;
    animation: compassWobble 8s ease-in-out infinite;
}

@keyframes compassWobble {
    0%, 100% { transform: rotate(0deg); }
    25%      { transform: rotate(-6deg); }
    50%      { transform: rotate(2deg); }
    75%      { transform: rotate(-3deg); }
}

.compass-overlay {
    position: fixed;
    inset: 0;
    background: rgba(242, 240, 236, 0.62);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 40;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.6s var(--soft), visibility 0.6s;
}

.compass-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

.overlay-inner {
    text-align: center;
    transform: scale(0.94);
    transition: transform 0.7s var(--elastic);
    max-width: 480px;
    padding: 20px;
}

.compass-overlay.is-open .overlay-inner {
    transform: scale(1);
}

.overlay-label {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(28px, 4vw, 48px);
    color: var(--deep-ink);
    margin-bottom: clamp(20px, 3vh, 32px);
    transform: rotate(-1deg);
}

.overlay-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: clamp(14px, 2.4vh, 20px);
    align-items: center;
}

.overlay-list a {
    display: flex;
    align-items: center;
    gap: 16px;
    text-decoration: none;
    font-family: var(--font-display);
    font-size: clamp(22px, 2.5vw, 30px);
    color: var(--graphite);
    transition: color 0.5s var(--soft), transform 0.6s var(--elastic);
    padding: 6px 14px;
    border-radius: 4px;
}

.overlay-list a:hover {
    color: var(--deep-ink);
    transform: translateX(4px);
}

.overlay-thumb {
    width: 48px;
    height: 32px;
    background: var(--paper);
    border: 1px solid var(--light-wash);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.overlay-thumb svg {
    width: 100%;
    height: 100%;
}

.overlay-foot {
    margin-top: clamp(28px, 4vh, 40px);
    font-family: var(--font-hand);
    color: var(--mid-wash);
    font-size: 15px;
    letter-spacing: 0.05em;
}

/* ============================================================
   In-view animation — elastic settle
   ============================================================ */
.fade-up {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.9s var(--soft), transform 0.7s var(--elastic);
}

.fade-up.in-view {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================================
   Responsive — narrower viewports
   ============================================================ */
@media (max-width: 720px) {
    .walk {
        grid-template-columns: 1fr min(94vw, 720px) 1fr;
    }

    .sketch-card {
        padding: clamp(28px, 6vw, 44px) clamp(20px, 5vw, 32px);
    }

    .sketch-card-right {
        grid-template-columns: 1fr;
    }

    .card-flank {
        justify-content: flex-start;
        margin-bottom: -24px;
    }

    .streetlamp {
        height: 120px;
        width: 50px;
    }

    .fire-escape {
        right: -8px;
        top: 6%;
        height: 140px;
        width: 44px;
        opacity: 0.4;
    }

    .display-title {
        font-size: clamp(48px, 14vw, 80px);
    }

    .sketch-title {
        font-size: clamp(32px, 8vw, 48px);
    }

    .corner-pigeon-tl {
        left: 6%;
    }

    .compass-toggle {
        width: 54px;
        height: 54px;
        bottom: 16px;
        right: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
