---
title: "Course Detail · UI SDK — StyleX Blocks"
description: "Interactive course overview page featuring breadcrumb navigation, tabbed Syllabus, Outcomes, Instructor, and Reviews views, a checkable 4-module curriculum accordion synced to live progress bars, and a sticky enrollment rail with a photographic course cover, self-paced vs. cohort planning, and toast feedback."
url: "https://stylexblocks.com/block/ui-sdk/course-detail/"
agent:
  instructions: "Use this search API to find relevant components and blocks across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://stylexblocks.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Course Detail block

Interactive course overview page featuring breadcrumb navigation, tabbed Syllabus, Outcomes, Instructor, and Reviews views, a checkable 4-module curriculum accordion synced to live progress bars, and a sticky enrollment rail with a photographic course cover, self-paced vs. cohort planning, and toast feedback.

- Behavior engine: UI SDK
- Category: [Content](https://stylexblocks.com/blocks/content.md)
- Built with: [Accordion](https://stylexblocks.com/components/ui-sdk/accordion.md), [Aspect Ratio](https://stylexblocks.com/components/ui-sdk/aspect-ratio.md), [Avatar](https://stylexblocks.com/components/ui-sdk/avatar.md), [Badge](https://stylexblocks.com/components/ui-sdk/badge.md), [Breadcrumb](https://stylexblocks.com/components/ui-sdk/breadcrumb.md), [Button](https://stylexblocks.com/components/ui-sdk/button.md), [Card](https://stylexblocks.com/components/ui-sdk/card.md), [Checkbox](https://stylexblocks.com/components/ui-sdk/checkbox.md), [Grid](https://stylexblocks.com/components/ui-sdk/grid.md), [Heading](https://stylexblocks.com/components/ui-sdk/heading.md), [Icon](https://stylexblocks.com/components/ui-sdk/icon.md), [Progress](https://stylexblocks.com/components/ui-sdk/progress.md), [Radio Card](https://stylexblocks.com/components/ui-sdk/radio-card.md), [Rating Group](https://stylexblocks.com/components/ui-sdk/rating-group.md), [Section](https://stylexblocks.com/components/ui-sdk/section.md), [Segment Group](https://stylexblocks.com/components/ui-sdk/segment-group.md), [Separator](https://stylexblocks.com/components/ui-sdk/separator.md), [Slider](https://stylexblocks.com/components/ui-sdk/slider.md), [Stack](https://stylexblocks.com/components/ui-sdk/stack.md), [Tabs](https://stylexblocks.com/components/ui-sdk/tabs.md), [Tag](https://stylexblocks.com/components/ui-sdk/tag.md), [Text](https://stylexblocks.com/components/ui-sdk/text.md), [Toast](https://stylexblocks.com/components/ui-sdk/toast.md)
- HTML page: https://stylexblocks.com/block/ui-sdk/course-detail/

## Install

Configure the project once (sets the behavior engine and import aliases):

```sh
npx stylexblocks init --style ui-sdk
```

Then add the item as source you own:

```sh
npx stylexblocks add course-detail
```

Equivalent: `npx shadcn add @stylexblocks/course-detail`. Registry item JSON: https://stylexblocks.com/r/ui-sdk/course-detail.json

## Usage

```tsx
import { CourseDetail } from "#components/blocks/ui-sdk/course-detail.tsx";

export function Example() {
  return (
    <div style={{ minHeight: "100dvh" }}>
      <CourseDetail />
    </div>
  );
}
```

## Source

`components/blocks/ui-sdk/course-detail.tsx`

```tsx
import * as stylex from "@stylexjs/stylex";
import { useCallback, useMemo, useState } from "react";
import { Accordion } from "#components/ui/ui-sdk/accordion.tsx";
import { AspectRatio } from "#components/ui/ui-sdk/aspect-ratio.tsx";
import { Avatar } from "#components/ui/ui-sdk/avatar.tsx";
import { Badge } from "#components/ui/ui-sdk/badge.tsx";
import { Breadcrumb } from "#components/ui/ui-sdk/breadcrumb.tsx";
import { Button } from "#components/ui/ui-sdk/button.tsx";
import { Card } from "#components/ui/ui-sdk/card.tsx";
import { Checkbox } from "#components/ui/ui-sdk/checkbox.tsx";
import { Grid } from "#components/ui/ui-sdk/grid.tsx";
import { Heading } from "#components/ui/ui-sdk/heading.tsx";
import { Icon } from "#components/ui/ui-sdk/icon.tsx";
import { Progress } from "#components/ui/ui-sdk/progress.tsx";
import { RadioCard } from "#components/ui/ui-sdk/radio-card.tsx";
import { RatingGroup } from "#components/ui/ui-sdk/rating-group.tsx";
import { Section } from "#components/ui/ui-sdk/section.tsx";
import { SegmentGroup } from "#components/ui/ui-sdk/segment-group.tsx";
import { Separator } from "#components/ui/ui-sdk/separator.tsx";
import { Slider } from "#components/ui/ui-sdk/slider.tsx";
import { HStack, VStack } from "#components/ui/ui-sdk/stack.tsx";
import { Tabs } from "#components/ui/ui-sdk/tabs.tsx";
import { Tag } from "#components/ui/ui-sdk/tag.tsx";
import { Text } from "#components/ui/ui-sdk/text.tsx";
import { Toast, Toaster } from "#components/ui/ui-sdk/toast.tsx";
import { semanticColors } from "@stylexblocks/ui/semantic-tokens/colors.stylex.ts";
import { semanticRadii } from "@stylexblocks/ui/semantic-tokens/radii.stylex.ts";
import { semanticShadows } from "@stylexblocks/ui/semantic-tokens/shadows.stylex.ts";
import {
  accentPalette,
  amberPalette,
  emeraldPalette,
  indigoPalette,
  rosePalette,
  tealPalette,
} from "@stylexblocks/ui/themes/palettes.ts";
import { durations } from "@stylexblocks/ui/tokens/durations.stylex.ts";
import { fontSizes } from "@stylexblocks/ui/tokens/font-sizes.stylex.ts";
import { fontWeights } from "@stylexblocks/ui/tokens/font-weights.stylex.ts";
import { fonts } from "@stylexblocks/ui/tokens/fonts.stylex.ts";
import { lineHeights } from "@stylexblocks/ui/tokens/line-heights.stylex.ts";
import { radii } from "@stylexblocks/ui/tokens/radii.stylex.ts";
import { spacing } from "@stylexblocks/ui/tokens/spacing.stylex.ts";
import type { StyleOverrideProps } from "#lib/recipe-props.ts";

// ---------------------------------------------------------------------------
// Types
// ---------------------------------------------------------------------------

export interface CourseLesson {
  id: string;
  title: string;
  duration: string;
  preview?: boolean;
}

export interface CourseModule {
  id: string;
  title: string;
  summary: string;
  duration: string;
  lessons: readonly CourseLesson[];
}

export interface CourseReview {
  id: string;
  author: string;
  initials: string;
  role: string;
  date: string;
  rating: number;
  body: string;
  helpful: number;
  paletteKey: "indigo" | "emerald" | "amber" | "teal";
}

export interface CourseCohort {
  id: string;
  label: string;
  detail: string;
}

export interface CourseDetailProps extends StyleOverrideProps {
  /** Course headline displayed in the page header. */
  title?: string;
  /** Concise value proposition under the headline. */
  subtitle?: string;
  /** Price in USD for one-time enrollment. */
  price?: number;
  /** Original comparison price in USD. */
  compareAtPrice?: number;
  /** Curriculum modules with checkable lessons. */
  modules?: readonly CourseModule[];
  /** Lesson IDs pre-marked as complete on mount. */
  initialCompletedLessonIds?: readonly string[];
  /** Called when the learner clicks the primary enroll CTA. */
  onEnroll?: (payload: { mode: "self-paced" | "cohort"; paceHours: number; cohortId: string }) => void;
  /** Called when the learner launches the free lesson preview. */
  onPreviewLesson?: (lesson: CourseLesson) => void;
}

// ---------------------------------------------------------------------------
// Demo data — Design Systems Architecture with Atomic CSS & Accessibility
// ---------------------------------------------------------------------------

const COURSE_META = {
  title: "Design Systems Architecture with Atomic CSS & Accessibility",
  subtitle:
    "Engineer a zero-runtime, multi-brand component library from first principles — compile-time atomic stylesheets, perceptual OKLCH semantic tokens, accessible headless primitives, and automated CI regression gates.",
  level: "Advanced",
  language: "English · Captions",
  rating: 4.9,
  reviewCount: 1420,
  learnerCount: "9,640",
  runtime: "6h 24m",
  price: 119,
  compareAtPrice: 169,
  skills: [
    "Atomic CSS compilation",
    "Semantic token layers",
    "WAI-ARIA state machines",
    "Keyboard & focus ergonomics",
    "Multi-brand theming",
    "Automated a11y CI gates",
  ],
};

const DEFAULT_MODULES: readonly CourseModule[] = [
  {
    id: "atomic-css",
    title: "Module 1 · Atomic CSS & Compile-Time Architecture",
    summary: "Deterministic styling, static extraction, and bundle ceilings.",
    duration: "1h 42m",
    lessons: [
      {
        id: "l-1",
        title: "Why atomic CSS plateaus in bundle size at enterprise scale",
        duration: "18 min",
        preview: true,
      },
      {
        id: "l-2",
        title: "Deterministic cascade resolution and banning CSS shorthands",
        duration: "26 min",
        preview: true,
      },
      {
        id: "l-3",
        title: "Static build extraction, dead-style elimination, and budgets",
        duration: "30 min",
      },
      {
        id: "l-4",
        title: "Lab: Type-safe recipe composition with explicit style overrides",
        duration: "28 min",
      },
    ],
  },
  {
    id: "semantic-tokens",
    title: "Module 2 · Semantic Tokens & Multi-Brand Theming",
    summary: "OKLCH perceptual ramps, light-dark(), and subtree palettes.",
    duration: "1h 24m",
    lessons: [
      {
        id: "l-5",
        title: "Separating primitive, semantic, and component token contracts",
        duration: "24 min",
      },
      {
        id: "l-6",
        title: "Perceptual OKLCH color spaces and automatic light-dark() contrast",
        duration: "32 min",
      },
      {
        id: "l-7",
        title: "Scoped palette overrides without React context re-renders",
        duration: "28 min",
      },
    ],
  },
  {
    id: "accessible-primitives",
    title: "Module 3 · Accessible Headless Primitives & ARIA",
    summary: "Focus management, keyboard matrices, and assistive tech audits.",
    duration: "1h 58m",
    lessons: [
      {
        id: "l-8",
        title: "Roving tabindex, focus trapping, and modal focus restoration",
        duration: "34 min",
      },
      {
        id: "l-9",
        title: "Composite widgets: tabs, accordions, sliders, and radio cards",
        duration: "30 min",
      },
      {
        id: "l-10",
        title: "Live regions, screen reader ergonomics, and reduced motion",
        duration: "26 min",
      },
      {
        id: "l-11",
        title: "Lab: End-to-end VoiceOver and NVDA audit walkthrough",
        duration: "28 min",
      },
    ],
  },
  {
    id: "governance-scale",
    title: "Module 4 · Governance, CI Gates & Capstone Kit",
    summary: "Automated accessibility assertions, codemods, and release policy.",
    duration: "1h 20m",
    lessons: [
      {
        id: "l-12",
        title: "Automated keyboard contracts and axe-core checks in CI",
        duration: "26 min",
      },
      {
        id: "l-13",
        title: "Versioning token schemas and writing migration codemods",
        duration: "28 min",
      },
      {
        id: "l-14",
        title: "Capstone: Publish a multi-brand accessible UI kit",
        duration: "26 min",
      },
    ],
  },
];

const OUTCOMES = [
  {
    title: "Zero-runtime atomic stylesheet pipeline",
    detail:
      "Configure compile-time style extraction with strict specificity guarantees and predictable bundle ceilings.",
  },
  {
    title: "WCAG 2.2 AA/AAA contrast by construction",
    detail:
      "Author semantic OKLCH token pairs using light-dark() so themes remain legible across light, dark, and high-contrast modes.",
  },
  {
    title: "Composable headless component contracts",
    detail:
      "Build multi-slot primitives with keyboard roving focus, ARIA ownership, and render-prop composition.",
  },
  {
    title: "Multi-brand subtree theming",
    detail:
      "Swap brand palettes and density factors locally with CSS custom property themes and zero React re-renders.",
  },
  {
    title: "Assistive technology verification workflow",
    detail:
      "Run repeatable screen reader checks alongside automated keyboard and axe-core assertions in pull requests.",
  },
  {
    title: "Safe migration and release governance",
    detail:
      "Ship token deprecations and recipe changes across dozens of consuming apps using AST codemods.",
  },
] as const;

const PREREQUISITES = [
  "Comfortable writing TypeScript and modern React components (hooks and compound patterns).",
  "Working familiarity with CSS custom properties, Flexbox, and CSS Grid.",
  "No prior screen-reader testing or compiler plugin experience required — both are taught from scratch.",
] as const;

const INSTRUCTOR = {
  name: "Dr. Soren Halvorsen",
  initials: "SH",
  role: "Principal Design Systems Architect · Nordic Foundry",
  learners: "24,800",
  courses: "5",
  rating: "4.9",
  bio: "Dr. Soren Halvorsen has spent eleven years designing compile-time CSS architectures and accessible component libraries across web and desktop product suites. After completing his PhD in Human-Computer Interaction at NTNU, he led core UI platform teams supporting over 300 engineers and now advises organizations on multi-brand design system governance.",
  focusAreas: [
    "Compile-time Atomic CSS",
    "WCAG 2.2 AA/AAA Audits",
    "Semantic Token Governance",
    "Headless State Machines",
  ],
};

const RATING_ASPECTS = [
  { label: "Architecture depth", score: 4.9 },
  { label: "Accessibility rigor", score: 5.0 },
  { label: "Hands-on labs", score: 4.8 },
  { label: "Instructor clarity", score: 4.9 },
  { label: "Token & theming tooling", score: 4.8 },
  { label: "Capstone review feedback", score: 4.7 },
] as const;

const REVIEWS: readonly CourseReview[] = [
  {
    id: "rev-1",
    author: "Maren Lindqvist",
    initials: "ML",
    role: "Staff Frontend Engineer",
    date: "Reviewed 1 week ago",
    rating: 5,
    body: "The semantic token architecture and OKLCH contrast lessons paid for the course in one afternoon. We cut our product CSS bundle by 68% and fixed three persistent dark-mode contrast bugs immediately.",
    helpful: 46,
    paletteKey: "indigo",
  },
  {
    id: "rev-2",
    author: "Devon Okafor",
    initials: "DO",
    role: "Design Technologist",
    date: "Reviewed 3 weeks ago",
    rating: 5,
    body: "Soren demystifies roving tabindex and composite ARIA patterns better than any spec guide I have read. The VoiceOver lab caught focus-restoration edge cases our team had shipped for years.",
    helpful: 34,
    paletteKey: "emerald",
  },
  {
    id: "rev-3",
    author: "Kenji Takahashi",
    initials: "KT",
    role: "Principal UI Engineer",
    date: "Reviewed 2 months ago",
    rating: 5,
    body: "Every module builds directly toward the capstone library. The codemod and CI gate chapter turned our design system upgrades from a quarterly firefight into an automated PR.",
    helpful: 29,
    paletteKey: "teal",
  },
  {
    id: "rev-4",
    author: "Camille Laurent",
    initials: "CL",
    role: "Accessibility Lead",
    date: "Reviewed 2 months ago",
    rating: 4,
    body: "Refreshingly opinionated and grounded in real browser behavior. I would have loved one extra lab on data-grid virtualization, though the coverage of tabs, accordions, and dialogs is stellar.",
    helpful: 18,
    paletteKey: "amber",
  },
];

const FAQS = [
  {
    id: "faq-framework",
    q: "Are the concepts tied to a single CSS library?",
    a: "No. While the hands-on labs use compile-time atomic CSS and CSS custom property themes, every token layer, ARIA state machine, and CI testing contract transfers cleanly to any modern React stack.",
  },
  {
    id: "faq-access",
    q: "How long do I keep access to the lessons and labs?",
    a: "Enrollment includes lifetime access to all 14 lessons, downloadable starter repositories, accessibility audit checklists, and every future curriculum update.",
  },
  {
    id: "faq-cohort",
    q: "What is the difference between self-paced and live cohort?",
    a: "Both options include the full video curriculum and capstone rubric. Live cohorts add weekly office hours, architecture critiques with Dr. Halvorsen, and peer PR reviews.",
  },
  {
    id: "faq-guarantee",
    q: "Is there a refund policy or team license?",
    a: "Every seat includes a 30-day no-questions-asked refund guarantee. Team licenses with shared capstone reviews are available directly from your enrollment receipt.",
  },
] as const;

const COHORTS: readonly CourseCohort[] = [
  {
    id: "jan-2027",
    label: "Cohort of Jan 11",
    detail: "Live critiques · 9 seats left",
  },
  {
    id: "feb-2027",
    label: "Cohort of Feb 8",
    detail: "Live critiques · 4 seats left",
  },
];

const COURSE_INCLUDES = [
  "Lifetime access to 14 lessons & starter labs",
  "Reviewed multi-brand capstone architecture",
  "WCAG 2.2 keyboard & screen reader checklists",
  "Verified certificate of completion",
] as const;

// Fixed reference date keeps estimated completion deterministic across SSR and client.
const COHORT_REFERENCE_DATE = new Date("2026-12-07T00:00:00Z");
const ESTIMATED_STUDY_HOURS = 36;
const PACE_MIN = 2;
const PACE_MAX = 12;

function formatUsd(amount: number) {
  return `$${amount.toFixed(0)}`;
}

function estimateFinish(hoursPerWeek: number) {
  const weeks = Math.max(1, Math.ceil(ESTIMATED_STUDY_HOURS / hoursPerWeek));
  const target = new Date(COHORT_REFERENCE_DATE);
  target.setUTCDate(target.getUTCDate() + weeks * 7);
  const formattedDate = target.toLocaleDateString("en-US", {
    month: "short",
    day: "numeric",
    timeZone: "UTC",
  });
  return `${weeks} ${weeks === 1 ? "week" : "weeks"} · finish around ${formattedDate}`;
}

const REVIEW_PALETTES = {
  indigo: indigoPalette,
  emerald: emeraldPalette,
  amber: amberPalette,
  teal: tealPalette,
} as const;

// ---------------------------------------------------------------------------
// Crisp inline SVG icons (zero external icon packages)
// ---------------------------------------------------------------------------

function ChevronDownIcon() {
  return (
    <Icon
      size="sm"
      viewBox="0 0 16 16"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.6"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <path d="M4 6l4 4 4-4" />
    </Icon>
  );
}

function ChevronRightIcon() {
  return (
    <Icon
      size="xs"
      viewBox="0 0 16 16"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.6"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <path d="M6 4l4 4-4 4" />
    </Icon>
  );
}

function ArrowRightIcon() {
  return (
    <Icon
      size="sm"
      viewBox="0 0 20 20"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.75"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <path d="M4.5 10h11" />
      <path d="M11 5.5 15.5 10 11 14.5" />
    </Icon>
  );
}

function PlayIcon() {
  return (
    <Icon
      size="sm"
      viewBox="0 0 20 20"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.6"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <path d="M7 5.2 15.2 10 7 14.8V5.2Z" />
    </Icon>
  );
}

function ClockIcon() {
  return (
    <Icon
      size="sm"
      viewBox="0 0 20 20"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.5"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <circle cx="10" cy="10" r="7.25" />
      <path d="M10 6.2V10l2.6 1.6" />
    </Icon>
  );
}

function BookOpenIcon() {
  return (
    <Icon
      size="sm"
      viewBox="0 0 20 20"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.5"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <path d="M3 5.2c1.8-.6 4.4-.5 7 .8 2.6-1.3 5.2-1.4 7-.8v9.8c-1.8-.6-4.4-.5-7 .8-2.6-1.3-5.2-1.4-7-.8V5.2Z" />
      <path d="M10 6v9.8" />
    </Icon>
  );
}

function GlobeIcon() {
  return (
    <Icon
      size="sm"
      viewBox="0 0 20 20"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.5"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <circle cx="10" cy="10" r="7.25" />
      <path d="M2.8 10h14.4" />
      <path d="M10 2.75c2.2 2.1 3.3 4.6 3.3 7.25s-1.1 5.15-3.3 7.25c-2.2-2.1-3.3-4.6-3.3-7.25S7.8 4.85 10 2.75Z" />
    </Icon>
  );
}

function UsersIcon() {
  return (
    <Icon
      size="sm"
      viewBox="0 0 20 20"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.5"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <circle cx="7.5" cy="7.2" r="2.7" />
      <path d="M2.8 15.8c.5-2.4 2.4-3.8 4.7-3.8s4.2 1.4 4.7 3.8" />
      <circle cx="13.8" cy="7.8" r="2.1" />
      <path d="M13.5 12.2c1.8.2 3.2 1.4 3.7 3.6" />
    </Icon>
  );
}

function CheckIcon() {
  return (
    <Icon
      size="sm"
      viewBox="0 0 20 20"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.75"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <path d="M4.5 10.4 8.2 14l7.3-8" />
    </Icon>
  );
}

function SparklesIcon() {
  return (
    <Icon
      size="sm"
      viewBox="0 0 20 20"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.5"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <path d="M10 3.2 11.4 7.6 15.8 9l-4.4 1.4L10 14.8l-1.4-4.4L4.2 9l4.4-1.4L10 3.2Z" />
      <path d="M15.4 13.4 16 15.2l1.8.6-1.8.6-.6 1.8-.6-1.8-1.8-.6 1.8-.6.6-1.8Z" />
    </Icon>
  );
}

function ThumbUpIcon() {
  return (
    <Icon
      size="xs"
      viewBox="0 0 16 16"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.5"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <path d="M5.2 7.2 7.8 2.5a1.3 1.3 0 0 1 2.4.7v2.6h2.7a1.3 1.3 0 0 1 1.3 1.6l-.8 4.4a1.6 1.6 0 0 1-1.6 1.3H5.2V7.2Z" />
      <path d="M2.2 7.2h3v5.9h-3a.6.6 0 0 1-.6-.6V7.8a.6.6 0 0 1 .6-.6Z" />
    </Icon>
  );
}

// ---------------------------------------------------------------------------
// Styles
// ---------------------------------------------------------------------------

const styles = stylex.create({
  root: {
    backgroundColor: semanticColors.bg,
    color: semanticColors.fg,
    fontFamily: fonts.body,
    minHeight: "100%",
    paddingBlock: {
      default: spacing._8,
      "@media (max-width: 640px)": spacing._5,
    },
    paddingInline: {
      default: spacing._6,
      "@media (max-width: 640px)": spacing._4,
    },
    width: "100%",
  },
  container: {
    marginInline: "auto",
    maxWidth: "75rem",
    width: "100%",
  },
  layoutGrid: {
    gap: {
      default: spacing._8,
      "@media (max-width: 960px)": spacing._6,
    },
    gridTemplateColumns: {
      default: "minmax(0, 1fr) 23.5rem",
      "@media (max-width: 960px)": "minmax(0, 1fr)",
    },
  },
  railColumn: {
    position: {
      default: "sticky",
      "@media (max-width: 960px)": "static",
    },
    top: spacing._6,
  },
  headingReset: {
    marginBlock: 0,
  },
  title: {
    marginBlock: 0,
    maxWidth: "28ch",
    textWrap: "balance",
  },
  subtitle: {
    lineHeight: lineHeights.lg,
    maxWidth: "66ch",
  },
  pt1: {
    paddingTop: spacing._1,
  },
  factItem: {
    color: semanticColors.fgMuted,
    fontSize: fontSizes.sm,
  },
  flexFill: {
    flex: 1,
    minWidth: 0,
  },
  shrink0: {
    flexShrink: 0,
  },
  fullWidth: {
    width: "100%",
  },
  leadingXs: {
    lineHeight: lineHeights.xs,
  },
  leadingSm: {
    lineHeight: lineHeights.sm,
  },
  leadingMd: {
    lineHeight: lineHeights.md,
  },
  leadingLg: {
    lineHeight: lineHeights.lg,
  },
  lineThrough: {
    textDecoration: "line-through",
  },
  plainList: {
    listStyle: "none",
    marginBlock: 0,
    marginInline: 0,
    paddingBlock: 0,
    paddingInline: 0,
  },
  tabsListWrap: {
    borderBottomColor: semanticColors.border,
    borderBottomStyle: "solid",
    borderBottomWidth: "1px",
    overflowX: "auto",
  },
  tabPanel: {
    paddingBlock: spacing._5,
    paddingInline: 0,
  },
  progressPercent: {
    minWidth: "2.5rem",
  },
  moduleAccordion: {
    borderColor: semanticColors.border,
    borderRadius: semanticRadii.panel,
    borderStyle: "solid",
    borderWidth: "1px",
    overflow: "hidden",
  },
  moduleItem: {
    borderBottomColor: semanticColors.border,
    borderBottomStyle: "solid",
    borderBottomWidth: {
      default: "1px",
      ":last-child": 0,
    },
  },
  moduleTrigger: {
    backgroundColor: {
      default: semanticColors.bgPanel,
      ":hover": semanticColors.bgSubtle,
    },
    paddingBlock: spacing._3_5,
    paddingInline: spacing._4,
    transitionDuration: durations.moderate,
    transitionProperty: "background-color",
  },
  moduleBody: {
    backgroundColor: semanticColors.bg,
    borderTopColor: semanticColors.borderMuted,
    borderTopStyle: "solid",
    borderTopWidth: "1px",
    paddingBlock: spacing._2,
    paddingInline: spacing._4,
  },
  lessonRow: {
    borderRadius: semanticRadii.control,
    paddingBlock: spacing._2,
    paddingInline: spacing._2,
    transitionDuration: durations.moderate,
    transitionProperty: "background-color",
    backgroundColor: {
      default: "transparent",
      ":hover": semanticColors.bgSubtle,
    },
  },
  lessonCheckboxRoot: {
    alignItems: "center",
    flex: 1,
    minWidth: 0,
  },
  lessonLabelCompleted: {
    color: semanticColors.fgMuted,
    textDecoration: "line-through",
  },
  lessonLabelActive: {
    color: semanticColors.fg,
    fontWeight: fontWeights.normal,
  },
  lessonDuration: {
    minWidth: "3.25rem",
  },
  sectionStack: {
    gap: spacing._4,
  },
  responsiveTwoCol: {
    gridTemplateColumns: {
      default: "repeat(2, minmax(0, 1fr))",
      "@media (max-width: 640px)": "minmax(0, 1fr)",
    },
  },
  outcomeIcon: {
    color: semanticColors.fgSuccess,
    flexShrink: 0,
    marginTop: "2px",
  },
  prereqBullet: {
    color: semanticColors.accentFg,
    flexShrink: 0,
    marginTop: "2px",
  },
  faqBody: {
    color: semanticColors.fgMuted,
    fontSize: fontSizes.sm,
    lineHeight: lineHeights.md,
  },
  reviewSummaryGrid: {
    gridTemplateColumns: {
      default: "10rem minmax(0, 1fr)",
      "@media (max-width: 640px)": "minmax(0, 1fr)",
    },
  },
  scoreDisplay: {
    fontFamily: fonts.heading,
    fontSize: fontSizes._5xl,
    fontWeight: fontWeights.semibold,
    lineHeight: 1,
  },
  enrollCard: {
    overflow: "hidden",
  },
  coverStage: {
    backgroundColor: semanticColors.bgMuted,
    borderBottomColor: semanticColors.border,
    borderBottomStyle: "solid",
    borderBottomWidth: "1px",
  },
  coverImage: {
    display: "block",
    height: "100%",
    objectFit: "cover",
    width: "100%",
  },
  coverOverlay: {
    backgroundImage:
      "linear-gradient(180deg, transparent 42%, rgba(9, 13, 24, 0.78) 100%)",
    bottom: 0,
    left: 0,
    paddingBlock: spacing._3,
    paddingInline: spacing._3_5,
    position: "absolute",
    right: 0,
    top: 0,
  },
  coverPreviewButton: {
    alignItems: "center",
    backgroundColor: {
      default: "rgba(15, 23, 42, 0.84)",
      ":hover": "rgba(15, 23, 42, 0.96)",
    },
    borderColor: "rgba(255, 255, 255, 0.28)",
    borderRadius: radii.full,
    borderStyle: "solid",
    borderWidth: "1px",
    boxShadow: semanticShadows.sm,
    color: "#ffffff",
    cursor: "pointer",
    display: "inline-flex",
    fontFamily: fonts.body,
    fontSize: fontSizes.xs,
    fontWeight: fontWeights.medium,
    gap: spacing._1_5,
    paddingBlock: spacing._1_5,
    paddingInline: spacing._3,
    transitionDuration: durations.moderate,
    transitionProperty: "background-color, border-color",
  },
  priceCurrent: {
    fontFamily: fonts.heading,
    fontSize: fontSizes._3xl,
    fontWeight: fontWeights.semibold,
    lineHeight: 1.1,
  },
  railProgressBox: {
    backgroundColor: semanticColors.bgMuted,
    borderColor: semanticColors.border,
    borderRadius: semanticRadii.control,
    borderStyle: "solid",
    borderWidth: "1px",
    paddingBlock: spacing._3,
    paddingInline: spacing._3,
  },
  segmentFull: {
    display: "grid",
    gridTemplateColumns: "1fr 1fr",
    width: "100%",
  },
  segmentItemCenter: {
    justifyContent: "center",
  },
  includesIcon: {
    color: semanticColors.fgSuccess,
    flexShrink: 0,
    marginTop: "1px",
  },
});

// ---------------------------------------------------------------------------
// Component
// ---------------------------------------------------------------------------

/**
 * CourseDetail — full course overview and interactive learning page combining
 * breadcrumb navigation, course header metrics, tabbed Syllabus / Outcomes /
 * Instructor / Reviews content, an interactive lesson-completion accordion
 * synced to a live Progress bar, and a sticky enrollment & preview rail with
 * a photographic course cover, self-paced vs. cohort planning, and toasts.
 */
export function CourseDetail({
  title = COURSE_META.title,
  subtitle = COURSE_META.subtitle,
  price = COURSE_META.price,
  compareAtPrice = COURSE_META.compareAtPrice,
  modules = DEFAULT_MODULES,
  initialCompletedLessonIds = ["l-1", "l-2"],
  onEnroll,
  onPreviewLesson,
  palette,
  style,
}: CourseDetailProps) {
  const queue = useMemo(() => Toast.createToaster(), []);

  const [activeTab, setActiveTab] = useState<string>("syllabus");
  const [openModules, setOpenModules] = useState<string[]>(() =>
    modules.slice(0, 2).map((mod) => mod.id),
  );
  const [completedIds, setCompletedIds] = useState<string[]>(() => [
    ...initialCompletedLessonIds,
  ]);
  const [enrolled, setEnrolled] = useState(false);
  const [followingInstructor, setFollowingInstructor] = useState(false);
  const [startMode, setStartMode] = useState<"self-paced" | "cohort">("self-paced");
  const [weeklyPace, setWeeklyPace] = useState<number>(6);
  const [selectedCohort, setSelectedCohort] = useState<string>(COHORTS[0]!.id);
  const [helpfulVotes, setHelpfulVotes] = useState<Record<string, boolean>>({});

  const allLessons = useMemo(
    () => modules.flatMap((mod) => mod.lessons),
    [modules],
  );
  const totalLessons = allLessons.length;
  const completedSet = useMemo(() => new Set(completedIds), [completedIds]);
  const completedCount = useMemo(
    () => allLessons.filter((lesson) => completedSet.has(lesson.id)).length,
    [allLessons, completedSet],
  );
  const progressPercent =
    totalLessons > 0 ? Math.round((completedCount / totalLessons) * 100) : 0;

  const discountPercent =
    compareAtPrice > price
      ? Math.round(((compareAtPrice - price) / compareAtPrice) * 100)
      : 0;

  const allExpanded = openModules.length === modules.length;

  const handleToggleLesson = useCallback(
    (lesson: CourseLesson, mod: CourseModule, nextChecked: boolean) => {
      setCompletedIds((prev) => {
        const nextSet = new Set(prev);
        if (nextChecked) {
          nextSet.add(lesson.id);
        } else {
          nextSet.delete(lesson.id);
        }
        const nextList = Array.from(nextSet);

        if (nextChecked) {
          const moduleComplete = mod.lessons.every((item) => nextSet.has(item.id));
          const courseComplete = allLessons.every((item) => nextSet.has(item.id));
          if (courseComplete) {
            queue.success("All lessons completed", {
              description: "You are ready to submit your multi-brand capstone library.",
            });
          } else if (moduleComplete) {
            queue.success("Module completed", {
              description: `${mod.title} — ${mod.lessons.length} of ${mod.lessons.length} lessons done.`,
            });
          }
        }
        return nextList;
      });
    },
    [allLessons, queue],
  );

  const handleToggleExpandAll = useCallback(() => {
    setOpenModules((prev) =>
      prev.length === modules.length ? [] : modules.map((mod) => mod.id),
    );
  }, [modules]);

  const handleResetProgress = useCallback(() => {
    setCompletedIds([]);
    queue.info("Course progress reset", {
      description: "All lesson checkmarks have been cleared.",
    });
  }, [queue]);

  const handlePreview = useCallback(
    (lesson?: CourseLesson) => {
      const target = lesson ?? allLessons[0];
      if (!target) return;
      onPreviewLesson?.(target);
      setActiveTab("syllabus");
      const parentModule = modules.find((mod) =>
        mod.lessons.some((item) => item.id === target.id),
      );
      if (parentModule) {
        setOpenModules((prev) =>
          prev.includes(parentModule.id) ? prev : [...prev, parentModule.id],
        );
      }
      queue.info(`Previewing: ${target.title}`, {
        description: `${target.duration} free lesson preview opened.`,
      });
    },
    [allLessons, modules, onPreviewLesson, queue],
  );

  const handleEnroll = useCallback(() => {
    onEnroll?.({
      mode: startMode,
      paceHours: weeklyPace,
      cohortId: selectedCohort,
    });
    if (enrolled) {
      setActiveTab("syllabus");
      queue.info("Resuming your curriculum", {
        description: `${completedCount} of ${totalLessons} lessons completed (${progressPercent}%).`,
      });
      return;
    }
    setEnrolled(true);
    const cohortLabel =
      COHORTS.find((item) => item.id === selectedCohort)?.label ?? "Upcoming cohort";
    queue.success("Enrolled in Design Systems Architecture", {
      description:
        startMode === "self-paced"
          ? `Self-paced plan at ${weeklyPace} h/week — ${estimateFinish(weeklyPace)}.`
          : `Seat reserved for ${cohortLabel}.`,
    });
  }, [
    completedCount,
    enrolled,
    onEnroll,
    progressPercent,
    queue,
    selectedCohort,
    startMode,
    totalLessons,
    weeklyPace,
  ]);

  const handleToggleFollow = useCallback(() => {
    setFollowingInstructor((prev) => {
      const next = !prev;
      queue.info(
        next
          ? `Following ${INSTRUCTOR.name}`
          : `Unfollowed ${INSTRUCTOR.name}`,
        {
          description: next
            ? "You will be notified when new design systems labs are published."
            : "Instructor updates have been muted.",
        },
      );
      return next;
    });
  }, [queue]);

  const handleToggleHelpful = useCallback(
    (review: CourseReview) => {
      setHelpfulVotes((prev) => {
        const nextVoted = !prev[review.id];
        queue.info(
          nextVoted ? "Marked review as helpful" : "Removed helpful vote",
          {
            description: `${review.author}'s review count updated.`,
          },
        );
        return { ...prev, [review.id]: nextVoted };
      });
    },
    [queue],
  );

  const handleBreadcrumbClick = useCallback(
    (label: string) => (event: React.MouseEvent<HTMLAnchorElement>) => {
      event.preventDefault();
      queue.info(`Browsing ${label}`, {
        description: "Catalog filter navigation is simulated in this preview.",
      });
    },
    [queue],
  );

  return (
    <div {...stylex.props(palette, styles.root, style)}>
      <VStack gap="6" style={styles.container}>
        {/* Breadcrumb Navigation */}
        <Breadcrumb.Root aria-label="Breadcrumb" size="sm" variant="plain">
          <Breadcrumb.List>
            <Breadcrumb.Item>
              <Breadcrumb.Link
                href="#catalog"
                onClick={handleBreadcrumbClick("Course Catalog")}
              >
                Catalog
              </Breadcrumb.Link>
            </Breadcrumb.Item>
            <Breadcrumb.Separator aria-hidden="true">
              <ChevronRightIcon />
            </Breadcrumb.Separator>
            <Breadcrumb.Item>
              <Breadcrumb.Link
                href="#frontend-architecture"
                onClick={handleBreadcrumbClick("Frontend Architecture")}
              >
                Frontend Architecture
              </Breadcrumb.Link>
            </Breadcrumb.Item>
            <Breadcrumb.Separator aria-hidden="true">
              <ChevronRightIcon />
            </Breadcrumb.Separator>
            <Breadcrumb.Item>
              <Breadcrumb.CurrentLink aria-current="page">
                Design Systems
              </Breadcrumb.CurrentLink>
            </Breadcrumb.Item>
          </Breadcrumb.List>
        </Breadcrumb.Root>

        {/* Two-column Course Layout */}
        <Grid align="start" style={styles.layoutGrid}>
          {/* Left Main Content Column */}
          <VStack render={<main />} gap="6">
            {/* Course Header */}
            <VStack render={<header />} gap="4">
              <HStack wrap="wrap" gap="2">
                <Badge variant="subtle" size="sm" palette={amberPalette}>
                  Bestseller
                </Badge>
                <Badge variant="surface" size="sm">
                  {COURSE_META.level}
                </Badge>
                <Badge variant="subtle" size="sm" palette={emeraldPalette}>
                  Updated 2026
                </Badge>
              </HStack>

              <Heading render={<h1 />} size="4xl" style={styles.title}>
                {title}
              </Heading>

              <Text variant="muted" size="md" style={styles.subtitle}>
                {subtitle}
              </Text>

              <HStack wrap="wrap" gap="2.5">
                <RatingGroup
                  count={5}
                  value={5}
                  readOnly
                  size="sm"
                  palette={amberPalette}
                  aria-label={`Rated ${COURSE_META.rating} out of 5`}
                />
                <Text render={<span />} size="sm" weight="semibold" tabular="true">
                  {COURSE_META.rating.toFixed(1)}
                </Text>
                <Text render={<span />} variant="muted" size="sm">
                  ({COURSE_META.reviewCount.toLocaleString("en-US")} reviews) ·{" "}
                  {COURSE_META.learnerCount} learners
                </Text>
              </HStack>

              <HStack wrap="wrap" gap="4" style={styles.pt1}>
                <HStack render={<span />} gap="1.5" style={styles.factItem}>
                  <ClockIcon />
                  {COURSE_META.runtime}
                </HStack>
                <HStack render={<span />} gap="1.5" style={styles.factItem}>
                  <BookOpenIcon />
                  {modules.length} modules · {totalLessons} lessons
                </HStack>
                <HStack render={<span />} gap="1.5" style={styles.factItem}>
                  <GlobeIcon />
                  {COURSE_META.language}
                </HStack>
                <HStack render={<span />} gap="1.5" style={styles.factItem}>
                  <SparklesIcon />
                  Self-paced or cohort
                </HStack>
              </HStack>

              <HStack wrap="wrap" gap="2">
                {COURSE_META.skills.map((skill) => (
                  <Tag.Root key={skill} size="md" variant="surface">
                    <Tag.Label>{skill}</Tag.Label>
                  </Tag.Root>
                ))}
              </HStack>
            </VStack>

            {/* Primary Content Tabs */}
            <Tabs.Root
              value={activeTab}
              onValueChange={setActiveTab}
              variant="line"
              size="md"
              palette={accentPalette}
            >
              <div {...stylex.props(styles.tabsListWrap)}>
                <Tabs.List aria-label="Course sections">
                  <Tabs.Tab value="syllabus">
                    Syllabus ({completedCount}/{totalLessons})
                  </Tabs.Tab>
                  <Tabs.Tab value="outcomes">Outcomes &amp; FAQ</Tabs.Tab>
                  <Tabs.Tab value="instructor">Instructor</Tabs.Tab>
                  <Tabs.Tab value="reviews">
                    Reviews ({COURSE_META.reviewCount.toLocaleString("en-US")})
                  </Tabs.Tab>
                </Tabs.List>
              </div>

              {/* Tab 1: Interactive Syllabus & Live Progress */}
              <Tabs.Panel value="syllabus" style={styles.tabPanel}>
                <VStack gap="5">
                  <Card.Root variant="outline" size="md">
                    <Card.Body>
                      <VStack gap="3">
                        <HStack wrap="wrap" justify="between" gap="3">
                          <VStack gap="0.5">
                            <Text size="sm" weight="semibold">
                              Curriculum completion tracker
                            </Text>
                            <Text variant="caption" tabular="true">
                              {completedCount} of {totalLessons} lessons marked complete — check off lessons below as you go.
                            </Text>
                          </VStack>
                          <HStack wrap="wrap" gap="2">
                            <Button
                              variant="ghost"
                              size="xs"
                              onClick={handleToggleExpandAll}
                            >
                              {allExpanded ? "Collapse all" : "Expand all"}
                            </Button>
                            {completedCount > 0 ? (
                              <Button
                                variant="outline"
                                size="xs"
                                onClick={handleResetProgress}
                              >
                                Reset
                              </Button>
                            ) : null}
                          </HStack>
                        </HStack>

                        <Progress.Root
                          value={progressPercent}
                          max={100}
                          variant="subtle"
                          size="md"
                          shape="full"
                          palette={
                            progressPercent === 100 ? emeraldPalette : accentPalette
                          }
                          aria-label="Course lesson completion"
                          style={styles.fullWidth}
                        >
                          <HStack gap="3">
                            <Progress.Track style={styles.flexFill}>
                              <Progress.Range />
                            </Progress.Track>
                            <Text
                              render={<span />}
                              variant="caption"
                              tone="default"
                              weight="semibold"
                              align="end"
                              tabular="true"
                              style={styles.progressPercent}
                            >
                              {progressPercent}%
                            </Text>
                          </HStack>
                        </Progress.Root>
                      </VStack>
                    </Card.Body>
                  </Card.Root>

                  <Accordion.Root
                    multiple
                    value={openModules}
                    onValueChange={(next) => setOpenModules(next)}
                    variant="outline"
                    size="md"
                    style={styles.moduleAccordion}
                  >
                    {modules.map((mod) => {
                      const modDone = mod.lessons.filter((lesson) =>
                        completedSet.has(lesson.id),
                      ).length;
                      const isModComplete = modDone === mod.lessons.length;

                      return (
                        <Accordion.Item
                          key={mod.id}
                          value={mod.id}
                          style={styles.moduleItem}
                        >
                          <Accordion.Header>
                            <Accordion.Trigger style={styles.moduleTrigger}>
                              <HStack
                                wrap="wrap"
                                justify="between"
                                gap="2"
                                style={styles.flexFill}
                              >
                                <VStack gap="0.5">
                                  <Text render={<span />} size="md" weight="semibold">
                                    {mod.title}
                                  </Text>
                                  <Text
                                    render={<span />}
                                    variant="caption"
                                    weight="normal"
                                  >
                                    {mod.summary}
                                  </Text>
                                </VStack>
                                <HStack gap="2" style={styles.shrink0}>
                                  <Badge
                                    variant="subtle"
                                    size="xs"
                                    palette={
                                      isModComplete ? emeraldPalette : accentPalette
                                    }
                                  >
                                    {modDone}/{mod.lessons.length} done
                                  </Badge>
                                  <Text
                                    render={<span />}
                                    variant="caption"
                                    weight="normal"
                                    tabular="true"
                                  >
                                    {mod.duration}
                                  </Text>
                                </HStack>
                              </HStack>
                              <Accordion.ItemIndicator>
                                <ChevronDownIcon />
                              </Accordion.ItemIndicator>
                            </Accordion.Trigger>
                          </Accordion.Header>
                          <Accordion.Panel>
                            <Accordion.ItemBody style={styles.moduleBody}>
                              <VStack render={<ul />} gap="1" style={styles.plainList}>
                                {mod.lessons.map((lesson) => {
                                  const isDone = completedSet.has(lesson.id);
                                  return (
                                    <HStack
                                      key={lesson.id}
                                      render={<li />}
                                      justify="between"
                                      gap="3"
                                      style={styles.lessonRow}
                                    >
                                      <Checkbox.Root
                                        size="sm"
                                        variant="solid"
                                        palette={
                                          isDone ? emeraldPalette : accentPalette
                                        }
                                        style={styles.lessonCheckboxRoot}
                                      >
                                        <Checkbox.Control
                                          checked={isDone}
                                          onCheckedChange={(checked) =>
                                            handleToggleLesson(
                                              lesson,
                                              mod,
                                              checked === true,
                                            )
                                          }
                                        />
                                        <Checkbox.Label
                                          style={
                                            isDone
                                              ? styles.lessonLabelCompleted
                                              : styles.lessonLabelActive
                                          }
                                        >
                                          {lesson.title}
                                        </Checkbox.Label>
                                      </Checkbox.Root>

                                      <HStack gap="2" style={styles.shrink0}>
                                        {lesson.preview ? (
                                          <Button
                                            variant="ghost"
                                            size="2xs"
                                            palette={accentPalette}
                                            onClick={() => handlePreview(lesson)}
                                          >
                                            <PlayIcon />
                                            Preview
                                          </Button>
                                        ) : null}
                                        <Text
                                          render={<span />}
                                          variant="caption"
                                          align="end"
                                          tabular="true"
                                          style={styles.lessonDuration}
                                        >
                                          {lesson.duration}
                                        </Text>
                                      </HStack>
                                    </HStack>
                                  );
                                })}
                              </VStack>
                            </Accordion.ItemBody>
                          </Accordion.Panel>
                        </Accordion.Item>
                      );
                    })}
                  </Accordion.Root>
                </VStack>
              </Tabs.Panel>

              {/* Tab 2: Outcomes, Capstone, Prerequisites & FAQ */}
              <Tabs.Panel value="outcomes" style={styles.tabPanel}>
                <VStack gap="5">
                  <Section.Root style={styles.sectionStack}>
                    <HStack wrap="wrap" justify="between" gap="2">
                      <Heading render={<h2 />} size="xl" style={styles.headingReset}>
                        What you will build &amp; master
                      </Heading>
                    </HStack>
                    <Grid columns="2" gap="3" style={styles.responsiveTwoCol}>
                      {OUTCOMES.map((outcome) => (
                        <Card.Root key={outcome.title} variant="outline" size="md">
                          <Card.Body>
                            <VStack gap="1.5">
                              <HStack align="start" gap="2">
                                <span {...stylex.props(styles.outcomeIcon)}>
                                  <CheckIcon />
                                </span>
                                <Text render={<h3 />} size="sm" weight="semibold">
                                  {outcome.title}
                                </Text>
                              </HStack>
                              <Text variant="muted" size="sm" style={styles.leadingMd}>
                                {outcome.detail}
                              </Text>
                            </VStack>
                          </Card.Body>
                        </Card.Root>
                      ))}
                    </Grid>
                  </Section.Root>

                  <Card.Root variant="subtle" size="md" palette={indigoPalette}>
                    <Card.Body>
                      <VStack gap="3">
                        <HStack wrap="wrap" justify="between" gap="2">
                          <Heading render={<h3 />} size="md" style={styles.headingReset}>
                            Reviewed Capstone · Multi-Brand Accessible UI Kit
                          </Heading>
                          <Badge variant="solid" size="xs" palette={indigoPalette}>
                            Graded PR Review
                          </Badge>
                        </HStack>
                        <Text variant="muted" size="sm" style={styles.leadingLg}>
                          Ship an installable package containing semantic OKLCH tokens,
                          compile-time atomic component recipes, five composite WAI-ARIA
                          primitives, and an automated keyboard + axe-core CI workflow.
                          Every capstone submission receives line-by-line architectural
                          feedback.
                        </Text>
                      </VStack>
                    </Card.Body>
                  </Card.Root>

                  <Section.Root style={styles.sectionStack}>
                    <Heading render={<h2 />} size="lg" style={styles.headingReset}>
                      Prerequisites
                    </Heading>
                    <VStack render={<ul />} gap="2" style={styles.plainList}>
                      {PREREQUISITES.map((item) => (
                        <HStack key={item} render={<li />} align="start" gap="2">
                          <span {...stylex.props(styles.prereqBullet)}>
                            <ChevronRightIcon />
                          </span>
                          <Text
                            render={<span />}
                            variant="muted"
                            size="sm"
                            style={styles.leadingMd}
                          >
                            {item}
                          </Text>
                        </HStack>
                      ))}
                    </VStack>
                  </Section.Root>

                  <Separator />

                  <Section.Root style={styles.sectionStack}>
                    <Heading render={<h2 />} size="lg" style={styles.headingReset}>
                      Common questions
                    </Heading>
                    <Accordion.Root multiple variant="outline" size="md">
                      {FAQS.map((faq) => (
                        <Accordion.Item key={faq.id} value={faq.id}>
                          <Accordion.Header>
                            <Accordion.Trigger>
                              {faq.q}
                              <Accordion.ItemIndicator>
                                <ChevronDownIcon />
                              </Accordion.ItemIndicator>
                            </Accordion.Trigger>
                          </Accordion.Header>
                          <Accordion.Panel>
                            <Accordion.ItemBody style={styles.faqBody}>
                              {faq.a}
                            </Accordion.ItemBody>
                          </Accordion.Panel>
                        </Accordion.Item>
                      ))}
                    </Accordion.Root>
                  </Section.Root>
                </VStack>
              </Tabs.Panel>

              {/* Tab 3: Instructor */}
              <Tabs.Panel value="instructor" style={styles.tabPanel}>
                <VStack gap="5">
                  <Card.Root variant="outline" size="lg">
                    <Card.Body>
                      <VStack gap="4">
                        <HStack wrap="wrap" gap="4">
                          <Avatar.Root
                            size="xl"
                            variant="subtle"
                            palette={indigoPalette}
                          >
                            <Avatar.Fallback>{INSTRUCTOR.initials}</Avatar.Fallback>
                          </Avatar.Root>
                          <VStack gap="1">
                            <Heading
                              render={<h2 />}
                              size="xl"
                              style={styles.headingReset}
                            >
                              {INSTRUCTOR.name}
                            </Heading>
                            <Text variant="muted" size="sm">
                              {INSTRUCTOR.role}
                            </Text>
                          </VStack>
                        </HStack>

                        <HStack wrap="wrap" gap="5">
                          <HStack render={<span />} gap="1.5" style={styles.factItem}>
                            <UsersIcon />
                            {INSTRUCTOR.learners} learners
                          </HStack>
                          <HStack render={<span />} gap="1.5" style={styles.factItem}>
                            <BookOpenIcon />
                            {INSTRUCTOR.courses} courses
                          </HStack>
                          <HStack render={<span />} gap="1.5" style={styles.factItem}>
                            <SparklesIcon />
                            {INSTRUCTOR.rating} instructor rating
                          </HStack>
                        </HStack>

                        <Text size="sm" style={styles.leadingLg}>
                          {INSTRUCTOR.bio}
                        </Text>

                        <HStack wrap="wrap" gap="2">
                          {INSTRUCTOR.focusAreas.map((area) => (
                            <Tag.Root key={area} size="sm" variant="subtle" palette={indigoPalette}>
                              <Tag.Label>{area}</Tag.Label>
                            </Tag.Root>
                          ))}
                        </HStack>

                        <HStack wrap="wrap" gap="2">
                          <Button
                            variant="surface"
                            size="md"
                            onClick={() =>
                              queue.info(`Opening ${INSTRUCTOR.name}'s profile`, {
                                description: "5 published architecture courses and 14 conference talks.",
                              })
                            }
                          >
                            View full profile
                          </Button>
                          <Button
                            variant={followingInstructor ? "subtle" : "outline"}
                            size="md"
                            palette={followingInstructor ? emeraldPalette : accentPalette}
                            onClick={handleToggleFollow}
                          >
                            {followingInstructor ? "Following" : "Follow instructor"}
                          </Button>
                        </HStack>
                      </VStack>
                    </Card.Body>
                  </Card.Root>
                </VStack>
              </Tabs.Panel>

              {/* Tab 4: Learner Reviews */}
              <Tabs.Panel value="reviews" style={styles.tabPanel}>
                <VStack gap="5">
                  <Card.Root variant="outline" size="lg">
                    <Card.Body>
                      <Grid gap="6" style={styles.reviewSummaryGrid}>
                        <VStack align="start" justify="center" gap="1.5">
                          <Text tabular="true" style={styles.scoreDisplay}>
                            {COURSE_META.rating.toFixed(1)}
                          </Text>
                          <RatingGroup
                            count={5}
                            value={5}
                            readOnly
                            size="sm"
                            palette={amberPalette}
                            aria-label={`Average rating ${COURSE_META.rating} out of 5`}
                          />
                          <Text render={<span />} variant="muted" size="sm">
                            {COURSE_META.reviewCount.toLocaleString("en-US")} verified reviews
                          </Text>
                        </VStack>

                        <VStack gap="2.5">
                          {RATING_ASPECTS.map((aspect) => (
                            <VStack key={aspect.label} gap="1">
                              <HStack justify="between">
                                <Text render={<span />} variant="caption">
                                  {aspect.label}
                                </Text>
                                <Text
                                  render={<span />}
                                  variant="caption"
                                  tone="default"
                                  weight="medium"
                                  tabular="true"
                                >
                                  {aspect.score.toFixed(1)}
                                </Text>
                              </HStack>
                              <Progress.Root
                                value={Math.round((aspect.score / 5) * 100)}
                                max={100}
                                variant="subtle"
                                size="xs"
                                shape="full"
                                palette={accentPalette}
                                aria-label={`${aspect.label}: ${aspect.score} out of 5`}
                              >
                                <Progress.Track>
                                  <Progress.Range />
                                </Progress.Track>
                              </Progress.Root>
                            </VStack>
                          ))}
                        </VStack>
                      </Grid>
                    </Card.Body>
                  </Card.Root>

                  <Grid columns="2" gap="4" style={styles.responsiveTwoCol}>
                    {REVIEWS.map((review) => {
                      const voted = Boolean(helpfulVotes[review.id]);
                      const count = review.helpful + (voted ? 1 : 0);
                      return (
                        <Card.Root key={review.id} variant="outline" size="md">
                          <Card.Body>
                            <VStack gap="3" style={styles.flexFill}>
                              <HStack gap="2.5">
                                <Avatar.Root
                                  size="sm"
                                  variant="subtle"
                                  palette={REVIEW_PALETTES[review.paletteKey]}
                                >
                                  <Avatar.Fallback>{review.initials}</Avatar.Fallback>
                                </Avatar.Root>
                                <VStack gap="0.5">
                                  <Text
                                    render={<span />}
                                    size="sm"
                                    weight="semibold"
                                    style={styles.leadingXs}
                                  >
                                    {review.author}
                                  </Text>
                                  <Text render={<span />} variant="caption">
                                    {review.role} · {review.date}
                                  </Text>
                                </VStack>
                              </HStack>

                              <RatingGroup
                                count={5}
                                value={review.rating}
                                readOnly
                                size="xs"
                                palette={amberPalette}
                                aria-label={`${review.author} rated ${review.rating} out of 5`}
                              />

                              <Text
                                size="sm"
                                style={[styles.flexFill, styles.leadingMd]}
                              >
                                {review.body}
                              </Text>

                              <HStack justify="between" style={styles.pt1}>
                                <Button
                                  variant={voted ? "subtle" : "ghost"}
                                  size="xs"
                                  palette={voted ? accentPalette : undefined}
                                  onClick={() => handleToggleHelpful(review)}
                                >
                                  <ThumbUpIcon />
                                  Helpful ({count})
                                </Button>
                              </HStack>
                            </VStack>
                          </Card.Body>
                        </Card.Root>
                      );
                    })}
                  </Grid>
                </VStack>
              </Tabs.Panel>
            </Tabs.Root>
          </VStack>

          {/* Right Sticky Enrollment & Preview Card */}
          <VStack
            render={<aside aria-label="Course enrollment and preview" />}
            gap="4"
            style={styles.railColumn}
          >
            <Card.Root variant="elevated" size="lg" style={styles.enrollCard}>
              {/* Course cover photo */}
              <AspectRatio ratio="wide" rounded="none" style={styles.coverStage}>
                <img
                  src="/images/blocks/course-detail/cover.webp"
                  alt="Overhead studio photo of color swatch chips arranged in smooth indigo-to-violet gradient ramps beside a pencil and ruler"
                  {...stylex.props(styles.coverImage)}
                />
                <HStack align="end" justify="between" style={styles.coverOverlay}>
                  <button
                    type="button"
                    onClick={() => handlePreview()}
                    {...stylex.props(styles.coverPreviewButton)}
                  >
                    <PlayIcon />
                    Preview lesson 1 · 18m
                  </button>
                </HStack>
              </AspectRatio>

              <Card.Body>
                <VStack gap="4">
                  <VStack gap="1">
                    <HStack align="baseline" wrap="wrap" gap="2">
                      <Text
                        render={<span />}
                        tabular="true"
                        style={styles.priceCurrent}
                      >
                        {formatUsd(price)}
                      </Text>
                      {compareAtPrice > price ? (
                        <Text
                          render={<span />}
                          variant="muted"
                          size="md"
                          tabular="true"
                          style={styles.lineThrough}
                        >
                          {formatUsd(compareAtPrice)}
                        </Text>
                      ) : null}
                      {discountPercent > 0 ? (
                        <Badge variant="subtle" size="sm" palette={rosePalette}>
                          Save {discountPercent}%
                        </Badge>
                      ) : null}
                    </HStack>
                    <Text render={<span />} variant="muted" size="sm">
                      One-time purchase · lifetime access &amp; updates
                    </Text>
                  </VStack>

                  <VStack gap="2">
                    <Button
                      variant="solid"
                      size="lg"
                      palette={enrolled ? emeraldPalette : accentPalette}
                      onClick={handleEnroll}
                      style={styles.fullWidth}
                    >
                      {enrolled ? "Continue learning" : "Enroll now"}
                      <ArrowRightIcon />
                    </Button>
                    <Button
                      variant="surface"
                      size="lg"
                      onClick={() => handlePreview()}
                      style={styles.fullWidth}
                    >
                      <PlayIcon />
                      Start lesson one free
                    </Button>
                  </VStack>

                  {/* Live synced progress summary */}
                  <VStack gap="2" style={styles.railProgressBox}>
                    <HStack justify="between">
                      <Text render={<span />} size="xs" weight="semibold">
                        Your syllabus progress
                      </Text>
                      <Text
                        render={<span />}
                        size="xs"
                        weight="semibold"
                        tabular="true"
                      >
                        {completedCount}/{totalLessons} ({progressPercent}%)
                      </Text>
                    </HStack>
                    <Progress.Root
                      value={progressPercent}
                      max={100}
                      variant="subtle"
                      size="sm"
                      shape="full"
                      palette={
                        progressPercent === 100 ? emeraldPalette : accentPalette
                      }
                      aria-label="Syllabus progress summary"
                    >
                      <Progress.Track>
                        <Progress.Range />
                      </Progress.Track>
                    </Progress.Root>
                  </VStack>

                  <Separator />

                  {/* Study Pace / Cohort Selector */}
                  <VStack gap="3">
                    <Text render={<span />} size="xs" weight="semibold">
                      Study format
                    </Text>
                    <SegmentGroup.Root
                      value={startMode}
                      onValueChange={(next) => {
                        if (next === "self-paced" || next === "cohort") {
                          setStartMode(next);
                        }
                      }}
                      size="sm"
                      aria-label="Study format"
                      style={styles.segmentFull}
                    >
                      <SegmentGroup.Item
                        value="self-paced"
                        style={styles.segmentItemCenter}
                      >
                        Self-paced
                      </SegmentGroup.Item>
                      <SegmentGroup.Item
                        value="cohort"
                        style={styles.segmentItemCenter}
                      >
                        Live cohort
                      </SegmentGroup.Item>
                    </SegmentGroup.Root>

                    {startMode === "self-paced" ? (
                      <VStack gap="3">
                        <HStack justify="between">
                          <Text render={<span />} variant="muted" size="sm">
                            Weekly study pace
                          </Text>
                          <Text
                            render={<span />}
                            size="xs"
                            weight="semibold"
                            tabular="true"
                          >
                            {weeklyPace} h/week
                          </Text>
                        </HStack>
                        <Slider.Root
                          size="sm"
                          min={PACE_MIN}
                          max={PACE_MAX}
                          step={1}
                          value={weeklyPace}
                          palette={accentPalette}
                          onValueChange={(next) => {
                            const hours = Array.isArray(next)
                              ? (next[0] ?? weeklyPace)
                              : next;
                            setWeeklyPace(hours);
                          }}
                        >
                          <Slider.Control>
                            <Slider.Track>
                              <Slider.Indicator />
                              <Slider.Thumb aria-label="Weekly study hours" />
                            </Slider.Track>
                          </Slider.Control>
                        </Slider.Root>
                        <HStack justify="between">
                          <Text render={<span />} variant="caption">
                            {PACE_MIN} h/wk
                          </Text>
                          <Text render={<span />} variant="caption">
                            {PACE_MAX} h/wk
                          </Text>
                        </HStack>
                        <Text render={<span />} variant="muted" size="sm">
                          At {weeklyPace} h/week — {estimateFinish(weeklyPace)}
                        </Text>
                      </VStack>
                    ) : (
                      <RadioCard.Root
                        value={selectedCohort}
                        onValueChange={(next) => {
                          if (next) setSelectedCohort(next);
                        }}
                        variant="outline"
                        size="sm"
                        palette={accentPalette}
                        aria-label="Upcoming live cohort"
                      >
                        {COHORTS.map((option) => (
                          <RadioCard.Item key={option.id} value={option.id}>
                            <RadioCard.ItemControl>
                              <RadioCard.ItemContent>
                                <RadioCard.ItemText>
                                  {option.label}
                                </RadioCard.ItemText>
                                <RadioCard.ItemDescription>
                                  {option.detail}
                                </RadioCard.ItemDescription>
                              </RadioCard.ItemContent>
                              <RadioCard.ItemIndicator />
                            </RadioCard.ItemControl>
                          </RadioCard.Item>
                        ))}
                      </RadioCard.Root>
                    )}
                  </VStack>

                  <Separator />

                  {/* Includes Checklist */}
                  <VStack gap="3">
                    <Text render={<span />} size="xs" weight="semibold">
                      This course includes
                    </Text>
                    <VStack render={<ul />} gap="2" style={styles.plainList}>
                      {COURSE_INCLUDES.map((item) => (
                        <HStack key={item} render={<li />} align="start" gap="2">
                          <span {...stylex.props(styles.includesIcon)}>
                            <CheckIcon />
                          </span>
                          <Text
                            render={<span />}
                            variant="caption"
                            style={styles.leadingSm}
                          >
                            {item}
                          </Text>
                        </HStack>
                      ))}
                    </VStack>
                  </VStack>
                </VStack>
              </Card.Body>
            </Card.Root>
          </VStack>
        </Grid>
      </VStack>

      <Toaster toaster={queue} />
    </div>
  );
}
```

Credit: Inspired by [Course Detail](https://astryx.atmeta.com/playground?template=course-detail) from Astryx (MIT License · Copyright (c) 2026 Meta Platforms, Inc.)
