/* ============================================
   NexDisplayAPI — generic states & built-in
   templates not covered by existing CSS.
   ============================================ */

/* Status messages share these so empty/error/loading look intentional. */
.nex-display-message {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  color: var(--text-secondary);
  text-align: center;
  font-size: 0.95rem;
}
.nex-display-empty-text,
.nex-display-error-text {
  margin: 0;
  max-width: 32ch;
  line-height: 1.5;
}
.nex-display-error .nex-display-error-text {
  color: var(--danger);
}

/* Spinner used for the default loading state. Keeps to brand colors. */
.nex-display-spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-primary);
  animation: nex-spin 0.8s linear infinite;
}
@keyframes nex-spin {
  to { transform: rotate(360deg); }
}

/* Scope hooks: anything bound via data-nex-display gets a state class. */
[data-nex-state="loading"] {
  min-height: 160px;
}

/* Built-in `script-row` template (compact list mode). */
.nex-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 16px;
  align-items: center;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  text-decoration: none;
  color: var(--text-primary);
  transition: border-color var(--transition-fast), transform var(--transition-fast);
}
.nex-row + .nex-row { margin-top: 8px; }
.nex-row:hover {
  border-color: var(--border-light);
  transform: translateX(2px);
}
.nex-row-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nex-row-game {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.nex-row-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Built-in `script-detail` fallback template. Pages with a real detail
   layout will override this; it exists so a `data-nex-display="detail"`
   element with no template still renders something usable. */
.nex-detail {
  display: grid;
  gap: 16px;
}
.nex-detail-thumbnail {
  width: 100%;
  max-width: 720px;
  aspect-ratio: 16 / 9;
  /* Contain so logos/banners aren't stretched; matte fills the bars. */
  object-fit: contain;
  border-radius: var(--radius-lg);
  background: #0d0d10;
  display: block;
}
.nex-detail-title {
  font-size: 2rem;
  margin: 0;
}
.nex-detail-meta {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0;
}
.nex-detail-price {
  font-size: 1.1rem;
  color: var(--accent-primary);
  font-weight: 700;
  margin: 0;
}
.nex-detail-description {
  color: var(--text-secondary);
  line-height: 1.6;
  white-space: pre-wrap;
  margin: 0;
}
.nex-detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.nex-tag {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Filter buttons get a basic active state for free.
   Pages can replace this with their own design. */
[data-nex-filter].is-active {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}
.nex-ad-stack{display:grid;gap:12px;width:min(1120px,calc(100% - 32px));margin:18px auto}
.nex-ad-text a{display:flex;align-items:center;gap:16px;text-decoration:none;color:#eee;background:#1c1c1c;border:1px solid #3c3c3c;border-radius:12px;padding:14px 16px}
.nex-ad-text a:hover{border-color:#6d6554}
.nex-ad-banner a{position:relative;display:flex;align-items:flex-end;min-height:180px;overflow:hidden;text-decoration:none;color:#f4f4f4;background:#141414 center/cover no-repeat;border:1px solid #3c3c3c;border-radius:16px;padding:24px 28px}
.nex-ad-banner a::before{content:"";position:absolute;inset:0;background:linear-gradient(90deg,#141414 0%,#141414f5 34%,#141414c7 48%,#14141400 76%);pointer-events:none}
.nex-ad-banner a:hover{border-color:#6d6554}
.nex-ad-banner .nex-ad-copy{position:relative;z-index:1;max-width:min(420px,46%)}.nex-ad-banner .nex-ad-copy span:last-child{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.nex-ad-copy{display:grid;gap:4px;min-width:0}
.nex-ad-kicker{color:#d7cfbb;font-size:11px;letter-spacing:.08em;text-transform:uppercase}
.nex-ad-copy strong{font-size:20px;font-weight:650;letter-spacing:-.3px}
.nex-ad-copy span:last-child{color:#c8c8c8;font-size:13px;line-height:1.45}
.nex-ad-text .nex-ad-copy strong{font-size:16px}
@media(max-width:640px){.nex-ad-banner a{min-height:150px;align-items:flex-end;padding:18px}.nex-ad-banner .nex-ad-copy{max-width:86%}.nex-ad-banner a::before{background:linear-gradient(90deg,#141414 0%,#141414f2 46%,#14141466 100%)}}
