/* SOTA – AI Community, the main site.
   It is laid out like a machine learning paper: booktabs-style tables, an algorithm box, and boxed
   links like LaTeX hyperref. Colors, type sizes, the top bar and the footer come from
   assets/sota.css, shared with the IOAI Guide and the AI Checklist; this file adds the rest. */

:root {
  --shade: rgb(22 22 29 / .16);
  --measure: 680px;

  /* Vertical rhythm, like a paper: tight inside a section, a big gap between sections.
     Keep --space-section several times larger than --space-block so sections read as blocks. */
  --space-section: 144px; /* between sections */
  --space-block: 16px;    /* between a heading and its content, and between paragraphs */
  --space-item: 32px;     /* between repeated items: programs, biographies, FAQ entries */

  /* Hover highlight: the faint box that shows which part of the page the pointer is on */
  --hover-fill: color-mix(in srgb, var(--ink) 2.5%, transparent);
  --hover-fill-item: color-mix(in srgb, var(--ink) 3.5%, transparent);
  --hover-line: color-mix(in srgb, var(--ink) 10%, transparent);
  --hover-radius: 8px;
  --hover-pad: 28px;   /* how far the box reaches above and below the text */
  --hover-bleed: 32px; /* how far it reaches to the left and right */

  color-scheme: light;
}

@media (max-width: 560px) {
  :root {
    --space-section: 104px;
    --space-block: 14px;
    --space-item: 26px;
  }
}

/* ---------- base (the rest is in sota.css) ---------- */

html { scroll-padding-top: calc(var(--topbar-h) + 30px); }

sup { line-height: 0; }

.mono { font-family: var(--mono); font-size: .82em; }
.sc { font-variant-caps: all-small-caps; letter-spacing: .06em; }

.box.strong { font-weight: 600; }

.cite { white-space: nowrap; }

/* ---------- paper ---------- */

.paper {
  position: relative;
  max-width: calc(var(--measure) + 40px);
  margin-inline: auto;
  padding: 80px 20px 128px;
}

/* Rotated identifier in the left margin, like a preprint */
.stamp {
  position: absolute;
  top: 176px;
  left: -64px;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 15px;
  letter-spacing: .02em;
  color: var(--graphite);
  white-space: nowrap;
  user-select: none;
}
@media (max-width: 1000px) {
  .stamp { display: none; }
}

/* ---------- contents rail (wide screens only) ---------- */

.toc { display: none; }

@media (min-width: 1280px) {
  .toc {
    display: block;
    position: fixed;
    left: 28px;
    top: 50%;
    z-index: 5;
    width: 180px;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.35;
    transform: translateY(-50%);
  }
}

/* Between 1280px and 1439px the rail and the margin stamp would crowd each other */
@media (min-width: 1280px) and (max-width: 1439px) {
  .stamp { display: none; }
}

.toc-title {
  margin: 0 0 8px 13px;
  font-size: 14px;
  font-variant-caps: all-small-caps;
  letter-spacing: .08em;
  color: var(--graphite);
}

.toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* A hairline track down the left; the section in view gets a red mark on it */
.toc-list { border-left: 1px solid var(--hairline); }

.toc a {
  display: grid;
  grid-template-columns: 2.2em minmax(0, 1fr);
  margin-left: -1px;
  padding: 3px 0 3px 12px;
  border-left: 2px solid transparent;
  color: var(--graphite);
}
.toc li li a {
  padding-left: 24px;
  font-size: 12px;
}
.toc a:hover {
  color: var(--ink);
  text-decoration: none;
}
.toc a.is-active {
  color: var(--ink);
  border-left-color: var(--red);
}
.toc .toc-appendix { margin-top: 10px; }

.title {
  border-top: 4px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  padding: 26px 8px 28px;
  text-align: center;
}
.title h1 {
  font-size: clamp(28px, 4vw, var(--text-title));
  line-height: 1.18;
  font-weight: 700;
  text-wrap: balance;
}

/* The front page's paper title is the one headline-sized title */
.home .title h1 { font-size: clamp(28px, 4.2vw, var(--text-hero)); }

.authors {
  list-style: none;
  padding: 0;
  margin-top: 44px;
  display: grid;
  grid-template-columns: repeat(4, auto);
  justify-content: space-between;
  gap: 28px 24px;
  text-align: center;
}
.authors li { display: grid; gap: 4px; align-content: start; }
.authors a { color: var(--ink); font-weight: 600; line-height: 1.3; }
.authors span { font-size: 14.5px; color: var(--graphite); line-height: 1.35; }
@media (max-width: 640px) {
  .authors { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.correspondence {
  margin-top: 28px;
  text-align: center;
  font-size: 14.5px;
  color: var(--graphite);
}

.abstract {
  max-width: 600px;
  margin: 72px auto 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}
.abstract h2 {
  font-size: var(--text-h3);
  font-weight: 700;
  text-align: center;
}
.abstract p { text-align: justify; hyphens: auto; }
.keywords { font-size: var(--text-ui); }
.keywords b { font-style: italic; }

.actions {
  margin-top: 44px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 16px 32px;
}

/* ---------- sections ---------- */

/* minmax(0, 1fr) columns stop wide tables from stretching the page on phones */
.section {
  margin-top: var(--space-section);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-block);
}
.section > h2 {
  font-size: var(--text-h2);
  font-weight: 700;
  line-height: 1.25;
}
.section h3 {
  font-size: var(--text-h3);
  font-weight: 700;
  line-height: 1.3;
}
.section p { text-align: justify; hyphens: auto; }

/* Numbered heading: "2.1  Monthly contests" */
.hn { display: flex; align-items: baseline; gap: 1em; }
.num { font-variant-numeric: tabular-nums; }

.lead { color: var(--graphite); font-style: italic; }

.pairs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-item) 48px;
}
.pairs > div { display: grid; gap: 6px; align-content: start; }
.section .pairs p { text-align: left; }
@media (max-width: 640px) {
  .pairs { grid-template-columns: 1fr; }
}

/* Displayed equation with its number on the right */
.eq {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding-block: 8px;
  font-size: 20px;
}
.eq-body {
  grid-column: 2;
  display: inline-flex;
  align-items: baseline;
  gap: .3em;
  white-space: nowrap;
}
.eq-n { grid-column: 3; justify-self: end; font-size: 18px; }
.argmax {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.25;
}
.argmax sub {
  vertical-align: baseline;
  font-size: .7em;
  font-style: italic;
  line-height: 1;
}

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

.table {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}
.table figcaption {
  font-size: var(--text-ui);
  text-align: center;
  text-wrap: balance;
}

/* Wide tables scroll sideways on phones; soft edge shadows show there is more */
.scroll {
  overflow-x: auto;
  background:
    linear-gradient(to right, var(--scroll-edge, var(--paper)) 40%, transparent) left / 28px 100% no-repeat local,
    linear-gradient(to left, var(--scroll-edge, var(--paper)) 40%, transparent) right / 28px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, var(--shade), transparent) left / 12px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, var(--shade), transparent) right / 12px 100% no-repeat scroll;
}

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

.past { min-width: 560px; }

/* ---------- algorithm ---------- */

.algorithm {
  border-top: 1.5px solid var(--ink);
  border-bottom: 1.5px solid var(--ink);
  font-size: 17px;
}
.algorithm figcaption {
  padding: 8px 2px;
  border-bottom: .8px solid var(--ink);
}
.algorithm .io {
  padding: 12px 2px 6px;
  display: grid;
  gap: 2px;
}
.algorithm ol {
  list-style: none;
  padding: 4px 2px 14px;
  counter-reset: line;
  display: grid;
}
.algorithm li {
  counter-increment: line;
  display: grid;
  grid-template-columns: 2.2em minmax(0, 1fr);
  line-height: 1.75;
}
.algorithm li::before {
  content: counter(line) ":";
  font-size: .8em;
  color: var(--graphite);
  text-align: right;
  padding-right: .7em;
  padding-top: .25em;
}
.algorithm .in { padding-left: 1.5em; }
.kw { font-weight: 700; }

/* ---------- authors: portraits as Figure 1 ---------- */

.team { display: grid; gap: 24px; }
.portraits {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 28px 12px;
}
.portrait {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 12px;
  text-align: center;
}
/* Round and black and white, so photos taken in different places read as one set; color on hover */
.portrait img {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 30%;
  background: var(--plate);
  filter: grayscale(1) contrast(1.04);
  transition: filter .25s ease;
}
.portrait:hover img,
.portrait:focus-within img { filter: none; }
/* The name, with the profile links under it */
.portrait figcaption {
  display: grid;
  justify-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
}
.team > figcaption { font-size: var(--text-ui); text-align: center; text-wrap: balance; }
.more { margin-top: 16px; text-align: center; }

/* The team page: one section per group, closer together than the home page's sections */
.team-page .section { margin-top: 80px; }
.team-page .actions { margin-top: 112px; }

/* Profile links as small, light gray logos: LinkedIn, X, email, GitHub */
.socials { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.socials a {
  display: inline-flex;
  padding: 5px; /* a bigger tap target without moving the icon */
  margin: -5px;
  color: color-mix(in srgb, var(--graphite) 70%, var(--paper));
}
.socials a:hover { color: var(--ink); text-decoration: none; }
.socials svg { width: 14px; height: 14px; fill: currentColor; }
@media (max-width: 640px) {
  .portraits { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- references and appendix ---------- */

.refs {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 8px;
  font-size: 16px;
}
.refs li {
  display: grid;
  grid-template-columns: 2.4em minmax(0, 1fr);
  overflow-wrap: anywhere;
}

/* The one divider on the page: where the main text ends and the appendices begin */
.appendix {
  margin-top: var(--space-section);
  padding-top: calc(var(--space-section) * .5);
  border-top: 1px solid var(--ink);
}
.faq { display: grid; gap: var(--space-item); }
.faq > div { display: grid; gap: 6px; }

/* ---------- hover: show which part of the page the pointer is on ---------- */

/* On devices with a mouse, a faint box fades in around the section under the pointer, and a
   program or FAQ entry inside it gets a slightly darker fill. Each box is a pseudo-element
   drawn behind the text and reaching past it, so nothing moves when it appears. */
@media (hover: hover) and (pointer: fine) {
  .section,
  .abstract,
  .pairs > div,
  .faq > div {
    position: relative;
    isolation: isolate;
  }

  .section::before,
  .abstract::before,
  .pairs > div::before,
  .faq > div::before {
    content: "";
    position: absolute;
    z-index: -1;
    border-radius: var(--hover-radius);
    opacity: 0;
    transform: scale(.985);
    transition: opacity .22s ease, transform .22s ease;
    pointer-events: none;
  }

  .section::before,
  .abstract::before {
    inset: calc(-1 * var(--hover-pad)) calc(-1 * var(--hover-bleed));
    background: var(--hover-fill);
    box-shadow: inset 0 0 0 1px var(--hover-line);
  }
  /* The buttons sit close under the abstract, so its box stops sooner */
  .abstract::before { bottom: -18px; }

  /* A table's scroll hints are painted in the page colour; match the tint while hovered */
  .section:hover { --scroll-edge: color-mix(in srgb, var(--ink) 2.5%, var(--paper)); }

  .pairs > div::before,
  .faq > div::before {
    inset: -10px -14px;
    border-radius: calc(var(--hover-radius) - 2px);
    background: var(--hover-fill-item);
  }

  .section:hover::before,
  .abstract:hover::before,
  .pairs > div:hover::before,
  .faq > div:hover::before {
    opacity: 1;
    transform: none;
  }

  /* The appendix opens with its divider and a wide gap: start its box at the heading */
  .appendix::before { top: calc(var(--space-section) * .5 - var(--hover-pad)); }
}

/* A narrow desktop window has little margin beside the text, so the box reaches out less */
@media (hover: hover) and (pointer: fine) and (max-width: 820px) {
  :root { --hover-bleed: 14px; }
}

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

@media (max-width: 560px) {
  .paper { padding-top: 52px; padding-bottom: 96px; }
  .title { padding-block: 20px 22px; }
  .authors { margin-top: 36px; gap: 24px 16px; }
  .correspondence { margin-top: 24px; }
  .abstract { margin-top: 52px; }
  .actions { margin-top: 36px; }
  .section p, .abstract p { text-align: left; }
  .eq { font-size: 18px; grid-template-columns: 0 auto 1fr; }
  .booktabs { font-size: 15px; }
  .booktabs th, .booktabs td { padding: 8px 8px; }
  .past { min-width: 0; }
  .past tbody th { white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- print: it is a paper, after all ---------- */

@media print {
  :root {
    --paper: #FFFFFF;
    --ink: #000000;
    --graphite: #444444;
    --hairline: #CCCCCC;
    --red: #B31B1B;
    --blue: #000000;
    --space-section: 28pt;
    --space-block: 8pt;
    --space-item: 12pt;
  }
  body { font-size: 11pt; }
  .topbar, .footer, .stamp, .toc, .actions, .skip { display: none; }
  .paper { max-width: none; padding: 0; }
  .section { break-inside: avoid-page; }
  .box { border: 0; padding: 0; }
  .scroll { background: none; }
}
