/* components.css — shared visual primitives.
 *
 * Anything that's used on 3+ pages and would otherwise be re-invented in
 * each page's inline <style> block belongs here. Canonical list:
 *
 *   - .nv-toast*         — ephemeral feedback, paired with js/toast.js
 *   - .nv-empty*         — empty states for zero-data list views
 *   - .nv-skel--*        — content-shaped skeletons (feed row, market row,
 *                          source row, prediction card, table row)
 *   - .skip-link         — keyboard-user "skip to content" anchor
 *
 * All selectors are monochrome by design — colours come from tokens.css
 * so a theme flip updates every component without a per-component
 * override. If a design system change needs a coloured accent, add it
 * via a CSS variable, not a hard-coded hex.
 */


/* ── Toast region ────────────────────────────────────────────────────── */

#nv-toast-region {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.nv-toast {
  background: var(--bg-surface, #141414);
  color: var(--text-primary, #ffffff);
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.12));
  border-radius: 10px;
  padding: 12px 16px;
  font-size: var(--text-base);
  line-height: 1.45;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.16s ease, transform 0.16s ease;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 240px;
  max-width: 480px;
  cursor: pointer;
}

.nv-toast--enter { opacity: 1; transform: translateY(0); }
.nv-toast--exit  { opacity: 0; transform: translateY(-8px); }

/* Error toasts keep the same monochrome palette — we differentiate via
 * a subtle left border rather than a colour swap so the design stays
 * monochrome. Screen readers get the role=alert signal separately. */
.nv-toast--error { border-left: 2px solid var(--text-primary, #ffffff); }

.nv-toast--success { border-left: 2px solid var(--text-primary, #ffffff); }

.nv-toast__msg { flex: 1; min-width: 0; }

.nv-toast__action {
  background: none;
  border: none;
  color: var(--text-primary, #ffffff);
  font-weight: 500;
  font-size: var(--text-sm);
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  /* On phones the thumbs land at the top of the screen and the bottom
   * is reserved for the OS home bar — flip the region. */
  #nv-toast-region {
    bottom: auto;
    top: 24px;
  }
}


/* ── Empty states ────────────────────────────────────────────────────── */

.nv-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary, rgba(255, 255, 255, 0.7));
}

.nv-empty__icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 16px;
  color: var(--text-tertiary, rgba(255, 255, 255, 0.5));
  /* Inline SVGs set their own stroke/fill to currentColor so the icon
   * inherits the tertiary text colour without a per-icon override. */
}

.nv-empty__icon svg { width: 100%; height: 100%; display: block; }

.nv-empty__title {
  font-size: var(--text-md);
  font-weight: 500;
  color: var(--text-primary, #ffffff);
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

.nv-empty__body {
  font-size: var(--text-base);
  line-height: 1.55;
  max-width: 440px;
  margin: 0 auto 20px;
}

.nv-empty__actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.nv-empty__action {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.12));
  color: var(--text-secondary, rgba(255, 255, 255, 0.7));
  background: transparent;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.nv-empty__action:hover {
  border-color: var(--text-primary, #ffffff);
  color: var(--text-primary, #ffffff);
}

.nv-empty__action--primary {
  background: var(--text-primary, #ffffff);
  color: var(--bg-base, #0d0d0d);
  border-color: var(--text-primary, #ffffff);
}

.nv-empty__action--primary:hover {
  background: var(--text-secondary, rgba(255, 255, 255, 0.9));
  color: var(--bg-base, #0d0d0d);
}


/* ── Skeleton shapes ─────────────────────────────────────────────────── *
 * Shape variants live here; the existing skeletons.js library paints
 * them in and handles the shimmer animation. Each variant matches the
 * shape of the final rendered list item so the data swap doesn't
 * shift layout. */

.nv-skel {
  /* Shared shimmer base. Keep the gradient stops monochrome so the
   * skeleton blends with the monochrome chrome — coloured shimmers
   * fight the design grammar and flash garishly in dark mode. */
  background: linear-gradient(
    90deg,
    var(--bg-surface, #141414) 0%,
    var(--border-strong, rgba(255, 255, 255, 0.12)) 40%,
    var(--bg-surface, #141414) 80%
  );
  background-size: 200% 100%;
  animation: nv-skel-shimmer 1.6s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes nv-skel-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Respect users who've asked to reduce motion. */
@media (prefers-reduced-motion: reduce) {
  .nv-skel { animation: none; }
}

.nv-skel--row-feed {
  display: grid;
  grid-template-columns: 32px 1fr 80px;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
}
.nv-skel--row-feed > div:nth-child(1) { height: 32px; border-radius: 50%; }
.nv-skel--row-feed > div:nth-child(2) { height: 14px; }
.nv-skel--row-feed > div:nth-child(3) { height: 10px; }

.nv-skel--row-market {
  display: grid;
  grid-template-columns: 1fr 80px 60px;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
}
.nv-skel--row-market > div { height: 14px; }

.nv-skel--row-source {
  display: grid;
  grid-template-columns: 1fr 60px 100px;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
}
.nv-skel--row-source > div { height: 14px; }
.nv-skel--row-source > div:nth-child(3) { height: 24px; }

.nv-skel--card-prediction {
  padding: 16px;
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.08));
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}
.nv-skel--card-prediction > div:nth-child(1) { height: 14px; width: 60%; }
.nv-skel--card-prediction > div:nth-child(2) { height: 18px; width: 90%; }
.nv-skel--card-prediction > div:nth-child(3) { height: 12px; width: 40%; }

.nv-skel--row-table {
  display: grid;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  /* Caller sets grid-template-columns to match the real table. */
}
.nv-skel--row-table > div { height: 12px; }


/* ── Skip link ───────────────────────────────────────────────────────── */

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--text-primary, #ffffff);
  color: var(--bg-base, #0d0d0d);
  padding: 8px 12px;
  z-index: 10000;
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 500;
}

.skip-link:focus-visible {
  top: 0;
}


/* ── ⌘K command palette ──────────────────────────────────────────────
 *
 * The palette is rendered into <body> by js/cmdk.js the first time a
 * user opens it (lazy mount — pages that never invoke it pay zero
 * runtime cost). Selectors stay scoped to .nv-cmdk* so the palette
 * never inherits page-level form/input styling. Monochrome,
 * keyboard-first, with the same backdrop blur the modals already
 * use across the product.
 */

.nv-cmdk {
  position: fixed;
  inset: 0;
  z-index: 1100;            /* above toasts (1000) and any sticky chrome */
  display: none;
}

.nv-cmdk--open { display: block; }

.nv-cmdk__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  cursor: pointer;
}

.nv-cmdk__panel {
  position: absolute;
  top: 14vh;
  left: 50%;
  transform: translateX(-50%);
  width: min(640px, calc(100% - 32px));
  background: var(--bg-surface, #141414);
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.14));
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.32);
  display: flex;
  flex-direction: column;
  max-height: 70vh;
}

.nv-cmdk__input {
  width: 100%;
  padding: 16px 20px;
  border: none;
  background: transparent;
  color: var(--text-primary, #ffffff);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  border-bottom: 1px solid var(--border-strong, rgba(255, 255, 255, 0.08));
}

.nv-cmdk__input::placeholder {
  color: var(--text-tertiary, rgba(255, 255, 255, 0.4));
}

.nv-cmdk__results {
  overflow-y: auto;
  padding: 6px;
  flex: 1 1 auto;
}

.nv-cmdk__group-header {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary, rgba(255, 255, 255, 0.5));
  padding: 12px 12px 6px;
  font-weight: 500;
}

.nv-cmdk__row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-primary, #ffffff);
  cursor: pointer;
  font-size: var(--text-base);
  line-height: 1.4;
}

.nv-cmdk__row[aria-selected="true"],
.nv-cmdk__row--active,
.nv-cmdk__row:hover {
  background: var(--border-strong, rgba(255, 255, 255, 0.06));
}

.nv-cmdk__row-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nv-cmdk__row-title mark {
  background: transparent;
  color: var(--text-primary, #ffffff);
  font-weight: 600;
  text-decoration: underline;
}

.nv-cmdk__row-subtitle {
  color: var(--text-tertiary, rgba(255, 255, 255, 0.5));
  font-size: 12px;
  flex-shrink: 0;
  margin-left: 8px;
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nv-cmdk__no-results,
.nv-cmdk__hint {
  color: var(--text-tertiary, rgba(255, 255, 255, 0.6));
  padding: 24px 16px;
  font-size: var(--text-sm);
  line-height: 1.6;
  text-align: center;
}

.nv-cmdk__hint kbd {
  background: var(--border-strong, rgba(255, 255, 255, 0.08));
  border-radius: var(--radius-xs);
  padding: 2px 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--text-xs);
}

.nv-cmdk__hint-action {
  display: inline-block;
  margin-top: 12px;
  padding: 6px 14px;
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.14));
  border-radius: var(--radius-sm);
  color: var(--text-primary, #ffffff);
  text-decoration: none;
  font-size: 12px;
}

.nv-cmdk__footer {
  display: flex;
  gap: 16px;
  padding: 10px 16px;
  border-top: 1px solid var(--border-strong, rgba(255, 255, 255, 0.08));
  font-size: var(--text-xs);
  color: var(--text-tertiary, rgba(255, 255, 255, 0.5));
  flex-shrink: 0;
  flex-wrap: wrap;
}

.nv-cmdk__footer kbd {
  background: var(--border-strong, rgba(255, 255, 255, 0.08));
  padding: 2px 6px;
  border-radius: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  margin-right: 4px;
  color: var(--text-secondary, rgba(255, 255, 255, 0.7));
}

@media (max-width: 640px) {
  /* On phones the palette wants to sit closer to the top so the
   * thumb-reach zone matches the keyboard's "↩" key, and full-bleed
   * margins so the long market questions don't truncate at 3 chars. */
  .nv-cmdk__panel {
    top: 4vh;
    width: calc(100% - 16px);
    max-height: 90vh;
  }
  .nv-cmdk__footer { gap: 10px; font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .nv-cmdk__backdrop { backdrop-filter: none; -webkit-backdrop-filter: none; }
}


/* ── Share menu (data-share dropdown) ────────────────────────────────
 *
 * Generic copy / markdown / X / OG-preview menu rendered into any
 * element with [data-share]. Sits beside the existing token-mint
 * .narve-share-btn (which lives elsewhere in the cascade) — both
 * patterns are scoped, no selector overlap.
 */

.nv-share {
  display: inline-block;
  position: relative;
}

.nv-share__trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.12));
  padding: 6px 10px 6px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary, rgba(255, 255, 255, 0.7));
  cursor: pointer;
  font-size: var(--text-sm);
  font-family: inherit;
  line-height: 1;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.nv-share__trigger:hover,
.nv-share__trigger:focus-visible {
  color: var(--text-primary, #ffffff);
  border-color: var(--text-primary, #ffffff);
  outline: none;
}

.nv-share__icon { display: inline-flex; }
.nv-share__caret { display: inline-flex; opacity: 0.7; }

.nv-share--open .nv-share__caret { transform: rotate(180deg); }

.nv-share__menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 180px;
  background: var(--bg-surface, #141414);
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.14));
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.32);
  z-index: 80;
  padding: 4px;
  display: flex;
  flex-direction: column;
}

.nv-share__menu[hidden] { display: none; }

.nv-share__item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  background: none;
  border: none;
  color: var(--text-primary, #ffffff);
  font-size: var(--text-sm);
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  border-radius: var(--radius-sm);
  line-height: 1.4;
}

.nv-share__item:hover,
.nv-share__item:focus-visible {
  background: var(--border-strong, rgba(255, 255, 255, 0.08));
  outline: none;
}

@media (max-width: 640px) {
  /* On phones the menu wants to anchor flush-right with a slightly
   * larger tap target. Keep the dropdown shape — it slides under the
   * trigger as expected. */
  .nv-share__trigger { padding: 8px 12px; }
  .nv-share__item { padding: 10px 14px; font-size: var(--text-base); }
}
