/* public/styles/night-sky.css */

/*
 * The night look (`LOOKS.dark` in `src/looks.ts`): the night sky under every page, drawn in CSS, with deep
 * indigo, violet glows of nebulae, a slanting milky way and two tiles of small stars. It hangs on `<body>`, so it
 * scrolls with the page; nothing in it is fixed to the window. Its colours are the `--color-night-*` tokens of
 * `src/tailwind.css`, and the token block keyed on the same body class makes the contract's surfaces dark.
 */

.night-sky {
  background-color: var(--color-night-indigo);
  background-image:
    url('/public/media/banner/sky-stars.svg'), url('/public/media/banner/sky-stars-wide.svg'),
    linear-gradient(
      158deg,
      transparent 0 34%,
      rgb(from var(--color-night-milky-way-blue) r g b / 0.5) 41%,
      rgb(from var(--color-night-milky-way-light) r g b / 0.24) 46%,
      rgb(from var(--color-night-milky-way-violet) r g b / 0.45) 51%,
      transparent 59%
    ),
    radial-gradient(
      ellipse 560px 320px at 18% 340px,
      rgb(from var(--color-night-nebula-blue) r g b / 0.6),
      transparent 70%
    ),
    radial-gradient(
      ellipse 640px 380px at 82% 820px,
      rgb(from var(--color-night-nebula-violet) r g b / 0.5),
      transparent 70%
    ),
    radial-gradient(
      ellipse 520px 320px at 12% 1500px,
      rgb(from var(--color-night-nebula-deep) r g b / 0.6),
      transparent 70%
    ),
    radial-gradient(
      ellipse 600px 360px at 88% 2200px,
      rgb(from var(--color-night-nebula-violet) r g b / 0.45),
      transparent 70%
    ),
    radial-gradient(
      ellipse 560px 340px at 20% 3000px,
      rgb(from var(--color-night-nebula-blue) r g b / 0.55),
      transparent 70%
    ),
    radial-gradient(
      ellipse 640px 380px at 80% 3800px,
      rgb(from var(--color-night-nebula-deep) r g b / 0.55),
      transparent 70%
    ),
    radial-gradient(
      ellipse 560px 340px at 15% 4600px,
      rgb(from var(--color-night-nebula-violet) r g b / 0.45),
      transparent 70%
    ),
    linear-gradient(180deg, var(--color-night-indigo) 0, var(--color-night-blue) 55%, var(--color-night-indigo) 100%);
  background-repeat:
    repeat, repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat;
  background-size:
    480px 420px,
    730px 610px,
    100% 1500px,
    auto,
    auto,
    auto,
    auto,
    auto,
    auto,
    auto,
    100% 100%;
  background-position:
    0 0,
    211px 157px,
    0 200px,
    0 0,
    0 0,
    0 0,
    0 0,
    0 0,
    0 0,
    0 0,
    0 0;
}

/*
 * The home banner's last stretch fades into the sky of the page, with no hard lower edge; the phone's taller
 * banner keeps its subtitle clear of the fade.
 */
.night-sky .night-banner {
  --night-banner-fade-from: 76%;
  -webkit-mask-image: linear-gradient(180deg, #000 var(--night-banner-fade-from), transparent 100%);
  mask-image: linear-gradient(180deg, #000 var(--night-banner-fade-from), transparent 100%);
}
@media (min-width: 48rem) {
  .night-sky .night-banner {
    --night-banner-fade-from: 68%;
  }
}

/*
 * The sky strip of a page without the banner: 140 px in the flow, its picture fading into the sky by 170 px and
 * its stars reaching on to 300 px, under the text.
 */
.night-sky .sky-strip {
  --sky-strip-height: 140px;
  --sky-strip-title-gap: 20px;
  --sky-strip-backdrop-height: 300px;
  --sky-strip-picture-height: 170px;
  --sky-strip-title-color: var(--color-night-text);
}
.night-sky .sky-strip-picture {
  -webkit-mask-image: linear-gradient(180deg, #000 0, #000 115px, transparent 170px);
  mask-image: linear-gradient(180deg, #000 0, #000 115px, transparent 170px);
}

/*
 * Text stands on this veil, scrolling with the content: clear at the top, then rising to its full strength,
 * with a wider, softer band of extra dark under the text column. Its strength gives paragraphs 7:1 even over
 * the brightest star; the sky shows through it beside the column and, more faintly, under it. Under the home
 * banner it starts in the banner's fading foot; under the sky strip, at the strip's foot.
 */
.night-sky .page-body-banner {
  --veil-top: -100px;
  --veil-ramp: 160px;
}
.night-sky .page-body-strip {
  --veil-top: 110px;
  --veil-ramp: 70px;
}
.night-sky .page-body-veil {
  display: block;
  position: absolute;
  inset: var(--veil-top) 0 0 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(
      90deg,
      rgb(from var(--color-night-navy) r g b / 0) calc(50% - 640px),
      rgb(from var(--color-night-navy) r g b / 0.6) calc(50% - 360px),
      rgb(from var(--color-night-navy) r g b / 0.6) calc(50% + 360px),
      rgb(from var(--color-night-navy) r g b / 0) calc(50% + 640px)
    ),
    linear-gradient(rgb(from var(--color-night-navy) r g b / 0.55), rgb(from var(--color-night-navy) r g b / 0.55));
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 var(--veil-ramp));
  mask-image: linear-gradient(180deg, transparent 0, #000 var(--veil-ramp));
}

/*
 * The heading of a message screen, such as the page not found, in the strip title's face, colour and dark patch,
 * with no glow.
 */
.night-sky main h1 {
  position: relative;
  isolation: isolate;
  align-self: flex-start;
  width: fit-content;
  color: var(--color-night-text);
  font-family: 'Dancing Script', cursive;
  font-weight: 700;
  font-size: 2.75rem;
  line-height: 1.1;
  letter-spacing: 0.005em;
  -webkit-text-stroke: 0.03em currentColor;
  paint-order: stroke fill;
}
.night-sky main h1::before {
  content: '';
  position: absolute;
  inset: -20px -32px;
  z-index: -1;
  pointer-events: none;
  border-radius: 999px;
  background: rgb(from var(--color-night-shade) r g b / 0.82);
  filter: blur(16px);
}

/* Paragraphs on the sky in the text colour, over 7:1 on the veil. */
.night-sky .prose p,
.night-sky .prose em {
  color: var(--color-night-text);
  line-height: 1.75;
}

/* Film titles on the sky in its text colour, with the banner title's stroke and no glow. */
.night-sky .night-banner-feed h2 {
  color: var(--color-night-text);
  -webkit-text-stroke: 0.03em currentColor;
  paint-order: stroke fill;
}

/*
 * The menu button, the menu drawer, the draft badge and the footer tab: a dark glass in the sky's navy with a
 * lavender edge. The contract's glass saturates what lies behind it so much that over the banner it turns a
 * bright royal blue; here it only blurs it, a little more opaque, so the light text keeps its contrast.
 */
.night-sky {
  /* The edge of every dark glass on the sky: a light lavender strong enough to show the shape at once. */
  --night-glass-edge: rgb(from var(--color-night-lavender) r g b / 0.75);
}
.night-sky .glass,
.night-sky .footer-tab > div {
  background: linear-gradient(
    135deg,
    rgb(from var(--color-night-navy) r g b / 0.86) 0%,
    rgb(from var(--color-night-navy) r g b / 0.9) 55%,
    rgb(from var(--color-night-navy) r g b / 0.84) 100%
  );
  border-color: var(--night-glass-edge);
  -webkit-backdrop-filter: blur(24px) saturate(110%);
  backdrop-filter: blur(24px) saturate(110%);
}
/* Keyboard focus on a link reads on the night as the buttons' does: the lavender ring, not the browser's blue. */
.night-sky :is(.link, .link-plain, .link-cta, .link-back):focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
}

/*
 * Over the banner's mid-tones neither the light edge nor the dark fill stands out from the sky, so the button
 * and the badge carry a crisp dark ring outside the edge, with no blur: the lavender always has a dark
 * neighbour.
 */
.night-sky .glass {
  box-shadow: 0 0 0 1px rgb(from var(--color-night-shade) r g b / 0.8);
}
