:root {
  --night: #0b1723;
  --night-2: #0e1e2c;
  --panel: #142c3f;
  --panel-2: #0f2233;
  --emerald: #12463c;
  --gold: #c9a227;
  --gold-bright: #e6c85a;
  --teal: #2aa198;
  --ivory: #f1ecdf;
  --muted: #93a6b3;
  --danger: #d17264;
  --border: rgba(241, 236, 223, 0.08);
  --radius: 16px;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--night);
  color: var(--ivory);
  font-family: 'Tajawal', sans-serif;
  line-height: 1.7;
  background-image:
    radial-gradient(circle at 15% 0%, rgba(42, 161, 152, 0.08), transparent 40%),
    radial-gradient(circle at 85% 10%, rgba(201, 162, 39, 0.07), transparent 45%);
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; }
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
}

a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 3px; border-radius: 4px; }

h1, h2, h3 {
  font-family: 'Amiri', serif;
  margin: 0 0 0.4em;
  font-weight: 700;
}

code {
  font-family: 'IBM Plex Mono', monospace;
  background: rgba(255, 255, 255, 0.08);
  padding: 0.1em 0.5em;
  border-radius: 6px;
  font-size: 0.9em;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(11, 23, 35, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar__inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand__mark { color: var(--gold); display: inline-flex; }
.brand__name { font-family: 'Amiri', serif; font-size: 1.35rem; font-weight: 700; color: var(--ivory); }
.nav { display: flex; gap: 28px; font-weight: 500; }
.nav a { color: var(--muted); transition: color 0.2s; padding: 6px 0; border-bottom: 2px solid transparent; }
.nav a:hover, .nav a.is-active { color: var(--gold-bright); border-color: var(--gold); }

/* ---------- Nav toggle (hamburger) — يظهر فقط على الجوال ---------- */
.nav-toggle {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  cursor: pointer;
}
.nav-toggle__bar {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--ivory);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  padding: 76px 0 0;
  text-align: center;
  background: linear-gradient(180deg, var(--night-2), var(--night) 70%);
}
.hero__star {
  position: absolute;
  top: -60px;
  left: 50%;
  width: 640px;
  height: 640px;
  transform: translateX(-50%);
  color: var(--gold);
  opacity: 0.08;
  animation: spin 90s linear infinite;
}
@keyframes spin { to { transform: translateX(-50%) rotate(360deg); } }
.hero__inner { position: relative; z-index: 2; }
.eyebrow {
  text-transform: none;
  color: var(--teal);
  letter-spacing: 0.03em;
  font-weight: 700;
  margin-bottom: 6px;
}
.hero h1 {
  font-size: clamp(2.4rem, 6vw, 4rem);
  color: var(--gold-bright);
  text-shadow: 0 2px 30px rgba(201, 162, 39, 0.25);
}
.hero__tagline { color: var(--muted); font-size: 1.15rem; margin-bottom: 34px; }

.search {
  display: flex;
  max-width: 560px;
  margin: 0 auto 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px;
  box-shadow: var(--shadow);
}
.search input {
  flex: 1;
  background: none;
  border: none;
  color: var(--ivory);
  padding: 12px 18px;
  font-family: inherit;
  font-size: 1rem;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: none; }
.search button {
  background: var(--gold);
  color: var(--night);
  border: none;
  border-radius: 999px;
  padding: 12px 26px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
}
.search button:hover { background: var(--gold-bright); }

.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 820px;
  margin: 0 auto 44px;
}
.chip {
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
  transition: all 0.2s;
}
.chip:hover { border-color: var(--teal); color: var(--ivory); }
.chip.is-active { background: var(--teal); border-color: var(--teal); color: var(--night); font-weight: 700; }

.hero__stats {
  display: flex;
  justify-content: center;
  gap: 56px;
  padding-bottom: 40px;
  position: relative;
  z-index: 2;
}
.hero__stats div { display: flex; flex-direction: column; }
.hero__stats strong { font-family: 'IBM Plex Mono', monospace; font-size: 1.6rem; color: var(--gold-bright); }
.hero__stats span { color: var(--muted); font-size: 0.85rem; }

.hero__skyline { display: block; width: 100%; height: 60px; position: relative; z-index: 1; }

/* ---------- Main / Cards ---------- */
.main { padding: 48px 0 80px; }
.section-title { font-size: 1.5rem; margin-bottom: 20px; color: var(--ivory); }
.section-title:not(:first-child) { margin-top: 48px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}
.grid--featured { margin-bottom: 8px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: rgba(201, 162, 39, 0.35); }
.card--featured { border-inline-start: 3px solid var(--gold); background: linear-gradient(160deg, var(--panel), var(--emerald)); }
.card__link { display: block; padding: 20px; }
.card__top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.card__icon { width: 52px; height: 52px; border-radius: 14px; object-fit: cover; flex-shrink: 0; }
.card__icon--fallback { background: var(--panel-2); padding: 12px; color: var(--gold); }
.card__title h3 { font-size: 1.05rem; margin: 0; }
.card__category { font-size: 0.78rem; color: var(--teal); }
.card__desc {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0 0 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card__stats { display: flex; gap: 16px; font-size: 0.85rem; color: var(--ivory); font-family: 'IBM Plex Mono', monospace; }

.badge-gold {
  background: var(--gold);
  color: var(--night);
  font-family: 'Tajawal', sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  vertical-align: middle;
}

.empty { color: var(--muted); text-align: center; padding: 40px 0; }

/* ---------- Page hero (top/other pages) ---------- */
.page-hero { padding: 56px 0 24px; text-align: center; }
.page-hero h1 { color: var(--gold-bright); font-size: 2.4rem; }

/* ---------- Leaderboard ---------- */
.leaderboard { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.leaderboard__row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 18px;
}
.leaderboard__row.is-top { border-color: rgba(201, 162, 39, 0.4); }
.leaderboard__rank { width: 36px; text-align: center; font-family: 'IBM Plex Mono', monospace; font-weight: 700; color: var(--gold-bright); }
.leaderboard__icon { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; }
.leaderboard__icon--fallback { background: var(--panel-2); padding: 8px; color: var(--gold); }
.leaderboard__name { flex: 1; font-weight: 700; }
.leaderboard__category { color: var(--teal); font-size: 0.85rem; }
.leaderboard__bumps { font-family: 'IBM Plex Mono', monospace; color: var(--muted); font-size: 0.85rem; }

/* ---------- Profile page ---------- */
.profile { max-width: 760px; }
.profile__card { background: var(--panel); border: 1px solid var(--border); border-radius: 20px; padding: 32px; }
.profile__top { display: flex; align-items: center; gap: 18px; margin-bottom: 18px; }
.profile__icon { width: 80px; height: 80px; border-radius: 20px; object-fit: cover; }
.profile__icon--fallback { background: var(--panel-2); padding: 18px; color: var(--gold); }
.profile__desc { color: var(--ivory); opacity: 0.9; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.tag { background: rgba(42, 161, 152, 0.15); color: var(--teal); padding: 4px 12px; border-radius: 999px; font-size: 0.82rem; }
.profile__stats { display: flex; gap: 40px; margin: 24px 0; padding: 18px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.profile__stats div { display: flex; flex-direction: column; }
.profile__stats strong { font-family: 'IBM Plex Mono', monospace; font-size: 1.3rem; color: var(--gold-bright); }
.profile__stats span { color: var(--muted); font-size: 0.82rem; }
.join-btn {
  display: inline-block;
  background: var(--gold);
  color: var(--night);
  font-weight: 700;
  padding: 12px 28px;
  border-radius: 999px;
  transition: background 0.2s, transform 0.2s;
}
.join-btn:hover { background: var(--gold-bright); transform: translateY(-2px); }

/* ---------- 404 ---------- */
.not-found { text-align: center; padding: 80px 0; }
.not-found h1 { font-size: 4rem; color: var(--gold-bright); }

/* ---------- Add-server / footer ---------- */
.add-server { background: var(--panel-2); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 56px 0; }
.add-server__inner { display: flex; align-items: center; gap: 40px; }
.add-server__star { width: 90px; height: 90px; color: var(--gold); opacity: 0.5; flex-shrink: 0; }
.add-server h2 { color: var(--ivory); }
.add-server__steps { color: var(--muted); padding-inline-start: 20px; }
.add-server__steps li { margin-bottom: 4px; }
.add-server__steps code { color: var(--gold-bright); }

.footer { padding: 28px 0 40px; text-align: center; color: var(--muted); font-size: 0.85rem; }
.footer__muted { opacity: 0.7; margin-top: 4px; }

/* ---------- Language switcher ---------- */
.lang-switch { display: flex; align-items: center; }
.lang-switch__select {
  background: var(--panel);
  color: var(--ivory);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.lang-switch__select:hover { border-color: var(--teal); }
.lang-switch__select:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 2px; }

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: 32px;
}
.pagination__btn {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 20px;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--ivory);
  transition: border-color 0.2s, color 0.2s;
}
.pagination__btn:not(.is-disabled):hover { border-color: var(--gold); color: var(--gold-bright); }
.pagination__btn.is-disabled { color: var(--muted); opacity: 0.5; cursor: default; }
.pagination__info { color: var(--muted); font-size: 0.85rem; font-family: 'IBM Plex Mono', monospace; }

@media (max-width: 720px) {
  .nav-toggle { display: flex; }
  .nav {
    position: absolute;
    inset-inline: 0;
    top: 68px;
    z-index: 39;
    flex-direction: column;
    gap: 0;
    background: rgba(11, 23, 35, 0.98);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: 4px 24px 16px;
    display: none;
  }
  .nav.is-open { display: flex; }
  .nav a { padding: 12px 0; border-bottom: 1px solid var(--border); }
  .nav a:last-child { border-bottom: none; }
  .add-server__inner { flex-direction: column; text-align: center; }
  .hero__stats { gap: 28px; }
}
