/* ==========================================================================
   Dmitry Petrov — personal site
   Clean, minimalist academic theme
   ========================================================================== */

:root {
  --max-width: 1000px;
  --text: #1a1a1a;
  --muted: #6b7280;
  --faint: #9aa0aa;
  --accent: #2563a8;
  --accent-hover: #16406f;
  --rule: #e7e9ee;
  --bg: #ffffff;
  --bg-soft: #f7f8fa;
  --tag-bg: #eef2f7;
  --tag-text: #2c5a8c;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
  --font-serif: Charter, Georgia, Cambria, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* ----- Site navigation ------------------------------------------------- */
.site-nav {
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--bg);
}

.site-nav .container {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-top: 18px;
  padding-bottom: 18px;
}

.site-nav .brand {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
}

.site-nav .nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
}

.site-nav .nav-links a {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 500;
}

.site-nav .nav-links a:hover,
.site-nav .nav-links a.active {
  color: var(--text);
}

/* ----- Back-to-top button ---------------------------------------------- */
.back-to-top {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
}

.back-to-top.back-to-top--visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top__label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  background-color: var(--bg);
  padding: 2px 8px;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  white-space: nowrap;
}

.back-to-top__btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background-color: var(--bg);
  font-size: 1.2rem;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.back-to-top:hover .back-to-top__label {
  color: var(--text);
}

.back-to-top:hover .back-to-top__btn {
  border-color: var(--faint);
}

@media (prefers-reduced-motion: reduce) {
  .back-to-top {
    transition: none;
  }
}

/* ----- Links ----------------------------------------------------------- */
a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ----- Headings -------------------------------------------------------- */
h1,
h2,
h3,
h4 {
  color: var(--text);
  line-height: 1.25;
  font-weight: 650;
}

h2 {
  font-size: 1.35rem;
  margin: 2.6rem 0 1.1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--rule);
}

h3 {
  font-size: 1.08rem;
  margin: 1.8rem 0 0.5rem;
}

h4 {
  font-size: 1rem;
  margin: 1.4rem 0 0.4rem;
}

p {
  margin: 0 0 1.1rem;
}

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2rem 0;
}

/* ----- Page header / hero --------------------------------------------- */
.page-head {
  margin: 40px 0 8px;
  scroll-margin-top: 16px;
}

.page-head::after {
  content: "";
  display: block;
  clear: both;
}

.page-head h1 {
  font-size: 2rem;
  margin: 0 0 6px;
}

.page-head .affiliation {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
  margin: 0;
}

.page-head .affiliation img {
  display: block;
  margin-top: 2px;
  max-width: 300px;
  height: auto;
}

/* Photo floats so the bio text wraps beside and below it */
.page-head .photo {
  float: right;
  width: 170px;
  margin: 6px 0 18px 30px;
}

.page-head .photo img {
  width: 100%;
  height: auto;
  border-radius: 12px;
  display: block;
}

/* Bio paragraphs live inside the header, after the contact block */
.page-head .social-links {
  margin-bottom: 1.4rem;
}

/* ----- Social / contact links (icon row) ------------------------------ */
.social-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin: 14px 0 0;
}

.social-links a {
  color: var(--muted);
  display: inline-flex;
}

.social-links a:hover {
  color: var(--accent);
  text-decoration: none;
}

.social-links svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
  display: block;
}

/* ----- Highlight / callout -------------------------------------------- */
.callout {
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 14px 18px;
  margin: 26px 0;
  font-size: 0.98rem;
}

.callout p:last-child {
  margin-bottom: 0;
}

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

.news li {
  display: flex;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--rule);
}

.news li:last-child {
  border-bottom: 0;
}

.news .date {
  flex: 0 0 92px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
  padding-top: 1px;
}

.news .item {
  flex: 1 1 auto;
}

/* ----- Publications ---------------------------------------------------- */
.research-topic {
  color: var(--muted);
  font-size: 0.97rem;
  margin-bottom: 1.4rem;
}

/* Collapsible publication chapters */
.pub-section {
  margin: 0;
}

.pub-section > summary {
  font-size: 1.08rem;
  font-weight: 650;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 1.8rem 0 0.9rem;
  user-select: none;
}

.pub-section > summary::-webkit-details-marker {
  display: none;
}

.pub-section > summary::before {
  content: "";
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border: solid var(--faint);
  border-width: 0 2px 2px 0;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

.pub-section[open] > summary::before {
  transform: rotate(45deg);
}

.pub-section > summary:hover {
  color: var(--accent);
}

.pub-section > summary:hover::before {
  border-color: var(--accent);
}

/* Collapsible top-level sections (styled like an h2) */
.section {
  margin: 0;
  scroll-margin-top: 16px;
}

.section > summary {
  font-size: 1.35rem;
  font-weight: 650;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 2.6rem 0 1.1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--rule);
  user-select: none;
}

.section > summary::-webkit-details-marker {
  display: none;
}

.section > summary::before {
  content: "";
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border: solid var(--muted);
  border-width: 0 2px 2px 0;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

.section[open] > summary::before {
  transform: rotate(45deg);
}

.section > summary:hover,
.section > summary:hover::before {
  color: var(--accent);
  border-color: var(--accent);
}

/* In-page section navigation */
.section-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 24px 0 4px;
  padding: 12px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  font-size: 0.92rem;
}

.section-nav a {
  color: var(--muted);
  font-weight: 500;
}

.section-nav a:hover {
  color: var(--accent);
}

.note {
  color: var(--muted);
  font-size: 0.92rem;
  font-style: italic;
  margin: 0 0 1.4rem;
}

.paper {
  margin: 0 0 1.4rem;
}

.paper .title {
  font-weight: 600;
  color: var(--text);
}

.paper .authors {
  font-size: 0.95rem;
  color: var(--muted);
}

.paper .authors .me {
  color: var(--text);
  font-weight: 700;
}

.paper .venue {
  font-size: 0.95rem;
  color: var(--muted);
  font-style: italic;
}

.paper .links {
  font-size: 0.9rem;
  margin-top: 2px;
}

.paper .links a {
  font-weight: 500;
}

.badge {
  display: inline-block;
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 5px;
  margin-right: 6px;
  vertical-align: middle;
}

/* ----- Blog ------------------------------------------------------------ */
.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.post-list li {
  padding: 18px 0;
  border-bottom: 1px solid var(--rule);
}

.post-list .post-date {
  color: var(--faint);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.post-list h3 {
  margin: 4px 0 6px;
}

.post-list .post-excerpt {
  color: var(--muted);
  font-size: 0.97rem;
  margin: 0;
}

.post-header {
  margin: 40px 0 28px;
}

.post-header h1 {
  font-size: 2rem;
  margin: 0 0 8px;
}

.post-header .post-meta {
  color: var(--faint);
  font-size: 0.92rem;
}

/* Long-form article typography */
.post-content {
  font-size: 1.05rem;
}

.post-content h2 {
  font-size: 1.3rem;
}

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.post-content blockquote {
  margin: 1.4rem 0;
  padding: 2px 18px;
  border-left: 3px solid var(--rule);
  color: var(--muted);
}

.post-content pre {
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 0.9rem;
}

.post-content code {
  font-family: "SF Mono", "Fira Code", Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--bg-soft);
  padding: 1px 5px;
  border-radius: 4px;
}

.post-content pre code {
  background: none;
  padding: 0;
}

.back-link {
  display: inline-block;
  margin: 8px 0 24px;
  font-size: 0.92rem;
  color: var(--muted);
}

/* ----- Footer ---------------------------------------------------------- */
.site-footer {
  margin-top: 64px;
  padding: 28px 0 48px;
  border-top: 1px solid var(--rule);
  color: var(--faint);
  font-size: 0.85rem;
}

.site-footer a {
  color: var(--muted);
}

/* ----- Responsive ------------------------------------------------------ */
@media (max-width: 600px) {
  body {
    font-size: 16px;
  }

  .page-head {
    margin-top: 28px;
  }

  .page-head .photo {
    float: none;
    width: 150px;
    margin: 0 0 16px;
  }

  .news li {
    flex-direction: column;
    gap: 2px;
  }

  .news .date {
    flex-basis: auto;
  }

  .site-nav .container {
    justify-content: flex-start;
    padding-top: 14px;
    padding-bottom: 14px;
  }
}
