/* ---------- app shell ---------- */

#app {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* ==========================================================
   Sidebar
   ========================================================== */

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--nav-bg);
  color: var(--nav-text);
  display: flex;
  flex-direction: column;
  height: 100dvh;
  border-right: 1px solid var(--nav-line);
  z-index: 40;
}

.side-head {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--nav-line);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 16px;
  min-width: 0;
}
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: url(/assets/brand-logo.jpg);
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  display: grid;
  place-items: center;
  color: #241a04;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(217, 119, 6, .3);
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: .1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-sub { font-size: 11px; color: var(--nav-text-2); margin-top: -1px; }

.search-wrap { position: relative; }
.search-wrap svg {
  position: absolute;
  left: 11px; top: 50%;
  transform: translateY(-50%);
  color: var(--nav-text-2);
  pointer-events: none;
}
.search-wrap input {
  width: 100%;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--nav-line);
  color: var(--nav-text);
  padding: 9px 34px 9px 34px;
  border-radius: var(--r-sm);
  font-size: 13px;
  outline: none;
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.search-wrap input::placeholder { color: var(--nav-text-2); }
.search-wrap input:focus {
  border-color: var(--brand-400);
  background: rgba(255, 255, 255, .08);
}
.search-clear {
  position: absolute;
  right: 6px; top: 50%;
  transform: translateY(-50%);
  background: none; border: 0;
  color: var(--nav-text-2);
  cursor: pointer;
  padding: 5px;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
}
.search-clear:hover { color: var(--nav-text); background: var(--nav-hover); }

.side-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px 24px;
  scrollbar-color: var(--nav-line) transparent;
}
.side-scroll::-webkit-scrollbar-thumb { background-color: var(--nav-line); }

/* --- chapter rows --- */
.chapter-block { margin-bottom: 4px; }

.chapter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  cursor: pointer;
  border-radius: var(--r-md);
  transition: background .15s var(--ease);
  width: 100%;
  background: none;
  border: 0;
  text-align: left;
  color: inherit;
}
.chapter-row:hover { background: var(--nav-hover); }
.chapter-row[aria-expanded="true"] { background: rgba(255, 255, 255, .04); }

.chapter-num {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--nav-text-2);
  flex-shrink: 0;
  padding-top: 1px;
}
.chapter-title {
  font-size: 13px;
  font-weight: 600;
  flex: 1;
  line-height: 1.35;
  min-width: 0;
}
.chev {
  flex-shrink: 0;
  opacity: .6;
  transition: transform .2s var(--ease);
  display: grid; place-items: center;
}
.chapter-row[aria-expanded="true"] .chev { transform: rotate(90deg); }

.chapter-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px 8px 34px;
}
.chapter-progress-track {
  height: 3px;
  flex: 1;
  background: var(--nav-line);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.chapter-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-500), var(--accent-400));
  border-radius: var(--r-pill);
  transition: width .4s var(--ease);
}
.chapter-progress-fill.complete { background: linear-gradient(90deg, #10b981, #34d399); }
.chapter-pct {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--nav-text-2);
  min-width: 30px;
  text-align: right;
}

.slide-list {
  padding: 0 4px 8px 20px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  position: relative;
}
/* the little rail that ties a chapter's slides together */
.slide-list::before {
  content: '';
  position: absolute;
  left: 18px; top: 2px; bottom: 10px;
  width: 1px;
  background: var(--nav-line);
}

.slide-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  color: #b8c1d1;
  cursor: pointer;
  transition: background .13s var(--ease), color .13s var(--ease);
  width: 100%;
  background: none;
  border: 0;
  text-align: left;
  position: relative;
}
.slide-row:hover { background: var(--nav-hover); color: #fff; }
.slide-row.active {
  background: linear-gradient(90deg, var(--brand-600), var(--brand-500));
  color: #fff;
  box-shadow: 0 3px 10px rgba(79, 70, 229, .35);
}
.slide-row .stype { opacity: .7; flex-shrink: 0; display: grid; place-items: center; }
.slide-row.active .stype { opacity: 1; }
.slide-row .label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.slide-row .check { flex-shrink: 0; color: #34d399; display: grid; place-items: center; }
.slide-row.active .check { color: #fff; }

.no-results {
  padding: 20px 12px;
  font-size: 12.5px;
  color: var(--nav-text-2);
  text-align: center;
  line-height: 1.6;
}

.side-foot {
  padding: 11px 14px;
  border-top: 1px solid var(--nav-line);
  font-size: 11px;
  color: var(--nav-text-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}
.side-foot-actions { display: flex; align-items: center; gap: 4px; }
.side-icon-btn {
  background: none;
  border: 0;
  color: var(--nav-text-2);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.side-icon-btn:hover { background: var(--nav-hover); color: var(--nav-text); }
.side-icon-btn.on { color: var(--accent-400); }

/* ==========================================================
   Main column
   ========================================================== */

.main {
  flex: 1;
  min-width: 0;
  height: 100dvh;
  overflow-y: auto;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  position: relative;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-shrink: 0;
}

/* On a wide screen the sidebar is part of the layout, and the same button
   collapses it — worth having on a laptop, where hiding 300px of navigation
   is what gives the API console's two columns room to breathe. */
@media (min-width: 1024px) {
  .menu-btn { display: grid; }
  body.nav-collapsed .sidebar { display: none; }
}

.breadcrumb {
  font-size: 12.5px;
  color: var(--text-2);
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 7px;
}
.breadcrumb .crumb-chapter {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 40%;
}
.breadcrumb .crumb-sep { color: var(--text-3); flex-shrink: 0; }
.breadcrumb .crumb-slide {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.slide-counter {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 4px 10px;
  border-radius: var(--r-pill);
  white-space: nowrap;
}

/* thin progress bar pinned under the topbar */
.topbar-progress {
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: transparent;
}
.topbar-progress > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--brand-500), var(--accent-400));
  transition: width .4s var(--ease);
}

.content-wrap {
  flex: 1;
  padding: 26px 28px 40px;
  display: flex;
  justify-content: center;
}
.content-inner {
  width: 100%;
  max-width: 1080px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ==========================================================
   Bottom nav
   ========================================================== */

.nav-bottom {
  position: sticky;
  bottom: 0;
  padding: 14px 28px 18px;
  background: linear-gradient(180deg, transparent, var(--bg) 45%);
  z-index: 15;
  flex-shrink: 0;
}
.nav-bottom-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.nav-hint {
  font-size: 11.5px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 6px;
}
.kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  background: var(--surface);
  border-radius: 5px;
  padding: 1px 5px;
  color: var(--text-2);
}

/* ==========================================================
   Responsive — sidebar becomes an off-canvas drawer
   ========================================================== */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 19, .5);
  backdrop-filter: blur(2px);
  z-index: 35;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s var(--ease);
}

@media (max-width: 1023px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    transform: translateX(-100%);
    transition: transform .28s var(--ease);
    box-shadow: var(--shadow-xl);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .scrim { opacity: 1; pointer-events: auto; }

  .menu-btn { display: grid; }
  .content-wrap { padding: 18px 16px 32px; }
  .nav-bottom { padding: 12px 16px 16px; }
  .topbar { padding: 0 14px; }
  .nav-hint { display: none; }
}

@media (max-width: 640px) {
  :root { --sidebar-w: 86vw; --topbar-h: 56px; }
  body { font-size: 14.5px; }
  .slide-counter { display: none; }
  .breadcrumb .crumb-chapter { max-width: 100%; }
  .breadcrumb .crumb-sep, .breadcrumb .crumb-slide { display: none; }
}

/* Which course the sidebar is currently showing, and the way back up to it. */
.side-course {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  font: inherit;
  color: var(--text-2);
  text-align: left;
  transition: background .12s var(--ease);
}
.side-course:hover { background: var(--surface-2); color: var(--text); }
.side-course-text { display: flex; flex-direction: column; min-width: 0; }
.side-course-kicker {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-3);
}
.side-course-name {
  font-size: 12.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================
   Right rail — Recent updates
   ----------------------------------------------------------
   The mirror of the sidebar: that one is where you are in the course, this
   one is what has changed in it. A flex sibling of .main rather than an
   overlay, so it takes its own width instead of covering what you are reading.
   ========================================================== */

.rightbar {
  width: var(--rightbar-w, 300px);
  flex: 0 0 var(--rightbar-w, 300px);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--line);
  z-index: 30;
}

/* Collapsed it keeps a strip rather than vanishing: a panel with no way back
   is a panel nobody finds again. */
.rightbar.collapsed {
  width: 46px;
  flex-basis: 46px;
  align-items: center;
  padding-top: 12px;
  background: transparent;
}

.hl-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 15px 12px 14px 16px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.hl-head h2 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
/* The star is the one bit of colour in the header, so the panel reads as
   curated rather than as another list. */
.hl-head h2 svg { color: var(--brand); }

.upd-toggle {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: none;
  color: var(--text-3);
  cursor: pointer;
  flex-shrink: 0;
  transition: background .12s var(--ease), color .12s var(--ease);
}
.upd-toggle:hover { background: var(--surface-2); color: var(--text); border-color: var(--line); }

.hl-feed {
  list-style: none;
  margin: 0;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  overflow-y: auto;
}

.hl-card {
  width: 100%;
  display: flex;
  gap: 11px;
  padding: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), transform .15s var(--ease);
}
.hl-card:hover:not(:disabled) {
  border-color: var(--brand);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.hl-card:disabled { cursor: default; opacity: .7; }

.hl-thumb {
  position: relative;
  flex-shrink: 0;
  width: 68px;
  aspect-ratio: 16 / 10;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface-3);
  display: grid;
  place-items: center;
}
.hl-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hl-glyph { color: var(--brand-text); }
.hl-thumb.api { background: var(--brand-soft); }

.hl-badge {
  position: absolute;
  right: 3px;
  bottom: 3px;
  display: grid;
  place-items: center;
  padding: 2px;
  border-radius: 50%;
  background: var(--ok-fg);
  color: #fff;
}

.hl-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; justify-content: center; }
.hl-kicker {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Two lines then ellipsis: deck titles vary wildly and a card that grows to
   fit the longest one wrecks the column. */
.hl-title {
  font-size: 12.5px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.hl-meta { font-size: 11px; color: var(--text-3); }

.hl-bar {
  display: block;
  height: 3px;
  margin-top: 4px;
  border-radius: 2px;
  background: var(--surface-3);
  overflow: hidden;
}
.hl-bar > i { display: block; height: 100%; background: var(--brand); border-radius: 2px; }
.hl-bar > i.complete { background: var(--ok-fg); }

.hl-empty {
  padding: 28px 20px;
  text-align: center;
  color: var(--text-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.hl-empty-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-3);
}
.hl-empty strong { font-size: 13px; color: var(--text-2); }
.hl-empty p { font-size: 11.5px; line-height: 1.5; margin: 0; }

/* Below this there is no room for a third column beside the sidebar and the
   content, and squeezing the reading view is the wrong trade. */
@media (max-width: 1279px) {
  .rightbar { display: none; }
}
