/* IAL Prep — the navigation bar along the top of every page (built by js/nav.js).
   The bar is fixed to the top; the page keeps a strip of the same height free at its top,
   so nothing jumps when the bar is drawn. Each subject's menu opens a panel of columns on a
   wide screen and a full-screen list on a phone. Colours come from the site variables in
   styles.css, so light and dark mode both work. */
:root {
  --site-nav-h: 56px;
}

body { padding-top: var(--site-nav-h); }

.site-nav {
  /* The bar takes the page subject's deep colour; the landing page uses Physics navy. */
  --nav-bar: #002b80;
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 50;
  height: var(--site-nav-h);
  background: var(--nav-bar);
  color: #fff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
}
.site-nav[data-subject="chemistry"] { --nav-bar: #063f33; }
.site-nav[data-subject="biology"] { --nav-bar: #173d17; }
.site-nav[data-subject="maths"] { --nav-bar: #2e1a5c; }

/* Each panel takes its own subject's accent, whatever page it opens on. */
.site-nav-panel { --nav-accent: #0056b3; --nav-tint: #e7f1ff; }
.site-nav-panel[data-nav-subject="chemistry"] { --nav-accent: #0b6e55; --nav-tint: #e3f6f0; }
.site-nav-panel[data-nav-subject="biology"] { --nav-accent: #2a6f2a; --nav-tint: #e9f5e9; }
.site-nav-panel[data-nav-subject="maths"] { --nav-accent: #5f32b0; --nav-tint: #f0eaff; }
:root[data-theme="dark"] .site-nav-panel { --nav-accent: #8fb4ff; --nav-tint: #18263f; }
:root[data-theme="dark"] .site-nav-panel[data-nav-subject="chemistry"] { --nav-accent: #6fd6b8; --nav-tint: #0f2c26; }
:root[data-theme="dark"] .site-nav-panel[data-nav-subject="biology"] { --nav-accent: #8fd18f; --nav-tint: #162d18; }
:root[data-theme="dark"] .site-nav-panel[data-nav-subject="maths"] { --nav-accent: #b9a0ff; --nav-tint: #251b40; }

.site-nav-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  box-sizing: border-box;
  height: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 20px;
}

.site-nav-logo {
  flex: none;
  margin-right: 14px;
  color: #fff;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.2px;
  text-decoration: none;
}

.site-nav-menu { flex: 1; min-width: 0; }

.site-nav-list {
  display: flex;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #dfe8ff;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.site-nav-trigger:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.site-nav-trigger.is-current { color: #fff; box-shadow: inset 0 -2px 0 rgba(255, 255, 255, 0.85); border-radius: 8px 8px 0 0; }
.site-nav-item.is-open > .site-nav-trigger { background: rgba(255, 255, 255, 0.16); color: #fff; }
.site-nav-trigger:focus-visible,
.site-nav-logo:focus-visible,
.site-nav-continue:focus-visible,
.site-nav-burger:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.site-nav-chev { width: 12px; height: 12px; transition: transform 0.2s cubic-bezier(.2, .9, .2, 1); }
.site-nav-item.is-open .site-nav-chev { transform: rotate(180deg); }

/* ---------- The panel under the bar ---------- */
.site-nav-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  box-sizing: border-box;
  width: min(1180px, calc(100vw - 32px));
  max-height: calc(100vh - var(--site-nav-h) - 24px);
  max-height: calc(100dvh - var(--site-nav-h) - 24px);
  overflow: auto;
  transform: translateX(-50%);
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.2);
}
.site-nav-panel[hidden] { display: none; }
:root[data-theme="dark"] .site-nav-panel { box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55); }

@media (prefers-reduced-motion: no-preference) {
  .site-nav { view-transition-name: site-nav; }
  .site-nav-panel:not([hidden]) { animation: site-nav-drop 0.18s cubic-bezier(.2, .9, .2, 1); }
}
@keyframes site-nav-drop { from { opacity: 0; transform: translate(-50%, -6px); } }

.site-nav-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.site-nav-col { min-width: 0; padding: 16px 10px 14px; }
.site-nav-col + .site-nav-col { border-left: 1px solid var(--line); }

.site-nav-col-title {
  display: block;
  margin: 0 8px 8px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}

.site-nav-links { margin: 0; padding: 0; list-style: none; }

.site-nav-link {
  display: block;
  padding: 7px 8px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
}
.site-nav-link:hover { background: var(--nav-tint); }
.site-nav-link:hover .site-nav-link-title { color: var(--nav-accent); }
.site-nav-link:focus-visible { outline: 2px solid var(--nav-accent); outline-offset: -2px; }
.site-nav-link-title { display: block; font-size: 14.5px; font-weight: 600; line-height: 1.3; }
.site-nav-link-desc {
  display: -webkit-box;
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}
.site-nav-link-note { display: block; margin-top: 3px; color: var(--nav-accent); font-size: 12px; font-weight: 700; }
.site-nav-link[aria-current="page"] { background: var(--nav-tint); }
.site-nav-link[aria-current="page"] .site-nav-link-title { color: var(--nav-accent); }

.site-nav-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 20px;
  padding: 11px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 14px;
}
.site-nav-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--nav-accent);
  font-weight: 700;
  text-decoration: none;
}
.site-nav-all:hover { text-decoration: underline; text-underline-offset: 3px; }
.site-nav-arrow { width: 15px; height: 15px; }
.site-nav-foot-side { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; color: var(--muted); }
.site-nav-foot-side a { color: var(--ink); text-decoration: none; }
.site-nav-foot-side a:hover { color: var(--nav-accent); text-decoration: underline; text-underline-offset: 3px; }
.site-nav-foot-progress { color: var(--nav-accent); font-weight: 600; }

/* ---------- Continue and the phone menu button ---------- */
.site-nav-end { display: flex; flex: none; align-items: center; gap: 8px; margin-left: auto; }

.site-nav-continue {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  max-width: 240px;
  padding: 7px 14px;
  border-radius: 999px;
  background: #fff;
  color: var(--nav-bar);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.site-nav-continue:hover { background: #e8eefc; }
.site-nav-continue-where { overflow: hidden; color: #4a5568; font-weight: 500; text-overflow: ellipsis; }

.site-nav-burger {
  display: none;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 7px 12px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.site-nav-burger svg { width: 18px; height: 18px; }

/* Between phone and full desktop width the panel's columns wrap three to a row. */
@media (min-width: 901px) and (max-width: 1140px) {
  .site-nav-cols { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .site-nav-col + .site-nav-col { border-left: 0; }
  .site-nav-col { border-bottom: 1px solid var(--line); }
  .site-nav-col:not(:nth-child(3n + 1)) { border-left: 1px solid var(--line); }
}

/* ---------- Phones and small tablets: a Menu button and a full-screen list ---------- */
@media (max-width: 900px) {
  .site-nav-bar { padding: 0 12px 0 16px; }
  .site-nav-burger { display: inline-flex; }

  .site-nav-menu {
    display: none;
    position: fixed;
    top: var(--site-nav-h);
    right: 0;
    bottom: 0;
    left: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--bg);
    color: var(--ink);
    padding: 4px 0 calc(28px + env(safe-area-inset-bottom));
  }
  .site-nav.is-open .site-nav-menu { display: block; }

  .site-nav-list { flex-direction: column; gap: 0; }
  .site-nav-trigger {
    justify-content: space-between;
    width: 100%;
    min-height: 56px;
    padding: 0 20px;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    color: var(--ink);
    font-size: 18px;
  }
  .site-nav-trigger:hover { background: var(--surface-2); color: var(--ink); }
  .site-nav-trigger.is-current { box-shadow: none; border-radius: 0; }
  .site-nav-trigger.is-current > span::after { content: " · this page"; color: var(--muted); font-size: 14px; font-weight: 500; }
  .site-nav-item.is-open > .site-nav-trigger { background: var(--surface-2); color: var(--ink); }
  .site-nav-trigger:focus-visible { outline-color: var(--ink); outline-offset: -3px; }
  .site-nav-chev { width: 16px; height: 16px; }

  .site-nav-panel {
    position: static;
    width: auto;
    max-height: none;
    overflow: visible;
    transform: none;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    box-shadow: none;
    background: var(--card);
    animation: none;
  }
  .site-nav-cols { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); padding: 4px 6px; }
  .site-nav-col { padding: 12px 6px 6px; }
  .site-nav-col + .site-nav-col { border-left: 0; }
  .site-nav-link { padding: 9px 8px; }
  .site-nav-foot { padding: 12px 18px; }

  html.site-nav-lock,
  html.site-nav-lock body { overflow: hidden; }
}

@media (max-width: 420px) {
  .site-nav-logo { margin-right: 4px; font-size: 19px; }
  .site-nav-continue { padding: 7px 12px; }
  .site-nav-continue-where { display: none; }
}

/* ---------- Pages under the bar ---------- */
/* Notes pages: the topic sidebar starts under the bar, and so does the phone Topics button. */
.sidebar {
  top: var(--site-nav-h);
  height: calc(100vh - var(--site-nav-h));
  height: calc(100dvh - var(--site-nav-h));
}
.menu-toggle { top: calc(var(--site-nav-h) + 10px); }
.section-title,
.sub-title { scroll-margin-top: calc(var(--site-nav-h) + 16px); }
@media (max-width: 900px) {
  .section-title,
  .sub-title { scroll-margin-top: calc(var(--site-nav-h) + 72px); }
}

/* Printing and the notes PDFs: no bar. */
@media print {
  .site-nav { display: none !important; }
  body { padding-top: 0 !important; }
}
