/* P5X UI skin — licensed button chrome from the owner-provided reference pack. */

:root {
  --p5x-button-red: url("../assets/ui/buttons/p5x-button-red.png");
  --p5x-button-white: url("../assets/ui/buttons/p5x-button-white.png");
  --p5x-button-ink: #17171b;
}

/* The source textures are wide nine-slice button plates. Rendering them as a
 * border image keeps the small rounded corners intact at arbitrary widths. */
button.ghost {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: .5rem 1.4rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--p5x-button-ink);
  font-weight: 800;
  line-height: 1;
  transform: rotate(-.35deg);
  transition: color .12s ease, filter .12s ease, transform .12s ease;
}

button.ghost::before {
  content: "";
  position: absolute;
  inset: -3px -8px;
  z-index: -1;
  border: 9px solid transparent;
  border-image-source: var(--p5x-button-white);
  border-image-slice: 16 fill;
  border-image-width: 9px;
  border-image-repeat: stretch;
  filter: drop-shadow(0 4px 0 rgba(0, 0, 0, .44));
  transition: filter .12s ease;
}

button.ghost:hover,
button.ghost:focus-visible {
  border-color: transparent;
  background: transparent;
  color: #fff;
  filter: brightness(1.04);
  transform: translateY(-2px) rotate(-.8deg);
  text-decoration: none;
}

button.ghost:hover::before,
button.ghost:focus-visible::before {
  border-image-source: var(--p5x-button-red);
  filter: drop-shadow(0 6px 0 rgba(0, 0, 0, .5));
}

button.ghost:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 4px;
}

button.ghost:active {
  filter: none;
  transform: translateY(1px) rotate(-.2deg) scale(.99);
}

/* The loadout action is the primary CTA, so it starts on the red plate and
 * reverses to white on hover/focus. */
button.ghost.wide {
  width: 100%;
  margin-top: .75rem;
  color: #fff;
  transform: rotate(-.2deg);
}

button.ghost.wide::before {
  border-image-source: var(--p5x-button-red);
}

button.ghost.wide:hover,
button.ghost.wide:focus-visible {
  color: var(--p5x-button-ink);
}

button.ghost.wide:hover::before,
button.ghost.wide:focus-visible::before {
  border-image-source: var(--p5x-button-white);
}

/* Carry the same red plate into the selected top-level route. */
.tab {
  isolation: isolate;
}

.tab.active {
  border-color: transparent;
  background: transparent;
  color: #fff;
}

.tab.active::before {
  content: "";
  position: absolute;
  inset: -2px -5px;
  z-index: -1;
  border: 8px solid transparent;
  border-image-source: var(--p5x-button-red);
  border-image-slice: 16 fill;
  border-image-width: 8px;
  border-image-repeat: stretch;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, .42));
}

@media (max-width: 640px) {
  button.ghost {
    min-height: 44px;
  }

  button.ghost::before {
    inset: -2px -5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  button.ghost,
  button.ghost::before {
    transition: none;
  }

  button.ghost:hover,
  button.ghost:focus-visible,
  button.ghost:active {
    transform: none;
  }
}
