/* Textbook pages: the lesson text, its boxes and the lesson list.
   The header, cards, buttons, page heading and footer come from shared.css. */

/* ---- the lesson list ----
   Wide window (981px and up): the list is always beside the lesson.
   980px and below: the list is a bar above the lesson that opens and closes. */
.toc { min-width: 0; }
.toc > summary { display: none; }

.nav-toggle {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  list-style: none;
  cursor: pointer;
  color: var(--deep);
  font-weight: 700;
}
.nav-toggle::-webkit-details-marker { display: none; }

.burger { position: relative; display: inline-block; width: 1.05rem; height: 2px; background: currentColor; border-radius: 2px; }
.burger::before,
.burger::after {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  width: 1.05rem;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
}
.burger::before { top: -5px; }
.burger::after { top: 5px; }

@media (min-width: 981px) {
  /* Chrome hides a closed details list even when its inner nav is displayed.
     On a wide window the list is always shown beside the lesson. */
  .toc::details-content { display: block !important; }
  .toc > .side { display: grid !important; }
}

@media (max-width: 980px) {
  .toc > summary {
    display: flex;
    align-items: center;
    padding: 0.8rem 1rem;
    background: var(--card);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }
  .toc > .side { margin-top: 0.6rem; max-height: 64vh; overflow: auto; }
  .toc:not([open]) > .side { display: none; }
}

/* ---- lesson text ---- */
/* Paragraph direction comes from the article (rtl for Persian, ltr for English).
   English runs inside Persian are isolated with <bdi>/<code>, so a Persian
   sentence that starts with an English word stays right-to-left. */
.lesson[dir="rtl"] { text-align: right; }
.lesson[dir="ltr"] { text-align: left; }
.lesson p { margin: 0.5rem 0; }

.lesson img,
.shot img {
  display: block;
  max-width: min(100%, 820px);
  height: auto;
  margin: 0.7rem auto;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.shot {
  margin: 0.9rem auto 1rem;
  max-width: min(100%, 820px);
  text-align: center;
}

.shot img { margin-bottom: 0; }

.shot figcaption {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 500;
  line-height: 1.45;
  text-align: center;
}

.lesson hr {
  border: 0;
  border-top: 1px dashed var(--line);
  margin: 1.3rem 0;
}

.code-wrap {
  direction: ltr;
  unicode-bidi: isolate;
  max-width: 100%;
  margin: 0.8rem 0;
}

.lesson pre,
.lesson pre code,
.code-wrap,
.code-wrap pre,
.code-wrap code {
  direction: ltr;
  unicode-bidi: isolate;
  text-align: left;
}

.lesson pre {
  background: var(--deep);
  color: #f4faf8;
  padding: 0.85rem 1rem;
  overflow: auto;
  border-radius: 10px;
  font-family: var(--mono);
  font-size: 0.92rem;
  line-height: 1.55;
  margin: 0;
  white-space: pre;
}

.lesson :not(pre) > code,
.lesson bdi[dir="ltr"] {
  direction: ltr;
  unicode-bidi: isolate;
}

.lesson :not(pre) > code {
  background: var(--chip);
  padding: 0.05em 0.35em;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.9em;
}


.lesson table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.8rem 0;
  font-size: 0.95rem;
}

.lesson th, .lesson td {
  border: 1px solid var(--line);
  padding: 0.35rem 0.5rem;
  vertical-align: top;
}

.lesson th { background: var(--chip); }

.contents {
  list-style: none;
  margin: 0.2rem 0 0;
  padding: 0;
}

.contents a {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.55rem 0.15rem;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
}

.contents a:hover { background: var(--chip); }

.contents .label {
  flex: 1;
  min-width: 0;
  text-align: start;
  line-height: 1.45;
}

.contents .page {
  flex: none;
  direction: ltr;
  unicode-bidi: isolate;
  color: var(--muted);
  font-size: 0.92rem;
  min-width: 2.4rem;
  text-align: end;
}

.contents .module .label { font-weight: 700; color: var(--deep); }

.contents .unit .label { padding-inline-start: 0.9rem; }
.page-mark {
  display: inline-block;
  margin: 0.8rem 0 0.2rem;
  padding: 0.05rem 0.55rem;
  border-radius: 999px;
  background: var(--chip);
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 700;
}

/* ---- boxes inside a lesson: one surface, the kind is shown by its edge and label ---- */
.extra {
  margin-top: 1rem;
}
.extra h2 {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
  color: var(--deep);
}
.extra .extra-note {
  margin: 0 0 0.6rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.extra ol, .extra ul { margin: 0.2rem 0 0.7rem; padding-inline-start: 1.3rem; }
.extra li { margin: 0.35rem 0; }
.extra a { font-weight: 700; }

.callout {
  margin: 1rem 0;
  padding: 0.8rem 1.1rem 0.9rem;
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-inline-start: 4px solid var(--kind, var(--accent));
  border-radius: var(--radius-sm);
}
.callout .callout-label {
  display: inline-block;
  margin: 0 0 0.45rem;
  padding: 0.05rem 0.6rem;
  border-radius: 999px;
  background: var(--paper);
  color: var(--kind, var(--accent));
  font-size: 0.85rem;
  font-weight: 700;
}
.callout.continued { border-top-style: dashed; }
.callout .callout { margin: 0.7rem 0; }
.callout h3 {
  margin: 0.6rem 0 0.35rem;
  padding: 0;
  border: 0;
  font-size: 1.02rem;
}
.callout.curiosity { --kind: #a86b12; }
.callout.project { --kind: #2f6cb5; }
.callout.note { --kind: #6f5bb5; }
.callout.activity { --kind: #c0622a; }
.callout.workshop { --kind: #138a9a; }
.callout.example { --kind: #7d6a45; }
.callout.more { --kind: #4f8f32; }
.callout.footnote {
  background: transparent;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  padding: 0.5rem 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}
.callout.footnote .callout-label { display: none; }
.callout .code-wrap { margin: 0.6rem 0; }
.callout figure:last-child,
.callout p:last-child,
.callout ol:last-child,
.callout ul:last-child { margin-bottom: 0.1rem; }


.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  margin: 0.4rem 0 0.9rem;
}
.table-wrap table { margin: 0; }
.lesson .table-cap {
  margin: 1rem 0 0.2rem;
  text-align: center;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 700;
}
.lesson td code { white-space: nowrap; }

.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.9rem;
  margin: 0.7rem 0 1.35rem;
}

.link-card {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 0.95rem 1.05rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--ease);
}

.link-card:hover {
  box-shadow: var(--shadow);
}

.link-card h3 { margin: 0 0 0.25rem; font-size: 1rem; color: var(--deep); }

.link-card p { margin: 0 0 0.55rem; font-size: var(--text-sm); color: var(--ink-soft); }

.link-card .video-title { color: var(--ink); font-weight: 700; }

.link-card a {
  font-weight: 700;
  text-decoration: none;
  border-bottom: 2px solid color-mix(in srgb, var(--teal) 35%, transparent);
}

.link-card a:hover {
  border-bottom-color: var(--teal);
}

.link-card .badge {
  flex: none;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 12px;
  background: var(--teal);
  color: #f4faf8;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  direction: ltr;
}

.link-card.video { flex-direction: column; }

.link-card .shot-link { display: block; width: 100%; }

.link-card .shot-link img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
}

.link-card .no-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 120px;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  background: var(--chip);
  color: var(--teal);
  font-size: 2rem;
}

.link-note { color: var(--muted); font-size: 0.9rem; }

/* ---- previous and next: two cards side by side ---- */
.pager {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.8rem;
  margin-top: 1.25rem;
}
.pager a {
  display: grid;
  gap: 0.25rem;
  min-width: 0;
  padding: 0.9rem 1.1rem;
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--ink);
  text-decoration: none;
}
.pager a:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.pager-word { font-size: 0.8rem; font-weight: 700; color: var(--accent); }
.pager-name { line-height: 1.4; font-weight: 700; color: var(--deep); }

/* ---- landing and book entry: the cards come from shared.css; these only place them ---- */
.course .chip { margin-bottom: 0.55rem; }
.course .card-title { font-size: 1.3rem; }
.card-cta {
  display: inline-block;
  margin-top: 0.8rem;
  color: var(--accent);
  font-weight: 700;
}
.step-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.9rem;
}
.step { display: grid; gap: 0.3rem; align-content: start; }
.step .num { justify-self: start; margin-bottom: 0.25rem; }
.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem 1.2rem;
  margin-top: 0.9rem;
}
.banner .card-title { margin-bottom: 0.2rem; }
.option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 0.9rem;
}
.option { display: flex; flex-direction: column; gap: 0.45rem; }
.option .num { align-self: flex-start; margin-bottom: 0.2rem; }
.option .card-title { margin: 0; font-size: 1.12rem; }
.option .card-cta { margin-top: auto; padding-top: 0.5rem; }
.option .btn-row { margin-top: 0.6rem; }
.option-note { margin: 0.4rem 0 0; font-size: 0.88rem; color: var(--muted); }
.lesson > .section-h:first-child { margin-top: 0; }

/* ---- phones ---- */
@media (max-width: 699px) {
  .lesson.card { padding: 1rem 0.95rem; }
  .callout { padding: 0.7rem 0.9rem 0.8rem; }
}
