/* eSchool Staff Manual — Material 3 styling.
   Colour scheme generated from the eSchool brand blue (#2e9ccb). */

:root {
  --brand: #2e9ccb;
  --md-primary: #00658f;
  --md-on-primary: #ffffff;
  --md-primary-container: #c7e7ff;
  --md-on-primary-container: #001e2e;
  --md-secondary: #4f616e;
  --md-secondary-container: #d2e5f5;
  --md-on-secondary-container: #0b1d29;
  --md-tertiary-container: #e7deff;
  --md-surface: #f6fafe;
  --md-surface-dim: #d6dade;
  --md-surface-container-lowest: #ffffff;
  --md-surface-container-low: #f0f4f8;
  --md-surface-container: #eaeef2;
  --md-surface-container-high: #e4e8ec;
  --md-surface-container-highest: #dfe3e7;
  --md-on-surface: #171c1f;
  --md-on-surface-variant: #41484d;
  --md-outline: #71787e;
  --md-outline-variant: #c1c7ce;
  --md-scrim: rgb(0 0 0 / 0.32);

  --elev-1: 0 1px 2px rgb(0 0 0 / 0.3), 0 1px 3px 1px rgb(0 0 0 / 0.15);
  --elev-2: 0 1px 2px rgb(0 0 0 / 0.3), 0 2px 6px 2px rgb(0 0 0 / 0.15);
  --elev-3: 0 4px 8px 3px rgb(0 0 0 / 0.15), 0 1px 3px rgb(0 0 0 / 0.3);

  --shape-xs: 4px;
  --shape-s: 8px;
  --shape-m: 12px;
  --shape-l: 16px;
  --shape-xl: 28px;
  --shape-full: 999px;

  --font: "Roboto Flex", Roboto, system-ui, -apple-system, "Segoe UI", sans-serif;
  --drawer-w: 320px;
  --gap: 16px;
  --topbar-h: 64px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: 24px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--md-on-surface);
  background: var(--md-surface-container-low);
}
svg { width: 24px; height: 24px; fill: currentColor; flex: none; }
a { color: var(--md-primary); }
:focus-visible { outline: 3px solid var(--md-primary); outline-offset: 2px; border-radius: var(--shape-xs); }

.skip { position: absolute; left: -9999px; top: 8px; z-index: 100; padding: 8px 16px; background: var(--md-primary); color: var(--md-on-primary); border-radius: var(--shape-full); }
.skip:focus { left: 8px; }

/* ---------- buttons ---------- */
.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; padding: 0;
  border: 0; border-radius: var(--shape-full);
  background: transparent; color: var(--md-on-surface-variant);
  cursor: pointer; position: relative;
}
.icon-btn::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: currentColor; opacity: 0; transition: opacity .15s; }
.icon-btn:hover::after { opacity: .08; }
.icon-btn:active::after { opacity: .12; }
.icon-btn.tonal { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }

/* ---------- top app bar (small screens) ---------- */
.topbar {
  display: none;
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h); padding: 0 8px;
  align-items: center; gap: 4px;
  background: var(--brand); color: #fff;
  box-shadow: var(--elev-2);
}
.topbar .icon-btn { color: #fff; }
.topbar-brand { flex: 1; display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-size: 20px; font-weight: 500; }

/* ---------- layout ---------- */
.shell { display: flex; align-items: flex-start; gap: var(--gap); padding: var(--gap); max-width: 1600px; margin: 0 auto; }

/* Floating contents drawer on the left */
.drawer {
  position: sticky; top: var(--gap);
  width: var(--drawer-w); flex: none;
  height: calc(100vh - 2 * var(--gap));
  height: calc(100dvh - 2 * var(--gap));
  display: flex; flex-direction: column;
  background: var(--md-surface-container-lowest);
  border-radius: var(--shape-l);
  box-shadow: var(--elev-1);
  overflow: hidden;
}
.drawer-brand {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 12px 16px 16px;
  background: var(--brand); color: #fff;
}
.brand-link { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.brand-link img { width: 48px; height: 40px; object-fit: contain; }
.brand-link span { display: flex; flex-direction: column; font-size: 24px; font-weight: 600; line-height: 1.1; }
.brand-link small { font-size: 12px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; opacity: .9; }
.drawer-close { display: none; color: #fff; }

.search-bar {
  display: flex; align-items: center; gap: 12px;
  margin: 16px 12px 8px; padding: 0 16px; height: 48px;
  border: 0; border-radius: var(--shape-xl);
  background: var(--md-surface-container-high); color: var(--md-on-surface-variant);
  font: inherit; font-size: 15px; cursor: pointer; text-align: left;
}
.search-bar span { flex: 1; }
.search-bar kbd {
  display: inline-grid; place-items: center;
  min-width: 26px; height: 26px; padding: 0 6px;
  border-radius: var(--shape-s);
  background: var(--md-surface-container-lowest);
  border: 1px solid var(--md-outline-variant);
  box-shadow: inset 0 -2px 0 var(--md-surface-container-highest);
  color: var(--md-on-surface-variant);
  font: 500 13px/1 var(--font);
}
.search-bar:hover { background: var(--md-surface-container-highest); }

/* Navigation tree */
.nav { flex: 1; overflow-y: auto; padding: 4px 12px 24px; scrollbar-width: thin; overscroll-behavior: contain; }
.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-list .nav-list { display: none; margin-left: 12px; padding-left: 8px; border-left: 1px solid var(--md-outline-variant); }
.nav-item.is-open > .nav-list { display: block; }
.nav-row { display: flex; align-items: center; }
.nav-link {
  flex: 1; display: flex; align-items: center;
  min-height: 40px; padding: 6px 16px;
  border-radius: var(--shape-full);
  color: var(--md-on-surface-variant); text-decoration: none;
  font-size: 14px; font-weight: 500; line-height: 1.3;
  position: relative;
}
.depth-0 > .nav-item > .nav-row > .nav-link, .depth-0 > .nav-item > .nav-link { min-height: 48px; font-size: 15px; color: var(--md-on-surface); }
.nav-link:hover { background: color-mix(in srgb, var(--md-on-surface) 8%, transparent); }
.nav-link.is-current { background: var(--md-secondary-container); color: var(--md-on-secondary-container); font-weight: 600; }
.nav-toggle { width: 36px; height: 36px; margin-left: 2px; color: var(--md-on-surface-variant); }
.nav-toggle svg { width: 20px; height: 20px; }
.nav-toggle svg { transition: transform .2s; }
.nav-item.is-open > .nav-row > .nav-toggle svg { transform: rotate(90deg); }

/* ---------- main ---------- */
.main { flex: 1; min-width: 0; }
.page { display: flex; gap: var(--gap); align-items: flex-start; }
.article {
  flex: 1; min-width: 0;
  background: var(--md-surface-container-lowest);
  border-radius: var(--shape-l);
  box-shadow: var(--elev-1);
  padding: 28px 40px 40px;
}

.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 8px; padding: 0; font-size: 14px; }
.crumbs li { display: flex; align-items: center; gap: 4px; }
.crumbs li + li::before { content: "›"; color: var(--md-outline); }
.crumbs a { color: var(--md-on-surface-variant); text-decoration: none; padding: 2px 6px; border-radius: var(--shape-xs); }
.crumbs a:hover { background: var(--md-surface-container); color: var(--md-primary); }

.title-row { display: flex; align-items: flex-start; gap: 16px; padding-bottom: 16px; margin-bottom: 24px; border-bottom: 1px solid var(--md-outline-variant); }
.title-row h1 { flex: 1; margin: 0; font-size: 36px; line-height: 44px; font-weight: 500; letter-spacing: -.25px; color: var(--md-on-surface); }

/* Article typography */
.content { font-size: 16px; line-height: 1.65; max-width: 1000px; overflow-wrap: anywhere; }
.content > :first-child { margin-top: 0; }
.content p { margin: 0 0 14px; }
.content h2, .content h3, .content h4 { color: var(--md-on-surface); line-height: 1.3; margin: 36px 0 12px; scroll-margin-top: 24px; }
.content h2 { font-size: 28px; font-weight: 500; }
.content h3 { font-size: 22px; font-weight: 500; }
.content h4 { font-size: 18px; font-weight: 600; }
.content h1 { font-size: 30px; font-weight: 500; margin: 32px 0 12px; }
.content ul, .content ol { padding-left: 28px; margin: 0 0 14px; }
.content li { margin: 4px 0; }
.content strong, .content b { font-weight: 600; }
.content a { text-underline-offset: 3px; }
.content a[target="_blank"]::after { content: " ↗"; font-size: .85em; }
.content hr { border: 0; border-top: 1px solid var(--md-outline-variant); margin: 32px 0; }
.content blockquote { margin: 16px 0; padding: 12px 20px; border-left: 4px solid var(--md-primary); background: var(--md-surface-container-low); border-radius: 0 var(--shape-m) var(--shape-m) 0; }

/* Screenshots: keep authored size, never overflow, click to enlarge */
.content img {
  max-width: 100%; height: auto;
  border-radius: var(--shape-s);
  border: 1px solid var(--md-outline-variant);
  background: #fff;
  vertical-align: middle;
  cursor: zoom-in;
  transition: box-shadow .15s;
}
.content img:hover { box-shadow: var(--elev-2); }
.content p:has(> img:only-child) { margin: 16px 0 24px; }
.content .right, .content [style*="float: right"] { float: right; margin: 0 0 16px 16px; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 16px 0 24px; border: 1px solid var(--md-outline-variant); border-radius: var(--shape-m); }
.content table { border-collapse: collapse; width: 100%; font-size: 15px; }
.content td, .content th { border: 1px solid var(--md-outline-variant); padding: 8px 12px; vertical-align: top; text-align: left; }
.content th, .content thead td { background: var(--md-surface-container); font-weight: 600; }
.content tr:first-child > * { border-top: 0; }
.content tr > :first-child { border-left: 0; }
.content tr > :last-child { border-right: 0; }
.content tr:last-child > * { border-bottom: 0; }
.content table img { cursor: zoom-in; }

/* On this page */
.toc {
  position: sticky; top: var(--gap);
  width: 240px; flex: none;
  max-height: calc(100vh - 2 * var(--gap)); overflow-y: auto;
  padding: 16px 12px;
  background: var(--md-surface-container-lowest);
  border-radius: var(--shape-l);
  box-shadow: var(--elev-1);
  font-size: 13px;
}
.toc-title { margin: 0 8px 8px; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--md-on-surface-variant); }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc a { display: block; padding: 6px 8px; border-radius: var(--shape-s); color: var(--md-on-surface-variant); text-decoration: none; line-height: 1.35; }
.toc a:hover { background: var(--md-surface-container); }
.toc a.is-active { color: var(--md-primary); background: var(--md-primary-container); font-weight: 600; }
.toc .lvl-3 a { padding-left: 20px; }
.toc .lvl-4 a { padding-left: 32px; }

/* Previous / next */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); margin-top: var(--gap); }
.pager-card {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 20px; min-height: 72px;
  background: var(--md-surface-container-lowest);
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--shape-l);
  color: var(--md-on-surface); text-decoration: none; font-weight: 500;
}
.pager-card:hover { border-color: var(--md-primary); box-shadow: var(--elev-1); }
.pager-card small { display: block; font-size: 12px; font-weight: 500; color: var(--md-on-surface-variant); }
.pager-card svg { color: var(--md-primary); }
.pager-card.next { justify-content: flex-end; text-align: right; }

.footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 24px 8px 8px; font-size: 13px; color: var(--md-on-surface-variant); }
.to-top { display: inline-flex; align-items: center; gap: 4px; color: var(--md-on-surface-variant); text-decoration: none; }
.to-top svg { width: 18px; height: 18px; }

/* ---------- dialogs ---------- */
dialog { border: 0; padding: 0; color: inherit; }
dialog::backdrop { background: var(--md-scrim); }
.search-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: min(80vh, 760px);
  margin: 10vh auto auto;
  border-radius: var(--shape-xl);
  background: var(--md-surface-container-high);
  box-shadow: var(--elev-3);
}
.search-head { display: flex; gap: 12px; align-items: flex-start; padding: 16px; }
.search-head #search { flex: 1; min-width: 0; }
/* Close button: same height as the search field and centred on it */
.search-head > .icon-btn {
  width: 56px; height: 56px; margin-top: 1px;
  background: var(--md-surface-container-lowest);
  border: 1px solid var(--md-outline-variant);
  color: var(--md-on-surface-variant);
}
.search-head > .icon-btn:hover { border-color: var(--md-outline); }
#search .pagefind-ui__search-input { font-weight: 400; }
#search .pagefind-ui__search-input::placeholder { color: var(--md-on-surface-variant); opacity: 1; }
#search {
  --pagefind-ui-scale: .9;
  --pagefind-ui-primary: var(--md-primary);
  --pagefind-ui-text: var(--md-on-surface);
  --pagefind-ui-background: var(--md-surface-container-lowest);
  --pagefind-ui-border: var(--md-outline-variant);
  --pagefind-ui-tag: var(--md-secondary-container);
  --pagefind-ui-border-width: 1px;
  --pagefind-ui-border-radius: 16px;
  --pagefind-ui-font: var(--font);
}
#search .pagefind-ui__search-input { border-radius: var(--shape-xl); }
/* Clear: a fixed-size pill centred inside the search field (the field is 64px × scale tall) */
#search .pagefind-ui__search-clear {
  border: 0; border-radius: var(--shape-full);
  background: transparent; color: var(--md-primary);
  font: 500 14px/1 var(--font);
  padding: 0 16px;
  height: 40px; top: calc(32px * var(--pagefind-ui-scale) - 20px); right: 8px;
}
#search .pagefind-ui__search-clear:hover { background: var(--md-primary-container); }
#search .pagefind-ui__result-link { color: var(--md-primary); }
#search .pagefind-ui__result-thumb { display: none; }
#search .pagefind-ui__drawer { max-height: calc(min(80vh, 760px) - 110px); overflow-y: auto; }

.zoom-dialog { max-width: 96vw; max-height: 96vh; background: transparent; overflow: visible; }
.zoom-dialog img { display: block; max-width: 96vw; max-height: 92vh; border-radius: var(--shape-m); background: #fff; box-shadow: var(--elev-3); }
.zoom-close { position: absolute; top: -48px; right: 0; background: var(--md-surface-container-lowest); }

/* ---------- plain pages (access / 404) ---------- */
body.plain .drawer, body.plain .topbar [data-open-nav], body.plain .print-btn { display: none; }
body.plain .shell { max-width: 760px; padding-top: 10vh; }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .toc { display: none; }
}
@media (max-width: 960px) {
  .topbar { display: flex; }
  .shell { padding: 12px; display: block; }
  .drawer {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 40;
    height: 100vh; height: 100dvh; width: min(var(--drawer-w), 86vw);
    border-radius: 0 var(--shape-l) var(--shape-l) 0;
    box-shadow: var(--elev-3);
    transform: translateX(-105%); transition: transform .25s cubic-bezier(.2, 0, 0, 1);
  }
  .drawer-close { display: inline-grid; }
  body.nav-open .drawer { transform: none; }
  .scrim { position: fixed; inset: 0; z-index: 30; background: var(--md-scrim); opacity: 0; pointer-events: none; transition: opacity .25s; }
  body.nav-open .scrim { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }
  .article { padding: 20px 20px 28px; }
  .title-row h1 { font-size: 28px; line-height: 36px; }
  .search-bar kbd { display: none; }
}
@media (max-width: 560px) {
  .pager { grid-template-columns: 1fr; }
  .content .right, .content [style*="float: right"] { float: none; margin: 0 0 16px; }
}

/* ---------- print: just the page ---------- */
@media print {
  .topbar, .drawer, .scrim, .toc, .pager, .footer, .print-btn, .crumbs, dialog { display: none !important; }
  body, .shell, .article { background: #fff; box-shadow: none; padding: 0; margin: 0; display: block; }
  .content img { break-inside: avoid; border: 0; }
  .content a[target="_blank"]::after { content: ""; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
