/* Ivan Srbulov — quiet column, Bear-shaped calm without Bear branding */

:root {
  --font-body: "Source Serif 4", "Source Serif Pro", "Libertinus Serif",
    "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-ui: "Source Sans 3", "Source Sans Pro", "IBM Plex Sans",
    "Helvetica Neue", Helvetica, sans-serif;
  --measure: 42rem; /* ~672px — near Herman’s ~720px */
  --pad: 1.25rem;
  --fg: #1a1a1a;
  --bg: #faf9f7;
  --muted: #5c5c5c;
  --link: #0b4f6c;
  --link-visited: #3d5a6c;
  --border: #d4d0c8;
  --code-bg: #f0eeea;
  --table-border: #c8c4bc;
  --hr: #c8c4bc;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fg: #e8e6e1;
    --bg: #12151a;
    --muted: #9a9690;
    --link: #7eb8d4;
    --link-visited: #a8c5d4;
    --border: #2a3038;
    --code-bg: #1c222a;
    --table-border: #3a424c;
    --hr: #3a424c;
  }
}

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

html {
  font-size: 112.5%; /* ~18px */
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.65;
  color: var(--fg);
  background: var(--bg);
  /* soft paper grain — not flat single color */
  background-image:
    radial-gradient(ellipse 120% 80% at 10% -20%, rgba(11, 79, 108, 0.06), transparent 50%),
    radial-gradient(ellipse 80% 60% at 100% 0%, rgba(60, 50, 40, 0.04), transparent 45%);
}

@media (prefers-color-scheme: dark) {
  body {
    background-image:
      radial-gradient(ellipse 120% 80% at 10% -20%, rgba(126, 184, 212, 0.07), transparent 50%),
      radial-gradient(ellipse 80% 60% at 100% 0%, rgba(0, 0, 0, 0.35), transparent 45%);
  }
}

.wrap {
  width: min(100% - 2 * var(--pad), var(--measure));
  margin-inline: auto;
  padding-block: 2rem 3rem;
}

/* —— Header / nav —— */
.site-header {
  margin-bottom: 2.5rem;
  animation: rise 0.55s ease-out both;
}

.site-title {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.85rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.site-title a {
  color: var(--fg);
  text-decoration: none;
}

.site-title a:hover {
  color: var(--link);
}

.site-subtitle {
  margin: 0.35rem 0 0;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.site-nav {
  margin-top: 1.1rem;
  font-family: var(--font-ui);
  font-size: 0.9rem;
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0;
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-nav li:not(:last-child)::after {
  content: "·";
  margin: 0 0.55rem;
  color: var(--muted);
  pointer-events: none;
}

.site-nav a {
  color: var(--link);
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

/* —— Home —— */
.home-intro {
  margin-bottom: 2.25rem;
  animation: rise 0.65s ease-out 0.08s both;
}

.home-intro p {
  margin: 0;
  font-size: 1.05rem;
}

.home-section {
  margin-bottom: 2rem;
  animation: rise 0.7s ease-out 0.16s both;
}

.home-section h2 {
  margin: 0 0 0.65rem;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

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

.post-list li {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 0.75rem;
  align-items: baseline;
  padding: 0.28rem 0;
  border-bottom: 1px dashed var(--hr);
}

.post-list time {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.post-list a {
  color: var(--link);
  text-decoration: none;
}

.post-list a:hover {
  text-decoration: underline;
  text-underline-offset: 0.12em;
}

.post-list a:visited {
  color: var(--link-visited);
}

/* —— Content pages —— */
.page-header {
  margin-bottom: 1.5rem;
}

.page-header h1 {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.page-meta {
  margin: 0.4rem 0 0;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--muted);
}

.content > *:first-child {
  margin-top: 0;
}

.content h2,
.content h3 {
  margin-top: 1.75em;
  margin-bottom: 0.5em;
  letter-spacing: -0.015em;
  line-height: 1.3;
}

.content a {
  color: var(--link);
}

.content a:visited {
  color: var(--link-visited);
}

.content p,
.content li {
  margin-bottom: 0.85em;
}

.content hr {
  border: none;
  border-top: 1px dashed var(--hr);
  margin: 2em 0;
}

.content blockquote {
  margin: 1.25em 0;
  padding-left: 1rem;
  border-left: 2px solid var(--border);
  color: var(--muted);
}

.content code {
  font-family: "IBM Plex Mono", "Consolas", "Menlo", monospace;
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

.content pre {
  overflow-x: auto;
  padding: 0.9rem 1rem;
  background: var(--code-bg);
  border-radius: 4px;
  font-size: 0.85rem;
  line-height: 1.5;
}

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

.content img,
.content figure img {
  max-width: 100%;
  height: auto;
  display: block;
}

.content figcaption {
  margin-top: 0.4rem;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--muted);
}

.content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  margin: 1.25em 0;
  font-variant-numeric: tabular-nums;
}

.content th,
.content td {
  border: 1px solid var(--table-border);
  padding: 0.4rem 0.65rem;
  text-align: left;
}

.content th {
  font-family: var(--font-ui);
  font-weight: 600;
  background: var(--code-bg);
}

/* Footnotes */
.content .footnotes {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--hr);
  font-size: 0.9rem;
  color: var(--muted);
}

.content .footnotes ol {
  padding-left: 1.25rem;
}

/* KaTeX */
.content .katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.25rem 0;
}

/* —— Footer —— */
.site-footer {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px dashed var(--hr);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--muted);
  animation: rise 0.75s ease-out 0.22s both;
}

.site-footer a {
  color: var(--link);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(0.4rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .site-header,
  .home-intro,
  .home-section,
  .site-footer {
    animation: none;
  }
}

@media (max-width: 520px) {
  html {
    font-size: 100%;
  }

  .post-list li {
    grid-template-columns: 1fr;
    gap: 0.1rem;
  }

  .site-title {
    font-size: 1.55rem;
  }
}
