/* Phase 3: approved frame/crystal pairs, preserved at their original resolution.
   Phase 2 owns hit targets and sizing; the existing elements own all actions. */
body .asteria-menu-button {
  --asteria-approved-frame:url("../assets/ui/buttons/button-standard-frame.webp");
  --asteria-approved-crystal:url("../assets/ui/buttons/button-standard-crystal.webp");
  --asteria-crystal-brightness:1;
}
body .asteria-menu-button[data-asteria-button-size="small"] {
  --asteria-approved-frame:url("../assets/ui/buttons/button-small-frame.webp");
  --asteria-approved-crystal:url("../assets/ui/buttons/button-small-crystal.webp");
}
body .asteria-menu-button[data-asteria-button-size="long"] {
  --asteria-approved-frame:url("../assets/ui/buttons/button-long-frame.webp");
  --asteria-approved-crystal:url("../assets/ui/buttons/button-long-crystal.webp");
}
body .asteria-menu-button[data-asteria-button-size="icon"] {
  --asteria-approved-frame:url("../assets/ui/buttons/button-icon-frame.webp");
  --asteria-approved-crystal:url("../assets/ui/buttons/button-icon-crystal.webp");
}
body :is(.asteria-menu-button,#globalNavigation > .crystal-button) {
  border-image:none!important;
  background:transparent!important;
  box-shadow:none!important;
}
/* Honour Phase 2 metadata over the legacy ID-scoped 48px minimum and 28px
   side padding, including classified buttons outside the top navigation. */
body :is(.asteria-menu-button,#globalNavigation > .crystal-button)[data-asteria-button-size] {
  min-height:var(--asteria-button-design-height)!important;
  padding-inline:var(--asteria-button-inline-padding)!important;
  font-size:var(--asteria-button-text-size)!important;
}
/* The supplied metal stays stationary and untinted, above the crystal. Remove
   the old generated bezel, polygon clipping and SVG sidewall from this skin. */
body :is(.asteria-menu-button,#globalNavigation > .crystal-button)::before {
  content:""!important;
  position:absolute!important;
  inset:0!important;
  z-index:-1!important;
  pointer-events:none!important;
  background:var(--asteria-approved-frame) center / 100% 100% no-repeat!important;
  background-blend-mode:normal!important;
  border:0!important;
  border-radius:0!important;
  box-shadow:none!important;
  clip-path:none!important;
  mask:none!important;
  -webkit-mask:none!important;
  transform:none!important;
  filter:none!important;
}
/* Alpha masking prevents a rectangular tint outside the supplied crystal.
   Luminosity keeps its authored facets/highlights while the existing independent
   top-menu, dashboard and compendium colours affect only this inner layer. */
body :is(.asteria-menu-button,#globalNavigation > .crystal-button)::after {
  content:""!important;
  position:absolute!important;
  inset:0!important;
  z-index:-2!important;
  pointer-events:none!important;
  background:var(--button-crystal-color,#1f7dff) var(--asteria-approved-crystal) center / 100% 100% no-repeat!important;
  background-blend-mode:luminosity!important;
  border:0!important;
  border-radius:0!important;
  box-shadow:none!important;
  clip-path:none!important;
  -webkit-mask-image:var(--asteria-approved-crystal)!important;
  mask-image:var(--asteria-approved-crystal)!important;
  -webkit-mask-size:100% 100%!important;
  mask-size:100% 100%!important;
  -webkit-mask-position:center!important;
  mask-position:center!important;
  -webkit-mask-repeat:no-repeat!important;
  mask-repeat:no-repeat!important;
  transform:translateY(var(--button-travel,0px))!important;
  filter:brightness(var(--asteria-crystal-brightness)) drop-shadow(0 0 calc(var(--asteria-glow-intensity,.36) * 8px) var(--button-crystal-glow))!important;
}
body .asteria-menu-button:is(.active,[aria-selected="true"],[aria-pressed="true"],[aria-current="page"],[aria-expanded="true"]) {--asteria-crystal-brightness:1.15;}
body .asteria-menu-button:not(:disabled):not([aria-disabled="true"]):hover {--asteria-crystal-brightness:1.2;}
body .asteria-menu-button:not(:disabled):not([aria-disabled="true"]):is(:active,[data-menu-pressed]) {--asteria-crystal-brightness:1.3;}
body .asteria-menu-button:is(:disabled,[aria-disabled="true"]) {--asteria-crystal-brightness:1;}
@media (prefers-reduced-motion:reduce) {
  body :is(.asteria-menu-button,#globalNavigation > .crystal-button)::before,
  body :is(.asteria-menu-button,#globalNavigation > .crystal-button)::after {
    transform:none!important;
    transition:none!important;
  }
}


/* Phase 4 — image fidelity: three-slice the APPROVED source images.
   Do not resize, replace or recolour the silver/gold artwork. CSS border-image
   stretches only the unornamented central strip; pointed ends retain fixed
   pixel widths. The icon family is an intentionally square image and is
   never three-sliced. The live HTML label remains independent. */
body .asteria-menu-button {
  --asteria-button-source-cap:13%;
  --asteria-button-render-cap:28px;
}
body .asteria-menu-button[data-asteria-button-size="small"] {
  --asteria-button-source-cap:14%;
  --asteria-button-render-cap:24px;
}
body .asteria-menu-button[data-asteria-button-size="standard"] {
  --asteria-button-source-cap:13%;
  --asteria-button-render-cap:28px;
}
body .asteria-menu-button[data-asteria-button-size="long"] {
  --asteria-button-source-cap:12%;
  --asteria-button-render-cap:42px;
}
body .asteria-menu-button[data-asteria-button-size="icon"] {
  --asteria-button-source-cap:0%;
  --asteria-button-render-cap:0px;
}

/* Preserve the pointed steel ends and thin top/bottom bevel at any width.
   The full transparent frame is kept in ::before and the crystal in ::after.
   border-image works with a zero-width transparent border in Chromium.
   The 'fill' keyword draws the image's centre strip between the endcaps. */
body :is(.asteria-menu-button,#globalNavigation > .crystal-button):not([data-asteria-button-size="icon"])::before {
  background:none!important;
  border:0 solid transparent!important;
  border-image-source:var(--asteria-approved-frame)!important;
  border-image-slice:0 var(--asteria-button-source-cap) 0 var(--asteria-button-source-cap) fill!important;
  border-image-width:0 var(--asteria-button-render-cap) 0 var(--asteria-button-render-cap)!important;
  border-image-outset:0!important;
  border-image-repeat:stretch!important;
}

/* Preserve the crystal's pointed alpha mask too. Chromium and Safari
   support -webkit-mask-box-image three-slice masks. Browsers without it retain
   the Phase 3 transparent alpha-mask fallback and existing colour blending.
   The colour/lighting only affects ::after, NEVER the steel frame. */
@supports (-webkit-mask-box-image-slice: 0 12% 0 12% fill) {
  body :is(.asteria-menu-button,#globalNavigation > .crystal-button):not([data-asteria-button-size="icon"])::after {
    -webkit-mask-image:none!important;
    mask-image:none!important;
    -webkit-mask-box-image-source:var(--asteria-approved-crystal)!important;
    -webkit-mask-box-image-slice:0 var(--asteria-button-source-cap) 0 var(--asteria-button-source-cap) fill!important;
    -webkit-mask-box-image-width:0 var(--asteria-button-render-cap) 0 var(--asteria-button-render-cap)!important;
    -webkit-mask-box-image-outset:0!important;
    -webkit-mask-box-image-repeat:stretch!important;
  }
}
