/* ============================================================
   RomsMania — Launcher view
   Console-frontend presentation of the library (Daijishou /
   Batocera style). Deliberately dark even on the light site: the
   contrast is the point — the user "enters the console".

   Depends on tokens from style.css (--rm-orange, --rm-blue, …)
   and the z-index scale in critical.css.
   ============================================================ */

/* ---------- View switch (Grid ⇄ Launcher) ---------- */
.rm-view-switch {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 2px solid var(--rm-border);
  border-radius: var(--rm-radius-lg);
  background: var(--rm-bg-alt);
}

.rm-view-switch__btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: none;
  border-radius: calc(var(--rm-radius-lg) - 4px);
  background: transparent;
  color: var(--rm-text-muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: background var(--rm-transition), color var(--rm-transition);
}

.rm-view-switch__btn:hover { color: var(--rm-text); }

.rm-view-switch__btn.is-active {
  background: var(--rm-blue);
  color: #fff;
  box-shadow: 0 2px 0 var(--rm-blue-dark);
}

.rm-view-switch__icon { font-size: 1rem; line-height: 1; }

.rm-view-switch__btn:focus-visible {
  outline: 2px solid var(--rm-orange);
  outline-offset: 2px;
}

@media (max-width: 640px) {
  .rm-view-switch__label { display: none; }
  .rm-view-switch__btn { padding: 8px 12px; }
}

/* ---------- Launcher shell ---------- */
.rm-launcher {
  --rm-launcher-ink: #e8ecf8;
  --rm-launcher-dim: #8b93ad;
  --rm-launcher-line: rgba(255, 255, 255, 0.09);

  position: relative;
  margin: 8px 0 28px;
  border: 3px solid var(--rm-border-dark);
  border-radius: var(--rm-radius-xl);
  background: var(--rm-bg-dark);
  box-shadow: var(--rm-shadow-xl), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  overflow: hidden;
  color: var(--rm-launcher-ink);
}

.rm-launcher[hidden] { display: none; }

/* Faint CRT grid so the panel reads as a screen, not a div. */
.rm-launcher::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--rm-launcher-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--rm-launcher-line) 1px, transparent 1px);
  background-size: 44px 44px;
  opacity: 0.35;
  pointer-events: none;
}

.rm-launcher__frame {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  min-height: 540px;
  position: relative;
}

/* ---------- Left pane: the title list ---------- */
.rm-launcher__list-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-right: 2px solid var(--rm-launcher-line);
  background: rgba(0, 0, 0, 0.28);
}

.rm-launcher__list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 2px solid var(--rm-launcher-line);
}

.rm-launcher__list-label {
  font-size: 0.62rem;
  color: var(--rm-orange);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rm-launcher__list-count {
  flex: none;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--rm-launcher-dim);
}

.rm-launcher__list {
  flex: 1;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--rm-blue) transparent;
}

.rm-launcher__list:focus-visible {
  outline: 2px solid var(--rm-orange);
  outline-offset: -2px;
}

.rm-launcher__list::-webkit-scrollbar { width: 8px; }
.rm-launcher__list::-webkit-scrollbar-track { background: transparent; }
.rm-launcher__list::-webkit-scrollbar-thumb {
  border-radius: 4px;
  background: var(--rm-blue);
}

.rm-launcher__row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--rm-radius);
  color: var(--rm-launcher-ink);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
  transition: background var(--rm-transition), color var(--rm-transition);
}

.rm-launcher__row:hover { background: rgba(255, 255, 255, 0.07); }

.rm-launcher__row.is-active {
  background: var(--rm-orange);
  color: #16130c;
  font-weight: 800;
  box-shadow: 0 2px 0 var(--rm-orange-dark);
}

.rm-launcher__row-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rm-launcher__row-fav {
  flex: none;
  color: var(--rm-red);
  font-size: 0.85rem;
}

.rm-launcher__row.is-active .rm-launcher__row-fav { color: #16130c; }

/* ---------- Right pane: the detail ---------- */
.rm-launcher__detail {
  display: grid;
  grid-template-columns: minmax(180px, 260px) 1fr;
  align-content: center;
  gap: 32px;
  padding: 36px 40px;
  min-width: 0;
}

.rm-launcher__art {
  position: relative;
  align-self: center;
}

.rm-launcher__art img {
  width: 100%;
  height: auto;
  border: 3px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--rm-radius-lg);
  background: #000;
  box-shadow: 0 22px 46px rgba(0, 0, 0, 0.55), var(--rm-glow-blue);
  aspect-ratio: 3 / 4;
  object-fit: cover;
}

.rm-launcher__art-badge {
  position: absolute;
  top: -10px;
  left: -10px;
  padding: 5px 10px;
  border-radius: var(--rm-radius);
  background: var(--rm-green);
  color: #fff;
  font-family: var(--font-pixel);
  font-size: 0.52rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: 0 3px 0 var(--rm-green-dark);
}

.rm-launcher__info { min-width: 0; }

.rm-launcher__platform {
  display: inline-block;
  margin-bottom: 12px;
  padding: 5px 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--rm-radius);
  background: rgba(60, 101, 199, 0.28);
  color: #cfe0ff;
  font-size: 0.55rem;
}

.rm-launcher__platform:empty { display: none; }

.rm-launcher__title {
  margin-bottom: 10px;
  color: #fff;
  font-size: clamp(1.5rem, 2.6vw, 2.25rem);
  line-height: 1.15;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
}

.rm-launcher__meta {
  margin-bottom: 16px;
  color: var(--rm-orange);
  font-size: 0.9rem;
  font-weight: 700;
}

.rm-launcher__summary {
  margin-bottom: 26px;
  max-width: 56ch;
  color: var(--rm-launcher-dim);
  font-size: 0.95rem;
  line-height: 1.65;
}

.rm-launcher__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.rm-launcher__btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 13px 24px;
  border: 2px solid transparent;
  border-radius: var(--rm-radius-lg);
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  transition: transform var(--rm-transition), background var(--rm-transition);
}

.rm-launcher__btn--primary {
  background: var(--rm-orange);
  color: #fff;
  box-shadow: 0 4px 0 var(--rm-orange-dark);
}

.rm-launcher__btn--ghost {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.06);
  color: var(--rm-launcher-ink);
}

.rm-launcher__btn:hover { transform: translateY(-2px); }
.rm-launcher__btn--primary:hover { color: #fff; }

.rm-launcher__btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.rm-launcher__btn-heart { color: var(--rm-launcher-dim); transition: color var(--rm-transition); }
.rm-launcher__btn--ghost[aria-pressed='true'] { border-color: var(--rm-red); }
.rm-launcher__btn--ghost[aria-pressed='true'] .rm-launcher__btn-heart { color: var(--rm-red); }

/* ---------- Status bar ---------- */
.rm-launcher__statusbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 11px 20px;
  position: relative;
  border-top: 2px solid var(--rm-launcher-line);
  background: var(--rm-bg-darker);
  font-size: 0.72rem;
  color: var(--rm-launcher-dim);
}

.rm-launcher__clock {
  font-family: var(--font-pixel);
  font-size: 0.58rem;
  color: var(--rm-green);
}

.rm-launcher__position {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rm-launcher__hints {
  display: flex;
  flex: none;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.rm-launcher__key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  margin-left: 8px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-family: var(--font-pixel);
  font-size: 0.5rem;
}

.rm-launcher__key--a { background: var(--rm-green); }
.rm-launcher__key--b { background: var(--rm-red); }
.rm-launcher__key:first-child { margin-left: 0; }

/* Lit up while a real gamepad is connected. */
.rm-launcher.is-gamepad .rm-launcher__key--a,
.rm-launcher.is-gamepad .rm-launcher__key--b {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .rm-launcher__frame {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .rm-launcher__detail {
    grid-template-columns: 132px 1fr;
    gap: 20px;
    padding: 22px;
    border-bottom: 2px solid var(--rm-launcher-line);
  }

  .rm-launcher__list-pane {
    border-right: none;
    max-height: 46vh;
  }

  .rm-launcher__summary { display: none; }

  .rm-launcher__hints { display: none; }
}

@media (max-width: 480px) {
  .rm-launcher__detail { grid-template-columns: 96px 1fr; padding: 16px; }
  .rm-launcher__actions { gap: 8px; }
  .rm-launcher__btn { flex: 1; justify-content: center; padding: 12px 14px; font-size: 0.75rem; }
}

/* ---------- Motion / FX opt-outs ---------- */
@media (prefers-reduced-motion: reduce) {
  .rm-launcher__btn,
  .rm-launcher__row { transition: none; }
  .rm-launcher__btn:hover { transform: none; }
}

.rm-no-fx .rm-launcher::before { display: none; }
.rm-no-fx .rm-launcher__art img { box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5); }
