/* Navigation glass: keep the functional layer translucent over real page content. */
@property --material-pointer-x {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 50%;
}

@property --material-pointer-y {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 0%;
}

@property --material-light-angle {
  syntax: "<angle>";
  inherits: true;
  initial-value: 118deg;
}

#demo-root :is(.top, .phone-head, .phone-tabs) {
  --material-pointer-x: 50%;
  --material-pointer-y: 0%;
  --material-glass-image:
    radial-gradient(78% 190% at var(--material-pointer-x) var(--material-pointer-y),
      color-mix(in srgb, var(--ui-text) 13%, transparent) 0%,
      color-mix(in srgb, var(--ui-accent) 8%, transparent) 27%,
      transparent 70%),
    linear-gradient(180deg, color-mix(in srgb, var(--ui-text) 9%, transparent), transparent 46%),
    var(--ui-ambient, none);
  background-color: var(--ui-glass, var(--ui-surface));
  background-image: var(--material-glass-image);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  transition-property: --material-pointer-x, --material-pointer-y, --material-light-angle;
  transition-duration: 190ms;
  transition-timing-function: cubic-bezier(.2, .8, .2, 1);
}

#demo-root .atlas-phone :is(.phone-head, .phone-tabs) {
  --material-glass-image:
    linear-gradient(var(--material-light-angle, 118deg), transparent 12%, rgb(255 255 255 / 7%) 38%, rgb(255 255 255 / 2%) 51%, transparent 74%),
    radial-gradient(48% 150% at var(--material-pointer-x) var(--material-pointer-y),
      color-mix(in srgb, var(--ui-text) 8%, transparent), color-mix(in srgb, var(--ui-accent) 4%, transparent) 32%, transparent 72%),
    linear-gradient(180deg, color-mix(in srgb, var(--ui-text) 8%, transparent), transparent 42%),
    var(--ui-ambient, none);
}

/* Match the workspace shell's more specific rules, which otherwise restore an opaque bar. */
body.demo-mode:not(.rider-mode) #demo-root .top,
#demo-root .atlas-phone .phone-head,
#demo-root .atlas-phone .phone-tabs {
  background-color: var(--ui-glass, var(--ui-surface));
  background-image: var(--material-glass-image);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  body.demo-mode:not(.rider-mode) #demo-root .top,
  #demo-root .atlas-phone .phone-head,
  #demo-root .atlas-phone .phone-tabs {
    background-color: color-mix(in srgb, var(--ui-glass, var(--ui-surface)) 76%, transparent);
    background-image: var(--material-glass-image);
    -webkit-backdrop-filter: blur(19px) saturate(155%);
    backdrop-filter: blur(19px) saturate(155%);
  }
}

body.demo-mode:not(.rider-mode) #demo-root .top {
  border-bottom-color: var(--ui-glass-line, var(--ui-line));
  box-shadow:
    0 12px 30px -23px color-mix(in srgb, var(--ui-text) 42%, transparent),
    inset 0 1px 0 color-mix(in srgb, var(--ui-text) 26%, transparent),
    inset 0 -1px 0 color-mix(in srgb, var(--ui-accent) 16%, transparent);
}

#demo-root .atlas-phone .phone-head {
  border-bottom-color: var(--ui-glass-line, var(--ui-line));
  box-shadow:
    0 10px 24px -20px color-mix(in srgb, var(--ui-text) 40%, transparent),
    inset 0 1px 0 color-mix(in srgb, var(--ui-text) 27%, transparent),
    inset 0 -1px 0 color-mix(in srgb, var(--ui-accent) 17%, transparent);
}

#demo-root .atlas-phone .phone-tabs {
  position: absolute;
  right: 14px;
  bottom: max(10px, calc(env(safe-area-inset-bottom) + 8px));
  left: 14px;
  border-top-color: var(--ui-glass-line, var(--ui-line));
  box-shadow:
    0 -12px 28px -23px color-mix(in srgb, var(--ui-text) 46%, transparent),
    inset 0 1px 0 color-mix(in srgb, var(--ui-text) 27%, transparent),
    inset 0 -1px 0 color-mix(in srgb, var(--ui-accent) 14%, transparent);
}

/* The header overlaps the live map/scroll surface so its backdrop is never a flat page color. */
#demo-root .atlas-phone .phone-head {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
}

#demo-root .atlas-phone.has-map :is(.phone-map-label, .phone-map-controls) {
  top: calc(12px + 64px + env(safe-area-inset-top));
}

#demo-root .atlas-phone.no-map .phone-scroll {
  padding-top: calc(16px + 64px + env(safe-area-inset-top));
}

/* The fixed tabs float above the real scroll layer; leave room for its last row. */
#demo-root .atlas-phone .phone-scroll {
  padding-bottom: calc(112px + env(safe-area-inset-bottom));
}

/* Sheets and tables stay content surfaces; only the sheet edge and grab handle catch light. */
#demo-root .phone-sheet {
  border-top: 1px solid color-mix(in srgb, var(--ui-glass-line, var(--ui-line)) 76%, transparent);
  background: var(--ui-surface);
  box-shadow:
    var(--phone-shadow, var(--ui-shadow)),
    0 -1px 0 color-mix(in srgb, var(--ui-text) 9%, transparent),
    inset 0 1px 0 color-mix(in srgb, var(--ui-text) 10%, transparent);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

#demo-root .phone-grab {
  background-color: var(--ui-surface);
  background-image: linear-gradient(180deg,
    color-mix(in srgb, var(--ui-accent) 7%, var(--ui-surface)),
    var(--ui-surface) 74%);
}

#demo-root .phone-grab > span {
  box-shadow: 0 1px 0 color-mix(in srgb, var(--ui-text) 16%, transparent);
}

#demo-root .phone-grab:active > span {
  width: 44px;
  background: var(--ui-accent);
}

#demo-root :is(.demo-table-wrap, .demo-table) {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

#demo-root :is(.top, .phone-head, .phone-tabs) :is(button, a, [role="button"]):active:not(:disabled) {
  filter: brightness(.94);
}

@media (prefers-reduced-motion: reduce) {
  #demo-root :is(.top, .phone-head, .phone-tabs) {
    transition: none;
  }

  #demo-root .phone-grab > span {
    transition: none;
  }
}

@media (prefers-reduced-transparency: reduce) {
  body.demo-mode:not(.rider-mode) #demo-root .top,
  #demo-root .atlas-phone .phone-head,
  #demo-root .atlas-phone .phone-tabs {
    background-color: var(--ui-surface);
    background-image: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

@media (forced-colors: active) {
  body.demo-mode:not(.rider-mode) #demo-root .top,
  #demo-root .atlas-phone :is(.phone-head, .phone-tabs, .phone-sheet) {
    color: CanvasText;
    border-color: ButtonBorder;
    background: Canvas;
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  #demo-root .phone-grab > span {
    background: ButtonText;
    box-shadow: none;
  }
}

/* The phone dock filters only its backdrop; its labels and icons stay crisp. */
#demo-root .atlas-phone .phone-tabs {
  isolation: isolate;
  overflow: visible;
  height: 72px;
  border: 1px solid color-mix(in srgb, var(--ui-glass-line, var(--ui-line)) 88%, transparent);
  border-radius: 999px;
  background-color: color-mix(in srgb, var(--ui-surface) 90%, transparent);
  background-image: var(--material-glass-image);
  box-shadow:
    0 16px 34px -19px color-mix(in srgb, var(--ui-text) 45%, transparent),
    inset 0 1px 0 color-mix(in srgb, var(--ui-text) 28%, transparent),
    inset 0 -1px 0 color-mix(in srgb, var(--ui-accent) 18%, transparent);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  transition: --material-pointer-x 190ms cubic-bezier(.2, .8, .2, 1), --material-pointer-y 190ms cubic-bezier(.2, .8, .2, 1), --material-light-angle 190ms cubic-bezier(.2, .8, .2, 1);
}

/* A thin directional rim reflects light without putting a lens over the content. */
@supports ((mask-composite: exclude) or (-webkit-mask-composite: xor)) {
#demo-root .atlas-phone :is(.phone-head, .phone-tabs)::after {
  position: absolute;
  z-index: 2;
  inset: 0;
  padding: 1px;
  border-radius: inherit;
  background: linear-gradient(var(--material-light-angle, 118deg), rgb(255 255 255 / 58%), rgb(255 255 255 / 7%) 24%, transparent 47%, rgb(255 255 255 / 22%) 78%, rgb(255 255 255 / 44%));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  content: "";
  pointer-events: none;
}
#demo-root .atlas-phone .phone-head::after { opacity: .35; }
}

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  #demo-root .atlas-phone .phone-tabs {
    background-color: color-mix(in srgb, var(--ui-glass, var(--ui-surface)) 32%, transparent);
    -webkit-backdrop-filter: blur(6px) saturate(145%);
    backdrop-filter: blur(6px) saturate(145%);
  }
}

html.supports-phone-glass-refraction #demo-root .atlas-phone .phone-tabs {
  -webkit-backdrop-filter: blur(6px) saturate(145%);
  backdrop-filter: url("#phone-glass-refraction") blur(6px) saturate(145%);
}

#demo-root .atlas-phone .phone-tabs::before {
  position: absolute;
  z-index: 0;
  top: 6px;
  bottom: 6px;
  left: 6px;
  width: calc((100% - 14px) / 3);
  border: 1px solid color-mix(in srgb, var(--ui-text) 13%, transparent);
  border-radius: 999px;
  background:
    linear-gradient(112deg, transparent 5%, color-mix(in srgb, var(--ui-text) 8%, transparent) 38%, color-mix(in srgb, var(--ui-text) 2%, transparent) 54%, transparent 84%),
    linear-gradient(180deg, color-mix(in srgb, var(--ui-glass, var(--ui-surface)) 25%, transparent), color-mix(in srgb, var(--ui-accent) 8%, transparent));
  box-shadow:
    0 5px 13px -9px color-mix(in srgb, var(--ui-text) 52%, transparent),
    inset 0 1px 0 color-mix(in srgb, var(--ui-text) 26%, transparent),
    inset 0 -1px 0 color-mix(in srgb, var(--ui-accent) 12%, transparent);
  content: "";
  pointer-events: none;
  transform: translateX(var(--material-lens-x, 0px));
  transition: transform 260ms cubic-bezier(.2, .8, .2, 1);
}

#demo-root .atlas-phone .phone-tabs .phone-tab {
  z-index: 1;
  min-height: 52px;
  border-radius: 999px;
  color: var(--phone-muted);
  font-size: 11px;
  letter-spacing: .01em;
  text-shadow: 0 1px 4px var(--ui-bg), 0 0 8px var(--ui-bg);
}

#demo-root .atlas-phone .phone-tabs .phone-tab::before { content: none; }
#demo-root .atlas-phone .phone-tabs .phone-tab.active { color: var(--phone-ink); }
#demo-root .atlas-phone .phone-tabs :is(button, a, [role="button"]):active:not(:disabled) { filter: none; }

@media (prefers-reduced-motion: reduce) {
  #demo-root .atlas-phone .phone-tabs,
  #demo-root .atlas-phone .phone-tabs::before { transition: none; }
}

@media (prefers-reduced-transparency: reduce) {
  #demo-root .atlas-phone :is(.phone-head, .phone-tabs)::after { content: none; }
  #demo-root .atlas-phone .phone-tabs {
    background-color: var(--ui-surface);
    background-image: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  #demo-root .atlas-phone .phone-tabs::before {
    border-color: color-mix(in srgb, var(--ui-accent) 42%, var(--ui-line));
    background: var(--phone-raised);
    box-shadow: none;
  }
}

@media (forced-colors: active) {
  #demo-root .atlas-phone :is(.phone-head, .phone-tabs)::after { content: none; }
  html.supports-phone-glass-refraction #demo-root .atlas-phone .phone-tabs,
  #demo-root .atlas-phone .phone-tabs {
    background: Canvas;
    border-color: ButtonBorder;
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  #demo-root .atlas-phone .phone-tabs::before {
    border: 1px solid Highlight;
    background: Highlight;
    box-shadow: none;
  }

  #demo-root .atlas-phone .phone-tabs .phone-tab.active { color: HighlightText; }
}
