/* ==========================================================================
   Components — shadcn/ui primitives ported to plain CSS classes, plus the
   pieces a course site needs (course card, rating, avatar stack).
   Logical properties throughout, so everything works in RTL and LTR.
   ========================================================================== */

/* ---------- Button ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 2.5rem;
  padding-inline: 1.125rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s, translate 0.1s;
}

.btn:active {
  translate: 0 1px;
}

.btn:focus-visible {
  outline: none;
  border-color: var(--ring);
  border-radius: var(--radius-md);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 50%, transparent);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  pointer-events: none;
  opacity: 0.5;
}

.btn svg {
  width: 1rem;
  height: 1rem;
}

.btn-default {
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: inset 0 1px 0 oklch(1 0 0 / 0.14), 0 1px 2px oklch(0 0 0 / 0.25);
}

.btn-default:hover {
  background: color-mix(in oklch, var(--primary) 84%, var(--background));
}

.btn-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
}

.btn-secondary:hover {
  background: color-mix(in oklch, var(--secondary) 90%, var(--foreground));
}

.btn-outline {
  border-color: var(--border);
  background: var(--card);
  box-shadow: var(--shadow-xs);
}

.btn-outline:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

.dark .btn-outline {
  border-color: var(--input);
  background: color-mix(in oklch, var(--input) 30%, transparent);
}

.dark .btn-outline:hover {
  background: color-mix(in oklch, var(--input) 50%, transparent);
}

.btn-ghost:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

.dark .btn-ghost:hover {
  background: color-mix(in oklch, var(--accent) 60%, transparent);
}

/* For the dark welcome panel */
.btn-inverse {
  background: var(--hero-foreground);
  color: var(--hero);
  box-shadow: 0 1px 2px oklch(0 0 0 / 0.3);
}

.btn-inverse:hover {
  background: color-mix(in oklch, var(--hero-foreground) 88%, var(--hero));
}

.btn-ghost-inverse {
  border-color: oklch(1 0 0 / 0.2);
  color: var(--hero-foreground);
}

.btn-ghost-inverse:hover {
  background: oklch(1 0 0 / 0.1);
}

.btn-inverse:focus-visible,
.btn-ghost-inverse:focus-visible {
  border-color: var(--hero-foreground);
  box-shadow: 0 0 0 3px oklch(1 0 0 / 0.3);
}

.btn-sm {
  height: 2.125rem;
  padding-inline: 0.875rem;
  gap: 0.375rem;
}

.btn-lg {
  height: 2.875rem;
  padding-inline: 1.5rem;
  font-size: var(--text-base);
}

.btn-icon {
  width: 2.5rem;
  padding-inline: 0;
}

.btn-icon.btn-sm {
  width: 2.125rem;
}

.btn-block {
  width: 100%;
}

/* ---------- Badge ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3125rem;
  padding: 0.125rem 0.625rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 500;
  line-height: var(--leading-snug);
  white-space: nowrap;
}

.badge svg {
  width: 0.75rem;
  height: 0.75rem;
}

.badge-default {
  background: var(--primary);
  color: var(--primary-foreground);
}

.badge-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
}

.badge-outline {
  border-color: var(--border);
  color: var(--foreground);
}

/* Tinted by the nearest data-hue */
.badge-hue {
  background: var(--hue-bg);
  color: var(--hue-fg);
}

/* Sits on top of an image */
.badge-glass {
  background: oklch(1 0 0 / 0.88);
  color: oklch(0.205 0 0);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* A small coloured dot, tinted by the nearest data-hue */
.dot {
  display: inline-block;
  flex-shrink: 0;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--hue-solid, var(--muted-foreground));
}

/* ---------- Card ---------- */

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--card);
  color: var(--card-foreground);
  box-shadow: var(--shadow-xs);
}

/* ---------- Input ---------- */

.input {
  display: block;
  width: 100%;
  height: 2.5rem;
  padding-inline: 0.875rem;
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  background: var(--card);
  box-shadow: var(--shadow-xs);
  font-size: var(--text-base);
  transition: border-color 0.15s, box-shadow 0.15s;
}

@media (min-width: 48rem) {
  .input {
    font-size: var(--text-sm);
  }
}

.dark .input {
  background: color-mix(in oklch, var(--input) 30%, transparent);
}

.input::placeholder {
  color: var(--muted-foreground);
}

.input:focus-visible {
  outline: none;
  border-color: var(--ring);
  border-radius: var(--radius-md);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 50%, transparent);
}

/* Input with a leading icon */
.input-group {
  position: relative;
}

.input-group > svg,
.input-group > [data-icon] {
  position: absolute;
  top: 50%;
  inset-inline-start: 0.875rem;
  width: 1rem;
  height: 1rem;
  translate: 0 -50%;
  color: var(--muted-foreground);
  pointer-events: none;
}

.input-group > .input {
  padding-inline-start: 2.5rem;
}

/* ---------- Select (native, styled) ---------- */

.select {
  position: relative;
  display: inline-flex;
}

.select select {
  appearance: none;
  height: 2.5rem;
  padding-inline: 0.875rem 2.5rem;
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  background: var(--card);
  box-shadow: var(--shadow-xs);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.dark .select select {
  background: color-mix(in oklch, var(--input) 30%, transparent);
}

.select select:focus-visible {
  outline: none;
  border-color: var(--ring);
  border-radius: var(--radius-md);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 50%, transparent);
}

.select > svg,
.select > [data-icon] {
  position: absolute;
  top: 50%;
  inset-inline-end: 0.875rem;
  width: 1rem;
  height: 1rem;
  translate: 0 -50%;
  opacity: 0.5;
  pointer-events: none;
}

/* ---------- Segmented control (shadcn tabs list, used as a filter) ---------- */

.segmented {
  display: inline-flex;
  max-width: 100%;
  padding: 3px;
  border-radius: var(--radius-md);
  background: var(--muted);
  overflow-x: auto;
  scrollbar-width: none;
}

.segment {
  height: calc(2.5rem - 6px);
  padding-inline: 0.875rem;
  border-radius: calc(var(--radius-md) - 3px);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--muted-foreground);
  white-space: nowrap;
  transition: background-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.segment:hover {
  color: var(--foreground);
}

.segment[aria-pressed="true"] {
  background: var(--card);
  color: var(--foreground);
  box-shadow: var(--shadow-sm);
}

.dark .segment[aria-pressed="true"] {
  background: color-mix(in oklch, var(--foreground) 12%, transparent);
}

.segment:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: -2px;
  border-radius: calc(var(--radius-md) - 3px);
}

/* ---------- Chip (a pill-shaped toggle) ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 2.25rem;
  padding-inline: 0.875rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  font-size: var(--text-sm);
  white-space: nowrap;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

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

.chip[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-foreground);
}

.chip:focus-visible {
  outline: none;
  border-color: var(--ring);
  border-radius: 999px;
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 50%, transparent);
}

/* ---------- Alert ---------- */

.alert {
  display: grid;
  grid-template-columns: 1.125rem minmax(0, 1fr);
  gap: 0.125rem 0.75rem;
  padding: 1rem 1.125rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
}

/* With data-hue the note takes the hue's tint */
.alert[data-hue] {
  border-color: color-mix(in oklch, var(--hue-solid) 28%, transparent);
  background: color-mix(in oklch, var(--hue-bg) 55%, transparent);
}

.alert > svg {
  width: 1.125rem;
  height: 1.125rem;
  margin-top: 0.35rem;
  color: var(--hue-fg, currentColor);
}

.alert-title {
  grid-column: 2;
  font-weight: 700;
}

.alert-description {
  grid-column: 2;
  color: color-mix(in oklch, var(--foreground) 78%, transparent);
}

/* ---------- Kbd ---------- */

.kbd {
  display: inline-block;
  min-width: 1.5rem;
  padding: 0.125rem 0.375rem;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  background: var(--muted);
  direction: ltr;
  font-size: var(--text-xs);
  line-height: var(--leading-heading);
  text-align: center;
}

/* ---------- Avatar ---------- */

.avatar {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--hue-bg, var(--muted));
  color: var(--hue-fg, var(--foreground));
  font-size: var(--text-sm);
  font-weight: 700;
  line-height: 1;
}

.avatar-xs {
  width: 1.5rem;
  height: 1.5rem;
  font-size: var(--text-2xs);
}

.avatar-sm {
  width: 2rem;
  height: 2rem;
  font-size: var(--text-xs);
}

.avatar-lg {
  width: 3.5rem;
  height: 3.5rem;
  font-size: var(--text-lg);
}

/* Overlapping avatars; --ring-color is the surface they sit on */
.avatar-stack {
  display: inline-flex;
}

.avatar-stack .avatar {
  box-shadow: 0 0 0 2px var(--ring-color, var(--background));
}

.avatar-stack .avatar + .avatar {
  margin-inline-start: -0.5rem;
}

/* ---------- Rating ---------- */

.rating {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-weight: 500;
  white-space: nowrap;
}

.rating svg {
  width: 0.875rem;
  height: 0.875rem;
  color: var(--star);
  fill: currentColor;
}

.stars {
  display: inline-flex;
  gap: 0.125rem;
}

.stars svg {
  width: 1rem;
  height: 1rem;
  color: var(--star);
  fill: currentColor;
}

.stars svg[data-off] {
  color: var(--border);
}

/* ---------- Breadcrumb ---------- */

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
  font-size: var(--text-sm);
  color: var(--muted-foreground);
}

.breadcrumb li {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.breadcrumb a {
  transition: color 0.15s;
}

.breadcrumb a:hover {
  color: var(--foreground);
}

.breadcrumb [aria-current="page"] {
  font-weight: 500;
  color: var(--foreground);
}

.breadcrumb svg {
  width: 0.875rem;
  height: 0.875rem;
}

/* ---------- Progress ---------- */

.progress {
  display: block;
  height: 0.5rem;
  border-radius: 999px;
  background: color-mix(in oklch, var(--foreground) 10%, transparent);
  overflow: hidden;
}

.progress-indicator {
  display: block;
  width: var(--value, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.4s var(--ease);
}

/* ---------- Course card ---------- */

/* The cover sits inside the card with an inset, so its radius = card radius - inset */
.course-card {
  display: flex;
  flex-direction: column;
  padding: 0.375rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--card);
  color: var(--card-foreground);
  box-shadow: var(--shadow-xs);
  transition: border-color 0.2s, box-shadow 0.2s, translate 0.2s var(--ease);
}

.course-card:hover {
  border-color: color-mix(in oklch, var(--foreground) 20%, transparent);
  box-shadow: var(--shadow-md);
  translate: 0 -2px;
}

.course-card:focus-visible {
  outline: none;
  border-color: var(--ring);
  border-radius: var(--radius-xl);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 50%, transparent);
}

.cover {
  display: block;
  position: relative;
  aspect-ratio: 8 / 5;
  border-radius: calc(var(--radius-xl) - 0.375rem);
  background: var(--hue-bg, var(--muted));
  overflow: hidden;
}

.cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dark .cover img {
  filter: brightness(0.9);
}

/* Bottom right is the one corner every cover illustration leaves empty */
.cover .badge {
  position: absolute;
  right: 0.625rem;
  bottom: 0.625rem;
}

.course-card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 0.875rem 0.75rem 0.625rem;
}

.course-card-category {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--text-xs);
  color: var(--muted-foreground);
}

.course-card-title {
  margin-top: 0.5rem;
  font-size: var(--text-base);
  line-height: var(--leading-snug);
}

.course-card-summary {
  display: -webkit-box;
  margin-top: 0.25rem;
  font-size: var(--text-sm);
  color: var(--muted-foreground);
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.course-card-by {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.875rem;
  font-size: var(--text-sm);
}

.course-card-by .rating {
  margin-inline-start: auto;
}

.course-card-foot {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: var(--text-sm);
  color: var(--muted-foreground);
}

.course-card-price {
  margin-inline-start: auto;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--foreground);
}

.course-card-foot .progress {
  flex: 1;
  height: 0.375rem;
}

/* ---------- Sidebar (shadcn "inset" variant) ----------
   .app is the frame: the sidebar sits on --sidebar, the content floats
   beside it as a rounded panel. Below 64rem the sidebar becomes off-canvas. */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100dvh;
  background: var(--sidebar);
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  color: var(--sidebar-foreground);
}

.sidebar-header {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  height: calc(var(--topbar-h) + var(--inset-gap));
  padding-inline: 1.125rem;
}

.sidebar-content > * {
  flex-shrink: 0;
}

.sidebar-content {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 1.25rem;
  min-height: 0;
  padding: 0.5rem 0.75rem 1.5rem;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--sidebar-border) transparent;
}

.sidebar-footer {
  flex-shrink: 0;
  padding: 0.75rem;
}

.sidebar-group-label {
  display: flex;
  align-items: center;
  min-height: 2rem;
  padding-inline: 0.625rem;
  font-size: var(--text-xs);
  font-weight: 500;
  line-height: var(--leading-snug);
  color: var(--muted-foreground);
}

.sidebar-menu {
  display: grid;
  gap: 2px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-height: 2.25rem;
  padding: 0.375rem 0.625rem;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
  color: color-mix(in oklch, var(--sidebar-foreground) 80%, transparent);
  transition: background-color 0.15s, color 0.15s;
}

.sidebar-link:hover {
  background: color-mix(in oklch, var(--sidebar-foreground) 6%, transparent);
  color: var(--sidebar-foreground);
}

/* The current page is a raised tile, like the content panel itself */
.sidebar-link[aria-current] {
  background: var(--background);
  color: var(--sidebar-foreground);
  font-weight: 500;
  box-shadow: 0 0 0 1px var(--sidebar-border), var(--shadow-xs);
}

.dark .sidebar-link[aria-current] {
  background: var(--sidebar-accent);
}

.sidebar-link:focus-visible {
  outline: 2px solid var(--sidebar-ring);
  outline-offset: -2px;
  border-radius: var(--radius-md);
}

.sidebar-link > svg {
  width: 1rem;
  height: 1rem;
  opacity: 0.7;
}

.sidebar-link[aria-current] > svg,
.sidebar-link[data-done="true"] > svg {
  opacity: 1;
}

.sidebar-link[data-done="true"] > svg {
  color: var(--success);
}

.sidebar-link > .dot {
  margin-inline: 0.28rem;
}

.sidebar-link-text {
  flex: 1;
  min-width: 0;
}

.sidebar-link-end {
  padding-inline-start: 0.5rem;
  font-size: var(--text-xs);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  color: var(--muted-foreground);
  white-space: nowrap;
}

.sidebar-thumb {
  flex-shrink: 0;
  width: 2rem;
  height: 1.25rem;
  border-radius: 4px;
  object-fit: cover;
}

/* A small card pinned to the bottom of the sidebar */
.sidebar-card {
  display: grid;
  gap: 0.25rem;
  padding: 0.875rem;
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius-lg);
  background: var(--background);
  box-shadow: var(--shadow-xs);
}

.dark .sidebar-card {
  background: var(--sidebar-accent);
}

.sidebar-card-title {
  font-size: var(--text-sm);
  font-weight: 700;
}

.sidebar-card p {
  font-size: var(--text-xs);
  line-height: var(--leading-normal);
  color: var(--muted-foreground);
}

.sidebar-card .btn {
  margin-top: 0.625rem;
}

.sidebar-backdrop {
  display: none;
}

/* The floating content panel */
.inset {
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin: var(--inset-gap);
  margin-inline-start: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--background);
  box-shadow: var(--shadow-sm);
}

@media (min-width: 64rem) {
  [data-sidebar="collapsed"] .app {
    grid-template-columns: minmax(0, 1fr);
  }

  [data-sidebar="collapsed"] .sidebar {
    display: none;
  }

  [data-sidebar="collapsed"] .inset {
    margin-inline-start: var(--inset-gap);
  }
}

@media (max-width: 63.99rem) {
  .app {
    display: block;
    background: var(--background);
  }

  .sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    z-index: 50;
    width: min(18.5rem, 86vw);
    border-inline-end: 1px solid var(--sidebar-border);
    background: var(--sidebar);
    translate: var(--sidebar-offset) 0;
    visibility: hidden;
    transition: translate 0.3s var(--ease), visibility 0s 0.3s;
  }

  [data-sidebar-open] .sidebar {
    translate: 0 0;
    visibility: visible;
    transition: translate 0.3s var(--ease), visibility 0s;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 45;
    background: oklch(0 0 0 / 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
  }

  [data-sidebar-open] .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .inset {
    min-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
}

/* ---------- Tabs (underline) ---------- */

.tabs-list {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 2.75rem;
  margin-bottom: -1px;
  padding-inline: 0.75rem;
  border-bottom: 2px solid transparent;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--muted-foreground);
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}

.tabs-trigger:hover {
  color: var(--foreground);
}

.tabs-trigger[aria-selected="true"] {
  border-color: var(--foreground);
  color: var(--foreground);
}

.tabs-trigger:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: -2px;
  border-radius: var(--radius-sm);
}

.tabs-trigger svg {
  width: 1rem;
  height: 1rem;
}

.tabs-count {
  min-width: 1.25rem;
  padding-inline: 0.375rem;
  border-radius: 999px;
  background: var(--muted);
  font-size: var(--text-2xs);
  font-variant-numeric: tabular-nums;
  line-height: 1.25rem;
  text-align: center;
  color: var(--foreground);
}

/* ---------- Form fields ---------- */

.field {
  display: grid;
  gap: 0.375rem;
}

.label {
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: var(--leading-snug);
}

.field-hint {
  font-size: var(--text-xs);
  color: var(--muted-foreground);
}

.field-error {
  font-size: var(--text-xs);
  color: var(--destructive);
}

.input[aria-invalid="true"] {
  border-color: var(--destructive);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--destructive) 18%, transparent);
}

.textarea {
  height: auto;
  min-height: 6.5rem;
  padding-block: 0.625rem;
  line-height: var(--leading-normal);
  resize: vertical;
}

.checkbox {
  appearance: none;
  display: inline-grid;
  place-content: center;
  flex-shrink: 0;
  width: 1.125rem;
  height: 1.125rem;
  margin: 0;
  border: 1px solid var(--muted-foreground);
  border-radius: 5px;
  background: var(--card);
  cursor: pointer;
  transition: background-color 0.12s, border-color 0.12s, box-shadow 0.15s;
}

.checkbox::before {
  content: "";
  width: 0.75rem;
  height: 0.75rem;
  background: var(--primary-foreground);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
  scale: 0;
  transition: scale 0.12s var(--ease);
}

.checkbox:checked {
  border-color: var(--primary);
  background: var(--primary);
}

.checkbox:checked::before {
  scale: 1;
}

.checkbox:focus-visible {
  outline: none;
  border-radius: 5px;
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 50%, transparent);
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
  cursor: pointer;
}

.check .checkbox {
  margin-top: 0.15rem;
}

/* A radio shown as a selectable card */
.radio-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}

.radio-card:hover {
  background: color-mix(in oklch, var(--accent) 65%, transparent);
}

.radio-card:has(:checked) {
  border-color: var(--foreground);
  box-shadow: 0 0 0 1px var(--foreground);
}

.radio-card:has(:focus-visible) {
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 50%, transparent);
}

.radio-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.radio-card svg {
  width: 1.125rem;
  height: 1.125rem;
}

/* ---------- Count badge on an icon button ---------- */

.has-count {
  position: relative;
}

.count-badge {
  position: absolute;
  top: -0.25rem;
  inset-inline-end: -0.25rem;
  min-width: 1.125rem;
  height: 1.125rem;
  padding-inline: 0.25rem;
  border-radius: 999px;
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: 0 0 0 2px var(--background);
  font-size: var(--text-2xs);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.125rem;
  text-align: center;
}

/* ---------- Dialog (the search palette) ---------- */

.dialog {
  position: fixed;
  inset: 0;
  width: min(36rem, calc(100vw - 2rem));
  max-width: none;
  max-height: min(32rem, 78dvh);
  margin: 12dvh auto auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--popover);
  color: var(--popover-foreground);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  opacity: 0;
  translate: 0 -0.5rem;
  transition: opacity 0.2s, translate 0.2s var(--ease), overlay 0.2s allow-discrete, display 0.2s allow-discrete;
}

.dialog[open] {
  display: flex;
  flex-direction: column;
  opacity: 1;
  translate: 0 0;
}

@starting-style {
  .dialog[open] {
    opacity: 0;
    translate: 0 -0.5rem;
  }
}

.dialog::backdrop,
.sheet::backdrop {
  background: oklch(0 0 0 / 0);
  transition: background-color 0.25s, overlay 0.25s allow-discrete, display 0.25s allow-discrete;
}

.dialog[open]::backdrop,
.sheet[open]::backdrop {
  background: oklch(0 0 0 / 0.5);
}

@starting-style {
  .dialog[open]::backdrop,
  .sheet[open]::backdrop {
    background: oklch(0 0 0 / 0);
  }
}

.command-input {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  padding-inline: 1rem;
  border-bottom: 1px solid var(--border);
}

.command-input > svg {
  width: 1.125rem;
  height: 1.125rem;
  color: var(--muted-foreground);
}

.command-input input {
  flex: 1;
  min-width: 0;
  height: 3.25rem;
  border: 0;
  outline: 0;
  background: none;
  font-size: var(--text-base);
}

.command-input input::placeholder {
  color: var(--muted-foreground);
}

.command-list {
  flex: 1;
  min-height: 0;
  padding: 0.5rem;
  overflow-y: auto;
  scrollbar-width: thin;
}

.command-group-label {
  padding: 0.5rem 0.625rem 0.25rem;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--muted-foreground);
}

.command-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

.command-item[aria-selected="true"] {
  background: var(--accent);
}

.command-thumb {
  flex-shrink: 0;
  width: 2.75rem;
  height: 1.75rem;
  border-radius: 5px;
  object-fit: cover;
}

.command-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 2.75rem;
  height: 1.75rem;
  border-radius: 5px;
  background: var(--muted);
}

.command-icon svg {
  width: 1rem;
  height: 1rem;
}

.command-text {
  flex: 1;
  min-width: 0;
}

.command-title {
  display: block;
  font-weight: 500;
}

.command-sub {
  display: block;
  font-size: var(--text-xs);
  color: var(--muted-foreground);
}

.command-empty {
  padding: 2.5rem 1rem;
  text-align: center;
  font-size: var(--text-sm);
  color: var(--muted-foreground);
}

.command-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem 1.25rem;
  flex-shrink: 0;
  padding: 0.625rem 1rem;
  border-top: 1px solid var(--border);
  background: color-mix(in oklch, var(--muted) 60%, transparent);
  font-size: var(--text-xs);
  color: var(--muted-foreground);
}

/* The sidebar's search field is a button that opens the palette */
.search-trigger {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  height: 2.5rem;
  padding-inline: 0.875rem 0.5rem;
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  background: var(--background);
  box-shadow: var(--shadow-xs);
  font-size: var(--text-sm);
  color: var(--muted-foreground);
  text-align: start;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.dark .search-trigger {
  background: color-mix(in oklch, var(--input) 30%, transparent);
}

.search-trigger:hover {
  border-color: var(--ring);
}

.search-trigger:focus-visible {
  outline: none;
  border-color: var(--ring);
  border-radius: var(--radius-md);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 50%, transparent);
}

.search-trigger svg {
  width: 1rem;
  height: 1rem;
}

.search-trigger span {
  flex: 1;
}

/* ---------- Sheet (the cart), built on <dialog> ---------- */

.sheet {
  position: fixed;
  inset-block: 0;
  inset-inline: auto 0;
  display: none;
  flex-direction: column;
  width: min(26rem, 92vw);
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-inline-start: 1px solid var(--border);
  background: var(--background);
  color: var(--foreground);
  box-shadow: var(--shadow-md);
  translate: var(--sheet-offset) 0;
  transition: translate 0.3s var(--ease), overlay 0.3s allow-discrete, display 0.3s allow-discrete;
}

.sheet[open] {
  display: flex;
  translate: 0 0;
}

@starting-style {
  .sheet[open] {
    translate: var(--sheet-offset) 0;
  }
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-shrink: 0;
  height: var(--topbar-h);
  padding-inline: 1.25rem 0.875rem;
  border-bottom: 1px solid var(--border);
}

.sheet-title {
  font-size: var(--text-lg);
}

.sheet-body {
  flex: 1;
  min-height: 0;
  padding: 1.25rem;
  overflow-y: auto;
}

.sheet-footer {
  display: grid;
  gap: 0.75rem;
  flex-shrink: 0;
  padding: 1.25rem;
  border-top: 1px solid var(--border);
}

/* ---------- Line item (cart sheet and order summary) ---------- */

.line-items {
  display: grid;
  gap: 1rem;
}

.line-item {
  display: grid;
  grid-template-columns: 5rem minmax(0, 1fr) auto;
  gap: 0.875rem;
  align-items: center;
}

.line-item .cover {
  border-radius: var(--radius-sm);
}

.line-item-title {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: var(--leading-snug);
}

a.line-item-title:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.line-item-meta {
  display: block;
  font-size: var(--text-xs);
  color: var(--muted-foreground);
}

.line-item-price {
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
}

.totals {
  display: grid;
  gap: 0.375rem;
  font-size: var(--text-sm);
}

.totals div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.totals dt {
  color: var(--muted-foreground);
}

.totals .totals-total {
  margin-top: 0.375rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: var(--text-lg);
  font-weight: 700;
}

.totals .totals-total dt {
  color: var(--foreground);
}

/* ---------- Product card: an article with a stretched link and one button ---------- */

.product-card {
  position: relative;
}

.product-card .card-link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius-xl);
}

.product-card .card-link:focus-visible {
  outline: none;
}

.product-card:has(.card-link:focus-visible) {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 50%, transparent);
}

.product-card .course-card-foot {
  margin-top: auto;
  color: var(--foreground);
}

.product-card .course-card-foot .btn {
  position: relative;
  z-index: 1;
  margin-inline-start: auto;
}

.product-card .course-card-price {
  margin-inline-start: 0;
  font-size: var(--text-base);
}

/* ---------- Menu (a dropdown built on <details>) ---------- */

.menu {
  position: relative;
}

.menu-trigger {
  display: grid;
  place-items: center;
  border-radius: 50%;
  list-style: none;
  cursor: pointer;
}

.menu-trigger::-webkit-details-marker {
  display: none;
}

.menu-trigger:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: 50%;
}

.menu-content {
  position: absolute;
  top: calc(100% + 0.5rem);
  inset-inline-end: 0;
  z-index: 30;
  min-width: 14rem;
  padding: 0.375rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--popover);
  color: var(--popover-foreground);
  box-shadow: var(--shadow-md);
}

.menu-label {
  display: grid;
  padding: 0.5rem 0.625rem;
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

.menu-label strong {
  font-weight: 500;
}

.menu-label span {
  font-size: var(--text-xs);
  color: var(--muted-foreground);
}

.menu-separator {
  height: 1px;
  margin: 0.375rem -0.375rem;
  border: 0;
  background: var(--border);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
  text-align: start;
}

.menu-item:hover,
.menu-item:focus-visible {
  outline: none;
  background: var(--accent);
}

.menu-item svg {
  width: 1rem;
  height: 1rem;
  color: var(--muted-foreground);
}

/* ---------- Password field with a show/hide button ---------- */

.password {
  position: relative;
}

/* Password inputs are left-to-right, so the button sits at their right end in both directions */
.password .input {
  padding-right: 2.75rem;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 0.25rem;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-sm);
  color: var(--muted-foreground);
  translate: 0 -50%;
}

.password-toggle:hover {
  color: var(--foreground);
}

.password-toggle svg {
  width: 1rem;
  height: 1rem;
}

/* ---------- Form-level message ---------- */

.form-alert {
  padding: 0.75rem 0.875rem;
  border: 1px solid color-mix(in oklch, var(--destructive) 30%, transparent);
  border-radius: var(--radius-md);
  background: color-mix(in oklch, var(--destructive) 7%, transparent);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}

.form-alert[data-state="success"] {
  border-color: color-mix(in oklch, var(--success) 35%, transparent);
  background: color-mix(in oklch, var(--success) 9%, transparent);
}

/* ---------- Sidebar: the signed-in user ---------- */

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem;
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius-lg);
  background: var(--background);
  box-shadow: var(--shadow-xs);
}

.dark .sidebar-user {
  background: var(--sidebar-accent);
}

.sidebar-user-text {
  flex: 1;
  min-width: 0;
  line-height: var(--leading-heading);
}

.sidebar-user-name {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-email {
  display: block;
  font-size: var(--text-xs);
  color: var(--muted-foreground);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-card .btn + .btn {
  margin-top: 0.375rem;
}
