/**
 * Course shell - the coherent wrapper around a unit (Phase 1).
 *
 * Renders ONE structured block: top between-units nav, hero banner, intro,
 * loader, then the interactive unit body. Replaces the loose page blocks
 * (banner image / nav HTML / intro paragraph / button) that used to sit
 * disconnected above the shortcode.
 *
 * Neutral framing (white card, soft borders) so it frames any per-unit
 * accent colour without clashing.
 */

.course-shell {
  --shell-max: 1180px;
  --shell-accent: #2a8c8c;
  --shell-salmon: #e67e7e;
  --shell-ink: #2c3e50;
  --shell-line: #e6e9ee;
  --course-topnav-h: 60px;
  /* viewport offset that sticky elements anchor to (admin bar height) */
  --stick-top: 0px;
  font-family: 'Rubik', 'Varela Round', 'Segoe UI', Tahoma, sans-serif;
  direction: rtl;
  max-width: var(--shell-max);
  margin: 0 auto 40px;
  background: #fff;
  border: 1px solid var(--shell-line);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(20, 40, 60, 0.06);
  scroll-margin-top: 90px;
  /* NO overflow:hidden here - it would break the native position:sticky of
     the top nav and the curriculum rail. Corners are rounded per-piece. */
}

.admin-bar .course-shell { --stick-top: 32px; }
@media screen and (max-width: 782px) {
  .admin-bar .course-shell { --stick-top: 46px; }
}

/* ---------- Top nav (between units) ---------- */

.course-topnav {
  position: sticky;
  top: var(--stick-top);
  z-index: 1100;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--course-topnav-h);
  padding: 0 16px;
  background: #fff;
  border-bottom: 1px solid var(--shell-line);
  border-radius: 16px 16px 0 0;
}

.course-topnav-list {
  list-style: none;
  margin: 0;
  padding: 4px;
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1 1 auto;
  overflow-x: auto;
  scrollbar-width: thin;
}
.course-topnav-list::-webkit-scrollbar { height: 6px; }
.course-topnav-list::-webkit-scrollbar-thumb { background: #cdd5dd; border-radius: 3px; }

.course-topnav-item { flex: 0 0 auto; }

.course-topnav-item a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  padding: 5px 10px 5px 6px;
  border-radius: 999px;
  border: 1.5px solid transparent;
  transition: background-color .18s, border-color .18s, transform .18s;
  white-space: nowrap;
}
.course-topnav-item a:hover { background: #f2f5f7; transform: translateY(-1px); }

.course-topnav-item.is-active a {
  background: linear-gradient(45deg, var(--shell-accent), #34b0a0);
  border-color: var(--shell-accent);
  box-shadow: 0 3px 10px rgba(42, 140, 140, .25);
}
.course-topnav-item.is-active .course-topnav-text { color: #fff; }
.course-topnav-item.is-active .course-topnav-thumb { box-shadow: 0 0 0 2px #fff; }

.course-topnav-thumb {
  position: relative;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.course-topnav-thumb img {
  width: 100%; height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  filter: brightness(.88);
}
.course-topnav-num {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 13px;
  text-shadow: 0 0 3px rgba(0, 0, 0, .85);
  pointer-events: none;
}
.course-topnav-text {
  color: var(--shell-salmon);
  font-size: 15px;
  font-weight: 600;
}

/* ---------- Hero banner ---------- */

.course-hero {
  position: relative;
  height: clamp(170px, 26vw, 280px);
  background-color: #0e2230;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  display: flex;
  align-items: flex-end;
}
.course-hero-overlay {
  position: relative;
  width: 100%;
  padding: 26px 32px 20px;
  background: linear-gradient(to top, rgba(8, 20, 30, .85), rgba(8, 20, 30, .15) 70%, rgba(8, 20, 30, 0));
}
.course-hero-kicker {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .04em;
  color: #ffd9a8;
  margin-bottom: 6px;
}
.course-hero-title {
  margin: 0;
  color: #fff;
  font-size: clamp(1.6rem, 3vw, 2.3rem);
  font-weight: 800;
  line-height: 1.15;
  text-shadow: 0 2px 12px rgba(0, 0, 0, .4);
}
.course-hero-blocked {
  position: absolute;
  bottom: 14px;
  left: 20px;          /* physical left — bottom-left corner of the hero */
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  color: rgba(255,255,255,.85);
  background: rgba(0,0,0,.35);
  border: 1px solid rgba(255,255,255,.3);
  padding: 5px 12px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
  transition: background .18s, color .18s;
  white-space: nowrap;
}
.course-hero-blocked:hover { background: rgba(0,0,0,.6); color: #fff; }

/* ---------- Intro ---------- */

.course-guest-banner {
  margin: 0 32px 12px;
  padding: 14px 18px;
  background: #fff8e6;
  border: 1px solid #f0d78c;
  border-radius: 12px;
  color: #5c4a1a;
  font-size: 0.98rem;
  line-height: 1.55;
}
.course-guest-banner a {
  color: #b45309;
  font-weight: 700;
  text-decoration: underline;
}
.course-guest-banner p { margin: 0; }

.course-login-gate {
  max-width: 520px;
  margin: 48px auto;
  padding: 32px;
  text-align: center;
  background: #f8fafc;
  border: 1px solid var(--shell-line);
  border-radius: 16px;
}
.course-login-gate-btn {
  display: inline-block;
  margin-top: 12px;
  padding: 12px 24px;
  background: var(--shell-accent);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  border-radius: 999px;
}

.course-intro {
  padding: 22px 32px 4px;
  color: #44525f;
  font-size: 1.06rem;
  line-height: 1.7;
  max-width: 820px;
}

/* ---------- Integrated unit progress (replaces the standalone card) ---------- */

.course-progress {
  margin: 16px 32px 4px;
  background: #f7f9fb;
  border: 1px solid var(--shell-line);
  border-radius: 12px;
}
.course-progress-head {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 12px 16px;
  background: transparent;
  border: 0;
  cursor: pointer;
  font: inherit;
  text-align: inherit;
  border-radius: 12px;
}
.course-progress-head:hover { background: #eef2f6; }
.course-progress-label {
  flex: 0 0 auto;
  font-size: .9rem;
  font-weight: 700;
  color: var(--shell-ink);
}
.course-progress-track {
  flex: 1 1 auto;
  height: 10px;
  background: #e6ebef;
  border-radius: 999px;
  overflow: hidden;
}
.course-progress-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--shell-accent), #4bbf9a);
  transition: width .5s ease;
}
.course-progress-pct {
  flex: 0 0 auto;
  font-size: .9rem;
  font-weight: 700;
  color: var(--shell-accent);
  min-width: 42px;
  text-align: left;
}
.course-progress-chevron {
  flex: 0 0 auto;
  color: #9aa7b4;
  transition: transform .2s ease;
}
.course-progress-head[aria-expanded="true"] .course-progress-chevron { transform: rotate(180deg); }

/* Per-chapter breakdown (revealed on click) - compact chips, wrap across width */
.course-progress-detail {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px 14px;
  border-top: 1px solid var(--shell-line);
}
.cpr-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 10px;
  background: #fff;
  border: 1px solid var(--shell-line);
  border-radius: 999px;
  font-size: .9rem;
}
.cpr-mark {
  width: 18px; height: 18px;
  flex: 0 0 auto;
  border: 2px solid #cbd3db;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #fff;
}
.cpr-chip.is-done {
  background: color-mix(in srgb, var(--shell-accent) 9%, #fff);
  border-color: color-mix(in srgb, var(--shell-accent) 35%, #fff);
}
.cpr-chip.is-done .cpr-mark { background: var(--shell-accent); border-color: var(--shell-accent); }
.cpr-chip.is-done .cpr-mark::after { content: "✓"; }
.cpr-label { color: #44525f; }
.cpr-chip.is-done .cpr-label { color: var(--shell-ink); font-weight: 600; }
.cpr-pct { font-size: .8rem; font-weight: 700; color: #98a3af; }
.cpr-chip.is-done .cpr-pct { color: var(--shell-accent); }

/* ---------- Back to top (bare colored chevron, no circle/background) ---------- */

.course-backtotop {
  position: fixed;
  bottom: 28px;
  /* hug the content column's left edge (shell max 1180 -> half 590),
     never closer than 16px to the viewport edge on narrow screens */
  left: max(16px, calc(50% - 600px));
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  background: none;
  border: none;
  /* literal colours: the button is appended to <body>, outside the
     .course-shell scope where --shell-* vars are defined */
  color: #2a8c8c;
  cursor: pointer;
  filter: drop-shadow(0 2px 5px rgba(20, 40, 60, .22));
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity .25s ease, transform .25s ease, visibility .25s, color .2s ease;
}
.course-backtotop svg { display: block; width: 38px; height: 38px; }
.course-backtotop.is-visible { opacity: 1; visibility: visible; transform: translateY(0); }
.course-backtotop:hover { color: #e67e7e; transform: translateY(-4px); }

/* ---------- Loader ---------- */

/* The unit body keeps its normal flow (so the old units' inline layout JS
   measures correctly); the loader is an overlay on top of it that fades out
   once content has rendered. */
.course-unit-body {
  position: relative;
  min-height: 340px;
  border-radius: 0 0 16px 16px;
}
.course-loader {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: #fff;
  color: #7a8895;
  font-size: 1rem;
  transition: opacity .35s ease;
}
.course-loader .spinner {
  width: 34px; height: 34px;
  border: 3px solid #e2e8ee;
  border-top-color: var(--shell-accent);
  border-radius: 50%;
  animation: course-spin .8s linear infinite;
}
@keyframes course-spin { to { transform: rotate(360deg); } }
.course-shell.is-ready .course-loader { opacity: 0; pointer-events: none; }

/* ---------- Mobile ---------- */

@media (max-width: 800px) {
  .course-shell {
    border-radius: 0;
    border-left: none;
    border-right: none;
    margin-bottom: 20px;
  }
  .course-hero-img { height: 180px; }
  .course-hero-overlay { padding: 18px 18px 14px; }
  .course-intro { padding: 16px 18px 4px; font-size: 1rem; }
  .course-topnav-text { font-size: 13px; }
}
