/* moddb mod browser overlay. Sits on top of the existing #boot panel
 * with its own z-index. Reuses the design tokens from doom/index.css
 * (--bg / --panel / --accent / etc.) so it inherits the active flavor
 * accent color automatically.
 *
 * Layout: a fixed-position overlay split into header / search / status /
 * grid / pagination, with a slide-in detail panel that overlays the grid
 * when the user picks a mod. Scoped under .moddb-panel and #moddbBrowser
 * so nothing leaks into the rest of the page.
 */

#moddbBrowser.moddb-panel {
  position: fixed;
  inset: 0;
  z-index: 25;
  background: var(--bg);
  color: var(--text);
  overflow-y: auto;
  padding: 18px 18px 48px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
#moddbBrowser.moddb-panel.hidden {
  display: none;
}
body.moddb-open #boot,
body.moddb-open #fsBtn,
body.moddb-open #flavorSwitcher,
body.moddb-open #flavorPickerSwitcher {
  /* Hide the boot overlay underneath so we don't paint two stacks of UI.
     The engine canvas (if it's running) stays visible behind us, but
     #moddbBrowser has a solid bg so it's covered. */
  display: none !important;
}

.moddb-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}
.moddb-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.moddb-title h2 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 1.5px;
  color: var(--accent);
  text-transform: uppercase;
}
.moddb-emoji {
  font-size: 22px;
}
.moddb-close {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--dim);
  font-size: 18px;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
}
.moddb-close:hover {
  border-color: var(--border-hot);
  color: var(--text);
}

.moddb-disclaimer {
  font-size: 11px;
  color: var(--dim);
  background: rgba(219, 180, 68, 0.06);
  border: 1px solid rgba(219, 180, 68, 0.25);
  border-radius: 4px;
  padding: 8px 12px;
  line-height: 1.5;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.moddb-search {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}
.moddb-search input[type='search'] {
  flex: 1 1 280px;
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  font-family: inherit;
  font-size: 13px;
  border-radius: 3px;
  min-width: 200px;
}
.moddb-search input[type='search']:focus {
  outline: none;
  border-color: var(--accent-dim);
}
.moddb-search select {
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  font-family: inherit;
  font-size: 12px;
  border-radius: 3px;
}

.moddb-status {
  font-size: 12px;
  color: var(--dim);
  min-height: 18px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}
.moddb-status.err {
  color: var(--warn);
}

.moddb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}
.moddb-grid.dimmed {
  opacity: 0.35;
  pointer-events: none;
}

.moddb-card {
  all: unset;
  cursor: pointer;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-dim);
  border-radius: 4px;
  padding: 0;
  display: flex;
  flex-direction: column;
  transition: border-color 120ms, transform 120ms, background 120ms;
  overflow: hidden;
}
.moddb-card:hover {
  background: var(--panel2);
  border-color: var(--border-hot);
  border-left-color: var(--accent);
  transform: translateY(-1px);
}
.moddb-card-thumb {
  width: 100%;
  height: 140px;
  object-fit: cover;
  background: #000;
  border-bottom: 1px solid var(--border);
}
.moddb-card-thumb.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  color: var(--dim);
}
.moddb-card-body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.moddb-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.5px;
}
.moddb-card-game {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--bg, #111);
  background: var(--accent, #c08400);
  border-radius: 8px;
  vertical-align: middle;
}
.moddb-card-summary {
  font-size: 11px;
  color: var(--dim);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.moddb-pagination {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  margin-top: 12px;
  max-width: 1100px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}
.moddb-pagination button {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 3px;
  cursor: pointer;
}
.moddb-pagination button:hover:not([disabled]) {
  border-color: var(--border-hot);
  background: var(--panel2);
}
.moddb-pagination button[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}
.moddb-page-label {
  font-size: 11px;
  color: var(--dim);
}

/* Detail panel — slides in over the grid when a mod is picked. */
.moddb-detail {
  position: fixed;
  inset: 0;
  z-index: 26;
  background: var(--bg);
  padding: 18px 18px 48px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.moddb-detail.hidden {
  display: none;
}
.moddb-detail h3 {
  margin: 0;
  font-size: 18px;
  color: var(--accent);
  letter-spacing: 1px;
  max-width: 900px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}
.moddb-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}
.moddb-back,
.moddb-extlink {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 3px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.moddb-back:hover,
.moddb-extlink:hover {
  border-color: var(--border-hot);
  background: var(--panel2);
}
.moddb-extlink {
  color: var(--accent);
}

.moddb-detail-status {
  font-size: 12px;
  color: var(--dim);
  min-height: 18px;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}
.moddb-detail-status.err {
  color: var(--warn);
}

.moddb-detail-body {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.moddb-shots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}
.moddb-shots img {
  width: 100%;
  height: 130px;
  object-fit: cover;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 3px;
}

.moddb-summary {
  margin: 0;
  font-size: 12px;
  color: var(--text);
  line-height: 1.6;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px 14px;
  white-space: pre-wrap;
}

.moddb-iwad {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 14px 12px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.moddb-iwad legend {
  font-size: 10px;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 2px;
  padding: 0 6px;
}
.moddb-iwad label {
  font-size: 12px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.moddb-iwad input[type='radio'] {
  accent-color: var(--accent);
}
.moddb-iwad-hint {
  font-size: 11px;
  color: var(--dim);
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
}
.moddb-iwad-hint em {
  color: var(--gold);
  font-style: normal;
}

.moddb-launch-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.moddb-launch {
  padding: 10px 22px;
  font-size: 13px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}
.moddb-launch-note {
  font-size: 11px;
  color: var(--dim);
  flex: 1 1 200px;
  line-height: 1.5;
}

/* Mobile tweaks. Smaller cards, larger touch targets, single-column. */
body.mobile #moddbBrowser.moddb-panel {
  padding: 14px 12px 32px;
}
body.mobile .moddb-grid {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
body.mobile .moddb-card-thumb {
  height: 110px;
}
body.mobile .moddb-search input[type='search'],
body.mobile .moddb-search select {
  font-size: 14px;
  padding: 10px 12px;
}
body.mobile .moddb-pagination button {
  padding: 10px 16px;
  font-size: 13px;
}
body.mobile .moddb-iwad label {
  padding: 6px 0;
  font-size: 13px;
}
