/* IOAI Guide — article components, home page, past tasks, search, print. */

/* ---------- article header ---------- */

.article-head {
  display: grid;
  gap: 12px;
  padding-bottom: 24px;
  margin-bottom: 40px;
  border-bottom: 1px solid var(--ink);
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  font-size: 14.5px;
  color: var(--graphite);
}
.crumbs a { color: var(--graphite); }
.crumbs .num { margin-right: .5em; }
.crumb-sep { color: var(--hairline); }

.article-title {
  display: flex;
  align-items: baseline;
  gap: .5em;
  font-size: clamp(30px, 4vw, 40px);
  line-height: 1.12;
  font-weight: 700;
  text-wrap: balance;
}
.article-title .num {
  flex: none;
  font-size: .6em;
  font-weight: 400;
  color: var(--graphite);
}

.article-summary {
  max-width: 60ch;
  font-size: 19px;
  font-style: italic;
  color: var(--graphite);
}

.article-meta {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 4px 20px;
  margin-top: 4px;
  font-size: 15px;
}
.article-meta div { display: contents; }
.article-meta dt {
  font-variant-caps: all-small-caps;
  letter-spacing: .06em;
  color: var(--graphite);
}

.cat-chip {
  display: inline-block;
  padding: 0 8px;
  border: 1px solid currentColor;
  font-size: 13.5px;
  line-height: 1.5;
}

.article-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  margin-top: 8px;
}

.status {
  display: inline-flex;
  border: 1px solid var(--hairline);
}
.status button {
  font: inherit;
  font-size: 14.5px;
  color: var(--graphite);
  background: none;
  border: 0;
  padding: 4px 12px;
  cursor: pointer;
}
.status button + button { border-left: 1px solid var(--hairline); }
.status button:hover { color: var(--ink); }
.status button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

.edit-link { font-size: 15px; }

/* ---------- article body ---------- */

.prose {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}
.prose > h2 {
  margin-top: 40px;
  font-size: 24px;
  line-height: 1.25;
}
.prose > h2:first-child { margin-top: 0; }
.prose > h3 {
  margin-top: 16px;
  font-size: 20px;
  line-height: 1.3;
}
.prose p, .prose li { hyphens: auto; }
.prose ul, .prose ol {
  display: grid;
  gap: 6px;
  padding-left: 1.4em;
}
.prose blockquote {
  margin: 0;
  padding-left: 16px;
  border-left: 2px solid var(--hairline);
  color: var(--graphite);
}
.prose hr {
  width: 100%;
  border: 0;
  border-top: 1px solid var(--hairline);
}
.prose :not(pre) > code {
  font-family: var(--mono);
  font-size: .82em;
  background: var(--plate);
  padding: .08em .32em;
}

/* Math */
.katex { font-size: 1.04em; }
.katex-display {
  margin: 0;
  padding-block: 4px;
  overflow-x: auto;
  overflow-y: hidden;
}

/* Code blocks, with muted token colors */
.prose pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  background: var(--plate);
  font-family: var(--mono);
  font-size: 14.5px;
  line-height: 1.55;
  tab-size: 4;
}
.prose pre code { font: inherit; background: none; padding: 0; }
.token.comment, .token.prolog, .token.doctype { color: #767785; font-style: italic; }
.token.keyword, .token.boolean, .token.important { color: #A31919; }
.token.string, .token.char, .token.attr-value { color: #1B6642; }
.token.number { color: #8F4600; }
.token.function, .token.class-name, .token.builtin { color: #1F48C7; }
.token.operator, .token.punctuation { color: #4A4B57; }
.token.decorator, .token.annotation { color: #6E3A92; }

/* Definition, note, tip, warning, example, exercise */
.callout {
  display: grid;
  gap: 8px;
  padding: 14px 18px 16px;
  background: var(--plate);
}
.callout > * { margin: 0; }
.callout ul, .callout ol { padding-left: 1.3em; }
.callout-label {
  font-size: 15px;
  font-weight: 700;
  font-variant-caps: all-small-caps;
  letter-spacing: .08em;
}
.callout-tip .callout-label { color: var(--blue); }
.callout-warning { background: color-mix(in srgb, var(--red) 6%, var(--paper)); }
.callout-warning .callout-label { color: var(--red); }
.callout-example .callout-label,
.callout-exercise .callout-label { color: var(--graphite); }

/* Algorithm box, as in papers */
.algorithm {
  border-top: 1.5px solid var(--ink);
  border-bottom: 1.5px solid var(--ink);
  font-size: 17px;
}
.algorithm figcaption {
  padding: 6px 2px;
  border-bottom: .8px solid var(--ink);
}
.prose .algorithm ol {
  list-style: none;
  counter-reset: line;
  display: grid;
  gap: 0;
  padding: 6px 2px 10px;
}
/* Line numbers sit in the left margin; the step itself flows as normal text,
   so bold keywords and inline math stay on one line. */
.algorithm li {
  counter-increment: line;
  position: relative;
  padding-left: 2.4em;
  line-height: 1.7;
}
.algorithm li::before {
  content: counter(line) ":";
  position: absolute;
  left: 0;
  width: 2.25em;
  font-size: .8em;
  line-height: 2.125;
  color: var(--graphite);
  text-align: right;
}

/* ---------- tables ---------- */

.scroll { overflow-x: auto; }

.booktabs,
.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
  line-height: 1.45;
  font-variant-numeric: lining-nums tabular-nums;
}
.booktabs caption,
.prose table caption {
  caption-side: top;
  padding-bottom: 8px;
  text-align: left;
  font-size: 15px;
  color: var(--graphite);
}
.booktabs th, .booktabs td,
.prose th, .prose td {
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}
.booktabs thead th,
.prose thead th {
  font-weight: 600;
  white-space: nowrap;
  border-top: 1.5px solid var(--ink);
  border-bottom: .8px solid var(--ink);
}
.booktabs:not(:has(thead)) tbody tr:first-child > * { border-top: 1.5px solid var(--ink); }
.booktabs tbody tr:last-child > *,
.prose tbody tr:last-child > * { border-bottom: 1.5px solid var(--ink); }
.booktabs tbody th { font-weight: 600; white-space: nowrap; }

.quiet { color: var(--graphite); }

.diff {
  font-size: 14px;
  font-variant-caps: all-small-caps;
  letter-spacing: .05em;
}
.diff-easy { color: #1B6642; }
.diff-medium { color: #8F4600; }
.diff-hard { color: var(--red); }

input.solved {
  width: 16px;
  height: 16px;
  margin: 4px 0 0;
  accent-color: var(--ink);
}

.block {
  display: grid;
  gap: 14px;
  margin-top: 56px;
}
.block > h2 { font-size: 24px; line-height: 1.25; }

/* ---------- module not written yet ---------- */

.unwritten { display: grid; gap: 16px; }
.unwritten > h2 { font-size: 24px; }
.scope th { width: 7.5em; color: var(--graphite); }
.unwritten-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
}

/* ---------- previous / next ---------- */

.pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 80px;
  padding-top: 24px;
  border-top: 1px solid var(--hairline);
}
.pager a {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--hairline);
  color: var(--ink);
}
.pager a:hover { border-color: var(--ink); text-decoration: none; }
.pager-next { grid-column: 2; text-align: right; }
.pager-label {
  font-size: 13.5px;
  font-variant-caps: all-small-caps;
  letter-spacing: .06em;
  color: var(--graphite);
}
.pager-title .num {
  margin-right: .5em;
  font-size: .85em;
  color: var(--graphite);
}

/* ---------- home page ---------- */

.home-title {
  display: grid;
  gap: 8px;
  padding: 22px 8px 24px;
  border-top: 4px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  text-align: center;
}
.home-title h1 {
  font-size: clamp(30px, 4.4vw, 42px);
  line-height: 1.12;
  text-wrap: balance;
}
.home-title p { color: var(--graphite); }

.home-abstract {
  display: grid;
  gap: 10px;
  max-width: 620px;
  margin: 40px auto 0;
}
.home-abstract h2 { font-size: 18px; text-align: center; }
.home-abstract p { text-align: justify; hyphens: auto; }

.home-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 28px;
  margin-top: 16px;
  font-size: 15px;
  color: var(--graphite);
}

.legend {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px 28px;
  margin-top: 64px;
}
.legend > div { display: grid; gap: 6px; align-content: start; }
.legend-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-weight: 700;
}
.legend p { font-size: 15.5px; color: var(--graphite); }

.part { display: grid; gap: 12px; margin-top: 80px; }
.part-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--ink);
}
.part-head h2 {
  display: flex;
  gap: .7em;
  font-size: 26px;
  line-height: 1.2;
}
.part-progress {
  font-size: 14.5px;
  color: var(--graphite);
  font-variant-numeric: tabular-nums;
}
.part-note { font-size: 15.5px; font-style: italic; color: var(--graphite); }

.topic { display: grid; gap: 4px; margin-top: 12px; }
.topic h3 {
  display: flex;
  gap: .7em;
  font-size: 17px;
  font-weight: 600;
  font-variant-caps: all-small-caps;
  letter-spacing: .06em;
  color: var(--graphite);
}
.topic-list {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 32px;
}
.topic-list a {
  display: grid;
  grid-template-columns: 8px 2.6em minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 8px;
  padding: 7px 4px;
  border-bottom: 1px solid var(--hairline);
  font-size: 16px;
  line-height: 1.35;
  color: var(--ink);
}
.topic-list a:hover { background: var(--plate); text-decoration: none; }
.topic-list .num { font-size: 13.5px; color: var(--graphite); }

/* ---------- past tasks ---------- */

.tasks-year { display: grid; gap: 12px; margin-top: 64px; }
.tasks-year h2 {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--ink);
  font-size: 26px;
}
.tasks-year h2 small { font-size: 15px; font-weight: 400; color: var(--graphite); }
.tasks-round {
  margin-top: 10px;
  font-size: 17px;
  font-weight: 600;
  font-variant-caps: all-small-caps;
  letter-spacing: .06em;
  color: var(--graphite);
}

/* ---------- search (Pagefind) ---------- */

#search {
  position: relative;
  --pagefind-ui-scale: .6;
  --pagefind-ui-primary: var(--blue);
  --pagefind-ui-text: var(--ink);
  --pagefind-ui-background: var(--paper);
  --pagefind-ui-border: var(--hairline);
  --pagefind-ui-tag: var(--plate);
  --pagefind-ui-border-width: 1px;
  --pagefind-ui-border-radius: 0;
  --pagefind-ui-font: var(--serif);
}
#search .pagefind-ui__drawer {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  width: min(560px, 92vw);
  max-height: 70vh;
  overflow-y: auto;
  padding: 0 16px 16px;
  background: var(--paper);
  border: 1px solid var(--hairline);
  box-shadow: 0 16px 40px rgb(22 22 29 / .12);
  z-index: 50;
}
.search-fallback {
  width: 100%;
  padding: 5px 10px;
  font: inherit;
  font-size: 15px;
  color: var(--graphite);
  background: var(--plate);
  border: 1px solid var(--hairline);
}

/* ---------- small screens ---------- */

@media (max-width: 760px) {
  .legend { grid-template-columns: 1fr; }
  .topic-list { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .article-title { font-size: 28px; }
  .article-actions { align-items: flex-start; flex-direction: column; }
  .pager { grid-template-columns: 1fr; }
  .pager-next { grid-column: auto; }
  .home-abstract p { text-align: left; }
}

/* ---------- print ---------- */

@media print {
  .topbar, .sidebar, .toc, .article-actions, .pager, .scrim, .skip { display: none !important; }
  .layout { display: block; }
  .main { padding: 0; }
  body { font-size: 11pt; }
  a { color: inherit; }
}
