/* ============================================
   archaic.works — styles.css
   Wabi-sabi contemplative scroll
   ============================================ */

/* ---------- CSS Custom Properties ---------- */
:root {
    --bg-primary: #f2ece0;
    --bg-alternate: #e8dfd1;
    --text-primary: #3d3530;
    --text-secondary: #8a7e72;
    --accent-warm: #c4943a;
    --accent-cool: #8a9a82;
    --accent-depth: #5c4a3a;
    --highlight: #faf6ee;

    --font-display: 'Cormorant Garamond', 'Georgia', serif;
    --font-body: 'DM Sans', 'Helvetica Neue', sans-serif;
    --font-accent: 'Noto Serif JP', serif;
}

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

/* ---------- Body & Base ---------- */
html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-weight: 300;
    overflow-x: hidden;
    position: relative;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---------- Grain Overlay (::after) ---------- */
body::after {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.025;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='0.65' numOctaves='3' type='fractalNoise' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 200px 200px;
    animation: grain-shift 0.5s steps(4) infinite;
}

@keyframes grain-shift {
    0% { transform: translate(0, 0); }
    25% { transform: translate(-1px, 1px); }
    50% { transform: translate(1px, -1px); }
    75% { transform: translate(-1px, -2px); }
    100% { transform: translate(2px, 1px); }
}

/* ---------- Vignette ---------- */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
    background: radial-gradient(ellipse at center, transparent 50%, rgba(93, 74, 58, 0.04) 100%);
}

/* ---------- SVG Filters (hidden) ---------- */
.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* ---------- Crack Lines ---------- */
.crack-lines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* ---------- Navigation Identity ---------- */
.nav-identity {
    position: fixed;
    top: 3vh;
    left: 4vw;
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 0.85rem;
    letter-spacing: 0.02em;
    color: var(--text-primary);
    opacity: 0.3;
    z-index: 100;
    pointer-events: none;
    transition: opacity 1.5s ease-in-out;
}

/* ---------- Scroll Progress ---------- */
.scroll-progress {
    position: fixed;
    right: 3vw;
    top: 0;
    width: 3px;
    height: 100vh;
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.6s ease-in-out;
}

.scroll-progress.visible {
    opacity: 0.15;
}

.scroll-progress-dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background-color: var(--text-secondary);
    position: absolute;
    top: 0;
    transition: top 0.3s ease-out;
}

/* ---------- Bubbles ---------- */
.bubbles-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
    overflow: hidden;
}

.bubble {
    position: absolute;
    border-radius: 50%;
    border: 1px solid var(--accent-warm);
    background: transparent;
    opacity: 0;
    transition: transform 0.8s ease-out;
}

.bubble.visible {
    opacity: 1;
}

.bubble-1 {
    width: 120px;
    height: 120px;
    top: 15%;
    left: 80%;
    opacity: 0.06;
    animation: drift-1 45s ease-in-out infinite alternate;
}

.bubble-2 {
    width: 60px;
    height: 60px;
    top: 35%;
    left: 10%;
    opacity: 0.04;
    animation: drift-2 38s ease-in-out infinite alternate;
}

.bubble-3 {
    width: 180px;
    height: 180px;
    top: 60%;
    left: 55%;
    opacity: 0.05;
    animation: drift-3 55s ease-in-out infinite alternate;
}

.bubble-4 {
    width: 40px;
    height: 40px;
    top: 80%;
    left: 25%;
    opacity: 0.08;
    animation: drift-4 32s ease-in-out infinite alternate;
}

.bubble-5 {
    width: 90px;
    height: 90px;
    top: 10%;
    left: 40%;
    opacity: 0.05;
    animation: drift-5 50s ease-in-out infinite alternate;
}

.bubble-6 {
    width: 25px;
    height: 25px;
    top: 50%;
    left: 70%;
    opacity: 0.07;
    animation: drift-6 42s ease-in-out infinite alternate;
}

.bubble-7 {
    width: 140px;
    height: 140px;
    top: 75%;
    left: 85%;
    opacity: 0.04;
    animation: drift-7 60s ease-in-out infinite alternate;
}

.bubble-8 {
    width: 50px;
    height: 50px;
    top: 25%;
    left: 60%;
    opacity: 0.06;
    animation: drift-8 35s ease-in-out infinite alternate;
}

@keyframes drift-1 {
    0% { transform: translate(0, 0); }
    100% { transform: translate(-30px, 20px); }
}

@keyframes drift-2 {
    0% { transform: translate(0, 0); }
    100% { transform: translate(25px, -15px); }
}

@keyframes drift-3 {
    0% { transform: translate(0, 0); }
    100% { transform: translate(-20px, -30px); }
}

@keyframes drift-4 {
    0% { transform: translate(0, 0); }
    100% { transform: translate(15px, 25px); }
}

@keyframes drift-5 {
    0% { transform: translate(0, 0); }
    100% { transform: translate(-25px, 15px); }
}

@keyframes drift-6 {
    0% { transform: translate(0, 0); }
    100% { transform: translate(20px, -20px); }
}

@keyframes drift-7 {
    0% { transform: translate(0, 0); }
    100% { transform: translate(-15px, -25px); }
}

@keyframes drift-8 {
    0% { transform: translate(0, 0); }
    100% { transform: translate(18px, 12px); }
}

/* ---------- Ink Wash Marks ---------- */
.ink-wash {
    position: absolute;
    height: 2px;
    width: 30vw;
    background-color: var(--text-primary);
    opacity: 0.06;
    filter: blur(8px);
    pointer-events: none;
    z-index: 3;
}

.ink-wash-1 {
    top: 220vh;
    left: 10vw;
}

.ink-wash-2 {
    top: 480vh;
    left: 35vw;
}

.ink-wash-3 {
    top: 720vh;
    left: 15vw;
}

/* ---------- Rooms (General) ---------- */
.room {
    min-height: 100vh;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 8vw;
    z-index: 5;
}

/* ---------- Breathing Spaces ---------- */
.breathing-space {
    height: 50vh;
    position: relative;
}

.breathing-space-1 { height: 45vh; }
.breathing-space-2 { height: 55vh; }
.breathing-space-3 { height: 50vh; }
.breathing-space-4 { height: 60vh; }
.breathing-space-5 { height: 45vh; }
.breathing-space-6 { height: 40vh; }

/* ---------- Reveal Animation ---------- */
.reveal-element {
    opacity: 0;
    transition: opacity 1.5s ease-in-out;
}

.reveal-element.revealed {
    opacity: 1;
}

/* ---------- Room 0: Opening ---------- */
.room-opening {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    padding-left: 20%;
    padding-top: 10vh;
    position: relative;
}

.opening-title {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(3rem, 8vw, 8rem);
    color: var(--text-primary);
    letter-spacing: -0.03em;
    line-height: 0.92;
    opacity: 0.85;
}

.letter {
    display: inline-block;
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
}

.letter.visible {
    opacity: 1;
}

.opening-subtitle {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(0.95rem, 1.1vw, 1.15rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    color: var(--text-secondary);
    margin-top: 3vh;
    max-width: 40%;
    opacity: 0;
    transition: opacity 1.5s ease-in-out;
}

.opening-subtitle.visible {
    opacity: 1;
}

/* Kanji decorative element */
.kanji-wabi {
    position: absolute;
    right: 15%;
    top: 20%;
    font-family: var(--font-accent);
    font-weight: 200;
    font-size: clamp(3rem, 15vw, 15rem);
    color: var(--text-primary);
    opacity: 0;
    transition: opacity 2s ease-in-out;
    animation: kanji-rotate 120s linear infinite;
    pointer-events: none;
    user-select: none;
}

.kanji-wabi.visible {
    opacity: 0.06;
}

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

/* ---------- Room 1: "archaic" ---------- */
.room-archaic {
    align-items: flex-start;
    padding-left: 15%;
    padding-top: 5vh;
}

.room-word {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(4rem, 12vw, 10rem);
    color: var(--accent-depth);
    letter-spacing: -0.03em;
    line-height: 0.92;
}

.room-etymology {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 0.85rem;
    color: var(--text-secondary);
    opacity: 0;
    margin-top: 2vh;
    letter-spacing: 0.01em;
    line-height: 1.75;
}

.room-etymology.revealed {
    opacity: 0.5;
}

/* ---------- Room 2: Texture ---------- */
.room-texture {
    align-items: center;
    justify-content: center;
}

.texture-field {
    width: 60vw;
    height: 40vh;
    background-color: var(--bg-alternate);
    position: relative;
    border-radius: 2px;
}

.texture-field::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='0.65' numOctaves='3' type='fractalNoise' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 200px 200px;
    opacity: 0.12;
    animation: grain-shift 0.5s steps(4) infinite;
}

.texture-field::before {
    content: '';
    position: absolute;
    top: 30%;
    left: 10%;
    width: 60%;
    height: 1px;
    background-color: var(--text-secondary);
    opacity: 0.08;
    filter: blur(1px);
}

/* ---------- Room 3: "what endures" ---------- */
.room-endures {
    align-items: flex-start;
    padding-left: 20%;
    position: relative;
}

.room-endures .ink-wash-mark {
    position: absolute;
    left: 8vw;
    top: 48%;
    width: 10vw;
    height: 2px;
    background-color: var(--text-primary);
    opacity: 0.06;
    filter: blur(6px);
}

.room-phrase {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(3rem, 6vw, 6rem);
    color: var(--text-primary);
    letter-spacing: -0.03em;
    line-height: 0.92;
    margin-left: 35%;
}

.room-body {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(0.95rem, 1.1vw, 1.15rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    color: var(--text-secondary);
    max-width: 36%;
    margin-top: 4vh;
    margin-left: 35%;
}

/* ---------- Room 4: Ens&#333; Circle ---------- */
.room-circle {
    align-items: center;
    justify-content: center;
}

.enso-circle {
    width: 40vw;
    height: 40vw;
    max-width: 500px;
    max-height: 500px;
}

.enso-path {
    stroke-dasharray: 1131;
    stroke-dashoffset: 1131;
    transition: stroke-dashoffset 3s ease-in-out;
}

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

/* ---------- Room 5: "works" ---------- */
.room-works {
    align-items: flex-end;
    padding-right: 15%;
}

.room-word-works {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(4rem, 10vw, 10rem);
    color: var(--accent-depth);
    letter-spacing: -0.03em;
    line-height: 0.92;
    text-align: right;
}

.room-body-works {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(0.95rem, 1.1vw, 1.15rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    color: var(--text-secondary);
    max-width: 36%;
    margin-top: 4vh;
    text-align: right;
}

/* ---------- Room 6: Closing ---------- */
.room-closing {
    min-height: 80vh;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 8vh;
}

.closing-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1vh;
}

.closing-domain {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 0.9rem;
    color: var(--text-primary);
    opacity: 0;
    letter-spacing: 0.02em;
}

.closing-domain.revealed {
    opacity: 0.25;
}

.closing-year {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 0.8rem;
    color: var(--text-secondary);
    opacity: 0;
}

.closing-year.revealed {
    opacity: 0.25;
}

/* ---------- Background color shift ---------- */
body {
    transition: background-color 2s ease-in-out;
}

body.bg-alternate {
    background-color: var(--bg-alternate);
}

/* ---------- Mobile Responsive ---------- */
@media (max-width: 768px) {
    .room {
        padding: 6vw;
    }

    .room-opening {
        padding-left: 8vw;
    }

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

    .opening-subtitle {
        max-width: 85vw;
    }

    .room-archaic {
        padding-left: 8vw;
    }

    .room-word {
        font-size: clamp(3rem, 14vw, 6rem);
    }

    .texture-field {
        width: 85vw;
        height: 30vh;
    }

    .room-endures {
        padding-left: 8vw;
    }

    .room-phrase {
        font-size: clamp(2.5rem, 8vw, 4rem);
        margin-left: 0;
    }

    .room-body {
        max-width: 85vw;
        margin-left: 0;
    }

    .enso-circle {
        width: 70vw;
        height: 70vw;
    }

    .room-works {
        padding-right: 8vw;
        align-items: flex-start;
    }

    .room-word-works {
        font-size: clamp(3rem, 12vw, 6rem);
        text-align: left;
    }

    .room-body-works {
        max-width: 85vw;
        text-align: left;
    }

    .kanji-wabi {
        right: 5%;
        top: 10%;
        font-size: clamp(3rem, 20vw, 10rem);
    }

    .breathing-space-1 { height: 30vh; }
    .breathing-space-2 { height: 35vh; }
    .breathing-space-3 { height: 30vh; }
    .breathing-space-4 { height: 40vh; }
    .breathing-space-5 { height: 30vh; }
    .breathing-space-6 { height: 25vh; }

    .bubble-1 { width: 80px; height: 80px; }
    .bubble-3 { width: 120px; height: 120px; }
    .bubble-5 { width: 60px; height: 60px; }
    .bubble-7 { width: 90px; height: 90px; }

    .room-endures .ink-wash-mark {
        display: none;
    }
}
