/* chikayami.com — 近闇 — a digital tea-ceremony at dusk inside a sealed glass cabinet of memory */

:root {
    --aged-cream: #f3ecdb;
    --honey-sepia: #c8a572;
    --ember-umber: #7a4f2b;
    --tea-stain: #9c6f3a;
    --dusk-vellum: #e3d6b8;
    --smoked-olive: #5c5240;
    --candle-halo: #f6d99a;
    --taper-soot: #2c241a;
    --highlight-cream: #fdf3d8;
    --inflate-mid: #e3c89a;
    --flame-intensity: 1;
}

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

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

body {
    background: var(--aged-cream);
    color: var(--ember-umber);
    font-family: "JetBrains Mono", monospace;
    font-weight: 300;
    font-size: 0.95rem;
    line-height: 1.85;
    letter-spacing: 0.005em;
    overflow-x: hidden;
    cursor: crosshair;
}

em, .emph { font-weight: 500; font-style: normal; color: var(--tea-stain); }

/* ---------- Overlays: grain + vignette ---------- */
.grain-defs { position: absolute; width: 0; height: 0; }

.grain-overlay {
    position: fixed; inset: 0;
    pointer-events: none;
    z-index: 9000;
    opacity: 0.04;
    filter: url(#filmGrain);
    mix-blend-mode: multiply;
}

.vignette-overlay {
    position: fixed; inset: 0;
    pointer-events: none;
    z-index: 8999;
    background: radial-gradient(ellipse at center, rgba(44,36,26,0) 35%, rgba(44,36,26,0.08) 100%);
}

/* ---------- Cursor trail ---------- */
#cursorTrailLayer {
    position: fixed; inset: 0;
    pointer-events: none;
    z-index: 9100;
}
.trail-dot {
    position: fixed;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--tea-stain);
    opacity: 0.24;
    mix-blend-mode: multiply;
    transform: translate(-50%, -50%);
    transition: opacity 4s linear;
    pointer-events: none;
}

/* ---------- Persistent candle ---------- */
.candle {
    position: fixed;
    bottom: 5vh; right: 5vw;
    width: 38px;
    z-index: 9050;
    pointer-events: none;
}
.candle-svg { width: 100%; height: auto; display: block; overflow: visible; }
.candle-halo {
    position: absolute;
    left: 50%; top: 4px;
    width: calc(160px * var(--flame-intensity));
    height: calc(160px * var(--flame-intensity));
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(246,217,154,0.26) 0%, rgba(246,217,154,0) 70%);
    transition: width 0.6s ease, height 0.6s ease;
}
#flameOuter, #flameInnerPath, #readFlameOuter, #readFlameInner {
    transform-origin: 50% 90%;
    animation: flicker calc(2.4s / var(--flame-intensity)) cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
#flameInnerPath, #readFlameInner { animation-delay: -0.6s; }
@keyframes flicker {
    0%   { transform: scale(1, 1) translateX(0); }
    18%  { transform: scale(0.94, 1.08) translateX(-0.6px); }
    37%  { transform: scale(1.05, 0.96) translateX(0.5px); }
    55%  { transform: scale(0.97, 1.05) translateX(-0.3px); }
    74%  { transform: scale(1.03, 0.98) translateX(0.4px); }
    100% { transform: scale(1, 1) translateX(0); }
}

/* ---------- Chambers / tatami rhythm ---------- */
.chamber {
    position: relative;
    width: 100%;
    padding: 8vh clamp(1.5rem, 6vw, 7rem);
    scroll-snap-align: start;
    overflow: hidden;
}
#chambers { scroll-snap-type: y proximity; }

/* ratio 1 : 1.618 : 1 : 0.5 : 1.618 : 1 -> heights */
.chamber-one   { min-height: 86vh; }
.chamber-two   { min-height: 139vh; }
.chamber-three { min-height: 86vh; }
.chamber-four  { min-height: 70vh; }
.chamber-five  { min-height: 139vh; }
.chamber-six   { min-height: 140vh; }

.chamber-title {
    font-family: "Space Mono", monospace;
    font-weight: 400;
    font-size: clamp(2.4rem, 5.6vw, 5.2rem);
    letter-spacing: -0.02em;
    color: var(--smoked-olive);
    line-height: 1.05;
    margin-bottom: 5vh;
}

/* ---------- Inflated-3D glyph objects ---------- */
.inflated { overflow: visible; }
[data-rotor] { transform: rotate3d(0,1,0, var(--r)); transition: transform 0.1s linear; }

/* ---------- Chamber One — The Vestibule ---------- */
.chamber-one { display: flex; flex-direction: column; justify-content: center; }
.vestibule-grid {
    display: grid;
    grid-template-columns: 7fr 5fr;
    gap: 2rem;
    width: 100%;
    min-height: 70vh;
    position: relative;
}
.vestibule-glyph {
    grid-column: 1;
    display: flex; align-items: flex-end; justify-content: flex-start;
    padding-bottom: 4vh; padding-left: 3vw;
}
.vestibule-glyph .inflated { width: clamp(220px, 34vw, 460px); height: auto; }
.vestibule-word {
    grid-column: 2;
    align-self: start;
    margin-top: 14vh;
    max-width: 34ch;
}
.kicker {
    font-family: "Space Mono", monospace;
    font-size: 0.8rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--tea-stain);
    margin-bottom: 1.2rem;
}
.wordmark {
    font-family: "Space Mono", monospace;
    font-weight: 400;
    font-size: clamp(1.6rem, 3.4vw, 2.8rem);
    letter-spacing: -0.02em;
    color: var(--smoked-olive);
    margin-bottom: 2rem;
}
.poem p {
    font-family: "Cormorant Garamond", serif;
    font-style: italic;
    font-weight: 300;
    font-size: 1.4rem;
    line-height: 1.6;
    color: var(--ember-umber);
}
.scroll-hint {
    position: absolute;
    bottom: 4vh; left: 50%;
    transform: translateX(-50%);
    font-family: "Space Mono", monospace;
    font-size: 0.75rem;
    letter-spacing: 0.2em;
    color: var(--tea-stain);
    opacity: 0.7;
    animation: breathe 5s ease-in-out infinite;
}
@keyframes breathe { 0%,100%{opacity:0.35;} 50%{opacity:0.8;} }

/* ---------- Glassmorphic cards ---------- */
.glass-card {
    backdrop-filter: blur(18px) saturate(1.4);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    background: rgba(243, 236, 219, 0.42);
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.35);
    box-shadow:
        inset 1px 1px 0 rgba(255,255,255,0.35),
        inset -1px -1px 0 rgba(124,79,43,0.18),
        0 18px 40px rgba(124,79,43,0.12);
    padding: 1.6rem 1.8rem;
    transform: rotate(var(--tilt));
    transition: transform 0.6s ease-out, backdrop-filter 0.6s ease-out;
    color: var(--ember-umber);
}
.glass-card:hover {
    transform: rotate(var(--tilt)) translateY(-6px);
    backdrop-filter: blur(14px) saturate(1.4);
    -webkit-backdrop-filter: blur(14px) saturate(1.4);
}
.glass-card .pull, .pull {
    font-family: "Cormorant Garamond", serif;
    font-style: italic;
    font-size: 1.4rem;
    line-height: 1.5;
    color: var(--tea-stain);
}
.card-photo {
    height: 130px;
    border-radius: 8px;
    margin-bottom: 0.8rem;
    background:
        radial-gradient(ellipse at 30% 25%, rgba(253,243,216,0.8), transparent 60%),
        linear-gradient(135deg, var(--inflate-mid), var(--ember-umber));
    opacity: 0.7;
    filter: sepia(0.3) contrast(0.95);
}
.photo-caption {
    font-family: "Space Mono", monospace;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    color: var(--tea-stain);
    opacity: 0.8;
}

/* ---------- Chamber Two — The Glass Cabinet ---------- */
.cabinet {
    position: relative;
    width: 100%;
    min-height: 105vh;
}
/* kare-sansui five-point asymmetric placement */
.card-a { position: absolute; width: 280px; height: 340px; left: 6%;  top: 4vh;  z-index: 4; }
.card-b { position: absolute; width: 220px; height: 240px; left: 38%; top: 30vh; z-index: 6; backdrop-filter: blur(20px) saturate(1.5); }
.card-c { position: absolute; width: 380px; height: 240px; right: 4%; top: 8vh;  z-index: 5; }
.card-d { position: absolute; width: 300px; height: 300px; left: 22%; top: 56vh; z-index: 3; }
.card-e { position: absolute; width: 240px; height: 360px; right: 12%; top: 50vh; z-index: 2; filter: saturate(0.85) sepia(0.15); }
.card-b .inflated.mini { width: 130px; height: 130px; display: block; margin: 0 auto; }
.glass-card.card-b, .glass-card.card-c, .glass-card.card-e { display: flex; align-items: center; }

/* ---------- Chamber Three — The Candle Reading Room ---------- */
.chamber-three { position: relative; }
.reading-flame {
    position: absolute;
    top: 6vh; right: 8vw;
    width: 40px; height: auto;
    overflow: visible;
}
.reading-column {
    padding-left: 22%;
    max-width: 48ch;
}
.reading-column p { margin-bottom: 2.2rem; }

/* ---------- Chamber Four — The Inflated Index ---------- */
.chamber-four { display: flex; flex-direction: column; }
.constellation {
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 50vh;
}
.iglyph {
    position: absolute;
    display: flex; align-items: center; justify-content: center;
    font-family: "Space Mono", monospace;
    font-weight: 400;
    color: var(--highlight-cream);
    border-radius: 28%;
    background: radial-gradient(circle at 32% 30%, var(--inflate-mid) 0%, var(--ember-umber) 100%);
    border: 1.4px solid rgba(200,165,114,0.8);
    box-shadow: 0 14px 32px rgba(124,79,43,0.18), inset 14px -10px 24px rgba(253,243,216,0.35);
    text-shadow: 0 2px 6px rgba(44,36,26,0.3);
    transition: transform 0.1s linear;
}
/* small drift upper-left, large anchor lower-right */
.g1 { width: 60px;  height: 60px;  font-size: 1.4rem; left: 8%;  top: 4%;  }
.g2 { width: 72px;  height: 72px;  font-size: 1.7rem; left: 22%; top: 14%; }
.g3 { width: 64px;  height: 64px;  font-size: 1.5rem; left: 14%; top: 32%; }
.g4 { width: 90px;  height: 90px;  font-size: 2rem;   left: 36%; top: 6%;  }
.g5 { width: 130px; height: 130px; font-size: 3rem;   left: 48%; top: 30%; }
.g6 { width: 160px; height: 160px; font-size: 3.6rem; left: 64%; top: 14%; }
.g7 { width: 200px; height: 200px; font-size: 4.6rem; right: 6%; bottom: 2%; }
.g8 { width: 110px; height: 110px; font-size: 2.6rem; left: 42%; bottom: 4%; }

/* ---------- Chamber Five — The Confession Pane ---------- */
.chamber-five { display: flex; flex-direction: column; }
.confession-panel {
    position: relative;
    width: 72%;
    min-height: 96vh;
    margin: 0 auto;
    backdrop-filter: blur(18px) saturate(1.4);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    background: rgba(243, 236, 219, 0.42);
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.35);
    box-shadow:
        inset 1px 1px 0 rgba(255,255,255,0.35),
        inset -2px -2px 0 rgba(124,79,43,0.18),
        0 26px 60px rgba(124,79,43,0.14);
    display: flex;
    align-items: flex-end;
}
.confession-content {
    width: 40%;
    min-width: 320px;
    padding: 2.4rem 2.6rem;
}
.confession-content p { margin-bottom: 1.6rem; }
.confession-form { display: flex; flex-direction: column; gap: 0.9rem; margin-top: 1.4rem; }
.confession-form label {
    font-family: "Space Mono", monospace;
    font-size: 0.7rem; letter-spacing: 0.18em; text-transform: uppercase;
    color: var(--tea-stain);
}
.confession-form input {
    font-family: "JetBrains Mono", monospace;
    font-weight: 300;
    font-size: 0.95rem;
    padding: 0.7rem 0.9rem;
    border: 1px solid rgba(124,79,43,0.3);
    background: rgba(253,243,216,0.5);
    color: var(--ember-umber);
    border-radius: 8px;
    outline: none;
}
.confession-form input::placeholder { color: rgba(122,79,43,0.45); }
.confession-form button {
    font-family: "Space Mono", monospace;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    padding: 0.7rem 1rem;
    background: var(--ember-umber);
    color: var(--aged-cream);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.6s ease-out, transform 0.6s ease-out;
}
.confession-form button:hover { background: var(--tea-stain); transform: translateY(-2px); }
.confession-ack {
    margin-top: 1.2rem;
    font-family: "Cormorant Garamond", serif;
    font-style: italic;
    font-size: 1.2rem;
    color: var(--tea-stain);
}

/* shake-error tremor */
@keyframes tremor {
    0%,100% { transform: translateX(0); }
    16% { transform: translateX(4px); }
    33% { transform: translateX(-4px); }
    50% { transform: translateX(4px); }
    66% { transform: translateX(-4px); }
    83% { transform: translateX(4px); }
}
.tremor { animation: tremor 0.4s ease-in-out; }

/* ---------- Chamber Six — The Long Goodbye ---------- */
.chamber-six { position: relative; }
.goodbye-image {
    position: absolute;
    left: 0; bottom: 0;
    width: 66%;
    height: 92vh;
    background:
        radial-gradient(ellipse at 28% 70%, rgba(246,217,154,0.5), transparent 55%),
        linear-gradient(160deg, var(--dusk-vellum), var(--ember-umber));
    opacity: 0.4;
    filter: sepia(0.4) blur(1px);
    border-top-right-radius: 30px;
}
.goodbye-title { position: relative; z-index: 2; }
.vertical-poem {
    position: absolute;
    right: 0; top: 0;
    width: 33%;
    min-width: 240px;
    padding: 14vh 2rem;
    z-index: 3;
}
.vertical-poem .vline {
    font-family: "Space Mono", monospace;
    font-size: 1.05rem;
    line-height: 2.4;
    color: var(--smoked-olive);
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 1.6s ease, transform 1.6s ease;
}
.vertical-poem .vline.revealed { opacity: 1; transform: translateY(0); }

/* ---------- Responsive softening ---------- */
@media (max-width: 820px) {
    .vestibule-grid { grid-template-columns: 1fr; }
    .vestibule-glyph { grid-column: 1; justify-content: center; padding-left: 0; }
    .vestibule-word { grid-column: 1; margin-top: 4vh; }
    .reading-column { padding-left: 6%; }
    .cabinet { min-height: auto; }
    .card-a,.card-b,.card-c,.card-d,.card-e {
        position: relative; width: 100% !important; height: auto !important;
        left: auto !important; right: auto !important; top: auto !important;
        margin-bottom: 1.6rem;
    }
    .confession-panel { width: 100%; }
    .confession-content { width: 100%; min-width: 0; }
    .goodbye-image { width: 100%; }
    .vertical-poem { position: relative; width: 100%; }
    .chamber-two, .chamber-five, .chamber-six { min-height: auto; }
}
