/* =============================================
   NES Cartridge Component
   Based on CodePen reference — front face kept
   nearly verbatim for geometric accuracy.
   3D side panels stripped; fake-3D via shadows.
   ============================================= */

/* Scoped box-sizing */
.cart-wrapper,
.cart-wrapper *,
.cart-wrapper *::before,
.cart-wrapper *::after {
  box-sizing: border-box;
}

/* ---- Wrapper: scene positioning + scale ---- */
/* ---- Drag & Drop States ---- */

/* Source cartridge hidden instantly while dragging —
   the proxy seamlessly replaces it at the same position */
.cart-shell.cart-dragging {
  opacity: 0;
  transition: none;
}

/* Hidden after successful insertion */
.cart-shell.cart-hidden {
  opacity: 0;
  pointer-events: none;
}

/* ---- Drag Proxy (follows cursor) ---- */
/* The proxy is a deep clone of .cart-shell, so it inherits all shell styles.
   We override positioning to fixed and add a drop shadow. */
.cart-shell.cart-drag-proxy {
  position: fixed;
  z-index: 10000;
  pointer-events: none;
  cursor: grabbing;
  opacity: 1;
}


/* ---- Slot highlight when drag hovers ---- */
.nes-cartridge-slot.slot-highlight .nes-slot-hole {
  box-shadow:
    inset 0 2em 3em #000,
    inset 0 -0.4em 0 #424242,
    inset 0 -1.2em 0 #222,
    0 0 1em 0.3em rgba(20, 253, 206, 0.15);
  transition: box-shadow 0.2s;
}

.cart-wrapper {
  position: absolute;
  /* Two cartridges side by side, on top of NES */
  left: calc(50% + var(--scene-offset-x) - 532px);
  top: calc(51% + var(--scene-offset-y) - 180px);
  margin-left: -511px; /* half of ~1022px pre-scale width */
  transform: scale(0.24);
  transform-origin: top center;
  z-index: 690;
  /* Scene integration: dim for dark void */
  filter: brightness(0.88) saturate(0.9);
  cursor: grab;
}

/* ---- Flex row for side-by-side cartridges ---- */
.cart-row {
  display: flex;
  gap: 2em;
}

/* Ground shadow — separate element that clones cart-wrapper's exact
   positioning + transform so it lands in the same spot, then uses
   a child div for the actual shadow shape at the tray's bottom edge.
   No filter → no stacking context trap. */
.cart-shadow {
  /* Clone cart-wrapper positioning exactly */
  position: absolute;
  left: calc(50% + var(--scene-offset-x) - 532px);
  top: calc(51% + var(--scene-offset-y) - 180px);
  margin-left: -511px;
  transform: scale(0.24);
  transform-origin: top center;
  /* Same dimensions as cart-wrapper content */
  width: 1022px;
  height: 0;
  z-index: 799;
  pointer-events: none;
  /* NO filter — this is the key difference from cart-wrapper */
}

/* The actual shadow ellipse, positioned at the tray bottom.
   Tray bottom = shell height (35.7em) + tray overflow (bottom:-4.8em →
   so tray-top starts at ~32.2em, tray = 8.3em, bottom at ~40.5em)
   plus front-face overflow (~40em). Use the front-face bottom. */
.cart-shadow::after {
  content: "";
  position: absolute;
  width: 67em; /* matches cart-tray width */
  height: 2em;
  left: 50%;
  transform: translateX(-50%);
  /* Shadow center at tray bottom (40.5em): top = 40.5 - 1 = 39.5em */
  top: 39.5em;
  background: rgba(0, 0, 0, 0.8);
  border-radius: 50%;
  box-shadow:
    0 0 1.5em 0.8em rgba(0, 0, 0, 0.6),
    0 0.5em 3em 1.5em rgba(0, 0, 0, 0.3),
    0 1em 8em 3em rgba(0, 0, 0, 0.12);
}

/* ---- Shell body ---- */
.cart-shell {
  background: rgb(156, 156, 156);
  width: 30.95em;
  height: 35.7em;
  border-bottom-right-radius: 6px;
  border-bottom-left-radius: 6px;
  position: relative;
  /* Noise texture (same base64 as NES body) */
  background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAMAAAAp4XiDAAAAUVBMVEWFhYWDg4N3d3dtbW17e3t1dXWBgYGHh4d5eXlzc3OLi4ubm5uVlZWPj4+NjY19fX2JiYl/f39ra2uRkZGZmZlpaWmXl5dvb29xcXGTk5NnZ2c8TV1mAAAAG3RSTlNAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEAvEOwtAAAFVklEQVR4XpWWB67c2BUFb3g557T/hRo9/WUMZHlgr4Bg8Z4qQgQJlHI4A8SzFVrapvmTF9O7dmYRFZ60YiBhJRCgh1FYhiLAmdvX0CzTOpNE77ME0Zty/nWWzchDtiqrmQDeuv3powQ5ta2eN0FY0InkqDD73lT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pY2Xl5zXdguFqYyTR1zSp1Y9p+tktDYYSNflcxI0iyO4TPBdlRcpeqjK/piF5bklq77VSEaA+z8qmJTFzIWiitbnzR794USKBUaT0NTEsVjZqLaFVqJoPN9ODG70IPbfBHKK+/q/AWR0tJzYHRULOa4MP+W/HfGadZUbfw177G7j/OGbIs8TahLyynl4X4RinF793Oz+BU0saXtUHrVBFT/DnA3ctNPoGbs4hRIjTok8i+algT1lTHi4SxFvONKNrgQFAq2/gFnWMXgwffgYMJpiKYkmW3tTg3ZQ9Jq+f8XN+A5eeUKHWvJWJ2sgJ1Sop+wwhqFVijqWaJhwtD8MNlSBeWNNWTa5Z5kPZw5+LbVT99wqTdx29lMUH4OIG/D86ruKEauBjvH5xy6um/Sfj7ei6UUVk4AIl3MyD4MSSTOFgSwsH/QJWaQ5as7ZcmgBZkzjjU1UrQ74ci1gWBCSGHtuV1H2mhSnO3Wp/3fEV5a+4wz//6qy8JxjZsmxxy5+4w9CDNJY09T072iKG0EnOS0arEYgXqYnXcYHwjTtUNAcMelOd4xpkoqiTYICWFq0JSiPfPDQdnt+4/wuqcXY47QILbgAAAABJRU5ErkJggg==);
  /* Beveled edges + drop shadow (inflated for scale(0.28)) */
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 -1px 0 rgba(0, 0, 0, 0.08),
    inset 1px 0 0 rgba(255, 255, 255, 0.06),
    inset -1px 0 0 rgba(0, 0, 0, 0.05),
    0 6px 14px rgba(0, 0, 0, 0.25),
    0 2px 4px rgba(0, 0, 0, 0.18);
}

/* Top edge — visible from slightly-above camera */
.cart-shell::before {
  content: "";
  position: absolute;
  top: -4px;
  left: 2%;
  width: 96%;
  height: 4px;
  background: rgb(146, 146, 146);
  border-radius: 2px 2px 0 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* CRT glow tint overlay */
.cart-shell::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(
    ellipse at 50% -50%,
    rgba(20, 253, 206, 0.04) 0%,
    transparent 70%
  );
  pointer-events: none;
  z-index: 10;
  border-radius: 0 0 6px 6px;
}

/* ---- Front face ----
   Kept nearly verbatim from CodePen for
   geometric accuracy. */
.cart-front {
  background: rgb(156, 156, 156);
  height: 40em;
  width: 26.3em;
  margin: 0px 2.15em auto;
  box-shadow: 0px 4px 0px 0px rgba(0, 0, 0, 0.6);
  position: relative;
}

/* ---- Cover image ---- */
.cart-cover {
  margin: 0em 7.7em auto;
  height: 400px;
  width: 280px;
  border-bottom-right-radius: 6px;
  border-bottom-left-radius: 6px;
  filter: drop-shadow(1.5px 1.5px 1px rgba(44, 44, 46, 0.72));
  display: block;
}

/* ---- Arrow notch ---- */
.cart-arrow {
  display: block;
  width: 0;
  height: 0;
  border-left: 18px solid transparent;
  border-right: 18px solid transparent;
  border-top: 33px solid rgb(121, 117, 117);
  float: right;
  margin: 4.3em 14.5em;
}

/* ---- Grip ridges ---- */
.cart-ridges {
  width: 14%;
  margin: -415px 15px;
  border-right: 1px solid black;
  border-left: 1px solid black;
  text-align: center;
  box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.66);
  list-style: none;
  padding: 0;
}

.cart-ridges li {
  background: rgb(180, 176, 176);
  height: 1em;
  list-style: none;
  margin: 10px 0px 10px -31px;
  box-shadow: 0px 0px 3px 0px rgba(0, 0, 0, 0.76);
  width: 5em;
  border-radius: 1.5px;
}

.cart-ridges .cart-ridge-last {
  height: 4.2em;
  box-shadow: 0px -1px 1px 0px rgba(0, 0, 0, 0.76);
}

/* ---- Connector cutout (flat version of 3D hole) ---- */
.cart-cutout {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 52%;
  height: 3.5em;
  background: #3a3a3a;
  border-radius: 3px 3px 0 0;
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.5),
    inset 1px 0 1px rgba(0, 0, 0, 0.2),
    inset -1px 0 1px rgba(0, 0, 0, 0.2);
}

/* ---- Wooden cartridge display stand ----
   Viewed front-on (like the cartridge), so the tray
   reads as a front-facing wooden plank behind the
   cartridge's base. "Top" = main front face of plank,
   "Front" = bottom edge / thickness.
   Shell bottom at 35.7em, front overflows to 40em.
   Tray positioned so cartridge base overlaps its upper portion. */
.cart-tray {
  position: absolute;
  /* Tray bottom at ~40.5em from wrapper top (below front face at 40em).
     Tray main face = 7.5em + edge = 0.8em = 8.3em total.
     Tray top at ~32.2em = right where the connector cutout begins.
     The entire bottom section (cutout + front overflow) is swallowed. */
  bottom: -4.8em;
  left: 50%;
  transform: translateX(-50%);
  /* Wide enough for two shells (30.95em × 2) + gap (2em) + padding */
  width: 67em;
}

/* Main face — tall enough to cover the cartridge's entire bottom
   section (connector cutout + front face overflow below shell) */
.cart-tray-top {
  width: 100%;
  height: 7.5em;
  position: relative;
  /* Brighter base so leather reads after parent brightness(0.72) */
  background-color: #3a3a3a;
  background-image: radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.35), transparent 55%), url('https://assets.codepen.io/4175254/black-leather-2.png');
  background-blend-mode: overlay, normal;
  background-size: 100% 100%, auto;
  background-repeat: no-repeat, repeat;
  border-radius: 2px 2px 0 0;
  box-shadow:
    0 -6px 10px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    inset 0 -1px 0 rgba(0, 0, 0, 0.08);
}

/* Photon shader — very subtle so leather texture stays visible */
.cart-tray-top::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.04);
  border-radius: 2px 2px 0 0;
  pointer-events: none;
}

/* Bottom edge — thickness of the plank, darker */
.cart-tray-front {
  width: 100%;
  height: 0.8em;
  position: relative;
  background-color: #353535;
  background-image: radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.25), transparent 55%), url('https://assets.codepen.io/4175254/black-leather-2.png');
  background-blend-mode: overlay, normal;
  background-size: 100% 100%, auto;
  background-repeat: no-repeat, repeat;
  border-radius: 0 0 2px 2px;
  box-shadow:
    0 3px 6px rgba(0, 0, 0, 0.2),
    0 1px 2px rgba(0, 0, 0, 0.12);
}

/* Photon shader on bottom edge — subtle */
.cart-tray-front::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.08);
  border-radius: 0 0 2px 2px;
  pointer-events: none;
}
