/* Definograph site stylesheet: a plain documentation layout.
   Self-contained: system fonts, no external resources, no inline styles needed. */

:root {
  color-scheme: light;
  --text: #1f2328;
  --muted: #59636e;
  --link: #1f4fbf;
  --link-hover: #183f99;
  --border: #c8d0d9;
  --rule: #e3e7ec;
  --panel: #f6f8fa;
  --sidebar: #f5f6f8;
  --keyword: #1d3f8f;
  --teal: #0b6b66;
  --rust: #9a3a10;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --measure: 44rem;
  --page: 72rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: #ffffff;
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.65;
  overflow-wrap: break-word;
}

img {
  max-width: 100%;
  height: auto;
}

a {
  color: var(--link);
  text-decoration-thickness: 0.06em;
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--link-hover);
  text-decoration-thickness: 0.12em;
}

main a,
.doc-sidebar a,
.site-footer a {
  overflow-wrap: anywhere;
}

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

/* The skip link moves focus to <main>; the container itself needs no ring. */
main:focus {
  outline: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 10;
  padding: 0.375rem 0.75rem;
  border-radius: 3px;
  background: var(--text);
  color: #ffffff;
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-300%);
}

.skip-link:focus {
  transform: none;
}

.skip-link:hover {
  color: #ffffff;
}

/* Masthead */

.site-header {
  border-bottom: 1px solid var(--border);
  background: #ffffff;
}

.site-header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
  max-width: var(--page);
  margin: 0 auto;
  padding: 0.5rem 1.25rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  font-size: 1.125rem;
  font-weight: 600;
  text-decoration: none;
}

.brand:hover {
  color: var(--text);
  text-decoration: underline;
}

.brand img {
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
}

/* Lets the one-word name wrap instead of overflowing at very large text sizes. */
.brand span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.primary-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.primary-nav a {
  display: inline-block;
  padding: 0.25rem 0;
  color: var(--text);
  text-decoration: none;
}

.primary-nav a:hover {
  color: var(--link);
  text-decoration: underline;
}

.primary-nav a[aria-current] {
  color: var(--link);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 0.125rem;
  text-underline-offset: 0.35em;
}

/* Page frames */

.page {
  display: block;
  max-width: var(--page);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.doc-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  column-gap: 2.5rem;
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 1.25rem;
}

.doc-main {
  min-width: 0;
  padding: 1.5rem 0 2.5rem;
}

.doc {
  min-width: 0;
}

/* Tutorial navigation. On narrow screens the sidebar follows the lesson and the
   lesson's own section list stands after its title; wide screens show the sidebar. */

.doc-sidebar {
  min-width: 0;
  margin: 0 -1.25rem;
  padding: 1rem 1.25rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--sidebar);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.sidebar-title,
.toc-title {
  margin: 0 0 0.375rem;
  font-weight: 600;
}

.sidebar-pages,
.sidebar-sections {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sidebar-pages > li {
  margin: 0;
  padding: 0.1875rem 0;
}

.sidebar-pages a {
  text-decoration: none;
}

.sidebar-pages a:hover {
  text-decoration: underline;
}

.sidebar-pages a[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
}

.sidebar-sections {
  margin: 0.375rem 0 0.25rem 0.25rem;
  padding-left: 0.75rem;
  border-left: 2px solid var(--border);
}

.sidebar-sections li {
  margin: 0;
  padding: 0.125rem 0;
}

.page-toc {
  max-width: var(--measure);
  margin: 0 0 1.5rem;
  padding: 0.5rem 0.875rem 0.625rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  font-size: 0.9375rem;
  line-height: 1.5;
}

.toc-sections {
  margin: 0;
  padding-left: 1.25rem;
}

.toc-sections li + li {
  margin-top: 0.125rem;
}

@media (max-width: 59.99em) {
  .sidebar-sections {
    display: none;
  }
}

@media (min-width: 60em) {
  .doc-layout {
    grid-template-columns: 15rem minmax(0, 1fr);
  }

  .doc-main {
    grid-row: 1;
    grid-column: 2;
  }

  .doc-sidebar {
    grid-row: 1;
    grid-column: 1;
    margin: 0;
    padding: 1.5rem 1rem 2rem;
    border-top: 0;
    border-right: 1px solid var(--rule);
  }

  .page-toc {
    display: none;
  }
}

.pager {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  max-width: var(--measure);
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}

.pager a {
  display: block;
  max-width: 100%;
  text-decoration: none;
}

.pager a:hover {
  text-decoration: underline;
}

.pager-previous {
  text-align: left;
}

.pager-next {
  margin-left: auto;
  text-align: right;
}

.pager-label {
  display: block;
  color: var(--muted);
  font-size: 0.875rem;
}

/* Type */

h1,
h2,
h3 {
  color: var(--text);
  font-family: var(--font);
  font-weight: 600;
  line-height: 1.25;
}

h1 {
  margin: 0.25rem 0 1rem;
  font-size: 1.875rem;
}

h2 {
  margin: 2.25rem 0 0.75rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--rule);
  font-size: 1.375rem;
}

h3 {
  margin: 1.75rem 0 0.5rem;
  font-size: 1.125rem;
}

p,
ul,
ol,
dl {
  margin: 0 0 1rem;
}

ul,
ol {
  padding-left: 1.5rem;
}

li + li {
  margin-top: 0.25rem;
}

main p,
main li,
main dd,
main blockquote,
main details,
main h1,
main h2,
main h3 {
  max-width: var(--measure);
}

blockquote {
  margin: 0 0 1rem;
  padding: 0.125rem 0 0.125rem 1rem;
  border-left: 3px solid var(--border);
}

blockquote p {
  margin: 0;
}

strong {
  font-weight: 600;
}

var {
  font-style: italic;
}

code {
  font-family: var(--mono);
  font-size: 0.9375em;
}

:not(pre) > code {
  padding: 0.0625em 0.3em;
  border-radius: 3px;
  background: var(--panel);
  overflow-wrap: anywhere;
}

.page-head {
  margin-bottom: 1.5rem;
}

.page-head > :last-child {
  margin-bottom: 0;
}

.kicker {
  margin: 0 0 0.25rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.lead {
  font-size: 1.125rem;
}

/* Home introduction: its actions are ordinary links. */

.intro h1 {
  margin-top: 0.5rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.actions li + li {
  margin-top: 0;
}

.action {
  font-weight: 600;
}

.action-primary {
  text-decoration-thickness: 0.12em;
}

/* Code */

pre {
  max-width: 48rem;
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--panel);
  font-family: var(--mono);
  font-size: 0.9375rem;
  line-height: 1.5;
  tab-size: 2;
}

pre code {
  font-size: inherit;
}

pre:focus-visible {
  outline-offset: 0;
}

@media (max-width: 30em) {
  pre {
    padding: 0.625rem 0.75rem;
  }
}

.tok-key {
  color: var(--keyword);
  font-weight: 600;
}

.tok-binder {
  color: var(--teal);
  font-weight: 600;
}

.tok-sorry {
  color: var(--rust);
  font-weight: 600;
  text-decoration: underline wavy;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

.source-file {
  min-width: 0;
  max-width: 48rem;
  margin: 0 0 1.25rem;
}

.source-file figcaption {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0 1rem;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--rule);
  border-bottom: 0;
  border-radius: 4px 4px 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.source-file pre {
  margin: 0;
  border-radius: 0 0 4px 4px;
}

.filename {
  color: var(--text);
  font-family: var(--mono);
  font-weight: 600;
  overflow-wrap: anywhere;
}

a.filename {
  color: var(--link);
}

/* Tables stack into labelled rows on narrow screens. */

table {
  width: 100%;
  max-width: 56rem;
  margin: 0 0 1.25rem;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

caption {
  padding-bottom: 0.375rem;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
  text-align: left;
}

th,
td {
  padding: 0.4375rem 0.625rem;
  border: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}

thead th {
  background: var(--panel);
  font-weight: 600;
}

tbody th {
  font-weight: 600;
}

@media (max-width: 44em) {
  .stack-table,
  .stack-table caption,
  .stack-table tbody,
  .stack-table tr,
  .stack-table th,
  .stack-table td {
    display: block;
  }

  .stack-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .stack-table tbody tr {
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--rule);
    border-radius: 4px;
  }

  .stack-table th,
  .stack-table td {
    padding: 0.1875rem 0;
    border: 0;
  }

  .stack-table td::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 0.875rem;
    font-weight: 600;
  }
}

/* Hints and worked answers */

details {
  margin: 0 0 1rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
}

summary {
  padding: 0.375rem 0.75rem;
  color: var(--link);
  font-weight: 600;
  cursor: pointer;
}

summary:hover {
  text-decoration: underline;
}

details[open] > summary {
  border-bottom: 1px solid var(--rule);
}

details > :not(summary) {
  margin: 0.75rem;
}

/* Teaching graphics and schematics: explanatory drawings, labelled as such. */

.illustration img {
  display: block;
  border: 1px solid var(--rule);
}

.comparison {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
  gap: 1rem 1.5rem;
  max-width: 56rem;
  margin: 1.25rem 0;
}

.schematic {
  min-width: 0;
  margin: 0;
  padding: 0.75rem;
  border: 1px dashed var(--border);
  border-radius: 4px;
}

.schematic > figcaption {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.scope {
  padding: 0.5rem 0.75rem;
  border: 1px solid #5b7fc0;
  border-radius: 3px;
}

.scope .scope {
  margin-top: 0.5rem;
}

.scope-x {
  border-color: #5b7fc0;
}

.scope-y {
  border-color: #3f8f88;
}

.scope p {
  margin: 0;
  font-size: 0.9375rem;
}

.scope p + p {
  margin-top: 0.25rem;
}

.dependency {
  font-weight: 600;
}

/* Reader views: recorded images of the reader, each stacked with its exact Lean source,
   download link and explanation, at the full width of the reading column. */

.reader-feature {
  margin: 2rem 0;
}

.reader-example {
  min-width: 0;
  margin: 1.25rem 0 2rem;
}

.reader-example > h3 {
  margin-top: 0;
}

.reader-view {
  min-width: 0;
  margin: 0 0 1rem;
  padding: 0.5rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
}

.reader-view > a {
  display: block;
}

.reader-view img {
  display: block;
  max-width: 100%;
  height: auto;
}

.reader-view figcaption {
  max-width: var(--measure);
  padding: 0.5rem 0.25rem 0;
  color: var(--muted);
  font-size: 0.9375rem;
}

/* Examples and reference pages */

.notice {
  padding-left: 0.75rem;
  border-left: 3px solid var(--border);
}

.on-page {
  max-width: var(--measure);
  margin: 1rem 0 1.5rem;
  font-size: 0.9375rem;
}

.on-page-title {
  margin: 0 0 0.25rem;
  font-weight: 600;
}

.on-page ul {
  margin: 0;
  padding-left: 1.25rem;
}

.on-page li + li {
  margin-top: 0.125rem;
}

.example {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
}

.example > h2 {
  margin-top: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

.source-with-note {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
  gap: 1rem 1.5rem;
  align-items: start;
  max-width: 60rem;
  margin-bottom: 1.25rem;
}

.source-with-note .source-file {
  margin: 0;
}

.note {
  min-width: 0;
  padding: 0.25rem 0 0.25rem 0.875rem;
  border-left: 3px solid var(--border);
}

.note > :last-child {
  margin-bottom: 0;
}

.note-axiom {
  border-left-color: var(--rust);
}

.note-title {
  margin-bottom: 0.25rem;
  font-weight: 600;
}

:target {
  scroll-margin-top: 1rem;
}

/* Footer */

.site-footer {
  max-width: var(--page);
  margin: 0 auto;
  padding: 1.25rem 1.25rem 2rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.9375rem;
}

.site-footer p {
  max-width: var(--measure);
  margin: 0 0 0.5rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.footer-links li + li {
  margin-top: 0;
}

@media (forced-colors: active) {
  .primary-nav a[aria-current] {
    text-decoration-color: currentColor;
  }
}

@media print {
  .skip-link,
  .site-header,
  .doc-sidebar,
  .page-toc,
  .pager,
  .site-footer {
    display: none;
  }

  .doc-layout,
  .page {
    display: block;
    padding: 0;
  }

  pre {
    white-space: pre-wrap;
  }
}
