/* ghost-costumes.css · sorahseong.com home · v3, 30 Nov 2026
   The ghost has its scene costume off, and puts it on only at a chest or a door the visitor has chosen.
   - City View: the sunglasses are pushed up onto its forehead. At a chosen chest they come down over its eyes.
   - Treetops: the Totoro mask is tipped back over the top of its head. At a chosen chest it comes down over its face.
   - Forest: a little leaf lies on its head. At a chosen door the leaf flies off and the antlers grow out of its head;
     when the door is let go, the antlers shrink back in and the leaf drifts back down.
   "Chosen" is the site's own state, so nothing has to tell this file:
   - City View and Treetops: a chest is open (.connections[data-selected] is not empty). On a laptop the mouse leads
     the ghost to it; on a phone or an iPad it was tapped, or the ghost is dragged over it or dropped on it.
   - Forest: on a laptop the mouse leads the ghost to a door (.chic-doors.cursor-guiding .chic-door.is-near); on a
     phone or an iPad a door was tapped once (.touch-armed), or the ghost is dragged over it (.ghost-target-ready) or
     dropped on it ([data-ghost-armed="true"]). The ghost's own walk from door to door on a laptop does not count.
   Moving alone does not count: dragged across the scene, or following the mouse, the ghost keeps its costume off.
   The cursor ghost (.page-ghost-cursor, laptops) never stands at a chest or a door, so it always has it off.
   The costume goes on at once with a small bounce; it comes off about half a second after the chest or door is let
   go, so passing from one chest to the next does not make it flicker.
   It arrives without its costume, from the very first frame. ghost-costumes.js adds the leaf, and for two frames
   after a scene change or a return to the home page turns the costume animations off (html.ghost-costume-snap).
   The costumes are the site's own drawings (the .ghost-costume groups that script.js adds to every ghost); only
   their position changes. With reduced motion, or with the site's motion switched off, nothing changes: the
   costume stays on, as before.
   v3: v1 and v2 put the costume on whenever the ghost moved (dragged, following the mouse, flying to a chest or
   walking to a door), so a visitor hardly ever saw it off. Now it is off all the time and on only at a chosen chest
   or door. ghost-costumes.js no longer watches the mouse or the chests and doors.
   Load it as the last stylesheet, after treetop-mobile.css. */

/* 1. Worn (as the site draws it). Putting it on is quick, with a small bounce. With reduced motion, or the site's
      motion switched off, this is how it stays. */
html body.home-view:has(.forest-stage[data-scene="nyc"]) :is(.spirit-wrap > svg.spirit, .page-ghost-cursor > svg.guide-ghost) .ghost-sunglasses {
  /* the same as the group's own transform attribute: translate(40 36) scale(1.14) translate(-40 -36) */
  transform: translate(40px, 36px) rotate(0deg) scale(1.14) translate(-40px, -36px);
  transition: transform .32s cubic-bezier(.3, 1.45, .55, 1);
}
html body.home-view:has(.forest-stage[data-scene="nyc"]) :is(.spirit-wrap > svg.spirit, .page-ghost-cursor > svg.guide-ghost) .ghost-sunglasses ellipse {
  transition: opacity .25s ease;
}
html body.home-view:has(.forest-stage[data-scene="treetop"]) :is(.spirit-wrap > svg.spirit, .page-ghost-cursor > svg.guide-ghost) .ghost-totoro-mask {
  transform: translate(40px, 36px) rotate(0deg) scale(1) translate(-40px, -36px);
  transition: transform .32s cubic-bezier(.3, 1.45, .55, 1);
}
/* Forest: the antlers (with the little deer ears under them) grow out of the top of the head, with a springy overshoot */
html body.home-view:has(.forest-stage[data-scene="forest"]) :is(.chic-doorguide svg.guide-ghost, .page-ghost-cursor > svg.guide-ghost) .ghost-antlers {
  --antler-size: 1;
  transform-origin: 0 0;
  transform: translate(40px, 19.2px) scale(var(--antler-size)) translate(-40px, -19.2px)
             translate(40px, 16px) scale(1, 1) translate(-40px, -16px);
  opacity: 1;
  transition: transform .45s cubic-bezier(.3, 1.5, .5, 1) .1s, opacity .12s ease .1s;
}
/* Phones: the antlers keep the site's smaller phone size (scale .82 around 50% 20%, chest-open-integration.css). */
@media (max-width: 680px) {
  html body.home-view:has(.forest-stage[data-scene="forest"]) .chic-doorguide svg.guide-ghost .ghost-antlers {
    --antler-size: .82;
  }
}
/* Forest: with the antlers on, the leaf has flown off up and to the right, turning as it goes (it fades out on the way) */
html body.home-view:has(.forest-stage[data-scene="forest"]) :is(.chic-doorguide svg.guide-ghost, .page-ghost-cursor > svg.guide-ghost) .ghost-leaf {
  display: inline;
  transform-origin: 0 0;
  transform: translate(58px, -16px) rotate(40deg) translate(-40px, -4px);
  opacity: 0;
  transition: transform .55s cubic-bezier(.25, .6, .35, 1), opacity .35s ease .15s;
}

@media (prefers-reduced-motion: no-preference) {
  /* 2. Off: how the ghost is everywhere, while it rests and while it moves. Taking it off waits about half a second. */
  html body.home-view.motion-enabled:has(.forest-stage[data-scene="nyc"]) :is(.spirit-wrap > svg.spirit, .page-ghost-cursor > svg.guide-ghost) .ghost-sunglasses {
    transform: translate(40px, 21px) rotate(-7deg) scale(1.14) translate(-40px, -36px);
    transition: transform .5s cubic-bezier(.4, 0, .3, 1) .45s;
  }
  /* the pink cheeks belong to the sunglasses drawing: they show only with the glasses on */
  html body.home-view.motion-enabled:has(.forest-stage[data-scene="nyc"]) :is(.spirit-wrap > svg.spirit, .page-ghost-cursor > svg.guide-ghost) .ghost-sunglasses ellipse {
    opacity: 0;
    transition: opacity .3s ease .45s;
  }
  /* the mask tips back over the top of the head: seen almost edge-on, so it is flat and its face barely shows */
  html body.home-view.motion-enabled:has(.forest-stage[data-scene="treetop"]) :is(.spirit-wrap > svg.spirit, .page-ghost-cursor > svg.guide-ghost) .ghost-totoro-mask {
    transform: translate(40px, 9px) rotate(-4deg) scale(.84, .34) translate(-40px, -36px);
    transition: transform .5s cubic-bezier(.4, 0, .3, 1) .45s;
  }
  /* the antlers shrink back into the head and are gone */
  html body.home-view.motion-enabled:has(.forest-stage[data-scene="forest"]) :is(.chic-doorguide svg.guide-ghost, .page-ghost-cursor > svg.guide-ghost) .ghost-antlers {
    transform: translate(40px, 19.2px) scale(var(--antler-size)) translate(-40px, -19.2px)
               translate(40px, 16px) scale(.3, 0) translate(-40px, -16px);
    opacity: 0;
    transition: transform .35s cubic-bezier(.5, 0, .75, 0) .45s, opacity .12s ease .68s;
  }
  /* the leaf lies on the crown of the head, a little tilted; it drifts back down once the antlers are gone */
  html body.home-view.motion-enabled:has(.forest-stage[data-scene="forest"]) :is(.chic-doorguide svg.guide-ghost, .page-ghost-cursor > svg.guide-ghost) .ghost-leaf {
    transform: translate(40px, 4px) rotate(-6deg) translate(-40px, -4px);
    opacity: 1;
    transition: transform .7s cubic-bezier(.3, 1.25, .5, 1) .75s, opacity .3s ease .75s;
  }

  /* 3. On: at a chest or a door the visitor has chosen. Only the ghost in the scene; never the cursor ghost. */
  html body.home-view.motion-enabled:has(.forest-stage[data-scene="nyc"] .connections[data-selected]:not([data-selected=""])) .spirit-wrap > svg.spirit .ghost-sunglasses {
    transform: translate(40px, 36px) rotate(0deg) scale(1.14) translate(-40px, -36px);
    transition: transform .32s cubic-bezier(.3, 1.45, .55, 1);
  }
  html body.home-view.motion-enabled:has(.forest-stage[data-scene="nyc"] .connections[data-selected]:not([data-selected=""])) .spirit-wrap > svg.spirit .ghost-sunglasses ellipse {
    opacity: 1;
    transition: opacity .25s ease;
  }
  html body.home-view.motion-enabled:has(.forest-stage[data-scene="treetop"] .connections[data-selected]:not([data-selected=""])) .spirit-wrap > svg.spirit .ghost-totoro-mask {
    transform: translate(40px, 36px) rotate(0deg) scale(1) translate(-40px, -36px);
    transition: transform .32s cubic-bezier(.3, 1.45, .55, 1);
  }
  html body.home-view.motion-enabled:has(.forest-stage[data-scene="forest"] :is(.chic-doors.cursor-guiding .chic-door.is-near, .chic-door.touch-armed, .chic-door.ghost-target-ready, .chic-door[data-ghost-armed="true"])) .chic-doorguide svg.guide-ghost .ghost-antlers {
    transform: translate(40px, 19.2px) scale(var(--antler-size)) translate(-40px, -19.2px)
               translate(40px, 16px) scale(1, 1) translate(-40px, -16px);
    opacity: 1;
    transition: transform .45s cubic-bezier(.3, 1.5, .5, 1) .1s, opacity .12s ease .1s;
  }
  html body.home-view.motion-enabled:has(.forest-stage[data-scene="forest"] :is(.chic-doors.cursor-guiding .chic-door.is-near, .chic-door.touch-armed, .chic-door.ghost-target-ready, .chic-door[data-ghost-armed="true"])) .chic-doorguide svg.guide-ghost .ghost-leaf {
    transform: translate(58px, -16px) rotate(40deg) translate(-40px, -4px);
    opacity: 0;
    transition: transform .55s cubic-bezier(.25, .6, .35, 1), opacity .35s ease .15s;
  }
}

/* 4. Arriving (a scene change, back on the home page): no taking-off on the way in, the costume is simply off.
      ghost-costumes.js sets this class for two frames. */
html.ghost-costume-snap .ghost-costume,
html.ghost-costume-snap .ghost-costume * {
  transition: none !important;
}
