/* Only opted-in native dialogs. Preserve their existing background and geometry. */
dialog[data-lb-modal-rim="account"] {
  --lb-rim-surface: radial-gradient(ellipse 105% 85% at 49% -10%, #222225 0%, #141415 55%, #101011 100%);
}
dialog[data-lb-modal-rim="auto"] {
  --lb-rim-surface: radial-gradient(ellipse 105% 85% at 49% -10%, #222225 0%, #141415 55%, #101011 100%);
}
[data-admin-shell] dialog[data-lb-modal-rim="auto"] { --lb-rim-surface: linear-gradient(#15161b, #15161b); }
dialog[data-lb-modal-rim="wallet"] {
  --lb-rim-surface: radial-gradient(ellipse 115% 95% at 50% -15%, #222225, #161617 50%, #101011 100%);
}
dialog[data-lb-modal-rim="backpack-filter"] {
  --lb-rim-surface: linear-gradient(#18181b, #18181b);
}
dialog[data-lb-modal-rim="card-inspect"] {
  --lb-rim-surface: linear-gradient(#191b23, #191b23);
}

.lbModalRim { display: none; pointer-events: none; }

@media (forced-colors: none) {
  dialog[data-lb-modal-rim]:modal {
    /* Keep the original border width. Both gradients are opaque where they meet,
       so only that existing line changes, never the dialog's dark fill. */
    border-color: transparent;
    background:
      var(--lb-rim-surface) padding-box,
      conic-gradient(
        #e6c997 0deg, #f4e5a9 24deg, #655e52 64deg, #495951 94deg,
        #8fc4ac 124deg, #a5e6c7 150deg, #719c89 174deg, #46524d 199deg,
        #54666a 238deg, #81a9b3 262deg, #7b7284 291deg,
        #e0adc6 324deg, #f6cce8 339deg, #e6c997 360deg
      ) border-box;
  }
}

@media (forced-colors: none) {
  dialog[data-lb-modal-rim="auto"]:modal {
    border: 1px solid transparent !important;
    background:
      var(--lb-rim-surface) padding-box,
      conic-gradient(
        #e6c997 0deg, #f4e5a9 24deg, #655e52 64deg, #495951 94deg,
        #8fc4ac 124deg, #a5e6c7 150deg, #719c89 174deg, #46524d 199deg,
        #54666a 238deg, #81a9b3 262deg, #7b7284 291deg,
        #e0adc6 324deg, #f6cce8 339deg, #e6c997 360deg
      ) border-box !important;
  }
}
/* Two windows can be open at once; each rim follows its own. */
dialog[data-lb-modal-rim] { anchor-scope: --lb-current-modal-rim; }

@supports (top: anchor(top)) {
  @media (prefers-reduced-motion: no-preference) and (forced-colors: none) {
    dialog[data-lb-modal-rim]:modal { anchor-name: --lb-current-modal-rim; }
    dialog[data-lb-modal-rim]:modal > .lbModalRim {
      /* A viewport-fixed decoration follows the dialog, not its scrolling content. */
      position: fixed;
      position-anchor: --lb-current-modal-rim;
      inset: anchor(top) anchor(right) anchor(bottom) anchor(left);
      display: block;
      z-index: 4;
      overflow: clip;
      border-radius: inherit;
    }
  }
}

/* All glow is in a static two-pixel perimeter mask. Motion only transforms its
   tiny cold-white sprite; the original coloured line remains underneath. */
:is(.lbGuestRimTrack, .lbCatalogRimTrack) { display: none; }
@media (prefers-reduced-motion: no-preference) and (forced-colors: none) {
  .lbDock.lbDockPreview .lbDockGuestButton[data-lb-auth-entry] > .lbGuestRimTrack,
  .lbCatalog .lbShelfPrice > .lbCatalogRimTrack {
    display: block;
    position: absolute;
    inset: -1px;
    z-index: 1;
    border-radius: inherit;
  }
  :is(.lbGuestRimTrack, .lbCatalogRimTrack, .lbModalRim) {
    pointer-events: none;
    box-sizing: border-box;
    padding: 2px;
    mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  }
  .lbRimGlint {
    position: absolute;
    left: -19px;
    top: -3.75px;
    width: 28px;
    height: 7.5px;
    pointer-events: none;
    opacity: 0;
    transform-origin: 19px 3.75px;
    background:
      radial-gradient(ellipse 7px 2.7px at 19px 50%, #fff 7%, #f2fafff7 34%, #def1ffb0 59%, transparent 100%),
      radial-gradient(ellipse 15px 3.7px at 12px 50%, #e6f4ff9e 0%, #ddedff6b 41%, #ddedff20 76%, transparent 100%);
  }
  .lbRimGlint[data-lb-rim-active] { opacity: 1; }
}
/* A window with its own backdrop filter or transform cannot anchor a fixed rim; pin it inside instead. */
@media (prefers-reduced-motion: no-preference) and (forced-colors: none) {
  dialog[data-lb-modal-rim]:modal > .lbModalRim[data-inside] { display: block; position: absolute; position-anchor: auto; inset: 0; z-index: 4; overflow: clip; border-radius: inherit; }
}
