/* ============================================
   martialaw.quest — Wabi-Sabi Urban Aesthetic
   Scroll: IntersectionObserver with threshold 0.3.
   Fonts: Poiret One, Zen Kaku Gothic New, Cutive Mono
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --wet-concrete: #2a2d31;
    --dojo-plaster: #3d4147;
    --oxidized-steel: #545a62;
    --rice-paper: #d8d4ce;
    --stone-dust: #9a9590;
    --celadon-crack: #7a9e8e;
    --kintsugi-gold: #b8a47c;
    --ink-well: #1a1c1f;

    --font-display: 'Poiret One', cursive;
    --font-body: 'Zen Kaku Gothic New', sans-serif;
    --font-mono: 'Cutive Mono', monospace;
}

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

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

body {
    background-color: var(--wet-concrete);
    color: var(--rice-paper);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    line-height: 1.85;
    letter-spacing: 0.02em;
    overflow-x: hidden;
    position: relative;
}

/* --- Noise Texture Overlay --- */
#noise-svg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.02;
}

/* --- Ambient Rain Layer --- */
#rain-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.rain-drop {
    position: absolute;
    top: -40px;
    width: 0.5px;
    height: 30px;
    background: linear-gradient(to bottom, transparent, rgba(216, 212, 206, 0.04), transparent);
    animation: fall linear infinite;
}

@keyframes fall {
    0% {
        transform: translateY(-40px);
    }
    100% {
        transform: translateY(calc(100vh + 40px));
    }
}

/* --- Hero Section (Entry Gate) --- */
.section-hero {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    overflow: hidden;
    z-index: 2;
    background-color: var(--wet-concrete);
}

/* Hero Collage — CSS-constructed abstract cityscape */
.hero-collage {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.collage-block {
    position: absolute;
    background-color: var(--dojo-plaster);
}

.cb-1 {
    width: 120px;
    height: 340px;
    top: 10%;
    right: 15%;
    opacity: 0.4;
    clip-path: polygon(0 0, 100% 0, 100% 85%, 0 100%);
}

.cb-2 {
    width: 80px;
    height: 260px;
    top: 20%;
    right: 22%;
    background-color: var(--oxidized-steel);
    opacity: 0.3;
}

.cb-3 {
    width: 160px;
    height: 200px;
    bottom: 15%;
    right: 10%;
    opacity: 0.25;
    clip-path: polygon(0 10%, 100% 0, 100% 100%, 0 90%);
}

.cb-4 {
    width: 60px;
    height: 380px;
    top: 5%;
    right: 35%;
    background-color: var(--ink-well);
    opacity: 0.5;
}

.cb-5 {
    width: 200px;
    height: 140px;
    bottom: 25%;
    right: 28%;
    background-color: var(--oxidized-steel);
    opacity: 0.2;
    clip-path: polygon(5% 0, 100% 0, 95% 100%, 0 100%);
}

.cb-6 {
    width: 100px;
    height: 300px;
    top: 15%;
    right: 42%;
    opacity: 0.15;
    clip-path: polygon(0 0, 100% 5%, 100% 95%, 0 100%);
}

.cb-7 {
    width: 140px;
    height: 180px;
    bottom: 10%;
    right: 40%;
    background-color: var(--dojo-plaster);
    opacity: 0.3;
    box-shadow: 8px 12px 30px rgba(26, 28, 31, 0.6);
}

/* Calligraphic Strokes — tall thin rectangles */
.collage-stroke {
    position: absolute;
    background-color: var(--celadon-crack);
}

.cs-1 {
    width: 4px;
    height: 80px;
    top: 30%;
    right: 18%;
    transform: rotate(25deg);
    opacity: 0.2;
}

.cs-2 {
    width: 3px;
    height: 110px;
    top: 45%;
    right: 32%;
    transform: rotate(-35deg);
    opacity: 0.15;
}

.cs-3 {
    width: 5px;
    height: 60px;
    bottom: 30%;
    right: 25%;
    transform: rotate(45deg);
    opacity: 0.25;
}

/* Dojo Grid Lines */
.dojo-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(to right, rgba(216, 212, 206, 0.04) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(216, 212, 206, 0.04) 1px, transparent 1px);
    background-size: 80px 80px;
    z-index: 0;
    pointer-events: none;
}

/* Hero Content */
.hero-content {
    position: relative;
    z-index: 2;
    padding-left: 8vw;
    max-width: 60%;
}

.hero-title {
    font-family: var(--font-display);
    font-size: clamp(3rem, 8vw, 7rem);
    font-weight: 400;
    letter-spacing: 0.15em;
    color: var(--rice-paper);
    opacity: 0;
    transform: scale(1.2);
    animation: zoomFocusHero 1200ms cubic-bezier(0.16, 1, 0.3, 1) 600ms forwards;
    line-height: 1.1;
}

.hero-subtitle {
    font-family: var(--font-mono);
    font-size: clamp(0.75rem, 1.2vw, 0.85rem);
    letter-spacing: 0.06em;
    color: var(--stone-dust);
    margin-top: 1.5rem;
    opacity: 0;
    animation: fadeIn 800ms ease 2200ms forwards;
}

@keyframes zoomFocusHero {
    0% {
        opacity: 0;
        transform: scale(1.2);
        filter: blur(2px);
    }
    100% {
        opacity: 1;
        transform: scale(1);
        filter: blur(0);
    }
}

@keyframes fadeIn {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

/* --- Kintsugi Lines --- */
.kintsugi-line {
    position: relative;
    width: 100%;
    height: 50px;
    z-index: 10;
    margin-top: -25px;
    margin-bottom: -25px;
    pointer-events: none;
}

.kintsugi-line svg {
    display: block;
    width: 100%;
    height: 100%;
}

.kintsugi-path {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 1.5s ease-in-out;
}

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

/* --- Diagonal Sections --- */
.diagonal-section {
    position: relative;
    min-height: 80vh;
    padding: 8vh 0;
    z-index: 2;
    animation: breathe 6s ease-in-out infinite;
}

@keyframes breathe {
    0%, 100% {
        padding-top: 8vh;
    }
    50% {
        padding-top: 8.4vh;
    }
}

.diagonal-left {
    background-color: var(--dojo-plaster);
    clip-path: polygon(0 4vh, 100% 0, 100% calc(100% - 4vh), 0 100%);
}

.diagonal-right {
    background-color: var(--wet-concrete);
    clip-path: polygon(0 0, 100% 4vh, 100% 100%, 0 calc(100% - 4vh));
}

.section-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 6vh 5vw;
}

/* Section Grid — 6-column with asymmetric empty columns */
.section-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 2rem;
}

.diagonal-left .section-content {
    grid-column: 1 / 5;
}

.diagonal-right .section-content {
    grid-column: 3 / 7;
}

.section-label {
    font-family: var(--font-mono);
    font-size: clamp(0.75rem, 1.2vw, 0.85rem);
    letter-spacing: 0.06em;
    color: var(--celadon-crack);
    text-transform: lowercase;
    display: block;
    margin-bottom: 1rem;
}

.section-heading {
    font-family: var(--font-display);
    font-size: clamp(1.8rem, 4vw, 3rem);
    font-weight: 400;
    letter-spacing: 0.15em;
    color: var(--rice-paper);
    margin-bottom: 2rem;
    line-height: 1.2;
}

.section-text {
    color: var(--rice-paper);
    font-weight: 400;
    max-width: 600px;
    margin-bottom: 1.5rem;
}

.section-text:last-child {
    margin-bottom: 0;
}

/* --- Zoom Focus Animation for Scroll --- */
.zoom-focus {
    opacity: 0;
    transform: scale(1.08);
    filter: blur(2px);
    transition: opacity 800ms ease, transform 800ms cubic-bezier(0.16, 1, 0.3, 1), filter 800ms ease;
}

.zoom-focus.in-view {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
}

/* --- Practice Floor (Collage Cards) --- */
.practice-floor-section {
    position: relative;
    min-height: 100vh;
    padding: 12vh 5vw;
    z-index: 2;
    background-color: var(--ink-well);
    overflow: hidden;
}

.practice-floor-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(to right, rgba(216, 212, 206, 0.03) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(216, 212, 206, 0.03) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
}

.practice-floor-inner {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
}

.practice-floor-inner > .section-heading {
    text-align: left;
    margin-bottom: 6vh;
    padding-left: 2vw;
}

.practice-cards {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    padding: 2rem;
}

.practice-card {
    background-color: var(--dojo-plaster);
    padding: 2.5rem 2rem;
    position: relative;
    box-shadow: 6px 8px 24px rgba(26, 28, 31, 0.5);
    opacity: 0;
    transform: translateY(40px);
}

.card-1 {
    transform: rotate(-1.5deg) translateY(40px);
    background-color: var(--dojo-plaster);
}

.card-2 {
    transform: rotate(1deg) translateX(30px) translateY(40px);
    background-color: #434950;
    margin-top: 3rem;
}

.card-3 {
    transform: rotate(-2deg) translateY(40px);
    background-color: var(--oxidized-steel);
}

.card-4 {
    transform: rotate(1.5deg) translateY(40px);
    background-color: #3a3f46;
    margin-top: -2rem;
}

.card-5 {
    transform: rotate(-0.5deg) translateX(-10px) translateY(40px);
    background-color: var(--dojo-plaster);
}

.card-6 {
    transform: rotate(2deg) translateY(40px);
    background-color: #4a5058;
    margin-top: 1rem;
}

.practice-card.card-assembled {
    opacity: 1;
}

.card-1.card-assembled { transform: rotate(-1.5deg); }
.card-2.card-assembled { transform: rotate(1deg) translateX(30px); margin-top: 3rem; }
.card-3.card-assembled { transform: rotate(-2deg); }
.card-4.card-assembled { transform: rotate(1.5deg); margin-top: -2rem; }
.card-5.card-assembled { transform: rotate(-0.5deg) translateX(-10px); }
.card-6.card-assembled { transform: rotate(2deg); margin-top: 1rem; }

.card-label {
    font-family: var(--font-mono);
    font-size: clamp(0.75rem, 1.2vw, 0.85rem);
    letter-spacing: 0.06em;
    color: var(--kintsugi-gold);
    display: block;
    margin-bottom: 1rem;
    text-transform: lowercase;
}

.card-text {
    color: var(--rice-paper);
    font-size: clamp(0.9rem, 1.4vw, 1rem);
    line-height: 1.75;
}

/* --- Urban Motifs --- */
.urban-motifs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.urban-motif {
    position: absolute;
    opacity: 0.4;
}

.motif-powerline {
    width: 40px;
    height: 80px;
    top: 15%;
    left: 3%;
}

.motif-watertower {
    width: 35px;
    height: 50px;
    top: 55%;
    right: 4%;
}

.motif-fireescape {
    width: 30px;
    height: 60px;
    top: 70%;
    left: 5%;
}

.motif-manhole {
    width: 30px;
    height: 30px;
    bottom: 12%;
    right: 6%;
}

/* --- Still Pool (Footer) --- */
.still-pool {
    position: relative;
    height: 50vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    background-color: var(--wet-concrete);
}

.footer-text {
    font-family: var(--font-mono);
    font-size: clamp(0.75rem, 1.2vw, 0.85rem);
    letter-spacing: 0.1em;
    color: var(--stone-dust);
    text-align: center;
    opacity: 0;
    transition: opacity 1.5s ease;
}

.footer-text.in-view {
    opacity: 1;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .hero-content {
        padding-left: 6vw;
        max-width: 90%;
    }

    .section-grid {
        grid-template-columns: 1fr;
    }

    .diagonal-left .section-content,
    .diagonal-right .section-content {
        grid-column: 1 / -1;
    }

    .practice-cards {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .card-1, .card-2, .card-3, .card-4, .card-5, .card-6 {
        transform: none !important;
        margin-top: 0 !important;
    }

    .card-1.card-assembled,
    .card-2.card-assembled,
    .card-3.card-assembled,
    .card-4.card-assembled,
    .card-5.card-assembled,
    .card-6.card-assembled {
        transform: none !important;
        margin-top: 0 !important;
    }

    .collage-block, .collage-stroke {
        display: none;
    }

    .urban-motifs {
        display: none;
    }

    .section-inner {
        padding: 6vh 6vw;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: clamp(2.2rem, 10vw, 3.5rem);
    }

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

    .practice-card {
        padding: 1.5rem 1.2rem;
    }
}
