/* ============================================================
   kaguya.bid -- the moon princess's farewell auction
   terracotta-warm dusk :: cinematic zoom-focus :: hand-only type
   ============================================================ */

:root {
    --volcanic: #3a1f15;   /* Volcanic Earth -- deepest shadow / letterbox bars */
    --terracotta: #c2543a; /* Kiln Terracotta -- dominant brand */
    --sunset-clay: #e8916b;/* Sunset Clay -- underlines, 2nd-tier strokes */
    --apricot: #f1d2a8;    /* Pressed Apricot -- paper background */
    --rice-husk: #f7e6cd;  /* Rice Husk Highlight -- raised cards */
    --walnut: #5b3a2a;     /* Tea-Stained Walnut -- body text */
    --aged-bamboo: #9e7a5a;/* Aged Bamboo -- hairlines, leaders, borders */
    --deep-ink: #1a0f0a;   /* deepest ink -- kanji extra weight */

    --col-width: min(880px, 92vw);
}

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

html { scroll-behavior: smooth; }

body {
    background: var(--apricot);
    color: var(--walnut);
    font-family: "Shadows Into Light Two", cursive;
    font-size: 18px;
    line-height: 1.6;
    overflow-x: hidden;
    position: relative;
}

/* ---- paper grain overlay ---- */
.paper-grain {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    opacity: 0.5;
    background-image:
        linear-gradient(125deg, rgba(58,31,21,0.04) 0%, transparent 40%, rgba(58,31,21,0.03) 100%),
        repeating-linear-gradient(0deg, rgba(94,58,42,0.025) 0px, rgba(94,58,42,0.025) 1px, transparent 1px, transparent 3px);
    mix-blend-mode: multiply;
}

/* ============================================================
   drifting moon-petals  (90s loop, opacity 0.18)
   ============================================================ */
.petal-field { position: fixed; inset: 0; pointer-events: none; z-index: 2; }
.petal {
    position: absolute;
    width: 22px; height: 22px;
    fill: var(--sunset-clay);
    opacity: 0.18;
    will-change: transform;
}
.petal-1 { top: -4%; left: 8%;  animation: drift 92s linear infinite; }
.petal-2 { top: -4%; left: 34%; animation: drift 104s linear infinite 12s; }
.petal-3 { top: -4%; left: 58%; animation: drift 88s linear infinite 30s; }
.petal-4 { top: -4%; left: 76%; animation: drift 110s linear infinite 48s; }
.petal-5 { top: -4%; left: 92%; animation: drift 96s linear infinite 64s; }

@keyframes drift {
    0%   { transform: translate(0, -10vh) rotate(0deg); }
    50%  { transform: translate(-8vw, 55vh) rotate(220deg); }
    100% { transform: translate(4vw, 115vh) rotate(420deg); }
}

/* ============================================================
   solder-fireflies -- global slow drift, mostly hidden,
   brighten only while the grove / firefly frames are active
   ============================================================ */
.firefly-field {
    position: fixed; inset: 0; pointer-events: none; z-index: 2;
    opacity: 0; transition: opacity 1.2s ease;
}
.firefly-field.lit { opacity: 1; }
.firefly {
    position: absolute;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--sunset-clay);
    box-shadow: 0 0 8px 2px rgba(232,145,107,0.7), 0 0 0 1px rgba(194,84,58,0.4);
    will-change: transform, opacity;
}
.f1 { top: 60%; left: 30%; animation: flit 14s ease-in-out infinite; }
.f2 { top: 45%; left: 62%; animation: flit 18s ease-in-out infinite 3s; }
.f3 { top: 70%; left: 50%; animation: flit 12s ease-in-out infinite 6s; }
.f4 { top: 35%; left: 40%; animation: flit 20s ease-in-out infinite 2s; }
.f5 { top: 55%; left: 70%; animation: flit 16s ease-in-out infinite 9s; }
.f6 { top: 65%; left: 22%; animation: flit 22s ease-in-out infinite 5s; }

@keyframes flit {
    0%, 100% { transform: translate(0,0); opacity: 0.25; }
    25% { transform: translate(40px, -30px); opacity: 0.9; }
    50% { transform: translate(-20px, -60px); opacity: 0.5; }
    75% { transform: translate(30px, -20px); opacity: 0.85; }
}

/* ============================================================
   fixed bamboo-spine -- the camera dolly track
   1px terracotta, dead center, with 5 chapter nodes
   ============================================================ */
.bamboo-spine {
    position: fixed;
    left: 50%; top: 0; bottom: 0;
    width: 14px;
    transform: translateX(-50%);
    z-index: 3;
    pointer-events: none;
}
.spine-svg {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
}
.spine-svg .seg { fill: none; stroke-linecap: round; }
.spine-svg .organic { stroke: var(--aged-bamboo); stroke-width: 1.4; }
.spine-svg .trace { stroke: var(--terracotta); stroke-width: 1.2; opacity: 0.7; }

.node {
    position: absolute;
    left: 50%;
    width: 9px; height: 9px;
    border-radius: 50%;
    background: var(--aged-bamboo);
    transform: translateX(-50%);
    transition: background 0.7s ease, box-shadow 0.7s ease, transform 0.7s ease;
}
.node-1 { top: 12%; }
.node-2 { top: 30%; }
.node-3 { top: 48%; }
.node-4 { top: 66%; }
.node-5 { top: 86%; }
.node.active {
    background: var(--terracotta);
    box-shadow: 0 0 0 3px rgba(194,84,58,0.18), 0 0 16px 4px rgba(194,84,58,0.45);
    transform: translateX(-50%) scale(1.25);
}

/* ============================================================
   vertical chapter index -- right edge
   ============================================================ */
.chapter-index {
    position: fixed;
    right: clamp(10px, 2vw, 36px);
    top: 50%;
    transform: translateY(-50%);
    z-index: 4;
    pointer-events: auto;
}
.chapter-index ol { list-style: none; }
.chapter-index li {
    font-family: "Caveat", cursive;
    font-size: clamp(0.7rem, 1.4vw, 0.95rem);
    color: var(--aged-bamboo);
    text-align: right;
    margin: 0.32em 0;
    cursor: pointer;
    transition: color 0.4s ease, opacity 0.4s ease;
    opacity: 0.7;
    max-width: 24vw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chapter-index li span {
    display: inline-block;
    min-width: 1.6em;
    color: var(--terracotta);
    margin-right: 0.3em;
    text-transform: lowercase;
}
.chapter-index li:hover { color: var(--walnut); opacity: 1; }
.chapter-index li.current { color: var(--terracotta); opacity: 1; }
.chapter-index li.struck {
    text-decoration: line-through;
    text-decoration-color: var(--sunset-clay);
    opacity: 0.4;
}
@media (max-width: 720px) {
    .chapter-index { display: none; }
}

/* ============================================================
   main column -- the film, surrounded by gallery-wall margin
   ============================================================ */
main {
    max-width: var(--col-width);
    margin-inline: auto;
    position: relative;
    z-index: 5;
}

/* ---- a frame: one full-viewport film still ---- */
.frame {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding-block: 12vh;
    position: relative;
    /* letterbox hairlines */
    border-top: 1px solid rgba(194,84,58,0.45);
    border-bottom: 1px solid rgba(194,84,58,0.45);
}

/* the inner element that receives zoom-focus depth-of-field */
.frame-inner {
    width: 100%;
    max-width: min(820px, 88vw);
    padding: clamp(2rem, 5vw, 4rem) clamp(1.4rem, 4vw, 3.4rem);
    position: relative;
    text-align: center;
    /* start de-focused */
    transform: scale(0.94);
    filter: blur(6px);
    opacity: 0.32;
    transition:
        transform 1.4s cubic-bezier(0.22, 1, 0.36, 1),
        filter 0.9s ease-out,
        opacity 0.9s ease;
}
.frame.in-focus .frame-inner {
    transform: scale(1);
    filter: blur(0);
    opacity: 1;
}
/* a previously-passed frame retreats further & re-blurs */
.frame.passed .frame-inner {
    transform: scale(1.06);
    filter: blur(7px);
    opacity: 0.28;
}

/* ---- hand-drawn washi border with corner tassels ---- */
.frame-border {
    position: absolute;
    inset: clamp(0.6rem, 2vw, 1.6rem);
    border: 1.6px solid var(--terracotta);
    border-radius: 2px;
    pointer-events: none;
    /* wobbling inked edge */
    border-style: solid;
    box-shadow: inset 0 0 0 0.5px rgba(94,58,42,0.25);
    mask-image: repeating-linear-gradient(0deg, #000 0 14px, rgba(0,0,0,0.82) 14px 18px);
    -webkit-mask-image: repeating-linear-gradient(0deg, #000 0 14px, rgba(0,0,0,0.82) 14px 18px);
}
.frame-border::before,
.frame-border::after,
.frame-inner::before,
.frame-inner::after {
    content: "";
    position: absolute;
    width: 11px; height: 11px;
    background: var(--terracotta);
    border-radius: 50% 50% 50% 0;
}
/* tassels at the four corners of the inner padding box */
.frame-inner::before { top: clamp(0.6rem,2vw,1.6rem); left: clamp(0.6rem,2vw,1.6rem); transform: rotate(-45deg) translate(-3px,-3px); }
.frame-inner::after  { top: clamp(0.6rem,2vw,1.6rem); right: clamp(0.6rem,2vw,1.6rem); transform: rotate(45deg) translate(3px,-3px); }
.frame-border::before { bottom: 0; left: 0; transform: rotate(-135deg) translate(3px,-3px); }
.frame-border::after  { bottom: 0; right: 0; transform: rotate(135deg) translate(-3px,-3px); }

/* ============================================================
   typography
   ============================================================ */
.couplet {
    font-family: "Klee One", cursive;
    font-size: 0.98rem;
    color: var(--aged-bamboo);
    margin-bottom: 1.4rem;
    letter-spacing: 0.02em;
}
.couplet .jp {
    color: var(--volcanic);
    font-weight: 600;
    margin-right: 0.6em;
    padding-right: 0.6em;
    border-right: 1px solid var(--aged-bamboo);
}
.couplet .en { font-style: italic; }

.frame-title {
    font-family: "Caveat", cursive;
    font-weight: 700;
    font-size: clamp(2.6rem, 6.4vw, 5.2rem);
    line-height: 1.05;
    letter-spacing: -0.01em;
    color: var(--volcanic);
    margin-bottom: 1.6rem;
}

.frame-body {
    font-family: "Shadows Into Light Two", cursive;
    font-size: 1.12rem;
    line-height: 1.78;
    color: var(--walnut);
    max-width: 38ch;
    margin: 0 auto 1.6rem;
}
.frame-body em {
    font-style: normal;
    color: var(--terracotta);
    border-bottom: 2px solid var(--sunset-clay);
}

/* ink-reveal: the handwriting writes itself L->R when frame focuses */
.ink-reveal {
    clip-path: inset(0 100% 0 0);
    transition: clip-path 2.4s cubic-bezier(0.4, 0, 0.2, 1) 0.3s;
}
.frame.in-focus .ink-reveal { clip-path: inset(0 0 0 0); }

.frame-counter {
    font-family: "Caveat", cursive;
    font-weight: 400;
    font-size: 0.82rem;
    color: var(--terracotta);
    text-transform: lowercase;
    position: absolute;
    bottom: clamp(1rem, 3vh, 1.6rem);
    left: clamp(1.2rem, 4vw, 2.6rem);
    text-align: left;
    opacity: 0.85;
}

/* ============================================================
   suitor list (frame 06)  &  auction lots (frame 09)
   ============================================================ */
.suitor-list {
    list-style: none;
    max-width: 44ch;
    margin: 0 auto;
    text-align: left;
}
.suitor-list li {
    font-family: "Shadows Into Light Two", cursive;
    font-size: 1.04rem;
    color: var(--walnut);
    padding: 0.4em 0;
    border-bottom: 1px dotted var(--aged-bamboo);
    display: flex;
    gap: 0.7em;
    align-items: baseline;
}
.lot-mark {
    font-family: "Homemade Apple", cursive;
    font-size: 1.1rem;
    color: var(--terracotta);
    min-width: 1.4em;
}

/* ---- the auction frame ---- */
.frame-auction { min-height: auto; }
.frame-auction .frame-inner { max-width: min(640px, 92vw); }

.lot-list {
    display: flex;
    flex-direction: column;
    gap: 28px;
    margin-top: 2.4rem;
    text-align: left;
}
.lot {
    position: relative;
    max-width: 480px;
    width: 100%;
    margin: 0 auto;
    background: var(--rice-husk);
    border: 1px solid var(--terracotta);
    border-radius: 2px;
    padding: 1.4rem 1.6rem 1.2rem;
    box-shadow: 0 2px 0 rgba(94,58,42,0.12), inset 0 0 0 0.5px rgba(158,122,90,0.4);
}
.lot-no {
    position: absolute;
    top: 0.6rem; left: 0.9rem;
    font-family: "Homemade Apple", cursive;
    font-size: 1.05rem;
    color: var(--terracotta);
}
.lot-name {
    font-family: "Caveat", cursive;
    font-weight: 700;
    font-size: 1.9rem;
    color: var(--volcanic);
    margin: 1.4rem 0 0.4rem;
    padding-right: 3rem;
    line-height: 1.1;
}
.lot-desc {
    font-family: "Shadows Into Light Two", cursive;
    font-size: 0.98rem;
    line-height: 1.7;
    color: var(--walnut);
}
.lot-bid {
    display: block;
    margin-top: 0.5em;
    font-family: "Homemade Apple", cursive;
    font-size: 1.05rem;
    color: var(--terracotta);
    border-top: 1px dotted var(--aged-bamboo);
    padding-top: 0.4em;
}

/* wax-seal button (jagged clip-path circle) */
.wax-seal {
    position: absolute;
    top: 0.7rem; right: 0.9rem;
    width: 38px; height: 38px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 50%;
    box-shadow: 0 0 0 1.5px var(--terracotta);
    transition: background 0.5s ease, box-shadow 0.4s ease, transform 0.3s ease;
    clip-path: polygon(50% 0%, 62% 8%, 75% 4%, 82% 16%, 95% 18%, 95% 32%, 100% 44%, 92% 54%, 98% 66%, 88% 74%, 90% 88%, 76% 90%, 66% 99%, 52% 92%, 40% 99%, 30% 88%, 16% 88%, 12% 74%, 2% 64%, 8% 52%, 0% 40%, 8% 30%, 5% 16%, 18% 14%, 26% 4%, 38% 8%);
}
.wax-seal::after {
    content: "印";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-family: "Klee One", cursive;
    font-size: 0.8rem;
    color: var(--terracotta);
    transition: color 0.4s ease;
}
.wax-seal:hover { transform: scale(1.08); }
.lot.bidded .wax-seal {
    background: var(--terracotta);
    box-shadow: 0 0 0 2px var(--volcanic), 0 0 14px 3px rgba(194,84,58,0.4);
}
.lot.bidded .wax-seal::after { color: var(--rice-husk); }

.lot-stamp {
    font-family: "Klee One", cursive;
    font-size: 0.92rem;
    color: var(--volcanic);
    margin-top: 0.7em;
    text-align: right;
    opacity: 0;
    transform: translateY(-4px) rotate(-3deg);
    transition: opacity 0.5s ease, transform 0.5s ease;
}
.lot.bidded .lot-stamp { opacity: 1; transform: translateY(0) rotate(-3deg); }

/* ============================================================
   illustrated tableaux & motif stages
   ============================================================ */
.grove-tableau, .procession-tableau {
    width: 100%;
    max-width: 720px;
    margin: 0 auto 2rem;
    border: 1px solid var(--aged-bamboo);
    border-radius: 2px;
    overflow: hidden;
    aspect-ratio: 21 / 9;
    background: var(--apricot);
}
.tableau-svg { width: 100%; height: 100%; display: block; }
/* depth-of-field within the tableau */
.tableau-svg .layer { transition: filter 0.9s ease; }
.tableau-svg .layer.back { filter: blur(2.5px); }
.tableau-svg .layer.mid  { filter: blur(1px); }
.frame.in-focus .tableau-svg .layer.front { filter: blur(0); }
.frame:not(.in-focus) .tableau-svg .layer.front { filter: blur(3px); }

/* glow stalk -- frame 02 */
.glow-stalk {
    position: relative;
    width: 200px; height: 320px;
    margin: 0 auto 2rem;
}
.glow-stalk .stalk-svg { width: 100%; height: 100%; }
.glow-line { filter: drop-shadow(0 0 6px rgba(194,84,58,0.65)); animation: pulse-glow 3.6s ease-in-out infinite; }
@keyframes pulse-glow {
    0%, 100% { opacity: 0.55; }
    50% { opacity: 1; }
}
.moon-glow {
    position: absolute;
    top: -30px; right: -40px;
    width: 160px; height: 160px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--apricot) 0%, rgba(241,210,168,0.3) 45%, transparent 72%);
    pointer-events: none;
}
.moon-glow.big { width: 320px; height: 320px; top: -60px; left: 50%; transform: translateX(-50%); }

/* circuit-cricket stage -- frame 05 */
.cricket-stage {
    width: 320px; height: 220px;
    margin: 0 auto 2rem;
}
.cricket-svg { width: 100%; height: 100%; }

/* grove divider -- frame 04 */
.grove-divider {
    width: 100%; max-width: 460px;
    margin: 0 auto 2.2rem;
}
.grove-divider svg { width: 100%; height: auto; }

/* ---- the coffee-stain moon ---- */
.moon-stage {
    position: relative;
    width: 280px; height: 280px;
    margin: 0 auto 2.4rem;
    display: grid;
    place-items: center;
}
.moon-stage.small { width: 180px; height: 180px; margin-bottom: 3rem; }
.moon-stage .moon-glow {
    position: absolute;
    inset: -40px;
    width: auto; height: auto;
    top: -40px; left: -40px; right: -40px; bottom: -40px;
}
.coffee-moon {
    width: 170px; height: 170px;
    background: var(--rice-husk);
    border-radius: 48% 52% 49% 51% / 50% 47% 53% 50%;
    box-shadow: 0 0 0 1px var(--terracotta), 0 0 80px 20px rgba(241,210,168,0.45);
    filter: url(#noise-displace);
    position: relative;
    z-index: 1;
}
.moon-stage.small .coffee-moon { width: 110px; height: 110px; }
.coffee-moon::after {
    content: "";
    position: absolute;
    top: 24%; left: 30%;
    width: 22%; height: 18%;
    background: rgba(158,122,90,0.22);
    border-radius: 50% 50% 48% 52% / 55% 50% 50% 45%;
}
.coffee-moon.retreating { animation: retreat 8s ease-in-out infinite alternate; }
@keyframes retreat {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(0.86) translateY(-6px); opacity: 0.78; }
}

/* firefly stage -- frame 08 */
.firefly-stage {
    position: relative;
    width: 100%; max-width: 520px;
    height: 200px;
    margin: 0 auto 2rem;
}
.local-firefly {
    position: absolute;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--sunset-clay);
    box-shadow: 0 0 10px 3px rgba(232,145,107,0.75), 0 0 0 1px rgba(194,84,58,0.45);
}
.lf1 { top: 20%; left: 12%; animation: flit 13s ease-in-out infinite; }
.lf2 { top: 60%; left: 28%; animation: flit 17s ease-in-out infinite 2s; }
.lf3 { top: 40%; left: 46%; animation: flit 15s ease-in-out infinite 5s; }
.lf4 { top: 75%; left: 60%; animation: flit 19s ease-in-out infinite 1s; }
.lf5 { top: 30%; left: 72%; animation: flit 14s ease-in-out infinite 7s; }
.lf6 { top: 55%; left: 84%; animation: flit 21s ease-in-out infinite 4s; }
.lf7 { top: 18%; left: 54%; animation: flit 16s ease-in-out infinite 9s; }

/* ---- the final line ---- */
.frame-end .frame-inner { max-width: min(560px, 88vw); }
.end-couplet { margin-bottom: 1rem; }
.end-line {
    font-family: "Caveat", cursive;
    font-weight: 500;
    font-size: clamp(1.4rem, 3vw, 2rem);
    line-height: 1.4;
    color: var(--aged-bamboo);
}

/* ============================================================
   focus rings (visual only, ink-harmonized)
   ============================================================ */
a:focus-visible,
button:focus-visible,
.chapter-index li:focus-visible {
    outline: 2px dashed var(--terracotta);
    outline-offset: 4px;
}

/* ============================================================
   reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .frame-inner {
        transform: none !important;
        filter: none !important;
        transition: opacity 0.4s ease;
        opacity: 0.4;
    }
    .frame.in-focus .frame-inner { opacity: 1; }
    .frame.passed .frame-inner { opacity: 0.4; }
    .ink-reveal { clip-path: inset(0 0 0 0) !important; transition: none; }
    .petal, .firefly, .local-firefly, .glow-line, .coffee-moon.retreating { animation: none !important; }
    .tableau-svg .layer { filter: none !important; }
}
