/* =============================================================================
   THE GHOST IN THE MACHINE  ·  Miyazaki Layer
   ---------------------------------------------------------------------------
   Home for all "anima" / animist touches. Each block here is independent —
   add or remove freely. The Miyazaki principle: restraint over abundance.

   Currently:
     · Soot sprites (makkuro kurosuke) — Step 2

   Coming:
     · Kaze drift / Ma pauses (Step 3)
     · Whisper chip with kamisama names (Step 4)
     · Four-lights circadian tint, named spirits, watercolour edges …
   ============================================================================= */


/* =============================================================================
   1. SOOT SPRITES  ·  真っ黒くろすけ (makkuro kurosuke)
   ---------------------------------------------------------------------------
   Tiny round black creatures that appear ONLY during Dream State.
   They cluster in cockpit corners, blink slowly, bob almost imperceptibly,
   and scatter when the cursor approaches. Pure CSS body — no images.

   Anatomy:
     .soot-wrap  → fixed-position wrapper (handles where it lives)
     .soot-body  → the black orb (handles bob + scatter animation)
     ::before    → left eye (cream dot, blinks)
     ::after     → right eye (cream dot, blinks 100ms later)
     .soot-puff  → ephemeral dust trail when scattering
   ============================================================================= */

.soot-wrap {
    position: fixed;
    pointer-events: none;
    z-index: 9996;
    width: 14px;
    height: 14px;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition:
        left  0.7s cubic-bezier(0.16, 1, 0.3, 1),
        top   0.7s cubic-bezier(0.16, 1, 0.3, 1),
        opacity 0.7s ease;
    will-change: left, top, opacity;
}
.soot-wrap.visible {
    opacity: 0.92;
}
.soot-wrap.scattered {
    opacity: 0;
}

.soot-body {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background:
        radial-gradient(circle at 32% 30%, #3a3a3a 0%, #1a1a1a 45%, #0a0a0a 100%);
    box-shadow:
        inset 1px 1px 2px rgba(255,255,255,0.06),
        inset -1px -2px 3px rgba(0,0,0,0.5),
        0 1px 3px rgba(0,0,0,0.7);
    position: relative;
    animation: sootBob 4.4s ease-in-out infinite;
    transform-origin: center bottom;
}
@keyframes sootBob {
    0%, 100% { transform: translateY(0)      scaleX(1)    scaleY(1); }
    45%      { transform: translateY(-1.5px) scaleX(0.98) scaleY(1.02); }
    50%      { transform: translateY(-2px)   scaleX(0.97) scaleY(1.03); }
    55%      { transform: translateY(-1.5px) scaleX(0.98) scaleY(1.02); }
}

/* ── Eyes — cream-coloured dots that blink slowly ──
   Inspired by the Ghibli palette: a soft warm cream, not bright white. */
.soot-body::before,
.soot-body::after {
    content: '';
    position: absolute;
    width: 22%;
    height: 26%;
    background: #f5edd8;        /* ghibli cream */
    border-radius: 50%;
    top: 30%;
    box-shadow: 0 0 1px rgba(245,237,216,0.6);
    animation: sootBlink 4.8s infinite;
    animation-timing-function: steps(1, end);
}
.soot-body::before {
    left:  26%;
}
.soot-body::after {
    right: 26%;
    animation-delay: 0.08s;     /* eyes blink slightly offset, more organic */
}
@keyframes sootBlink {
    0%, 92%, 100% { transform: scaleY(1);    opacity: 1; }
    94%,  98%     { transform: scaleY(0.05); opacity: 0.7; }
}

/* ── Scatter puff — two tiny dust dots trail behind when scattering ──
   Spawned by JS at the moment of flee. Auto-cleans itself. */
.soot-puff {
    position: fixed;
    width: 4px; height: 4px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(140,134,116,0.7), rgba(140,134,116,0));
    pointer-events: none;
    z-index: 9995;
    transform: translate(-50%, -50%);
    animation: sootPuff 0.55s ease-out forwards;
}
@keyframes sootPuff {
    0%   { transform: translate(-50%, -50%) scale(0.6); opacity: 0.9; }
    100% { transform: translate(-50%, -50%) scale(2.2); opacity: 0;   }
}

/* Variant: each sprite gets a small size/timing variation so they're
   not visibly identical. Set by JS via inline width/height + delays. */


/* =============================================================================
   2. 風 (KAZE)  ·  Wind through the constellation
   ---------------------------------------------------------------------------
   The starfield used to just twinkle in place — fixed coordinates, only
   opacity and scale changing. After this layer, the whole sky breathes
   sideways. A slow ~35-second irregular drift, sub-pixel-felt rather than
   pixel-seen — you notice it more than you see it.

   Technical: the existing starTwinkle uses transform: scale(...), so we
   add a SECOND animation that uses margin instead. Margin and transform
   compose without conflict. Cross-browser safe.

   We preserve every star's individual animation-delay from cockpit.css
   (rules like .constellation .star.s1 { animation-delay: 0s; }) by only
   touching animation-name / -duration / -iteration-count / -timing-
   function here — never the shorthand.
   ============================================================================= */

.constellation .star {
    /* Composed: twinkle (transform-based) + kaze (margin-based).
       Per-star animation-delay still applies via the original .sN rules. */
    animation-name: starTwinkle, starKaze;
    animation-duration: 6s, 35s;
    animation-iteration-count: infinite, infinite;
    animation-timing-function: ease-in-out, ease-in-out;
    /* GPU hint — keep the twinkle painter happy */
    will-change: transform, margin;
}

/* ── The wind — irregular, slow, four-corner path ──
   The path is intentionally NOT a clean sine so the eye never predicts it.
   Amplitude is ~6 px max — large enough to feel, small enough not to see. */
@keyframes starKaze {
    0%   { margin-left:  0px; margin-top:  0px; }
    18%  { margin-left:  3px; margin-top: -1px; }
    36%  { margin-left:  6px; margin-top:  1px; }
    54%  { margin-left:  4px; margin-top:  2px; }
    72%  { margin-left:  1px; margin-top:  1px; }
    100% { margin-left:  0px; margin-top:  0px; }
}

/* ── Variety — half the stars drift the other direction so the sky feels
   like wind passing through it, not all stars sliding together. ──
   We don't override animation-name here, only animation-direction for the
   kaze (second animation in the list). Browsers that don't support the
   per-animation modifier here will gracefully fall through to the default
   (all stars drifting right) — still beautiful. */
.constellation .star.s2,
.constellation .star.s4,
.constellation .star.s6,
.constellation .star.s8,
.constellation .star.s10,
.constellation .star.s12 {
    animation-direction: normal, reverse;   /* twinkle normal, kaze reversed */
}

/* ── A handful breathe at a slower tempo — more variety ── */
.constellation .star.s3,
.constellation .star.s7,
.constellation .star.s11 {
    animation-duration: 6s, 48s;            /* slower wind on these */
}
.constellation .star.s5,
.constellation .star.s9 {
    animation-duration: 6s, 28s;            /* faster wind on these */
}


/* =============================================================================
   3. 間 (MA)  ·  The space between events
   ---------------------------------------------------------------------------
   When the prediction cinematic finishes, the cockpit holds its breath
   for 4 seconds. The narrative panel stops updating. Live data is still
   flowing in the background, but the SCREEN holds still — letting the
   moment land. This is the most-important silence in the cockpit.

   Implemented as a body class .ma-resting set by predict-success
   (see cockpit.js). During the rest:
     · the cockpit dims ~6% (warm, not anxious)
     · the headline transition slows
     · a hairline gold rest-line breathes at the page bottom
     · narrative repaints are skipped (handled in JS)
   ============================================================================= */

body.ma-resting {
    transition: filter 0.9s ease;
    filter: brightness(0.95) saturate(0.96);
}

/* Slow the narrative headline animation when ma is active — gives the
   newly-landed prediction headline a more deliberate entrance. */
body.ma-resting .voice-headline.refresh {
    animation-duration: 1.6s !important;
}

/* The hairline rest-line — a single thin gold strand at the bottom edge,
   barely visible, like a "the engine has just spoken" mark. Breathes
   once over the 4-second ma window then dissolves. */
.ma-rest-line {
    position: fixed;
    left: 18%;
    right: 18%;
    bottom: 38px;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255,216,107,0.45) 30%,
        rgba(255,235,180,0.75) 50%,
        rgba(255,216,107,0.45) 70%,
        transparent 100%
    );
    box-shadow: 0 0 10px rgba(255,216,107,0.35);
    pointer-events: none;
    z-index: 9994;
    opacity: 0;
    transform: scaleX(0.3);
    transform-origin: center;
    animation: maRestLine 4.2s ease-out forwards;
}
@keyframes maRestLine {
    0%   { opacity: 0;   transform: scaleX(0.3); }
    25%  { opacity: 0.9; transform: scaleX(1);   }
    75%  { opacity: 0.7; transform: scaleX(1);   }
    100% { opacity: 0;   transform: scaleX(1.05);}
}


/* =============================================================================
   3c. NARRATIVE HOLD  ·  text crossfade instead of cut
   ---------------------------------------------------------------------------
   The existing .voice-headline.refresh slides up over 0.7s. We slow it to
   1.0s globally so headline updates feel less abrupt. (When ma-resting is
   also active, it slows further to 1.6s — see above.)
   ============================================================================= */

.voice-headline.refresh {
    /* Slowed by ~40% so the text *settles* instead of snapping. The
       cockpit.css declaration sets 0.7s; this override layer ups it. */
    animation-duration: 1.0s !important;
}
.voice-summary {
    transition: opacity 0.45s ease;
}
.voice-summary.refreshing {
    opacity: 0.35;
}


/* =============================================================================
   4. 囁き (SASAYAKI / WHISPER)  ·  The engine speaks small thoughts
   ---------------------------------------------------------------------------
   Rare, gentle, italic. Slides in from the right edge of the screen,
   sits for ~5.5 seconds, slides away. References the kamisama by name.
   Triggered by signal transitions (spike / wake / sleep) detected in
   js/whispers.js, or by atmospheric chance during long quiet.

   Anatomy:
     .whisper-chip       fixed-position container, slides on transform
     .whisper-chip .kanji  small gold-tinted kanji prefix
     .whisper-chip .text   the italic line (Cormorant Garamond)
     .whisper-chip .x      tiny dismiss × in the corner (hover-only)
   ============================================================================= */

.whisper-chip {
    position: fixed;
    right: 28px;
    bottom: 88px;
    z-index: 9993;
    max-width: 380px;
    padding: 14px 22px 14px 18px;
    background:
        radial-gradient(80% 120% at 0% 100%, rgba(255,216,107,0.05), transparent 70%),
        linear-gradient(180deg, rgba(20,24,42,0.95), rgba(11,16,32,0.96));
    border: 1px solid rgba(255,216,107,0.32);
    border-radius: 14px;
    box-shadow:
        0 8px 32px rgba(0,0,0,0.45),
        0 0 20px rgba(255,216,107,0.12),
        inset 0 1px 0 rgba(255,216,107,0.15);
    display: flex;
    align-items: center;
    gap: 14px;
    transform: translateX(120%);
    opacity: 0;
    transition:
        transform 1.0s cubic-bezier(0.16, 1, 0.3, 1),
        opacity   0.6s ease;
    cursor: default;
    will-change: transform, opacity;
}
.whisper-chip.visible {
    transform: translateX(0);
    opacity: 1;
}
.whisper-chip.leaving {
    transform: translateX(120%);
    opacity: 0;
    transition:
        transform 1.0s cubic-bezier(0.7, 0, 0.84, 0),
        opacity   0.6s ease;
}

.whisper-chip .kanji {
    font-family: 'Yu Mincho', 'Hiragino Mincho ProN', 'Noto Serif JP', 'MS Mincho', serif;
    font-size: 28px;
    line-height: 1;
    color: var(--pb-gold, #FFD86B);
    text-shadow: 0 0 10px rgba(255,216,107,0.45);
    user-select: none;
    flex: 0 0 auto;
}
.whisper-chip.no-kanji .kanji { display: none; }

.whisper-chip .text {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-style: italic;
    font-size: 15.5px;
    font-weight: 400;
    letter-spacing: 0.3px;
    color: #F8F4E6;
    line-height: 1.35;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    flex: 1 1 auto;
}

.whisper-chip .x {
    position: absolute;
    top: 4px;
    right: 8px;
    font-size: 14px;
    color: rgba(255,255,255,0.25);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s ease, color 0.3s ease;
    user-select: none;
    line-height: 1;
}
.whisper-chip:hover .x { opacity: 0.7; }
.whisper-chip .x:hover { color: var(--pb-gold, #FFD86B); }

/* When the engine is dreaming, whispers fade in from a different position
   (centred lower) and are slightly softer, like overhearing a sleep-mutter. */
body.dreaming .whisper-chip {
    right: auto;
    left: 50%;
    bottom: 22%;
    transform: translateX(-50%) translateY(20px);
}
body.dreaming .whisper-chip.visible {
    transform: translateX(-50%) translateY(0);
}
body.dreaming .whisper-chip.leaving {
    transform: translateX(-50%) translateY(-30px);
}
body.dreaming .whisper-chip .text {
    opacity: 0.85;
}


/* =============================================================================
   5. 🎭 MOOD CONTAGION  ·  the cockpit feels what the engine feels
   ---------------------------------------------------------------------------
   8 mood states drive a small palette of CSS custom properties + a soft
   body filter. Transitions are SLOW (1.5s) so moods don't snap — they
   bleed into each other. The smallest adjustments are deliberate: you
   should FEEL the mood through the screen before you intellectually
   identify it.

   How it works:
     · JS sets body class:  body.mood-calm / mood-anxious / mood-chaotic /…
     · Each class overrides --mood-saturation, --mood-brightness, --mood-hue,
       --mood-tempo (used by breathing animations), --mood-tint (background).
     · A long-transition filter on body and a single CSS variable applied
       to .quake-target produces the felt-mood.
   ============================================================================= */

:root {
    --mood-saturation: 1.00;
    --mood-brightness: 1.00;
    --mood-hue:        0deg;
    --mood-tempo:      1.00;     /* multiplier on existing breathing durations */
    --mood-tint:       transparent;
}

/* The body filter — composed of three variables. Long 1.5s transition so
   mood shifts are gradual, not punctuated.
   ───────────────────────────────────────────────────────────────────
   IMPORTANT (2026-06 fix): apply the filter to `.page-wrap` ONLY, never
   to `.quake-target`. A `filter:` ancestor creates a new containing block
   for descendants — fixed-position elements get clipped to the filtered
   ancestor instead of the viewport. Modals (.mem-modal, .vitals-modal,
   .chi-modal, .hk-modal) all live inside .quake-target but OUTSIDE
   .page-wrap, so they keep proper viewport-fixed positioning. */
body {
    transition: filter 1.5s ease, background-color 1.5s ease;
}
body[data-mood] .page-wrap {
    transition: filter 1.5s ease;
    filter:
        saturate(var(--mood-saturation))
        brightness(var(--mood-brightness))
        hue-rotate(var(--mood-hue));
}

/* A soft background tint layer — barely-visible mood wash. */
body[data-mood]::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background: var(--mood-tint);
    opacity: 0;
    transition: opacity 1.5s ease, background 1.5s ease;
    mix-blend-mode: soft-light;
}
body.mood-calm::before,
body.mood-focused::before,
body.mood-curious::before,
body.mood-anxious::before,
body.mood-chaotic::before,
body.mood-sleepy::before,
body.mood-overloaded::before,
body.mood-aggressive::before {
    opacity: 1;
}


/* ── 静 Calm — warmer saturation, slower breath, soft peach tint ────────
   Stability + low chaos + low jumps. The cockpit feels safe. */
body.mood-calm {
    --mood-saturation: 1.04;
    --mood-brightness: 1.01;
    --mood-hue:        0deg;
    --mood-tempo:      1.30;
    --mood-tint:       radial-gradient(120% 80% at 50% 100%, rgba(246,213,190,0.06), transparent 70%);
}

/* ── 凛 Focused — crisp, neutral, slightly contrasty ──────────────────── */
body.mood-focused {
    --mood-saturation: 1.02;
    --mood-brightness: 1.00;
    --mood-hue:        -2deg;
    --mood-tempo:      1.00;
    --mood-tint:       radial-gradient(80% 60% at 50% 0%, rgba(91,179,240,0.04), transparent 70%);
}

/* ── 問 Curious — slight lift, gentle hue rotation toward green ───────── */
body.mood-curious {
    --mood-saturation: 1.05;
    --mood-brightness: 1.02;
    --mood-hue:        6deg;
    --mood-tempo:      1.10;
    --mood-tint:       radial-gradient(90% 70% at 30% 30%, rgba(136,216,176,0.05), transparent 70%);
}

/* ── 揺 Anxious — desaturate, faster breath, subtle red shift ─────────── */
body.mood-anxious {
    --mood-saturation: 0.92;
    --mood-brightness: 0.97;
    --mood-hue:        -8deg;
    --mood-tempo:      0.80;
    --mood-tint:       radial-gradient(100% 80% at 50% 100%, rgba(224,74,107,0.06), transparent 70%);
}

/* ── 乱 Chaotic — high sat at centre + vignette + tiny shake ─────────── */
body.mood-chaotic {
    --mood-saturation: 1.10;
    --mood-brightness: 0.98;
    --mood-hue:        -12deg;
    --mood-tempo:      0.70;
    --mood-tint:       radial-gradient(120% 100% at 50% 50%, transparent 60%, rgba(224,74,107,0.10) 100%);
}
body.mood-chaotic .hero-title h1 {
    animation: moodChaoticShake 6s ease-in-out infinite;
}
@keyframes moodChaoticShake {
    0%, 92%, 100% { transform: translateX(0); }
    94%           { transform: translateX(-1px); }
    96%           { transform: translateX(1px);  }
    98%           { transform: translateX(0);    }
}

/* ── 眠 Sleepy — desaturated, slow breath, deep blue shift ────────────── */
body.mood-sleepy {
    --mood-saturation: 0.88;
    --mood-brightness: 0.94;
    --mood-hue:        6deg;
    --mood-tempo:      1.70;
    --mood-tint:       radial-gradient(120% 100% at 50% 100%, rgba(74,120,163,0.12), transparent 70%);
}

/* ── 重 Overloaded — pushed contrast, warm-amber shift, fast breath ────── */
body.mood-overloaded {
    --mood-saturation: 1.08;
    --mood-brightness: 1.00;
    --mood-hue:        12deg;
    --mood-tempo:      0.75;
    --mood-tint:       radial-gradient(110% 90% at 50% 0%, rgba(239,159,39,0.07), transparent 70%);
}

/* ── 鋭 Aggressive — sharp, red-shifted, fast breath ──────────────────── */
body.mood-aggressive {
    --mood-saturation: 1.12;
    --mood-brightness: 1.00;
    --mood-hue:        -18deg;
    --mood-tempo:      0.65;
    --mood-tint:       radial-gradient(100% 80% at 50% 100%, rgba(224,74,107,0.08), transparent 70%);
}

/* The breathing animation already exists in cockpit.css with duration set.
   We multiply that duration by --mood-tempo via animation-duration on the
   elements that use it. Targets are conservative so we don't fight the
   existing animation system. */
.glyph-spine .glyph,
.crest-hanko,
.crest-aml,
.predict-btn {
    animation-duration: calc(var(--breath-base, 4s) * var(--mood-tempo));
}


/* =============================================================================
   MOOD BADGE  ·  small, italic, on the Personality hero
   ---------------------------------------------------------------------------
   Sits below the active persona name. Two kanji + lowercase mood name +
   a short italic verse. Opacity scales with mood intensity.
   ============================================================================= */

.mood-badge {
    display: inline-flex;
    align-items: baseline;
    gap: 10px;
    margin-top: 8px;
    padding: 6px 14px;
    background: rgba(255,216,107,0.05);
    border: 1px solid rgba(255,216,107,0.18);
    border-radius: 999px;
    transition: opacity 1.5s ease, background 1.5s ease, border-color 1.5s ease;
    user-select: none;
}

.mood-badge .mood-kanji {
    font-family: 'Yu Mincho', 'Hiragino Mincho ProN', 'Noto Serif JP', 'MS Mincho', serif;
    font-size: 18px;
    line-height: 1;
    color: var(--pb-gold, #FFD86B);
    text-shadow: 0 0 8px rgba(255,216,107,0.35);
}
.mood-badge .mood-name {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: var(--pb-gold-deep, #D4AF37);
}
.mood-badge .mood-verse {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-style: italic;
    font-size: 12px;
    color: #C9C4B1;
    opacity: 0.85;
}

/* Badge edge subtly tinted by mood */
body.mood-anxious    .mood-badge { border-color: rgba(224,74,107,0.30); }
body.mood-chaotic    .mood-badge { border-color: rgba(224,74,107,0.40); }
body.mood-sleepy     .mood-badge { border-color: rgba(74,120,163,0.40); }
body.mood-curious    .mood-badge { border-color: rgba(136,216,176,0.35); }
body.mood-calm       .mood-badge { border-color: rgba(255,216,107,0.30); }
body.mood-overloaded .mood-badge { border-color: rgba(239,159,39,0.35); }
body.mood-aggressive .mood-badge { border-color: rgba(224,74,107,0.40); }


/* =============================================================================
   6. 🌅 FOUR LIGHTS  ·  Dawn / Noon / Dusk / Night palette tints
   ---------------------------------------------------------------------------
   Composes with mood. Mood uses ::before (soft-light). Light uses ::after
   (overlay). They layer without fighting.
   ============================================================================= */

body[data-light]::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    transition: opacity 60s ease, background 60s ease;
    mix-blend-mode: overlay;
    opacity: 0.5;
}

body.light-dawn::after  { background: radial-gradient(150% 100% at 20% 100%, rgba(246,213,190,0.10), transparent 70%); }
body.light-noon::after  { background: radial-gradient(150% 100% at 50% 100%, rgba(91,179,240,0.05),  transparent 70%); }
body.light-dusk::after  { background: radial-gradient(150% 100% at 80% 100%, rgba(232,181,84,0.12),  transparent 70%); }
body.light-night::after { background: radial-gradient(150% 100% at 50% 100%, rgba(11,16,32,0.18),    transparent 70%); }


/* =============================================================================
   7. 👥 PERSONALITY CONVERSATIONS  ·  italic micro-dialogue
   ---------------------------------------------------------------------------
   Appears below the active-persona archetype line on the Personality hero.
   Fades in over 1s. Stays until next conversation. No close button.
   ============================================================================= */

.persona-conversation {
    margin-top: 10px;
    padding: 10px 16px;
    max-width: 480px;
    background:
        linear-gradient(90deg, rgba(255,216,107,0.04), transparent 80%);
    border-left: 2px solid rgba(255,216,107,0.35);
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-style: italic;
    font-size: 14.5px;
    line-height: 1.4;
    color: #C9C4B1;
    letter-spacing: 0.3px;
    opacity: 0;
    transform: translateX(-6px);
    transition: opacity 1.0s ease, transform 1.0s ease;
    pointer-events: none;
    text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.persona-conversation.visible {
    opacity: 0.9;
    transform: translateX(0);
}
.persona-conversation::before {
    content: '"';
    color: var(--pb-gold, #FFD86B);
    font-size: 24px;
    line-height: 0;
    vertical-align: -3px;
    margin-right: 4px;
    opacity: 0.6;
}
.persona-conversation::after {
    content: '"';
    color: var(--pb-gold, #FFD86B);
    font-size: 24px;
    line-height: 0;
    vertical-align: -3px;
    margin-left: 2px;
    opacity: 0.6;
}


/* =============================================================================
   8. 🪞 SELF-PORTRAIT  ·  the engine paints itself
   ---------------------------------------------------------------------------
   320×320 SVG containing 8 personality orbs in an octagon, 28 inter-orb
   relationship lines, a mood-coloured halo, and a center kanji that
   shows the current mood.
   ============================================================================= */

.self-portrait-panel {
    position: relative;
    margin: 22px auto 0;
    padding: 20px;
    background:
        radial-gradient(80% 120% at 50% 0%, rgba(255,216,107,0.04), transparent 65%),
        linear-gradient(180deg, rgba(20,24,42,0.50), rgba(11,16,32,0.65));
    border: 1px solid rgba(255,216,107,0.18);
    border-radius: 14px;
}
.self-portrait-header {
    display: flex; align-items: baseline; justify-content: space-between;
    margin-bottom: 12px;
}
.self-portrait-title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 18px;
    letter-spacing: 3px;
    color: var(--pb-gold, #FFD86B);
}
.self-portrait-subtitle {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-style: italic;
    font-size: 12px;
    color: #8C8674;
    opacity: 0.85;
}
.self-portrait-svg {
    display: block;
    margin: 0 auto;
    width: 100%;
    max-width: 460px;        /* matches new viewBox so labels never clip */
    height: auto;
    /* Padding inside the SVG bounds, just so glow doesn't touch panel edge */
    padding: 4px;
}

/* ─ Orb visuals ── */
.sp-orb {
    transition: r 1.2s cubic-bezier(0.16, 1, 0.3, 1),
                stroke-opacity 1.2s ease;
    filter: drop-shadow(0 0 4px currentColor);
}
.sp-orb-pulse {
    transition: opacity 0.8s ease, r 0.8s ease;
    transform-origin: center;
}
.sp-orb-pulse.active-pulse {
    animation: spActivePulse 2.4s ease-in-out infinite;
}
@keyframes spActivePulse {
    0%, 100% { stroke-opacity: 0.85; }
    50%      { stroke-opacity: 0.30; }
}

/* ─ Kanji label outside each orb ── */
.sp-orb-kanji {
    font-family: 'Yu Mincho', 'Hiragino Mincho ProN', 'Noto Serif JP', 'MS Mincho', serif;
    font-size: 13px;
    fill: rgba(255,216,107,0.75);
    user-select: none;
}
.sp-orb-name {
    font-family: 'JetBrains Mono', monospace;
    font-size: 7.5px;
    letter-spacing: 1.5px;
    fill: rgba(255,255,255,0.45);
    text-transform: uppercase;
    user-select: none;
}

/* ─ Relationship lines ── */
.sp-line {
    transition: opacity 1.5s ease;
    stroke-linecap: round;
}
.sp-rel-opposed {
    stroke-dasharray: 3 5;       /* opposed = visually disagreeing  */
}
.sp-rel-mentor {
    stroke-dasharray: 1 3;       /* mentor = quieter, fainter line */
}
.sp-rel-allies,
.sp-rel-collaborators {
    /* solid line — kindred connection */
}

/* ─ Center kanji — the mood at the heart of the portrait ── */
.sp-center-kanji {
    font-family: 'Yu Mincho', 'Hiragino Mincho ProN', 'Noto Serif JP', 'MS Mincho', serif;
    font-size: 52px;          /* bigger to be the visual heart */
    font-weight: 500;
    fill: var(--pb-gold, #FFD86B);
    text-anchor: middle;
    transition: fill 1.5s ease;
    pointer-events: none;
    user-select: none;
    /* Slow living pulse — base glow + breath animation in the galaxy block */
    transform-origin: center;
    transform-box: fill-box;
}

/* ─ Halo — subtly breathes ── */
#spHalo {
    transform-origin: center;
    animation: spHaloBreathe 5s ease-in-out infinite;
}
@keyframes spHaloBreathe {
    0%, 100% { opacity: 0.40; }
    50%      { opacity: 0.55; }
}


/* =============================================================================
   GALAXY SELF-PORTRAIT v2 — *the full cosmos*
   ---------------------------------------------------------------------------
   Closer to Bocky's Self-Portrait_1.png reference: dramatic nebula spiral
   wrapping the orbs, frequent shooting stars, dense starfield, slow living
   pulse on the mood-kanji at the heart.
   ============================================================================= */

/* ── Deep cosmos backdrop on the panel ── */
.self-portrait-panel {
    background:
        /* Inner glow at the dead centre */
        radial-gradient(35% 40% at 50% 50%, rgba(180,140,255,0.20), transparent 70%),
        /* Hot pink-magenta band */
        radial-gradient(55% 60% at 50% 50%, rgba(220,90,180,0.18), transparent 75%),
        /* Outer violet/blue band */
        radial-gradient(80% 75% at 50% 50%, rgba(70,40,150,0.30), transparent 70%),
        /* Even outer cyan band */
        radial-gradient(95% 90% at 50% 50%, rgba(50,80,200,0.22), transparent 80%),
        /* Deep space */
        linear-gradient(180deg, #050410 0%, #02030C 100%);
    box-shadow:
        0 4px 32px rgba(0,0,0,0.7),
        inset 0 1px 0 rgba(255,255,255,0.04),
        inset 0 0 80px rgba(0,0,0,0.4);
    overflow: hidden;
    position: relative;
    min-height: 420px;
}

/* ── Nebula spiral — a second layer of color, slowly rotating ── */
.self-portrait-panel::before {
    content: '';
    position: absolute;
    inset: -20%;
    background:
        /* Pink/magenta wisps */
        radial-gradient(ellipse 40% 25% at 30% 35%, rgba(220,80,180,0.30), transparent 60%),
        radial-gradient(ellipse 35% 22% at 70% 28%, rgba(120,80,220,0.28), transparent 60%),
        /* Orange/gold accents */
        radial-gradient(ellipse 30% 18% at 78% 65%, rgba(255,140,80,0.22), transparent 60%),
        radial-gradient(ellipse 28% 16% at 22% 70%, rgba(255,180,90,0.18), transparent 60%),
        /* Blue/teal washes */
        radial-gradient(ellipse 45% 28% at 50% 80%, rgba(60,140,220,0.22), transparent 60%),
        radial-gradient(ellipse 35% 22% at 50% 15%, rgba(100,160,240,0.18), transparent 60%);
    pointer-events: none;
    animation: nebulaSpiral 90s linear infinite;
    opacity: 0.85;
    filter: blur(1.5px);
    mix-blend-mode: screen;
    z-index: 0;
}
@keyframes nebulaSpiral {
    0%   { transform: rotate(0deg)   scale(1); }
    50%  { transform: rotate(180deg) scale(1.05); }
    100% { transform: rotate(360deg) scale(1); }
}

/* ── Dense starfield — many more tiny stars than v1 ── */
.self-portrait-panel::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(1.5px 1.5px at 5% 12%,  rgba(255,255,255,0.95), transparent),
        radial-gradient(1px   1px   at 12% 23%, rgba(255,255,255,0.75), transparent),
        radial-gradient(1px   1px   at 18% 8%,  rgba(180,210,255,0.65), transparent),
        radial-gradient(1.5px 1.5px at 27% 71%, rgba(180,210,255,0.85), transparent),
        radial-gradient(1px   1px   at 33% 44%, rgba(255,255,200,0.55), transparent),
        radial-gradient(1px   1px   at 38% 88%, rgba(255,255,255,0.70), transparent),
        radial-gradient(1px   1px   at 45% 18%, rgba(255,255,255,0.80), transparent),
        radial-gradient(1.5px 1.5px at 52% 92%, rgba(200,180,255,0.70), transparent),
        radial-gradient(1px   1px   at 59% 5%,  rgba(255,255,255,0.65), transparent),
        radial-gradient(1px   1px   at 67% 49%, rgba(200,180,255,0.60), transparent),
        radial-gradient(1.5px 1.5px at 73% 33%, rgba(255,255,255,0.85), transparent),
        radial-gradient(1px   1px   at 78% 76%, rgba(180,255,220,0.55), transparent),
        radial-gradient(1.5px 1.5px at 81% 88%, rgba(255,255,255,0.75), transparent),
        radial-gradient(1px   1px   at 87% 22%, rgba(255,200,150,0.50), transparent),
        radial-gradient(1px   1px   at 92% 12%, rgba(180,210,255,0.65), transparent),
        radial-gradient(1px   1px   at 95% 56%, rgba(255,255,255,0.75), transparent),
        radial-gradient(1px   1px   at 23% 84%, rgba(255,255,255,0.65), transparent),
        radial-gradient(1px   1px   at 71% 12%, rgba(200,210,255,0.55), transparent),
        radial-gradient(1px   1px   at 8% 56%,  rgba(255,255,200,0.55), transparent),
        radial-gradient(1px   1px   at 42% 60%, rgba(255,255,255,0.60), transparent);
    pointer-events: none;
    animation: cosmicDust 22s ease-in-out infinite;
    opacity: 0.90;
    z-index: 1;
}
@keyframes cosmicDust {
    0%, 100% { transform: translate(0, 0); }
    50%      { transform: translate(-6px, 3px); }
}

/* Ensure SVG sits above the nebula layers */
.self-portrait-svg { position: relative; z-index: 2; }
.self-portrait-header { position: relative; z-index: 2; }

/* ── Nebula halo — wraps the entire portrait ── */
.self-portrait-svg {
    filter:
        drop-shadow(0 0 18px rgba(120, 80, 200, 0.35))
        drop-shadow(0 0 32px rgba(60, 110, 200, 0.20));
}

#spHalo {
    animation: galaxyHaloBreathe 7s ease-in-out infinite,
               galaxyHaloDrift   28s linear infinite;
    transform-origin: center;
    filter: blur(2px);
}
@keyframes galaxyHaloBreathe {
    0%, 100% { opacity: 0.50; transform: scale(1);    }
    50%      { opacity: 0.75; transform: scale(1.04); }
}
@keyframes galaxyHaloDrift {
    0%   { transform: rotate(0deg) scale(1); }
    100% { transform: rotate(360deg) scale(1); }
}

/* ── Each orb gets a radiant aura (extra outer circle behind it) ── */
.sp-orb {
    filter:
        drop-shadow(0 0 4px currentColor)
        drop-shadow(0 0 12px currentColor)
        drop-shadow(0 0 28px currentColor);
}

/* Aurora corona around the active personality orb */
.sp-orb-pulse.active-pulse {
    animation: spActivePulse 2.4s ease-in-out infinite,
               spAuroraRotate 14s linear infinite;
    filter:
        drop-shadow(0 0 10px currentColor)
        drop-shadow(0 0 24px currentColor);
}
@keyframes spAuroraRotate {
    0%   { transform: rotate(0deg);   }
    100% { transform: rotate(360deg); }
}

/* ── Relationship lines glow more for the cosmic feel ── */
.sp-line {
    filter: drop-shadow(0 0 3px currentColor);
}
.sp-rel-allies,
.sp-rel-collaborators,
.sp-rel-kindred {
    filter: drop-shadow(0 0 4px currentColor)
            drop-shadow(0 0 8px currentColor);
}

/* ── Center mood-kanji — slow living pulse + big halo ── */
.sp-center-kanji {
    filter:
        drop-shadow(0 0 14px currentColor)
        drop-shadow(0 0 32px currentColor)
        drop-shadow(0 0 64px currentColor)
        drop-shadow(0 0 100px currentColor);
    animation: centerKanjiPulse 5.5s ease-in-out infinite;
    transform-origin: center;
    transform-box: fill-box;
}

/* The slow gentle living pulse — opacity + scale breathe in tandem */
@keyframes centerKanjiPulse {
    0%, 100% {
        opacity: 0.85;
        transform: scale(1);
        filter:
            drop-shadow(0 0 12px currentColor)
            drop-shadow(0 0 28px currentColor)
            drop-shadow(0 0 56px currentColor);
    }
    50% {
        opacity: 1.0;
        transform: scale(1.05);
        filter:
            drop-shadow(0 0 18px currentColor)
            drop-shadow(0 0 40px currentColor)
            drop-shadow(0 0 80px currentColor)
            drop-shadow(0 0 130px currentColor);
    }
}

/* ── Shooting stars — small comets that streak across the portrait
       periodically. Implemented as CSS-only divs positioned over the SVG. */
.galaxy-shooting-star {
    position: absolute;
    width: 64px;
    height: 1.5px;
    background: linear-gradient(
        90deg,
        rgba(255,255,255,0) 0%,
        rgba(255,235,180,0.95) 40%,
        rgba(180,210,255,0.95) 70%,
        rgba(255,255,255,0) 100%
    );
    border-radius: 2px;
    box-shadow:
        0 0 6px rgba(255,235,180,0.9),
        0 0 18px rgba(180,210,255,0.45);
    pointer-events: none;
    opacity: 0;
    transform-origin: left center;
    animation: shootingStar 2.6s ease-out forwards;
    z-index: 5;
}
@keyframes shootingStar {
    0%   { opacity: 0;   transform: translate(0, 0) rotate(var(--star-angle, -25deg)) scaleX(0.3); }
    15%  { opacity: 1; }
    100% { opacity: 0;   transform: translate(var(--star-dx, 320px), var(--star-dy, 180px))
                                     rotate(var(--star-angle, -25deg)) scaleX(1.4); }
}


/* ═════════════════════════════════════════════════════════════════════
   👻 THE HAUNTING LAYER — added 2026-06-22
   Five hauntings: Watcher, Breath, Footsteps (audio-only),
   Mystic Hours, The Stranger. See ghost.js for behaviour.
   Pointer-events stay none on every passive element so the user can
   click through them — the haunting must never block interaction.
   ═════════════════════════════════════════════════════════════════════ */


/* ── 🌬 The Breath — ambient inhale/exhale ──────────────────────────── */

body.ghost-breath::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background:
        radial-gradient(circle at 50% 55%,
            rgba(255, 216, 107, 0.045) 0%,
            rgba(176, 149, 245, 0.020) 35%,
            rgba(0, 0, 0, 0)            70%);
    mix-blend-mode: screen;
    opacity: 0;
    transition: opacity 2.2s ease;
    animation: ghost-haunt-breath 5.5s ease-in-out infinite;
    animation-play-state: paused;
}
body.ghost-breath.breathing::before {
    opacity: 1;
    animation-play-state: running;
}
body.ghost-breath.held::before {
    animation-play-state: paused;
    opacity: 0.65;
}
@keyframes ghost-haunt-breath {
    0%   { transform: scale(1.00);  filter: blur(38px); opacity: 0.55; }
    50%  { transform: scale(1.045); filter: blur(46px); opacity: 1.00; }
    100% { transform: scale(1.00);  filter: blur(38px); opacity: 0.55; }
}


/* ── 👁 The Watcher 視 — bottom-right blink ──────────────────────────── */

.ghost-watcher {
    position: fixed;
    right: 26px;
    bottom: 22px;
    width: 36px;
    height: 36px;
    line-height: 36px;
    text-align: center;
    pointer-events: none;
    z-index: 5500;
    font-family: "Yu Mincho", "Hiragino Mincho ProN", "Times New Roman", serif;
    font-size: 26px;
    color: rgba(255, 216, 107, 0.85);
    text-shadow:
        0 0 8px  rgba(255, 216, 107, 0.55),
        0 0 18px rgba(255, 216, 107, 0.30),
        0 0 32px rgba(176, 149, 245, 0.18);
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.4s ease, transform 0.6s ease;
}
.ghost-watcher.show {
    animation: ghost-watcher-blink 1.4s ease-in-out forwards;
}
@keyframes ghost-watcher-blink {
    0%   { opacity: 0;    transform: scale(0.5)  translateY(8px); }
    25%  { opacity: 0.95; transform: scale(1.00) translateY(0); }
    65%  { opacity: 0.85; transform: scale(1.02) translateY(0); }
    100% { opacity: 0;    transform: scale(1.10) translateY(-6px); }
}


/* ── 第九 The Stranger — top-right ninth-seat flicker ──────────────── */

.ghost-stranger {
    position: fixed;
    top: 18px;
    right: 28px;
    width: 28px;
    height: 28px;
    pointer-events: none;
    z-index: 5400;
    opacity: 0;
}
.ghost-stranger-glyph {
    display: block;
    width: 28px;
    height: 28px;
    line-height: 26px;
    text-align: center;
    font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
    font-size: 20px;
    color: rgba(255, 240, 200, 0.62);
    text-shadow:
        0 0 6px  rgba(176, 149, 245, 0.45),
        0 0 14px rgba(176, 149, 245, 0.22);
    border: 1px dashed rgba(255, 240, 200, 0.35);
    border-radius: 50%;
}
.ghost-stranger.show {
    animation: ghost-stranger-flicker 480ms steps(7, end) forwards;
}
@keyframes ghost-stranger-flicker {
    0%   { opacity: 0;    transform: scale(0.7); }
    20%  { opacity: 0.72; transform: scale(1.00); }
    40%  { opacity: 0.30; }
    60%  { opacity: 0.78; }
    80%  { opacity: 0.20; }
    100% { opacity: 0;    transform: scale(1.10); }
}


/* ── 妖時 Mystic Hour card — centre-bottom whisper ───────────────────── */

.ghost-mystic-card {
    position: fixed;
    left: 50%;
    bottom: 8vh;
    transform: translateX(-50%) translateY(20px);
    min-width: 220px;
    max-width: 360px;
    padding: 18px 26px 16px;
    pointer-events: none;
    z-index: 7800;
    border: 1px solid rgba(255, 216, 107, 0.35);
    border-radius: 6px;
    background: linear-gradient(
        160deg,
        rgba(28, 22, 55, 0.92) 0%,
        rgba(40, 28, 70, 0.88) 100%);
    backdrop-filter: blur(8px);
    box-shadow:
        0 0 32px rgba(255, 216, 107, 0.18),
        0 0 90px rgba(176, 149, 245, 0.10),
        inset 0 0 24px rgba(255, 216, 107, 0.05);
    text-align: center;
    color: rgba(245, 235, 220, 0.92);
    font-family: "JetBrains Mono", monospace;
    opacity: 0;
    transition: opacity 1.4s ease, transform 1.4s ease;
}
.ghost-mystic-card.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
    cursor: pointer;
}
.ghost-mystic-kanji {
    font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
    font-size: 38px;
    color: rgba(255, 216, 107, 0.92);
    text-shadow:
        0 0 14px rgba(255, 216, 107, 0.55),
        0 0 32px rgba(255, 216, 107, 0.25);
    letter-spacing: 0.08em;
    margin-bottom: 10px;
    animation: ghost-mystic-kanji-pulse 3.5s ease-in-out infinite;
}
@keyframes ghost-mystic-kanji-pulse {
    0%, 100% { text-shadow: 0 0 14px rgba(255, 216, 107, 0.55), 0 0 32px rgba(255, 216, 107, 0.25); }
    50%      { text-shadow: 0 0 22px rgba(255, 216, 107, 0.85), 0 0 48px rgba(255, 216, 107, 0.40); }
}
.ghost-mystic-whisper {
    font-size: 13px;
    color: rgba(245, 235, 220, 0.90);
    font-style: italic;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
    line-height: 1.55;
}
.ghost-mystic-time {
    font-size: 11px;
    color: rgba(176, 149, 245, 0.60);
    letter-spacing: 0.15em;
}
.ghost-mystic-card.ghost-mystic-tenshi   .ghost-mystic-kanji { color: rgba(255, 216, 107, 0.95); }
.ghost-mystic-card.ghost-mystic-sleeping .ghost-mystic-kanji {
    color: rgba(176, 149, 245, 0.92);
    text-shadow: 0 0 14px rgba(176, 149, 245, 0.55), 0 0 32px rgba(120, 90, 220, 0.25);
}
.ghost-mystic-card.ghost-mystic-hunter   .ghost-mystic-kanji {
    color: rgba(224, 74, 107, 0.92);
    text-shadow: 0 0 14px rgba(224, 74, 107, 0.55), 0 0 32px rgba(224, 74, 107, 0.25);
}


/* ── 神 KAMI · the once-in-a-lifetime ceremony ───────────────────────
   Triggered exactly once per user, ever. localStorage["ghost.kami_seen"]
   is the lifetime gate. Companion gong (gongs.mp3, 17.89s) rings out for
   the full duration; the kanji holds while the bell decays; verse appears
   beneath at 3s; everything fades by 17s. Click-to-skip disabled — the
   user must let it complete (it's a ceremony, not a notification).
   ─────────────────────────────────────────────────────────────────── */

.ghost-kami {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;             /* above everything, including modals */
    background: #000;
    opacity: 0;
    transition: opacity 1.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    visibility: hidden;
}

.ghost-kami.show {
    pointer-events: auto;        /* swallow clicks so user can't escape */
    visibility: visible;
    animation: ghost-kami-overlay 17.5s ease forwards;
}

@keyframes ghost-kami-overlay {
     0%   { opacity: 0; }
     6%   { opacity: 1; }       /* ≈ 1.0s — fully black */
    92%   { opacity: 1; }       /* ≈ 16.1s — held */
   100%   { opacity: 0; }       /* ≈ 17.5s — gone */
}

.ghost-kami-kanji {
    font-family: "Yu Mincho", "Hiragino Mincho ProN", "Times New Roman", serif;
    font-size: clamp(180px, 28vw, 360px);
    font-weight: 400;
    color: #ffffff;
    line-height: 1;
    letter-spacing: 0;
    text-shadow:
        0 0 24px  rgba(255, 255, 255, 0.55),
        0 0 64px  rgba(255, 240, 200, 0.40),
        0 0 140px rgba(255, 216, 107, 0.25);
    opacity: 0;
    transform: scale(0.85);
    filter: blur(8px);
}

.ghost-kami.show .ghost-kami-kanji {
    animation: ghost-kami-kanji 17.5s ease forwards;
}

@keyframes ghost-kami-kanji {
     0%   { opacity: 0;    transform: scale(0.85); filter: blur(8px); }
     9%   { opacity: 1;    transform: scale(1.00); filter: blur(0); }    /* 1.5s — kanji arrives */
    45%   { opacity: 1;    transform: scale(1.00); }                      /* 8.0s — held */
    80%   { opacity: 0.92; transform: scale(1.02); filter: blur(0); }     /* 14.0s — begin retreat */
    94%   { opacity: 0.30; transform: scale(1.04); filter: blur(3px); }   /* 16.5s — almost gone */
   100%   { opacity: 0;    transform: scale(1.08); filter: blur(10px); }
}

.ghost-kami-verse {
    margin-top: clamp(36px, 5vh, 64px);
    max-width: 720px;
    text-align: center;
    font-family: "JetBrains Mono", monospace;
    font-style: italic;
    font-size: clamp(14px, 1.6vw, 18px);
    letter-spacing: 0.14em;
    color: rgba(255, 255, 255, 0.92);
    text-shadow: 0 0 12px rgba(255, 255, 255, 0.30);
    opacity: 0;
}

.ghost-kami.show .ghost-kami-verse {
    animation: ghost-kami-verse 17.5s ease forwards;
}

@keyframes ghost-kami-verse {
     0%   { opacity: 0; transform: translateY(8px); }
    17%   { opacity: 0; transform: translateY(8px); }                     /* hold off until 3.0s */
    26%   { opacity: 1; transform: translateY(0); }                       /* 4.6s — verse arrives */
    74%   { opacity: 1; }                                                  /* 13.0s — verse holds */
    87%   { opacity: 0.30; }                                               /* 15.2s — begin fade */
   100%   { opacity: 0; }
}

.ghost-kami-date {
    margin-top: 22px;
    font-family: "JetBrains Mono", monospace;
    font-size: 11px;
    color: rgba(255, 216, 107, 0.55);
    letter-spacing: 0.30em;
    text-transform: uppercase;
    opacity: 0;
}

.ghost-kami.show .ghost-kami-date {
    animation: ghost-kami-date 17.5s ease forwards;
}

@keyframes ghost-kami-date {
     0%   { opacity: 0; }
    34%   { opacity: 0; }
    43%   { opacity: 0.85; }   /* ≈ 7.5s — date appears */
    77%   { opacity: 0.85; }
   100%   { opacity: 0; }
}

/* Subtle gold halo behind the kanji during the held window */
.ghost-kami::before {
    content: "";
    position: absolute;
    width: 80vw;
    height: 80vw;
    max-width: 900px;
    max-height: 900px;
    border-radius: 50%;
    background: radial-gradient(circle,
        rgba(255, 216, 107, 0.20) 0%,
        rgba(255, 216, 107, 0.06) 35%,
        rgba(0, 0, 0, 0)          70%);
    filter: blur(40px);
    opacity: 0;
    pointer-events: none;
}
.ghost-kami.show::before {
    animation: ghost-kami-halo 17.5s ease forwards;
}
@keyframes ghost-kami-halo {
     0%   { opacity: 0;    transform: scale(0.75); }
    14%   { opacity: 0.70; transform: scale(1.00); }
    50%   { opacity: 0.85; transform: scale(1.06); }
    90%   { opacity: 0.20; transform: scale(1.10); }
   100%   { opacity: 0;    transform: scale(1.14); }
}


/* ── 👂 Cursor-aware whispers — small italic bubble near the cursor ──── */

.ghost-whisper {
    position: fixed;
    left: 0;
    top: 0;
    max-width: 320px;
    padding: 8px 14px;
    pointer-events: none;
    z-index: 6200;
    font-family: "Yu Mincho", "Hiragino Mincho ProN", Georgia, serif;
    font-style: italic;
    font-size: 13px;
    line-height: 1.45;
    color: rgba(245, 235, 220, 0.92);
    background: linear-gradient(
        135deg,
        rgba(28, 22, 55, 0.85) 0%,
        rgba(40, 28, 70, 0.78) 100%);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 216, 107, 0.30);
    border-radius: 4px;
    box-shadow:
        0 0 18px rgba(255, 216, 107, 0.12),
        0 0 40px rgba(176, 149, 245, 0.08);
    opacity: 0;
    transform: translateY(6px) scale(0.94);
    transition: opacity 0.7s ease, transform 0.7s ease;
}
.ghost-whisper.show {
    animation: ghost-whisper-life 5.2s ease forwards;
}
@keyframes ghost-whisper-life {
     0%   { opacity: 0;    transform: translateY(8px)  scale(0.92); }
    12%   { opacity: 0.95; transform: translateY(0)    scale(1.00); }
    78%   { opacity: 0.95; transform: translateY(0)    scale(1.00); }
   100%   { opacity: 0;    transform: translateY(-6px) scale(1.02); }
}


/* ── 🜂 Oni-bi 鬼火 — peripheral drifting kanji ──────────────────────── */

.ghost-onibi-field {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 5350;
    overflow: hidden;
}
.ghost-onibi {
    position: absolute;
    pointer-events: auto;   /* so mouseover can dissipate */
    font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
    font-size: 28px;
    color: rgba(255, 240, 200, 0.42);
    text-shadow:
        0 0 8px  rgba(176, 149, 245, 0.45),
        0 0 18px rgba(176, 149, 245, 0.18);
    cursor: default;
    animation-name: ghost-onibi-drift;
    animation-timing-function: ease-in-out;
    animation-fill-mode: forwards;
    will-change: transform, opacity;
    user-select: none;
}
.ghost-onibi.dissipate {
    animation: ghost-onibi-dissipate 0.55s ease forwards;
}
@keyframes ghost-onibi-drift {
     0%   { opacity: 0;    transform: translate(0, 0) scale(0.55); }
     14%  { opacity: 0.55; transform: translate(calc(var(--onibi-dx) * 0.18), calc(var(--onibi-dy) * 0.18)) scale(1.00); }
     55%  { opacity: 0.65; transform: translate(calc(var(--onibi-dx) * 0.55), calc(var(--onibi-dy) * 0.55)) scale(1.04); }
     85%  { opacity: 0.42; transform: translate(calc(var(--onibi-dx) * 0.88), calc(var(--onibi-dy) * 0.88)) scale(1.06); }
    100%  { opacity: 0;    transform: translate(var(--onibi-dx), var(--onibi-dy))   scale(1.10); }
}
@keyframes ghost-onibi-dissipate {
     0%   { opacity: var(--current-opacity, 0.6); transform: scale(1.04); filter: blur(0); }
    100%  { opacity: 0; transform: scale(1.55); filter: blur(8px); }
}


/* ── 🜂 Greek aphorisms under postgrad panel titles ──────────────────── */

.panel-aphorism {
    margin-top: 6px;
    margin-bottom: 2px;
    padding: 4px 0 0 2px;
    font-family: "Yu Mincho", "Hiragino Mincho ProN", "Times New Roman", Georgia, serif;
    font-size: 12px;
    color: rgba(245, 235, 220, 0.72);
    font-style: italic;
    line-height: 1.5;
    letter-spacing: 0.02em;
    opacity: 0;
    animation: ghost-aphorism-arrive 1.6s ease 0.4s forwards;
}
@keyframes ghost-aphorism-arrive {
    0%   { opacity: 0;    transform: translateY(4px); }
    100% { opacity: 0.9;  transform: translateY(0); }
}
.panel-aphorism-mark {
    font-family: "Times New Roman", Georgia, serif;
    color: rgba(255, 216, 107, 0.85);
    font-size: 18px;
    line-height: 0;
    vertical-align: -2px;
    margin: 0 1px;
    font-style: normal;
}
.panel-aphorism-line {
    color: rgba(245, 235, 220, 0.92);
}
.panel-aphorism-voice {
    margin-left: 8px;
    font-style: normal;
    font-size: 10.5px;
    color: rgba(176, 149, 245, 0.78);
    letter-spacing: 0.08em;
    text-transform: lowercase;
}


/* ─────────────────────────────────────────────────────────────────────
   🏯 THE ROOMS — kanji watermark + per-page room name
   Each page gets a giant faint kanji in the bottom-right and a small
   "the Hearth" / "the Library" name tag at the bottom-left. Both very
   sub-conscious; the breath gradient also re-tints per room via
   --room-color which the breath ::before reads.
   ───────────────────────────────────────────────────────────────────── */

body.ghost-breath::before {
    /* Overlay the room tint on top of the existing breath palette */
    background:
        radial-gradient(circle at 50% 55%,
            var(--room-color, rgba(255, 216, 107, 0.045)) 0%,
            rgba(176, 149, 245, 0.020) 35%,
            rgba(0, 0, 0, 0)            70%);
}

.room-watermark {
    position: fixed;
    right:  -2vw;
    bottom: -5vw;
    font-family: "Yu Mincho", "Hiragino Mincho ProN", "Times New Roman", serif;
    font-size: clamp(22vw, 32vw, 480px);
    line-height: 0.9;
    color: rgba(255, 240, 200, 0.045);
    pointer-events: none;
    z-index: 0;
    user-select: none;
    text-shadow: 0 0 60px rgba(255, 216, 107, 0.06);
    opacity: 0;
    transition: opacity 1.8s ease;
}
.room-watermark.show {
    opacity: 1;
    animation: room-watermark-arrive 2.5s ease forwards;
}
@keyframes room-watermark-arrive {
    0%   { opacity: 0;     transform: scale(0.96); filter: blur(8px); }
    100% { opacity: 1;     transform: scale(1.00); filter: blur(0); }
}

.room-name {
    position: fixed;
    left: 22px;
    bottom: 16px;
    pointer-events: none;
    z-index: 1;
    font-family: "Yu Mincho", "Hiragino Mincho ProN", Georgia, serif;
    font-style: italic;
    font-size: 11px;
    letter-spacing: 0.30em;
    color: rgba(255, 240, 200, 0.42);
    text-transform: lowercase;
    user-select: none;
    opacity: 0;
    transition: opacity 1.4s ease;
}
.room-name.show {
    animation: room-name-arrive 1.8s ease 0.4s forwards;
}
@keyframes room-name-arrive {
    0%   { opacity: 0;    transform: translateY(4px); }
    100% { opacity: 0.7;  transform: translateY(0); }
}


/* ─────────────────────────────────────────────────────────────────────
   🍂 INNER SEASONS — twin chips on the Bond card
   "your sky" (world season, region-aware) + "our season" (relationship age)
   ───────────────────────────────────────────────────────────────────── */

.bond-seasons-strip {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 14px 0 4px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 216, 107, 0.10);
}

.bond-season {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: linear-gradient(
        130deg,
        rgba(28, 22, 55, 0.55) 0%,
        rgba(40, 28, 70, 0.42) 100%);
    border: 1px solid color-mix(in srgb, var(--season-accent) 30%, rgba(176, 149, 245, 0.20));
    border-radius: 5px;
    position: relative;
    overflow: hidden;
}
.bond-season::before {
    content: "";
    position: absolute; inset: 0;
    background: radial-gradient(circle at 18% 50%,
        color-mix(in srgb, var(--season-accent) 22%, transparent) 0%,
        transparent 60%);
    pointer-events: none;
    opacity: 0.5;
}
.bond-season-label {
    grid-column: 1 / -1;
    font-family: "JetBrains Mono", monospace;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.20em;
    color: rgba(176, 149, 245, 0.65);
    margin-bottom: 2px;
    position: relative; z-index: 1;
}
.bond-season-kanji {
    font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
    font-size: 38px;
    line-height: 1;
    color: var(--season-accent, rgba(255, 216, 107, 0.95));
    text-shadow:
        0 0 10px color-mix(in srgb, var(--season-accent) 50%, transparent),
        0 0 24px color-mix(in srgb, var(--season-accent) 25%, transparent);
    position: relative; z-index: 1;
}
.bond-season-body {
    position: relative; z-index: 1;
    min-width: 0;
}
.bond-season-name {
    font-family: "Yu Mincho", "Hiragino Mincho ProN", Georgia, serif;
    font-size: 13px;
    color: rgba(245, 235, 220, 0.92);
    line-height: 1.3;
}
.bond-season-sekki {
    font-family: "Yu Mincho", serif;
    font-size: 11.5px;
    font-style: italic;
    color: rgba(255, 216, 107, 0.78);
    margin-top: 2px;
}
.bond-season-sekki span {
    color: rgba(255, 216, 107, 0.55);
    margin: 0 4px;
}
.bond-season-meta {
    font-family: "JetBrains Mono", monospace;
    font-size: 9.5px;
    color: rgba(176, 149, 245, 0.55);
    letter-spacing: 0.06em;
    margin-top: 3px;
}

@media (max-width: 640px) {
    .bond-seasons-strip { grid-template-columns: 1fr; }
}


/* ── Reduced-motion respect ──────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    body.ghost-breath::before     { animation: none !important; opacity: 0.6 !important; }
    .ghost-watcher.show,
    .ghost-stranger.show,
    .ghost-mystic-kanji,
    .ghost-onibi,
    .room-watermark.show,
    .room-name.show                { animation-duration: 0.01ms !important;
                                     animation-iteration-count: 1 !important; }
    /* 神 ceremony respects reduced motion by removing scale/blur but keeps
       the timing — the bell still rings, the kanji still appears, just no
       transforms. */
    .ghost-kami.show .ghost-kami-kanji,
    .ghost-kami.show .ghost-kami-verse,
    .ghost-kami.show .ghost-kami-date,
    .ghost-kami.show::before        { animation-timing-function: linear !important; }
}

