/* Math Harness document layout on top of the canonical chao-ui theme. */

html {
  color-scheme: light;
  scroll-behavior: smooth;
}

body {
  min-width: 20rem;
  background: var(--pf-bg);
  color: var(--pf-fg);
  font-size: 1rem;
  line-height: 1.62;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--pf-accent);
  color: var(--pf-accent-fg);
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0;
  left: 0;
  padding: 0.55rem 0.75rem;
  background: var(--pf-accent);
  color: var(--pf-accent-fg);
  font-size: 0.8rem;
  font-weight: 600;
  transform: translateY(-110%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-masthead {
  width: min(calc(100% - 3rem), 62.5rem);
  min-height: 3.5rem;
  margin: 0 auto;
  border-bottom: 2px solid var(--pf-border-strong);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

.site-masthead p {
  color: var(--pf-muted);
  font-family: var(--pf-font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.site-name {
  border: 0;
  color: var(--pf-fg);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
}

.reading-layout {
  width: min(calc(100% - 3rem), 62.5rem);
  margin: 0 auto;
  padding: 2.5rem 0 5rem;
  display: grid;
  grid-template-columns: minmax(10rem, 13rem) minmax(0, 1fr);
  align-items: start;
  gap: 3rem;
}

.toc-rail {
  min-width: 0;
  position: sticky;
  top: 1.5rem;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  scrollbar-width: thin;
}

.toc-disclosure {
  border-top: 2px solid var(--pf-border-strong);
  padding-top: 0.65rem;
}

.toc-disclosure summary {
  list-style: none;
  color: var(--pf-muted);
  cursor: default;
  font-family: var(--pf-font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.toc-disclosure summary::-webkit-details-marker,
.toc-disclosure summary span:last-child {
  display: none;
}

#TOC {
  margin-top: 0.65rem;
}

#TOC ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

#TOC ul ul {
  margin: 0.2rem 0 0.45rem;
  border-left: 1px solid var(--pf-border);
  padding-left: 0.65rem;
}

#TOC li,
#TOC li + li {
  margin: 0;
  padding: 0;
}

#TOC a {
  display: block;
  border: 0;
  padding: 0.18rem 0;
  color: var(--pf-muted);
  font-size: 0.75rem;
  line-height: 1.35;
  text-decoration: none;
}

#TOC > ul > li > a {
  padding-top: 0.42rem;
  color: var(--pf-fg);
  font-weight: 600;
}

#TOC a:hover,
#TOC a:focus-visible {
  color: var(--pf-fg);
  text-decoration: underline;
  text-underline-offset: 0.16em;
}

main {
  min-width: 0;
  outline: none;
}

.document-header {
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--pf-border);
  padding-bottom: 1.5rem;
}

.document-title {
  margin: 0;
  color: var(--pf-fg);
  font-size: clamp(2.1rem, 6vw, 3.25rem);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.04;
  text-wrap: balance;
}

.document-header p:first-of-type {
  margin-top: 0.9rem;
  color: var(--pf-muted);
  font-size: 1.05rem;
  line-height: 1.45;
}

.document-header p:nth-of-type(2) {
  margin-top: 0.45rem;
  color: var(--pf-muted);
  font-family: var(--pf-font-mono);
  font-size: 0.72rem;
}

.document-header em {
  font-style: normal;
}

.document-body > .document-header + p {
  margin-top: 0;
  font-size: 1.04rem;
}

.document-body p,
.document-body ul,
.document-body ol,
.document-body blockquote,
.document-body pre,
.table-scroll {
  margin-top: 0.9rem;
  margin-bottom: 0.9rem;
}

.document-body p {
  overflow-wrap: break-word;
  text-wrap: pretty;
}

.document-body h2,
.document-body h3,
.document-body h4 {
  color: var(--pf-accent);
  line-height: 1.25;
  scroll-margin-top: 1.5rem;
  text-wrap: balance;
}

.document-body h2 {
  margin: 3rem 0 1rem;
  border-bottom: 1px solid var(--pf-border);
  padding-bottom: 0.4rem;
  font-size: 1.5rem;
}

.document-body h3 {
  margin: 2.1rem 0 0.65rem;
  font-size: 1.15rem;
}

.document-body h4 {
  margin: 1.6rem 0 0.55rem;
  font-size: 1rem;
}

.document-body a,
.document-footer a {
  border-bottom: 1px dotted var(--pf-border-strong);
  color: inherit;
  overflow-wrap: anywhere;
  text-decoration: none;
}

.document-body a:hover,
.document-footer a:hover {
  border-bottom-color: var(--pf-fg);
}

a:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--pf-accent);
  outline-offset: 3px;
}

.document-body ul,
.document-body ol {
  padding-left: 1.35rem;
}

.document-body li {
  padding-left: 0.15rem;
}

.document-body li + li {
  margin-top: 0.3rem;
}

.document-body blockquote {
  border-left: 3px solid var(--pf-border-strong);
  padding: 0.1rem 0 0.1rem 1rem;
  color: var(--pf-muted);
}

.document-body blockquote > :first-child {
  margin-top: 0;
}

.document-body blockquote > :last-child {
  margin-bottom: 0;
}

.document-body :not(pre) > code {
  background: var(--pf-hover);
  padding: 0.08em 0.25em;
  overflow-wrap: anywhere;
}

.document-body pre {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--pf-border);
  background: var(--pf-surface);
  padding: 0.9rem 1rem;
  color: var(--pf-fg);
  line-height: 1.55;
  tab-size: 2;
}

.document-body pre code {
  font-size: 0.82rem;
}

.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  border-top: 2px solid var(--pf-border-strong);
  border-bottom: 1px solid var(--pf-border-strong);
  scrollbar-width: thin;
}

.document-body table {
  min-width: 34rem;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}

.document-body caption {
  padding: 0.6rem 0;
  color: var(--pf-muted);
  text-align: left;
  font-size: 0.75rem;
}

.document-body th,
.document-body td {
  vertical-align: top;
}

.katex {
  font-size: 1em;
}

.katex-display {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-block: 0.2rem;
}

.footnotes {
  margin-top: 3rem;
  border-top: 1px solid var(--pf-border);
  padding-top: 0.8rem;
  color: var(--pf-muted);
  font-size: 0.85rem;
}

.document-footer {
  margin-top: 3.5rem;
  border-top: 1px solid var(--pf-border);
  padding-top: 0.8rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--pf-muted);
  font-family: var(--pf-font-mono);
  font-size: 0.7rem;
}

@media (max-width: 58rem) {
  .site-masthead,
  .reading-layout {
    width: min(calc(100% - 2rem), 46rem);
  }

  .reading-layout {
    padding-top: 2rem;
    display: block;
  }

  .toc-rail {
    position: static;
    max-height: none;
    margin-bottom: 2.5rem;
    overflow: visible;
  }

  .toc-disclosure {
    border-bottom: 1px solid var(--pf-border);
    padding-bottom: 0.65rem;
  }

  .toc-disclosure summary {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
  }

  .toc-disclosure summary span:last-child {
    display: inline;
    font-family: var(--pf-font-sans);
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
  }

  #TOC {
    columns: 2 14rem;
    column-gap: 2rem;
  }

  #TOC li {
    break-inside: avoid;
  }
}

@media (max-width: 40rem) {
  .site-masthead p {
    display: none;
  }

  .reading-layout {
    padding-top: 1.5rem;
  }

  #TOC {
    columns: auto;
  }

  .document-title {
    font-size: clamp(2rem, 12vw, 2.75rem);
  }

  .document-footer {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

@media print {
  @page {
    margin: 0.7in;
  }

  body {
    background: #ffffff;
    color: #000000;
    font-size: 10.5pt;
  }

  .skip-link,
  .site-masthead,
  .toc-rail,
  .document-footer {
    display: none;
  }

  .reading-layout {
    width: auto;
    padding: 0;
    display: block;
  }

  .document-body h2,
  .document-body h3,
  .document-body h4 {
    break-after: avoid;
  }

  .document-body a {
    border: 0;
  }
}
