/**
 * ═══════════════════════════════════════════════════════════════════
 * M1LL3NN1UM · CABINET SHELL
 * Master reusable arcade vault wrapper
 * Path: /assets/css/cabinet-shell.css
 *
 * Markup skeleton:
 *
 * <div class="cabinet-shell">
 *   <div class="cabinet-shell__side cabinet-shell__side--left" aria-hidden="true"></div>
 *   <div class="cabinet-shell__column">
 *     <div class="cabinet-shell__marquee">GAME TITLE</div>
 *     <div class="cabinet-shell__monitor">
 *       <div class="cabinet-shell__bezel">
 *         <div class="cabinet-shell__glass">
 *           <div class="cabinet-shell__scanlines" aria-hidden="true"></div>
 *           <div class="cabinet-shell__mount">
 *             <!-- canvas or iframe game -->
 *             <canvas class="cabinet-shell__canvas"></canvas>
 *           </div>
 *         </div>
 *       </div>
 *     </div>
 *     <div class="cabinet-shell__coin-door">
 *       <button type="button" class="cabinet-shell__coin-btn">INSERT COIN</button>
 *       <button type="button" class="cabinet-shell__coin-btn cabinet-shell__coin-btn--quarter">25¢</button>
 *     </div>
 *   </div>
 *   <div class="cabinet-shell__side cabinet-shell__side--right" aria-hidden="true"></div>
 * </div>
 *
 * Fullscreen exit (arcade-fullscreen-exit.js) sits fixed top-right (z-index 999999)
 * and remains above this shell when FS mode is active.
 * ═══════════════════════════════════════════════════════════════════
 */

/* ── Tokens ─────────────────────────────────────────────────────── */
.cabinet-shell {
  --cab-bg: #050506;
  --cab-bezel: #0a0a0c;
  --cab-bezel-edge: #1a1a1e;
  --cab-bezel-highlight: #2a2a30;
  --cab-pink: #ff2d95;
  --cab-cyan: #00e5ff;
  --cab-orange: #ff9f1a;
  --cab-green: #39ff14;
  --cab-monitor-max: 800px;
  --cab-gap: clamp(0.5rem, 2vw, 1.25rem);

  box-sizing: border-box;
  width: 100%;
  max-width: min(1100px, 100%);
  margin: 0 auto;
  padding: var(--cab-gap);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, var(--cab-monitor-max)) minmax(0, 1fr);
  grid-template-areas: "sideL column sideR";
  align-items: stretch;
  gap: var(--cab-gap);
  background:
    radial-gradient(ellipse at 50% 0%, rgba(0, 229, 255, 0.06) 0%, transparent 55%),
    radial-gradient(ellipse at 50% 100%, rgba(255, 45, 149, 0.05) 0%, transparent 50%),
    var(--cab-bg);
  color: #e2e2e2;
  font-family: "Courier New", Courier, monospace;
}

.cabinet-shell *,
.cabinet-shell *::before,
.cabinet-shell *::after {
  box-sizing: border-box;
}

/* ── Side art panels (vector neon flanks) ───────────────────────── */
.cabinet-shell__side {
  grid-row: 1;
  position: relative;
  min-height: 100%;
  min-width: 0;
  border: 2px solid transparent;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.55)),
    repeating-linear-gradient(
      180deg,
      transparent 0 14px,
      rgba(255, 255, 255, 0.02) 14px 15px
    );
  overflow: hidden;
}

.cabinet-shell__side--left {
  grid-area: sideL;
  border-color: rgba(255, 45, 149, 0.55);
  box-shadow:
    0 0 18px rgba(255, 45, 149, 0.2),
    inset 0 0 24px rgba(255, 45, 149, 0.08);
}

.cabinet-shell__side--right {
  grid-area: sideR;
  border-color: rgba(0, 229, 255, 0.55);
  box-shadow:
    0 0 18px rgba(0, 229, 255, 0.2),
    inset 0 0 24px rgba(0, 229, 255, 0.08);
}

/* Vector line-art (pseudo panels — no images required) */
.cabinet-shell__side::before,
.cabinet-shell__side::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.cabinet-shell__side--left::before {
  inset: 12% 18% 12% 22%;
  border: 1.5px solid rgba(255, 45, 149, 0.75);
  box-shadow: 0 0 12px rgba(255, 45, 149, 0.35);
  transform: skewY(-6deg);
}

.cabinet-shell__side--left::after {
  left: 30%;
  right: 30%;
  top: 18%;
  bottom: 18%;
  border-left: 1px solid rgba(255, 45, 149, 0.45);
  border-right: 1px solid rgba(255, 102, 184, 0.35);
  background: repeating-linear-gradient(
    0deg,
    transparent 0 10px,
    rgba(255, 45, 149, 0.12) 10px 11px
  );
}

.cabinet-shell__side--right::before {
  inset: 12% 22% 12% 18%;
  border: 1.5px solid rgba(0, 229, 255, 0.75);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.35);
  transform: skewY(6deg);
}

.cabinet-shell__side--right::after {
  left: 30%;
  right: 30%;
  top: 18%;
  bottom: 18%;
  border-left: 1px solid rgba(0, 229, 255, 0.4);
  border-right: 1px solid rgba(120, 255, 255, 0.3);
  background: repeating-linear-gradient(
    0deg,
    transparent 0 10px,
    rgba(0, 229, 255, 0.12) 10px 11px
  );
}

/* ── Center column ──────────────────────────────────────────────── */
.cabinet-shell__column {
  grid-area: column;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
  min-width: 0;
  width: 100%;
  max-width: var(--cab-monitor-max);
  margin: 0 auto;
}

/* Optional marquee / header plate */
.cabinet-shell__marquee {
  text-align: center;
  font-family: "Courier New", Courier, monospace;
  font-size: clamp(0.7rem, 2vw, 0.95rem);
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--cab-green);
  text-shadow: 0 0 10px rgba(57, 255, 20, 0.55);
  padding: 0.45rem 0.75rem;
  border: 1px solid rgba(57, 255, 20, 0.35);
  background: linear-gradient(180deg, #121214, #0a0a0c);
  box-shadow: 0 0 16px rgba(57, 255, 20, 0.12);
}

/* ═════════════════════════════════════════════════════════════════
   1. THE 4:3 MONITOR FRAME
   ═════════════════════════════════════════════════════════════════ */
.cabinet-shell__monitor {
  width: 100%;
  max-width: var(--cab-monitor-max);
  margin: 0 auto;
}

.cabinet-shell__bezel {
  /* Thick textured matte-black bezel */
  position: relative;
  padding: clamp(10px, 2.2vw, 18px);
  background:
    radial-gradient(circle at 20% 15%, #1c1c20 0%, transparent 40%),
    radial-gradient(circle at 80% 85%, #141418 0%, transparent 42%),
    repeating-linear-gradient(
      135deg,
      #0c0c0e 0 2px,
      #0a0a0c 2px 4px,
      #0e0e10 4px 6px
    ),
    var(--cab-bezel);
  border: 3px solid var(--cab-bezel-edge);
  border-radius: 6px;
  box-shadow:
    0 0 0 1px #000,
    0 12px 40px rgba(0, 0, 0, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    inset 0 -2px 8px rgba(0, 0, 0, 0.55);
}

/* Inner lip of bezel */
.cabinet-shell__bezel::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 3px;
  pointer-events: none;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
}

.cabinet-shell__glass {
  position: relative;
  width: 100%;
  max-width: 100%;
  /* Locked 4:3 aspect ratio */
  aspect-ratio: 4 / 3;
  background: #000;
  border: 2px solid rgba(0, 229, 255, 0.35);
  box-shadow:
    0 0 24px rgba(0, 229, 255, 0.12),
    inset 0 0 40px rgba(0, 0, 0, 0.85);
  overflow: hidden;
  isolation: isolate;
}

/* CRT scanline artifact layer */
.cabinet-shell__scanlines {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(0, 0, 0, 0) 0px,
      rgba(0, 0, 0, 0) 2px,
      rgba(0, 0, 0, 0.22) 2px,
      rgba(0, 0, 0, 0.22) 3px
    ),
    radial-gradient(
      ellipse at center,
      rgba(0, 255, 200, 0.03) 0%,
      transparent 65%
    );
  mix-blend-mode: multiply;
  opacity: 0.85;
  animation: cabinet-shell-phosphor 4.5s ease-in-out infinite;
}

.cabinet-shell__scanlines::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.04) 0%,
    transparent 12%,
    transparent 88%,
    rgba(0, 0, 0, 0.25) 100%
  );
  pointer-events: none;
}

@keyframes cabinet-shell-phosphor {
  0%, 100% { opacity: 0.78; }
  50% { opacity: 0.92; }
}

/* ═════════════════════════════════════════════════════════════════
   3. SCALABLE CANVAS MOUNTING
   Fill 4:3 glass without stretching physics — object-fit contain
   keeps native aspect; cover available via modifier.
   ═════════════════════════════════════════════════════════════════ */
.cabinet-shell__mount {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
}

/* Default: fill mount box (game engines that letterbox internally) */
.cabinet-shell__mount > canvas,
.cabinet-shell__mount > iframe,
.cabinet-shell__mount > .cabinet-shell__canvas,
.cabinet-shell__canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
  max-height: 100%;
  border: 0;
  background: #000;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Preserve internal aspect if game draws its own letterbox */
.cabinet-shell--contain .cabinet-shell__mount > canvas,
.cabinet-shell--contain .cabinet-shell__canvas {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain;
}

/* Force cover (crops edges) when explicit */
.cabinet-shell--cover .cabinet-shell__mount > canvas,
.cabinet-shell--cover .cabinet-shell__canvas {
  object-fit: cover;
}

/* iframe cabinets */
.cabinet-shell__mount > iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ═════════════════════════════════════════════════════════════════
   2. VIRTUAL COIN DOOR
   ═════════════════════════════════════════════════════════════════ */
.cabinet-shell__coin-door {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  width: 100%;
  max-width: var(--cab-monitor-max);
  margin: 0 auto;
  padding: 0.85rem 1rem;
  background:
    linear-gradient(180deg, #16161a 0%, #0a0a0c 45%, #08080a 100%);
  border: 2px solid #222;
  border-radius: 4px;
  box-shadow:
    0 0 0 1px #000,
    inset 0 2px 0 rgba(255, 255, 255, 0.04),
    inset 0 -6px 16px rgba(0, 0, 0, 0.55);
}

.cabinet-shell__coin-door::before {
  content: "COIN DOOR · DUAL SLOT";
  grid-column: 1 / -1;
  text-align: center;
  font-size: 0.58rem;
  letter-spacing: 0.2em;
  color: #444;
  margin-bottom: 0.15rem;
}

.cabinet-shell__coin-btn {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.65rem 0.75rem;
  border-radius: 3px;
  border: 2px solid var(--cab-orange);
  background:
    radial-gradient(circle at 35% 25%, rgba(255, 180, 80, 0.35), transparent 55%),
    #120a00;
  color: var(--cab-orange);
  font-family: "Courier New", Courier, monospace;
  font-size: clamp(0.7rem, 2vw, 0.85rem);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-shadow: 0 0 10px rgba(255, 159, 26, 0.75);
  box-shadow:
    0 0 16px rgba(255, 159, 26, 0.35),
    inset 0 0 12px rgba(255, 120, 0, 0.15);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.cabinet-shell__coin-btn:hover,
.cabinet-shell__coin-btn:focus {
  outline: none;
  filter: brightness(1.12);
  box-shadow:
    0 0 26px rgba(255, 159, 26, 0.55),
    inset 0 0 16px rgba(255, 160, 40, 0.25);
}

.cabinet-shell__coin-btn:active {
  transform: scale(0.97) translateY(1px);
}

.cabinet-shell__coin-btn--quarter {
  border-color: #ffb040;
  color: #ffcc66;
}

/* ═════════════════════════════════════════════════════════════════
   FULLSCREEN EXIT COMPAT (arcade-fullscreen-exit.js)
   Hidden in normal 4:3 cabinet view — only visible in true browser FS.
   ═════════════════════════════════════════════════════════════════ */
.fullscreen-exit-anchor,
.fullscreen-exit-hub,
.cabinet-shell ~ .fullscreen-exit-anchor,
body .fullscreen-exit-anchor {
  display: none !important;
  z-index: 999999 !important;
}

/* When shell itself is the fullscreen element */
.cabinet-shell:fullscreen,
.cabinet-shell:-webkit-full-screen {
  max-width: none;
  width: 100%;
  height: 100%;
  padding: clamp(0.75rem, 2vw, 1.5rem);
  grid-template-columns: minmax(48px, 1fr) minmax(0, min(96vh * 4 / 3, 96vw)) minmax(48px, 1fr);
  align-items: center;
  background: #000;
}

.cabinet-shell:fullscreen .cabinet-shell__monitor,
.cabinet-shell:-webkit-full-screen .cabinet-shell__monitor {
  max-width: min(96vh * 4 / 3, 96vw);
}

.cabinet-shell:fullscreen .cabinet-shell__column,
.cabinet-shell:-webkit-full-screen .cabinet-shell__column {
  max-width: min(96vh * 4 / 3, 96vw);
}

/* ── Responsive: stack / hide side art on narrow viewports ─────── */
@media (max-width: 720px) {
  .cabinet-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "column";
    padding: 0.65rem;
  }

  .cabinet-shell__side {
    display: none; /* side art collapses; monitor stays 4:3 */
  }

  .cabinet-shell__coin-door {
    gap: 0.5rem;
    padding: 0.7rem;
  }

  .cabinet-shell__coin-btn {
    min-height: 44px;
    letter-spacing: 0.1em;
  }
}

@media (min-width: 721px) and (max-width: 900px) {
  .cabinet-shell {
    grid-template-columns: 36px minmax(0, 1fr) 36px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .cabinet-shell__scanlines {
    animation: none;
  }
}
