/* ========================================
   archaic.works - Wabi-Sabi Design System
   Earth tones, kintsugi gold, organic flow.
   ======================================== */

:root {
    /* Palette (from DESIGN.md, exact hex values) */
    --kiln-ash: #2B2622;
    --kiln-ash-cool: #272428;
    --weathered-plaster: #E8E0D4;
    --aged-linen: #D4C9B8;
    --charcoal-slip: #3A332B;
    --gold-lacquer: #C4973B;
    --warm-clay: #8B7355;
    --celadon-glaze: #7D9E8A;

    /* Type */
    --display: "Cormorant Garamond", "Lora", Georgia, serif;
    --body: "Alegreya", "Lora", Georgia, serif;
    --mono: "BIZ UDGothic", "Inter", "Helvetica Neue", sans-serif;

    /* Scroll-driven temperature shift */
    --scroll-progress: 0;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--body);
    font-weight: 400;
    line-height: 2.0;
    color: var(--aged-linen);
    background: linear-gradient(
        to bottom,
        var(--kiln-ash) 0%,
        color-mix(in srgb, var(--kiln-ash) calc((1 - var(--scroll-progress)) * 100%), var(--kiln-ash-cool) calc(var(--scroll-progress) * 100%)) 100%
    );
    background-color: var(--kiln-ash);
    overflow-x: hidden;
    min-height: 100vh;
    transition: background-color 1200ms ease;
}

/* Body grain (paper-aged) on dark sections */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background-image:
        radial-gradient(rgba(212, 201, 184, 0.018) 1px, transparent 1px),
        radial-gradient(rgba(212, 201, 184, 0.012) 1px, transparent 1px);
    background-size: 3px 3px, 7px 7px;
    background-position: 0 0, 1px 2px;
    mix-blend-mode: screen;
}

/* ========================================
   HERO / Opening Viewport
   ======================================== */

.hero {
    position: relative;
    width: 100%;
    height: 100vh;
    min-height: 600px;
    background-color: var(--kiln-ash);
    overflow: hidden;
    z-index: 2;
}

.hero-grain {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image:
        radial-gradient(rgba(212, 201, 184, 0.04) 1px, transparent 1.4px),
        radial-gradient(rgba(212, 201, 184, 0.025) 1px, transparent 1px);
    background-size: 4px 4px, 9px 9px;
    background-position: 0 0, 2px 3px;
    opacity: 0.6;
    mix-blend-mode: screen;
}

.kintsugi-crack-hero {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

#crackMainPath {
    stroke-dasharray: 2400;
    stroke-dashoffset: 2400;
    animation: drawCrack 2500ms cubic-bezier(0.25, 0.1, 0.25, 1.0) 300ms forwards;
}

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

/* Dust motes */
.dust-motes {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 3;
    overflow: hidden;
    opacity: 0;
    animation: motesFadeIn 1400ms ease 1800ms forwards;
}

@keyframes motesFadeIn {
    to { opacity: 1; }
}

.mote {
    position: absolute;
    bottom: -10px;
    width: var(--sz, 3px);
    height: var(--sz, 3px);
    border-radius: 50%;
    background: var(--gold-lacquer);
    opacity: var(--op, 0.18);
    filter: drop-shadow(0 0 3px rgba(196, 151, 59, 0.45));
    animation: drift var(--dur, 20s) linear var(--d, 0s) infinite;
}

@keyframes drift {
    0% {
        transform: translateY(0) translateX(0);
        opacity: 0;
    }
    10% {
        opacity: var(--op, 0.18);
    }
    50% {
        transform: translateY(-50vh) translateX(8px);
    }
    90% {
        opacity: var(--op, 0.18);
    }
    100% {
        transform: translateY(-110vh) translateX(-6px);
        opacity: 0;
    }
}

.domain-mark {
    position: absolute;
    left: 8vw;
    bottom: 22vh;
    font-family: var(--display);
    font-weight: 300;
    font-size: clamp(36px, 7vw, 96px);
    letter-spacing: 0.06em;
    line-height: 1.3;
    color: var(--aged-linen);
    transform: rotate(-1.2deg) translateY(8px);
    opacity: 0;
    animation: domainFade 1200ms cubic-bezier(0.25, 0.1, 0.25, 1.0) 2200ms forwards;
    z-index: 5;
    user-select: none;
}

@keyframes domainFade {
    to {
        opacity: 1;
        transform: rotate(-1.2deg) translateY(0);
    }
}

.hero-meta {
    position: absolute;
    left: 8vw;
    bottom: 16vh;
    font-family: var(--mono);
    font-size: 13px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--warm-clay);
    opacity: 0;
    animation: metaFade 1000ms ease 2800ms forwards;
    z-index: 5;
}

@keyframes metaFade {
    to { opacity: 0.78; }
}

/* ========================================
   Brush stroke dividers
   ======================================== */

.brush-divider {
    width: 100%;
    height: 40px;
    margin: 14vh 0;
    z-index: 4;
    position: relative;
}

.brush-divider svg {
    width: 100%;
    height: 100%;
    display: block;
}

.brush-divider-light {
    margin: 8vh 0 14vh;
}

/* ========================================
   Clearing zones (organic clip-path pools)
   ======================================== */

.clearing {
    position: relative;
    background-color: var(--weathered-plaster);
    color: var(--charcoal-slip);
    margin: 0 auto;
    padding: 12vh 0 14vh;
    width: 92vw;
    max-width: 1200px;
    z-index: 4;
    /* Paper-grain texture on light surface */
    background-image:
        radial-gradient(rgba(58, 51, 43, 0.025) 1px, transparent 1.5px),
        radial-gradient(rgba(58, 51, 43, 0.018) 1px, transparent 1px);
    background-size: 3px 3px, 8px 8px;
    background-position: 0 0, 1px 2px;
    box-shadow:
        0 0 0 1px rgba(139, 115, 85, 0.04),
        0 30px 80px rgba(43, 38, 34, 0.18);
}

/* Each clearing has a unique organic clip-path */
.clearing[data-shape="one"] {
    clip-path: polygon(2% 5%, 98% 0%, 100% 92%, 5% 100%);
    margin-top: 8vh;
}

.clearing[data-shape="two"] {
    clip-path: polygon(0% 4%, 96% 2%, 100% 96%, 3% 100%);
    margin-top: 18vh;
}

.clearing[data-shape="three"] {
    clip-path: polygon(4% 0%, 100% 6%, 96% 100%, 0% 94%);
    margin-top: 16vh;
}

.clearing[data-shape="four"] {
    clip-path: polygon(2% 3%, 99% 0%, 100% 95%, 0% 100%);
    margin-top: 22vh;
}

.clearing-inner {
    position: relative;
    padding: 4vh 8vw;
    z-index: 2;
}

.caption-meta {
    font-family: var(--mono);
    font-size: 13px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--warm-clay);
    margin-bottom: 3vh;
    line-height: 1.6;
}

.meta-trailing {
    margin-top: 5vh;
    margin-bottom: 0;
    color: var(--warm-clay);
    opacity: 0.85;
}

.clearing-title {
    font-family: var(--display);
    font-weight: 300;
    font-size: clamp(28px, 5.4vw, 72px);
    letter-spacing: 0.06em;
    line-height: 1.3;
    color: var(--charcoal-slip);
    margin-bottom: 5vh;
    transform: rotate(-0.6deg);
    transform-origin: top left;
}

.clearing-title .line {
    display: block;
}

.clearing-body {
    font-family: var(--body);
    font-weight: 400;
    font-size: clamp(16px, 1.2vw, 20px);
    line-height: 2.0;
    color: var(--charcoal-slip);
    max-width: 60ch;
    margin-bottom: 3vh;
    text-align: left;
    transform: rotate(0.5deg);
}

.clearing-body.shifted {
    margin-left: 12%;
    max-width: 56ch;
    transform: rotate(-0.4deg);
}

.clearing-body.shifted-right {
    margin-left: auto;
    margin-right: 4%;
    max-width: 52ch;
    transform: rotate(0.7deg);
    text-align: left;
}

.clearing-body .line {
    display: block;
}

/* Per-line stagger reveal */
.line-reveal .line {
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 700ms ease, transform 700ms ease;
}

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

.reveal.is-visible .line-reveal .line:nth-child(1) { transition-delay: 0ms; }
.reveal.is-visible .line-reveal .line:nth-child(2) { transition-delay: 80ms; }
.reveal.is-visible .line-reveal .line:nth-child(3) { transition-delay: 160ms; }
.reveal.is-visible .line-reveal .line:nth-child(4) { transition-delay: 240ms; }
.reveal.is-visible .line-reveal .line:nth-child(5) { transition-delay: 320ms; }
.reveal.is-visible .line-reveal .line:nth-child(6) { transition-delay: 400ms; }
.reveal.is-visible .line-reveal .line:nth-child(7) { transition-delay: 480ms; }
.reveal.is-visible .line-reveal .line:nth-child(8) { transition-delay: 560ms; }

/* Whole-clearing fade + scale on reveal */
.reveal {
    opacity: 0;
    transform: scale(0.98);
    transition: opacity 800ms cubic-bezier(0.25, 0.1, 0.25, 1.0),
                transform 800ms cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

.reveal.is-visible {
    opacity: 1;
    transform: scale(1.0);
}

/* ========================================
   Showcase figures (project images)
   ======================================== */

.showcase-figure {
    position: relative;
    width: 90%;
    max-width: 1100px;
    margin: 5vh auto;
    padding: 0;
    overflow: visible;
}

.showcase-left {
    margin-left: 0;
    margin-right: auto;
    transform: rotate(-0.5deg) translateX(-2%);
}

.showcase-right {
    margin-left: auto;
    margin-right: 0;
    transform: rotate(0.7deg) translateX(2%);
}

.showcase-figure .paper-tile {
    position: relative;
    width: 100%;
    aspect-ratio: 5 / 3;
    overflow: hidden;
    background: var(--weathered-plaster);
    box-shadow:
        0 14px 32px rgba(43, 38, 34, 0.22),
        0 0 0 1px rgba(139, 115, 85, 0.08);
    transition: transform 700ms cubic-bezier(0.25, 0.1, 0.25, 1.0);
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 800ms ease 200ms, transform 800ms ease 200ms;
}

.reveal.is-visible .showcase-figure .paper-tile {
    opacity: 1;
    transform: translateX(0);
}

.showcase-figure .paper-tile svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Kintsugi hover overlay (gold crack appears on hover) */
.kintsugi-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    clip-path: inset(0 100% 0 0);
    transition: clip-path 600ms cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

.paper-tile:hover .kintsugi-overlay {
    clip-path: inset(0 0 0 0);
}

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

/* ========================================
   Bowl watermarks (slow rotation, idle reveal)
   ======================================== */

.bowl-watermark {
    position: absolute;
    width: 30vw;
    max-width: 380px;
    height: auto;
    opacity: 0.10;
    pointer-events: none;
    z-index: 3;
    transition: opacity 3000ms ease;
    animation: wheel 120s linear infinite;
    transform-origin: center center;
}

.is-idle .bowl-watermark {
    opacity: 0.20;
}

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

.bowl-wm-1 {
    top: -8vh;
    right: -6vw;
}

.bowl-wm-2 {
    top: 5vh;
    left: -8vw;
    width: 28vw;
}

.bowl-wm-3 {
    bottom: 4vh;
    right: -7vw;
    width: 32vw;
}

.bowl-wm-4 {
    top: 3vh;
    right: 5vw;
    width: 26vw;
}

/* ========================================
   Archive list (no. 04 clearing)
   ======================================== */

.archive-list {
    list-style: none;
    margin-top: 6vh;
    margin-left: 4%;
    max-width: 64ch;
}

.archive-list li {
    display: flex;
    align-items: baseline;
    gap: 24px;
    padding: 18px 0;
    border-top: 1px solid rgba(139, 115, 85, 0.22);
    transform: rotate(-0.2deg);
}

.archive-list li:last-child {
    border-bottom: 1px solid rgba(139, 115, 85, 0.22);
}

.archive-tag {
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--warm-clay);
    flex: 0 0 130px;
}

.archive-link {
    font-family: var(--display);
    font-weight: 400;
    font-style: italic;
    font-size: clamp(18px, 1.6vw, 24px);
    color: var(--charcoal-slip);
    text-decoration: none;
    letter-spacing: 0.02em;
    position: relative;
    transition: color 400ms ease;
}

.archive-link::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -4px;
    width: 0;
    height: 1px;
    background: var(--gold-lacquer);
    transition: width 600ms cubic-bezier(0.25, 0.1, 0.25, 1.0);
    box-shadow: 0 0 6px rgba(196, 151, 59, 0.5);
}

.archive-link:hover {
    color: var(--gold-lacquer);
}

.archive-link:hover::after {
    width: 100%;
}

.archive-link:visited {
    color: var(--celadon-glaze);
}

/* ========================================
   Footer
   ======================================== */

.site-footer {
    position: relative;
    background: var(--kiln-ash);
    color: var(--aged-linen);
    padding: 30vh 0 10vh;
    text-align: center;
    overflow: hidden;
    z-index: 4;
}

.site-footer::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image:
        radial-gradient(rgba(212, 201, 184, 0.035) 1px, transparent 1.4px),
        radial-gradient(rgba(212, 201, 184, 0.022) 1px, transparent 1px);
    background-size: 4px 4px, 9px 9px;
    background-position: 0 0, 2px 3px;
    opacity: 0.6;
    mix-blend-mode: screen;
}

.closing-line {
    font-family: var(--display);
    font-style: italic;
    font-weight: 300;
    font-size: clamp(22px, 3.2vw, 38px);
    letter-spacing: 0.08em;
    color: var(--aged-linen);
    line-height: 1.3;
    margin-bottom: 6vh;
}

.footer-bowl {
    width: 240px;
    height: auto;
    max-width: 60vw;
    margin: 0 auto 5vh;
    display: block;
    opacity: 0.65;
}

.footer-bowl path {
    stroke: var(--celadon-glaze);
}

.footer-meta {
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.1em;
    text-transform: lowercase;
    color: var(--warm-clay);
    opacity: 0.7;
    line-height: 1.6;
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 768px) {
    .domain-mark {
        left: 6vw;
        bottom: 24vh;
    }

    .hero-meta {
        left: 6vw;
        bottom: 18vh;
    }

    .clearing {
        width: 96vw;
        padding: 10vh 0 12vh;
    }

    .clearing-inner {
        padding: 3vh 6vw;
    }

    .clearing-body.shifted,
    .clearing-body.shifted-right {
        margin-left: 0;
        margin-right: 0;
    }

    .archive-list li {
        flex-direction: column;
        gap: 4px;
        align-items: flex-start;
    }

    .archive-tag {
        flex: 0 0 auto;
    }

    .bowl-watermark {
        width: 50vw;
    }

    .site-footer {
        padding: 20vh 0 8vh;
    }
}

@media (max-width: 480px) {
    .clearing[data-shape="one"],
    .clearing[data-shape="two"],
    .clearing[data-shape="three"],
    .clearing[data-shape="four"] {
        clip-path: polygon(0% 2%, 100% 0%, 100% 98%, 0% 100%);
    }
}

/* Reduced motion: keep visual identity, suppress motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    #crackMainPath {
        stroke-dashoffset: 0;
    }

    .domain-mark,
    .hero-meta,
    .dust-motes {
        opacity: 1;
    }

    .reveal {
        opacity: 1;
        transform: none;
    }

    .reveal .line-reveal .line {
        opacity: 1;
        transform: none;
    }
}
