/* عربي — the tutorial pages (home and /<id>), laid out like javascript.info. */

html { scroll-padding-top: 80px; }

body {
  font-family: var(--font);
  background: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
}

a { color: var(--accent); }

/* ── Header ─────────────────────────── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  height: auto;
  padding: 0;
  display: block;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1240px;
  margin: 0 auto;
  height: 64px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}


.site-nav { margin-right: auto; display: flex; align-items: center; gap: 6px; }
.site-nav .btn { text-decoration: none; }

.nav-link {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 10px;
}
.nav-link:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-link[aria-current] { color: var(--accent); }

/* ── Home: the table of contents ────── */

.home { max-width: 1240px; margin: 0 auto; padding: 32px 20px 64px; }

.home-top { max-width: 760px; margin-bottom: 28px; }
.home-top h1 { font-size: 34px; display: flex; align-items: baseline; gap: 12px; }
.home-top h1 .en { display: inline; font-size: 16px; }
.home-lead { font-size: 19px; line-height: 2; margin: 6px 0 18px; }
.home-lead .en { font-size: 14px; }

.home-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 18px; }

.search {
  flex: 1;
  min-width: 220px;
  max-width: 420px;
  height: 44px;
  font: inherit;
  font-size: 16px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--bg-panel);
  color: var(--text-primary);
  outline: none;
}
.search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.progress { font-size: 15px; font-weight: 700; color: var(--accent); }

.part { margin-top: 36px; }
.part-title { font-size: 24px; padding-bottom: 10px; margin-bottom: 18px; border-bottom: 2px solid var(--border); }
.part-title .en { font-size: 14px; }

.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 18px; }

.group {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px 14px;
  box-shadow: var(--shadow);
}

.group-title { display: flex; align-items: flex-start; gap: 12px; font-size: 19px; margin-bottom: 10px; }
.group-title a { color: var(--text-primary); text-decoration: none; }
.group-title a:hover { color: var(--accent); }
.group-title .en { font-size: 13px; }

.group-num {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
}

.group-pages { list-style: none; padding-right: 44px; }
.group-pages li { padding: 3px 0; font-size: 17px; line-height: 1.8; }
.group-pages a { text-decoration: none; }
.group-pages a:hover { text-decoration: underline; }

.done-mark { color: var(--accent); font-weight: 700; }

.search-empty { margin-top: 28px; font-size: 17px; color: var(--text-muted); }

/* ── A page: sidebar and article ────── */

.page {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 20px 64px;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  font-size: 15px;
}

.sidebar-part { display: block; font-weight: 700; color: var(--text-muted); text-decoration: none; margin-bottom: 12px; line-height: 1.7; }
.sidebar-part:hover { color: var(--accent); }
.sidebar-group { margin-bottom: 16px; }
.sidebar-group h3 { font-size: 15px; margin-bottom: 4px; }
.sidebar-pages { list-style: none; }
.sidebar-pages a {
  display: block;
  padding: 4px 12px;
  border-right: 2px solid var(--border);
  color: var(--text-secondary);
  text-decoration: none;
  line-height: 1.7;
}
.sidebar-pages a:hover { color: var(--text-primary); border-right-color: var(--border-strong); }
.sidebar-pages a[aria-current] { color: var(--accent); border-right-color: var(--accent); font-weight: 700; background: var(--accent-soft); }

.article {
  max-width: 860px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 40px 36px;
  box-shadow: var(--shadow);
}

.breadcrumbs { font-size: 14px; color: var(--text-muted); margin-bottom: 10px; }
.breadcrumbs a { text-decoration: none; }

.page-title { font-size: 32px; line-height: 1.6; }
.page-title + .en { font-size: 15px; margin-bottom: 18px; }

.step-text { font-size: 19px; line-height: 2.1; margin: 22px 0 12px; }
.step-text .en, .task-text .en { font-size: 14px; margin-top: 4px; }

/* ── Examples you can run ───────────── */

.example {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
  overflow: hidden;
  margin: 10px 0 8px;
}

.example-bar {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding: 6px 8px 0;
}
.example-bar .mini-btn, .task-actions .mini-btn { text-decoration: none; }
.run-btn { color: var(--accent); border-color: var(--accent); }
.run-btn.running { color: var(--red); border-color: var(--red); }

.example-code {
  font-family: var(--font);
  font-size: 18px;
  line-height: var(--code-line);
  white-space: pre-wrap;
  overflow-wrap: break-word;
  tab-size: 4;
  padding: 2px 18px 12px;
  margin: 0;
}

.example-output {
  border-top: 1px dashed var(--border-strong);
  background: var(--bg-panel);
  padding: 10px 18px;
  font-size: 17px;
  line-height: 1.8;
  max-height: 340px;
  overflow-y: auto;
}

/* ── Exercises ──────────────────────── */

.tasks-heading { font-size: 26px; margin-top: 40px; padding-top: 18px; border-top: 2px solid var(--border); }
.tasks-heading .en { font-size: 14px; }

.task { margin-top: 22px; }
.task-title { font-size: 20px; display: flex; align-items: center; gap: 12px; }
.task-badge { font-size: 14px; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 0 10px 2px; }
.task-text { font-size: 18px; line-height: 2; margin: 6px 0 12px; }

.task-editor {
  /* the code area fills it; --rows is set from the exercise's code */
  display: flex;
  flex-direction: column;
  height: calc(var(--rows, 6) * 18px * var(--code-line) + 28px);
  min-height: 140px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  overflow: hidden;
}
.task-editor:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.task-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.task-actions .btn { height: 38px; }

.task .example-output { border: 1px solid var(--border); border-radius: 10px; }

.task-result p { font-size: 17px; font-weight: 700; white-space: pre-line; margin: 8px 0; }
.task-result.pass p { color: var(--accent); }
.task-result.fail p { color: var(--red); }
.task-result .en { white-space: pre-line; }

.solution { margin-top: 12px; }
.solution summary {
  cursor: pointer;
  width: fit-content;
  font-weight: 700;
  color: var(--text-secondary);
  padding: 4px 0;
}
.solution summary .en { display: inline; margin-right: 8px; }
.solution summary:hover { color: var(--accent); }

/* ── Reference pages ────────────────── */

.ref-entry { padding: 16px 0; border-bottom: 1px solid var(--border); }
.ref-usage code { font-family: var(--font); font-size: 20px; color: var(--tok-builtin); }
.ref-usage .en { display: inline; margin-right: 10px; color: var(--accent); }
.ref-doc { font-size: 18px; line-height: 2; margin-top: 4px; }

/* ── Previous / next ────────────────── */

.pager { display: flex; justify-content: space-between; gap: 14px; margin-top: 40px; }
.pager-link {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 48%;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
}
.pager-link:hover { border-color: var(--accent); background: var(--accent-soft); }
.pager-next { text-align: left; margin-right: auto; }
.pager-label { font-size: 13px; color: var(--text-muted); }
.pager-title { font-size: 17px; font-weight: 700; }

.not-found-link { margin-top: 20px; }
.not-found-link .btn { width: fit-content; text-decoration: none; }

/* ── Phones and narrow windows ──────── */

@media (max-width: 900px) {
  .page { grid-template-columns: minmax(0, 1fr); gap: 20px; padding: 16px 16px 48px; }
  .sidebar { position: static; max-height: none; order: 2; }
  .article { padding: 20px 16px 28px; }
  .page-title { font-size: 26px; }
  .step-text { font-size: 18px; }
}

@media (max-width: 600px) {
  .header-inner { padding: 0 16px; height: 58px; }
  .home { padding: 22px 16px 48px; }
  .home-top h1 { font-size: 28px; }
  .groups { grid-template-columns: minmax(0, 1fr); }
  .example-code { font-size: 16px; padding: 2px 12px 10px; }
  .code-surface { font-size: 15px; padding-right: 3.3rem; }
  .code-area::before { width: 2.6rem; }
  .hl-line::before { right: -3.2rem; width: 2.6rem; font-size: 12px; }
  .task-editor { height: calc(var(--rows, 6) * 15px * var(--code-line) + 28px); }
}
