/* ============================================================
 * HEADER — Abhiyantriki Forge
 *   Row 1: Glass navy bar — hamburger · ⚡ brand · big search · theme · GitHub
 *   Row 2: 5-item mega-nav with hover dropdowns + amber active underline
 *
 *   Design language: Stripe Docs / Vercel Docs / Linear / Anthropic Docs.
 *   Typography: Inter.  Active accent: amber #F59E0B.  Brand accent: #3B82F6.
 * ============================================================ */

/* ====================================================================
 * Row 1 — Glass header
 * ==================================================================== */

.md-header {
  background: rgba(10, 15, 30, 0.85) !important;
  color: #F1F5F9 !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
  box-shadow: 0 4px 24px -8px rgba(0, 0, 0, 0.45) !important;
  position: sticky !important;
  top: 0 !important;
  z-index: 100 !important;
  height: 3.5rem !important;            /* 56px */
  overflow: visible;
  -webkit-backdrop-filter: blur(20px) saturate(160%) !important;
  backdrop-filter: blur(20px) saturate(160%) !important;
  transition: background 0.22s ease, box-shadow 0.22s ease;
}
.md-header--shadow,
.md-header--lifted {
  box-shadow: 0 8px 28px -8px rgba(0, 0, 0, 0.55) !important;
}

.md-header__inner {
  max-width: 1440px !important;
  margin: 0 auto !important;
  padding: 0 1.25rem !important;
  height: 3.5rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

/* --- Strip unwanted Material defaults --- */
.md-header__topic + .md-header__topic { display: none !important; }
.md-header__ellipsis,
.md-header__topic .md-ellipsis:not(:first-child) { display: none !important; }
.md-source__repository,
.md-source__facts { display: none !important; }

/* --- Hamburger menu (Material's __drawer toggle) — keep visible always --- */
.md-header__button.md-icon[for="__drawer"],
label.md-header__button[for="__drawer"] {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  margin: 0 0.25rem 0 -0.25rem !important;
  padding: 0;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.85) !important;
  background: transparent;
  transition: background 0.18s ease, color 0.18s ease;
}
label.md-header__button[for="__drawer"]:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #FFFFFF !important;
}

/* --- Material's default site-icon logo: hide (we render our own bolt) --- */
.md-header__button.md-logo { display: none !important; }

/* --- Brand: "⚡ Abhiyantriki Forge" — white + blue --- */
.md-header__title {
  position: relative;
  font-weight: 700 !important;
  font-size: 1.02rem !important;
  color: #FFFFFF !important;
  letter-spacing: -0.015em;
  margin: 0 !important;
  flex-shrink: 0;
  padding-left: 2.1rem;
  height: 100%;
  display: flex;
  align-items: center;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}
.md-header__title::before {
  content: "⚡";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.40em;
  color: #F59E0B;                       /* amber bolt */
  filter: drop-shadow(0 2px 8px rgba(245, 158, 11, 0.55));
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.md-header__title:hover::before {
  transform: translateY(-50%) rotate(18deg) scale(1.15);
}

/* Wrap the actual title text and split into white + blue halves via JS. */
.md-header__topic > .md-ellipsis,
.md-header__title .md-ellipsis {
  color: #FFFFFF !important;
  font-weight: 700;
}
.md-header__title .md-ellipsis .brand-accent {
  color: #3B82F6;                       /* blue "Forge" */
  margin-left: 0.18em;
}

/* ====================================================================
 * Search — prominent rounded pill
 * ==================================================================== */

.md-search {
  flex: 1 1 0;
  max-width: 600px;
  margin: 0 auto;
}
.md-search__form {
  background: rgba(255, 255, 255, 0.08) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  border-radius: 999px;                 /* rounded-full pill */
  height: 2.4rem;
  position: relative;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.22s ease,
    transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.md-search__form:hover {
  background: rgba(255, 255, 255, 0.12) !important;
  border-color: rgba(255, 255, 255, 0.22) !important;
}
.md-search__form:focus-within,
[data-md-toggle="search"]:checked ~ .md-header .md-search__form {
  background: #FFFFFF !important;
  border-color: #3B82F6 !important;
  box-shadow:
    0 0 0 4px rgba(59, 130, 246, 0.18),
    0 12px 32px -8px rgba(0, 0, 0, 0.42);
}
.md-search__input {
  background: transparent !important;
  color: #FFFFFF !important;
  font-size: 0.9rem;
  padding-left: 2.65em !important;
  padding-right: 3.4em !important;
  height: 100%;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}
.md-search__input::placeholder { color: rgba(255, 255, 255, 0.55); }
.md-search__icon[for="__search"] {
  color: rgba(255, 255, 255, 0.55);
  left: 0.85em !important;
  width: 1.05rem;
  height: 1.05rem;
}

[data-md-toggle="search"]:checked ~ .md-header .md-search__input,
[data-md-toggle="search"]:checked ~ .md-header .md-search__input::placeholder {
  color: var(--color-text-primary) !important;
}
[data-md-toggle="search"]:checked ~ .md-header .md-search__icon[for="__search"] {
  color: var(--color-text-tertiary);
}

/* ⌘K chip */
.md-search__form::after {
  content: "⌘K";
  position: absolute;
  right: 0.55em;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 0.66rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 5px;
  padding: 0.18em 0.5em;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
.md-search__form:focus-within::after,
[data-md-toggle="search"]:checked ~ .md-header .md-search__form::after { opacity: 0; }

/* ====================================================================
 * Action buttons — theme toggle + GitHub
 * ==================================================================== */

.md-header__button[hidden] { display: none !important; }
form[data-md-component="palette"] input[hidden] + label { display: none !important; }

.md-header__button:not([hidden]):not([for="__drawer"]) {
  color: rgba(255, 255, 255, 0.85) !important;
  width: 2.25rem;
  height: 2.25rem;
  margin: 0 !important;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: transparent;
  transition:
    color 0.18s ease,
    background 0.18s ease,
    transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.md-header__button:not([hidden]):not([for="__drawer"]):hover {
  color: #FFFFFF !important;
  background: rgba(255, 255, 255, 0.08);
}
.md-header__button:not([hidden]) svg {
  width: 1.05rem;
  height: 1.05rem;
  fill: currentColor;
}

[data-md-component="palette"] .md-header__button:hover svg {
  transform: rotate(-22deg) scale(1.12);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* GitHub source chip */
.md-header__source {
  flex: 0 0 auto !important;
  width: auto !important;
  margin-left: 0.4rem !important;
  padding: 0.4rem 0.55rem !important;
  border-radius: 8px !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  background: rgba(255, 255, 255, 0.04) !important;
  display: flex;
  align-items: center;
  gap: 0;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.md-header__source:hover {
  background: rgba(59, 130, 246, 0.16) !important;
  border-color: rgba(59, 130, 246, 0.45) !important;
}
.md-header__source .md-source__icon svg {
  fill: #FFFFFF;
  width: 1.05rem;
  height: 1.05rem;
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.md-header__source:hover .md-source__icon svg {
  transform: rotate(360deg);
  fill: #93C5FD;
}

/* ====================================================================
 * Row 2 — Mega-nav with hover dropdowns
 * ==================================================================== */

.edu-meganav {
  background: rgba(15, 23, 42, 0.92);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  position: sticky !important;
  top: 3.5rem !important;
  z-index: 99 !important;
  height: 2.75rem;
  overflow: visible;
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
}

.edu-meganav__inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 1.25rem;
  height: 2.75rem;
  display: flex;
  align-items: stretch;
  gap: 0.4rem;
  /* CRITICAL: do NOT use overflow-x: auto/scroll here — it creates a
     clipping context that hides the absolutely-positioned dropdown
     panels.  Let panels escape the bar naturally. */
  overflow: visible;
}

.edu-meganav__item {
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.edu-meganav__link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  height: 100%;
  padding: 0 0.95rem;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: rgba(255, 255, 255, 0.78) !important;
  text-decoration: none !important;
  white-space: nowrap;
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: color 0.18s ease;
}
.edu-meganav__link:hover { color: #FFFFFF !important; }

.edu-meganav__caret {
  font-size: 0.7em;
  margin-left: 0.1rem;
  opacity: 0.6;
  transition: transform 0.22s ease, opacity 0.22s ease;
}
.edu-meganav__item:hover .edu-meganav__caret,
.edu-meganav__item.is-open .edu-meganav__caret {
  transform: rotate(180deg);
  opacity: 1;
}

/* Active state — bold + amber animated underline */
.edu-meganav__item.is-active .edu-meganav__link {
  color: #FFFFFF !important;
  font-weight: 700;
}
.edu-meganav__item.is-active .edu-meganav__link::after {
  content: "";
  position: absolute;
  left: 0.95rem;
  right: 0.95rem;
  bottom: 0;
  height: 3px;
  background: #F59E0B;
  border-radius: 2px 2px 0 0;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.55);
  animation: edu-underline-in 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes edu-underline-in {
  from { transform: scaleX(0); opacity: 0; }
  to   { transform: scaleX(1); opacity: 1; }
}

/* ====================================================================
 * Mega-nav dropdown panels
 * ==================================================================== */

.edu-meganav__panel {
  position: absolute;
  top: calc(100% - 1px);
  left: 0;
  min-width: 14rem;
  max-width: 22rem;
  padding: 0.5rem;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  box-shadow:
    0 24px 60px -8px rgba(0, 0, 0, 0.55),
    0 6px 16px -4px rgba(0, 0, 0, 0.30);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition:
    opacity 0.18s ease,
    transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 200;
}
.edu-meganav__item:hover .edu-meganav__panel,
.edu-meganav__item:focus-within .edu-meganav__panel,
.edu-meganav__item.is-open .edu-meganav__panel {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.edu-meganav__panel-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.edu-meganav__sublink {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.7rem;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.78) !important;
  text-decoration: none !important;
  border-radius: 8px;
  border: 0;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    transform 0.15s ease;
}
.edu-meganav__sublink:hover {
  background: rgba(59, 130, 246, 0.14);
  color: #FFFFFF !important;
  transform: translateX(2px);
}
.edu-meganav__sublink.is-active {
  background: rgba(245, 158, 11, 0.16);
  color: #FCD34D !important;
  font-weight: 600;
}
.edu-meganav__sublink-icon {
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95em;
  opacity: 0.85;
}
.edu-meganav__sublink-meta {
  margin-left: auto;
  font-size: 0.72em;
  color: rgba(255, 255, 255, 0.4);
  font-style: italic;
}

/* ====================================================================
 * Hide legacy nav rows
 * ==================================================================== */
.md-tabs,
.edu-topics,
.edu-quicknav { display: none !important; }

/* ====================================================================
 * Sidebar — focus on active category (paired with sidebar-focus.js)
 * ==================================================================== */

.md-sidebar--primary .md-nav__title[for="__drawer"],
.md-sidebar--primary .md-nav__source {
  display: none !important;
}
.md-sidebar--primary .md-nav--primary > .md-nav__list {
  padding-top: 0.6rem;
}

/* Category headers — small, uppercase, quiet */
.md-sidebar--primary
  .md-nav--primary
  > .md-nav__list
  > .md-nav__item--section
  > label.md-nav__link,
.md-sidebar--primary
  .md-nav--primary
  > .md-nav__list
  > .md-nav__item--section
  > .md-nav__link:not(.md-nav__container) {
  font-size: 0.68rem !important;
  font-weight: 700 !important;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-tertiary) !important;
  background: transparent !important;
  padding: 0.6rem 0.6rem 0.35rem !important;
  margin: 0.4rem 0 0 0 !important;
  border-radius: 0 !important;
  pointer-events: none;
}
.md-sidebar--primary
  .md-nav--primary
  > .md-nav__list
  > .md-nav__item--section
  > label.md-nav__link::before,
.md-sidebar--primary
  .md-nav--primary
  > .md-nav__list
  > .md-nav__item--section
  > .md-nav__link::before {
  display: none !important;
}
.md-sidebar--primary
  .md-nav--primary
  > .md-nav__list
  > .md-nav__item--section
  > label.md-nav__link
  .md-nav__icon,
.md-sidebar--primary
  .md-nav--primary
  > .md-nav__list
  > .md-nav__item--section
  .md-nav__icon {
  display: none !important;
}

/* Active course chapter — amber capsule + bar */
.md-sidebar--primary .md-nav__item--active > .md-nav__link,
.md-sidebar--primary .md-nav__item--active > .md-nav__container > .md-nav__link,
.md-sidebar--primary .md-nav__link--active {
  position: relative;
  background: rgba(59, 130, 246, 0.10) !important;
  color: #2563EB !important;
  font-weight: 600 !important;
  border-radius: 6px !important;
}
[data-md-color-scheme="slate"] .md-sidebar--primary .md-nav__item--active > .md-nav__link,
[data-md-color-scheme="slate"] .md-sidebar--primary .md-nav__item--active > .md-nav__container > .md-nav__link,
[data-md-color-scheme="slate"] .md-sidebar--primary .md-nav__link--active {
  background: rgba(59, 130, 246, 0.18) !important;
  color: #93C5FD !important;
}
.md-sidebar--primary .md-nav__item--active > .md-nav__link::before,
.md-sidebar--primary .md-nav__item--active > .md-nav__container > .md-nav__link::before,
.md-sidebar--primary .md-nav__link--active::before {
  content: "";
  position: absolute;
  left: -0.35rem;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 65%;
  background: #3B82F6;
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.55);
}

/* Don't double-mark category headers */
.md-sidebar--primary
  .md-nav--primary
  > .md-nav__list
  > .md-nav__item--section.md-nav__item--active
  > label.md-nav__link {
  background: transparent !important;
  color: var(--color-text-tertiary) !important;
  font-weight: 700 !important;
}
.md-sidebar--primary
  .md-nav--primary
  > .md-nav__list
  > .md-nav__item--section.md-nav__item--active
  > label.md-nav__link::before {
  display: none !important;
}

/* ====================================================================
 * Responsive — fold mega-nav into a horizontal-scroll strip on small screens
 * ==================================================================== */
@media (max-width: 960px) {
  .md-header__inner { gap: 0.5rem; }
  .md-search { max-width: 100%; }
  .edu-meganav__panel {
    /* Drop panels keep their floating placement; on tiny screens we let
       them scroll horizontally with the nav. */
    min-width: 12rem;
  }
}
@media (max-width: 720px) {
  .md-header { height: 3rem !important; }
  .md-header__inner { height: 3rem; padding: 0 0.85rem !important; }
  .md-header__title { padding-left: 1.85rem; font-size: 0.95rem !important; }
  .md-search__form { height: 2.1rem; }
  .md-search__form::after { display: none; }
  .edu-meganav { top: 3rem !important; height: 2.5rem; }
  .edu-meganav__inner { height: 2.5rem; padding: 0 0.85rem; }
  .edu-meganav__link { padding: 0 0.7rem; font-size: 0.82rem; }
  .edu-meganav__panel {
    min-width: calc(100vw - 1.7rem);
    max-width: calc(100vw - 1.7rem);
    left: 0;
  }
}
