/* ============================================================
   SECTION RAIL  —  static/rail.css

   A sticky list of a page's sections, with the current one
   tracked as you scroll. Used by any long page: Model, Wet Lab,
   Dry Lab, Human Practices.

   One dot per chapter sits on the hairline: hollow ahead of you,
   filled behind, solid and larger where you are. That carries
   the count and the position without any numbering.

   Self-contained: it defines its own colours and takes
   everything else from the page it sits on, so it does not
   depend on home.css or on any change to style.css.

   Every class is prefixed ir- so nothing here can reach
   Bootstrap, the nav, the footer, or the homepage's ih- rules.

   Anchor offset comes from style.css, which already sets
   html { scroll-padding-top: ... } for the floating nav.
   ============================================================ */

.ir-page {
  --ir-accent: #634BE0;
  --ir-line:   rgba(25, 15, 79, .16);
  --ir-dim:    rgba(99, 75, 224, .30);
  --ir-hole:   var(--color-bg, #FBFDFF);
}
:root[data-theme="dark"] .ir-page {
  --ir-accent: #C7A1EF;
  --ir-line:   rgba(210, 203, 247, .20);
  --ir-dim:    rgba(199, 161, 239, .32);
}
/* the hollow dot is punched out of the page, so it follows the
   accessibility backgrounds too */
:root.a11y-contrast[data-theme] .ir-page { --ir-hole: #000; }
:root.a11y-sepia[data-theme]    .ir-page { --ir-hole: #F4ECD8; }

/* ---------- three-column shell: text centred, rail in the left margin ---------- */
.ir-page {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(0, 720px) minmax(0, 1fr);
  gap: 0 40px;
  align-items: start;
  padding-bottom: clamp(240px,42vh, 5600px);
}
.ir-main > section { margin: 0 0 72px; }
.ir-main > section:last-child { margin-bottom: 0; }

/* a grid item will not shrink below its widest child unless told to;
   without this the 760px parameter tables widen the whole page */
.ir-main { min-width: 0; }


/* ---------- the rail ---------- */
.ir-rail {
  position: sticky;
  top: calc(var(--nav-top) + var(--nav-h) + 1rem);
  padding-top: 3px;
  justify-self: start;
  width: 300px;
  padding-left: clamp(0px, 3vw, 60px);
}
.ir-list {
  position: relative;
  padding-left: 18px;
}
/* full-height hairline */
.ir-list::before {
  content: "";
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 2px;
  border-radius: 2px;
  background: var(--ir-line);
  -webkit-mask-image: linear-gradient(transparent, #000 7%, #000 93%, transparent);
          mask-image: linear-gradient(transparent, #000 7%, #000 93%, transparent);
}

.ir-rail ol { list-style: none; margin: 0; padding: 0; }
.ir-rail a {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 9px 0;
  line-height: 1.35;
  transition: color .25s, opacity .25s, font-size .22s cubic-bezier(.2, .8, .2, 1);
}
.ir-rail a:hover { color: var(--ir-accent); text-decoration: none; }
.ir-rail a:focus-visible {
  outline: 2px solid var(--ir-accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---------- wide shell: rail pinned left, text fills the rest ---------- */
@media (min-width: 901px) {
  .ir-page.ir-wide {
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 0 56px;
    max-width: 1500px;
    margin-inline: auto;
    padding-inline: clamp(16px, 3vw, 40px);
  }
   .ir-page.ir-wide .ir-rail {
    justify-self: auto;
    width: auto;
    padding-left: 4px;
  }
     .ir-rail {
    max-height: calc(100vh - var(--nav-top) - var(--nav-h) - 2rem);
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .ir-rail::-webkit-scrollbar { width: 0; height: 0; }
}

/* ---------- chapters ---------- */
.ir-ch > a {
  position: relative;
  font-size: 18px;
  font-weight: 600;
  opacity: .62;
  padding-right: 16px;
}
.ir-ch.is-past > a { opacity: .72; }
.ir-ch > a.is-on {
  font-size: 26px;
  font-weight: 800;
  opacity: 1;
  color: var(--ir-accent);
  letter-spacing: -.015em;
  padding-top: 12px;
  padding-bottom: 12px;
}

/* the dot on the line */
.ir-ch > a::before {
  content: "";
  position: absolute;
  left: -21px;
  top: calc(9px + .68em);
  margin-top: -4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ir-hole);
  box-shadow: 0 0 0 1.6px var(--ir-line);
  transition: background .3s, box-shadow .3s,
              transform .3s cubic-bezier(.2, .8, .2, 1);
}
.ir-ch.is-past > a::before {
  background: var(--ir-dim);
  box-shadow: 0 0 0 1.6px transparent;
}
.ir-ch > a.is-on::before {
  background: var(--ir-accent);
  box-shadow: 0 0 0 1.6px transparent;
  transform: scale(1.45);
  top: calc(12px + .68em);
}
/* the chapter you are inside stays lit while a sub-section is active */
.ir-ch.is-open > a { opacity: 1; color: var(--ir-accent); }
.ir-ch.is-open > a::before {
  background: var(--ir-accent);
  box-shadow: 0 0 0 1.6px transparent;
}

/* chevron, only on chapters that have sub-sections */
.ir-ch.has-sub > a::after {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: -4px;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  opacity: .62;
  transform: rotate(45deg);
  transform-origin: 70% 70%;
  transition: transform .32s cubic-bezier(.2, .8, .2, 1);
}
.ir-ch.is-open > a::after { transform: rotate(-135deg); }

/* sub-sections: collapsed until their chapter is the current one */
.ir-sub {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .34s cubic-bezier(.2, .8, .2, 1);
}
.ir-ch.is-open > .ir-sub { grid-template-rows: 1fr; }
.ir-sub > ol { overflow: hidden; min-height: 0; }

.ir-subs a { font-size: 13.5px; opacity: .5; padding: 5px 0 5px 22px; }
.ir-subs a.is-on { opacity: 1; font-weight: 700; color: var(--ir-accent); }

/* ---------- unnumbered opening entries ---------- */
.ir-pre {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--ir-line);
}
.ir-pre a { font-size: 13.5px; font-weight: 600; opacity: .55; }
.ir-pre a.is-on { opacity: 1; font-weight: 800; color: var(--ir-accent); }

/* ---------- mobile ---------- */
.ir-toggle {
  display: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  border: 0;
  background: none;
  color: inherit;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
  padding: 14px 0;
}
.ir-toggle::after { content: "+"; float: right; font-size: 16px; line-height: 1; }
.ir-toggle[aria-expanded="true"]::after { content: "\2013"; }

@media (max-width: 900px) {
  .ir-page { grid-template-columns: 1fr; gap: 0; }
  .ir-rail {
    position: static;
    margin-bottom: 30px;
    width: auto;
    padding-left: 0;
  }
  .ir-toggle { display: block; }
  .ir-list { display: none; }
  .ir-list.is-open { display: block; }
}

@media (min-width: 901px) {
  .ir-lead { margin-left: -25px; }
  .ir-page.ir-wide .ir-rail { width: 260px; }
}

@media (prefers-reduced-motion: reduce) {
  .ir-rail a,
  .ir-sub,
  .ir-ch > a::before,
  .ir-ch.has-sub > a::after { transition: none; }
}

/* ---------- reading column ---------- */
.ir-main h2 {
  font-size: clamp(25px, 3vw, 32px);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -.015em;
  text-wrap: balance;
  margin-bottom: 1.3rem;
}
.ir-lead {
  font-size: clamp(18px, 1.35vw, 21px);
  line-height: 1.65;
  border-left: 3px solid var(--ir-accent);
  padding-left: 22px;
  margin-bottom: 1.4em;
}

/* ---------- panel block ---------- */
.ir-panel {
  border-radius: 22px;
  padding: 34px 32px 30px;
  margin-bottom: 40px;
  background: color-mix(in srgb, var(--ir-accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--ir-accent) 22%, transparent);
}
.ir-panel .ir-lead { margin-left: 0; }

@media (max-width: 900px) {
  .ir-panel { padding: 24px 20px 22px; border-radius: 16px; }
}


/* ---------- figures ---------- */
.ir-fig { margin: 32px 0; }
.ir-fig img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 14px;
}
.ir-fig figcaption {
  margin-top: 12px;
  font-size: 14px;
  line-height: 1.5;
  opacity: .8;
  text-align: left;
}
.ir-fig .ir-dark { display: none; }
:root[data-theme="dark"] .ir-fig .ir-light { display: none; }
:root[data-theme="dark"] .ir-fig .ir-dark  { display: block; }

/* ---------- drawback branch ---------- */
.ir-branch {
  position: relative;
  margin: 42px 0 30px;
  padding-left: 32px;
}
.ir-branch::before {                 /* stem out of the paragraph above */
  content: "";
  position: absolute;
  left: 9px; top: -28px;
  width: 2px; height: 44px;
  background: var(--ir-line);
  border-radius: 2px;
}
.ir-branch::after {                  /* terminal node — the rail's dot */
  content: "";
  position: absolute;
  left: 4px; top: 10px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--ir-hole);
  box-shadow: 0 0 0 2px var(--ir-accent);
}
.ir-branch-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--ir-accent);
  margin-bottom: 7px;
}
.ir-branch p + p { margin-bottom: 0; }

/* ---------- the response branch ---------- */
.ir-branch-r {
  padding-left: 0;
  padding-right: 32px;
  margin-top: 14px;
  margin-left: 30%;
}
.ir-branch-r::before {
  left: auto;
  right: 9px;
  width: 0;
  background: none;
  border-left: 2px dashed var(--ir-accent);
  opacity: .5;
}
.ir-branch-r::after {
  left: auto;
  right: 4px;
  background: var(--ir-accent);
  box-shadow: none;
}

@media (max-width: 900px) {
  .ir-branch-r {
    margin-left: 0;
    padding-right: 0;
    padding-left: 32px;
  }
  .ir-branch-r::before { right: auto; left: 9px; }
  .ir-branch-r::after  { right: auto; left: 4px; }
}

/* ---------- emphasis ---------- */
.ir-main strong { color: var(--ir-accent); }

/* ---------- cross-references in the text ---------- */
.ir-main p a:not(.cite) {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--ir-accent) 55%, transparent);
  text-decoration-thickness: 1.5px;
  text-underline-offset: .18em;
  transition: color .2s, text-decoration-color .2s;
}
.ir-main p a:not(.cite):hover {
  color: var(--ir-accent);
  text-decoration-color: var(--ir-accent);
}

/* ---------- labelled definitions ---------- */
.ir-defs {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  column-gap: 26px;
  row-gap: 20px;
  margin: 26px 0;
}
.ir-defs dt {
  font-size: .95em;
  font-weight: 700;
  color: var(--ir-accent);
  line-height: 1.6;
}
.ir-defs dd { margin: 0; font-size: .95em; }
@media (max-width: 900px) {
  .ir-defs { grid-template-columns: 1fr; row-gap: 6px; }
  .ir-defs dd { margin-bottom: 16px; }
}

/* ---------- references ---------- */
.ir-refs {
  list-style: none;
  counter-reset: ref;
  padding-left: 0;
  margin: 0;
  overflow-wrap: anywhere;
}
.ir-refs li {
  counter-increment: ref;
  font-size: .9em;
  line-height: 1.6;
  margin-bottom: 14px;
}
.ir-refs li::before {
  content: "[" counter(ref) "] ";
  font-weight: 700;
  color: var(--ir-accent);
}
.ir-refs a { word-break: break-word; }
.ir-refs li:target { font-weight: 600; }

/* ---------- the response arrives ---------- */
@media (prefers-reduced-motion: no-preference) {
  :root.ir-js .ir-main .ir-branch-r {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity .6s ease, transform .6s cubic-bezier(.2, .8, .2, 1);
  }
  :root.ir-js .ir-main .ir-branch-r.is-in { opacity: 1; transform: none; }

  :root.ir-js .ir-branch-r::before {
    transform: scaleY(0);
    transform-origin: top;
    transition: transform .5s ease .12s;
  }
  :root.ir-js .ir-branch-r.is-in::before { transform: scaleY(1); }

  :root.ir-js .ir-branch-r::after {
    transform: scale(0);
    transition: transform .4s cubic-bezier(.2, .8, .2, 1.5) .45s;
  }
  :root.ir-js .ir-branch-r.is-in::after { transform: scale(1); }
}

/* ---------- justified reading text ---------- */
.ir-main p,
.ir-main dd {
  text-align: justify;
  text-justify: inter-word;
  hyphens: none;
  -webkit-hyphens: none;
}

@media (max-width: 900px) {
  .ir-main p,
  .ir-main dd { text-align: left; }
}

/* ---------- references panel ---------- */
.ir-refbox {
  --ir-ref-ink: var(--purple-600, #7E00FF);
  border-radius: 18px;
  overflow: hidden;
  background: color-mix(in srgb, var(--ir-accent) 7%, transparent);
  border: 1px solid color-mix(in srgb, var(--ir-accent) 18%, transparent);
}
:root[data-theme="dark"] .ir-refbox { --ir-ref-ink: var(--purple-300, #C7A1EF); }

.ir-refbox summary {
  list-style: none;
  cursor: pointer;
  position: relative;
  padding: 18px 48px 18px 24px;
  color: var(--ir-ref-ink);
}
.ir-refbox summary h2 {
  display: inline;
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
  line-height: 1;
  color: inherit;
}
.ir-refbox summary::-webkit-details-marker { display: none; }
.ir-refbox summary::after {
  content: "";
  position: absolute;
  right: 24px; top: 50%;
  width: 8px; height: 8px;
  margin-top: -6px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform .3s cubic-bezier(.2, .8, .2, 1);
}
.ir-refbox[open] summary::after { transform: rotate(-135deg); margin-top: -2px; }
.ir-refbox summary:focus-visible { outline: 2px solid var(--ir-ref-ink); outline-offset: -4px; }
.ir-refbox .ir-refs { margin: 0; padding: 0 24px 20px; }