:root {
  --ink: #050F22;        /* page */
  --deep: #0A1B3A;       /* panels */
  --line: #1C3563;       /* borders */
  --ts: #3178C6;         /* TypeScript blue */
  --glow: #4FA8FF;       /* cover glow */
  --ice: #D6E7FF;        /* body text */
  --mute: #8AA4CC;       /* secondary text */
  --add: #3FD68B;
  --del: #FF6B7A;

  --f-display: "Readex Pro", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --f-body: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --f-code: "JetBrains Mono", ui-monospace, Consolas, monospace;

  --wrap: 1120px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

body {
  margin: 0;
  background: var(--ink);
  color: var(--ice);
  font-family: var(--f-body);
  font-size: 1.0625rem;
  line-height: 1.85;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--glow); }
:focus-visible { outline: 2px solid var(--glow); outline-offset: 3px; border-radius: 4px; }

h1, h2, h3 { font-family: var(--f-display); line-height: 1.25; margin: 0; }
h2 { font-size: clamp(1.6rem, 3.2vw, 2.25rem); font-weight: 700; }
h3 { font-size: 1.15rem; font-weight: 500; }

main > section { max-width: var(--wrap); margin: 0 auto; padding: clamp(4rem, 9vw, 7rem) 1.25rem; }

.section-head { max-width: 40rem; margin-bottom: 2.5rem; }
.section-head p { color: var(--mute); margin: .75rem 0 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--f-display); font-weight: 500; font-size: 1rem;
  padding: .8rem 1.5rem; border-radius: 999px;
  background: var(--ts); color: #fff; text-decoration: none;
  border: 1px solid var(--ts); cursor: pointer;
  transition: background .2s, box-shadow .2s;
}
.btn:hover { background: #3f8ae0; box-shadow: 0 0 24px rgba(79,168,255,.35); }
.btn-ghost { background: transparent; color: var(--ice); border-color: var(--line); }
.btn-ghost:hover { background: var(--deep); box-shadow: none; }
.btn-small { padding: .45rem 1rem; font-size: .9rem; }
.btn-large { padding: 1rem 2.25rem; font-size: 1.15rem; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1.5rem;
  padding: .75rem clamp(1rem, 4vw, 2.5rem);
  background: rgba(5,15,34,.82);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--f-display); font-weight: 700; color: var(--ice); text-decoration: none; }
.topnav { display: flex; gap: 1.25rem; margin-inline-start: auto; }
.topnav a { color: var(--mute); text-decoration: none; font-size: .95rem; }
.topnav a:hover { color: var(--ice); }
@media (max-width: 640px) { .topnav { display: none; } .topbar .btn { margin-inline-start: auto; } }

/* Hero */
.hero {
  display: grid; grid-template-columns: 1.1fr .9fr; align-items: center; gap: clamp(2rem, 5vw, 4rem);
  padding-top: clamp(3rem, 7vw, 5rem) !important;
}
.hero h1 { display: flex; flex-direction: column; gap: .1em; margin-bottom: 1.5rem; }
.h1-ar { font-size: clamp(2.8rem, 7.5vw, 5.4rem); font-weight: 700; }
.h1-ts {
  font-size: clamp(2.6rem, 7vw, 5rem); font-weight: 700; letter-spacing: -.02em;
  color: transparent; -webkit-text-stroke: 1.5px var(--glow);
  text-shadow: 0 0 32px rgba(79,168,255,.35);
  display: flex; align-items: center; gap: .3em; white-space: nowrap;
}
.ts-in { -webkit-text-stroke: 0; color: var(--glow); font-size: .6em; }
.lede { color: var(--mute); max-width: 34rem; margin: 0 0 2rem; font-size: 1.1rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .75rem; }

.facts { display: flex; gap: 2.25rem; margin: 2.75rem 0 0; padding: 0; }
.facts div { display: flex; flex-direction: column; }
.facts dt { font-family: var(--f-code); font-size: 1.75rem; font-weight: 600; color: var(--ice); line-height: 1.1; }
.facts dd { margin: 0; color: var(--mute); font-size: .9rem; }

.hero-cover { margin: 0; position: relative; }
.hero-cover::before {
  content: ""; position: absolute; inset: 12% 8%; z-index: -1;
  background: radial-gradient(closest-side, rgba(49,120,198,.55), transparent);
  filter: blur(40px);
}
.hero-cover img { border-radius: 10px; box-shadow: 0 30px 80px rgba(0,0,0,.6); }

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; }
  .hero-cover { max-width: 420px; margin: 0 auto; order: -1; }
}

/* Refactor editor — the signature */
.editor {
  background: var(--deep);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(79,168,255,.06), 0 40px 80px -30px rgba(49,120,198,.45);
}
.editor-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .75rem 1rem; border-bottom: 1px solid var(--line);
  background: #081732;
}
.tabs { display: flex; gap: .25rem; background: var(--ink); padding: .25rem; border-radius: 999px; }
.tabs button, .toc-tabs button {
  font: inherit; font-size: .92rem; color: var(--mute); background: transparent;
  border: 0; padding: .4rem 1rem; border-radius: 999px; cursor: pointer;
}
.tabs button[aria-selected="true"], .toc-tabs button[aria-selected="true"] { background: var(--ts); color: #fff; }
#add-feature[aria-pressed="true"] { background: transparent; color: var(--ice); border-color: var(--line); }

.editor-body {
  direction: ltr; text-align: left;
  display: grid; gap: 1px; background: var(--line);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr));
}
.file { background: var(--deep); min-width: 0; }
.file-name {
  font-family: var(--f-code); font-size: .8rem; color: var(--mute);
  padding: .55rem 1rem; border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 1rem;
}
.file-name .badge { color: var(--add); }
.file-name .badge.edit { color: var(--del); }
.file.new { animation: arrive .45s ease-out; }
@keyframes arrive { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

pre {
  margin: 0; padding: 1rem 0; overflow-x: auto;
  font-family: var(--f-code); font-size: .85rem; line-height: 1.7;
}
.ln { display: block; padding: 0 1rem; white-space: pre; }
.ln.added { background: rgba(63,214,139,.12); box-shadow: inset 3px 0 var(--add); }
.ln.changed { background: rgba(255,107,122,.12); box-shadow: inset 3px 0 var(--del); }
.k { color: #7FB4FF; } .t { color: #5FE0D0; } .s { color: #FFC680; } .n { color: #E9A0FF; } .c { color: #5A7299; }

.editor-note {
  margin: 0; padding: 1rem 1.25rem; border-top: 1px solid var(--line);
  color: var(--ice); font-size: .98rem;
}
.editor-note strong { font-weight: 600; }

/* Learning path — a real sequence */
.path {
  list-style: none; margin: 0; padding: 0; counter-reset: step;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0;
  border-top: 1px solid var(--line);
}
.path li { counter-increment: step; padding: 1.75rem 1.25rem 0 0; position: relative; }
.path li + li { border-inline-start: 1px solid var(--line); padding-inline-start: 1.25rem; }
.path li:first-child { padding-inline-start: 1.25rem; padding-right: 0; }
.path li::before {
  content: counter(step); font-family: var(--f-code); color: var(--glow);
  display: block; font-size: .9rem; margin-bottom: .5rem;
}
.path p { color: var(--mute); font-size: .97rem; margin: .5rem 0 0; }
@media (max-width: 860px) {
  .path { grid-template-columns: 1fr 1fr; row-gap: 2rem; }
  .path li:nth-child(3) { border-inline-start: 0; padding-inline-start: 0; }
}
@media (max-width: 520px) {
  .path { grid-template-columns: 1fr; }
  .path li, .path li + li { border-inline-start: 0; padding-inline-start: 0; padding-right: 0; }
}

/* Contents */
.toc-tabs {
  display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1.5rem;
}
.toc-tabs button { border: 1px solid var(--line); }
.toc-tabs button[aria-selected="true"] { border-color: var(--ts); }
.toc-list {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  border-top: 1px solid var(--line);
}
.toc-list li {
  display: flex; gap: 1rem; align-items: baseline;
  padding: 1rem .25rem; border-bottom: 1px solid var(--line);
}
.toc-num { font-family: var(--f-code); color: var(--glow); font-size: .85rem; min-width: 2ch; }
.toc-title { font-weight: 500; }
.toc-desc { display: block; color: var(--mute); font-size: .9rem; font-weight: 400; }

/* FAQ */
.faq-list { max-width: 46rem; border-top: 1px solid var(--line); }
details { border-bottom: 1px solid var(--line); }
summary {
  cursor: pointer; list-style: none; padding: 1.15rem 0;
  font-family: var(--f-display); font-weight: 500; font-size: 1.08rem;
  display: flex; justify-content: space-between; gap: 1rem;
}
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; font-family: var(--f-code); color: var(--glow); transition: transform .2s; }
details[open] summary::after { transform: rotate(45deg); }
details p { color: var(--mute); margin: 0 0 1.25rem; max-width: 40rem; }

/* Author */
.author { display: flex; gap: 2rem; align-items: center; }
.author-mark {
  flex: none; width: 96px; height: 96px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--f-display); font-size: 2.6rem; font-weight: 700;
  border: 1.5px solid var(--glow); color: var(--glow);
  box-shadow: 0 0 30px rgba(79,168,255,.25);
}
.author p { color: var(--mute); max-width: 36rem; margin: .5rem 0 0; }
@media (max-width: 520px) { .author { flex-direction: column; align-items: flex-start; } }

/* CTA */
.get {
  text-align: center;
  background: radial-gradient(60% 80% at 50% 100%, rgba(49,120,198,.35), transparent 70%);
  border-top: 1px solid var(--line);
  max-width: none !important;
}
.get h2 { font-size: clamp(1.8rem, 4.5vw, 3rem); }
.get p { color: var(--mute); margin: 1rem auto 2rem; max-width: 32rem; }

.footer { text-align: center; color: var(--mute); font-size: .85rem; padding: 2rem 1rem; border-top: 1px solid var(--line); }
.footer p { margin: 0; }
