/* ---------- 3D portrait plates ---------- */

.join-photo__frame.p3d,
.dash-photo__frame.p3d {
  --p3d-accent: rgba(216, 255, 63, 0.72);
  --p3d-line: rgba(216, 255, 63, 0.2);
  --p3d-grid: rgba(216, 255, 63, 0.1);
  --p3d-glow: rgba(216, 255, 63, 0.16);
  perspective: 820px;
  perspective-origin: 50% 46%;
  isolation: isolate;
}

html[data-theme="daylight"] .join-photo__frame.p3d,
html[data-theme="daylight"] .dash-photo__frame.p3d {
  --p3d-accent: rgba(216, 31, 54, 0.7);
  --p3d-line: rgba(11, 13, 16, 0.16);
  --p3d-grid: rgba(11, 13, 16, 0.08);
  --p3d-glow: rgba(216, 31, 54, 0.12);
}

.p3d__plate {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  transform-style: preserve-3d;
  transform: rotateX(var(--p3d-rx, 0deg)) rotateY(var(--p3d-ry, 0deg));
  will-change: transform;
}

.p3d__plate > img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  pointer-events: none;
  user-select: none;
}

.p3d__plate > img.p3d__subject {
  z-index: 2;
  transform: translateZ(26px) scale(1.045);
  filter: saturate(0.9) contrast(1.05) brightness(1.02);
}

.p3d__plate > img.p3d__ghost {
  z-index: 1;
  transform: translateZ(-30px) scale(1.16);
  filter: blur(15px) grayscale(0.35) brightness(0.48) contrast(1.1);
  opacity: 0.9;
}

.p3d__grid {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  transform: translateZ(40px);
  background-image:
    linear-gradient(90deg, transparent calc(50% - 0.5px), var(--p3d-line) 50%, transparent calc(50% + 0.5px)),
    linear-gradient(0deg, transparent calc(50% - 0.5px), var(--p3d-line) 50%, transparent calc(50% + 0.5px)),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 6px),
    radial-gradient(var(--p3d-grid) 0.8px, transparent 0.9px),
    radial-gradient(circle at 50% 45%, transparent 34%, rgba(4, 5, 6, 0.35) 100%);
  background-size: 100% 100%, 100% 100%, 100% 100%, 7px 7px, 100% 100%;
  opacity: 0.85;
}

.p3d__grid::before,
.p3d__grid::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1px solid var(--p3d-accent);
  opacity: 0.55;
}

.p3d__grid::before {
  top: 10px;
  left: 10px;
  border-right: 0;
  border-bottom: 0;
}

.p3d__grid::after {
  right: 10px;
  bottom: 10px;
  border-top: 0;
  border-left: 0;
}

.p3d__glare {
  position: absolute;
  inset: -10%;
  z-index: 5;
  pointer-events: none;
  transform: translateZ(52px);
  background: radial-gradient(
    240px circle at var(--p3d-gx, 50%) var(--p3d-gy, 40%),
    rgba(255, 255, 255, 0.2),
    transparent 62%
  );
  mix-blend-mode: screen;
  opacity: 0.55;
}

.p3d__scan {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 36%;
  z-index: 5;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, var(--p3d-glow), transparent);
  transform: translate3d(0, -140%, 48px);
  animation: p3d-scan 6.4s linear infinite;
  mix-blend-mode: screen;
  opacity: 0.65;
}

@keyframes p3d-scan {
  0% { transform: translate3d(0, -140%, 48px); }
  100% { transform: translate3d(0, 380%, 48px); }
}

.p3d__tag {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 6px;
  border: 1px solid var(--p3d-accent);
  background: rgba(4, 5, 6, 0.58);
  color: var(--bone);
  font-family: var(--mono);
  font-size: 6.5px;
  line-height: 1;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  transform: translateZ(58px);
  pointer-events: none;
}

.p3d__tag i {
  display: block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--p3d-accent);
}

html[data-theme="daylight"] .p3d__tag {
  background: rgba(255, 255, 255, 0.78);
  color: var(--day-ink);
}

html[data-theme="daylight"] .p3d__plate > img.p3d__ghost {
  filter: blur(14px) grayscale(0.5) brightness(0.66) contrast(1.05);
  opacity: 0.62;
}

.join-photo__frame.p3d::before,
.join-photo__frame.p3d::after,
.dash-photo__frame.p3d::after {
  z-index: 7;
}

@media (hover: hover) and (pointer: fine) {
  .p3d:hover .p3d__grid {
    opacity: 1;
  }
}

@media (max-width: 720px) {
  .join-photo__frame.p3d,
  .dash-photo__frame.p3d {
    perspective: 620px;
  }

  .p3d__scan {
    display: none;
  }

  .p3d__glare {
    opacity: 0.32;
  }

  .p3d__tag {
    font-size: 6px;
    padding: 2px 5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .p3d__scan {
    display: none;
  }

  .p3d__glare {
    display: none;
  }

  .p3d__plate {
    transform: rotateX(2deg) rotateY(-2deg);
  }

  .p3d__plate--mono {
    transform: rotateX(2deg) rotateY(-2deg) scale(1.02);
  }
}

/* ---------- Monogram plates: roster cards + public profile panels ---------- */

.player-modal__visual.p3d,
.player-panel__visual.p3d,
.player-card__media--live.p3d {
  --p3d-accent: color-mix(in srgb, var(--acid) 72%, transparent);
  --p3d-line: color-mix(in srgb, var(--acid) 22%, transparent);
  --p3d-grid: color-mix(in srgb, var(--acid) 10%, transparent);
  --p3d-glow: color-mix(in srgb, var(--acid) 14%, transparent);
  perspective: 900px;
  perspective-origin: 50% 45%;
  isolation: isolate;
}

.p3d__plate--mono {
  position: absolute;
  inset: -3%;
  display: grid;
  place-items: center;
  transform-style: preserve-3d;
  transform: rotateX(var(--p3d-rx, 0deg)) rotateY(var(--p3d-ry, 0deg)) scale(1.02);
  will-change: transform;
}

.p3d__ghost-text {
  display: grid;
  place-items: center;
  background: none !important;
  border: 0;
  box-shadow: none;
  opacity: 0.55 !important;
  text-shadow: none !important;
  filter: blur(18px) saturate(0.75);
  transform: translateZ(-48px) scale(1.2);
  pointer-events: none;
  user-select: none;
  z-index: 0;
}

.p3d__plate--mono > .p3d__ghost-text,
.p3d__plate--mono > .player-card__monogram {
  grid-area: 1 / 1;
}

.p3d__plate--mono > .player-modal__monogram,
.p3d__plate--mono > .player-panel__monogram {
  z-index: 1;
  transform: translateZ(28px);
}

.p3d__plate--mono > .player-card__monogram {
  position: relative;
  z-index: 1;
  transform: translateZ(28px);
}

/* The ghost carries the monogram classes, so restate its depth after them. */
.p3d__plate--mono > .p3d__ghost-text {
  position: absolute;
  inset: 0;
  grid-area: 1 / 1;
  z-index: 0;
  transform: translateZ(-48px) scale(1.2);
}

/* The profile panels paint their backdrop on the monogram, which would hide
   the blurred ghost copy. Move that backdrop onto the plate instead. */
.p3d__plate--panel {
  background:
    radial-gradient(circle at 50% 42%, color-mix(in srgb, var(--acid) 12%, transparent), transparent 62%),
    #0c0d0f;
}

.p3d--mono .player-modal__monogram,
.p3d--mono .player-panel__monogram {
  background: none;
}

.p3d__grid--mono {
  z-index: 3;
  opacity: 0.72;
}

.p3d__glare--mono {
  z-index: 4;
  opacity: 0.3;
}

/* Depth comes from the plate transform; a per-layer translateZ would push
   HUD elements outside the panel once perspective is applied. */
.p3d--mono .p3d__grid,
.p3d--mono .p3d__glare,
.p3d--mono .p3d__tag {
  transform: none;
}

.p3d--mono .p3d__scan {
  display: none;
}

.p3d__tag--panel {
  bottom: 12px;
  left: 12px;
  top: auto;
  right: auto;
  z-index: 8;
  transform: none;
}

.player-card__media--live.p3d .p3d__grid--mono {
  opacity: 0.34;
}

.player-card__media--live.p3d .p3d__tag {
  display: none;
}

@media (max-width: 720px) {
  .player-modal__visual.p3d,
  .player-panel__visual.p3d {
    perspective: 680px;
  }

  .p3d__ghost-text {
    filter: blur(11px) saturate(0.7);
  }
}

/* ---------- Consented public portraits ---------- */

.player-card__media--photo .player-card__monogram,
.player-modal__visual.is-portrait .player-modal__monogram {
  display: none;
}

.player-card__media--photo .p3d__plate > img.p3d__subject,
.player-modal__visual.is-portrait .p3d__plate > img.p3d__subject {
  object-position: 50% 26%;
}

.player-card__media--photo .p3d__plate > img.p3d__subject {
  filter: saturate(0.95) contrast(1.04) brightness(1.04);
}

/* Keep consenting faces close to their natural colour: the roster's colour
   wash is tuned for the initials plates, not photographs. */
.player-card--photo::before,
.player-card--photo.is-active::before {
  opacity: 0.1;
}

.player-modal__visual.is-portrait .player-modal__glow {
  opacity: 0.45;
}
