/* TokenCap — dark-first crypto market tracker */
:root {
  --bg: #070a0f;
  --bg-elevated: #0c1118;
  --bg-card: #101820;
  --bg-hover: #16202c;
  --border: rgba(148, 163, 184, 0.12);
  --border-strong: rgba(148, 163, 184, 0.22);
  --text: #e8eef6;
  --text-muted: #8b9cb3;
  --text-dim: #5c6b80;
  --accent: #34d399;
  --accent-2: #22d3ee;
  --accent-soft: rgba(52, 211, 153, 0.12);
  --up: #34d399;
  --up-soft: rgba(52, 211, 153, 0.14);
  --down: #f87171;
  --down-soft: rgba(248, 113, 113, 0.14);
  --warn: #fbbf24;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --font: "DM Sans", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --header-h: 64px;
  --stats-h: 52px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(52, 211, 153, 0.08), transparent),
    radial-gradient(ellipse 40% 30% at 90% 10%, rgba(34, 211, 238, 0.05), transparent);
  background-attachment: fixed;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input { font: inherit; color: inherit; }

/* —— Header —— */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: rgba(7, 10, 15, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.25rem;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none !important;
  flex-shrink: 0;
}

.brand-mark { width: 32px; height: 32px; display: block; }
.brand-mark svg { width: 100%; height: 100%; }

.brand-text {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 420px;
}

.search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-dim);
  pointer-events: none;
}

#search-input {
  width: 100%;
  height: 40px;
  padding: 0 2.5rem 0 2.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  outline: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

#search-input::placeholder { color: var(--text-dim); }

#search-input:focus {
  border-color: rgba(52, 211, 153, 0.45);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-hint {
  position: absolute;
  right: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  pointer-events: none;
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 360px;
  overflow-y: auto;
  z-index: 200;
}

.search-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background 0.15s;
}

.search-item:hover,
.search-item.active {
  background: var(--bg-hover);
}

.search-item img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

.search-item-name { font-weight: 550; font-size: 0.9rem; }
.search-item-sym {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
}
.search-item-rank {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-dim);
}

.search-empty {
  padding: 1.25rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.header-meta { margin-left: auto; flex-shrink: 0; }

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(52, 211, 153, 0.25);
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* —— Global stats —— */
.global-stats {
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.stats-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.75rem;
  align-items: center;
}

.stat {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.stat-label {
  color: var(--text-muted);
  font-weight: 500;
}

.stat-value {
  font-family: var(--mono);
  font-weight: 550;
  font-size: 0.85rem;
  letter-spacing: -0.02em;
}

.stat-change.up { color: var(--up); }
.stat-change.down { color: var(--down); }

/* —— Category tabs —— */
.category-nav {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.65rem 1.25rem 0;
  display: flex;
  flex-wrap: nowrap;
  gap: 0.4rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  border-bottom: 1px solid var(--border);
}

.cat-tab {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  padding: 0.55rem 0.95rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-muted);
  text-decoration: none !important;
  border-radius: 999px 999px 0 0;
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.cat-tab:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.cat-tab.active {
  color: var(--accent);
  background: var(--bg-card);
  border-color: var(--border);
  box-shadow: inset 0 2px 0 var(--accent);
}

.view-intro {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.55;
  max-width: 62ch;
  margin-top: 0.45rem;
}

.view-sub {
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-top: 0.35rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* —— Main —— */
.main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  min-height: calc(100vh - var(--header-h) - var(--stats-h) - 80px);
}

.loading-screen,
.state-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 4rem 1rem;
  color: var(--text-muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.state-block h2 { color: var(--text); font-size: 1.15rem; }
.state-block p { max-width: 360px; text-align: center; font-size: 0.9rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.btn:hover {
  background: var(--bg-hover);
  border-color: rgba(52, 211, 153, 0.35);
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: linear-gradient(135deg, #2dd4a0, #1cb8d4);
  color: #0a0e14;
  border: none;
}

.btn-primary:hover {
  filter: brightness(1.08);
  background: linear-gradient(135deg, #2dd4a0, #1cb8d4);
}

/* —— Markets view —— */
.view-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.view-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.view-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.2rem;
}

.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.25);
}

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.markets-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.markets-table th {
  position: sticky;
  top: 0;
  text-align: left;
  padding: 0.85rem 1rem;
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}

.markets-table th.sortable {
  cursor: pointer;
}

.markets-table th.sortable:hover { color: var(--text); }

.markets-table th .sort-ind {
  display: inline-block;
  margin-left: 0.25rem;
  opacity: 0.35;
  font-size: 0.65rem;
}

.markets-table th.sorted .sort-ind { opacity: 1; color: var(--accent); }

.markets-table th.num,
.markets-table td.num { text-align: right; }

.markets-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  vertical-align: middle;
}

.markets-table tbody tr {
  cursor: pointer;
  transition: background 0.12s;
}

.markets-table tbody tr:hover { background: var(--bg-hover); }
.markets-table tbody tr:last-child td { border-bottom: none; }

.rank {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-dim);
  width: 3rem;
}

.coin-cell {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 160px;
}

.coin-cell img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg);
}

.coin-name { font-weight: 600; letter-spacing: -0.01em; }
.coin-sym {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-left: 0.35rem;
}

.price { font-family: var(--mono); font-weight: 500; font-variant-numeric: tabular-nums; }

.change {
  font-family: var(--mono);
  font-weight: 550;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  display: inline-block;
}

.change.up { color: var(--up); background: var(--up-soft); }
.change.down { color: var(--down); background: var(--down-soft); }
.change.flat { color: var(--text-muted); }

.mcap, .vol {
  font-family: var(--mono);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.table-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}

.table-footer p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.pager {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pager span {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 5rem;
  text-align: center;
}

/* —— Coin detail —— */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 1.25rem;
  text-decoration: none !important;
  transition: color 0.15s;
}

.back-link:hover { color: var(--accent); }

.coin-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.75rem;
}

.coin-hero-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.coin-hero-left img {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.coin-hero h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.coin-hero .sym {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
}

.coin-rank-badge {
  display: inline-block;
  margin-top: 0.35rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
}

.coin-price-block { text-align: right; }

.coin-price {
  font-family: var(--mono);
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.coin-changes {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 860px) {
  .detail-grid { grid-template-columns: 1fr; }
  .coin-price-block { text-align: left; }
  .coin-changes { justify-content: flex-start; }
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.panel h2 {
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.chart-wrap {
  position: relative;
  height: 220px;
  width: 100%;
}

.chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.metrics {
  display: grid;
  gap: 0.85rem;
}

.metric {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.metric:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.metric-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.metric-value {
  font-family: var(--mono);
  font-size: 0.875rem;
  font-weight: 550;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.desc-panel {
  margin-top: 0;
}

.desc-panel .desc-body {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.65;
  max-height: 160px;
  overflow: hidden;
  position: relative;
}

.desc-panel .desc-body.expanded { max-height: none; }

.desc-panel .desc-body a { color: var(--accent-2); }

.desc-toggle {
  margin-top: 0.75rem;
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
}

.desc-toggle:hover { text-decoration: underline; }

/* Skeleton */
.skeleton-row td {
  height: 52px;
}

.skel {
  display: inline-block;
  height: 0.85em;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--bg-hover) 25%, var(--bg-elevated) 50%, var(--bg-hover) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}

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

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 0.875rem;
  z-index: 500;
  transition: transform 0.3s var(--ease);
  max-width: min(90vw, 420px);
  text-align: center;
}

.toast.show { transform: translateX(-50%) translateY(0); }
.toast.warn { border-color: rgba(251, 191, 36, 0.4); }
.toast.error { border-color: rgba(248, 113, 113, 0.45); }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 1.25rem;
  margin-top: auto;
}

.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.footer-note a { color: var(--text-muted); }

/* Responsive */
@media (max-width: 720px) {
  .header-inner { gap: 0.75rem; }
  .brand-text { display: none; }
  .search-hint { display: none; }
  .search-wrap { max-width: none; }
  .live-pill { display: none; }
  .view-header h1 { font-size: 1.25rem; }
  .view-intro { font-size: 0.875rem; }
  .markets-table th, .markets-table td { padding: 0.7rem 0.65rem; }
  .coin-hero h1 { font-size: 1.35rem; }
  .coin-price { font-size: 1.5rem; }
  .stats-inner { gap: 0.4rem 1rem; }
  .category-nav { padding: 0.5rem 0.75rem 0; gap: 0.25rem; }
  .cat-tab { padding: 0.5rem 0.75rem; font-size: 0.75rem; }
}

/* Hide volume on very small screens to keep table readable */
@media (max-width: 560px) {
  .col-vol { display: none; }
}

/* —— SEO landing pages —— */
.landing-page #app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.landing-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.15rem;
  margin-left: auto;
  font-size: 0.875rem;
  font-weight: 500;
}

.landing-nav a {
  color: var(--text-muted);
  text-decoration: none;
}

.landing-nav a:hover {
  color: var(--accent);
  text-decoration: none;
}

.landing-main {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  width: 100%;
}

.landing-breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 1.25rem;
}

.landing-breadcrumbs a { color: var(--text-muted); }

.landing-hero {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.landing-hero h1 {
  font-size: clamp(1.65rem, 4vw, 2.15rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 0.75rem;
}

.landing-lead {
  color: var(--text-muted);
  font-size: 1.05rem;
  line-height: 1.65;
  margin-bottom: 1.25rem;
}

.landing-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.7rem 1.2rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0a0e14 !important;
  font-weight: 700;
  font-size: 0.9rem;
  border-radius: 999px;
  text-decoration: none !important;
  box-shadow: 0 4px 20px rgba(52, 211, 153, 0.25);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.landing-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 28px rgba(52, 211, 153, 0.35);
}

.landing-cta-wrap {
  margin-top: 1.75rem;
  margin-bottom: 0.5rem;
}

.landing-prose h2 {
  font-size: 1.2rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin: 1.75rem 0 0.65rem;
}

.landing-prose p {
  color: var(--text-muted);
  margin-bottom: 0.9rem;
  line-height: 1.7;
  font-size: 0.975rem;
}

.landing-prose strong { color: var(--text); font-weight: 600; }

.landing-faq {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.landing-faq h2 {
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

.landing-faq details {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  margin-bottom: 0.65rem;
}

.landing-faq summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  list-style: none;
}

.landing-faq summary::-webkit-details-marker { display: none; }

.landing-faq details[open] summary {
  margin-bottom: 0.5rem;
  color: var(--accent);
}

.landing-faq details p {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.65;
}

.landing-related {
  margin-top: 2rem;
  padding: 1.15rem 1.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.landing-related h2 {
  font-size: 0.95rem;
  margin-bottom: 0.65rem;
  color: var(--text);
}

.landing-related ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.landing-related a { font-size: 0.9rem; }

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  width: 100%;
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
}

.footer-links a { color: var(--text-muted); }
.footer-links a:hover { color: var(--accent); }

@media (max-width: 720px) {
  .landing-nav { display: none; }
  .landing-main { padding-top: 1rem; }
}
