/* ============================
   archaic.studio v2
   Wabi-sabi design system
   ============================ */

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

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

body {
    font-family: 'Karla', sans-serif;
    font-weight: 300;
    font-size: clamp(15px, 1.2vw, 18px);
    line-height: 2.0;
    letter-spacing: 0.02em;
    color: var(--text-primary, #5C4D3C);
    background-color: var(--bg, #F0E6D3);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 600ms ease, color 600ms ease;
}

:root {
    --bg: #F0E6D3;
    --bg-deep: #2C2419;
    --text-primary: #5C4D3C;
    --text-secondary: #8A7B6A;
    --text-light: #D4C5A9;
    --gold: #C9A84C;
    --frame: #C4B5A0;
    --fire: #A0522D;
    --clay-mid: #E8D9C0;
    --clay-pale: #F5EDE0;
}

body.in-dark-zone {
    --bg: #2C2419;
    --text-primary: #D4C5A9;
    --text-secondary: #A69783;
    background-color: #2C2419;
    color: #D4C5A9;
}

/* --- Stippled background texture --- */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.07;
    background-image:
        radial-gradient(circle at 20% 30%, #8A7B6A 1px, transparent 1.6px),
        radial-gradient(circle at 60% 15%, #8A7B6A 1.2px, transparent 1.8px),
        radial-gradient(circle at 85% 45%, #8A7B6A 0.8px, transparent 1.4px),
        radial-gradient(circle at 40% 70%, #8A7B6A 1px, transparent 1.6px),
        radial-gradient(circle at 10% 85%, #8A7B6A 1.5px, transparent 2.2px),
        radial-gradient(circle at 70% 60%, #8A7B6A 1px, transparent 1.6px),
        radial-gradient(circle at 50% 90%, #8A7B6A 0.8px, transparent 1.4px),
        radial-gradient(circle at 30% 50%, #8A7B6A 1.2px, transparent 1.8px);
    background-size:
        180px 200px,
        220px 180px,
        160px 240px,
        200px 190px,
        240px 210px,
        190px 170px,
        210px 230px,
        170px 200px;
    transition: opacity 800ms ease;
}

body.in-dark-zone::before {
    opacity: 0.025;
}

/* --- Page container --- */
.page {
    position: relative;
    z-index: 1;
}

/* --- Typography defaults --- */
h1, h2, h3 {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    letter-spacing: 0.12em;
    line-height: 1.3;
    color: var(--text-primary);
}

p {
    color: var(--text-primary);
}

em {
    font-style: italic;
    color: var(--text-secondary);
}

/* --- Section meta label (Roman numeral + label) --- */
.section-meta {
    display: flex;
    align-items: baseline;
    gap: 1.2rem;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #A69783;
    margin-bottom: 4rem;
}

.section-meta__num {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: 16px;
    letter-spacing: 0.15em;
    color: var(--gold);
}

.section-meta__label {
    color: #A69783;
}

/* ============================
   OPENING VIEWPORT
   ============================ */
.opening {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
}

.opening__field {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3rem;
    width: 100%;
    max-width: 560px;
}

.opening__circle {
    width: clamp(220px, 38vw, 380px);
    height: clamp(220px, 38vw, 380px);
    opacity: 0;
    animation: ensoFadeIn 2000ms ease-out forwards, breathe 8s ease-in-out 2000ms infinite;
    transform-origin: center;
}

@keyframes ensoFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes breathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.015); }
}

/* Kintsugi crack paths in opening — hidden until triggered */
.kintsugi-crack,
.kintsugi-crack-glow,
.kintsugi-crack-branch,
.kintsugi-line {
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
}

.kintsugi-crack.animate {
    animation: drawCrack 3000ms ease-in-out forwards;
}

.kintsugi-crack-glow.animate {
    animation: drawCrack 3000ms ease-in-out 400ms forwards;
}

.kintsugi-crack-branch.animate {
    animation: drawCrack 2200ms ease-in-out 1200ms forwards;
}

.kintsugi-line.animate {
    animation: drawCrack 2500ms ease-in-out forwards;
}

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

/* Opening logotype + meta */
.opening__mark {
    text-align: center;
    opacity: 0;
    transform: translateY(8px);
    animation: openingMarkFade 1500ms ease-out 1200ms forwards;
}

.opening__title {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: clamp(28px, 4vw, 56px);
    letter-spacing: 0.15em;
    color: var(--text-primary);
    margin-bottom: 1.4rem;
}

.opening__meta {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 11px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: #A69783;
    line-height: 1.6;
}

@keyframes openingMarkFade {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scroll hint */
.opening__hint {
    position: absolute;
    bottom: 3vh;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.9rem;
    opacity: 0;
    animation: openingMarkFade 1500ms ease-out 2600ms forwards;
}

.opening__hint-line {
    display: block;
    width: 1px;
    height: 36px;
    background: linear-gradient(to bottom, transparent, #A69783);
}

.opening__hint-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.32em;
    color: #A69783;
}

/* ============================
   COMMON SECTION SCAFFOLDING
   ============================ */
section {
    position: relative;
}

.philosophy,
.works,
.process {
    padding: 10rem 2rem 8rem;
    position: relative;
    overflow: hidden;
}

/* Decorative watermarks (background enso) */
.watermark {
    position: absolute;
    width: clamp(420px, 70vw, 760px);
    height: clamp(420px, 70vw, 760px);
    opacity: 0.18;
    pointer-events: none;
    z-index: 0;
}

.watermark--right {
    right: -18vw;
    top: 18%;
}

.watermark--left {
    left: -16vw;
    top: 28%;
}

/* ============================
   PHILOSOPHY (Scroll zone 1)
   ============================ */
.philosophy {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.philosophy .section-meta {
    width: 100%;
    max-width: 520px;
    justify-content: flex-start;
}

.philosophy__column {
    position: relative;
    z-index: 1;
    max-width: 520px;
    width: 100%;
    margin: 0 auto;
}

.philosophy__block {
    margin-bottom: 4rem;
}

.philosophy__block:last-child {
    margin-bottom: 0;
}

.philosophy__block .lede {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: clamp(22px, 2.4vw, 32px);
    letter-spacing: 0.05em;
    line-height: 1.5;
    color: var(--text-primary);
}

.philosophy__block p {
    font-size: clamp(15px, 1.2vw, 18px);
    line-height: 2.0;
    color: var(--text-primary);
}

.philosophy__divider {
    margin: 2rem 0 4rem;
    display: block;
}

.philosophy__divider svg {
    width: 100%;
    height: 8px;
    overflow: visible;
}

/* ============================
   WORKS (Scroll zone 2)
   ============================ */
.works {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.works .section-meta {
    align-self: flex-start;
    margin-left: max(2rem, 8vw);
}

.works__intro {
    max-width: 520px;
    margin: 0 auto 5rem;
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(16px, 1.4vw, 20px);
    letter-spacing: 0.04em;
    line-height: 1.8;
    font-weight: 300;
}

/* Irregular hand-placed grid (CSS grid, explicit row/column placement) */
.works__arrangement {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-auto-rows: minmax(40px, auto);
    gap: 1.5rem 1.2rem;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 0;
}

/* Frame variants — each placed by hand */
.frame {
    background: rgba(240, 230, 211, 0.6);
    border: 1px solid var(--frame);
    box-shadow: inset 0 0 30px rgba(44, 36, 25, 0.08);
    transition: box-shadow 600ms ease, transform 600ms ease;
    position: relative;
    overflow: hidden;
}

.frame:hover {
    box-shadow: inset 0 0 40px rgba(44, 36, 25, 0.15);
}

.frame--scroll-tall {
    grid-column: 1 / span 4;
    grid-row: 1 / span 8;
    border-radius: 4px 6px 3px 7px;
    margin-top: 1.5rem;
}

.frame--landscape-wide {
    grid-column: 6 / span 7;
    grid-row: 1 / span 4;
    border-radius: 6px 3px 5px 4px;
}

.frame--square-small {
    grid-column: 6 / span 3;
    grid-row: 6 / span 4;
    border-radius: 3px 7px 4px 5px;
    margin-top: 1.5rem;
}

.frame--scroll-narrow {
    grid-column: 10 / span 3;
    grid-row: 5 / span 5;
    border-radius: 5px 2px 7px 3px;
    margin-top: 3rem;
}

.frame__inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 1.4rem 1.4rem 1.6rem;
    gap: 1rem;
}

.frame__index {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.2em;
    color: #A69783;
    text-transform: uppercase;
}

.frame__num {
    color: var(--gold);
}

.frame__art {
    width: 100%;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
}

.frame__art svg {
    width: 100%;
    height: auto;
    max-height: 320px;
    display: block;
}

.frame__title {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: clamp(15px, 1.3vw, 19px);
    letter-spacing: 0.1em;
    line-height: 1.4;
    color: var(--text-primary);
}

.frame__caption {
    font-size: clamp(13px, 1vw, 14px);
    line-height: 1.7;
    color: var(--text-secondary);
    font-weight: 300;
}

/* Quiet line after the works */
.works__quiet {
    max-width: 520px;
    margin: 6rem auto 0;
    text-align: center;
    color: var(--text-secondary);
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: clamp(15px, 1.3vw, 18px);
    line-height: 1.9;
}

.works__quiet-mark {
    display: block;
    color: var(--gold);
    font-size: 32px;
    margin-bottom: 1rem;
    letter-spacing: 0;
    line-height: 0.5;
}

/* ============================
   PROCESS (Scroll zone 3)
   ============================ */
.process {
    padding: 10rem 2rem 8rem;
}

.process .section-meta {
    margin-left: max(2rem, 15vw);
    max-width: 580px;
}

.process__column {
    position: relative;
    z-index: 1;
    max-width: 580px;
    margin-left: max(2rem, 15vw);
    margin-right: auto;
}

.process__block {
    margin-bottom: 3.4rem;
}

.process__block h2 {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: clamp(24px, 2.6vw, 36px);
    letter-spacing: 0.08em;
    margin-bottom: 1.6rem;
    color: var(--text-primary);
}

.process__block p {
    font-size: clamp(15px, 1.2vw, 18px);
    line-height: 2.0;
    color: var(--text-primary);
}

.process__inline-mark {
    display: flex;
    margin: 3rem 0;
}

.process__inline-mark svg {
    width: 56px;
    height: auto;
    opacity: 0.7;
}

.process__inline-mark--dots svg {
    width: 200px;
    height: 18px;
    opacity: 0.85;
}

.process__signature {
    margin-top: 5rem;
    display: flex;
    align-items: center;
    gap: 1.4rem;
}

.process__signature-line {
    display: block;
    flex: 0 0 60px;
    height: 1px;
    background: var(--gold);
    opacity: 0.7;
}

.process__signature-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.22em;
    color: #A69783;
    text-transform: uppercase;
}

/* ============================
   CLOSING VIEWPORT
   ============================ */
.closing {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    background-color: #2C2419;
    color: #D4C5A9;
    transition: background-color 800ms ease;
}

.closing__inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3rem;
    max-width: 600px;
    width: 100%;
    text-align: center;
}

.closing__bowl {
    width: clamp(280px, 50vw, 480px);
    height: auto;
}

.closing__bowl path {
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
}

.closing__bowl.animate path {
    animation: drawCrack 3500ms ease-in-out forwards;
}

.closing__bowl.animate #bowlRim {
    animation-delay: 600ms;
}

.closing__bowl.animate #bowlSeam {
    animation-delay: 1400ms;
}

.closing__mark {
    color: #D4C5A9;
}

.closing__title {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: clamp(28px, 4vw, 52px);
    letter-spacing: 0.15em;
    color: #D4C5A9;
    margin-bottom: 1.4rem;
}

.closing__line {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-weight: 300;
    font-size: clamp(15px, 1.4vw, 20px);
    line-height: 1.8;
    color: rgba(212, 197, 169, 0.6);
    max-width: 480px;
    margin: 0 auto;
    letter-spacing: 0.04em;
}

.closing__meta {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.28em;
    color: rgba(166, 151, 131, 0.7);
    text-transform: uppercase;
}

/* ============================
   REVEAL (scroll-triggered, plays once)
   ============================ */
.reveal {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 800ms ease-out, transform 800ms ease-out;
}

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

/* ============================
   RESPONSIVE
   ============================ */
@media (max-width: 880px) {
    .philosophy,
    .works,
    .process {
        padding: 7rem 1.5rem 5rem;
    }

    .works .section-meta,
    .process .section-meta,
    .process__column {
        margin-left: 1.5rem;
    }

    .works__arrangement {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .frame--scroll-tall,
    .frame--landscape-wide,
    .frame--square-small,
    .frame--scroll-narrow {
        grid-column: 1 / -1;
        grid-row: auto;
        margin-top: 0;
    }

    .opening__hint {
        bottom: 2vh;
    }

    .watermark {
        opacity: 0.1;
    }
}

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

    .opening__circle {
        opacity: 1;
    }

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