/* markmukhin.com — shared styles. Light by default, dark follows the system. */

@font-face {
  font-family: 'JetBrains Mono';
  src: url(fonts/JetBrainsMono-Regular.woff) format('woff');
  font-weight: 400 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'JetBrains Mono';
  src: url(fonts/JetBrainsMono-Bold.woff) format('woff');
  font-weight: 600 800;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --bg: #fdfdfc;
  --text: #111;
  --text-mid: #555;
  --text-dim: #6b6b6b;
  --rule: #ddd;
  --accent: #d03a2b;
  --spiral: rgba(17, 17, 17, 0.13);
  --mono: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121211;
    --text: #ecece9;
    --text-mid: #a6a6a2;
    --text-dim: #8b8b87;
    --rule: #2d2d2b;
    --accent: #e5594a;
    --spiral: rgba(255, 255, 255, 0.13);
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--mono);
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2 { text-wrap: balance; }

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 24px;
  width: 100%;
}

/* ---------- header ---------- */

header {
  padding: 56px 0 0;
  margin-bottom: 72px;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.8rem;
  font-weight: 500;
}

.top-bar > a { color: var(--text); text-decoration: none; }

nav { display: flex; gap: 20px; }

nav a {
  color: var(--text-mid);
  text-decoration: none;
  font-size: 0.8rem;
  transition: color 0.15s;
}

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

/* ---------- shared link style ---------- */

.copy a, .links a, .article-body a, .end-links a, .plain-links a, footer a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--text-dim);
  transition: border-color 0.15s;
}

.copy a:hover, .links a:hover, .article-body a:hover,
.end-links a:hover, .plain-links a:hover, footer a:hover { border-color: var(--accent); }

footer a { color: inherit; }

/* ---------- home ---------- */

.name, .page-title {
  font-size: clamp(2rem, 5vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.name { margin-bottom: 48px; }
.page-title { margin-bottom: 56px; }

.copy { margin-bottom: 48px; }

.copy p {
  font-size: 0.88rem;
  line-height: 1.7;
  font-weight: 400;
  max-width: 560px;
}

.links {
  font-size: 0.8rem;
  line-height: 1.8;
}

.links.spaced { margin-bottom: 48px; }
.links .sep { color: var(--text-dim); margin: 0 4px; }

/* ---------- texts list ---------- */

.post-list { list-style: none; }

.post-item {
  padding: 24px 0;
  border-top: 1px solid var(--rule);
}

.post-item:last-child { border-bottom: 1px solid var(--rule); }

.post-date {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.post-title {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 8px;
}

.post-title a {
  color: var(--text);
  text-decoration: none;
  transition: color 0.15s;
}

.post-title a:hover { color: var(--accent); }

.post-excerpt {
  font-size: 0.78rem;
  color: var(--text-mid);
  line-height: 1.6;
  max-width: 520px;
}

/* ---------- essay ---------- */

.article-header { margin-bottom: 48px; }

.back-link {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-decoration: none;
  display: inline-block;
  margin-bottom: 28px;
  transition: color 0.15s;
}

.back-link:hover { color: var(--text); }
.back-link::before { content: '← '; }

.article-title {
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

.article-date {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.article-body {
  padding-top: 36px;
  border-top: 1px solid var(--rule);
}

.article-body p {
  font-size: 0.88rem;
  line-height: 1.75;
  font-weight: 400;
  margin-bottom: 1.4em;
  max-width: 600px;
  text-wrap: pretty;
}

.article-body p:last-of-type { margin-bottom: 0; }

.article-body h2 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-top: 48px;
  margin-bottom: 20px;
}

/* section break: an asterism, drawn in as it scrolls into view */

.break {
  display: flex;
  justify-content: center;
  color: var(--text-dim);
  margin: 40px 0 44px;
}

.break svg {
  width: 36px;
  height: auto;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
  stroke-linejoin: round;
}

.break path {
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1.1s cubic-bezier(0.4, 0.1, 0.2, 1);
}

.break path:nth-child(2) { transition-delay: 0.18s; }
.break path:nth-child(3) { transition-delay: 0.36s; }
.break.pre:not(.in) path { stroke-dashoffset: 1; }

.end-mark {
  display: flex;
  justify-content: center;
  margin-top: 56px;
  color: var(--text-dim);
  transition: opacity 1.2s ease;
}

.end-mark svg { width: 11px; height: 11px; fill: currentColor; }
.end-mark.pre:not(.in) { opacity: 0; }

.end-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px 24px;
  margin-top: 48px;
  font-size: 0.8rem;
  line-height: 1.8;
}

/* ---------- 404 ---------- */

body.center {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}

.code {
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 16px;
}

.message {
  font-size: 0.88rem;
  color: var(--text-mid);
  line-height: 1.7;
  max-width: 380px;
  margin-bottom: 32px;
}

.plain-links { display: flex; gap: 20px; font-size: 0.8rem; }
.plain-links .sep { color: var(--text-dim); }

/* ---------- footer ---------- */

footer {
  margin-top: auto;
  padding: 48px 0 36px;
  font-size: 0.7rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---------- the big spiral (drawn by site.js) ---------- */

.spiral {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 120vmax;
  height: 120vmax;
  transform: translate(-50%, -50%);
  z-index: -1;
  pointer-events: none;
  overflow: visible;
  fill: none;
  stroke: var(--spiral);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.spiral path { stroke-dasharray: 1; stroke-dashoffset: 1; }
.spiral.draw path { transition: stroke-dashoffset 4s cubic-bezier(0.45, 0.05, 0.2, 1); }

/* small variant: a corner spiral (a progress ring on essays) */
.spiral.small {
  left: auto;
  top: auto;
  right: 36px;
  bottom: 36px;
  width: var(--s, 68px);
  height: var(--s, 68px);
  transform: none;
  stroke: var(--text-dim);
}

.spiral.small.draw path { transition-duration: 2.4s; }
.spiral .track { stroke: var(--spiral); stroke-dasharray: none; stroke-dashoffset: 0; }
.spiral:not(.small) .track { display: none; }


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

.fade-in { opacity: 0; animation: fadeIn 0.5s ease forwards; }
.d1 { animation-delay: 0.05s; }
.d2 { animation-delay: 0.1s; }
.d3 { animation-delay: 0.15s; }
.d4 { animation-delay: 0.2s; }

@keyframes fadeIn { to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .fade-in { opacity: 1; animation: none; }
  .break path, .end-mark, .spiral path { transition: none !important; }
}

@media (max-width: 520px) {
  header { padding: 36px 0 0; margin-bottom: 48px; }
  .name { margin-bottom: 36px; }
  .article-header { margin-bottom: 36px; }
  .article-body h2 { margin-top: 36px; }
}

@media print {
  .spiral { display: none; }
}
