/* Shared website, account and lesson navigation. Keep this file last in <head>. */
#n9-site-menu {
  --n9-menu-ink: var(--n9-colour-text, #17324d);
  --n9-menu-surface: var(--n9-colour-surface, #fff);
  --n9-menu-soft: var(--n9-colour-background, #faf8f1);
  --n9-menu-line: var(--n9-colour-border, #d8e0e8);
  --n9-menu-gold: #ecc766;
  position: sticky;
  top: var(--wp-admin--admin-bar--height, 0px);
  z-index: 90;
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 72px;
  height: auto;
  margin: 0;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--n9-menu-line);
  background: var(--n9-menu-surface);
  color: var(--n9-menu-ink);
  box-shadow: 0 3px 14px #17324d0b;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  text-align: left;
}

#n9-site-menu *,
#n9-site-menu *::before,
#n9-site-menu *::after { box-sizing: border-box; }

#n9-site-menu [hidden] { display: none !important; }

#n9-site-menu .n9-menu-bar {
  position: relative;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  width: min(1200px, calc(100% - 32px));
  max-width: none;
  min-width: 0;
  min-height: 72px;
  height: auto;
  margin: 0 auto;
  padding: 10px 0;
}

#n9-site-menu .n9-menu-brand {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  margin: 0 auto 0 0;
  padding: 0;
}

#n9-site-menu .n9-menu-logo {
  display: inline-flex;
  align-items: center;
  width: 112px;
  min-width: 0;
  min-height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
}

#n9-site-menu .n9-menu-logo img {
  display: block;
  width: 112px;
  max-width: 100%;
  height: auto;
  max-height: none;
  margin: 0;
  object-fit: contain;
}

#n9-site-menu :is(.n9-menu-links, .nav) {
  position: static;
  inset: auto;
  display: flex;
  flex: 0 1 auto;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 4px;
  width: auto;
  min-width: 0;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

#n9-site-menu :is(.n9-menu-links, .nav) > a,
#n9-site-menu :is(.n9-menu-links, .nav) summary,
#n9-site-menu .n9-menu-panel > a,
#n9-site-menu .n9-menu-panel button,
#n9-site-menu .n9-grade-menu-links a,
#n9-site-menu .n9-account-home,
#n9-site-menu :is(.n9-menu-login, .header-course-link),
#n9-site-menu .n9-menu-logout > button,
#n9-site-menu .n9-menu-toggle,
#n9-site-menu .n9-menu-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: auto;
  min-width: 0;
  min-height: 44px;
  margin: 0;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--n9-menu-ink);
  box-shadow: none;
  font: 700 14px/1.4 Arial, Helvetica, sans-serif;
  letter-spacing: normal;
  text-decoration: none;
  text-transform: none;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#n9-site-menu a:focus-visible,
#n9-site-menu button:focus-visible,
#n9-site-menu summary:focus-visible {
  outline: 3px solid #176b9b;
  outline-offset: 3px;
}

#n9-site-menu :is(.n9-menu-links, .nav) > a:hover,
#n9-site-menu :is(.n9-menu-links, .nav) summary:hover,
#n9-site-menu .n9-menu-panel > a:hover,
#n9-site-menu .n9-menu-panel button:hover,
#n9-site-menu .n9-grade-menu-links a:hover,
#n9-site-menu .n9-account-home:hover,
#n9-site-menu .n9-menu-back:hover {
  background: var(--n9-menu-soft);
  border-color: var(--n9-menu-line);
}

#n9-site-menu a[aria-current="page"],
#n9-site-menu :is(.n9-menu-links, .nav) details[data-current="true"] > summary {
  background: var(--n9-menu-soft);
  border-color: #d5b34f;
  color: var(--n9-menu-ink);
}

#n9-site-menu .n9-grade-desktop-links { display: none; }
#n9-site-menu :is(.n9-menu-links, .nav) > .n9-menu-home-mobile { display: none; }

#n9-site-menu .n9-grade-menu,
#n9-site-menu .n9-account-menu {
  position: relative;
  display: block;
  flex: 0 0 auto;
  width: auto;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

#n9-site-menu .n9-grade-menu > summary,
#n9-site-menu .n9-account-menu > summary {
  list-style: none;
  user-select: none;
}

#n9-site-menu summary::-webkit-details-marker { display: none; }
#n9-site-menu summary::marker { content: ""; }

#n9-site-menu .n9-grade-menu > summary::after,
#n9-site-menu .n9-account-menu > summary::after {
  content: "";
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  margin: -3px 2px 0 4px;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}

#n9-site-menu details[open] > summary::after {
  margin-top: 3px;
  transform: rotate(225deg);
}

#n9-site-menu .n9-grade-menu-links,
#n9-site-menu .n9-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  left: auto;
  z-index: 5;
  display: none;
  width: 280px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 150px);
  max-height: calc(100dvh - 150px);
  margin: 0;
  padding: 10px;
  border: 1px solid var(--n9-menu-line);
  border-radius: 14px;
  background: var(--n9-menu-surface);
  box-shadow: 0 12px 32px #17324d1c;
  overflow: auto;
  overscroll-behavior: contain;
}

#n9-site-menu .n9-grade-menu[open] > .n9-grade-menu-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

#n9-site-menu .n9-account-menu[open] > .n9-menu-panel {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

#n9-site-menu .n9-menu-panel > a,
#n9-site-menu .n9-menu-panel button {
  justify-content: flex-start;
  width: 100%;
  white-space: normal;
  text-align: left;
}

#n9-site-menu .n9-menu-panel form { margin: 0; }

#n9-site-menu .n9-header-language-tools,
#n9-site-menu .n9-menu-language {
  flex: 0 0 auto;
  width: auto;
  margin: 0 4px;
  padding: 0;
  border: 0;
}

#n9-site-menu .header-preference-group { margin: 0; }
#n9-site-menu .header-preference-group > p { display: none; }

#n9-site-menu .language-switch,
#n9-site-menu .n9-menu-language {
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--n9-menu-line);
  border-radius: 12px;
  background: var(--n9-menu-soft);
}

#n9-site-menu .language-switch a,
#n9-site-menu .n9-menu-language a {
  display: inline-flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 0;
  min-height: 38px;
  margin: 0;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--n9-menu-ink);
  box-shadow: none;
  font: 700 13px/1.4 Arial, Helvetica, sans-serif;
  text-decoration: none;
  white-space: nowrap;
}

#n9-site-menu .language-switch a.active,
#n9-site-menu .language-switch a[aria-current],
#n9-site-menu .n9-menu-language a[aria-current] {
  border-color: #d5b34f;
  background: var(--n9-menu-surface);
}

#n9-site-menu .n9-menu-auth {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 0;
}

#n9-site-menu .n9-account-home { max-width: 180px; white-space: normal; }
#n9-site-menu .n9-menu-logout { display: block; margin: 0; padding: 0; }

#n9-site-menu :is(.n9-menu-login, .header-course-link),
#n9-site-menu .n9-menu-logout > button {
  border-color: #d4ad43;
  background: var(--n9-menu-gold);
  color: #17324d;
}

#n9-site-menu :is(.n9-menu-login, .header-course-link):hover,
#n9-site-menu .n9-menu-logout > button:hover { background: #f4d887; }

#n9-site-menu .n9-menu-bar > .n9-screen-tint-tools {
  position: static;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  flex-wrap: nowrap;
  order: 0;
  gap: 6px;
  width: auto;
  margin: 0;
}

#n9-site-menu .n9-tint-eyes {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 10px;
}

#n9-site-menu .n9-tint-reset { min-height: 44px; }

#n9-site-menu .n9-menu-toggle {
  display: none;
  flex: 0 0 auto;
  border-color: var(--n9-menu-line);
  background: var(--n9-menu-surface);
}

#n9-site-menu .n9-menu-toggle svg { display: block; width: 20px; height: 20px; }

#n9-site-menu .n9-menu-context {
  display: flex;
  flex: 1 0 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 8px 0 0;
  border-top: 1px solid var(--n9-menu-line);
}

#n9-site-menu .n9-menu-back {
  justify-content: flex-start;
  min-width: 0;
  padding: 7px 10px;
  border-color: var(--n9-menu-line);
  font-size: 13px;
  white-space: normal;
}

#n9-site-menu .n9-lesson-label {
  flex: 0 0 auto;
  margin: 0;
  padding: 0 2px;
  color: var(--n9-menu-ink);
  font: 700 13px/1.4 Arial, Helvetica, sans-serif;
}

@media (max-width: 1000px) {
  /* Without JS, all links remain visible below the first row. */
  #n9-site-menu :is(.n9-menu-links, .nav) {
    flex: 1 0 100%;
    order: 5;
    align-items: stretch;
    justify-content: flex-start;
    width: 100%;
    padding-top: 8px;
    border-top: 1px solid var(--n9-menu-line);
  }
  #n9-site-menu[data-n9-menu-ready="true"] .n9-menu-toggle { display: inline-flex; }
  #n9-site-menu[data-n9-menu-ready="true"] :is(.n9-menu-links, .nav) {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    left: auto;
    z-index: 4;
    display: none;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 6px;
    width: min(380px, 100%);
    max-height: calc(100vh - 190px);
    max-height: calc(100dvh - 190px);
    padding: 12px;
    border: 1px solid var(--n9-menu-line);
    border-radius: 14px;
    background: var(--n9-menu-surface);
    box-shadow: 0 12px 32px #17324d1c;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  #n9-site-menu[data-n9-menu-ready="true"][data-open="true"] :is(.n9-menu-links, .nav) { display: flex; }
  #n9-site-menu :is(.n9-menu-links, .nav) > a,
  #n9-site-menu :is(.n9-menu-links, .nav) summary { justify-content: flex-start; width: 100%; }
  #n9-site-menu .n9-grade-menu,
  #n9-site-menu .n9-account-menu { width: 100%; }
  #n9-site-menu .n9-grade-menu > summary::after,
  #n9-site-menu .n9-account-menu > summary::after { margin-left: auto; }
  #n9-site-menu .n9-grade-menu-links,
  #n9-site-menu .n9-menu-panel {
    position: static;
    width: 100%;
    max-width: none;
    max-height: none;
    margin: 4px 0 0;
    padding: 6px;
    border: 0;
    border-radius: 10px;
    background: var(--n9-menu-soft);
    box-shadow: none;
    overflow: visible;
  }
  #n9-site-menu .n9-header-language-tools,
  #n9-site-menu .n9-menu-language { width: 100%; margin: 4px 0 0; }
  #n9-site-menu .language-switch { width: 100%; }
  #n9-site-menu .language-switch a,
  #n9-site-menu .n9-menu-language a { min-height: 44px; }
  #n9-site-menu .n9-menu-context { order: 6; }
}

@media (max-width: 560px) {
  #n9-site-menu .n9-menu-bar { width: calc(100% - 24px); gap: 6px; }
  #n9-site-menu .n9-menu-auth .n9-account-home { display: none; }
  #n9-site-menu :is(.n9-menu-links, .nav) > .n9-menu-home-mobile { display: inline-flex; }
  #n9-site-menu .n9-menu-brand { margin-right: auto; }
  /* Off remains available in the tint dialog at small widths. */
  #n9-site-menu .n9-menu-bar > .n9-screen-tint-tools > .n9-tint-reset { display: none; }
  #n9-site-menu .n9-menu-context { gap: 8px; }
  #n9-site-menu .n9-lesson-label { font-size: 12px; }
}

@media (max-width: 480px) {
  #n9-site-menu .n9-menu-bar { gap: 4px; }
  #n9-site-menu .n9-menu-logo,
  #n9-site-menu .n9-menu-logo img { width: 88px; }
  #n9-site-menu :is(.n9-menu-login, .header-course-link),
  #n9-site-menu .n9-menu-logout > button { padding-inline: 10px; font-size: 13px; }
  #n9-site-menu .n9-menu-toggle { width: 44px; height: 44px; padding: 10px; }
  #n9-site-menu .n9-menu-toggle > span {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  #n9-site-menu .n9-menu-back { padding-inline: 8px; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  #n9-site-menu *, #n9-site-menu *::before, #n9-site-menu *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

/* Keep the account colour chooser readable inside the navigation panel. */
@media (min-width: 1001px) {
  #n9-site-menu .n9-menu-panel:has(.n9-colour-control) { width: 340px; }
}
#n9-site-menu .n9-menu-panel .n9-colour-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
#n9-site-menu .n9-menu-panel .n9-colour-option {
  display: grid;
  grid-template-columns: 14px 12px minmax(0, 1fr);
  align-items: center;
  gap: 4px;
  min-width: 0;
  min-height: 48px;
  margin: 0;
  padding: 7px 6px;
  font-size: 13px;
  line-height: 1.4;
  word-break: normal;
  overflow-wrap: normal;
  white-space: normal;
}
#n9-site-menu .n9-menu-panel .n9-colour-option input {
  width: 14px;
  height: 14px;
  min-width: 14px;
  min-height: 0;
  margin: 0;
}
#n9-site-menu .n9-menu-panel .n9-colour-dot { width: 12px; height: 12px; }
#n9-site-menu .n9-menu-panel .n9-colour-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}
#n9-site-menu .n9-menu-panel .n9-colour-actions button {
  justify-content: center;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 8px;
  border-color: var(--n9-menu-line);
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
  white-space: normal;
  word-break: normal;
  overflow-wrap: normal;
}
#n9-site-menu .n9-menu-panel .n9-colour-actions [data-n9-save] {
  background: var(--n9-colour-primary, #ecc766);
  color: var(--n9-colour-primary-text, #17324d);
}

/* Standalone account forms keep their own cards below the shared header. */
body.student-auth-page:has(> #n9-site-menu) { display: block; padding: 0; }
.student-auth-page #n9-site-menu + .student-login-shell,
.student-auth-page #n9-site-menu + .checkout-account-gate-shell {
  min-height: calc(100vh - 72px);
  min-height: calc(100svh - 72px);
}

/* Native public navigation keeps the same visual order as the shared account shell. */
#n9-site-menu :is(.n9-menu-links,.nav),
#n9-site-menu .n9-menu-auth,
#n9-site-menu .n9-menu-toggle { order:0; }
#n9-site-menu .language-switch a.active::before { content:none; }
@media(max-width:1000px){#n9-site-menu :is(.n9-menu-links,.nav){order:5}}

/* Desktop starts immediately above 1000px. Grade links stay beside the logo. */
@media (min-width:1001px) {
  #n9-site-menu .n9-menu-brand { margin-right:0; }
  #n9-site-menu :is(.n9-menu-links,.nav) { flex:1 1 auto; flex-wrap:nowrap; gap:2px; }
  #n9-site-menu .n9-grade-desktop-links { display:flex; flex:0 0 auto; gap:2px; margin-right:auto; }
  #n9-site-menu .n9-grade-menu { display:none; }
  #n9-site-menu .n9-grade-desktop-links a {
    display:inline-flex; align-items:center; justify-content:center;
    min-height:44px; padding:8px 6px; border:1px solid transparent; border-radius:8px;
    color:var(--n9-menu-ink); font:700 13px/1.4 Arial,Helvetica,sans-serif;
    text-decoration:none; white-space:nowrap;
  }
  #n9-site-menu .n9-grade-desktop-links a:hover { background:var(--n9-menu-soft); border-color:var(--n9-menu-line); }
}
@media (min-width:1001px) and (max-width:1200px) {
  #n9-site-menu .n9-menu-bar { gap:4px; }
  #n9-site-menu .n9-menu-logo,
  #n9-site-menu .n9-menu-logo img { width:88px; }
  #n9-site-menu .n9-grade-desktop-links { gap:0; }
  #n9-site-menu .n9-grade-desktop-links a { padding-inline:3px; font-size:12px; }
  #n9-site-menu :is(.n9-menu-links,.nav)>a,
  #n9-site-menu :is(.n9-menu-links,.nav) summary,
  #n9-site-menu .n9-account-home,
  #n9-site-menu .n9-menu-logout>button { padding-inline:5px; font-size:12px; }
  #n9-site-menu .language-switch a,
  #n9-site-menu .n9-menu-language a { padding-inline:5px; font-size:12px; }
  #n9-site-menu .n9-menu-language { margin-inline:0; }
  #n9-site-menu .n9-menu-auth { gap:2px; }
  #n9-site-menu .n9-menu-bar>.n9-screen-tint-tools>.n9-tint-reset { display:none; }
}

/* Match the dictionary header logo: 120px wide, 42px high. */
#n9-site-menu .n9-menu-logo { width: 120px; }
#n9-site-menu .n9-menu-logo img { width: 120px; height: auto; }
