/* ============================================================
   AI Tools Navigator — Minimal B&W Style
   ============================================================ */

/* ---------- Variables ---------- */
:root {
  --bg-base:      #f4f4f2;   /* warm off-white, never pure #fff */
  --bg-card:      #ffffff;
  --bg-hover:    #efefef;
  --bg-dark:     #1c1c1e;   /* deep charcoal, not pure black */
  --text-1:      #141416;   /* near-black */
  --text-2:      #636366;   /* mid gray */
  --text-3:      #aeaeb2;   /* light gray */
  --border:      #d1d1d6;
  --border-soft: #e8e8ea;
  --line:        #c7c7cc;
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.06);
  --shadow-md:   0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg:   0 12px 32px rgba(0,0,0,0.10);
  --radius:      10px;
  --radius-sm:   6px;
  --radius-lg:   16px;
  --ease:        cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --font:        -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', sans-serif;
}

/* Dark mode — refined charcoal, not harsh black */
[data-theme="dark"] {
  --bg-base:      #111113;
  --bg-card:      #1c1c1e;
  --bg-hover:     #262628;
  --bg-dark:      #0a0a0c;
  --text-1:      #f2f2f7;
  --text-2:      #8e8e93;
  --text-3:      #48484a;
  --border:      #38383a;
  --border-soft: #2c2c2e;
  --line:        #434345;
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.35);
  --shadow-md:   0 4px 12px rgba(0,0,0,0.45);
  --shadow-lg:   0 12px 32px rgba(0,0,0,0.55);
}

/* ---------- Reset ---------- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-1);
  line-height: 1.6;
  min-height: 100vh;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }

/* Subtle grain overlay for texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
  opacity: 0.6;
}

/* ---------- Navbar ---------- */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 58px;
  background: rgba(244,244,242,0.82);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid var(--border-soft);
  z-index: 100;
  transition: background 0.3s var(--ease), border-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
[data-theme="dark"] .navbar {
  background: rgba(17,17,19,0.85);
}

.navbar.scrolled {
  box-shadow: var(--shadow-sm);
  border-bottom-color: var(--border);
}

.nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 28px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-1);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.025em;
  flex-shrink: 0;
}

.logo-mark {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--text-1);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
}
.logo-mark svg { display: block; }

.logo-text { color: var(--text-1); }

.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Search */
.search-global {
  position: relative;
  width: 240px;
}

.search-global svg {
  position: absolute;
  left: 11px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
  width: 14px; height: 14px;
  transition: color 0.2s;
}

.search-global input {
  width: 100%;
  padding: 9px 40px 9px 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-1);
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.search-global input::placeholder { color: var(--text-3); }

.search-global input:focus {
  border-color: var(--text-2);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(99,102,102,0.08);
}

.search-global input:focus ~ svg,
.search-global svg:has(+ input:focus) { color: var(--text-2); }

.search-global kbd {
  position: absolute;
  right: 9px; top: 50%;
  transform: translateY(-50%);
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  font-size: 10px;
  color: var(--text-3);
  font-family: inherit;
  pointer-events: none;
}

/* Nav buttons */
.icon-btn {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s var(--ease);
}
.icon-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border);
  color: var(--text-1);
}
.icon-btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.theme-btn .sun { display: none; }
.theme-btn .moon { display: block; }
[data-theme="dark"] .theme-btn .sun { display: block; }
[data-theme="dark"] .theme-btn .moon { display: none; }

.sidebar-toggle { display: none; }

/* ---------- Layout ---------- */
.layout {
  display: flex;
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  position: sticky;
  top: 58px;
  height: calc(100vh - 58px);
  overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 0; }

.sidebar-inner {
  padding: 20px 12px 40px;
}

.sidebar-top {
  padding: 0 6px;
  margin-bottom: 12px;
}

.sidebar-total {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.sidebar-divider {
  height: 1px;
  background: var(--border-soft);
  margin: 8px 6px 10px;
}

.sidebar-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-cat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: transparent;
  color: var(--text-2);
  border: none;
  width: 100%;
  text-align: left;
  font-size: 13px;
  font-weight: 450;
  font-family: inherit;
  transition: all 0.12s var(--ease);
}

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

.sidebar-cat.active {
  background: var(--text-1);
  color: var(--bg-base);
  font-weight: 500;
}
[data-theme="dark"] .sidebar-cat.active {
  background: var(--text-1);
  color: var(--bg-dark);
}

.sidebar-cat-icon {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.7;
}
.sidebar-cat.active .sidebar-cat-icon { opacity: 1; }

.sidebar-cat-label { flex: 1; }

.sidebar-cat-count {
  font-size: 11px;
  color: var(--text-3);
  background: var(--bg-hover);
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 22px;
  text-align: center;
  transition: all 0.12s;
}
.sidebar-cat.active .sidebar-cat-count {
  background: rgba(255,255,255,0.15);
  color: inherit;
}
[data-theme="dark"] .sidebar-cat.active .sidebar-cat-count {
  background: rgba(0,0,0,0.25);
}

/* ---------- Main Content ---------- */
.main-content {
  flex: 1;
  min-width: 0;
}

/* ---------- Hero ---------- */
.hero {
  padding: 100px 40px 48px;
  position: relative;
}

.hero-inner {
  max-width: 580px;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 20px;
}

.hero-eyebrow .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-3);
}

.hero-title {
  font-size: 48px;
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.08;
  color: var(--text-1);
  margin-bottom: 16px;
}

.hero-title em {
  font-style: italic;
  font-weight: 300;
  color: var(--text-2);
}

.hero-desc {
  font-size: 16px;
  color: var(--text-2);
  line-height: 1.65;
  max-width: 440px;
}

/* ---------- Tools Section ---------- */
.tools-section {
  padding: 0 40px 80px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.result-count {
  font-size: 13px;
  color: var(--text-3);
}
.result-count strong {
  color: var(--text-2);
  font-weight: 500;
}

.sort-options {
  display: flex;
  gap: 2px;
  background: var(--bg-hover);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
}

.sort-btn {
  padding: 6px 14px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.12s var(--ease);
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 5px;
}

.sort-btn:hover { color: var(--text-1); }

.sort-btn.active {
  background: var(--bg-card);
  color: var(--text-1);
  box-shadow: var(--shadow-sm);
}

/* ---------- Tools Grid ---------- */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

/* ---------- Tool Card ---------- */
.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px 20px;
  transition: all 0.18s var(--ease);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: cardIn 0.4s var(--ease) both;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.tool-card:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* left color accent bar */
.tool-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--line);
  transition: background 0.2s;
}
.tool-card:hover::before { background: var(--text-2); }

.tool-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.tool-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg-hover);
  border: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  transition: all 0.15s;
}
.tool-card:hover .tool-icon {
  background: var(--bg-base);
}

.tool-meta { flex: 1; min-width: 0; }

.tool-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: -0.015em;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tool-desc {
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.55;
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tool-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--border-soft);
  margin-top: auto;
}

.tool-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tool-tag {
  font-size: 10.5px;
  color: var(--text-3);
  background: var(--bg-hover);
  border: 1px solid var(--border-soft);
  padding: 2px 7px;
  border-radius: 4px;
  transition: all 0.12s;
}
.tool-card:hover .tool-tag {
  border-color: var(--border);
}

.tool-badges {
  display: flex;
  gap: 4px;
  align-items: center;
}

.badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-new {
  background: var(--text-1);
  color: var(--bg-base);
}
[data-theme="dark"] .badge-new {
  background: var(--text-1);
  color: var(--bg-dark);
}

.badge-hot {
  background: var(--bg-hover);
  color: var(--text-2);
  border: 1px solid var(--border);
}

.badge-cn {
  background: var(--bg-hover);
  color: var(--text-2);
  border: 1px solid var(--border);
}

.badge-free {
  background: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #c8e6c9;
}
[data-theme="dark"] .badge-free {
  background: rgba(46,125,50,0.15);
  color: #81c784;
  border-color: rgba(46,125,50,0.3);
}

.badge-paid {
  background: var(--bg-hover);
  color: var(--text-2);
  border: 1px solid var(--border);
}

.tool-link {
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-3);
}
.empty-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.5; }
.empty-state p { font-size: 14px; }

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--border-soft);
  padding: 40px;
  margin-top: 20px;
  position: relative;
  z-index: 1;
}

.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-3);
}

.footer-brand .logo-mark {
  width: 24px; height: 24px;
  border-radius: 5px;
}

.footer-text { font-size: 12px; color: var(--text-3); }

/* ---------- Mobile Overlay ---------- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 90;
  opacity: 0;
  transition: opacity 0.25s;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar-toggle { display: flex; }
  .sidebar {
    position: fixed;
    top: 58px; left: 0;
    height: calc(100vh - 58px);
    z-index: 95;
    background: var(--bg-base);
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform 0.25s var(--ease);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay { display: block; }
  .sidebar-overlay.visible { opacity: 1; pointer-events: auto; }

  .hero { padding: 80px 24px 40px; }
  .hero-title { font-size: 36px; }
  .tools-section { padding: 0 24px 60px; }
  .search-global { width: 200px; }
}

@media (max-width: 600px) {
  .hero { padding: 72px 16px 32px; }
  .hero-title { font-size: 30px; }
  .hero-desc { font-size: 14px; }
  .tools-section { padding: 0 16px 48px; }
  .tools-grid { grid-template-columns: 1fr; }
  .nav-inner { padding: 0 16px; }
  .search-global { display: none; }
  .footer { padding: 32px 20px; }
  .footer-inner { flex-direction: column; align-items: flex-start; }
}
