/* ==========================================================================
   Bolys Sabitbek — mathematician
   Light editorial design. Plain CSS, no build step.
   Typography: STIX Two Text (the math-journal serif) + IBM Plex Mono.
   The hero / banner surfaces are drawn by js/wave.js, which reads its line
   colours from the --wave-* variables below.
   ========================================================================== */

:root {
  color-scheme: only light;

  --bg:         #fdfdfc;
  --bg-rgb:     253, 253, 252;   /* same colour as --bg, for fades */
  --bg-2:       #f5f5f1;
  --card:       #ffffff;
  --card-hover: #f3f8f6;
  --ink:        #15171d;
  --ink-soft:   #383d49;
  --muted:      #5d6474;
  --faint:      #6c7384;
  --teal:       #0f7d6a;
  --teal-dark:  #0a5c4e;
  --teal-soft:  rgba(15, 125, 106, 0.09);
  --teal-line:  rgba(15, 125, 106, 0.34);
  --violet:     #5a49c9;
  --line:       rgba(21, 30, 50, 0.14);
  --line-soft:  rgba(21, 30, 50, 0.08);

  /* wave surface colours as "r, g, b" (near rows → far rows) */
  --wave-near:  15, 125, 106;
  --wave-far:   90, 73, 201;
  --wave-depth: 60, 80, 120;

  --serif: "STIX Two Text", "STIX Two Math", Charter, Cambria, Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --wrap: 72rem;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5.5rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: rgba(15, 125, 106, 0.18); color: var(--ink); }

a {
  color: var(--teal);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover { color: var(--teal-dark); text-decoration: underline; text-underline-offset: 3px; }
a:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
  border-radius: 2px;
}

.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 4vw, 2.5rem);
}

/* --------------------------------------------------------------------------
   Top bar
   -------------------------------------------------------------------------- */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: rgba(var(--bg-rgb), 0.84);
  border-bottom: 1px solid var(--line-soft);
}

.topbar-inner {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 4vw, 2.5rem);
  height: 4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  margin-right: auto;
  font-family: var(--serif);
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.brand:hover { color: var(--ink); text-decoration: none; }

.brand .brand-mark {
  display: inline-block;
  color: var(--teal);
  font-style: italic;
  margin-right: 0.4rem;
  font-size: 1.3em;
  vertical-align: -0.05em;
}

.nav {
  display: flex;
  align-items: center;
  gap: clamp(0.9rem, 2.2vw, 1.9rem);
}

.nav a {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--muted);
  padding: 0.35rem 0;
  border-bottom: 1px solid transparent;
}
.nav a:hover { color: var(--ink); text-decoration: none; }
.nav a[aria-current="page"] {
  color: var(--teal);
  border-bottom-color: var(--teal);
}

/* Language switch: EN | ҚАЗ — the current language is plain teal text,
   the other is a link to the same page in that language. */
.lang {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-left: 0.4rem;
  padding-left: clamp(0.9rem, 1.8vw, 1.3rem);
  border-left: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  white-space: nowrap;
}
.lang a { color: var(--muted); }
.lang a:hover { color: var(--ink); text-decoration: none; }
.lang [aria-current] { color: var(--teal); }

/* Phones: brand and language switch on one row, all five links on the row
   below (no menu button, nothing hidden), and the bar scrolls away with
   the page. */
@media (max-width: 720px) {
  html { scroll-padding-top: 1rem; }
  .topbar { position: absolute; }
  .topbar-inner {
    height: auto;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: "brand lang" "nav nav";
    align-items: center;
    gap: 0.3rem 1rem;
    padding-top: 0.75rem;
    padding-bottom: 0.45rem;
  }
  .brand { grid-area: brand; }
  .lang { grid-area: lang; margin: 0; padding: 0; border: 0; }
  .nav {
    grid-area: nav;
    justify-content: space-between;
    gap: 1rem;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { font-size: 0.68rem; letter-spacing: 0.1em; }
}
@media (max-width: 360px) {
  .nav a { font-size: 0.64rem; letter-spacing: 0.04em; }
}

/* --------------------------------------------------------------------------
   Hero (index)
   -------------------------------------------------------------------------- */

.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 70% 10%, #ecf5f2 0%, var(--bg) 62%);
}

.hero canvas,
.banner canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: pan-y;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to top, rgba(var(--bg-rgb), 0.97) 0%, rgba(var(--bg-rgb), 0.88) 28%, rgba(var(--bg-rgb), 0) 58%),
    linear-gradient(to bottom, rgba(var(--bg-rgb), 0.7) 0%, rgba(var(--bg-rgb), 0) 16%);
}

.hero-content {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 4vw, 2.5rem) clamp(3rem, 8vh, 5.5rem);
  pointer-events: none;
}
.hero-content a { pointer-events: auto; }

.eyebrow {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--teal);
  margin: 0 0 1.1rem;
}

.hero h1 {
  font-size: clamp(2.9rem, 8.5vw, 6.2rem);
  font-weight: 550;
  line-height: 1.02;
  letter-spacing: -0.015em;
  margin: 0 0 1.4rem;
}

.hero .tagline {
  font-size: clamp(1.05rem, 1.8vw, 1.3rem);
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: 44rem;
  margin: 0 0 1.6rem;
}

.hero .equation-note {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin: 0;
  max-width: 44rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 1rem;
}

.hero .equation-note .eq {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--teal);
  letter-spacing: 0;
}

.scroll-cue {
  position: absolute;
  right: clamp(1.25rem, 4vw, 2.5rem);
  bottom: clamp(3rem, 8vh, 5.5rem);
  z-index: 2;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--faint);
  writing-mode: vertical-rl;
  pointer-events: none;
}
.scroll-cue::after {
  content: "";
  display: block;
  width: 1px;
  height: 3.2rem;
  margin: 0.8rem auto 0;
  background: linear-gradient(to bottom, var(--faint), transparent);
}
@media (max-width: 1080px) { .scroll-cue { display: none; } }

/* --------------------------------------------------------------------------
   Banner (sub-pages)
   -------------------------------------------------------------------------- */

.banner {
  position: relative;
  height: clamp(15rem, 36vh, 21rem);
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  background: radial-gradient(120% 120% at 70% 0%, #ecf5f2 0%, var(--bg) 66%);
  border-bottom: 1px solid var(--line-soft);
}
.banner::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to right, rgba(var(--bg-rgb), 0.9) 0%, rgba(var(--bg-rgb), 0.55) 32%, rgba(var(--bg-rgb), 0) 62%),
    linear-gradient(to top, rgba(var(--bg-rgb), 0.85) 0%, rgba(var(--bg-rgb), 0) 42%);
}
.banner .hero-content { padding-bottom: 2.2rem; }

.banner h1 {
  font-size: clamp(2.2rem, 5.5vw, 3.6rem);
  font-weight: 550;
  letter-spacing: -0.01em;
  line-height: 1.05;
  margin: 0;
}

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

main { display: block; }

.section {
  padding: clamp(3.5rem, 9vh, 6.5rem) 0;
  border-top: 1px solid var(--line-soft);
}
.section:first-of-type { border-top: none; }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 1.2rem;
  margin-bottom: clamp(1.8rem, 4vh, 2.8rem);
}

.section-head .no {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  color: var(--teal);
}

.section-head h2 {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 550;
  letter-spacing: -0.01em;
  margin: 0;
}

h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 2.6rem 0 1.1rem;
  color: var(--ink);
}
h3:first-child { margin-top: 0; }

.sub-label {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 2.8rem 0 1.2rem;
}
.sub-label:first-child { margin-top: 0; }

/* one-line description under a group heading (publications by topic) */
.group-intro {
  font-size: 0.97rem;
  color: var(--muted);
  max-width: 46rem;
  margin: -0.6rem 0 1.1rem;
}

/* --------------------------------------------------------------------------
   About block
   -------------------------------------------------------------------------- */

.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: start;
}
@media (max-width: 860px) {
  .about-grid { grid-template-columns: 1fr; }
}

.bio p { margin: 0 0 1.2em; color: var(--ink-soft); }
.bio p:last-child { margin-bottom: 0; }
.bio strong { color: var(--ink); font-weight: 600; }

.portrait-figure {
  position: relative;
  margin: 0;
  max-width: 21rem;
  justify-self: end;
}
@media (max-width: 860px) {
  .portrait-figure { justify-self: start; max-width: 17rem; }
}

/* the offset frame is a pair of shadows: a page-coloured rectangle 1px
   smaller than the photo, over a teal one the photo's exact size */
.portrait-figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
  box-shadow:
    0.9rem 0.9rem 0 -1px var(--bg),
    0.9rem 0.9rem 0 0 var(--teal-line);
}

.portrait-figure figcaption {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
  margin-top: 1.6rem;
}

/* --------------------------------------------------------------------------
   Research interest cards
   -------------------------------------------------------------------------- */

.interest-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  overflow: hidden;
}

.interest {
  background: var(--card);
  padding: 1.8rem 1.6rem 1.7rem;
  transition: background 0.25s ease;
}
.interest:hover { background: var(--card-hover); }

.interest .glyph {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.9rem;
  line-height: 1;
  color: var(--teal);
  display: block;
  margin-bottom: 1rem;
}

.interest h3 {
  font-size: 1.08rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.interest p {
  margin: 0;
  font-size: 0.94rem;
  line-height: 1.55;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   News timeline
   -------------------------------------------------------------------------- */

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

.news li {
  display: grid;
  grid-template-columns: 5rem 1fr;
  gap: 1.5rem;
  padding: 1.15rem 0;
  border-bottom: 1px solid var(--line-soft);
}
.news li:first-child { border-top: 1px solid var(--line-soft); }

.news .when {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  color: var(--teal);
  padding-top: 0.25rem;
}

.news .what { color: var(--ink-soft); }
.news .what em { color: var(--ink); }

@media (max-width: 560px) {
  .news li { grid-template-columns: 1fr; gap: 0.3rem; }
}

/* --------------------------------------------------------------------------
   Publications
   -------------------------------------------------------------------------- */

.pubs {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: pub;
}

.pubs li {
  counter-increment: pub;
  display: grid;
  grid-template-columns: 3.2rem 1fr;
  gap: 1.2rem;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--line-soft);
}
.pubs li:first-child { border-top: 1px solid var(--line-soft); }

.pubs li::before {
  content: counter(pub, decimal-leading-zero);
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  color: var(--faint);
  padding-top: 0.35rem;
}

.pub-title {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.45;
  margin-bottom: 0.35rem;
  color: var(--ink);
}

.pub-authors {
  font-size: 0.94rem;
  color: var(--muted);
  margin-bottom: 0.15rem;
}
.pub-authors strong { color: var(--ink); font-weight: 600; }

.pub-venue {
  font-size: 0.94rem;
  color: var(--muted);
}
.pub-venue em { color: var(--ink-soft); }
.pub-venue .note { color: var(--violet); font-style: italic; }

.pub-links { margin-top: 0.7rem; display: flex; flex-wrap: wrap; gap: 0.5rem; }

.pub-links a {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  padding: 0.28rem 0.7rem;
  border: 1px solid var(--teal-line);
  border-radius: 99px;
  color: var(--teal);
  transition: background 0.15s ease, border-color 0.15s ease;
}
.pub-links a:hover {
  background: var(--teal-soft);
  border-color: var(--teal);
  text-decoration: none;
}

@media (max-width: 560px) {
  .pubs li { grid-template-columns: 1fr; gap: 0.4rem; }
  .pubs li::before { padding-top: 0; }
}

.more-link {
  margin-top: 2rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.more-link a::after { content: " →"; }

/* --------------------------------------------------------------------------
   Timeline (CV, teaching)
   -------------------------------------------------------------------------- */

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

.timeline li {
  display: grid;
  grid-template-columns: 8rem 1fr;
  gap: 1.5rem;
  padding: 1.3rem 0;
  border-bottom: 1px solid var(--line-soft);
}
.timeline li:first-child { border-top: 1px solid var(--line-soft); }

.timeline .when {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  color: var(--teal);
  padding-top: 0.3rem;
}

.timeline .what strong {
  display: block;
  font-size: 1.08rem;
  font-weight: 600;
  color: var(--ink);
}

.timeline .where {
  display: block;
  font-size: 0.94rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.timeline .what p {
  margin: 0.55rem 0 0;
  font-size: 0.94rem;
  line-height: 1.55;
  color: var(--muted);
}

@media (max-width: 560px) {
  .timeline li { grid-template-columns: 1fr; gap: 0.3rem; }
}

/* --------------------------------------------------------------------------
   Videos (outreach)
   -------------------------------------------------------------------------- */

.videos {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(19rem, 100%), 1fr));
  gap: 1.5rem;
}

.videos li {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}
.videos li:hover {
  border-color: var(--line);
  transform: translateY(-3px);
  box-shadow: 0 14px 30px -18px rgba(21, 30, 50, 0.35);
}

.video-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--bg-2);
}
.video-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.video-title {
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.45;
  padding: 1rem 1.1rem 0.35rem;
}

.video-meta {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 0 1.1rem 1.1rem;
}

/* --------------------------------------------------------------------------
   Generic lists / lede
   -------------------------------------------------------------------------- */

.lede {
  font-size: clamp(1.05rem, 1.6vw, 1.2rem);
  line-height: 1.65;
  color: var(--ink-soft);
  max-width: 46rem;
  margin: 0 0 1.5rem;
}

.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li {
  padding: 0.55rem 0 0.55rem 1.4rem;
  position: relative;
  color: var(--ink-soft);
}
.plain-list li::before {
  content: "—";
  position: absolute;
  left: 0;
  color: var(--teal);
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.footer {
  border-top: 1px solid var(--line-soft);
  background: var(--bg-2);
  padding: clamp(2.5rem, 6vh, 4rem) 0 2.5rem;
  margin-top: clamp(2rem, 6vh, 4rem);
}

.footer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 2.5rem;
}
@media (max-width: 720px) { .footer-grid { grid-template-columns: 1fr; } }

.footer-eq {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.6rem;
  color: var(--teal);
  margin: 0 0 1rem;
}

.footer p {
  margin: 0 0 0.4rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.footer .email { font-family: var(--mono); font-size: 0.8rem; color: var(--ink-soft); }

.footer-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem 1.5rem;
  align-content: start;
}
.footer-links a {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.footer-links a:hover { color: var(--teal); }

/* --------------------------------------------------------------------------
   Reduced motion
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .videos li, .interest, a { transition: none; }
  .videos li:hover { transform: none; }
}

/* --------------------------------------------------------------------------
   Print
   -------------------------------------------------------------------------- */

@media print {
  body { background: #fff; color: #111; }
  .topbar, .hero canvas, .banner canvas, .scroll-cue, .footer-links { display: none; }
  .hero, .banner { min-height: 0; height: auto; background: none; border: none; }
  .hero::after, .banner::after { display: none; }
  a { color: #114; }
  .section { border-top-color: #ddd; }
}
