/* ==========================================================================
   TRACE study page 2026: additions to the standard page. Scoped to .sp.
   ========================================================================== */

.sp-caption { margin: 0; font-size: .82rem; line-height: 1.4; color: var(--text-muted, #626468); }
.sp-meta { margin: 1.5rem 0 0; padding-top: .85rem; border-top: 1px solid var(--trace-border, #e5e7eb); font-size: .82rem; color: var(--text-muted, #626468); }

/* --- Overview: first chart of the published dashboard --------------------- */
.sp-glance {
  max-width: 760px;
  margin: 0 0 1.75rem;
  padding: 1.05rem 1.15rem;
  background: var(--trace-primary-soft, rgba(0,136,58,.08));
  border: 1px solid var(--trace-border, #e5e7eb);
  border-radius: .85rem;
}
.sp-glance-head { display: flex; flex-wrap: wrap; gap: .25rem 1rem; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.sp-glance h2 { margin: 0; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted, #626468); }
.sp-glance h3 { margin: 0 0 .75rem; font-size: 1.05rem; font-weight: 600; color: var(--text-main, #1f2328); }
.sp-link {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--trace-primary-ink, #00662b);
  font-size: .88rem;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}
.sp-link:hover { color: var(--trace-primary-hover, #005b27); }
.sp-bars { margin: 0 0 .75rem; padding: 0; list-style: none; display: grid; grid-template-columns: minmax(64px, max-content) 1fr max-content; gap: .45rem .75rem; align-items: center; font-size: .85rem; }
.sp-bars li { display: contents; }
.sp-bars-label { overflow-wrap: anywhere; }
.sp-bars-track { height: 14px; background: #fff; border-radius: 999px; overflow: hidden; }
.sp-bars-fill { display: block; width: 0; height: 100%; background: var(--trace-primary, #00883a); border-radius: 999px; }
.sp-bars-value { text-align: right; color: var(--text-muted, #626468); font-variant-numeric: tabular-nums; }
.sp-bars:not(.is-ready) { grid-template-columns: 1fr max-content; }
.sp-bars:not(.is-ready) .sp-bars-track { display: none; }

.sp-register { display: flex; flex-wrap: wrap; gap: .35rem 2rem; margin-top: 1.25rem; padding-top: .85rem; border-top: 1px solid var(--trace-border, #e5e7eb); font-size: .9rem; overflow-wrap: anywhere; }

/* --- Side column: access steps -------------------------------------------- */
.sp-steps { margin: 0 0 1rem; padding: 0; list-style: none; counter-reset: sp-step; display: grid; gap: .7rem; font-size: .9rem; }
.sp-steps li { counter-increment: sp-step; display: flex; gap: .65rem; }
.sp-steps li::before {
  content: counter(sp-step);
  flex: none;
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  background: var(--trace-primary-soft, rgba(0,136,58,.08));
  color: var(--trace-primary-ink, #00662b);
  font-size: .78rem;
  font-weight: 700;
}
.sp-access-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.sp-access-actions .btn { flex: 1 1 auto; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; }
.sp-access-actions .btn-primary { background: var(--trace-primary, #00883a); border-color: var(--trace-primary, #00883a); color: #fff; }
.sp-access-actions .btn-primary:hover, .sp-access-actions .btn-primary:focus-visible { background: var(--trace-primary-ink, #00662b); border-color: var(--trace-primary-ink, #00662b); color: #fff; }
.sp-register a { color: var(--trace-primary-ink, #00662b); font-weight: 600; }

/* --- Overview: text flows in up to three columns --------------------------- */
.default-project-theme.sp #overview .project-overview { max-width: none; columns: 3 300px; column-gap: 2.75rem; }
.default-project-theme.sp #overview .project-tab-heading { column-span: all; }
.default-project-theme.sp #overview .project-overview-section,
.default-project-theme.sp #overview .project-overview-section:last-of-type { padding: 0; margin: 0 0 1.4rem !important; border-bottom: 0; }
/* Keep a section title with the lines that follow it: the title reserves room
   below itself, and the text moves up into that room. */
.default-project-theme.sp #overview .project-overview-title { break-inside: avoid; padding-bottom: 4.6em; margin-bottom: calc(.45rem - 4.6em); }
.default-project-theme.sp #overview .project-overview-copy { position: relative; max-width: none; padding-left: 0 !important; }
.default-project-theme.sp #overview .project-overview-copy li { break-inside: avoid; }
.default-project-theme.sp #overview .project-overview-empty { column-span: all; }

/* --- Dashboard: borderless chart cards ------------------------------------- */
.sp-dash-title { margin: 0 0 .25rem; font-size: 1.25rem; font-weight: 700; color: var(--text-main, #1f2328); }
.sp-dash-text { margin: 0 0 .35rem; color: #34383d; }
.sp-dash-asof { margin-bottom: 1.25rem; }
.sp-dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: 1.25rem; }
.sp-chart { min-width: 0; padding: 1.15rem 1.25rem 1rem; background: #fff; border-radius: .85rem; box-shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 20px rgba(16, 24, 40, .07); }
.sp-chart-title { margin: 0 0 .25rem; font-size: 1rem; font-weight: 700; color: var(--text-main, #1f2328); }
.sp-chart-text { margin: 0 0 .5rem; font-size: .88rem; color: var(--text-muted, #626468); }
.sp-chart-frame { height: 240px; margin: .75rem 0; }
.sp-chart-values summary { min-height: 44px; display: flex; align-items: center; color: var(--trace-primary-ink, #00662b); font-size: .88rem; font-weight: 600; cursor: pointer; }
.sp-chart-values summary:hover { text-decoration: underline; }

/* --- Structure: outline with counts ---------------------------------------- */
.sp-struct-head { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; align-items: flex-start; justify-content: space-between; margin-bottom: 1rem; }
.sp-struct-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.sp-struct-actions .btn, .sp-tree-footer .btn { min-height: 44px; display: inline-flex; align-items: center; gap: .45rem; font-weight: 600; }
.sp-struct-note { margin: 0 0 1rem; padding: .65rem .9rem; background: var(--trace-primary-soft, rgba(0,136,58,.08)); border-radius: .6rem; font-size: .9rem; }
.sp-struct-note a { color: var(--trace-primary-ink, #00662b); font-weight: 600; }
.sp-count { margin-left: .5rem; color: var(--text-muted, #626468); font-size: .82rem; font-weight: 400; white-space: nowrap; }
.sp-arm { margin-bottom: 1.5rem; }
.sp-arm-title { margin: 0 0 .6rem; font-size: 1rem; font-weight: 700; color: var(--text-main, #1f2328); }
.sp-event { margin-bottom: .75rem; background: #fff; border-radius: .85rem; box-shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 20px rgba(16, 24, 40, .07); }
.sp-event > summary, .sp-form > summary { display: flex; flex-wrap: wrap; align-items: center; gap: .15rem .25rem; min-height: 48px; padding: .6rem 1.1rem; cursor: pointer; list-style: none; }
.sp-event > summary::-webkit-details-marker, .sp-form > summary::-webkit-details-marker { display: none; }
.sp-event > summary::before, .sp-form > summary::before { content: ""; flex: none; width: .5rem; height: .5rem; margin-right: .6rem; border-right: 2px solid var(--trace-primary, #00883a); border-bottom: 2px solid var(--trace-primary, #00883a); transform: rotate(-45deg); transition: transform .15s; }
.sp-event[open] > summary::before, .sp-form[open] > summary::before { transform: rotate(45deg); }
.sp-event-name { font-weight: 700; color: var(--text-main, #1f2328); overflow-wrap: anywhere; }
.sp-forms { padding: 0 1.1rem .9rem; }
.sp-forms-flat { padding: 0; }
.sp-form { border-top: 1px solid var(--trace-border, #e5e7eb); }
.sp-forms-flat .sp-form:first-child { border-top: 0; }
.sp-form > summary { padding-left: 0; padding-right: 0; }
.sp-form-closed { display: flex; flex-wrap: wrap; align-items: center; gap: .15rem .25rem; min-height: 44px; padding: .5rem 0 .5rem 1.1rem; }
.sp-form-name { font-weight: 600; overflow-wrap: anywhere; }
.sp-form-body { padding: 0 0 .9rem; font-size: .9rem; }
.sp-form-body a { color: var(--trace-primary-ink, #00662b); }
.sp-form-body .variable-table { font-size: .85rem; }
@media (prefers-reduced-motion: reduce) { .sp-event > summary::before, .sp-form > summary::before { transition: none; } }

/* --- Structure: diagram window (styles follow below) ----------------------- */
.sp-btn-green { background: var(--trace-primary, #00883a); border-color: var(--trace-primary, #00883a); min-height: 44px; font-weight: 600; }
.sp-btn-green:hover, .sp-btn-green:focus-visible { background: var(--trace-primary-ink, #00662b); border-color: var(--trace-primary-ink, #00662b); }
.sp-form-body .table-responsive .variable-table { min-width: 640px; }

/* --- Structure: make the levels visible (arm > event > instrument > variables) */
.sp-level { flex: none; margin-right: .55rem; padding: .1rem .45rem; border-radius: .35rem; font-size: .66rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.sp-arm-titled { margin-bottom: 1.75rem; }
.sp-arm-title { display: flex; flex-wrap: wrap; align-items: center; margin: 0 0 .75rem; padding: .7rem 1rem; background: var(--trace-primary, #00883a); border-radius: .7rem; color: #fff; font-size: 1.1rem; }
.sp-arm-title .sp-level { background: #fff; color: var(--trace-primary-ink, #00662b); }
.sp-arm-title .sp-count { color: #fff; }
/* Events hang below their arm on a guide line. */
.sp-arm-titled > .sp-event { margin-left: 1.25rem; position: relative; }
.sp-arm-titled > .sp-event::after { content: ""; position: absolute; left: -.75rem; top: -.75rem; bottom: 50%; width: .75rem; border-left: 2px solid #99cfb0; border-bottom: 2px solid #99cfb0; border-bottom-left-radius: .5rem; pointer-events: none; }
.sp-event > summary { background: #e8f4ed; border-radius: .85rem; }
.sp-event[open] > summary { border-radius: .85rem .85rem 0 0; }
.sp-event > summary .sp-level { background: #cce7d8; color: var(--trace-primary-ink, #00662b); }
.sp-event-name { font-size: 1rem; }
/* Instruments are indented inside their event. */
.sp-event .sp-forms { padding: .35rem 1.1rem .9rem 2.4rem; }
.sp-level-form { background: #f5f5f5; color: #626468; }
.sp-form-name { font-size: .95rem; }
/* Variables sit one level deeper, on a tinted panel. */
.sp-form-body { margin-left: 1.1rem; padding: .75rem .9rem; background: #f8fafc; border-left: 2px solid #c0c1c3; border-radius: 0 .5rem .5rem 0; }
.sp-form[open] { padding-bottom: .9rem; }
@media (max-width: 767.98px) {
  .sp-arm-titled > .sp-event { margin-left: .75rem; }
  .sp-arm-titled > .sp-event::after { left: -.5rem; width: .5rem; }
  .sp-event .sp-forms { padding-left: 1.1rem; }
  .sp-form-body { margin-left: 0; }
}

/* --- Structure diagram: size controls -------------------------------------- */
.sp-tree-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .75rem; }
.sp-tree-tools .btn { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; }
.sp-tree-zoom { min-width: 3.5rem; text-align: center; font-size: .9rem; color: var(--text-muted, #626468); font-variant-numeric: tabular-nums; }
.sp-tree { --sp-zoom: 1; overflow: auto; max-height: 65vh; padding: .25rem; font-size: calc(var(--sp-zoom) * .85rem); }
/* Left-to-right tree made of lists: a box, then the column of what it contains. */
.sp-t, .sp-t ul { margin: 0; padding: 0; list-style: none; }
.sp-t ul { position: relative; margin-left: 2.6em; }
.sp-t ul[hidden] { display: none; }
.sp-t li { position: relative; display: flex; align-items: center; padding: .3em 0; }
.sp-t ul > li::before { content: ""; position: absolute; left: -1.3em; top: 50%; width: 1.3em; border-top: 1.5px solid #99cfb0; }
.sp-t ul > li::after { content: ""; position: absolute; left: -1.3em; top: 0; bottom: 0; border-left: 1.5px solid #99cfb0; }
.sp-t ul > li:first-child::after { top: 50%; }
.sp-t ul > li:last-child::after { bottom: 50%; }
.sp-t ul::before { content: ""; position: absolute; left: -2.6em; top: 50%; width: 1.3em; border-top: 1.5px solid #99cfb0; }
.sp-node { flex: none; display: inline-flex; align-items: center; gap: .75em; max-width: 24em; min-height: 2.9em; padding: .3em .8em; background: #fff; border: 1px solid #c0c1c3; border-radius: .55em; color: #1f2328; font: inherit; line-height: 1.3; text-align: left; }
.sp-node-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-node-count { flex: none; margin-left: auto; color: #626468; font-size: .85em; font-variant-numeric: tabular-nums; }
.sp-node-root { background: var(--trace-primary, #00883a); border-color: var(--trace-primary, #00883a); color: #fff; font-weight: 700; }
.sp-node-arm { background: #e8f4ed; border-color: #99cfb0; font-weight: 700; }
.sp-node-event { font-weight: 600; }
button.sp-node { cursor: pointer; }
button.sp-node::after { content: ""; flex: none; width: .45em; height: .45em; border-right: 2px solid var(--trace-primary, #00883a); border-bottom: 2px solid var(--trace-primary, #00883a); transform: rotate(-45deg); }
button.sp-node[aria-expanded="true"]::after { transform: rotate(135deg); }
button.sp-node:hover { border-color: var(--trace-primary, #00883a); }
button.sp-node:focus-visible { outline: 3px solid #66b889; outline-offset: 2px; }

/* --- Structure diagram: curved connectors, drawn by the page script --------- */
.sp-t-canvas { position: relative; display: inline-block; min-width: 100%; vertical-align: top; }
.sp-t-wires { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.sp-t-wires path { fill: none; stroke: #99cfb0; stroke-width: 1.5; stroke-linecap: round; }
.sp-tree.is-curved .sp-t { position: relative; }
.sp-tree.is-curved .sp-t ul { margin-left: 5em; }
.sp-tree.is-curved .sp-t ul::before,
.sp-tree.is-curved .sp-t ul > li::before,
.sp-tree.is-curved .sp-t ul > li::after { content: none; }

/* --- Publications: reference list by year ---------------------------------- */
.sp-pubs { display: grid; grid-template-columns: 4.5rem minmax(0, 1fr); gap: 1rem 1.25rem; }
.sp-pub-year { padding-top: .8rem; color: var(--trace-primary, #00883a); font-size: 1.45rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.sp-pub-rows { display: grid; gap: .75rem; min-width: 0; }
.sp-pub { min-width: 0; padding: .95rem 1.15rem; background: #fff; border-radius: .85rem; box-shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 20px rgba(16, 24, 40, .07); }
.sp-pub-venue { margin: 0 0 .15rem; color: var(--trace-primary-ink, #00662b); font-size: .8rem; font-weight: 600; overflow-wrap: anywhere; }
.default-project-theme.sp #publications .sp-pub-title { margin: 0 0 .3rem; color: var(--text-main, #1f2328); font-size: 1.02rem; font-weight: 700; line-height: 1.4; overflow-wrap: anywhere; }
.sp-pub-authors, .sp-pub-summary { margin: 0 0 .3rem; color: #34383d; font-size: .9rem; line-height: 1.5; overflow-wrap: anywhere; }
.sp-pub-more { color: var(--text-muted, #626468); }
.sp-pub-summary { color: var(--text-muted, #626468); }
.sp-pub-foot { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; margin-top: .55rem; }
.sp-pub-type { padding: .15rem .55rem; background: var(--trace-primary-soft, rgba(0,136,58,.08)); border-radius: .4rem; color: var(--trace-primary-ink, #00662b); font-size: .76rem; font-weight: 600; }
.sp-pub-doi { color: var(--text-muted, #626468); font-size: .8rem; overflow-wrap: anywhere; }
.sp-pub-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-left: auto; }
.sp-pub-actions .btn { min-height: 44px; display: inline-flex; align-items: center; gap: .35rem; background: #fff; font-weight: 600; }
@media (max-width: 575.98px) {
  .sp-pubs { grid-template-columns: minmax(0, 1fr); gap: .5rem; }
  .sp-pub-year { padding-top: .5rem; font-size: 1.2rem; }
  .sp-pub-actions { margin-left: 0; width: 100%; }
}
