:root {
  --bg: #0b0f1a;
  --bg-soft: #131a2b;
  --card: #161e33;
  --line: #243049;
  --text: #e8edf7;
  --muted: #9aa7c2;
  --brand: #6d8bff;
  --brand-2: #b06dff;
  --accent: #ffb43d;
  --ok: #41d18b;
  --danger: #ff6b6b;
  --radius: 16px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 600px at 70% -10%, #1b2440 0%, var(--bg) 55%);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px clamp(16px, 5vw, 48px);
  position: sticky;
  top: 0;
  backdrop-filter: blur(8px);
  background: rgba(11, 15, 26, 0.7);
  border-bottom: 1px solid var(--line);
  z-index: 10;
}
.brand { font-weight: 800; font-size: 1.25rem; letter-spacing: -0.02em; }
.brand-mark {
  color: var(--brand);
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.topnav { display: flex; align-items: center; gap: 20px; }
.topnav a { color: var(--muted); font-weight: 500; }
.topnav a:hover { color: var(--text); }
.btn-beer {
  background: linear-gradient(135deg, var(--accent), #ff7a3d);
  color: #1a1205 !important;
  padding: 9px 16px;
  border-radius: 999px;
  font-weight: 700;
}
.lang-toggle {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.lang-toggle:hover { border-color: var(--brand); color: var(--brand); }

/* ---------- Hero ---------- */
main { max-width: 920px; margin: 0 auto; padding: 0 clamp(16px, 5vw, 32px); }
.hero { text-align: center; padding: clamp(48px, 9vw, 96px) 0 32px; }
.hero h1 {
  font-size: clamp(2rem, 5.5vw, 3.4rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin: 0 0 16px;
}
.grad {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.sub { color: var(--muted); font-size: clamp(1rem, 2.2vw, 1.15rem); margin: 0 auto 28px; max-width: 560px; }

.grab {
  display: flex;
  gap: 10px;
  max-width: 640px;
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--line);
  padding: 8px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.grab input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text);
  font-size: 1rem;
  padding: 12px 14px;
}
.grab input::placeholder { color: #6b779a; }
.grab button {
  border: 0;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.98rem;
  padding: 0 22px;
  border-radius: 11px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  transition: transform 0.08s ease, filter 0.15s ease;
}
.grab button:hover { filter: brightness(1.08); }
.grab button:active { transform: scale(0.98); }
.grab button:disabled { opacity: 0.6; cursor: progress; }

.platforms { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.chip {
  font-size: 0.8rem;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--bg-soft);
}

.status { min-height: 22px; margin-top: 18px; font-size: 0.95rem; color: var(--muted); }
.status.error { color: var(--danger); }
.status.loading::after { content: ''; animation: dots 1.2s steps(4, end) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* ---------- Result card ---------- */
.result { margin: 12px auto 40px; }
.hidden { display: none !important; }
.media-card {
  display: flex;
  gap: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.media-card .thumb {
  width: 220px;
  min-width: 220px;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  object-fit: cover;
  background: #0a0e18;
}
.media-meta { flex: 1; min-width: 0; }
.media-meta h3 { margin: 2px 0 6px; font-size: 1.1rem; line-height: 1.3; }
.media-meta .by { color: var(--muted); font-size: 0.88rem; margin-bottom: 14px; }
.fmt-list { display: flex; flex-wrap: wrap; gap: 10px; }
.fmt {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 11px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.08s;
}
.fmt:hover { border-color: var(--brand); }
.fmt:active { transform: scale(0.98); }
.fmt .sz { color: var(--muted); font-weight: 500; font-size: 0.8rem; }
.fmt-group-label { width: 100%; color: var(--muted); font-size: 0.8rem; margin: 8px 0 2px; }

@media (max-width: 620px) {
  .media-card { flex-direction: column; }
  .media-card .thumb { width: 100%; min-width: 0; }
}

/* ---------- How it works ---------- */
.how { padding: 24px 0 8px; }
.how h2, .donate h2 { font-size: 1.5rem; letter-spacing: -0.02em; }
.steps { list-style: none; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.steps li {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  color: var(--muted);
}
.steps li .step-num {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  font-weight: 700;
  margin-inline-end: 8px;
  vertical-align: middle;
}
.steps li b { color: var(--text); }

/* ---------- Donate ---------- */
.donate { padding: 40px 0 64px; }
.donate-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin-top: 18px; }
.coin {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  gap: 14px;
  align-items: center;
}
.coin canvas, .coin .qr-fallback {
  width: 96px;
  height: 96px;
  border-radius: 10px;
  background: #fff;
  padding: 6px;
  flex: 0 0 auto;
}
.coin .qr-fallback { display: grid; place-items: center; color: #333; font-size: 0.7rem; text-align: center; }
.coin-info { min-width: 0; flex: 1; }
.coin-info .name { font-weight: 700; }
.coin-info .name .sym { color: var(--muted); font-weight: 500; margin-inline-start: 6px; font-size: 0.85rem; }
.addr-row { display: flex; gap: 8px; margin-top: 10px; }
.addr {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.copy-btn {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 8px;
  padding: 0 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.82rem;
}
.copy-btn:hover { border-color: var(--brand); }
.copy-btn.copied { color: var(--ok); border-color: var(--ok); }
.donate-empty { color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: 12px; padding: 18px; }
.donate-link {
  display: inline-block;
  margin-top: 16px;
  color: var(--accent);
  font-weight: 600;
}

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--line); padding: 24px; text-align: center; color: #6b779a; font-size: 0.85rem; }

/* ---------- Responsive / mobile ---------- */
@media (max-width: 640px) {
  main { padding: 0 16px; }

  .topbar { padding: 12px 16px; }
  .topnav { gap: 10px; }
  .topnav a[href="#how"] { display: none; } /* keep the bar uncluttered; section still scrolls */
  .brand { font-size: 1.1rem; }
  .btn-beer { padding: 8px 13px; font-size: 0.85rem; }
  .lang-toggle { padding: 7px 11px; font-size: 0.8rem; }

  .hero { padding: 36px 0 20px; }
  .grab { gap: 8px; padding: 6px; }
  .grab input { padding: 12px; font-size: 16px; } /* 16px avoids iOS focus-zoom */
  .grab button { padding: 0 16px; }
  .platforms { margin-top: 14px; }

  .media-card { padding: 14px; gap: 14px; }
  .media-meta h3 { font-size: 1rem; }
  .fmt { padding: 11px 14px; }            /* comfortable tap targets */

  .how, .donate { padding-top: 28px; }
  .donate { padding-bottom: 48px; }
  .coin { padding: 14px; gap: 12px; }
  .coin canvas, .coin .qr-fallback { width: 84px; height: 84px; }
}

/* Very small phones: stack things that would otherwise feel cramped. */
@media (max-width: 380px) {
  /* Keep the top bar on one line without overflowing. */
  .topbar { padding: 11px 12px; }
  .brand { font-size: 1rem; }
  .topnav { gap: 8px; }
  .btn-beer { padding: 7px 11px; font-size: 0.8rem; }
  .lang-toggle { padding: 6px 9px; font-size: 0.75rem; }

  .grab { flex-direction: column; }
  .grab input { text-align: center; }
  .grab button { width: 100%; padding: 13px; }
  .coin { flex-direction: column; text-align: center; }
  .coin .addr-row { justify-content: center; }
  [dir="rtl"] .addr { text-align: center; }
}

/* ---------- Arabic / RTL ---------- */
html[lang="ar"] body {
  font-family: 'Cairo', 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
/* Keep the play glyph pointing the right way regardless of direction. */
[dir="rtl"] .brand-mark { display: inline-block; transform: scaleX(-1); }
/* Format buttons read left-to-right (qualities/extensions) even in RTL. */
[dir="rtl"] .fmt { direction: ltr; }
[dir="rtl"] .addr { direction: ltr; text-align: left; }
