/* lab.css – ONLY Lab-specific styles.
   Do NOT restyle body, header, .logo, nav, .user-menu, footer, etc. */

/* Make the Lab page use a single-column layout */
/* Main Lab area */
.lab-main {
  display: block;           /* no flex rows/columns fighting us */
  max-width: 1400px;        /* nice wide lab area */
  margin: 0 auto;
  padding: 2rem;
}

/* Every direct child (filters + sections) should take full width */
/* Make filters + sections full-width inside the lab */
.lab-main > .filters,
.lab-main > #backgroundSection,
.lab-main > #musicSection {
  width: 100%;
  margin: 0 auto 2rem auto;
}

/* Filters block */
.filters {
  background: rgba(0, 0, 0, 0.75);
  padding: 1rem;
  border: 1px solid rgba(21, 255, 0, 0.5);
  border-radius: 10px;
  color: #eaffea;
}

.filters h2 {
  margin-top: 0;
}

.filters select {
  margin: 0.5rem;
  padding: 0.5rem;
  border-radius: 4px;
  border: none;
}

/* Background & music grids */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.5rem;
  justify-items: center;
}

.store-card {
  max-width: 220px;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(21, 255, 0, 0.5);
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
  box-shadow: 0 0 10px rgba(21, 255, 0, 0.3);
}

.preview-img {
  width: 100%;
  height: auto;
  max-height: 200px;
  object-fit: contain;
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

.store-card p {
  margin: 0.25rem 0;
  font-weight: 600;
}

/* Buttons inside cards */
.store-card button,
.store-card .apply-now {
  margin: 0.25rem;
  padding: 6px 12px;
  border: none;
  border-radius: 5px;
  background: #15ff00;
  color: #000;
  font-weight: bold;
  cursor: pointer;
  font-size: 0.9rem;
}

.store-card button:hover {
  background: #ff0044;
  color: #fff;
}

/* Ownership states */
.apply-now {
  background: #15ff00;
  color: #111;
  border-radius: 6px;
  cursor: pointer;
}

.buy.owned {
  opacity: 0.8;
  cursor: not-allowed;
  background: #333;
  border: 1px dashed #777;
  color: #bbb;
}

/* Audio player */
.store-card audio {
  width: 100%;
  margin-top: 0.5rem;
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #111;
  border: 1px solid rgba(21, 255, 0, 0.6);
  padding: 2rem;
  text-align: center;
  border-radius: 10px;
  color: #eaffea;
}

/* Responsive tweaks */
@media (max-width: 768px) {
  .lab-main {
    padding: 1rem;
  }

  .grid {
    gap: 1rem;
  }

  .store-card {
    flex: 1 1 45%;
    max-width: 100%;
  }

  .filters {
    text-align: center;
  }

  .filters select {
    display: block;
    margin: 0.5rem auto;
  }
}

/* --- FORCE LAB GRID TO BE HORIZONTAL (MULTIPLE PER ROW) --- */
/* --- LAB GRIDS: MULTIPLE CARDS PER ROW --- */
#backgroundGrid,
#musicGrid {
  display: grid !important;
  width: 100% !important;
  grid-template-columns: repeat(5, minmax(0, 1fr)); /* 5 across on desktop */
  gap: 1.5rem;
}

/* Cards sit nicely in each grid cell */
#backgroundGrid .store-card,
#musicGrid .store-card {
  width: 100%;
  max-width: 260px;
  margin: 0 auto;
  gap: 2rem !important;   /* increase spacing between grid items */
  padding: 0.5rem;        /* prevents items from touching grid edges */
}

@media (max-width: 1200px) {
  #backgroundGrid,
  #musicGrid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 950px) {
  #backgroundGrid,
  #musicGrid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  #backgroundGrid,
  #musicGrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  #backgroundGrid,
  #musicGrid {
    display: flex !important;
    overflow-x: auto;
    gap: 16px;
    padding-bottom: 12px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }

  #backgroundGrid .store-card,
  #musicGrid .store-card {
    min-width: 220px;
    scroll-snap-align: start;
  }
}

/* =========================
   LAB EXPERIENCE (append)
   ========================= */

.hidden { display: none !important; }

.lab-shell{
  display:grid;
  grid-template-columns: 260px 1fr;
  gap: 18px;
  align-items:start;
}

/* Glass + scanline vibe */
.lab-stations, .lab-content, .lab-loadout .loadout-card {
  background: rgba(0,0,0,0.68);
  border: 1px solid rgba(21,255,0,0.35);
  border-radius: 14px;
  box-shadow: 0 0 18px rgba(21,255,0,0.15);
  backdrop-filter: blur(6px);
}

.lab-stations{
  padding: 14px;
  position: sticky;
  top: 16px;
}

.lab-title{
  margin:0 0 12px 0;
  letter-spacing: 1px;
}

.station-btn{
  width:100%;
  text-align:left;
  padding: 12px 12px;
  margin: 8px 0;
  border-radius: 12px;
  border: 1px solid rgba(21,255,0,0.35);
  background: rgba(0,0,0,0.55);
  color:#eaffea;
  cursor:pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}

.station-btn:hover{ transform: translateY(-1px); box-shadow: 0 0 10px rgba(21,255,0,0.22); }
.station-btn.active{ background: rgba(21,255,0,0.12); border-color: rgba(21,255,0,0.65); }
.station-btn.locked{ opacity: 0.55; cursor:not-allowed; }
.station-sub{ display:block; font-size: 12px; opacity:.8; margin-top:4px; }

.station-divider{ height:1px; background: rgba(21,255,0,0.18); margin: 10px 0; }

.lab-overrides h3{ margin: 10px 0 8px 0; font-size: 14px; }
.lab-overrides label{ display:block; font-size: 13px; margin: 8px 0; opacity: .95; }

.lab-content{ padding: 14px; position: relative; overflow: visible; padding-right: 30px;}
.lab-content::before{
  content:"";
  border-radius: 14px;  /* match your card radius */
  position:absolute; inset:0;
  pointer-events:none;
  opacity: 0.07;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,0.10) 0px,
    rgba(255,255,255,0.10) 1px,
    rgba(0,0,0,0) 3px,
    rgba(0,0,0,0) 6px
  );
}

.lab-loadout{
  position: sticky;
  top: 16px;
}

.loadout-card{ padding: 14px; }
.loadout-row{ display:flex; justify-content:space-between; align-items:center; }
.muted{ opacity:.8; }
.small{ font-size: 12px; }

.zb{ font-weight: 800; color:#15ff00; }

.loadout-divider{ height:1px; background: rgba(21,255,0,0.18); margin: 12px 0; }

.loadout-block h3{ margin: 0 0 8px 0; }
.mini-preview{
  width: 100%;
  height: 110px;
  border-radius: 12px;
  border: 1px solid rgba(21,255,0,0.25);
  background: rgba(0,0,0,0.45);
  background-size: cover;
  background-position: center;
  margin-bottom: 10px;
}

/* Lab buttons */
.lab-btn{
  margin: 6px 0;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 0;
  cursor: pointer;
  font-weight: 800;
  background: #15ff00;
  color: #000;
}
.lab-btn:hover{ filter: brightness(1.05); }
.lab-btn.ghost{
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(21,255,0,0.35);
  color: #eaffea;
}

/* Simulation chamber */
.sim-content{ max-width: 980px; width: min(980px, 92vw); }
.sim-header{ display:flex; justify-content:space-between; align-items:center; gap: 12px; margin-bottom: 10px; }
.sim-backdrop{
  height: 360px;
  border-radius: 14px;
  border: 1px solid rgba(21,255,0,0.35);
  background: rgba(0,0,0,0.55);
  background-size: contain;
  background-position: center;
  display:flex;
  align-items:center;
  justify-content:center;
  position:relative;
  overflow:hidden;
}
.sim-profilecard{
  width: 340px;
  border-radius: 18px;
  padding: 16px;
  background: rgba(0,0,0,0.72);
  border: 1px solid rgba(21,255,0,0.28);
  box-shadow: 0 0 18px rgba(21,255,0,0.12);
}

.sim-top{
  display:flex;
  gap:12px;
  align-items:center;
  margin-bottom:12px;
}

.sim-userpic{
  width:84px;
  height:84px;
  border-radius:14px;
  border: 1px solid rgba(21,255,0,0.35);
  object-fit: cover;
  background: rgba(0,0,0,0.35);
}

.sim-username{
  font-weight: 900;
  font-size: 16px;
  color: #eaffea;
}

.sim-usermeta{
  font-size: 12px;
  opacity: .85;
}

.sim-bio{
  margin-top: 4px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(21,255,0,0.22);
  background: rgba(0,0,0,0.35);
  min-height: 70px;
  line-height: 1.35;
  font-size: 13px;
  color: #eaffea;
}

.sim-avatar{
  width: 84px;
  height: 84px;
  border-radius: 14px;
  border: 1px solid rgba(21,255,0,0.35);
  background: rgba(21,255,0,0.10);
  margin-bottom: 12px;
}
.sim-lines .line{
  height: 10px;
  border-radius: 99px;
  background: rgba(255,255,255,0.10);
  margin: 10px 0;
}
.sim-lines .line.short{ width: 55%; }
.sim-chip{
  display:inline-block;
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(21,255,0,0.35);
  background: rgba(21,255,0,0.10);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: .6px;
}
.sim-controls{
  display:flex;
  gap: 16px;
  align-items:center;
  justify-content:space-between;
  margin-top: 12px;
}
.sim-name{ font-weight: 900; font-size: 18px; }

/* Safety overrides behavior */
body.reduce-motion *{ animation: none !important; transition: none !important; }
body.high-contrast .lab-stations,
body.high-contrast .lab-content,
body.high-contrast .loadout-card{
  border-color: rgba(21,255,0,0.75);
}

/* Responsive */
@media (max-width: 1100px){
  .lab-shell{ grid-template-columns: 1fr; }
  .lab-stations{ position: static; } /* keep only stations static */
  /* DO NOT touch .lab-loadout here */
}

/* ===== LAB BACKDROP (default + user-selected override) ===== */
.page-wrapper{
  /* Default lab images */
  --lab-default: url("../assets/backgrounds/lab-bg.png");
  --lab-mobile:  url("../assets/backgrounds/lab-mobile.png");

  /* User-selected background (set by JS). Starts empty. */
  --user-bg: none;

  /* If JS sets --user-bg, it will show. Otherwise default lab bg shows. */
  background-image: var(--user-bg, var(--lab-default));

  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  min-height: 100vh;
}

/* Mobile override: still supports user background */
@media (max-width: 768px){
  .page-wrapper{
    background-image:
      linear-gradient(to bottom, rgba(0,0,0,0.80), rgba(0,0,0,0.95)),
      var(--user-bg, var(--lab-mobile));
    background-attachment: scroll;
    background-position: center top;
  }
}

/* Adds “glass” readability behind your 3 columns */
.lab-shell {
  padding: 18px;
}

/* Optional: subtle vignette on top of everything */
.page-wrapper::before{
  content:"";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(circle at center, rgba(0,0,0,0) 35%, rgba(0,0,0,0.65) 100%);
}

/* Ensure content is above vignette overlay */
.page-wrapper > * {
  position: relative;
  z-index: 1;
}

/* ===== Mobile: Dock the loadout at bottom (small phones) ===== */
@media (max-width: 700px) {
  .lab-shell {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .lab-loadout {
  position: sticky;
  bottom: 12px;
  z-index: 200;
}

  /* Make it collapsible */
  .lab-loadout .loadout-card {
    max-height: 42vh;           /* doesn't take whole screen */
    overflow: auto;
  }

  /* Add space so content isn't hidden behind dock */
  .lab-content {
    padding-bottom: 46vh;       /* space for dock */
  }

  /* Optional: slightly smaller buttons/text */
  .lab-btn { padding: 10px; }
}

/* Collapsed state */
@media (max-width: 700px) {
  .lab-loadout.collapsed .loadout-card {
    max-height: 64px;
    overflow: hidden;
  }
}

/* ===== FORCE SIM MODAL TO BE A REAL OVERLAY ===== */
#simModal.modal {
  position: fixed !important;
  inset: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: rgba(0,0,0,0.85) !important;
  z-index: 99999 !important;
}

#simModal.modal.hidden {
  display: none !important;
}

/* keep the card sized nicely on mobile too */
#simModal .modal-content {
  max-height: 90vh;
  overflow: auto;
}

@media (max-width: 700px) {
  .lab-loadout .loadout-card {
    backdrop-filter: blur(10px);
    background: linear-gradient(
      to top,
      rgba(0,0,0,0.92),
      rgba(0,0,0,0.65)
    );
    border-radius: 16px;
    box-shadow: 0 -10px 30px rgba(21,255,0,0.25);
  }
}

@media (max-width: 700px) {
  #simModal .modal-content {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    max-width: none;
    max-height: none;
  }

  .sim-backdrop {
    height: 50vh;
  }
}

@media (max-width: 480px) {
  .grid {
    display: flex;
    overflow-x: auto;
    gap: 16px;
    padding-bottom: 12px;
  }

  .store-card {
    min-width: 220px;
  }
}

/* Override global style.css that forces transparent backgrounds */
.page-wrapper {
  background: none !important;
  background-image:
    linear-gradient(to bottom, rgba(0,0,0,0.35), rgba(0,0,0,0.55)),
    var(--user-bg, url("../assets/backgrounds/lab-bg.png")) !important;
  background-size: cover !important;
  background-position: center !important;
  background-attachment: fixed !important;
}

/* =========================
   HARD OVERRIDE: LAB BACKGROUND
   Put background on BODY so global .page-wrapper rules can't kill it
   ========================= */

body.lab-page {
  background-image:
    linear-gradient(to bottom, rgba(0,0,0,0.35), rgba(0,0,0,0.75)),
    url("../assets/backgrounds/lab-bg.png");
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  min-height: 100vh;
}

/* Mobile version */
@media (max-width: 768px) {
  body.lab-page {
    background-image:
      linear-gradient(to bottom, rgba(0,0,0,0.75), rgba(0,0,0,0.95)),
      url("../assets/backgrounds/lab-mobile.png");
    background-attachment: scroll;
    background-position: center top;
  }
}

/* Keep wrapper transparent (fine) */
body.lab-page .page-wrapper {
  background: transparent !important;
}

@supports (-webkit-touch-callout: none) {
  .user-menu .dropdown,
  .notif-dropdown {
    will-change: transform;
  }
}

/* 🔥 FIX: vignette must never intercept taps */
.page-wrapper::before {
  pointer-events: none !important;
}

/* 🔥 FIX: allow dropdowns to escape lab containers (mobile) */
body.lab-page,
body.lab-page .page-wrapper,
body.lab-page .lab-shell,
body.lab-page .lab-content {
  overflow: visible !important;
}

/* LAB ONLY: dropdown escapes layout safely */
body.lab-page .user-menu {
  position: static;
}

body.lab-page #userDropdown {
  position: fixed;
  top: 72px;
  right: 12px;
  z-index: 999999;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
}
