/* Masir Course Rail — second fixed right rail, course-details only (Masir tokens, Morshed metrics).
   Enqueued after `masir-shell`; depends on it for tokens + the 256px primary sidebar.
   Sits just inside the shell (right:256px). Everything is gated on body.masir-has-rail,
   which the rail's own JS adds ONLY when >=1 on-page anchor matched — so courses without
   the journey structure get neither the rail nor the wider offset.
   Breakpoints: >=1200 vertical rail (+512px offset); 1024-1199 & <=1023 a compact top bar. */

/* ----- Vertical rail (hidden until >=1200 + has-rail) ----- */
.masir-rail {
  position: fixed;
  inset-block: 0;
  right: 256px; left: auto;
  width: 256px;
  z-index: 49;
  display: none;
  flex-direction: column;
  background: var(--background);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  font-family: inherit;
}
.masir-rail-svg { width: 16px; height: 16px; }
.masir-rail-ic { display: inline-flex; flex: none; }

/* head */
.masir-rail-head {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
}
.masir-rail-kicker {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted-foreground);
  margin-bottom: 6px;
}
.masir-rail-kicker .masir-rail-svg { width: 14px; height: 14px; }
.masir-rail-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.45;
  color: var(--foreground);
}

/* nav */
.masir-rail-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 8px;
  overflow-y: auto;
}

/* stage row */
.masir-rail-stagebtn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  text-align: start;
  color: var(--muted-foreground);
  font-family: inherit;
  transition: background-color .15s, color .15s;
}
.masir-rail-stagebtn:hover { background: var(--secondary); }
.masir-rail-stagetxt {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.masir-rail-stagename {
  font-size: 14px;
  font-weight: 600;
  color: var(--foreground);
}
.masir-rail-stagesub {
  font-size: 11px;
  color: var(--muted-foreground);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.masir-rail-chev {
  display: inline-flex;
  flex: none;
  color: var(--muted-foreground);
  transform: rotate(90deg);
  transition: transform .2s ease;
}
.masir-rail-stage.is-open > .masir-rail-stagebtn { background: var(--secondary); }
.masir-rail-stage.is-open .masir-rail-ic { color: var(--primary); }
.masir-rail-stage.is-open .masir-rail-chev { transform: rotate(0); color: var(--primary); }

/* sub-items (collapsed unless the stage is open) */
.masir-rail-subs {
  position: relative;
  list-style: none;
  margin: 2px 0 6px;
  padding: 0 30px 0 4px;
  display: none;
  flex-direction: column;
  gap: 1px;
}
.masir-rail-stage.is-open .masir-rail-subs { display: flex; }
.masir-rail-subs::before {
  content: "";
  position: absolute;
  inset-inline-start: 19px;
  top: 4px; bottom: 4px;
  width: 1.5px;
  background: var(--border);
}
.masir-rail-sub {
  display: block;
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 12.5px;
  color: var(--muted-foreground);
  text-decoration: none;
  transition: background-color .15s, color .15s;
}
.masir-rail-sub:hover { background: var(--secondary); color: var(--foreground); }
.masir-rail-sub.is-active {
  background: var(--secondary);
  color: var(--primary);
  font-weight: 600;
}

/* ----- Compact top bar (tablet/mobile) ----- */
.masir-rail-bar {
  display: none;
  position: fixed;
  align-items: stretch;
  gap: 4px;
  height: 46px;
  padding: 6px 10px;
  background: var(--background);
  border-bottom: 1px solid var(--border);
  z-index: 39;
  overflow-x: auto;
}
.masir-rail-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 13px;
  white-space: nowrap;
  color: var(--muted-foreground);
  text-decoration: none;
}
.masir-rail-chip .masir-rail-svg { width: 15px; height: 15px; }
.masir-rail-chip.is-active {
  background: var(--secondary);
  color: var(--primary);
  font-weight: 600;
}

/* ----- Desktop (>=1200px): show the rail + widen the content offset ----- */
@media (min-width: 1200px) {
  body.masir-has-rail .masir-rail { display: flex; }
  body.masir-has-rail #wrap { margin-right: 512px; }
  body.masir-has-rail .masir-footer { margin-right: 512px; }
}

/* ----- Tablet (1024-1199px): shell is a vertical rail (right:256), bar fills content ----- */
@media (min-width: 1024px) and (max-width: 1199px) {
  body.masir-has-rail .masir-rail-bar {
    display: flex;
    top: 0; right: 256px; left: 0;
  }
  body.masir-has-rail #wrap { padding-block-start: 46px; }
}

/* ----- Mobile (<=1023px): shell topbar is fixed at top:0 (56px); bar sits below it ----- */
@media (max-width: 1023px) {
  body.masir-has-rail .masir-rail-bar {
    display: flex;
    top: 56px; right: 0; left: 0;
  }
  body.masir-has-rail #wrap { padding-block-start: 102px; }
}
