/* ===== Lesson Unit: collapsible lesson on a collection page (native <details>) ===== */
/* Used in collection wrappers instead of mini-toc + lesson_meta.
   Old collections keep their markup and are not affected. */

:root {
  --unit_bg: #ffffff;
  --unit_bg_hover: #f8fafc;
  --unit_border: #e2e8f0;
  --unit_accent: #0E7490;        /* focus outline */
  /* lesson colors cycle in the same order as lesson_jigsaw / lesson_homework numbers */
  --unit_color_1: #0e7490;       /* teal   — lessons 1, 5, 9… */
  --unit_color_2: #7c3aed;       /* violet — lessons 2, 6, 10… */
  --unit_color_3: #d97706;       /* amber  — lessons 3, 7, 11… */
  --unit_color_4: #db2777;       /* pink   — lessons 4, 8, 12… */
  --unit_title: #1F2A44;
  --unit_date: #64748b;
  --unit_radius: 12px;
  --unit_scroll_offset: 80px;    /* space for the fixed site header when jumping to #lesson_N */
}

/* ---------- Card ---------- */
.lesson_unit {
  --unit_color: var(--unit_color_1);
  background: var(--unit_bg);
  border: 1px solid var(--unit_border);
  border-left: 5px solid var(--unit_color);
  border-radius: var(--unit_radius);
  margin: 0 0 14px 0;
  box-shadow: 0 2px 6px rgba(31, 42, 68, 0.06);
  scroll-margin-top: var(--unit_scroll_offset);
}

/* each lesson gets its own color: number badge and left stripe */
.lesson_unit:nth-of-type(4n+2) { --unit_color: var(--unit_color_2); }
.lesson_unit:nth-of-type(4n+3) { --unit_color: var(--unit_color_3); }
.lesson_unit:nth-of-type(4n+4) { --unit_color: var(--unit_color_4); }

.lesson_unit[open] {
  box-shadow: 0 4px 14px rgba(31, 42, 68, 0.1);
  margin-bottom: 28px;
}

/* ---------- Clickable row ---------- */
.lesson_unit_summary {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  cursor: pointer;
  user-select: none;
  list-style: none;
  border-radius: var(--unit_radius);
}

.lesson_unit_summary::-webkit-details-marker {
  display: none;
}

.lesson_unit_summary:hover {
  background: var(--unit_bg_hover);
}

.lesson_unit_summary:focus-visible {
  outline: 3px solid var(--unit_accent);
  outline-offset: 2px;
}

/* chevron on the right, rotates when open */
.lesson_unit_summary::after {
  content: "";
  flex: 0 0 auto;
  margin-left: auto;
  width: 22px;
  height: 22px;
  background: var(--unit_date);
  -webkit-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='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat center / contain;
  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='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat center / contain;
  transition: transform 0.2s ease;
}

.lesson_unit[open] > .lesson_unit_summary::after {
  transform: rotate(180deg);
}

/* ---------- Number badge ---------- */
.lesson_unit_number {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.05rem;
  color: #ffffff;
  background: var(--unit_color);
}

/* ---------- Title + date ---------- */
.lesson_unit_heading {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lesson_unit_title {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--unit_title);
}

.lesson_unit_date {
  font-size: 0.85rem;
  color: var(--unit_date);
}

/* ---------- Lesson content ---------- */
.lesson_unit_body {
  padding: 6px 16px 16px;
  border-top: 1px solid var(--unit_border);
}

/* ---------- Mobile adaptation ---------- */
@media (max-width: 480px) {
  .lesson_unit_summary {
    padding: 12px 12px;
    gap: 10px;
  }
  .lesson_unit_number {
    width: 32px;
    height: 32px;
    font-size: 0.95rem;
  }
  .lesson_unit_title {
    font-size: 1.05rem;
  }
  .lesson_unit_body {
    padding: 6px 6px 12px;
  }
}
