/* Reuse the original Account button treatment on pages that only load section-page.css. */
.section-account-toggle {
  display: inline-flex;
  width: auto;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: .7rem .9rem;
  border: 3px solid #fff;
  border-radius: 17px;
  background: linear-gradient(#ff9ed0, #eb4d9a 68%, #b72e73);
  box-shadow: 0 5px #92245b;
  color: #fff;
  font: 900 1rem Trebuchet MS, Arial, sans-serif;
  text-decoration: none;
  text-shadow: 0 2px rgba(89, 15, 58, .25);
  white-space: nowrap;
  cursor: pointer;
  transition: .2s;
}
.section-account-toggle:hover { transform: translateY(-3px); box-shadow: 0 8px #92245b; }
.section-account-toggle:focus-visible { outline: 3px solid #0876c5; outline-offset: 3px; }
.home-page .main-menu {
  position: absolute; z-index: 40; top: calc(100% + 5px); right: 1rem; left: auto;
  display: none; width: min(420px, calc(100vw - 2rem)); max-height: calc(100vh - 100px);
  flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: .35rem; padding: 1rem;
  overflow-y: auto; border: 5px solid #fff; border-radius: 24px; background: #e8faff;
  box-shadow: 0 9px #4bc2e4, var(--shadow);
}
.home-page .menu-toggle { display: block; flex: 0 0 auto; }
.home-page .main-menu.open { display: flex; }
.home-page .main-menu > a, .home-page .main-menu > .language-toggle { width: 100%; text-align: center; }
.donut-menu-session { display: flex; width: 100%; flex-direction: column; align-items: stretch; gap: .35rem; }
.donut-menu-session .donut-menu-link { width: 100%; }
.donut-menu-divider { width: 100%; height: 2px; margin: .45rem 0; border: 0; background: rgba(23, 62, 114, .2); }
.donut-menu-link {
  display: block; width: 100%; min-height: 42px; padding: .7rem .9rem; border: 3px solid transparent;
  border-radius: 17px; background: transparent; color: var(--ink); font: 900 1rem Trebuchet MS, Arial, sans-serif;
  text-align: center; text-decoration: none; cursor: pointer; transition: .2s;
}
.donut-menu-link:hover, .donut-menu-link:focus-visible {
  transform: translateY(-3px); border-color: #fff; background: linear-gradient(#6bdbff, #1ca8df);
  box-shadow: 0 5px #0878b6; color: #fff; text-shadow: 0 2px rgba(0, 66, 114, .25);
}
.donut-menu-link:focus-visible { outline: 3px solid #0876c5; outline-offset: 2px; }
.donut-menu-logout:disabled { opacity: .55; cursor: not-allowed; }
@media (max-width: 900px) { .home-page .main-menu { right: 1rem; left: auto; width: min(420px, calc(100vw - 2rem)); } }

/* Hide only the obsolete icon controls shipped by section shells before their live controls mount. */
.section-topbar > .section-home:has(> img[src*="home-button"]),
.section-topbar > .section-actions > #focusPageSearch:has(> img),
.section-topbar > .section-actions > #favoriteFilter:has(> img),
.section-topbar > .section-actions > #openSectionInfo:has(> img),
.main-menu > .account-button:not(.donut-menu-account) { display: none !important; }

/* Keep the original blue menu button and normalize its bars. */
.home-page .menu-toggle > span { width: 21px; height: 2.5px; margin: 3px auto; }
.donut-unified-header .menu-toggle > span { width: 28px; height: 4px; margin: 3px; border-radius: 9px; background: #fff; }
.donut-unified-header {
  position: sticky; z-index: 60; top: 0; display: grid; grid-template-columns: auto minmax(180px, 1fr) auto;
  align-items: center; gap: .8rem; min-height: 68px; padding: .45rem clamp(.8rem, 3vw, 2.5rem);
  border-bottom: 1px solid #c7e8f3; background: #f2fdfff5; box-shadow: 0 2px 8px #16476f14;
}
.donut-unified-header .donut-unified-brand {
  display: flex; align-items: center; gap: .55rem; color: #17477e;
  font: 1000 1.2rem/1 Arial Rounded MT Bold, Trebuchet MS, Arial, sans-serif; text-decoration: none;
}
.donut-unified-header .donut-unified-brand img { display: block; width: 48px; height: 48px; object-fit: contain; }
.donut-unified-header .donut-unified-search { position: relative; display: block; width: min(100%, 520px); margin-left: auto; }
.donut-unified-header .donut-unified-search label, .donut-unified-header .donut-unified-search input { display: block; width: 100%; }
.donut-unified-header .donut-unified-search input {
  min-height: 38px; padding: .35rem .7rem; border: 1px solid #a8d7e8; border-radius: 7px;
  background: #fff; box-shadow: none; color: #17477e; font: 500 .9rem Trebuchet MS, Arial, sans-serif;
}
.donut-unified-header .menu-toggle {
  display: inline-flex; flex-direction: column; flex: 0 0 auto; align-items: center; justify-content: center; gap: .45rem;
  min-width: 88px; min-height: 40px; padding: .42rem .65rem; border: 2px solid #fff; border-radius: 13px;
  background: linear-gradient(#67d8fa, #159bd3); box-shadow: 0 4px 0 #0877b5; color: #fff;
  font: 900 .88rem Trebuchet MS, Arial, sans-serif; white-space: nowrap; cursor: pointer;
}
.donut-unified-header .menu-toggle > b { position: static; width: auto; height: auto; overflow: visible; font: inherit; }
.donut-unified-header .main-menu {
  position: absolute; z-index: 70; top: calc(100% + 5px); right: 1rem; left: auto; display: none;
  width: min(420px, calc(100vw - 2rem)); max-height: calc(100vh - 90px); flex-direction: column;
  flex-wrap: nowrap; align-items: stretch; gap: .35rem; padding: 1rem; overflow-y: auto;
  border: 5px solid #fff; border-radius: 24px; background: #e8faff;
  box-shadow: 0 9px #4bc2e4, var(--shadow, 0 15px 30px rgba(22,71,111,.2));
}
.donut-unified-header .main-menu.open { display: flex; }
.donut-unified-header .main-menu > a, .donut-unified-header .main-menu > .language-toggle { width: 100%; text-align: center; }
.donut-menu-account.account-button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 42px; border: 3px solid #fff;
  border-radius: 17px; background: linear-gradient(#ff9ed0, #eb4d9a 68%, #b72e73); box-shadow: 0 5px #92245b;
  color: #fff; text-shadow: 0 2px rgba(89, 15, 58, .25);
}
.donut-menu-account.account-button:hover, .donut-menu-account.account-button:focus-visible { background: linear-gradient(#ff9ed0, #eb4d9a 68%, #b72e73); color: #fff; }
@media (max-width: 760px) {
  .donut-unified-header { grid-template-columns: auto 1fr auto; gap: .5rem; padding: .4rem .7rem; }
  .donut-unified-header .donut-unified-brand span { display: none; }
  .donut-unified-header .donut-unified-brand img { width: 42px; height: 42px; }
  .donut-unified-header .donut-unified-search input { min-width: 0; }
}

/* section-page.js replaces this legacy large local search with the global Search in the header. */
body[data-page] .page-search { display: none !important; }

/* Approved header geometry and menu treatment from the local visual reference. */
.donut-unified-header {
  grid-template-columns: minmax(0, 1fr) 250px 48px;
  min-height: 78px;
  gap: 12px;
  padding: 6px 34px;
}
.donut-unified-header .preview-brand-breadcrumbs {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: clamp(12px, 2vw, 32px);
}
.donut-unified-header .section-breadcrumbs {
  order: initial;
  flex: 0 1 auto;
  min-width: 0;
  margin: 0;
  font-size: .9rem;
  white-space: nowrap;
}
.donut-unified-header .donut-unified-brand img { width: 40px; height: 40px; }
.donut-unified-header .donut-unified-brand { font-size: 1.2rem; }
.donut-unified-header .donut-unified-search { width: 250px; max-width: 250px; }
.donut-unified-header .menu-toggle {
  display: inline-flex !important;
  width: 42px !important;
  min-width: 42px !important;
  height: 46px;
  min-height: 46px !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0;
  padding: 5px;
}
.donut-unified-header .menu-toggle > b { display: none !important; }
.donut-unified-header .menu-toggle > span {
  display: block !important;
  visibility: visible !important;
  width: 22px !important;
  height: 3px !important;
  margin: 2.5px 0 !important;
  border: 0 !important;
  border-radius: 9px !important;
  background: #fff !important;
  opacity: 1 !important;
}
body[data-page] .donut-unified-header .menu-toggle > span { display: none !important; }
body[data-page] .donut-unified-header .menu-toggle { position: relative !important; }
body[data-page] .donut-unified-header .menu-toggle::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  display: block;
  width: 22px;
  height: 3px;
  border: 0;
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 -7px 0 #fff, 0 7px 0 #fff;
  transform: translate(-50%, -50%);
}
.home-page .donut-unified-header .menu-toggle > span {
  display: none !important;
}
.home-page .donut-unified-header .menu-toggle {
  position: relative !important;
}
.home-page .donut-unified-header .menu-toggle::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  display: block;
  width: 22px;
  height: 3px;
  border: 0;
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 -7px 0 #fff, 0 7px 0 #fff;
  transform: translate(-50%, -50%);
}
body[data-page="free-materials"] .donut-unified-header .donut-unified-brand img {
  transform: scale(1.5);
  transform-origin: center;
}
.donut-unified-header .main-menu {
  min-height: min(570px, calc(100vh - 100px));
  justify-content: space-between;
  align-items: stretch !important;
}
.donut-unified-header .main-menu > *,
.donut-unified-header .donut-menu-session .donut-menu-link { text-align: center !important; }
.donut-unified-header .main-menu > .donut-menu-account { justify-content: center !important; }
.donut-unified-header #mainMenu > a.donut-menu-link,
.donut-unified-header #mainMenu .donut-menu-session .donut-menu-link {
  justify-content: center !important;
  text-align: center !important;
}
.donut-unified-header .main-menu > a[href="/"] { order: 0; }
.donut-unified-header .main-menu > a[href="/courses/"] { order: 1; }
.donut-unified-header .main-menu > a[href="/library/"] { order: 2; }
.donut-unified-header .main-menu > a[href="/games/"] { order: 3; }
.donut-unified-header .main-menu > a[href="/worksheets/"] { order: 4; }
.donut-unified-header .main-menu > a[href="/free-materials/"] { order: 5; }
.donut-unified-header .main-menu > a[href="/articles/"] { order: 6; }
.donut-unified-header .main-menu > #preview-favorites-label { order: 7; }
.donut-unified-header .main-menu > #preview-legal-label { order: 8; }
.donut-unified-header .main-menu > .language-toggle { order: 9; }
.donut-unified-header .main-menu > .donut-menu-account { order: 10; min-height: 44px; }
.donut-unified-header .donut-menu-session { order: 11; }
.donut-unified-header .main-menu > .language-toggle {
  min-height: 32px;
  border: 3px solid #fff;
  border-radius: 18px;
  background: linear-gradient(#ffe96d, #ffb72b 72%, #d97813);
  box-shadow: 0 4px #a95d16;
  color: #633a0a;
}
.donut-unified-header .donut-menu-divider { display: none; }
.donut-unified-header .donut-menu-session .donut-menu-logout,
.donut-unified-header .donut-menu-session .donut-menu-login {
  min-height: 42px;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: #123f78;
  text-shadow: none;
}
@media (max-width: 760px) {
  .donut-unified-header {
    grid-template-columns: minmax(0, 1fr) minmax(120px, 250px) 48px;
    gap: 8px;
    padding: 6px 12px;
  }
  .donut-unified-header .preview-brand-breadcrumbs { gap: 8px; }
  .donut-unified-header .section-breadcrumbs { font-size: .75rem; white-space: normal; }
  .donut-unified-header .donut-unified-brand span { display: inline; font-size: 1rem; }
  .donut-unified-header .donut-unified-brand img { width: 36px; height: 36px; }
  .donut-unified-header .donut-unified-search { width: 100%; max-width: 250px; }
}
