/* Shared hamburger navigation for top-level student pages.
   Pages provide the common colour variables declared in their own :root. */
.student-nav-root { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.header-menu-wrap { position: relative; flex-shrink: 0; }

/* Shared chrome for header shortcuts left of the hamburger: the ✉ "write to
   me" button and, when enabled in student-nav.js, the 🎯 game link. The ✉ one is a <button>
   (the form opens as a modal, never a navigation), so the UA button defaults
   — padding, border, background, font and appearance — are all reset here
   rather than inherited; the neutral chrome then matches .menu-trigger. The
   game link overrides the fill below, but keeps this box and this height so
   the two controls line up. */
.nav-shortcut {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  height: 38px;
  margin: 0;
  padding: 0 0.75rem;
  color: var(--ink);
  background: var(--card);
  border: 1.5px solid var(--line-2);
  border-radius: 10px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.nav-shortcut:hover,
.nav-shortcut:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.nav-shortcut:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.nav-shortcut-icon { font-size: 0.95rem; line-height: 1; }

.menu-trigger {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  background: var(--card);
  border: 1.5px solid var(--line-2);
  border-radius: 10px;
  font: inherit;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.menu-trigger:hover,
.menu-trigger[aria-expanded="true"] {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.menu-trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.menu-icon { font-size: 1.15rem; line-height: 1; transform: translateY(-1px); }
.header-menu {
  position: absolute;
  top: calc(100% + 0.55rem);
  right: 0;
  width: max-content;
  min-width: 220px;
  max-width: calc(100vw - 2rem);
  padding: 0.45rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 14px 35px rgba(26, 26, 46, 0.14);
}
.header-menu[hidden] { display: none; }
.menu-nav { display: grid; gap: 0.15rem; }
.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.62rem 0.7rem;
  color: var(--ink);
  background: transparent;
  border: none;
  border-radius: 8px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  opacity: 1;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
}
.menu-item:hover { color: var(--accent); background: var(--accent-soft); }
.menu-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.menu-item.is-current {
  color: var(--ink-3);
  background: transparent;
  opacity: 0.55;
  cursor: default;
}
.menu-item.is-current:hover,
.menu-item.is-current:focus-visible { color: var(--ink-3); background: transparent; opacity: 0.55; }
/* The menu's beta tag is smaller than the label so it reads as a qualifier. */
.menu-item-beta {
  margin-left: auto;
  padding: 0.12rem 0.4rem;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  line-height: 1.5;
}
.menu-item.is-current .menu-item-beta { color: var(--ink-3); background: transparent; }
.menu-item-icon {
  width: 1.15rem;
  flex: 0 0 1.15rem;
  text-align: center;
  line-height: 1;
}
/* Optional per-page slot (index.html puts the term selector here). A page that
   ignores it leaves the container empty, and :empty keeps it invisible —
   no divider, no padding, so every other page's menu is unchanged. */
.menu-extras {
  margin-top: 0.4rem;
  padding: 0.6rem 0.7rem 0.15rem;
  border-top: 1px solid var(--line);
}
.menu-extras:empty { display: none; }
.menu-extras-label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--ink-3);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.menu-language {
  margin-top: 0.4rem;
  padding: 0.6rem 0.7rem 0.25rem;
  border-top: 1px solid var(--line);
}
.lang-switch {
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  flex-shrink: 0;
  border: 1.5px solid var(--line-2);
  border-radius: 999px;
}
.lang-btn {
  padding: 0.3rem 0.6rem;
  color: var(--ink-3);
  background: none;
  border: none;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.lang-btn + .lang-btn { border-left: 1.5px solid var(--line-2); }
.lang-btn:hover:not([aria-pressed="true"]) { color: var(--accent); background: var(--accent-soft); }
.lang-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.lang-btn[aria-pressed="true"] {
  color: var(--accent);
  background: var(--accent-soft);
  cursor: default;
}

@media (max-width: 520px) {
  /* Top-level page headers stay one row when they fit, but may wrap the whole
     navigation below the wordmark instead of creating horizontal overflow. */
  header { height: auto; min-height: 60px; flex-wrap: wrap; row-gap: 0.4rem; padding-top: 0.45rem; padding-bottom: 0.45rem; }
  .student-nav-root { margin-left: auto; }
  .menu-trigger { width: 40px; height: 40px; }
  .lang-btn { padding: 0.3rem 0.45rem; font-size: 0.7rem; }
  .student-nav-root { gap: 0.4rem; }
  /* Drop the icon, never the label: "Écrivez-moi" is what tells the student
     what the control does, while a bare ✉ next to a ☰ reads as decoration. */
  .nav-shortcut { height: 40px; padding: 0 0.5rem; font-size: 0.74rem; gap: 0.35rem; }
  .nav-shortcut-icon { display: none; }
}

@media (max-width: 400px) {
  /* The labelled ✉ shortcut plus ☰ and index.html's term badge: below 400 px
     every remaining pixel of gap and padding is what keeps ☰ on screen. */
  .student-nav-root { gap: 0.3rem; }
  .nav-shortcut { padding: 0 0.42rem; gap: 0.25rem; font-size: 0.7rem; }
  .menu-trigger { width: 36px; height: 36px; }
  .nav-shortcut { height: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  .menu-trigger, .menu-item, .lang-btn, .nav-shortcut { transition: none; }
}
