/* ═══════════════════════════════════════════════════════════════════════════
   In-Depth Engineering Series — Portable Shared Components (v1.0)
   Shell · Right TOC · Lesson Header · Callouts · Code · Diagrams · Share · Footer
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── 1. Lesson 2-Column + Sticky Right TOC Reading Shell ────────────────── */
.ds-lesson-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--ds-space-10);
  align-items: start;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
}

@media (min-width: 1280px) {
  .main__content:has(.ds-lesson-shell--with-toc) {
    max-width: 1140px;
  }

  .ds-lesson-shell--with-toc {
    grid-template-columns: minmax(0, var(--ds-article-max)) var(--ds-toc-w);
    justify-content: space-between;
  }

  .ds-lesson-shell--with-toc .topic-quick-jump {
    display: none;
  }
}

.sr-only-status {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.ds-below-fold {
  content-visibility: auto;
  contain-intrinsic-size: auto none auto 320px;
}

.ds-lesson-article {
  min-width: 0;
  width: 100%;
  max-width: var(--ds-article-max);
}

/* Sticky Right-Rail Table of Contents */
.ds-toc {
  display: none;
}

@media (min-width: 1280px) {
  .ds-toc {
    display: block;
    position: sticky;
    top: calc(var(--ds-topbar-h) + var(--ds-space-6));
    max-height: calc(100vh - var(--ds-topbar-h) - var(--ds-space-10));
    overflow-y: auto;
    padding-left: var(--ds-space-4);
    border-left: 1px solid var(--ds-border);
    font-size: var(--ds-text-xs);
  }
}

.ds-toc__heading {
  font-size: var(--ds-text-xs);
  font-weight: 600;
  color: var(--ds-ink);
  margin-bottom: var(--ds-space-3);
}

.ds-toc__list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  list-style: none;
  padding: 0;
  margin: 0 0 var(--ds-space-5) 0;
}

.ds-toc__link {
  display: block;
  padding: 5px 8px;
  border-radius: var(--ds-radius-xs);
  color: var(--ds-ink-muted);
  line-height: 1.38;
  text-decoration: none;
  transition: color var(--ds-dur-fast), background var(--ds-dur-fast);
}

.ds-toc__link:hover {
  color: var(--ds-ink);
  background: var(--ds-surface-hover);
}

.ds-toc__link.is-active {
  color: var(--brand-accent);
  background: var(--brand-accent-soft);
  font-weight: 500;
}

.ds-toc__progress-card {
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-md);
  padding: var(--ds-space-3);
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-2);
}

.ds-toc__progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--ds-font-mono);
  font-size: var(--ds-text-2xs);
  color: var(--ds-ink-muted);
}

.ds-toc__progress-bar {
  height: 4px;
  background: var(--ds-canvas-subtle);
  border-radius: var(--ds-radius-pill);
  overflow: hidden;
}

.ds-toc__progress-fill {
  height: 100%;
  background: var(--brand-accent);
  border-radius: var(--ds-radius-pill);
  transition: width var(--ds-dur-slow) var(--ds-ease-out);
}

/* ── 2. Framed Lesson Header & One-Line Promise ─────────────────────────── */
.ds-lesson-hero {
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
  padding: var(--ds-space-6);
  margin-bottom: var(--ds-space-8);
}

@media (max-width: 640px) {
  .ds-lesson-hero {
    padding: var(--ds-space-4);
  }
}

.ds-lesson-hero__meta-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--ds-space-2);
  margin-bottom: var(--ds-space-3);
  font-family: var(--ds-font-mono);
  font-size: var(--ds-text-xs);
  color: var(--ds-ink-muted);
}

.ds-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: var(--ds-radius-pill);
  font-family: var(--ds-font-mono);
  font-size: var(--ds-text-2xs);
  font-weight: 500;
  border: 1px solid var(--ds-border);
  background: var(--ds-canvas);
  color: var(--ds-ink-muted);
}

.ds-pill--accent {
  background: var(--brand-accent-soft);
  border-color: var(--brand-accent-border);
  color: var(--brand-accent);
}

.ds-lesson-hero__promise {
  font-size: var(--ds-text-prose);
  line-height: 1.5;
  color: var(--ds-ink-muted);
  max-width: 64ch;
  margin-top: var(--ds-space-2);
  margin-bottom: var(--ds-space-4);
}

.ds-lesson-hero__toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--ds-space-2);
  padding-top: var(--ds-space-4);
  border-top: 1px solid var(--ds-divider);
}

/* ── 3. Craft-Floor Callouts (1px Full Border, Icon Badge, Zero Left Stripe) */
.ds-callout,
.callout,
.intuition {
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
  padding: var(--ds-space-4) var(--ds-space-5);
  margin: var(--ds-space-6) 0;
}

.ds-callout--note {
  background: var(--ds-info-bg);
  border-color: var(--ds-info-border);
}

.ds-callout--tip {
  background: var(--ds-success-bg);
  border-color: var(--ds-success-border);
}

.ds-callout--warning,
.ds-callout--mistake {
  background: var(--ds-warning-bg);
  border-color: var(--ds-warning-border);
}

.ds-callout--danger {
  background: var(--ds-danger-bg);
  border-color: var(--ds-danger-border);
}

.ds-callout__header {
  display: flex;
  align-items: center;
  gap: var(--ds-space-2);
  font-size: var(--ds-text-base);
  font-weight: 600;
  color: var(--ds-ink);
  margin-bottom: var(--ds-space-2);
}

.ds-callout__icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: var(--ds-radius-xs);
  flex-shrink: 0;
}

.ds-callout--note .ds-callout__icon { color: var(--ds-info); }
.ds-callout--tip .ds-callout__icon { color: var(--ds-success); }
.ds-callout--warning .ds-callout__icon,
.ds-callout--mistake .ds-callout__icon { color: var(--ds-warning); }
.ds-callout--danger .ds-callout__icon { color: var(--ds-danger); }

.ds-callout__body {
  font-size: var(--ds-text-base);
  line-height: 1.62;
  color: var(--ds-ink-prose);
}

.ds-callout__body p + p {
  margin-top: var(--ds-space-2);
}

/* ── 4. Diagram Frame & Flagship Video Stage ────────────────────────────── */
.ds-diagram-frame {
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
  overflow: hidden;
  margin: var(--ds-space-6) 0;
  max-width: 100%;
}

.ds-diagram-frame__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ds-space-3);
  padding: var(--ds-space-2) var(--ds-space-4);
  background: var(--ds-canvas);
  border-bottom: 1px solid var(--ds-border);
  font-size: var(--ds-text-xs);
  color: var(--ds-ink-muted);
}

.ds-diagram-frame__body {
  padding: var(--ds-space-5);
  overflow-x: auto;
  display: flex;
  justify-content: center;
  align-items: center;
}

.ds-diagram-frame__body svg {
  max-width: 100%;
  height: auto;
}

.ds-diagram-frame__caption {
  padding: var(--ds-space-2) var(--ds-space-4);
  border-top: 1px solid var(--ds-divider);
  font-size: var(--ds-text-xs);
  color: var(--ds-ink-muted);
  background: var(--ds-canvas);
}

/* Flagship Original Video Player Card */
.ds-video-stage {
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
  overflow: hidden;
  margin: var(--ds-space-6) 0;
}

.ds-video-stage__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ds-space-3);
  padding: var(--ds-space-3) var(--ds-space-4);
  border-bottom: 1px solid var(--ds-border);
  background: var(--ds-canvas);
}

.ds-video-stage__title {
  display: flex;
  align-items: center;
  gap: var(--ds-space-2);
  font-size: var(--ds-text-sm);
  font-weight: 600;
  color: var(--ds-ink);
}

.ds-video-stage__player {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0B0E14;
}

.ds-video-stage__player video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.ds-video-stage__transcript {
  border-top: 1px solid var(--ds-border);
  font-size: var(--ds-text-sm);
  color: var(--ds-ink-muted);
}

.ds-video-stage__transcript summary {
  padding: var(--ds-space-2) var(--ds-space-4);
  cursor: pointer;
  font-size: var(--ds-text-xs);
  font-weight: 500;
  color: var(--ds-ink-muted);
  user-select: none;
}

.ds-video-stage__transcript summary:hover {
  color: var(--ds-ink);
  background: var(--ds-surface-hover);
}

.ds-video-stage__transcript-body {
  padding: var(--ds-space-3) var(--ds-space-4) var(--ds-space-4);
  line-height: 1.6;
  color: var(--ds-ink-prose);
  border-top: 1px solid var(--ds-divider);
}

/* Secondary Curated External Lecture Disclosure */
.ds-external-lecture {
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-md);
  background: var(--ds-surface);
  margin: var(--ds-space-4) 0;
}

.ds-external-lecture summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ds-space-3);
  padding: var(--ds-space-3) var(--ds-space-4);
  cursor: pointer;
  list-style: none;
  font-size: var(--ds-text-sm);
  color: var(--ds-ink);
}

.ds-external-lecture summary::-webkit-details-marker {
  display: none;
}

/* ── 5. Code Block Line Highlighting & Filename Bar ─────────────────────── */
.code-line {
  display: block;
  padding: 0 var(--ds-space-2);
  margin: 0 calc(-1 * var(--ds-space-2));
  border-radius: 3px;
}

.code-line--highlight {
  background: var(--brand-accent-soft);
}

/* ── 6. Share Button & Toast Notification ───────────────────────────────── */
.ds-share-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: var(--ds-radius-sm);
  border: 1px solid var(--ds-border);
  background: var(--ds-surface);
  color: var(--ds-ink);
  font-size: var(--ds-text-xs);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--ds-dur-fast), border-color var(--ds-dur-fast);
}

.ds-share-btn:hover {
  background: var(--ds-surface-hover);
  border-color: var(--ds-border-strong);
}

.ds-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--ds-radius-md);
  background: var(--ds-ink);
  color: var(--ds-ink-inverse);
  font-size: var(--ds-text-sm);
  font-weight: 500;
  box-shadow: var(--ds-shadow-overlay);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity var(--ds-dur-base) var(--ds-ease-out), transform var(--ds-dur-base) var(--ds-ease-out);
}

.ds-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── 7. Product-Family Site Footer ──────────────────────────────────────── */
.ds-footer {
  margin-top: var(--ds-space-16);
  padding: var(--ds-space-10) var(--ds-space-6) var(--ds-space-8);
  border-top: 1px solid var(--ds-border);
  background: var(--ds-canvas);
  color: var(--ds-ink-muted);
  font-size: var(--ds-text-sm);
}

.ds-footer__inner {
  max-width: var(--ds-shell-max);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "family links"
    "meta meta";
  align-items: center;
  gap: var(--ds-space-6) var(--ds-space-8);
}

.ds-footer__family {
  grid-area: family;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.ds-footer__label {
  width: 100%;
  margin-bottom: 4px;
  font-family: var(--ds-font-mono, var(--font-mono));
  font-size: var(--ds-text-2xs);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ds-ink-faint);
}

.ds-footer__product {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 12px;
  font-size: var(--ds-text-sm);
  font-weight: 500;
  color: var(--ds-ink-muted);
  border: 1px solid var(--ds-border);
  border-radius: 999px;
  white-space: nowrap;
  transition: color var(--ds-dur-fast), border-color var(--ds-dur-fast), background var(--ds-dur-fast);
}

.ds-footer__product:hover {
  color: var(--ds-ink);
  border-color: var(--ds-border-strong);
}

.ds-footer__product.is-current {
  color: var(--ds-ink);
  background: var(--ds-surface);
  border-color: var(--ds-border-strong);
}

.ds-footer__inner > .ds-footer__links {
  grid-area: links;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px 20px;
}

.ds-footer__meta {
  grid-area: meta;
  padding-top: var(--ds-space-4);
  border-top: 1px solid var(--ds-divider);
  font-size: var(--ds-text-xs);
  line-height: 1.6;
  color: var(--ds-ink-faint);
}

.ds-footer__meta a {
  color: var(--ds-ink-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ds-footer__meta a:hover {
  color: var(--ds-ink);
}

@media (max-width: 820px) {
  .ds-footer__inner {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "family"
      "links"
      "meta";
    gap: var(--ds-space-5);
  }
  .ds-footer__inner > .ds-footer__links {
    justify-content: flex-start;
  }
}

.ds-footer__brand {
  font-weight: 600;
  color: var(--ds-ink);
  font-size: var(--ds-text-base);
  margin-bottom: var(--ds-space-2);
}

.ds-footer__desc {
  color: var(--ds-ink-muted);
  line-height: 1.55;
  max-width: 44ch;
}

.ds-footer__col-title {
  font-size: var(--ds-text-xs);
  font-weight: 600;
  color: var(--ds-ink);
  margin-bottom: var(--ds-space-3);
}

.ds-footer__links {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ds-footer__links a {
  color: var(--ds-ink-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  transition: color var(--ds-dur-fast);
}

.ds-footer__links a:hover {
  color: var(--brand-accent);
}

.ds-footer__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ds-footer__bottom {
  max-width: var(--ds-shell-max);
  margin: var(--ds-space-8) auto 0;
  padding-top: var(--ds-space-4);
  border-top: 1px solid var(--ds-divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--ds-space-3);
  font-size: var(--ds-text-xs);
  color: var(--ds-ink-faint);
}
