/* ---------------------------------------------------------------
   Sharvi Tomar, personal site
   A quiet, text-first stylesheet. One serif, one accent, lots of air.
------------------------------------------------------------------*/

:root {
  --bg: #f7f4ec;
  --bg-rule: #e3ddca;
  --text: #2a2622;
  --text-muted: #8c8474;
  --accent: #46527a;
  --accent-soft: #9aa1bc;
  --max-width: 640px;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  font-size: 1.125rem;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

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

a:hover {
  color: var(--text);
  text-decoration-color: var(--text);
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

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

/* Keep all real content above the ambient cursor-worm layer, which is
   position:fixed and unpositioned by default. This guarantees doodles
   never paint over text, only in the page's empty space. */
.site-header,
main.wrap,
.site-footer {
  position: relative;
  z-index: 2;
}

/* ---------- ambient cursor doodles ---------- */

#cursor-worms {
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}

.cursor-worm {
  position: absolute;
  animation: worm-life 1100ms ease-out forwards;
}

.cursor-worm path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.3;
  stroke-linecap: round;
}

@keyframes worm-life {
  0% {
    opacity: 0;
    transform: scale(0.55) rotate(var(--rot, 0deg));
  }
  18% {
    opacity: 0.4;
  }
  65% {
    opacity: 0.25;
  }
  100% {
    opacity: 0;
    transform: scale(1.2) rotate(var(--rot, 0deg)) translateY(-10px);
  }
}

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

.site-header {
  padding: 56px 0 0;
}

.site-nav {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.site-nav .wordmark {
  font-style: italic;
  color: var(--text);
  text-decoration: none;
}

.site-nav .links a {
  margin-left: 18px;
}

/* ---------- hero ---------- */

.hero {
  padding-top: 36px;
}

.hero h1 {
  font-size: 2.25rem;
  font-weight: 600;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}

.hero .role {
  margin: 0 0 22px;
  color: var(--text-muted);
  font-style: italic;
  font-size: 1.05rem;
}

.manifold-curve {
  display: block;
  margin: 4px 0 28px -4px;
  overflow: visible;
}

.manifold-curve path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.4;
  opacity: 0.75;
}

.manifold-curve circle {
  fill: var(--accent);
  opacity: 0.85;
}

/* Animated version: only applies once JS has confirmed motion is wanted
   and set the initial dash offset, otherwise the curve just renders
   fully drawn, as above. */

.manifold-curve.will-animate path.draw {
  transition: stroke-dashoffset 1.3s cubic-bezier(0.65, 0, 0.35, 1);
}

.manifold-curve.will-animate circle.pt {
  opacity: 0;
  transform: scale(0.3);
  transform-box: fill-box;
  transform-origin: center;
  transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.manifold-curve.will-animate.in-view circle.pt {
  opacity: 0.85;
  transform: scale(1);
}

/* stagger the points roughly in the order the curve passes through them */
.manifold-curve circle.pt:nth-of-type(1) { transition-delay: 0.15s; }
.manifold-curve circle.pt:nth-of-type(2) { transition-delay: 0.35s; }
.manifold-curve circle.pt:nth-of-type(3) { transition-delay: 0.55s; }
.manifold-curve circle.pt:nth-of-type(4) { transition-delay: 0.75s; }
.manifold-curve circle.pt:nth-of-type(5) { transition-delay: 0.95s; }

/* ---------- prose ---------- */

main p {
  margin: 0 0 20px;
}

.links-row {
  margin: 28px 0 8px;
  font-size: 1.05rem;
}

.links-row a {
  margin-right: 4px;
}

.divider {
  border: none;
  border-top: 1px solid var(--bg-rule);
  margin: 44px 0 36px;
}

.section-label {
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-transform: lowercase;
  color: var(--text-muted);
  font-style: italic;
  margin: 0 0 14px;
}

/* ---------- blog index ---------- */

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

.post-list li {
  padding: 26px 0;
  border-top: 1px solid var(--bg-rule);
}

.post-list li:first-child {
  border-top: none;
  padding-top: 6px;
}

.post-date {
  display: block;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.post-list h2 {
  font-size: 1.4rem;
  margin: 0 0 6px;
  font-weight: 600;
}

.post-list h2 a {
  text-decoration: none;
}

.post-list h2 a:hover {
  text-decoration: underline;
}

.post-teaser {
  margin: 0;
  color: var(--text-muted);
}

/* ---------- single post ---------- */

.post-header {
  padding-top: 28px;
  margin-bottom: 8px;
}

.post-header h1 {
  font-size: 2rem;
  margin: 6px 0 10px;
  line-height: 1.3;
}

.post-meta {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-style: italic;
}

.post-meta a {
  font-style: normal;
}

article.post {
  margin-top: 28px;
}

article.post h2 {
  font-size: 1.35rem;
  margin: 40px 0 14px;
}

article.post h3 {
  font-size: 1.1rem;
  margin: 32px 0 12px;
}

article.post blockquote {
  margin: 24px 0;
  padding-left: 18px;
  border-left: 2px solid var(--bg-rule);
  color: var(--text-muted);
  font-style: italic;
}

article.post code {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--bg-rule);
  padding: 1px 5px;
  border-radius: 3px;
}

article.post img {
  max-width: 100%;
  display: block;
  margin: 28px 0;
  border: 1px solid var(--bg-rule);
}

article.post figcaption {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: -16px;
  margin-bottom: 28px;
}

.katex-display {
  margin: 28px 0 !important;
  font-size: 1.05em;
}

.post-footer-nav {
  margin-top: 56px;
  padding-top: 20px;
  border-top: 1px solid var(--bg-rule);
}

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

.site-footer {
  margin-top: 64px;
  padding: 24px 0 56px;
  border-top: 1px solid var(--bg-rule);
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ---------- responsive ---------- */

@media (max-width: 480px) {
  body {
    font-size: 1.05rem;
  }
  .site-header {
    padding-top: 40px;
  }
  .hero h1 {
    font-size: 1.9rem;
  }
  .post-header h1 {
    font-size: 1.7rem;
  }
}

/* ---------- reduced motion / no decoration overreach ---------- */

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }

  .manifold-curve path.draw,
  .manifold-curve circle.pt {
    transition: none !important;
  }

  .manifold-curve.will-animate circle.pt {
    opacity: 0.85 !important;
    transform: scale(1) !important;
  }

  #cursor-worms {
    display: none !important;
  }
}
