/* ============================================================
   ALGOSTEP — Public site
   الهوية: أسود بنفسجي عميق + بنفسجي كهربائي + تدرّج نصّي
   ============================================================ */

:root {
  --ink:        #0A0611;
  --ink-2:      #100A1B;
  --ink-3:      #16102A;
  --surface:    rgba(255, 255, 255, .035);
  --surface-2:  rgba(255, 255, 255, .06);
  --line:       rgba(255, 255, 255, .09);
  --line-soft:  rgba(255, 255, 255, .05);

  --violet:      #7C4DFF;
  --violet-hi:   #A67BFF;
  --violet-deep: #4A1FB8;
  --violet-glow: rgba(124, 77, 255, .45);

  --text:  #EFEAF8;
  --muted: #A196B8;
  --dim:   #6F6488;

  --mint: #6EE7A8;
  --amber: #FFC46B;
  --rose: #FF7A93;

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-pill: 999px;

  --shell: 1240px;
  --nav-h: 76px;

  --font-ar: 'IBM Plex Sans Arabic', 'Tajawal', system-ui, sans-serif;
  --font-en: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;

  --ease: cubic-bezier(.22, .61, .36, 1);
}

/* ---------- Reset / app-like base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 20px);
  touch-action: pan-x pan-y;              /* يمنع pinch zoom */
}

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-ar);
  font-size: 16px;
  line-height: 1.75;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
html[dir="ltr"] body { font-family: var(--font-en); }

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
::selection { background: var(--violet); color: #fff; }

:focus-visible {
  outline: 2px solid var(--violet-hi);
  outline-offset: 3px;
  border-radius: 6px;
}

/* خلفية الصفحة: توهّج بنفسجي خفيف ثابت */
body::before {
  content: '';
  position: fixed; inset: 0;
  background:
    radial-gradient(900px 500px at 78% -8%, rgba(124, 77, 255, .18), transparent 60%),
    radial-gradient(700px 420px at 8% 12%, rgba(74, 31, 184, .14), transparent 62%);
  pointer-events: none; z-index: 0;
}
main, .site-nav, .site-footer { position: relative; z-index: 1; }

.shell { width: min(var(--shell), 100% - 40px); margin-inline: auto; }
@media (max-width: 640px) { .shell { width: calc(100% - 32px); } }

/* ---------- Typography ---------- */
h1, h2, h3, h4 { margin: 0; line-height: 1.28; font-weight: 800; letter-spacing: -.01em; }
h1 { font-size: clamp(2.4rem, 6vw, 4.4rem); line-height: 1.16; }
h2 { font-size: clamp(1.75rem, 3.6vw, 2.7rem); }
h3 { font-size: clamp(1.15rem, 2vw, 1.4rem); }
p { margin: 0 0 1rem; }
.lead { font-size: clamp(1rem, 1.5vw, 1.15rem); color: var(--muted); max-width: 62ch; }
.muted { color: var(--muted); }

.grad-text {
  background: linear-gradient(200deg, #FFFFFF 18%, #D6C6FF 48%, var(--violet) 92%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.mono { font-family: var(--font-mono); }

/* عنوان قسم: سطر رفيع + نص */
.section-head { margin-bottom: 42px; }
.section-kicker {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-mono); font-size: .78rem; color: var(--violet-hi);
  letter-spacing: .1em; margin-bottom: 14px;
}
.section-kicker::before {
  content: ''; width: 34px; height: 1px;
  background: linear-gradient(to left, var(--violet), transparent);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 14px 30px; border-radius: var(--r-pill); border: 1px solid transparent;
  font-weight: 700; font-size: .96rem; white-space: nowrap;
  transition: transform .18s var(--ease), box-shadow .25s var(--ease), background .25s;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--violet) 0%, var(--violet-deep) 100%);
  color: #fff; box-shadow: 0 10px 34px -10px var(--violet-glow);
}
.btn-primary:hover { box-shadow: 0 14px 44px -8px var(--violet-glow); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--violet); background: rgba(124, 77, 255, .08); }
.btn-block { width: 100%; }
.btn-sm { padding: 10px 20px; font-size: .86rem; }
.btn[disabled], .btn.is-disabled { opacity: .45; pointer-events: none; }

/* ---------- Nav ---------- */
.site-nav {
  position: sticky; top: 0; z-index: 60; height: var(--nav-h);
  display: flex; align-items: center;
  background: rgba(10, 6, 17, .72);
  backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid var(--line-soft);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; gap: 20px; width: min(var(--shell), 100% - 40px); margin-inline: auto; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 34px; height: 34px; }
.brand-name { font-family: var(--font-en); font-weight: 700; font-size: 1.22rem; letter-spacing: .14em; }
.nav-links { display: flex; align-items: center; gap: 34px; }
.nav-link { color: var(--muted); font-size: .95rem; padding: 6px 0; position: relative; transition: color .2s; }
.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--text); font-weight: 600; }
.nav-link.active::after {
  content: ''; position: absolute; inset-inline: 0; bottom: -2px; height: 2px;
  background: linear-gradient(90deg, var(--violet-hi), var(--violet)); border-radius: 2px;
}
.nav-actions { display: flex; align-items: center; gap: 14px; }
.lang-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line);
  background: transparent; color: var(--text); font-family: var(--font-mono); font-size: .78rem;
  display: grid; place-items: center; transition: .2s;
}
.lang-btn:hover { border-color: var(--violet); color: var(--violet-hi); }
.nav-toggle { display: none; background: none; border: 0; color: var(--text); font-size: 1.4rem; padding: 8px; }

/* ---------- Hero ---------- */
.hero { padding: clamp(56px, 9vw, 108px) 0 clamp(48px, 7vw, 92px); }
.hero-grid { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(32px, 5vw, 72px); align-items: center; }
html[dir="rtl"] .hero-grid { direction: rtl; }
.hero-copy { text-align: start; }
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 12px; margin-bottom: 22px;
  font-family: var(--font-mono); font-size: .8rem; color: var(--muted); letter-spacing: .08em;
}
.hero-eyebrow::before { content: ''; width: 40px; height: 1px; background: var(--line); }
.hero h1 { margin-bottom: 24px; }
.hero h1 .caret {
  display: inline-block; width: 4px; height: .78em; vertical-align: -.06em;
  background: var(--violet-hi); margin-inline-start: 8px; border-radius: 2px;
  animation: blink 1.15s steps(2, start) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.hero-sub { max-width: 54ch; margin-bottom: 34px; }
.hero-cta { display: flex; gap: 14px; flex-wrap: wrap; }

/* بطاقة الكود */
.code-card {
  background: linear-gradient(180deg, #17102A 0%, #120C1F 100%);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: 0 40px 90px -40px rgba(0, 0, 0, .9), 0 0 0 1px rgba(124, 77, 255, .07) inset;
  overflow: hidden; direction: ltr;
}
.code-bar { display: flex; align-items: center; gap: 8px; padding: 15px 18px; border-bottom: 1px solid var(--line-soft); }
.code-dot { width: 10px; height: 10px; border-radius: 50%; background: #2E2545; }
.code-dot:first-child { background: var(--violet); }
.code-file { font-family: var(--font-mono); font-size: .8rem; color: var(--dim); margin-inline-start: 14px; }
.code-body { padding: 22px 20px; font-family: var(--font-mono); font-size: .84rem; line-height: 2.1; overflow-x: auto; }
.code-body .ln { display: inline-block; width: 26px; color: #3D3358; user-select: none; }
.c-com { color: #5C5177; } .c-key { color: #A67BFF; } .c-str { color: #6EE7A8; }
.c-fn { color: #E7DFFA; } .c-num { color: #FFC46B; } .c-bool { color: #7C4DFF; }

/* ---------- Stats strip ---------- */
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-block: 1px solid var(--line-soft);
}
.stat { padding: 30px 22px; text-align: center; border-inline-start: 1px solid var(--line-soft); }
.stat:first-child { border-inline-start: 0; }
.stat-n { font-family: var(--font-mono); font-size: clamp(1.6rem, 3vw, 2.3rem); font-weight: 700; color: #fff; }
.stat-l { font-size: .84rem; color: var(--dim); }

/* ---------- Sections ---------- */
.section { padding: clamp(58px, 8vw, 104px) 0; }
.section-alt { background: linear-gradient(180deg, transparent, rgba(255, 255, 255, .02), transparent); }

/* شبكة المزايا */
.why-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line-soft); border: 1px solid var(--line-soft); border-radius: var(--r-lg); overflow: hidden; }
.why-cell { background: var(--ink); padding: 34px 28px; transition: background .3s; }
.why-cell:hover { background: var(--ink-2); }
.why-icon {
  width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center;
  background: rgba(124, 77, 255, .12); color: var(--violet-hi); font-size: 1.05rem; margin-bottom: 18px;
}
.why-cell h3 { margin-bottom: 10px; font-size: 1.08rem; }
.why-cell p { color: var(--muted); font-size: .93rem; margin: 0; }

/* ---------- Course cards ---------- */
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 24px; }
.course-card {
  display: flex; flex-direction: column;
  background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--r-lg);
  overflow: hidden; transition: transform .25s var(--ease), border-color .25s;
}
.course-card:hover { transform: translateY(-4px); border-color: rgba(124, 77, 255, .45); }
.course-card.is-locked { opacity: .72; }
.course-cover { aspect-ratio: 16 / 9; background: linear-gradient(135deg, #241748, #150E26); position: relative; overflow: hidden; }
.course-cover img { width: 100%; height: 100%; object-fit: cover; }
.course-cover-fallback { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-mono); color: rgba(255, 255, 255, .18); font-size: 2.2rem; letter-spacing: .2em; }
.course-body { padding: 24px; display: flex; flex-direction: column; gap: 12px; flex: 1; }
.course-title { font-size: 1.22rem; font-weight: 800; }
.course-tag { color: var(--muted); font-size: .92rem; margin: 0; }
.course-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: .82rem; color: var(--dim); font-family: var(--font-mono); }
.course-modules { display: flex; flex-wrap: wrap; gap: 7px; }
.mod-chip {
  padding: 5px 12px; border-radius: var(--r-pill); font-size: .76rem;
  background: var(--surface); border: 1px solid var(--line-soft); color: var(--muted); font-family: var(--font-mono);
}
.course-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line-soft); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.course-price { font-family: var(--font-mono); font-weight: 700; color: #fff; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 13px; border-radius: var(--r-pill); font-size: .74rem; font-weight: 700;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-open   { background: rgba(110, 231, 168, .12); color: var(--mint); }
.badge-soon   { background: rgba(255, 196, 107, .12); color: var(--amber); }
.badge-closed { background: rgba(255, 122, 147, .1); color: var(--rose); }
.badge-float { position: absolute; top: 14px; inset-inline-start: 14px; backdrop-filter: blur(10px); }

/* ---------- Modules grid (شو رح تتعلم) ---------- */
.mod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.mod-card {
  padding: 22px; border-radius: var(--r-md); background: var(--surface);
  border: 1px solid var(--line-soft); transition: .25s;
}
.mod-card:hover { border-color: rgba(124, 77, 255, .4); background: rgba(124, 77, 255, .06); }
.mod-card .name { font-family: var(--font-mono); font-weight: 700; color: #fff; margin-bottom: 6px; }
.mod-card .from { font-size: .78rem; color: var(--dim); }
.mod-card .hrs { font-size: .78rem; color: var(--violet-hi); font-family: var(--font-mono); }

/* ---------- Instructors ---------- */
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 20px; }
.team-card { background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 26px; text-align: start; }
.team-avatar {
  width: 74px; height: 74px; border-radius: 20px; object-fit: cover; margin-bottom: 16px;
  background: linear-gradient(135deg, var(--violet-deep), #1B1230);
  display: grid; place-items: center; font-family: var(--font-mono); font-size: 1.4rem; color: #fff;
}
.team-card h3 { font-size: 1.06rem; margin-bottom: 4px; }
.team-role { color: var(--violet-hi); font-size: .85rem; margin-bottom: 10px; }
.team-bio { color: var(--muted); font-size: .88rem; margin: 0 0 14px; }
.team-links { display: flex; gap: 10px; }
.team-links a {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line-soft); color: var(--muted); transition: .2s;
}
.team-links a:hover { color: var(--violet-hi); border-color: var(--violet); }

/* ---------- Course details ---------- */
.detail-hero { padding: clamp(40px, 6vw, 72px) 0 34px; }
.detail-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 40px; align-items: start; }
.detail-facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line-soft); border: 1px solid var(--line-soft); border-radius: var(--r-md); overflow: hidden; margin-top: 28px; }
.fact { background: var(--ink-2); padding: 18px 20px; }
.fact .k { font-size: .78rem; color: var(--dim); }
.fact .v { font-weight: 700; font-family: var(--font-mono); color: #fff; }

.sticky-card {
  position: sticky; top: calc(var(--nav-h) + 20px);
  background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 26px;
}
.price-row { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.price-row .n { font-family: var(--font-mono); font-size: 2rem; font-weight: 700; color: #fff; }
.seat-bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin: 14px 0 8px; }
.seat-bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--violet-hi), var(--violet)); }

/* Accordion المسارات */
.track { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; margin-bottom: 12px; background: var(--ink-2); }
.track-head {
  width: 100%; display: flex; align-items: center; gap: 14px; padding: 18px 22px;
  background: none; border: 0; color: var(--text); text-align: start;
}
.track-head .idx { font-family: var(--font-mono); font-size: .8rem; color: var(--dim); min-width: 26px; }
.track-head .nm { font-weight: 700; flex: 1; font-family: var(--font-mono); }
.track-head .hr { font-size: .8rem; color: var(--dim); }
.track-head .chev { transition: transform .3s var(--ease); color: var(--violet-hi); }
.track.open .track-head .chev { transform: rotate(180deg); }
.track.open { border-color: rgba(124, 77, 255, .4); }
.track-body { max-height: 0; overflow: hidden; transition: max-height .38s var(--ease); }
.track-inner { padding: 4px 22px 22px; border-top: 1px solid var(--line-soft); }
.track-inner p { color: var(--muted); font-size: .92rem; padding-top: 14px; }
.topic-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 9px; }
.topic-list li { display: flex; gap: 10px; align-items: flex-start; font-size: .92rem; color: var(--muted); }
.topic-list li::before { content: '▸'; color: var(--violet); flex: none; }

.outcome-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.outcome-list li { display: flex; gap: 12px; align-items: flex-start; }
.outcome-list li i { color: var(--mint); margin-top: 5px; }

/* ---------- Form ---------- */
.form-card { background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--r-lg); padding: clamp(24px, 4vw, 40px); }
.field { margin-bottom: 20px; }
.field label { display: block; font-size: .88rem; font-weight: 600; margin-bottom: 8px; }
.field .req { color: var(--violet-hi); }
.input, select.input, textarea.input {
  width: 100%; padding: 14px 18px; border-radius: 14px;
  background: rgba(255, 255, 255, .04); border: 1px solid var(--line);
  color: var(--text); font: inherit; font-size: .95rem; transition: .2s;
}
.input::placeholder { color: var(--dim); }
.input:focus { outline: none; border-color: var(--violet); background: rgba(124, 77, 255, .07); box-shadow: 0 0 0 4px rgba(124, 77, 255, .12); }
.input.is-invalid { border-color: var(--rose); }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: left 20px top 22px, left 15px top 22px; background-size: 5px 5px; background-repeat: no-repeat; }
html[dir="ltr"] select.input { background-position: right 15px top 22px, right 20px top 22px; }
.field-err { color: var(--rose); font-size: .8rem; margin-top: 6px; display: none; }
.field-err.show { display: block; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line-soft); background: linear-gradient(180deg, transparent, rgba(124, 77, 255, .05)); margin-top: 40px; }
.footer-top { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1.4fr; gap: 40px; padding: 58px 0 44px; }
.footer-brand .brand { margin-bottom: 16px; }
.footer-brand p { color: var(--muted); font-size: .92rem; max-width: 38ch; }
.footer-col h4 { font-size: .95rem; margin-bottom: 16px; }
.footer-col ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 11px; }
.footer-col a { color: var(--muted); font-size: .9rem; transition: color .2s; }
.footer-col a:hover { color: var(--violet-hi); }
.footer-news .news-form { display: flex; gap: 8px; margin-top: 14px; }
.footer-news .input { padding: 12px 16px; }
.footer-bottom {
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 20px 0 28px; border-top: 1px solid var(--line-soft);
  font-size: .82rem; color: var(--dim); font-family: var(--font-mono);
}

/* ---------- Mobile tab bar (app feel) ---------- */
.tabbar { display: none; }

/* ---------- 404 ---------- */
.err-wrap { min-height: 62vh; display: grid; place-items: center; text-align: center; }
.err-code { font-family: var(--font-mono); font-size: clamp(4rem, 16vw, 9rem); font-weight: 700; }

/* ---------- Reveal (حركة واحدة عند التحميل) ---------- */
.reveal { opacity: 0; transform: translateY(18px); }
.reveal.in { opacity: 1; transform: none; transition: opacity .6s var(--ease), transform .6s var(--ease); }

/* ---------- Responsive ---------- */
@media (max-width: 1020px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-media { order: -1; }
  .why-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: 1fr; }
  .sticky-card { position: static; }
  .footer-top { grid-template-columns: 1fr 1fr; gap: 32px; }
}

@media (max-width: 760px) {
  :root { --nav-h: 64px; }
  .nav-links {
    position: fixed; inset: var(--nav-h) 0 auto; flex-direction: column; gap: 0;
    background: rgba(12, 8, 20, .97); backdrop-filter: blur(20px);
    padding: 10px 24px 22px; border-bottom: 1px solid var(--line);
    transform: translateY(-130%); transition: transform .34s var(--ease);
  }
  .nav-links.open { transform: none; }
  .nav-link { padding: 15px 0; width: 100%; border-bottom: 1px solid var(--line-soft); }
  .nav-toggle { display: block; }
  .nav-actions .btn { display: none; }

  .why-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(3) { border-inline-start: 0; }
  .stat { border-top: 1px solid var(--line-soft); }
  .stat:nth-child(-n+2) { border-top: 0; }
  .form-row { grid-template-columns: 1fr; }
  .detail-facts { grid-template-columns: 1fr; }
  .footer-top { grid-template-columns: 1fr; }
  body { padding-bottom: 72px; }

  /* شريط تبويبات سفلي زي تطبيق الهاتف */
  .tabbar {
    display: flex; position: fixed; inset-inline: 0; bottom: 0; z-index: 70;
    background: rgba(12, 8, 20, .92); backdrop-filter: blur(20px);
    border-top: 1px solid var(--line); padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  }
  .tabbar a {
    flex: 1; display: grid; place-items: center; gap: 3px; padding: 6px 0;
    color: var(--dim); font-size: .68rem;
  }
  .tabbar a i { font-size: 1.05rem; }
  .tabbar a.active { color: var(--violet-hi); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; transform: none; }
}
