/* =============================================================================
   agTeachingNotes.css
   House stylesheet for long-form NOTES pages (teaching-notes/).

   A notes page is built from the same markdown as a slide deck - a file
   whose front matter says  type: "notes"  - by the same builder
   (framework/build.html or convert.bat). The deck links agSlides.css; the
   notes page links this file. Both import agContent.css, which holds the
   palette, the colour roles and the light/dark theme, so a page of notes and
   a deck can never disagree about colour.

       agContent.css          shared: palette, roles, light/dark, fonts, icons
        +- agSlides.css         the deck layer
        +- agTeachingNotes.css  THIS FILE: the page layer

   -----------------------------------------------------------------------------
   WHAT A PAGE NEEDS THAT A DECK DOES NOT

   - A READING MEASURE. Long lines are tiring to read; ~65-75 characters is
     the long-established comfortable range. The text column is
     --ag-notes-measure wide, which gives about 75 at the body size.
   - A CONTENTS LIST, generated by the builder from the headings. On a wide
     screen it sits in a sticky column on the left; on a narrow one it is a
     box above the text.
   - PRINT RULES. Students print notes or save them as PDF. Without these,
     figures split across pages, headings strand at the foot of a page, and
     demos print as blank boxes. Paper is always light: the page's script
     switches to the light theme for printing and back afterwards.
   - Comfortable type: 18px body (on a default browser), 1.6 line height.

   WHAT IS DELIBERATELY THE SAME AS THE SLIDES

   The semantic blocks (.keypoint, .question, .definition, .top-tip,
   .learning-outcomes), quotations and figure captions mean the same thing in
   both media, so they are drawn to the same design here - centred violet
   keypoint, left-ruled definition, powder-violet panel band and so on - only
   re-sized for a page. They belong in agContent.css in the long run; they
   are here for now because the slide versions are scoped to reveal and
   moving them is a refactor of agSlides.css still to be done carefully. If
   you change one of these designs, change it in agSlides.css section 6/5d
   too, until that refactor happens.

   Every colour here is a ROLE from agContent.css, never a raw palette
   colour - that is what makes the dark theme work. If you add a rule, use a
   role.
============================================================================= */

@import url("agContent.css");


/* -----------------------------------------------------------------------------
   1. PAGE
----------------------------------------------------------------------------- */

:root {
  --ag-notes-measure:   42rem;     /* the text column: ~75 characters        */
  --ag-notes-toc-width: 15rem;     /* the contents column on a wide screen   */
  --ag-notes-font-size: 1.125rem;  /* 18px with the browser's default 16px   */
  --ag-notes-leading:   1.6;
  color-scheme: light;
}

:root[data-theme="dark"] { color-scheme: dark; }

html {
  -webkit-text-size-adjust: 100%;
          text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--ag-surface);
  color: var(--ag-body-text);
  font-family: var(--ag-text-sans);
  font-size: var(--ag-notes-font-size);
  line-height: var(--ag-notes-leading);
}

::selection { background: var(--ag-selection); }

:focus-visible {
  outline: 2px solid var(--ag-accent);
  outline-offset: 2px;
}

/* One column by default - phones, tablets, narrow windows - with the
   contents list as a box above the text. */
.ag-notes-page {
  box-sizing: border-box;
  max-width: calc(var(--ag-notes-measure) + 2.5rem);
  margin: 0 auto;
  padding: 3.5rem 1.25rem 5rem;
}

/* Wide screens: the contents list becomes a sticky column on the left. Only
   when there IS a contents list - :has() checks - otherwise the text would sit
   off-centre beside an empty column. Browsers without :has() keep the
   single-column layout, which is perfectly usable. 72rem is 1152px. */
@media (min-width: 72rem) {
  .ag-notes-page:has(> .ag-toc) {
    max-width: calc(var(--ag-notes-toc-width) + 3rem + var(--ag-notes-measure) + 2.5rem);
    display: grid;
    grid-template-columns: var(--ag-notes-toc-width) minmax(0, var(--ag-notes-measure));
    grid-template-areas:
      ".   header"
      "toc main";
    column-gap: 3rem;
  }
  .ag-notes-page:has(> .ag-toc) > .ag-notes-header { grid-area: header; }
  .ag-notes-page:has(> .ag-toc) > .ag-notes        { grid-area: main; }
  .ag-notes-page:has(> .ag-toc) > .ag-toc {
    grid-area: toc;
    position: sticky;
    top: 1.5rem;
    align-self: start;
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
    margin: 0;
    padding: 0.2rem 0 0;
    border: 0;
  }
}

/* Keyboard users can jump past the header and contents list. Invisible until
   it has focus - the first Tab on the page. */
.ag-skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 100;
  padding: 0.5rem 0.9rem;
  border-radius: 0 0 6px 6px;
  background: var(--ag-emphasis);
  color: var(--ag-surface);
  font-weight: 600;
  text-decoration: none;
}
.ag-skip-link:focus { top: 0; }


/* -----------------------------------------------------------------------------
   2. THE LIGHT / DARK TOGGLE
   -----------------------------------------------------------------------------
   Same behaviour and the same remembered choice as the decks (one stored
   preference, so a student's choice follows them from slides to notes). A
   simpler control than the deck's sliding pill: on a page there is no
   projected audience for it to distract, so it can simply be a visible
   button. The glyph shows the CURRENT theme; the aria-label describes the
   action.
----------------------------------------------------------------------------- */

#ag-theme-toggle {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  border: 1px solid var(--ag-rule);
  border-radius: 999px;
  background: var(--ag-surface);
  color: var(--ag-emphasis);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

#ag-theme-toggle:hover,
#ag-theme-toggle:focus-visible { opacity: 1; }

.ag-toggle-knob { pointer-events: none; }

/* Decorative motion, so it goes for anyone who has asked for less. */
@media (prefers-reduced-motion: reduce) {
  #ag-theme-toggle { transition: none; }
}


/* -----------------------------------------------------------------------------
   3. HEADER
   -----------------------------------------------------------------------------
   Built from the front matter with the same fields as a deck's cover: kicker,
   title, subtitle, then author and institute on one line, details and date on
   the next. A short violet bar closes it, echoing the rule on the cover.
----------------------------------------------------------------------------- */

.ag-notes-header {
  margin-bottom: 2.5rem;
}

.ag-notes-header::after {
  content: "";
  display: block;
  width: 4rem;
  height: 3px;
  margin-top: 1.5rem;
  border-radius: 2px;
  background: var(--ag-emphasis);
}

.ag-notes-kicker {
  margin: 0 0 0.8rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ag-emphasis);
}

.ag-notes-header h1 {
  margin: 0;
  font-size: clamp(2.1rem, 1.5rem + 2.2vw, 3rem);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.02em;
  color: var(--ag-heading);
  text-wrap: balance;
}

.ag-notes-subtitle {
  margin: 0.7rem 0 0;
  font-family: var(--ag-text-serif);
  font-style: italic;
  font-size: 1.3rem;
  line-height: 1.35;
  color: var(--ag-body-text);
}

.ag-notes-meta {
  margin: 1.1rem 0 0;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--ag-body-text);
  opacity: 0.8;
}
.ag-notes-meta + .ag-notes-meta { margin-top: 0.15rem; }

/* A middle dot between the parts, drawn here so the markup stays plain. The
   "/ ''" gives it empty alt text, so a screen reader does not say "dot". */
.ag-notes-meta > span + span::before {
  content: "\00B7";
  content: "\00B7" / "";
  margin: 0 0.55em;
  color: var(--ag-emphasis);
}


/* -----------------------------------------------------------------------------
   4. CONTENTS LIST
----------------------------------------------------------------------------- */

.ag-toc {
  margin: 0 0 2.5rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--ag-rule);
  border-radius: 8px;
  font-size: 0.95rem;
  line-height: 1.4;
}

.ag-toc h2 {
  margin: 0 0 0.7rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ag-emphasis);
}

.ag-toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.ag-toc ol ol {
  margin: 0.3rem 0 0.4rem;
  padding-left: 0.9rem;
  border-left: 1px solid var(--ag-rule);
  font-size: 0.93em;
}

.ag-toc li { margin: 0.35rem 0; }

.ag-toc a {
  color: var(--ag-body-text);
  text-decoration: none;
}

.ag-toc a:hover {
  color: var(--ag-link);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}


/* -----------------------------------------------------------------------------
   5. TEXT
   -----------------------------------------------------------------------------
   Headings in the HTML are one level below the markdown (# is <h2>), because
   the page title is the only <h1>. So .ag-notes h2 is a "#" heading.
----------------------------------------------------------------------------- */

.ag-notes > :first-child { margin-top: 0; }

.ag-notes :is(h2, h3, h4, h5, h6) {
  color: var(--ag-heading);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-wrap: balance;
  scroll-margin-top: 1.5rem;       /* contents-list links land with breathing room */
}

/* "#" - a major section. Carries the full-width rule a slide title has. */
.ag-notes h2 {
  margin: 2.8rem 0 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--ag-rule);
  font-size: 1.75rem;
}

/* "##" - a section. Brand violet, as an h3 is on a slide. */
.ag-notes h3 {
  margin: 2.1rem 0 0.7rem;
  font-size: 1.45rem;              /* a clear step above "###" at 1.25rem */
  color: var(--ag-subheading);
}

/* "###" and below.

   RULE: no heading is ever smaller than the body text (1.125rem). The first
   version set "###" at 1.1rem - fractionally SMALLER than the paragraph under
   it - so only its weight told it apart, and Andrew found it hard to see
   (2026-11-09). A heading needs at least two cues out of size, weight,
   colour and space; "###" now has three: a clear size step (1.25rem, between
   body and "##"), heavier weight, and more space above than below, so it
   visibly belongs to the text that follows it. */
.ag-notes h4 {
  margin: 2rem 0 0.45rem;
  font-size: 1.25rem;
  font-weight: 700;
}

/* "####" and deeper are rare in notes. At body size they are told apart by
   small capitals and the emphasis colour instead of by size. */
.ag-notes :is(h5, h6) {
  margin: 1.6rem 0 0.4rem;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ag-emphasis);
}

.ag-notes :is(p, ul, ol, dl, table) { margin: 0 0 1em; }
.ag-notes :is(p, li) { text-wrap: pretty; }

.ag-notes :is(ul, ol) { padding-left: 1.5em; }
.ag-notes li { margin: 0.3em 0; }
.ag-notes li > :is(ul, ol) { margin: 0.3em 0 0; }
.ag-notes li::marker {
  color: var(--ag-marker);
  font-variant-numeric: tabular-nums;
}

/* Both emphases are violet, as on the slides: strong carries weight, em
   carries slant, and colour marks both as emphasis. */
.ag-notes strong { color: var(--ag-emphasis); font-weight: 700; }
.ag-notes em     { color: var(--ag-emphasis); }

.ag-notes a {
  color: var(--ag-link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
.ag-notes a:hover { color: var(--ag-link-hover); }

.ag-notes hr {
  margin: 2.5rem 0;
  border: 0;
  border-top: 1px solid var(--ag-rule);
}

/* Definition lists: term bold, definition indented under it. */
.ag-notes dt {
  margin-top: 0.8em;
  font-weight: 700;
  color: var(--ag-heading);
}
.ag-notes dd { margin: 0.15em 0 0 1.5em; }

/* Columns are a slide layout. On a page they simply stack - the builder drops
   the widths - so explanation sits above and below a figure, not beside it. */
.ag-notes :is(.columns, .column) { display: block; }


/* -----------------------------------------------------------------------------
   6. CODE AND TABLES
----------------------------------------------------------------------------- */

.ag-notes code {
  padding: 0.1em 0.3em;
  border-radius: 4px;
  background: var(--ag-panel-body);
  font-family: var(--ag-text-mono);
  font-size: 0.88em;
}

.ag-notes pre {
  margin: 1.4rem 0;
  padding: 0.9rem 1.1rem;
  border-radius: 8px;
  background: var(--ag-panel-body);
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.45;
}
.ag-notes pre code {
  padding: 0;
  background: none;
  font-size: inherit;
}

.ag-notes table {
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.95rem;
}
.ag-notes :is(th, td) {
  padding: 0.45em 0.8em;
  border-bottom: 1px solid var(--ag-rule);
  vertical-align: top;
}
/* Left-aligned unless the markdown asked otherwise (|:--:| gives align=). */
.ag-notes th:not([align]) { text-align: left; }
.ag-notes th {
  border-bottom-width: 2px;
  color: var(--ag-heading);
  font-weight: 600;
}


/* -----------------------------------------------------------------------------
   7. MATHS
   -----------------------------------------------------------------------------
   MathJax draws equations as SVG from framework/mathjax, offline. A display
   equation wider than the column scrolls sideways rather than being squashed
   - the usual choice on a page, where a phone screen is narrow but nothing
   is projected. (Slides shrink it instead, because a projection cannot
   scroll.)
----------------------------------------------------------------------------- */

.ag-notes .math.display { display: block; }

.ag-notes mjx-container[display="true"] {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.15em 0;
}


/* -----------------------------------------------------------------------------
   8. FIGURES
   -----------------------------------------------------------------------------
   An image alone on a line becomes <figure> + <figcaption>, exactly as on a
   slide. Diagrams (.svg) arrive as <object> so their linked stylesheet works;
   width: 100% gives an object something to scale from, and its own
   width/height attributes keep the proportions.
----------------------------------------------------------------------------- */

.ag-notes figure {
  margin: 2rem 0;
  text-align: center;
}

.ag-notes figure :is(img, object) {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.ag-notes figure object { width: 100%; }

.ag-notes figcaption {
  margin-top: 0.6rem;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--ag-body-text);
  opacity: 0.8;
}


/* -----------------------------------------------------------------------------
   9. EMBEDDED DEMOS
----------------------------------------------------------------------------- */

.ag-notes .ag-demo-embed { margin: 2rem 0; }

.ag-notes iframe.demo-frame {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 6px;
  background: #fff;           /* demos are designed on white, whatever the theme */
}

/* The sentence that stands in for a demo on paper. Hidden on screen. */
.ag-print-only { display: none; }


/* -----------------------------------------------------------------------------
   10. QUOTATIONS  -  same design as agSlides.css 5d
   -----------------------------------------------------------------------------
   > The words being quoted.
   >
   > — Who said it

   A soft centred box with large opening and closing marks; the attribution
   right-aligned like a signature, with its dash drawn here.
----------------------------------------------------------------------------- */

/* Two plain selectors, NOT .ag-notes :is(figure.quote, blockquote): :is()
   takes the specificity of its strongest argument, so that form would outrank
   the blockquote's own side padding below and push the marks into the text. */
.ag-notes figure.quote,
.ag-notes blockquote {
  box-sizing: border-box;
  width: fit-content;
  max-width: 90%;
  margin: 2rem auto;
  padding: 1rem 1.25rem;
  border-radius: 12px;
  background: var(--ag-panel-body);
}

.ag-notes blockquote {
  position: relative;
  padding-left: 2.6rem;
  padding-right: 2.6rem;
  font-style: italic;
  text-align: center;
}

.ag-notes figure.quote blockquote {
  width: auto;
  max-width: none;
  margin: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-radius: 0;
  background: none;
}

/* The marks are decoration: empty alt text, so screen readers skip them. */
.ag-notes blockquote::before,
.ag-notes blockquote::after {
  position: absolute;
  font-family: var(--ag-text-serif);
  font-size: 2.6em;
  font-style: normal;
  line-height: 1;
  color: var(--ag-accent);
  opacity: 0.55;
}
.ag-notes blockquote::before {
  content: "\201C";
  content: "\201C" / "";
  left: 0.15em;
  top: 0;
}
.ag-notes blockquote::after {
  content: "\201D";
  content: "\201D" / "";
  right: 0.15em;
  bottom: -0.45em;
}

.ag-notes blockquote > :first-child { margin-top: 0; }
.ag-notes blockquote > :last-child  { margin-bottom: 0; }

.ag-notes figure.quote figcaption {
  margin-top: 0.6rem;
  padding-right: 2.6rem;
  font-size: 0.9rem;
  text-align: right;
  color: var(--ag-emphasis);
  opacity: 1;
}
.ag-notes figure.quote figcaption::before { content: "\2014\00A0"; }


/* -----------------------------------------------------------------------------
   11. SEMANTIC BLOCKS  -  same design as agSlides.css section 6
   -----------------------------------------------------------------------------
       keypoint     the thing to remember: centred, bold, violet, unboxed
       question     something actually being asked: centred italic accent
       definition   a formal definition: left rule, pale violet wash
       top-tip      a practical aside: left rule, electric wash, labelled
----------------------------------------------------------------------------- */

.ag-notes :is(.keypoint, .question, .definition, .top-tip) > :first-child { margin-top: 0; }
.ag-notes :is(.keypoint, .question, .definition, .top-tip) > :last-child  { margin-bottom: 0; }

.ag-notes .keypoint {
  max-width: 90%;
  margin: 2rem auto;
  text-align: center;
  font-size: 1.15em;
  font-weight: 700;
  line-height: 1.35;
  color: var(--ag-emphasis);
}

.ag-notes .question {
  max-width: 90%;
  margin: 2rem auto;
  text-align: center;
  font-size: 1.15em;
  font-style: italic;
  line-height: 1.4;
  color: var(--ag-accent);
}

.ag-notes .definition {
  margin: 1.5rem 0;
  padding: 0.8rem 1.1rem;
  border-left: 5px solid var(--ag-emphasis);
  background: var(--ag-tint-violet);
}

.ag-notes .top-tip {
  margin: 1.5rem 0;
  padding: 0.8rem 1.1rem;
  border-left: 5px solid var(--ag-accent);
  background: var(--ag-tint-tip);
}

.ag-notes .top-tip::before {
  content: "Top tip";
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ag-accent);
}

/* -- learning-outcomes: the boxed panel with a powder-violet header band and
   a target icon, matching the slides and the MEE Labs 2.0 callout. The label
   is supplied here, so the markdown carries only the outcomes. ------------ */
.ag-notes .learning-outcomes {
  position: relative;               /* anchors the icon                      */
  margin: 1.5rem 0 2rem;
  padding: 0 0 0.6rem;
  border: 2px solid var(--ag-panel-head);
  border-radius: 4px;
  background: var(--ag-panel-body);
  overflow: hidden;                 /* clips the band to the rounded corners */
}

.ag-notes .learning-outcomes::before {
  content: "Learning outcomes";
  display: block;
  margin-bottom: 0.7rem;
  padding: 0.4rem 1rem 0.4rem 2.5rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ag-panel-head-text);
  background: var(--ag-panel-head);
}

.ag-notes .learning-outcomes::after {
  content: "";
  position: absolute;
  top: 0.62rem;
  left: 0.85rem;
  width: 1.05rem;
  height: 1.05rem;
  background-color: var(--ag-panel-head-text);
  -webkit-mask: var(--ag-icon-target) center / contain no-repeat;
          mask: var(--ag-icon-target) center / contain no-repeat;
}

.ag-notes .learning-outcomes > * {
  margin-left: 1.1rem;
  margin-right: 1.1rem;
}
.ag-notes .learning-outcomes > :is(ol, ul) { padding-left: 1.4em; }
.ag-notes .learning-outcomes > :last-child { margin-bottom: 0; }


/* -----------------------------------------------------------------------------
   12. PRINT
   -----------------------------------------------------------------------------
   The page script switches to the light theme before printing, so no colour
   overrides are needed here - only layout.
----------------------------------------------------------------------------- */

@media print {
  @page { margin: 18mm 16mm; }

  :root { --ag-notes-font-size: 11pt; }
  body  { background: #fff; }

  #ag-theme-toggle,
  .ag-skip-link,
  .ag-toc { display: none !important; }

  .ag-notes-page,
  .ag-notes-page:has(> .ag-toc) {
    display: block;
    max-width: none;
    padding: 0;
  }

  /* Never leave a heading alone at the foot of a page. */
  .ag-notes :is(h2, h3, h4, h5, h6) { break-after: avoid; }

  /* Keep these whole rather than splitting them across a page break. */
  .ag-notes :is(figure, pre, table, blockquote, .definition, .top-tip,
                .keypoint, .question, .learning-outcomes, .math.display) {
    break-inside: avoid;
  }

  .ag-notes :is(p, li) { orphans: 3; widows: 3; }

  /* A tall photo should not take a whole page to itself. Photos only: a
     diagram (<object>) keeps its width so its line weights stay consistent. */
  .ag-notes figure img {
    max-height: 120mm;
    width: auto;
  }

  /* Paper cannot be clicked, so an external link prints its address. */
  .ag-notes a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.85em;
    word-break: break-all;
  }

  /* An iframe prints as an empty box. Show the sentence instead. */
  .ag-notes iframe.demo-frame { display: none; }
  .ag-print-only {
    display: block;
    margin: 0;
    padding: 0.6rem 0.9rem;
    border: 1px dashed var(--ag-panel-head);
    border-radius: 6px;
    font-style: italic;
  }
}
