/* Course sub-nav. Scoped to .course-nav so page styles can't leak in.
   Layout: breadcrumb / [course switcher | section tabs] / semester pills. */
.course-nav {
  background: #fff;
  border-bottom: 1px solid #dbe3ee;
  font: 14px/1.4 Arial, sans-serif;
  color: #334155;
  position: relative;
}
.course-nav .cn-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas: "crumb crumb" "sw tabs" "sems sems";
  align-items: center;
}

/* breadcrumb */
.course-nav .cn-crumb {
  grid-area: crumb;
  padding: 8px 0 2px;
  font-size: 13px;
  color: #64748b;
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.course-nav .cn-crumb::-webkit-scrollbar { display: none; }
.course-nav .cn-crumb a { color: #475569; text-decoration: none; }
.course-nav .cn-crumb a:hover { color: #0b6ef6; text-decoration: underline; }
.course-nav .cn-crumb span { color: #1e293b; font-weight: 700; }

/* course switcher */
.course-nav .cn-sw { grid-area: sw; position: relative; padding: 4px 10px 4px 0; }
.course-nav .cn-sw summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid #b9c6d8;
  border-radius: 8px;
  background: #fff;
  color: #0f172a;
  font-size: 13px;
  font-weight: 700;
  -webkit-tap-highlight-color: transparent;
}
.course-nav .cn-sw summary::-webkit-details-marker { display: none; }
.course-nav .cn-sw summary::after {
  content: "";
  width: 6px; height: 6px;
  border-right: 2px solid #475569; border-bottom: 2px solid #475569;
  transform: rotate(45deg) translateY(-2px);
}
.course-nav .cn-sw[open] summary::after { transform: rotate(-135deg) translateY(-1px); }
.course-nav .cn-sw summary:hover { border-color: #0b6ef6; }
/* Click anywhere outside the open list closes it: a transparent full-screen layer that belongs to <summary>,
   so clicking it toggles the <details> shut. Sits above page content, below the list and the main navbar. */
.course-nav .cn-sw[open] summary::before { content: ""; position: fixed; inset: 0; z-index: 1000; cursor: default; }
.course-nav .cn-k { font-weight: 400; color: #64748b; }

.course-nav .cn-sw ul {
  position: absolute;
  left: 0;
  top: calc(100% + 2px);
  min-width: 230px;
  z-index: 1001; /* above the click-away layer and the page's sticky notice banner (999), below the main navbar */
  margin: 0;
  padding: 4px;
  list-style: none;
  background: #fff;
  border: 1px solid #b9c6d8;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, .12);
}
.course-nav .cn-sw li { margin: 0; padding: 0; list-style: none; }
.course-nav .cn-sw li a {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 6px;
  color: #0f172a;
  text-decoration: none;
}
.course-nav .cn-sw li a:hover { background: #eef4ff; color: #0b6ef6; }
.course-nav .cn-sw li.cn-head { padding: 6px 10px 4px; font-size: 12px; color: #64748b; }
.course-nav .cn-sw li.cn-cur { padding: 8px 10px; border-radius: 6px; background: #eef4ff; color: #0b6ef6; font-weight: 700; }
.course-nav .cn-sw li.cn-cur::before { content: "✓ "; }
.course-nav .cn-hint { color: #64748b; font-size: 12px; white-space: nowrap; }
.course-nav .cn-hint::before { content: "→ "; }

/* section tabs: one line, scrolls sideways when there isn't room */
.course-nav .cn-tabs {
  grid-area: tabs;
  position: relative;
  display: flex;
  flex-wrap: nowrap;
  gap: 0 2px;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.course-nav .cn-tabs::-webkit-scrollbar { display: none; }
.course-nav .cn-tabs li { margin: 0; padding: 0; list-style: none; flex: 0 0 auto; }
.course-nav .cn-tabs a {
  display: block;
  padding: 8px 12px;
  color: #475569;
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
}
.course-nav .cn-tabs a:hover { background: #f1f5fb; color: #0b6ef6; }
.course-nav .cn-tabs a.is-active { color: #0b6ef6; font-weight: 700; border-bottom-color: #0b6ef6; }

/* semester pills */
.course-nav .cn-sems {
  grid-area: sems;
  position: relative;
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  margin: 0;
  padding: 4px 0 8px;
  list-style: none;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.course-nav .cn-sems::-webkit-scrollbar { display: none; }
.course-nav .cn-sems li { margin: 0; padding: 0; list-style: none; flex: 0 0 auto; }
.course-nav .cn-sems a {
  display: block;
  padding: 3px 12px;
  border: 1px solid #b9c6d8;
  border-radius: 999px;
  background: #fff;
  color: #334155;
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}
.course-nav .cn-sems a:hover { border-color: #0b6ef6; color: #0b6ef6; background: #eef4ff; }
.course-nav .cn-sems a.is-active { background: #0b6ef6; border-color: #0b6ef6; color: #fff; font-weight: 700; }

.course-nav a:focus-visible, .course-nav summary:focus-visible { outline: 2px solid #0b6ef6; outline-offset: 2px; }

@media (max-width: 640px) {
  /* phones: no breadcrumb; course switcher sits top-left, every section is visible as a tap-friendly grid (no hidden scrolling) */
  .course-nav { border-top: 1px solid #dbe3ee; }
  .course-nav .cn-inner { padding: 0 12px; grid-template-columns: minmax(0, 1fr); grid-template-areas: "sw" "tabs" "sems"; }
  .course-nav .cn-crumb { display: none; }
  .course-nav .cn-sw { padding: 8px 0 2px; justify-self: start; }
  .course-nav .cn-tabs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
    gap: 6px;
    padding: 4px 0 6px;
    overflow: visible;
  }
  .course-nav .cn-tabs a {
    padding: 7px 4px;
    border: 1px solid #dbe3ee;
    border-radius: 8px;
    background: #f8fafc;
    text-align: center;
    font-size: 13px;
  }
  .course-nav .cn-tabs a:hover { background: #eef4ff; }
  .course-nav .cn-tabs a.is-active { background: #eef4ff; border-color: #0b6ef6; }
  .course-nav .cn-sems { flex-wrap: wrap; overflow: visible; padding: 0 0 8px; gap: 5px; }
  .course-nav .cn-sems a { padding: 3px 10px; font-size: 12.5px; }
}
@media print { .course-nav { display: none; } }
