/* ============================================================
   BCGAME Speed Navigator — Huggingface-inspired dark design
   ============================================================ */

:root {
  /* Canvas — HF uses a warm near-black with very slight purple */
  --bg: #0B0D12;
  --bg-2: #11131A;
  --surface: #171923;
  --surface-hi: #1E212D;
  --border: rgba(255, 255, 255, 0.08);
  --border-hi: rgba(255, 255, 255, 0.16);

  /* Text */
  --text: #F5F6FA;
  --text-2: #B6BAC7;
  --text-3: #787E90;

  /* HF-style accents */
  --accent: #FFD21E;       /* HF yellow */
  --accent-ink: #0B0D12;

  /* Card gradient palette — vivid, saturated, one per card */
  --card-pad: 20px;
  --gap: 16px;
  --radius: 18px;

  /* Quality */
  --good: #34D399;
  --ok:   #FBBF24;
  --bad:  #F87171;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 24px 48px -20px rgba(0, 0, 0, .6);
}

/* density via localStorage-driven class */
html[data-density="compact"]  { --card-pad: 16px; --gap: 12px; }
html[data-density="comfy"]    { --card-pad: 20px; --gap: 16px; }
html[data-density="spacious"] { --card-pad: 26px; --gap: 22px; }

html[data-radius="sharp"]   { --radius: 8px; }
html[data-radius="soft"]    { --radius: 18px; }
html[data-radius="pillowy"] { --radius: 26px; }

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body { min-height: 100%; }

body {
  font-family: 'Source Sans 3', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body::before {
  /* ambient glow, restrained */
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(60rem 40rem at 90% -10%, rgba(255, 210, 30, .06), transparent 60%),
    radial-gradient(50rem 30rem at -10% 20%, rgba(91, 70, 255, .08), transparent 60%);
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; }

/* ============================================
   Layout
   ============================================ */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 20px 120px;
  position: relative;
  z-index: 1;
}

/* ============================================
   Top Nav
   ============================================ */
.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0 22px;
}

.brand {
  display: inline-flex; align-items: center;
  min-width: 0;
  flex: none;
  transition: opacity .15s ease;
}
.brand:hover { opacity: .85; }
.brand-logo {
  height: 44px;
  width: auto;
  display: block;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, .4));
}

/* Live stats strip — replaces redundant top Support button */
.nav-stats {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  height: 38px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-2);
}
.nav-stat { display: inline-flex; align-items: center; gap: 8px; }
.nav-stat-label {
  color: var(--text-3);
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: .12em;
  font-weight: 600;
}
.nav-stat-value {
  color: var(--text);
  font-weight: 600;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}
.nav-stat-value.mono {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-weight: 600;
  letter-spacing: -.01em;
}
.nav-stat-value .u { color: var(--text-3); font-size: 11px; font-weight: 500; margin-left: 2px; }
.nav-stat-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, .18);
  animation: pulse-dot 2s ease-in-out infinite;
  flex: none;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%      { opacity: .45; }
}
.nav-stat-sep {
  width: 1px; height: 18px; background: var(--border);
}

/* ============================================
   Hero Section (Banner)
   ============================================ */
.hero-section {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 28px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.hero-banner {
  width: 100%;
  height: auto;
  display: block;
}

/* ============================================
   Section Header
   ============================================ */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}
.section-title-wrap { display: flex; align-items: center; gap: 10px; }
.section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.01em;
}
.section-count {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 12px;
  color: var(--text-3);
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.refresh-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.refresh-btn:hover {
  background: var(--surface-hi);
  border-color: var(--border-hi);
  color: var(--text);
}
.refresh-btn svg { width: 16px; height: 16px; }
.refresh-btn.spinning svg {
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================
   Grid — HF Spaces uses responsive auto-fill
   ============================================ */
.domains-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--gap);
  padding-bottom: 40px;
}

/* ============================================
   Card — HF Spaces style: vibrant gradient bg, chips, big title
   ============================================ */
.domain-card {
  position: relative;
  border-radius: var(--radius);
  padding: var(--card-pad);
  min-height: 200px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  transition: transform .2s ease, box-shadow .2s ease;
  isolation: isolate;
  color: #fff;
  background: var(--card-bg, linear-gradient(135deg, #3b82f6, #1e40af));
}

/* subtle darkening veil for readability */
.domain-card::before {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,.05) 0%, rgba(0,0,0,.35) 100%);
  z-index: 0;
  pointer-events: none;
}
/* noise/vignette — very subtle, HF cards have slight grain feel from the gradients */
.domain-card::after {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(120% 80% at 100% 0%, rgba(255,255,255,.14), transparent 60%),
    radial-gradient(120% 80% at 0% 100%, rgba(0,0,0,.2), transparent 60%);
  z-index: 0;
  pointer-events: none;
}

.domain-card > * { position: relative; z-index: 1; }

.domain-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 40px -18px rgba(0,0,0,.7), 0 0 0 1px rgba(255,255,255,.08) inset;
}

/* Card top row — status chip + badges */
.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px;
  padding: 0 10px;
  background: rgba(0, 0, 0, .35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 6px;
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 11.5px;
  font-weight: 500;
  color: rgba(255, 255, 255, .92);
  letter-spacing: -.005em;
  white-space: nowrap;
}
.chip b {
  color: #fff;
  font-weight: 700;
}
.chip .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, .2);
}
.chip[data-q="testing"] .dot { background: #fff; animation: blink 1s steps(2) infinite; }
.chip[data-q="slow"] .dot    { background: var(--bad); box-shadow: 0 0 0 3px rgba(248, 113, 113, .2); }
.chip[data-q="offline"] .dot { background: var(--bad); animation: none; }
@keyframes blink { 50% { opacity: .3; } }

.card-badges {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: 5px;
  background: rgba(0, 0, 0, .35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, .92);
  white-space: nowrap;
}
.badge.featured {
  color: #fff;
}
.badge.featured::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: #FB7185;
}
.badge.priority {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 11px;
}

/* Card body — title + description */
.card-body { margin-top: auto; }
.domain-name {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.02em;
  line-height: 1.1;
  text-shadow: 0 2px 12px rgba(0, 0, 0, .35);
  word-break: break-all;
}
.domain-desc {
  margin-top: 6px;
  font-size: 14px;
  color: rgba(255, 255, 255, .88);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-shadow: 0 1px 6px rgba(0,0,0,.3);
}

/* Card footer — host + latency + go */
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, .14);
}
.card-author {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 12px;
  color: rgba(255, 255, 255, .85);
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-author .author-icon {
  width: 16px; height: 16px; border-radius: 4px;
  background: rgba(255,255,255,.18);
  display: grid; place-items: center;
  flex: none;
}
.card-author .author-icon svg {
  width: 10px; height: 10px; color: rgba(255,255,255,.85);
}
.card-author-text {
  overflow: hidden;
  text-overflow: ellipsis;
}

.latency {
  display: inline-flex; align-items: baseline; gap: 4px;
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  color: #fff;
  flex: none;
}
.latency .num {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.latency .unit {
  font-size: 11px;
  color: rgba(255,255,255,.7);
  font-weight: 500;
}

.go-btn {
  display: inline-flex; align-items: center; gap: 4px;
  height: 30px;
  padding: 0 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .95);
  color: #111;
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: .02em;
  transition: transform .15s ease, background .15s ease;
  flex: none;
}
.go-btn:hover { background: #fff; transform: translateX(2px); }
.go-btn svg { width: 12px; height: 12px; }

/* ============================================
   Footer
   ============================================ */
.site-footer {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 20px;
  color: var(--text-3);
  font-size: 13px;
}
.footer-brand {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  color: var(--text-2);
}
.footer-nav {
  display: flex;
  gap: 18px;
}
.footer-nav a {
  color: var(--text-3);
  transition: color .15s;
}
.footer-nav a:hover { color: var(--text); }

/* ============================================
   Floating Support Ball
   ============================================ */
.support-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 0 18px 0 14px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .01em;
  box-shadow:
    0 14px 32px -10px rgba(255, 210, 30, .5),
    0 0 0 6px rgba(255, 210, 30, .12);
  transition: transform .15s ease, box-shadow .15s ease;
}
.support-fab:hover {
  transform: translateY(-2px);
  box-shadow:
    0 18px 40px -10px rgba(255, 210, 30, .6),
    0 0 0 8px rgba(255, 210, 30, .15);
}
.support-fab svg { width: 20px; height: 20px; }

/* ============================================
   Loading Overlay
   ============================================ */
.loading-overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 9999;
  display: grid;
  place-items: center;
  transition: opacity .35s ease;
}
.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.loader-mark {
  width: 52px; height: 52px;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid; place-items: center;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 800;
  font-size: 18px;
  animation: mark-pulse 1.4s ease-in-out infinite;
}
@keyframes mark-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 210, 30, .5); }
  50%      { transform: scale(1.06); box-shadow: 0 0 0 18px rgba(255, 210, 30, 0); }
}
.loading-text {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--text-3);
  letter-spacing: .14em;
  text-transform: uppercase;
}
.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ============================================
   Notifications (preserved from original)
   ============================================ */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--surface-hi);
  border: 1px solid var(--border-hi);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text);
  font-size: 13.5px;
  z-index: 10000;
  box-shadow: var(--shadow-lg);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 900px) {
  .domains-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
}

/* Mobile: one column */
@media (max-width: 640px) {
  .container { padding: 16px 14px 140px; }
  .top-nav { padding-top: 4px; padding-bottom: 16px; }
  .brand-logo { height: 34px; }
  .nav-stats {
    height: 34px;
    padding: 0 12px;
    gap: 10px;
    font-size: 12px;
  }
  .nav-stat-label { display: none; }
  .nav-stat-value { font-size: 12.5px; }
  .nav-stat-sep { height: 14px; }

  .hero-section {
    border-radius: 14px;
    margin-bottom: 20px;
  }

  .section-header { margin-bottom: 12px; }
  .section-title { font-size: 16px; }
  .refresh-btn {
    height: 34px; padding: 0 12px; font-size: 12.5px;
  }
  .refresh-btn span { display: none; }
  .refresh-btn {
    width: 34px; padding: 0; justify-content: center;
  }

  .domains-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .domain-card { min-height: 180px; padding: 18px; border-radius: 16px; }
  .domain-name { font-size: 20px; }
  .domain-desc { font-size: 13.5px; }

  .footer-content { justify-content: center; text-align: center; }

  .support-fab {
    right: 14px; bottom: 14px;
    height: 46px; width: 46px;
    padding: 0;
    justify-content: center;
  }
  .support-fab .fab-label { display: none; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
