/*
 * PRANATARA Relic uniform-rail frame v003 — chat-156.
 *
 * The builder supplies a dedicated .relic-literal-frame-layer containing an
 * inline SVG whose viewBox is the proven frame boundary (11 5 355 440). The
 * SVG clips the flattened reference raster to four text-free outer rails only:
 * top 11,5 355x12; bottom 11,432 355x13; left 11,17 15x415; and right
 * 351,17 15x415. No centre fill or opaque lower strip is painted.
 *
 * Fidelity boundary: the sampled rail pixels are literal source pixels, but
 * the supplied PNG is a flattened card rather than a transparent frame asset.
 * preserveAspectRatio="xMidYMid meet" and the 71/88 shell prevent stretching;
 * they do not turn the unavailable inner ornaments into a pixel-perfect frame.
 * Artwork, copy, hologram pseudo-elements, and card layout remain untouched.
 */

/* Shared non-interactive rail layer. It sits above artwork and below the
 * accepted copy/open-button layers. Each context supplies its own contain fit. */
body[data-relic-literal-frame="uniform-rail-v003"]
  #grid
  > article.holo-card[data-rarity="Relic"]
  > .relic-literal-frame-layer,
body[data-relic-literal-frame="uniform-rail-v003"]
  .reference-feature-card[data-rarity="Relic"]
  > .relic-literal-frame-layer,
body[data-relic-literal-frame="uniform-rail-v003"]
  #cardDialog
  .collectible-card.holo-card[data-rarity="Relic"]
  > .collectible-art
  > .relic-literal-frame-layer,
body[data-relic-literal-frame="uniform-rail-v003"]
  > article.card.holo-card[data-rarity="Relic"]
  > .relic-literal-frame-layer {
  position: absolute !important;
  z-index: 6 !important;
  display: block !important;
  box-sizing: border-box !important;
  aspect-ratio: 71 / 88 !important;
  max-width: 100% !important;
  max-height: 100% !important;
  overflow: hidden !important;
  border: 0 !important;
  background: none !important;
  box-shadow: none !important;
  opacity: 1 !important;
  mix-blend-mode: normal !important;
  filter: none !important;
  pointer-events: none !important;
  user-select: none !important;
  animation: none !important;
  transition: none !important;
  forced-color-adjust: none;
}

/* Gallery: retain the current card ratio, then centre the exact-ratio portrait
 * shell by height. This also safely letterboxes any wider/landscape surface. */
body[data-relic-literal-frame="uniform-rail-v003"]
  #grid
  > article.holo-card[data-rarity="Relic"]
  > .relic-literal-frame-layer {
  top: 50% !important;
  right: auto !important;
  bottom: auto !important;
  left: 50% !important;
  width: auto !important;
  height: 100% !important;
  transform: translate(-50%, -50%) !important;
}

/* Featured card: use the same height-contained portrait shell without
 * changing the accepted feature-card dimensions. */
body[data-relic-literal-frame="uniform-rail-v003"]
  .reference-feature-card[data-rarity="Relic"]
  > .relic-literal-frame-layer {
  top: 50% !important;
  right: auto !important;
  bottom: auto !important;
  left: 50% !important;
  width: auto !important;
  height: 100% !important;
  transform: translate(-50%, -50%) !important;
}

/* Modal art: width containment preserves the 4:5 artwork window. The layer is
 * a child overlay; it never changes collectible-art padding, border, or size. */
body[data-relic-literal-frame="uniform-rail-v003"]
  #cardDialog
  .collectible-card.holo-card[data-rarity="Relic"]
  > .collectible-art
  > .relic-literal-frame-layer {
  top: 50% !important;
  right: auto !important;
  bottom: auto !important;
  left: 50% !important;
  width: 100% !important;
  height: auto !important;
  transform: translate(-50%, -50%) !important;
}

/* Self-contained animation media: contain the shell by width inside the
 * existing 4:5 card. No card aspect-ratio or media/copy sizing is changed. */
body[data-relic-literal-frame="uniform-rail-v003"]
  > article.card.holo-card[data-rarity="Relic"]
  > .relic-literal-frame-layer {
  top: 50% !important;
  right: auto !important;
  bottom: auto !important;
  left: 50% !important;
  width: 100% !important;
  height: auto !important;
  transform: translate(-50%, -50%) !important;
}

/* The SVG markup owns the crop and the local raster href. CSS only preserves
 * its exact viewBox ratio and does not introduce a filter or animation. */
body[data-relic-literal-frame="uniform-rail-v003"]
  .relic-literal-frame-layer
  > .relic-literal-frame-svg {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  aspect-ratio: 71 / 88 !important;
  overflow: hidden !important;
  background: none !important;
  opacity: 1 !important;
  mix-blend-mode: normal !important;
  filter: none !important;
  transform: none !important;
  pointer-events: none !important;
  animation: none !important;
  transition: none !important;
  shape-rendering: geometricPrecision;
}

body[data-relic-literal-frame="uniform-rail-v003"]
  .relic-literal-frame-svg
  image {
  opacity: 1 !important;
  filter: none !important;
  transform: none !important;
  pointer-events: none !important;
  animation: none !important;
  transition: none !important;
  image-rendering: auto;
}

/* Catalogue compatibility: suppress only the former ornamental shell. The
 * element stays present because its child .heirloom-top-number is identity
 * content and must remain visible. This selector intentionally outranks the
 * v004/v005 !important frame bindings. */
body[data-relic-literal-frame="uniform-rail-v003"][data-reference-portrait-card="v001"][data-reference-portrait-frame="transparent-centre-v002"][data-reference-portrait-fidelity="v003"][data-reference-portrait-optical="v004"][data-reference-feature-coordinate="v005"]
  #grid
  > article.holo-card[data-rarity="Relic"]
  > .ornamental-frame-v002.heirloom-cartouche-frame-v001 {
  border-color: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  outline: 0 !important;
  opacity: 1 !important;
  mix-blend-mode: normal !important;
  filter: none !important;
  transform: none !important;
  animation: none !important;
  transition: none !important;
}

body[data-relic-literal-frame="uniform-rail-v003"][data-reference-portrait-card="v001"][data-reference-portrait-frame="transparent-centre-v002"][data-reference-portrait-fidelity="v003"][data-reference-portrait-optical="v004"][data-reference-feature-coordinate="v005"]
  #grid
  > article.holo-card[data-rarity="Relic"]
  > .ornamental-frame-v002.heirloom-cartouche-frame-v001
  > svg.heirloom-corner {
  display: none !important;
}

/* The inherited article inset rail is part of the former frame, not the
 * hologram. Retain the three established outer depth shadows, but omit the
 * inset rail so the literal layer is the sole visible frame while
 * .protected-media pseudo-elements continue their token-bound motion. */
body[data-relic-literal-frame="uniform-rail-v003"][data-reference-portrait-card="v001"][data-reference-portrait-frame="transparent-centre-v002"][data-reference-portrait-fidelity="v003"][data-reference-portrait-optical="v004"][data-reference-feature-coordinate="v005"]
  #grid
  > article.holo-card[data-rarity="Relic"] {
  border-color: transparent !important;
  box-shadow:
    0 0 0 1px #050403,
    0 3px 0 #332719,
    0 22px 38px -23px rgba(0,0,0,.96) !important;
}

body[data-relic-literal-frame="uniform-rail-v003"][data-reference-portrait-card="v001"][data-reference-portrait-frame="transparent-centre-v002"][data-reference-portrait-fidelity="v003"][data-reference-portrait-optical="v004"][data-reference-feature-coordinate="v005"]
  #grid
  > article.holo-card[data-rarity="Relic"]::before,
body[data-relic-literal-frame="uniform-rail-v003"]
  > article.card.holo-card[data-rarity="Relic"]::before {
  content: none !important;
  display: none !important;
}

/* Featured compatibility frame contains no identity content, so it may be
 * removed while the token plaque and rarity pennant remain sibling elements. */
body[data-relic-literal-frame="uniform-rail-v003"][data-reference-portrait-card="v001"][data-reference-portrait-frame="transparent-centre-v002"][data-reference-portrait-fidelity="v003"][data-reference-portrait-optical="v004"][data-reference-feature-coordinate="v005"]
  .reference-feature-card[data-rarity="Relic"]
  > .reference-feature-frame {
  display: none !important;
}

/* Modal compatibility: remove the old v004 background image and inset outline.
 * Do not set padding, size, overflow, or any protected-media pseudo-element. */
body[data-relic-literal-frame="uniform-rail-v003"][data-reference-portrait-card="v001"][data-reference-portrait-frame="transparent-centre-v002"][data-reference-portrait-fidelity="v003"][data-reference-portrait-optical="v004"][data-reference-feature-coordinate="v005"]
  #cardDialog
  .collectible-card.holo-card[data-rarity="Relic"]
  > .collectible-art {
  background-image: none !important;
  border-color: transparent !important;
  box-shadow: none !important;
}

/* Standalone compatibility shell is likewise neutralised without removing its
 * number. The unique hologram remains on .media::before/.media::after. */
body[data-relic-literal-frame="uniform-rail-v003"]
  > article.card.holo-card[data-rarity="Relic"]
  > .ornamental-frame-v002.heirloom-cartouche-frame-v001 {
  border-color: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  outline: 0 !important;
  z-index: 7 !important;
  opacity: 1 !important;
  mix-blend-mode: normal !important;
  filter: none !important;
  transform: none !important;
  animation: none !important;
  transition: none !important;
}

body[data-relic-literal-frame="uniform-rail-v003"]
  > article.card.holo-card[data-rarity="Relic"]
  > .ornamental-frame-v002.heirloom-cartouche-frame-v001
  > .heirloom-top-number {
  top: 18px !important;
  right: auto !important;
  bottom: auto !important;
  left: 31px !important;
  z-index: 8 !important;
  transform: none !important;
}

body[data-relic-literal-frame="uniform-rail-v003"]
  > article.card.holo-card[data-rarity="Relic"] {
  border-color: transparent !important;
}

body[data-relic-literal-frame="uniform-rail-v003"]
  > article.card.holo-card[data-rarity="Relic"]
  > .ornamental-frame-v002.heirloom-cartouche-frame-v001
  > svg.heirloom-corner {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  body[data-relic-literal-frame="uniform-rail-v003"]
    .relic-literal-frame-layer,
  body[data-relic-literal-frame="uniform-rail-v003"]
    .relic-literal-frame-svg {
    animation: none !important;
    transition: none !important;
  }
}

/* The literal raster is not forced into high-contrast palettes. Replace it
 * with a simple system-colour outline while retaining the same centred shell. */
@media (forced-colors: active) {
  body[data-relic-literal-frame="uniform-rail-v003"]
    .relic-literal-frame-layer {
    border: 2px solid CanvasText !important;
    background: transparent !important;
    box-shadow: none !important;
    filter: none !important;
    forced-color-adjust: auto;
  }

  body[data-relic-literal-frame="uniform-rail-v003"]
    .relic-literal-frame-layer
    > .relic-literal-frame-svg {
    visibility: hidden !important;
  }
}
