:root {
  --header-h: 84px;
}
:root {
  --bg: #ffffff;
  --text: #0b1220;
  --muted: #5a6a85;
  --card: #f6f8fb;
  --brand: #368086;
  --brand-2: #276065;
  --ring: rgba(31, 111, 235, 0.35);
  --radius: 16px;
  --shadow: 0 10px 20px rgba(0, 0, 0, 0.06), 0 2px 6px rgba(0, 0, 0, 0.04);
}

/* ========== Header / Nav ========== */
/* ========== Header / Nav ========== */
.site-header {
  position: sticky;
  top: 0;

  z-index: 99999;
  background: #fff;
  border-bottom: 1px solid #eef2f8;
  overflow: visible;
  contain: none;
}

/* never clip menus */
.site-header,
.nav,
.desktop-menu {
  overflow: visible;
}

/* main row */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  gap: 12px;
  min-height: 56px;
}

/* brand */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background:
    url("/img/ngp-logo-white.png") center/cover no-repeat,
    linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: var(--shadow);
}
.brand-title {
  font-weight: 700;
}
/* desktop menu */
.desktop-menu {
  display: none;
}

.menu {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 0;
  padding: 0;
}
.menu > li {
  list-style: none;
  position: relative;
}
.menu > li > a,
.dd-btn {
  padding: 10px 8px;
  border-radius: 10px;
  font-weight: 600;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.menu > li > a:hover,
.dd-btn:hover {
  background: #f1f5ff;
}

/* ---------------- Dropdowns: structure + z-index ---------------- */
.has-dd,
.lang-dd {
  position: relative;
  z-index: 100001; /* above page content */
}
.has-dd .dropdown,
.lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; /* default for .dropdown */
  min-width: 240px;
  background: #fff;
  border: 1px solid #e8edf6;
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 8px;
  display: none;
  z-index: 100002; /* above header & content */
  max-height: min(60vh, 420px);
  overflow: auto; /* scroll inside the menu */
  -webkit-overflow-scrolling: touch;
  will-change: transform;
}
/* align the language menu to the button's right edge */
.lang-menu {
  right: 0;
  left: auto;
}

/* open on focus (keyboard) or when JS toggles .open */
.has-dd:focus-within .dropdown,
.has-dd.open .dropdown {
  display: block;
}
.lang-dd:focus-within .lang-menu,
.lang-dd.open .lang-menu {
  display: block;
}

/* items inside dropdowns */
.dropdown a {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  color: #334155;
}
.dropdown a:hover {
  background: #f7f9ff;
}

/* ---------------- Visual parity + caret for dropdown tabs ---------------- */
/* add a caret only to tabs that actually have dropdowns */
.menu > li.has-dd > a,
.menu > li.has-dd > button.dd-btn,
.lang-dd > .lang-btn {
  position: relative;
  padding-right: 18px; /* room for caret */
}

/* caret */
.menu > li.has-dd > a::after,
.menu > li.has-dd > button.dd-btn::after,
.lang-dd > .lang-btn::after {
  content: "▾";
  font-size: 12px;
  line-height: 1;
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.85;
  pointer-events: none;
}

/* optional: subtle active state if a menu is open */
.has-dd.open > a,
.has-dd.open > button.dd-btn,
.lang-dd.open > .lang-btn {
  background: #f1f5ff;
}

.has-dd.open > a::after,
.has-dd.open > button.dd-btn::after,
.lang-dd.open > .lang-btn::after {
  transform: translateY(-50%) rotate(180deg);
}
/* Make dropdown buttons look exactly like normal links */
.menu > li > a,
.menu > li > button.dd-btn {
  font: inherit;
  color: inherit;
  background: transparent;
  border: 0;
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 8px; /* same as links */
  border-radius: 10px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
}

/* Same hover style as links */
.menu > li > a:hover,
.menu > li > button.dd-btn:hover {
  background: #f1f5ff;
}

/* Add the small caret only to items that have dropdowns */
.menu > li.has-dd > a,
.menu > li.has-dd > button.dd-btn {
  padding-right: 18px; /* room for caret */
  position: relative;
}
.menu > li.has-dd > a::after,
.menu > li.has-dd > button.dd-btn::after {
  content: "▾";
  font-size: 12px;
  line-height: 1;
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.85;
  pointer-events: none;
}

/* Optional: show an active/pressed state when open */
.has-dd.open > a,
.has-dd.open > button.dd-btn {
  background: #f1f5ff;
}

/* actions (icons, lang, search, etc.) */
.actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid #e6edf7;
  background: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.icon-btn:hover {
  background: #f6f9ff;
}

/* hamburger */
.hamburger span {
  width: 18px;
  height: 2px;
  background: #1f2937;
  display: block;
  position: relative;
}
.hamburger span::before,
.hamburger span::after {
  content: "";
  position: absolute;
  left: 0;
  width: 18px;
  height: 2px;
  background: #1f2937;
}
.hamburger span::before {
  top: -6px;
}
.hamburger span::after {
  top: 6px;
}

/* search popover */
.search-pop {
  position: absolute;
  right: 0;
  left: 0;
}
.search-form {
  display: flex;
  gap: 8px;
  background: #fff;
  border: 1px solid #e8edf6;
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 10px;
  margin-top: 8px;
}
.search-form input {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid #e5eaf3;
  border-radius: 12px;
  outline: none;
}

/* buttons (shared chip style) */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid #dfe7f3;
  background: #fff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
  text-decoration: none;
}
.btn.primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  border: 0;
}
.btn[aria-disabled="true"] {
  pointer-events: none;
  opacity: 0.6;
}

/* mobile drawer */
.drawer {
  background: #fff;
  border-top: 1px solid #edf2fb;
}
.drawer ul {
  padding: 8px 0;
  margin: 0;
  list-style: none;
}
.drawer a {
  display: block;
  padding: 12px;
  border-radius: 10px;
  color: #334155;
}
.drawer .subtle {
  padding-left: 24px;
}

/* sticky subnav/tabs live under the header & menus */
.subnav,
.tabs-sticky,
.course-tabs,
.sticky-subnav {
  position: sticky;
  top: var(--header-h);
  z-index: 1;
}

/* show desktop menu ≥1024px */
@media (min-width: 1024px) {
  .desktop-menu {
    display: block;
  }
  .hamburger {
    display: none;
  }
}

/* ========== Base ========== */
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
}
body {
  font-family:
    Inter,
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    Arial,
    "Noto Sans",
    sans-serif;
  color: var(--text);
  background: var(--bg);
}
a {
  color: #368086;
  text-decoration: none;
}
.container {
  width: min(1200px, 92%);
  margin-inline: auto;
}
/* keep page wrappers from clipping dropdowns */
.container,
.nav,
.desktop-menu {
  overflow: visible !important;
}

.muted {
  color: var(--muted);
}
.visually-hidden {
  position: absolute !important;
  height: 1px;
  width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
  border: 0;
  padding: 0;
  margin: -1px;
}

/* ========== Breadcrumbs / Titles ========== */
.breadcrumbs {
  font-size: 13px;
  color: var(--muted);
  margin: 8px 0 6px;
}
.breadcrumbs a {
  color: inherit;
}
.breadcrumbs a:hover {
  text-decoration: underline;
}
.page-title {
  margin: 10px 0 14px;
}

/* ========== Cards / Layout ========== */
.card {
  background: #fff;
  border: 1px solid #eaf0f8;
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 10px;
  margin-bottom: 15px;
}
.card h3 {
  margin: 5px 0 6px;
  font-size: 16px;
}
.card .content {
  padding: 8px 14px;
  color: #1b2a3a;
  line-height: 1.6;
}
.card .content p {
  margin: 8px 0;
}
.card .content p:first-child {
  margin-top: 1px;
}

#mainCol .card {
  margin-bottom: 18px;
}
#mainCol .card:last-of-type {
  margin-bottom: 0;
}

/* Preface body */
#prefaceContent {
  color: var(--text);
}
#prefaceContent .muted {
  color: var(--muted);
}

.note {
  background: var(--card);
  border-radius: 12px;
  padding: 12px;
}

/* buttons row */
.actions-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

/* ========== Prev / Next ========== */
.prevnext {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0 28px;
}
.pn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #fff;
  border: 1px solid #eaf0f8;
  border-radius: 12px;
  box-shadow:
    0 6px 14px rgba(0, 0, 0, 0.05),
    0 1px 3px rgba(0, 0, 0, 0.05);
  padding: 12px 14px;
  text-decoration: none;
}
.pn .ico {
  flex: 0 0 auto;
}
.pn .txt {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.pn .txt.right {
  text-align: right;
  align-items: flex-end;
}
.pn small {
  display: block;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 4px;
}
.pn b {
  font-weight: 600;
}
.pn.is-disabled {
  pointer-events: none;
  opacity: 0.55;
}
@media (max-width: 480px) {
  .prevnext {
    grid-template-columns: 1fr;
  }
}

/* ========== Resources chips ========== */
#resourcesList {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
#resourcesList .btn {
  padding: 8px 12px;
  border-radius: 999px;
}

/* ========== Footer ========== */
.site-footer {
  padding: 28px 0 40px;
  color: var(--muted);
  border-top: 1px solid #eef2f8;
  margin-top: 36px;
}
.footer-inner {
  text-align: center;
  font-size: 12px;
}

/* ========== TOC ========== */
#tocList {
  counter-reset: item;
  margin: 0;
  padding: 0;
  list-style: none;
}
#tocList li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 6px 0;
}
#tocList li::before {
  counter-increment: item;
  content: counter(item) ".";
  color: var(--muted);
  width: 22px;
  text-align: right;
  flex: none;
}
#tocList a {
  font-weight: 600;
  line-height: 1.35;
}
#tocList a.active {
  font-weight: 700;
  text-decoration: underline;
}

/* ========== Iframes ========== */
#pptFrame,
#extractYt {
  margin-top: 10px;
  width: 100%;
  aspect-ratio: 16/9;
  border: 0;
  border-radius: 12px;
}

/* ========== Courses Grid ========== */
.courses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
  margin: 18px 0;
}
.course-card {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.course-card h4 {
  margin: 0;
  font-size: 18px;
}
.course-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}
.course-card .meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}

/* ========== Course Structure ========== */
.module {
  margin: 16px 0;
}
.module h3 {
  font-size: 18px;
  border-left: 4px solid var(--brand);
  padding-left: 10px;
}
.topic-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.topic-list li {
  padding: 10px 14px;
  border-top: 1px solid #eef2f8;
}
.topic-list li:first-child {
  border-top: 0;
}
.topic-list a {
  color: var(--text);
}
.topic-list a:hover {
  color: var(--brand);
}

/* ========== Language Dropdown ========== */
.lang-dd {
  position: relative;
}
.lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.3px;
  color: var(--brand);
  background: #fff;
  border: 1px solid #d6e0f0;
  border-radius: 9999px;
  padding: 8px 12px 8px 14px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition:
    background 0.2s,
    color 0.2s,
    border-color 0.2s,
    transform 0.15s;
}
.lang-btn .chev {
  opacity: 0.9;
}
.lang-btn:hover {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  transform: translateY(-1px);
}
.lang-btn:active {
  transform: translateY(0);
}
.lang-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}
.lang-menu {
  position: absolute;
  right: 0;
  left: auto;
  top: calc(100% + 8px);
  min-width: 180px;
  background: #fff;
  border: 1px solid #e6edf7;
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
  margin: 0;
  list-style: none;
  z-index: 10001;
}
.lang-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  color: #162433;
}
.lang-item[aria-selected="true"] {
  background: var(--card);
}
.lang-item:hover,
.lang-item:focus {
  background: var(--card);
  outline: none;
}
@media (max-width: 600px) {
  .lang-btn {
    font-size: 12px;
    padding: 6px 10px;
  }
  .lang-menu {
    min-width: 160px;
  }
}
@media (prefers-color-scheme: dark) {
  .lang-btn {
    background: #0f1622;
    color: #e7eef7;
    border-color: #1b2431;
  }
  .lang-menu {
    background: #0f1622;
    border-color: #1b2431;
  }
  .lang-item {
    color: #e7eef7;
  }
  .lang-item[aria-selected="true"],
  .lang-item:hover {
    background: #121a28;
  }
}

/* ========== Home hero ========== */
.hero {
  padding: 24px 0;
}
.hero-wrap {
  display: grid;
  gap: 24px;
  align-items: center;
}
.hero-card {
  background: #fff;
  border: 1px solid #eaf0f8;
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.hero-card iframe {
  width: 100%;
  aspect-ratio: 16/9;
  border: 0;
  border-radius: 12px;
}
@media (min-width: 980px) {
  .hero-wrap {
    grid-template-columns: 1.2fr 0.8fr;
  }
}

/* ========== Topic two-column layout ========== */
.topic-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 22px;
  align-items: start;
}
@media (max-width: 1024px) {
  .topic-layout {
    grid-template-columns: 1fr;
  }
}

/* ----- SIDEBAR (critical) ----- */
.sidebar {
  display: grid;
  gap: 14px;
}
.sidebar .card {
  margin: 0;
}
@media (min-width: 1025px) {
  .sidebar {
    position: sticky;
    top: calc(var(--header-h) + 12px);
    align-self: start;
    z-index: 1;
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
}

/* Header nav alignment polish */
.header-nav > li > a,
.header-nav > li > button {
  font-size: 14px;
  line-height: 1;
  padding: 10px 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  vertical-align: middle;
  border: 0;
  background: transparent;
  color: inherit;
}
.header-nav > li.has-dropdown > button {
  transform: none !important;
  box-shadow: none !important;
  position: relative;
  top: 0;
}
.header-nav > li > a:hover,
.header-nav > li > button:hover {
  opacity: 0.85;
}
.header-nav .chevron {
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
}

/* Responsive YouTube embeds from editor/preface */
.prose iframe.yt-embed,
.content iframe.yt-embed {
  display: block;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 16/9;
  height: auto;
  border: 0;
  border-radius: 12px;
}
.prose .yt-wrap {
  position: relative;
  width: 100%;
}
.prose .yt-wrap::before {
  content: "";
  display: block;
  padding-top: 56.25%;
}
.prose .yt-wrap > iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 12px;
}

/* Generic safe defaults */
img,
svg,
video,
canvas,
iframe {
  max-width: 100%;
  height: auto;
}

/* Content images */
#prefaceContent img,
#extractTranscript img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto 1rem;
  border-radius: 8px;
}

/* Topic cover (single definition) */
.topic-cover {
  display: block;
  width: min(100%, 320px);
  height: auto;
  margin: 0 auto 1rem;
  border-radius: 12px;
}

/* Guard horizontal overflow from 3rd-party embeds */
main,
.container,
body {
  overflow-x: hidden;
}

/* Always reserve space for the page scrollbar so it never overlays the header */
html {
  scrollbar-gutter: stable both-edges;
}
@supports not (scrollbar-gutter: stable) {
  html {
    overflow-y: scroll;
  }
}
/* Course modules grid */
.module-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)); /* 3-up on desktop */
  gap: 24px;
  margin: 18px 0 40px;
}

@media (max-width: 1100px) {
  .module-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 700px) {
  .module-grid {
    grid-template-columns: 1fr;
  }
}

/* Cards inside the grid */
.module-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  padding: 16px;
}

/* Image area (shows placeholder even if image hides) */
.module-media {
  width: 100%;
  height: 170px;
  border-radius: 12px;
  overflow: hidden;
  background: #f5f7fa;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
.module-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.module-title {
  font-size: 1.05rem;
  margin: 4px 0 12px;
}
