/* Bedtime in Scribblemoor on the website (templates/world_bedtime.html; docs/bedtime.md "The website").
 * A dusk sky and a row of homes on Bedtime Street, drawn in code: no characters. Landscape first, then portrait. */
html, body { margin: 0; height: 100%; }
.bt-body {
  background: #1F2550;
  color: #FFF6DE;
  font-family: "Baloo 2", "Nunito", system-ui, sans-serif;
  overflow: hidden;
}
.bt {
  position: fixed; inset: 0;
  background: linear-gradient(180deg, #1B2048 0%, #2E3470 45%, #5B4E86 75%, #8A6A8E 100%);
  transition: background 2s ease;
}
.bt.is-night { background: linear-gradient(180deg, #11142E 0%, #1B2048 55%, #2A2A5C 100%); }
.bt-h {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* the sky */
.bt-sky { position: absolute; inset: 0 0 30% 0; }
.bt-star {
  position: absolute; width: 4px; height: 4px; border-radius: 50%; background: #FFF6DE; opacity: .75;
  animation: bt-twinkle 5s ease-in-out infinite; animation-delay: calc(var(--d, 0s) * -1);
}
@keyframes bt-twinkle { 0%, 100% { opacity: .35; } 50% { opacity: .85; } }
.bt-moon { position: absolute; top: 7%; right: 9%; width: clamp(56px, 9vmin, 96px); height: auto; }
.bt-moon path { fill: #FFE7A3; }

/* Bedtime Street: one home per goodnight line, its window lit until that line has played */
.bt-street {
  position: absolute; left: 0; right: 0; bottom: 0; height: 30%;
  display: flex; align-items: flex-end; justify-content: space-evenly; gap: 1vw;
  padding: 0 4vw; box-sizing: border-box;
  background: linear-gradient(180deg, transparent 0%, transparent 70%, #2B2A4A 70%);
}
.bt-home { display: flex; flex-direction: column; align-items: center; width: min(13vw, 22vh); }
.bt-roof {
  width: 0; height: 0;
  border-left: calc(min(13vw, 22vh) / 2) solid transparent; border-right: calc(min(13vw, 22vh) / 2) solid transparent;
  border-bottom: calc(min(13vw, 22vh) * .42) solid #4A3F6B;
}
.bt-house {
  position: relative; width: 82%; aspect-ratio: 1 / .85; background: #6B5A8C;
  border: 3px solid #2B2346; border-top: 0; box-sizing: border-box; margin-bottom: 21%;
}
.bt-window {
  position: absolute; left: 18%; top: 18%; width: 36%; height: 34%; border-radius: 4px;
  background: #FFD978; box-shadow: 0 0 18px 6px rgba(255, 210, 110, .55);
  border: 3px solid #2B2346; box-sizing: border-box;
  transition: background 1.6s ease, box-shadow 1.6s ease;
}
.bt-door {
  position: absolute; right: 14%; bottom: 0; width: 22%; height: 52%; border-radius: 6px 6px 0 0;
  background: #3A2F5A; border: 3px solid #2B2346; border-bottom: 0; box-sizing: border-box;
}
.bt-home.is-dark .bt-window { background: #2E2A52; box-shadow: none; }

/* the story, over the dusk: full screen, the film's own shape */
.bt-player { position: absolute; inset: 0; background: #11142E; display: flex; align-items: center; justify-content: center; }
.bt-player[hidden] { display: none; }
.bt-video { width: 100%; height: 100%; object-fit: contain; background: #11142E; }
.bt-video::cue { font-size: 1.15em; background: rgba(17, 20, 46, .78); color: #FFF6DE; }

/* the goodnight's words */
.bt-say {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); margin: 0;
  width: min(82vw, 760px); text-align: center;
  font-size: clamp(22px, 4.4vmin, 40px); line-height: 1.3; font-weight: 700;
  text-shadow: 0 2px 10px rgba(10, 10, 30, .7);
  opacity: 0; transition: opacity .9s ease;
}
.bt-say.is-on { opacity: 1; }

/* no fresh start from a grown-up: a calm card, and the way back to the map */
.bt-wait {
  position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); width: min(82vw, 620px);
  text-align: center;
}
.bt-wait[hidden] { display: none; }
.bt-wait__p { margin: 0 0 18px; font-size: clamp(22px, 4.4vmin, 38px); font-weight: 700; line-height: 1.3; }
.bt-wait__back {
  display: inline-block; padding: 14px 26px; border-radius: 16px; border: 3px solid #FFF6DE;
  color: #FFF6DE; background: #3A3F7A; font-size: clamp(18px, 3vmin, 24px); font-weight: 700; text-decoration: none;
}
.bt-wait__back:focus-visible { outline: 4px solid #FFD978; outline-offset: 4px; }

/* only when the browser wouldn't start the sound by itself: one calm button */
.bt-start { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.bt-start[hidden] { display: none; }
.bt-play {
  width: 120px; height: 120px; border-radius: 50%; border: 4px solid #FFF6DE; background: #3A3F7A; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.bt-play svg { width: 56px; height: 56px; }
.bt-play path { fill: #FFF6DE; }
.bt-play:focus-visible { outline: 4px solid #FFD978; outline-offset: 4px; }

/* portrait: taller street, smaller moon */
@media (orientation: portrait) {
  .bt-sky { inset: 0 0 24% 0; }
  .bt-street { height: 24%; padding: 0 2vw; }
  .bt-home { width: 15vw; }
  .bt-roof { border-left-width: 7.5vw; border-right-width: 7.5vw; border-bottom-width: 6.3vw; }
  .bt-say { top: 36%; }
}

/* calm motion (the grown-ups' setting) and the device's own reduce-motion: nothing twinkles */
.mdwp-calm .bt-star { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .bt-star { animation: none; }
  .bt, .bt-window, .bt-say { transition: none; }
}
