/* osipov.cc — one stylesheet for the home page and the articles. */

@font-face {
  font-family: "Archivo";
  src: url("/fonts/archivo-var-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Fragment Mono";
  src: url("/fonts/fragment-mono-latin.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;

  --bg: oklch(0.155 0.008 195);
  --bg-raise: oklch(0.195 0.01 195);
  --line: oklch(0.275 0.012 195);
  --line-strong: oklch(0.4 0.014 195);
  --text: oklch(0.945 0.008 170);
  --text-2: oklch(0.78 0.014 185);
  --text-3: oklch(0.66 0.016 190);
  --accent: oklch(0.87 0.12 172);
  --accent-ink: oklch(0.2 0.035 185);

  --sans: "Archivo", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Fragment Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --step-data: 0.8125rem;
  --step-small: 0.9375rem;
  --step-body: 1.0625rem;
  --step-lead: 1.375rem;
  --step-line: clamp(1.375rem, 1.05rem + 1.3vw, 1.875rem);
  --step-display: clamp(3.25rem, 1.6rem + 6.6vw, 6rem);

  --gutter: clamp(1.25rem, 0.5rem + 3.2vw, 3rem);
  --wrap: 72rem;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

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

html {
  background: var(--bg);
  scroll-behavior: smooth;
  scroll-padding-top: 1.5rem;
  scrollbar-color: var(--line-strong) var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-2);
  font-family: var(--sans);
  font-size: var(--step-body);
  line-height: 1.55;
  font-stretch: 100%;
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  caret-color: var(--accent);
}

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

a {
  color: var(--text);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  text-decoration-color: var(--line-strong);
  transition: color 160ms var(--ease-out), text-decoration-color 160ms var(--ease-out);
}
a:hover { color: var(--accent); text-decoration-color: currentColor; }

h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }

.mono {
  font-family: var(--mono);
  font-size: var(--step-data);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.skip {
  position: absolute;
  left: var(--gutter);
  top: -4rem;
  z-index: 10;
  padding: 0.6rem 0.9rem;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 650;
  text-decoration: none;
  border-radius: 4px;
}
.skip:focus { top: 0.75rem; color: var(--accent-ink); }

/* ---------- Header ---------- */

.site-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  padding-block: 1.5rem;
}
.wordmark {
  color: var(--text);
  font-weight: 700;
  font-stretch: 108%;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.wordmark span { color: var(--text-3); }
.site-nav ul { display: flex; flex-wrap: wrap; gap: 0.25rem 1.75rem; }
.site-nav a {
  color: var(--text-2);
  font-size: var(--step-small);
  text-decoration: none;
  padding-block: 0.35rem;
}
.site-nav a:hover { color: var(--accent); }

/* ---------- Hero ---------- */

.hero {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: 1.5rem;
  align-items: center;
  padding-block: clamp(2rem, 1rem + 3.4vw, 4rem) clamp(3rem, 2rem + 3.4vw, 4.5rem);
}
.hero-copy { grid-column: 1 / span 7; }
.hero-fig { grid-column: 8 / span 5; }

.hero h1 {
  color: var(--text);
  font-size: var(--step-display);
  font-weight: 800;
  font-stretch: 112%;
  line-height: 0.94;
  letter-spacing: -0.035em;
  text-wrap: balance;
}
.hero .line {
  margin-top: 1.75rem;
  color: var(--text);
  font-size: var(--step-line);
  font-weight: 560;
  line-height: 1.2;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
.hero .bio {
  margin-top: 1.25rem;
  max-width: 34rem;
  text-wrap: pretty;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.75rem;
  margin-top: 2.25rem;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 1.15rem 0.8rem 1.25rem;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 680;
  font-size: var(--step-body);
  line-height: 1;
  text-decoration: none;
  border-radius: 6px;
  transition: background-color 160ms var(--ease-out), transform 160ms var(--ease-out);
}
.btn:hover { background: var(--text); color: var(--accent-ink); }
.btn:active { transform: translateY(1px); }
.btn svg, .ext svg { width: 0.8em; height: 0.8em; flex: none; }
.ext { display: inline-flex; align-items: center; gap: 0.4rem; }

/* Curve figure */
.curve { color: var(--text); }
.curve svg { width: 100%; height: auto; overflow: visible; touch-action: pan-y; cursor: crosshair; }
.curve .axis { stroke: var(--line); stroke-width: 1; }
.curve .tick { stroke: var(--line-strong); stroke-width: 1; }
.curve .path { fill: none; stroke: var(--text); stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.curve .chord { stroke: var(--text-3); stroke-width: 1; }
.curve .drop { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 3 5; }
.curve .pt { fill: var(--bg); stroke: var(--text); stroke-width: 1.5; }
.curve .pt-p { fill: var(--text); }
.curve .pt-sum { fill: var(--accent); stroke: var(--accent); }
.curve text {
  fill: var(--text-2);
  font-family: var(--mono);
  font-size: 21px;
}
.curve .lbl-sum { fill: var(--accent); }
.curve figcaption {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 1.5rem;
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
  color: var(--text-3);
  line-height: 1.7;
}
.curve figcaption b { display: block; color: var(--text); font-weight: 400; }
.curve .hint { font-family: var(--sans); font-size: var(--step-small); }
.curve .readout { display: grid; grid-template-columns: auto auto; column-gap: 1rem; margin: 0; white-space: pre; }
.curve .readout dt { color: var(--text-3); }
.curve .readout dd { margin: 0; color: var(--text-2); }
.curve .readout .sum { color: var(--accent); }

@media (prefers-reduced-motion: no-preference) {
  .curve .path {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: draw 1400ms var(--ease-out) 120ms forwards;
  }
  .curve .live { opacity: 0; animation: appear 500ms var(--ease-out) 1100ms forwards; }
}
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes appear { to { opacity: 1; } }

/* ---------- Sections ---------- */

.section {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: 1.5rem;
  padding-block: clamp(3rem, 2rem + 3.5vw, 5rem);
  border-top: 1px solid var(--line);
}
.section > h2 {
  grid-column: 1 / span 3;
  color: var(--text);
  font-size: var(--step-lead);
  font-weight: 700;
  font-stretch: 108%;
  line-height: 1.2;
  letter-spacing: -0.015em;
}
.section > .body { grid-column: 4 / -1; min-width: 0; }
.section .intro { max-width: 38rem; margin-bottom: 1.75rem; text-wrap: pretty; }

.rows > li {
  position: relative;
  display: grid;
  column-gap: 1.5rem;
  align-items: baseline;
  padding-block: 1.15rem;
  border-top: 1px solid var(--line);
}
.rows > li:first-child { border-top: 0; padding-top: 0; }
.rows > li:last-child { padding-bottom: 0; }
.rows .when { color: var(--text-3); white-space: nowrap; }
.rows .what { color: var(--text); font-weight: 600; text-wrap: pretty; }
.rows .note { color: var(--text-2); font-weight: 400; }

/* Work */
.work > li { grid-template-columns: 7.5rem minmax(0, 1fr) auto; row-gap: 0.35rem; }
.work .name {
  color: var(--text);
  font-size: var(--step-lead);
  font-weight: 700;
  font-stretch: 106%;
  line-height: 1.2;
  letter-spacing: -0.015em;
}
.work .name a { text-decoration: none; }
.work .name a::after { content: ""; position: absolute; inset: 0; }
.work .role { color: var(--text-3); font-size: var(--step-small); font-weight: 400; letter-spacing: 0; margin-left: 0.6rem; font-stretch: 100%; }
.work .desc { grid-column: 2; max-width: 36rem; text-wrap: pretty; }
.work .go { grid-column: 3; grid-row: 1; color: var(--text-3); white-space: nowrap; transition: color 160ms var(--ease-out), transform 240ms var(--ease-out); }
.work li:hover .go, .work li:focus-within .go { color: var(--accent); transform: translate(2px, -2px); }
.work li:hover .name a { color: var(--accent); }

/* Record */
.record > li { grid-template-columns: 7.5rem minmax(0, 1fr) minmax(8rem, auto); }
.record .result { color: var(--text); font-weight: 650; text-align: right; }

/* Research */
.papers > li { grid-template-columns: minmax(0, 1fr) auto; }
.papers .what { font-weight: 560; }
.papers .when { text-align: right; }

/* Writing */
.posts > li { grid-template-columns: 7.5rem minmax(0, 1fr) auto; }
.posts .what a { text-decoration: none; }
.posts .what a::after { content: ""; position: absolute; inset: 0; }
.posts .go { color: var(--text-3); transition: color 160ms var(--ease-out), transform 240ms var(--ease-out); }
.posts li:hover .go, .posts li:focus-within .go { color: var(--accent); transform: translateX(3px); }
.posts li:hover .what a { color: var(--accent); }
.go svg { width: 0.85rem; height: 0.85rem; }

/* Contact */
.contact .mail {
  display: inline-block;
  color: var(--text);
  font-size: clamp(1.75rem, 0.9rem + 4.2vw, 3.75rem);
  font-weight: 760;
  font-stretch: 110%;
  line-height: 1.05;
  letter-spacing: -0.03em;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.16em;
  overflow-wrap: anywhere;
}
.contact .intro { margin-bottom: 1.25rem; }
.contact .more { margin-top: 1.5rem; display: flex; flex-wrap: wrap; gap: 0.5rem 1.75rem; }

.site-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  padding-block: 1.75rem 2.5rem;
  border-top: 1px solid var(--line);
  color: var(--text-3);
  font-size: var(--step-small);
}

/* ---------- Articles ---------- */

.article { padding-block: clamp(2rem, 1rem + 4vw, 4.5rem) 4rem; }
.article-head { max-width: 46rem; }
.article-head .when { color: var(--text-3); }
.article-head .when { display: block; margin-top: 1.1rem; }
.article-head h1 {
  color: var(--text);
  font-size: clamp(2.25rem, 1.3rem + 3.6vw, 3.75rem);
  font-weight: 780;
  font-stretch: 110%;
  line-height: 1;
  letter-spacing: -0.03em;
  text-wrap: balance;
}
.prose {
  max-width: 42rem;
  margin-top: 2.5rem;
  padding-top: 2.25rem;
  border-top: 1px solid var(--line);
  font-size: 1.125rem;
  line-height: 1.65;
  overflow-wrap: break-word;
}
.prose > * + * { margin-top: 1.15em; }
.prose h2 {
  margin-top: 2.4em;
  color: var(--text);
  font-size: 1.5rem;
  font-weight: 700;
  font-stretch: 106%;
  line-height: 1.2;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
.prose h2 + * { margin-top: 0.8em; }
.prose em { color: var(--text); }
.prose img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 34rem;
  margin-block: 2em;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}
.prose img.shot { background: transparent; }
.prose code, .prose pre { font-family: var(--mono); font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.prose :not(pre) > code { padding: 0.12em 0.4em; background: var(--bg-raise); border: 1px solid var(--line); border-radius: 4px; color: var(--text); }
.prose pre {
  padding: 1.1rem 1.25rem;
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  line-height: 1.6;
  overflow-x: auto;
  scrollbar-width: thin;
}
.prose mjx-container { color: var(--text); overflow-x: auto; overflow-y: hidden; max-width: 100%; }
.prose p:has(> mjx-container[display="true"]) { overflow-x: auto; }
.article-foot { font-size: var(--step-small); max-width: 42rem; margin-top: 3.5rem; padding-top: 1.5rem; border-top: 1px solid var(--line); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem 2rem; }

/* 404 */
.lost { padding-block: clamp(4rem, 12vh, 9rem); max-width: 40rem; }
.lost h1 { color: var(--text); font-size: var(--step-display); font-weight: 800; font-stretch: 112%; line-height: 0.94; letter-spacing: -0.035em; }
.lost p { margin-top: 1.5rem; font-size: var(--step-lead); color: var(--text); line-height: 1.3; }
.lost .actions { margin-top: 2rem; }

/* ---------- Responsive ---------- */

@media (max-width: 62rem) {
  .hero-copy { grid-column: 1 / span 7; }
  .hero-fig { grid-column: 8 / -1; }
  .curve figcaption { grid-template-columns: minmax(0, 1fr); row-gap: 0.4rem; }
  .section > h2 { grid-column: 1 / -1; margin-bottom: 1.75rem; }
  .section > .body { grid-column: 1 / -1; }
}

@media (max-width: 47rem) {
  .site-head { flex-direction: column; align-items: stretch; gap: 0.6rem; padding-block: 1.25rem 0.5rem; }
  .site-nav ul { flex-wrap: nowrap; justify-content: space-between; gap: 0; }
  .hero { row-gap: 3rem; }
  .hero-copy, .hero-fig { grid-column: 1 / -1; }
  .hero-fig { max-width: 26rem; }
  .curve figcaption { grid-template-columns: minmax(0, 1fr) auto; }
  .work > li { grid-template-columns: minmax(0, 1fr) auto; }
  .work .name { grid-column: 1; grid-row: 1; }
  .work .go { grid-column: 2; grid-row: 1; }
  .work .when { grid-column: 1 / -1; grid-row: 2; }
  .work .desc { grid-column: 1 / -1; grid-row: 3; }
  .work .role { display: block; margin: 0.2rem 0 0; }
  .record > li { grid-template-columns: minmax(0, 1fr) auto; row-gap: 0.2rem; }
  .record .when { grid-column: 1 / -1; }
  .papers > li { grid-template-columns: minmax(0, 1fr); row-gap: 0.3rem; }
  .papers .when { text-align: left; }
  .posts > li { grid-template-columns: minmax(0, 1fr) auto; row-gap: 0.2rem; }
  .posts .when { grid-column: 1 / -1; }
  .prose { font-size: 1.0625rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

@media print {
  :root { --bg: #fff; --text: #000; --text-2: #111; --text-3: #333; --line: #bbb; --line-strong: #888; --accent: #000; }
  .site-nav, .hero-fig, .skip { display: none; }
}
