/* =====================================================================
   Site chrome: ONE EduSmartUp header on every page + a section subheader
   (.esb) where a section needs its own navigation.

   Loaded UNLAYERED from the root layout, after legacy-layer.css, so it
   beats both the layered main stylesheet and each section's own
   stylesheet (developers.css, ai.css, community.css) for these elements.

   Height variables:
     --site-header-h  height of the main header (owned here; the sections'
                      stylesheets each redefined --header-h for their OWN
                      old header, which would have resized ours).
     --sub-h          height of the subheader; 0 when the page has none.
     --header-h       TOTAL sticky chrome = main header + subheader. The
                      sections already offset sticky sidebars / full-height
                      panels by --header-h, so they now line up below both
                      bars without touching each stylesheet.
   `html:root` (0,1,1) outranks the sections' `:root` (0,1,0).
   ===================================================================== */
html:root {
  --site-header-h: 70px;
  --sub-h: 0px;
  --header-h: calc(var(--site-header-h) + var(--sub-h));
}
html:root:has(.esb) { --sub-h: 50px; }
@media (max-width: 768px) {
  html:root { --site-header-h: 62px; }
  html:root:has(.esb) { --sub-h: 46px; }
}

/* ---------- Main header guard ------------------------------------------
   Section stylesheets restyle generic classes the header also uses
   (.container, .logo, .btn, .hamburger, .header-actions, .btn-icon). Pin
   the header's own look with id-scoped rules so it is identical on every
   page. */
#site-header {
  position: sticky; top: 0; z-index: 1000;
  background: #fff; border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .06);
  font-family: var(--font-inter, Inter), system-ui, sans-serif;
  color: #1f2937;
}
#site-header .container {
  width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 20px; box-sizing: border-box;
}
#site-header .header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: var(--site-header-h); min-height: 0; gap: 16px;
}
#site-header .logo {
  display: flex; align-items: center; gap: 0; padding: 0; margin: 0;
  background: none; border: 0; font-size: 1.4rem; text-decoration: none;
}
#site-header .logo-img { height: 52px; width: auto; }
#site-header .header-actions { display: flex; align-items: center; gap: 10px; padding: 0; margin: 0; background: none; border: 0; }
#site-header .btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; min-width: 40px; padding: 0; gap: 2px;
  border: 0; border-radius: 10px; background: #f8fafc; color: #1f2937;
  font-size: 1rem; line-height: 1; box-shadow: none; flex-direction: row;
}
#site-header .btn-icon.lang-toggle { flex-direction: column; font-size: .7rem; }
#site-header .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 18px; border-radius: 100px; font-size: .88rem; font-weight: 600;
  line-height: 1.2; text-decoration: none; box-shadow: none; transform: none; width: auto;
}
#site-header .btn-outline { background: transparent; color: #6c3ae1; border: 2px solid #6c3ae1; }
#site-header .btn-primary { background: #6c3ae1; color: #fff; border: 2px solid #6c3ae1; }
#site-header .hamburger {
  flex-direction: column; justify-content: center; gap: 5px;
  width: 40px; height: 40px; padding: 8px; border: 0; background: none; position: static;
}
#site-header .hamburger span { display: block; width: 24px; height: 2.5px; background: #1f2937; border-radius: 2px; }
#site-header .hamburger.open span:nth-child(1) { transform: translateY(7.5px) rotate(45deg); }
#site-header .hamburger.open span:nth-child(2) { opacity: 0; }
#site-header .hamburger.open span:nth-child(3) { transform: translateY(-7.5px) rotate(-45deg); }

/* Main nav + mega menus (literal colours: the sections redefine --primary etc.) */
#site-header ul { list-style: none; margin: 0; padding: 0; }
#site-header .main-nav { flex: 1; display: flex; justify-content: center; background: none; border: 0; padding: 0; margin: 0; position: static; }
#site-header .nav-list { display: flex; align-items: center; gap: 4px; }
#site-header .nav-link {
  display: flex; align-items: center; gap: 4px; padding: 8px 12px; border-radius: 6px;
  font-family: var(--font-inter, Inter), system-ui, sans-serif; font-weight: 500; font-size: .92rem;
  letter-spacing: 0; text-transform: none; color: #1e293b; text-decoration: none; background: none; border: 0;
}
#site-header .nav-link:hover, #site-header .nav-link.active { color: #6c3ae1; background: #efeafd; }
#site-header .nav-link .fa-chevron-down { font-size: .65rem; }
#site-header .mega-menu { background: #fff; border: 1px solid #e2e8f0; border-radius: 20px; box-shadow: 0 10px 40px rgba(0,0,0,.12); }
#site-header .mega-col h4 { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: #64748b; margin: 0 0 10px; font-weight: 600; }
#site-header .mega-col ul li a {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px;
  font-size: .88rem; color: #1e293b; text-decoration: none; background: none;
}
#site-header .mega-col ul li a:hover { background: #efeafd; color: #6c3ae1; }
#site-header .mega-col ul li a i { width: 16px; color: #6c3ae1; }
#site-header .mega-promo { background: linear-gradient(135deg, #6c3ae1, #3ecfcf); color: #fff; border-radius: 12px; padding: 16px; text-align: center; }
#site-header .mega-promo h4, #site-header .mega-promo p, #site-header .mega-promo i { color: #fff; }
#site-header .mega-promo .btn { background: #fff; color: #6c3ae1; border-color: #fff; }
#site-header .search-bar-wrapper { background: #f8fafc; }
/* The full menu (9 links + icons) needs ~1,100 px; below that (tablets, small laptops) it wrapped and
   pushed the icons off-screen, so the links move into the hamburger drawer (main.js) there too. */
@media (min-width: 1101px) { #site-header .hamburger { display: none; } }
@media (max-width: 1100px) {
  #site-header .main-nav { display: none; }
  #site-header .header-actions { margin-left: auto; }
  #site-header .hamburger { display: flex; }
}
@media (max-width: 768px) {
  /* Phones: smaller logo, and Login / Sign Up live in the drawer. */
  #site-header .logo-img { height: 44px; }
  #site-header .header-actions .btn { display: none; }
}

/* ---------- Section subheader ------------------------------------------ */
.esb {
  --esb-accent: #6c3ae1;
  position: sticky; top: var(--site-header-h); z-index: 990;
  background: #fff; border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 2px 10px rgba(15, 23, 42, .04);
  font-family: var(--font-inter, Inter), system-ui, sans-serif;
}
.esb-inner {
  display: flex; align-items: center; gap: 14px;
  max-width: 1200px; margin: 0 auto; padding: 0 20px; height: var(--sub-h);
  box-sizing: border-box;
}
.esb-brand {
  display: inline-flex; align-items: center; gap: 9px; flex-shrink: 0;
  font-weight: 700; font-size: .95rem; color: #0f172a; text-decoration: none; white-space: nowrap;
}
.esb-brand:hover { color: var(--esb-accent); }
.esb-ico {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px;
  background: color-mix(in srgb, var(--esb-accent) 13%, #fff); color: var(--esb-accent); font-size: .85rem;
}
.esb-sep { width: 1px; height: 22px; background: #e5e7eb; flex-shrink: 0; }
.esb-links {
  display: flex; align-items: center; gap: 2px; min-width: 0; flex: 1;
  overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none;
}
.esb-links::-webkit-scrollbar { display: none; }
.esb-link {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  padding: 7px 12px; border-radius: 8px; white-space: nowrap;
  font-size: .86rem; font-weight: 500; color: #475569; text-decoration: none;
  background: none; border: 0; cursor: pointer; line-height: 1.2;
}
.esb-link:hover { background: #f1f5f9; color: #0f172a; }
.esb-link.active { background: color-mix(in srgb, var(--esb-accent) 11%, #fff); color: color-mix(in srgb, var(--esb-accent) 85%, #000); font-weight: 600; } /* darkened text: ≥4.5:1 on its own tint */
.esb-link i { font-size: .8rem; }
.esb-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: #ef4444; color: #fff; font-size: .68rem; font-weight: 700; display: inline-grid; place-items: center;
}
.esb-more { position: relative; flex-shrink: 0; }
.esb-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 995;
  min-width: 220px; max-height: 70vh; overflow-y: auto;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .14); padding: 6px;
}
.esb-menu a, .esb-menu button {
  display: flex; align-items: center; gap: 8px; width: 100%; box-sizing: border-box;
  padding: 8px 12px; border-radius: 8px; border: 0; background: none; text-align: left;
  font-size: .86rem; color: #334155; text-decoration: none; cursor: pointer;
}
.esb-menu a:hover, .esb-menu button:hover, .esb-menu a.active { background: #f1f5f9; color: var(--esb-accent); }
.esb-menu-label { padding: 8px 12px 4px; font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #94a3b8; }
.esb-menu hr { border: 0; border-top: 1px solid #f1f5f9; margin: 4px 0; }
.esb-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.esb-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 9px; white-space: nowrap;
  font-size: .84rem; font-weight: 600; text-decoration: none; cursor: pointer;
  border: 1px solid #e5e7eb; background: #fff; color: #334155; position: relative;
}
.esb-btn:hover { border-color: var(--esb-accent); color: var(--esb-accent); }
.esb-btn.primary { background: var(--esb-accent); border-color: var(--esb-accent); color: #fff; }
.esb-btn.primary:hover { filter: brightness(1.08); color: #fff; }
.esb-btn.icon { width: 34px; padding: 0; }
.esb-btn .esb-badge { position: absolute; top: -6px; right: -6px; }
@media (max-width: 768px) {
  .esb-inner { padding: 0 12px; gap: 8px; }
  .esb-brand .esb-title { display: none; }
  .esb-sep { display: none; }
  .esb-link { padding: 6px 10px; font-size: .82rem; }
  .esb-btn .esb-btn-label { display: none; }
  .esb-btn { padding: 0 10px; }
}

/* Dark section themes (Developers dark mode): keep the bars readable. */
[data-theme="dark"] .esb { background: #111827; border-color: #1f2937; }
[data-theme="dark"] .esb-brand { color: #f1f5f9; }
[data-theme="dark"] .esb-link { color: #cbd5e1; }
[data-theme="dark"] .esb-link:hover { background: #1f2937; color: #fff; }
[data-theme="dark"] .esb-link.active { background: color-mix(in srgb, var(--esb-accent) 25%, #111827); color: #fff; }
[data-theme="dark"] .esb-btn { background: #111827; border-color: #334155; color: #e2e8f0; }
[data-theme="dark"] .esb-btn.primary { background: var(--esb-accent); border-color: var(--esb-accent); color: #fff; }
[data-theme="dark"] .esb-menu { background: #111827; border-color: #1f2937; }
[data-theme="dark"] .esb-menu a, [data-theme="dark"] .esb-menu button { color: #cbd5e1; }
[data-theme="dark"] .esb-menu a:hover, [data-theme="dark"] .esb-menu button:hover { background: #1f2937; }
[data-theme="dark"] .esb-sep { background: #334155; }

/* ---------- Sections that used to own the whole screen ------------------ */

/* Developers Try-It editor: <body> is a full-height flex column (tryit.css);
   the page's wrapper (subheader + editor) must stretch so the editor fills
   everything below the site header instead of stopping at its content. */
body.editor-shell-lock > div:has(.vsc-shell) { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
body.editor-shell-lock > div:has(.vsc-shell) > .vsc-shell { flex: 1 1 auto; min-height: 0; }
/* Developers sign-in: the original puts .auth-page on <body>, but the main
   site's stylesheet (pages.css) also uses .auth-page for ITS login page as a
   centred flex row — which laid the header and page out side by side. */
body.portal-shell.auth-page { display: block; }

/* tryit.css styles bare buttons; keep the subheader's own look. */
.esb button.esb-link { background: none; border: 0; color: #475569; font: 500 .86rem/1.2 var(--font-inter, Inter), system-ui, sans-serif; box-shadow: none; }
.esb button.esb-link:hover { background: #f1f5f9; color: #0f172a; }
.esb button.esb-link.active { background: color-mix(in srgb, var(--esb-accent) 11%, #fff); color: color-mix(in srgb, var(--esb-accent) 85%, #000); }
.esb button.esb-btn { font: 600 .84rem/1 var(--font-inter, Inter), system-ui, sans-serif; }

/* AI chat: was 100vh/100vw from the top of the window. */
html .pro-app { height: calc(100dvh - var(--header-h)); width: 100%; }

/* Community app: the subheader carries its links + "New post" on tablet and
   desktop, so the old icon rail / bottom bar / floating + are phone-only. */
.esb .esb-avatar { overflow: hidden; font-size: .72rem; font-weight: 700; }
.esb .esb-avatar img { width: 100%; height: 100%; object-fit: cover; }
@media (min-width: 769px) {
  html .main-app .bottom-nav, html .main-app > .fab { display: none !important; }
  html .main-app { padding-left: 0 !important; }
  html .main-app .pages-container { padding-bottom: 24px; }
}
@media (max-width: 768px) {
  .esb--community .esb-links, .esb--community .esb-sep { display: none; }
  .esb--community .esb-inner { justify-content: space-between; }
}

/* Printable pages (certificate, invoice, ID cards): no site chrome on paper. */
@media print {
  #site-header, .esb, .floating-ai-btn, .whatsapp-float { display: none !important; }
}

/* ── Courses / Webinars filters on phones ─────────────────────────────
   The vertical filter list filled the whole first screen, pushing every
   course below the fold. On narrow screens show each group as wrapping chips. */
@media (max-width: 900px) {
  html .filter-sidebar { padding: 16px; }
  html .filter-sidebar h6 { margin-bottom: 10px; }
  html .filter-sidebar .filter-group { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
  html .filter-sidebar .filter-group-label { flex-basis: 100%; margin-bottom: 2px; }
  html .filter-sidebar .filter-option { width: auto; padding: 6px 12px; border: 1px solid #e2e8f0; border-radius: 999px; font-size: .82rem; }
  html .filter-sidebar .filter-option.active { border-color: transparent; }
  html .filter-sidebar .filter-option .count { margin-left: 6px; }
}

/* ── Inline text links: underline them (WCAG 1.4.1) ───────────────────
   Links inside sentences were told apart by colour only. Class-less <a>
   inside a paragraph is an inline text link; buttons/pills keep their look. */
p a:not([class]), .policy-body li a:not([class]), .tip a:not([class]), .note-box a:not([class]) {
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

/* ── Footer bottom bar + mobile-menu labels: readable contrast ─────────
   Footer copyright/links were #475569 on #0a0e1a (2.5:1); the AI section's
   light text colour leaked into the white mobile menu's section labels. */
html .footer-copy, html .footer-copy strong, html .footer-bottom-links a { color: #8b95a5; }
html .footer-bottom-links a:hover { color: #c4b5fd; }
html:not([data-theme="dark"]) .mobile-nav-section { color: #4b5563; }

/* ── Remaining low-contrast text (axe audit) ── */
html .auth-divider span, html .course-loading p, html .hv2-lesson em { color: #64748b; }
html .policy-body .last-updated, html .policy-body .data-table th { color: #4a40d0; }
html .footer-bottom p { color: #8b95a5; }

/* ── Study mega menu: anchor to the left of its tab ───────────────────
   Centred under "Study", the 4-column panel ran off the left edge. */
#site-header .mega-menu.mega-menu--study,
#site-header .has-mega-menu:hover .mega-menu.mega-menu--study,
#site-header .has-mega-menu:focus-within .mega-menu.mega-menu--study {
  left: -60px; right: auto; transform: none;
  min-width: 900px; grid-template-columns: 1fr 1fr 1fr 230px;
}
