/* alfarsi.org — shared design system for the landing page and the app pages.
   Warm paper background, deep ink text, one accent, per-app tint on the cards.
   Logical properties everywhere so the same layout works in RTL and LTR. */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&display=swap');

:root {
  --bg: #F6F4EF;
  --bg-2: #EDEAE2;
  --surface: #FFFFFF;
  --ink: #15171C;
  --ink-2: #4E5460;
  --line: rgba(21, 23, 28, 0.10);
  --accent: #0B7A63;
  --accent-ink: #FFFFFF;
  --accent-soft: rgba(11, 122, 99, 0.10);
  --shadow: 0 1px 2px rgba(21, 23, 28, 0.04), 0 12px 32px rgba(21, 23, 28, 0.08);
  --radius: 22px;
  --ok: #1F8A4C;
  --bad: #C43D3D;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1014;
    --bg-2: #14171D;
    --surface: #181C23;
    --ink: #EEF0F4;
    --ink-2: #A3AAB8;
    --line: rgba(255, 255, 255, 0.09);
    --accent: #3BC9A3;
    --accent-ink: #0B1B17;
    --accent-soft: rgba(59, 201, 163, 0.14);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 16px 40px rgba(0, 0, 0, 0.45);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans Arabic", -apple-system, BlinkMacSystemFont, "SF Arabic", "Segoe UI", Tahoma, sans-serif;
  font-size: 17px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-align: start;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
img { display: block; }

/* Language switch: site.js sets data-lang on <html>. Only that language's elements show.
   Without JavaScript both languages remain visible. */
html[data-lang="ar"] [data-lang="en"],
html[data-lang="en"] [data-lang="ar"] { display: none !important; }

/* ---------- Top bar ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px clamp(16px, 4vw, 40px);
  background: var(--bg);                                   /* fallback (Safari < 16.2) */
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
  /* The switch sits on the LEFT in both directions, as requested. */
  flex-direction: row-reverse;
}
html[dir="ltr"] .top { flex-direction: row; }
.brand { font-weight: 700; text-decoration: none; color: var(--ink); font-size: 17px; }
.brand span { color: var(--ink-2); font-weight: 500; }

.lang-switch {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px;
  direction: ltr;
}
.lang-switch button {
  font: inherit; font-size: 13px; font-weight: 600; line-height: 1;
  padding: 7px 12px; border: 0; border-radius: 999px; cursor: pointer;
  background: transparent; color: var(--ink-2);
  transition: background .2s, color .2s;
}
.lang-switch button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden;
  padding: clamp(56px, 10vw, 112px) clamp(16px, 4vw, 40px) clamp(40px, 6vw, 72px);
  text-align: center;
}
.hero::before, .hero::after {
  content: ""; position: absolute; inset: auto; pointer-events: none; z-index: 0;
  border-radius: 50%; filter: blur(60px); opacity: .55;
}
.hero::before { width: 520px; height: 520px; top: -260px; inset-inline-start: -160px; background: var(--accent-soft); }
.hero::after  { width: 420px; height: 420px; top: -120px; inset-inline-end: -140px; background: rgba(201, 151, 43, 0.14); }
.hero > * { position: relative; z-index: 1; }
.hero h1 { font-size: clamp(40px, 8vw, 72px); font-weight: 700; }
.hero .lead { margin-top: 14px; font-size: clamp(17px, 2.2vw, 20px); color: var(--ink-2); max-width: 34em; margin-inline: auto; }
.eyebrow {
  display: inline-block; margin-bottom: 18px;
  font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft); padding: 6px 12px; border-radius: 999px;
}

/* ---------- Layout ---------- */
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px); }
.section { padding: clamp(28px, 5vw, 56px) 0; }
.section-head { margin-bottom: 22px; }
.section-head h2 { font-size: clamp(26px, 4vw, 34px); }
.section-head p { color: var(--ink-2); margin-top: 6px; }

/* ---------- App cards ---------- */
.apps { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.app {
  --tint: var(--accent);
  position: relative; overflow: hidden;
  display: grid; gap: 18px;
  padding: 26px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform .25s ease, box-shadow .25s ease;
}
.app:hover { transform: translateY(-3px); }
.app::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 6px;
  background: linear-gradient(90deg, var(--tint), transparent 80%);
}
html[dir="rtl"] .app::before { background: linear-gradient(270deg, var(--tint), transparent 80%); }
.app-head { display: flex; align-items: center; gap: 16px; }
.app-head img {
  width: 76px; height: 76px; border-radius: 18px; flex: none;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--tint) 35%, transparent);
}
.app-head h3 { font-size: 26px; }
.app-head h3 small { display: block; font-size: 15px; font-weight: 500; color: var(--ink-2); margin-top: 2px; }
.app p.desc { color: var(--ink-2); }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  font-size: 13px; font-weight: 600; color: var(--ink-2);
  padding: 5px 11px; border-radius: 999px; background: var(--bg-2); border: 1px solid var(--line);
}
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-size: 15px; font-weight: 600; line-height: 1;
  padding: 12px 18px; border-radius: 999px; text-decoration: none; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  transition: transform .15s ease, background .2s, box-shadow .2s;
}
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn svg { width: 16px; height: 16px; flex: none; }

/* ---------- Contact ---------- */
.contact {
  display: grid; gap: 28px; grid-template-columns: 1fr;
  padding: clamp(22px, 4vw, 36px);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
@media (min-width: 820px) { .contact { grid-template-columns: 1fr 1.4fr; } }
.contact aside h2 { font-size: 28px; }
.contact aside p { color: var(--ink-2); margin-top: 10px; }
.contact aside ul { color: var(--ink-2); padding-inline-start: 18px; margin: 12px 0 0; }
form { display: grid; gap: 14px; }
.row { display: grid; gap: 14px; }
@media (min-width: 560px) { .row { grid-template-columns: 1fr 1fr; } }
label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; }
label small { font-weight: 400; color: var(--ink-2); }
input, select, textarea {
  width: 100%; font: inherit; font-weight: 400; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; transition: border-color .2s, box-shadow .2s;
}
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
input[type="email"] { direction: ltr; text-align: start; }
select { appearance: none; -webkit-appearance: none; padding-inline-end: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 14px center; background-size: 16px; }
html[dir="ltr"] select { background-position: right 14px center; }
textarea { min-height: 150px; resize: vertical; }
.trap { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.status { display: none; padding: 12px 14px; border-radius: 14px; font-weight: 600; }
.status.show { display: block; }
.status.ok { background: rgba(31, 138, 76, .12); color: var(--ok); }
.status.bad { background: rgba(196, 61, 61, .12); color: var(--bad); }
form .btn { justify-self: start; }

/* ---------- App page ---------- */
.app-hero { text-align: center; padding-top: clamp(40px, 7vw, 72px); }
.app-hero img { width: 128px; height: 128px; border-radius: 30px; margin: 0 auto 22px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.25);
  box-shadow: 0 18px 40px color-mix(in srgb, var(--tint) 40%, transparent); }
.app-hero h1 { font-size: clamp(36px, 7vw, 60px); }
.app-hero h1 small { display: block; font-size: 22px; font-weight: 500; color: var(--ink-2); margin-top: 4px; }
.app-hero .actions { justify-content: center; margin-top: 24px; }
.page { display: grid; gap: 32px; padding-bottom: 56px; }
@media (min-width: 900px) { .page { grid-template-columns: 230px 1fr; gap: 48px; } }
.toc { position: sticky; top: 84px; align-self: start; display: none; }
@media (min-width: 900px) { .toc { display: block; } }
.toc a { display: block; padding: 8px 12px; border-radius: 10px; color: var(--ink-2); text-decoration: none; font-weight: 500; }
.toc a:hover { background: var(--bg-2); color: var(--ink); }
.content { display: grid; gap: 20px; }
.card {
  padding: clamp(22px, 3.5vw, 32px);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  scroll-margin-top: 90px;
}
.card h2 { font-size: 24px; margin-bottom: 10px; }
.card h3 { font-size: 17px; margin: 18px 0 4px; }
.card p, .card li { color: var(--ink-2); }
.card ul { padding-inline-start: 20px; margin: 6px 0; }
.card strong { color: var(--ink); }
.games { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-top: 10px; }
.game { padding: 14px 16px; border-radius: 16px; background: var(--bg); border: 1px solid var(--line); }
.game b { display: block; color: var(--ink); margin-bottom: 2px; }
.game span { font-size: 15px; color: var(--ink-2); }
.faq details { border-top: 1px solid var(--line); padding: 12px 0; }
.faq details:last-child { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; font-weight: 600; color: var(--ink); list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--ink-2); font-weight: 400; }
.faq details[open] summary::after { content: "–"; }
.faq details p { margin-top: 8px; }
.note { font-size: 14px; color: var(--ink-2); }

footer { padding: 28px clamp(16px, 4vw, 40px) 44px; text-align: center; color: var(--ink-2); font-size: 14px; }
footer a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); }
footer a:hover { border-color: var(--accent); }
