/* ==========================================================================
   VARIABLES
   ========================================================================== */
:root {
  --bg:        #09090b;
  --surface:   #18181b;
  --surface-2: #27272a;
  --border:    #27272a;
  --border-h:  #3f3f46;
  --text:      #fafafa;
  --text-2:    #a1a1aa;
  --text-3:    #71717a;
  --accent:    #34d399;
  --accent-d:  rgba(52, 211, 153, 0.12);
  --accent-h:  rgba(52, 211, 153, 0.2);
  --danger:    #f87171;
  --radius:    12px;
  --radius-sm: 8px;
  --font:      'Geist', system-ui, -apple-system, sans-serif;
  --mono:      'Geist Mono', 'JetBrains Mono', ui-monospace, monospace;
}

/* ==========================================================================
   RESET
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
a:hover { color: #6ee7b7; }
button { cursor: pointer; border: none; background: none; font-family: inherit; color: inherit; }
img { display: block; max-width: 100%; }
::selection { background: var(--accent-h); color: var(--text); }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 99px; }

.hidden { display: none !important; }

/* ==========================================================================
   PAGE
   ========================================================================== */
.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

@media (min-width: 768px) {
  .page { padding: 3rem 2rem 5rem; }
}

/* ==========================================================================
   HEADER
   ========================================================================== */
.header {
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.header-content {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}

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

.avatar-link {
  display: block;
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--border);
  transition: border-color 0.3s;
}
.avatar-link:hover { border-color: var(--accent); }

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar-img.hidden { display: none; }

.avatar-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  color: var(--text-3);
}
.avatar-fallback svg { width: 24px; height: 24px; }

.header-text h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.header-bio {
  color: var(--text-3);
  font-size: 0.875rem;
  margin-top: 0.15rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-stats {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.4rem 0.85rem;
}

.stat-val {
  font-family: var(--mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.65rem;
  color: var(--text-3);
  white-space: nowrap;
}

.stat-divider {
  width: 1px;
  height: 100%;
  background: var(--border);
  align-self: stretch;
}

.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.6rem;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-3);
  border: 1px solid var(--border);
  background: var(--surface);
}

.sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2s ease-in-out infinite;
}

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

/* ==========================================================================
   METRICS
   ========================================================================== */
.metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 2rem;
}

@media (min-width: 640px) {
  .metrics { grid-template-columns: repeat(4, 1fr); }
}

.metric-card {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 1.25rem 1rem;
  background: var(--surface);
}

.metric-val {
  font-family: var(--mono);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

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

/* ==========================================================================
   CONTROLS
   ========================================================================== */
.controls {
  margin-bottom: 1.5rem;
}

.controls-top {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.search-wrap {
  flex: 1;
  min-width: 200px;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  width: 16px;
  height: 16px;
  color: var(--text-3);
  pointer-events: none;
}

#search {
  width: 100%;
  padding: 0.6rem 2.25rem 0.6rem 2.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s;
}
#search::placeholder { color: var(--text-3); }
#search:focus { border-color: var(--accent); }

.search-clear {
  position: absolute;
  right: 0.5rem;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--text-3);
  transition: color 0.2s, background 0.2s;
}
.search-clear:hover { color: var(--text); background: var(--surface-2); }
.search-clear svg { width: 14px; height: 14px; }

.controls-right {
  display: flex;
  gap: 0.5rem;
}

.controls-right select {
  padding: 0.6rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.8rem;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}
.controls-right select:focus { border-color: var(--accent); }
.controls-right select option { background: var(--surface); color: var(--text); }

.controls-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.category-tabs {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.cat-tab {
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-3);
  border: 1px solid transparent;
  transition: all 0.15s;
}
.cat-tab:hover { color: var(--text); background: var(--surface); }
.cat-tab.active {
  color: var(--accent);
  background: var(--accent-d);
  border-color: rgba(52, 211, 153, 0.15);
}

.result-count {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-3);
}

/* ==========================================================================
   SKELETON
   ========================================================================== */
.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.skeleton-card {
  padding: 1.25rem;
  background: var(--surface);
  min-height: 140px;
  position: relative;
  overflow: hidden;
}
.skeleton-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.03), transparent);
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ==========================================================================
   GRID
   ========================================================================== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* ==========================================================================
   CARD
   ========================================================================== */
.card {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1.25rem;
  background: var(--surface);
  transition: background 0.2s;
  cursor: pointer;
  animation: cardIn 0.35s ease both;
}
.card:hover { background: var(--surface-2); }
.card.hidden { display: none; }

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

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.card-name {
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  word-break: break-all;
  transition: color 0.2s;
  line-height: 1.3;
}
.card-name:hover { color: var(--accent); }

.card-stars {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: #fbbf24;
  white-space: nowrap;
  flex-shrink: 0;
}
.card-stars svg { width: 13px; height: 13px; fill: #fbbf24; stroke: #fbbf24; }

.card-desc {
  font-size: 0.82rem;
  color: var(--text-2);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: auto;
  flex-wrap: wrap;
}

.card-lang {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--text-3);
}

.lang-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.card-date {
  font-size: 0.72rem;
  color: var(--text-3);
}

.card-link {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  color: var(--text-3);
  text-decoration: none;
  transition: color 0.2s;
}
.card-link:hover { color: var(--accent); }
.card-link svg { width: 12px; height: 12px; }

/* Highlight */
mark {
  background: var(--accent-h);
  color: var(--accent);
  border-radius: 2px;
  padding: 0 1px;
}

/* ==========================================================================
   EMPTY STATE
   ========================================================================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 4rem 1rem;
  text-align: center;
}

.empty-icon {
  width: 40px;
  height: 40px;
  color: var(--text-3);
}

.empty-state p {
  color: var(--text-3);
  font-size: 0.9rem;
}

.empty-reset {
  padding: 0.4rem 1rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-d);
  border: 1px solid rgba(52, 211, 153, 0.15);
  transition: background 0.2s;
}
.empty-reset:hover { background: var(--accent-h); }

/* ==========================================================================
   FOOTER
   ========================================================================== */
.footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.footer-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

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

.visitor-counter {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-3);
  background: var(--surface);
  border: 1px solid var(--border);
}

.visitor-icon {
  width: 13px;
  height: 13px;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 640px) {
  .header-content { flex-direction: column; }
  .header-right { width: 100%; justify-content: space-between; }
  .controls-top { flex-direction: column; }
  .controls-right { width: 100%; }
  .controls-right select { flex: 1; }
  .grid { grid-template-columns: 1fr; }
  .skeleton-grid { grid-template-columns: 1fr; }
  .metric-val { font-size: 1.3rem; }
}
