/* A shared night sky behind the entire document. */
:root {
  --sky-night: #060a13;
  --sky-fallback:
    radial-gradient(ellipse 123% 103% at 82% -13%, #1a2940, #1722389a 45%, #0c13242b 69%, transparent 86%),
    linear-gradient(143deg, #080e1b, var(--sky-night) 74%);
}
html { background: var(--sky-night); overflow-x: clip; }
body { min-height: 100svh; isolation: isolate; background: var(--sky-fallback); }
body.environment-ready { background: var(--sky-night); }
html.ld #loader { background: var(--sky-fallback); }

body.glimmer-home {
  --sky-night: #050912;
  --sky-fallback:
    radial-gradient(ellipse 123% 103% at 82% -13%, #142136, #131d309a 45%, #0b12222b 69%, transparent 86%),
    linear-gradient(143deg, #070c18, var(--sky-night) 74%);
}

.environment {
  position: fixed;
  z-index: -1;
  inset: 0 auto 0 0;
  inline-size: 100vw;
  inline-size: 100svw;
  max-inline-size: 100%;
  pointer-events: none;
  overflow: hidden;
  contain: strict;
  background: var(--sky-fallback);
}
.environment-fill, .environment-key {
  position: absolute;
  inset: -12%;
}
.environment-fill {
  background:
    url("img/sky-diffusion.webp") center / 100% 100% no-repeat,
    radial-gradient(ellipse 112% 91% at 35% 74%, #30274c65, #2230523d 42%, #111a2c18 67%, transparent 88%);
  opacity: .7;
}
.environment-key {
  background:
    radial-gradient(ellipse 97% 87% at 91% 28%, #43688860 0%, #32547553 32%, #25486232 58%, #162a3d14 76%, transparent 94%),
    radial-gradient(ellipse 88% 46% at 77% 39%, #6791b02b, #3e668126 44%, transparent 91%);
  opacity: .4;
}
/* Overscan leaves room to move and narrow the light without exposing the texture's edges. */
.glimmer-home .environment-key {
  --key-origin: 72.5% 33.75%;
  inset: -34% -63%;
  transform-origin: var(--key-origin);
  background:
    radial-gradient(ellipse 53.2% 64.2% at var(--key-origin), #43688860 0%, #32547553 32%, #25486232 58%, #162a3d14 76%, transparent 94%),
    radial-gradient(ellipse 48.3% 33.9% at 64.8% 41.9%, #6791b02b, #3e668126 44%, transparent 91%);
}
.glimmer-home[data-wallpaper-light="space"] { --sky-hue: 12deg; --sky-saturation: 1.06; --wallpaper-reflection: .31; }
.glimmer-home[data-wallpaper-light="ocean"] { --sky-hue: -21deg; --sky-saturation: 1.10; --wallpaper-reflection: .38; }
.glimmer-home[data-wallpaper-light="dusk"] { --sky-hue: 34deg; --sky-saturation: 1.16; --wallpaper-reflection: .43; }
.glimmer-home .environment-fill { --ambient-brightness: .8; }
.glimmer-home :is(.environment-fill, .environment-key) {
  filter:hue-rotate(var(--sky-hue, 0deg)) saturate(var(--sky-saturation, 1)) brightness(var(--ambient-brightness, 1));
  transition:filter var(--wallpaper-light-time) var(--ease);
}
.environment-stars, .environment-middle, .environment-near {
  position: absolute;
  inset: -7% -7% auto;
  width: 114%;
  height: 142%;
}
.environment-stars { display: block; opacity: .86; }
.environment-middle { opacity: .89; }
.environment-near { opacity: .96; }
.environment-star {
  position: absolute;
  border-radius: 50%;
  background: #c5dcf3;
  transform: translate(var(--star-x, 0px), var(--star-y, 0px));
}
.environment-star--teal { background: #a9dce7; }
.environment-star--bright { box-shadow: 0 0 3px #a4d3ff9c, 0 0 7px #8eafff52; }
.environment[data-motion="on"] .environment-star--twinkle {
  animation: environment-twinkle var(--star-period) ease-in-out var(--star-delay) infinite;
}
.environment[data-paused] .environment-star--twinkle { animation-play-state: paused; }
@keyframes environment-twinkle {
  0%, 100% { opacity: var(--star-base); }
  28% { opacity: var(--star-dim); }
  65% { opacity: var(--star-lit); }
}

.environment-comet {
  position: absolute;
  inset: 0 auto auto 0;
  width: 0;
  height: 0;
  opacity: 0;
}
.environment-comet::before, .environment-comet::after {
  content: "";
  position: absolute;
}
.environment-comet::before {
  right: 0;
  top: -3px;
  width: var(--comet-tail);
  height: 6px;
  background:
    linear-gradient(90deg, transparent 2%, #a2c6fa70 42%, #e0f0fff2) center / 100% 1.5px no-repeat,
    linear-gradient(90deg, transparent, #799fdb20 48%, #b0d7ff60) center / 100% 4px no-repeat;
  clip-path: polygon(0 50%, 100% 0, 100% 100%);
}
.environment-comet::after {
  left: -7px;
  top: -7px;
  width: 14px;
  height: 14px;
  background: radial-gradient(circle, #f4f9ff 0 11%, #c3e3ffd9 17%, #86baf64d 38%, transparent 67%);
}
.environment-links { position: absolute; inset: 0 auto auto 0; visibility: hidden; }
.environment[data-motion="on"] :is(.environment-fill, .environment-key, .environment-stars, .environment-middle, .environment-near) {
  will-change: transform;
}
@media (max-width: 700px), (pointer: coarse) {
  .environment-fill, .environment-key { inset: -9%; }
  .glimmer-home .environment-key {
    --key-origin: 71.4% 34.6%;
    background:
      radial-gradient(ellipse 50.6% 61.1% at var(--key-origin), #43688860 0%, #32547553 32%, #25486232 58%, #162a3d14 76%, transparent 94%),
      radial-gradient(ellipse 46% 32.3% at 64.1% 42.25%, #6791b02b, #3e668126 44%, transparent 91%);
  }
}
@media (hover: none), (pointer: coarse) {
  .environment-links { display: none; }
  .environment[data-motion="on"] :is(.environment-fill, .environment-key) { will-change: opacity; }
}
/* The neutral key light already has the desired colour. Its oversized layer
   can be composited directly until a scene applies a real filter. */
.glimmer-home:not([data-wallpaper-light]) .environment-key { filter:none; }
.glimmer-home .environment[data-motion="on"] :is(.environment-fill, .environment-key) { will-change:transform,opacity; }
@media (forced-colors: active) {
  .environment { display: none; }
}


/* Shared cool glass. Background colour is mostly the light behind the surface. */
.glimmer-home {
  --scene-light-duration: var(--scene-light-time, 0ms);
  --scene-light-ease: cubic-bezier(.333, 0, .667, 1);
  --wallpaper-light-time: .68s;
}
.glimmer-home[data-light-scene="morning"] {
  --scene-reflection-shape: translate3d(-28%, -12%, 0) scale(1.32, 1.12);
  --scene-reflection-strength: .90;
}
.glimmer-home[data-light-scene="evening"] {
  --scene-reflection-shape: translate3d(30%, 6%, 0) scale(.58, .68);
  --scene-reflection-strength: .80;
  --scene-orbit-opacity: .76;
}
/* Move a single reflection across each surface using the same timing as the sky. */
:where(.reflects-scene) { position: relative; }
.scene-reflection {
  display: block;
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  overflow: hidden;
}
.scene-reflection::before {
  content: "";
  position: absolute;
  inset: -35% -34%;
  background: radial-gradient(ellipse 42% 52% at 50% 34%, #c7ddff35, #aec8f018 40%, transparent);
  transform-origin: 50% 34%;
  transform: var(--scene-reflection-shape, translate3d(30%, 0, 0) scale(1));
  opacity: var(--scene-reflection-strength, var(--wallpaper-reflection, 0));
  filter: hue-rotate(var(--sky-hue, 0deg)) saturate(var(--sky-saturation, 1));
}
[data-reflection-visible] > .scene-reflection::before {
  transition: transform var(--scene-light-duration) var(--scene-light-ease),
    opacity var(--scene-light-duration) var(--scene-light-ease), filter var(--wallpaper-light-time) var(--ease);
}
@media (prefers-reduced-motion: reduce) {
  .glimmer-home { --scene-light-duration: 0s; --wallpaper-light-time: 0s; }
  [data-reflection-visible] > .scene-reflection::before, .glimmer-home .orbit-ring { transition: none; }
}

:root {
  --material-glass: radial-gradient(ellipse 91% 104% at 11% -12%, #d4eaff0d, transparent 78%),
    linear-gradient(153deg, #a9c7ef0d, #7194c006 49%, #060c181a);
  --material-action: radial-gradient(ellipse 97% 116% at 15% -17%, #d4eaff18, transparent 83%),
    linear-gradient(151deg, #a7c8ef13, #7b9dca0b 52%, #070c191e);
  --material-panel: linear-gradient(151deg, #bdd6f518, #86a2c70a 49%, #060c1924);
  --material-rim: #a9c4e43c;
  --material-top: #c7dfff52;
  --material-accent: #b7d5f268;
  --material-focus: #c0e0ff;
  --material-sheen: inset 0 1px 0 #e3eeff11, inset 0 -5px 14px #93abda06, 0 8px 22px -16px #000a;
  --material-bright: inset 0 1px 0 #eaf4ff23, inset 0 -5px 15px #99b8e308, 0 8px 24px -16px #709ce974;
  --material-blur: blur(5px) saturate(106%);
}

/* UI actions share a finish. The purchase control inherits the same tokens in pro-orbit.css. */
:is(.btn.main:not(.orbit-buy), .btn.ghost, .top nav a.pill, .top nav a.top-profile, .cb-btn:not(.bad)) {
  --material-control: var(--material-glass);
  background: var(--material-control);
  color: #e5effc;
  border: 1px solid var(--material-rim);
  border-top-color: var(--material-top);
  box-shadow: var(--material-sheen);
  -webkit-backdrop-filter: var(--material-blur);
  backdrop-filter: var(--material-blur);
}
:is(.btn.main:not(.orbit-buy), .top nav a.pill, .cb-btn:not(.ghost, .bad)) {
  --material-control: var(--material-action);
  border-color: var(--material-accent);
  border-top-color: #cee4ff74;
  box-shadow: var(--material-bright);
  color: #f2f7ff;
}
:is(.btn.main:not(.orbit-buy), .btn.ghost, .top nav a.pill, .top nav a.top-profile, .cb-btn:not(.bad)):hover {
  background: var(--material-control);
  border-color: #c1dcfa6e;
  border-top-color: #d1e6ff8a;
  box-shadow: var(--material-bright);
  color: #f6faff;
}
:is(.btn.main:not(.orbit-buy), .btn.ghost, .top nav a.pill, .top nav a.top-profile, .cb-btn:not(.bad)):focus-visible {
  outline: 2px solid var(--material-focus);
  outline-offset: 4px;
}
:is(.btn.main:not(.orbit-buy), .btn.ghost, .cb-btn:not(.bad)):active {
  box-shadow: inset 0 2px 7px #050a1654;
}

:is(.glimmer-home .bcard, .pcard, .cb-card:not(.danger), .release-bronze .release-head, .glimmer-home .scene-library),
#pro :is(.pro-showcase, .pro-details) {
  background: var(--material-panel);
  border-color: var(--material-rim);
  border-top-color: var(--material-top);
  box-shadow: var(--material-sheen);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
:is(.glimmer-home .bcard, .pcard, .cb-card:not(.danger)):is(:hover, :focus-within) {
  border-color: #a5c8f259;
  border-top-color: #c7e1ff73;
  box-shadow: var(--material-bright);
}
:is(.feature-playground .feature-controls button, .chips .chip) {
  background: var(--material-glass);
  box-shadow: inset 0 1px 0 #dcebff0f, inset 0 0 0 1px #b8d3f420;
}
:is(.feature-playground .feature-controls button, .compare-views button, .chips .chip)[aria-pressed="true"] {
  background: var(--material-action);
  border-color: var(--material-accent);
  box-shadow: inset 0 1px 0 #dcebff20, inset 0 0 0 1px #b8d3f437;
  color: #e8f1ff;
}
.feature-controls button[aria-pressed="true"]::before {
  background: #c2daff;
  box-shadow: 0 0 7px #96b8ff35;
}
.environment-ready :is(.bar.scrolled, .cb-head, .dhead, .updates-bar) {
  background: #070d1ac4;
  border-bottom-color: #a2bbde25;
}
/* A cool reflection keeps the navigation glass lit over the dark bar. */
.glimmer-home .bar .top nav a:is(.pill, .top-profile) {
  position: relative;
  isolation: isolate;
}
.glimmer-home .bar .top nav a:is(.pill, .top-profile)::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  border-radius: inherit;
  background:
    radial-gradient(ellipse 105% 110% at 26% -20%, #cbdfff29, transparent 82%),
    linear-gradient(160deg, #a5c9f124, #8eafe713 58%, #6d9cd00d);
  opacity: 0;
  transition: opacity .25s ease;
}
.glimmer-home .bar.scrolled .top nav a:is(.pill, .top-profile)::before { opacity: 1; }

.top-brand {
  position: relative;
  container: glimmer-brand / inline-size;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 0;
  flex: 1 1 0;
  min-inline-size: 44px;
  font-size: clamp(.73rem, .57rem + .55vw, 1.05rem);
  pointer-events: none;
}
.dhead-in .top-brand {
  justify-self: center;
  inline-size: 156px;
  max-inline-size: 100%;
}
.cb-logo.top-brand { flex: 0 1 156px; }
.top-brand-icon {
  display: grid;
  align-items: center;
  min-block-size: 44px;
  pointer-events: auto;
  border-radius: 8px;
}
.top-brand-name {
  font-size: min(1em, 8cqi);
  justify-self: start;
  max-inline-size: 100%;
  overflow: hidden;
  white-space: nowrap;
  color: #e7f1ff;
  opacity: 0;
  clip-path: inset(0 100% 0 0);
  transform: translateX(-6px);
  transition: opacity .2s ease, clip-path .34s var(--ease), transform .34s var(--ease);
}
@container glimmer-brand (max-width: 154px) {
  .top-brand-name {
    position: absolute;
    inset: calc(100% + 15px) auto auto 0;
    max-inline-size: none;
    font-size: inherit;
    padding: 4px 9px;
    border: 1px solid var(--material-rim);
    border-radius: 8px;
    background-color: #0e1929eb;
    background-image: var(--material-glass);
  }
}
.top-brand:focus-visible { outline: none; }
.top-brand:focus-visible .top-brand-icon {
  outline: 2px solid var(--material-focus);
  outline-offset: 3px;
}
.top-brand:focus-visible .top-brand-name {
  opacity: 1;
  clip-path: inset(0);
  transform: none;
}
@media (hover: hover) and (pointer: fine) {
  .top-brand:is(:hover, .brand-revealed) .top-brand-name {
    opacity: 1;
    clip-path: inset(0);
    transform: none;
    pointer-events: auto;
  }
}
@media (prefers-reduced-motion: reduce) {
  .top-brand-name,
  .glimmer-home .bar .top nav a:is(.pill, .top-profile)::before { transition: none; }
}

@media (hover: hover) and (pointer: fine) {
  .cb-card:not(.danger) { transition: border-color .22s, box-shadow .24s; }
}
@media (max-width: 700px), (pointer: coarse) {
  :root { --material-blur: blur(3px); }
  :is(.glimmer-home .bcard, .pcard, .cb-card:not(.danger), .release-bronze .release-head, .glimmer-home .scene-library),
  #pro :is(.pro-showcase, .pro-details) {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .cb-card:not(.danger) { transition: none; }
}
