/* Waking (sleep-view.mjs, sleep spec §2 and §3). The black is a veil under
   the cast, so only the dreamer stays lit; the hand dims with the stage; the
   DREAM card is the dialogue's front beat. --sleep-ms is the current beat's
   fade, a crossfade under reduced motion. */
.sleep-veil {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #030409;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--sleep-ms, 0ms) ease-in-out;
}
.stage:is(
    [data-sleep="fade"],
    [data-sleep="held"],
    [data-sleep="enter"],
    [data-sleep="dreaming"],
    [data-sleep="dream"],
    [data-sleep="quest"]
  )
  > .sleep-veil {
  opacity: 1;
}
/* A sleep that crosses no light only dims and lifts. */
.stage[data-sleep="dim"] > .sleep-veil {
  opacity: 0.55;
}
.stage[data-sleep] #cast > .portrait,
.stage[data-sleep] > .weather-layer {
  transition: opacity var(--sleep-ms, 0ms) ease-in-out;
}
.stage:is(
    [data-sleep="fade"],
    [data-sleep="held"],
    [data-sleep="enter"],
    [data-sleep="dreaming"],
    [data-sleep="dream"],
    [data-sleep="quest"]
  )
  #cast
  > .portrait:not([data-dreamer]),
.stage:is(
    [data-sleep="fade"],
    [data-sleep="held"],
    [data-sleep="enter"],
    [data-sleep="dreaming"],
    [data-sleep="dream"],
    [data-sleep="quest"]
  )
  > .weather-layer {
  opacity: 0;
}
/* The dialogue leaves with the light and comes back with the dream card,
   or with the light when there is no dream. */
body:is([data-sleep="fade"], [data-sleep="held"]) .dialogue {
  opacity: 0;
  transition: opacity var(--sleep-ms, 0ms) ease-in-out;
}
body[data-sleep] #hand > * {
  transition: filter var(--sleep-ms, 0ms) ease-in-out;
}
body:is(
    [data-sleep="fade"],
    [data-sleep="held"],
    [data-sleep="enter"],
    [data-sleep="dreaming"],
    [data-sleep="dream"],
    [data-sleep="quest"]
  )
  #hand
  > * {
  filter: brightness(0.18) saturate(0.4);
}
/* Keep the Dream cue above the hand while its card takes taps. */
body:is([data-sleep="enter"], [data-sleep="dreaming"], [data-sleep="dream"])
  main > .dialogue {
  z-index: 6;
}
/* While a wake plays, a tap anywhere finishes its beat. */
.sleep-catcher {
  position: fixed;
  inset: 0;
  z-index: 40;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.sleep-catcher[hidden] {
  display: none;
}
/* The DREAM card. Its name sits at the top in the Common tier colour
   (card-label-spec.md); its art keeps the night treatment until dream art
   arrives. */
#speech-row[data-beat="dream"] {
  background: radial-gradient(ellipse at 24% 0%, #1a2240f0, #070a14f2 72%);
  border-color: #3e4c7a88;
}
#speech-row[data-beat="dream"] #speaker {
  font:
    600 max(10px, calc(var(--card-height, 260px) * 0.042)) system-ui,
    sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  line-height: 1.18;
  color: var(--tier-color, #c8dce6);
  text-shadow:
    0 1px 2px #000,
    0 0 8px #000c;
}
#speech-row[data-beat="dream"] .speaker-portrait img {
  filter: brightness(0.62) saturate(0.55) hue-rotate(-12deg);
}
#speech-row[data-beat="dream"] #dialogue-text {
  font-style: italic;
  color: #dfe6f4;
}
/* The halfway glimpse: one aspect card beside the DREAM card, partly out of
   the dark (glimpse-card.mjs). It stands above the card's corner so it fits
   at phone width. */
.glimpse-card {
  position: absolute;
  right: 12px;
  bottom: calc(100% + 8px);
  width: 76px;
  margin: 0;
  pointer-events: none;
  animation: glimpse-in 600ms ease-out both;
}
.glimpse-face {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border: 1px solid var(--tier-color, #c9c3b4);
  border-radius: 8px;
  background: #07080d;
  color: #e9e3d4;
  font-size: 1.6rem;
}
.glimpse-face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* The dark, or the cloth, over the part not yet shown. */
.glimpse-face::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    #07080d calc((1 - var(--revealed, 0.5)) * 100%),
    transparent
  );
}
.glimpse-name {
  margin-top: 4px;
  font-size: 0.72rem;
  line-height: 1.2;
  text-align: center;
  color: var(--tier-color, #c9c3b4);
}
@keyframes glimpse-in {
  from {
    opacity: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .glimpse-card {
    animation-duration: 300ms;
  }
}
