/* ============================================================
   Design System — Rohit Dilip's Personal Site
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #faf9f7;
  --bg-card: #ffffff;
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-muted: #86868b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --border: #e8e5e1;
  --border-light: #f0ede9;
  --surface: #f5f3f0;
  --code-bg: #f5f3f0;
  --max-width: 680px;
  --max-width-wide: 860px;
  --nav-height: 52px;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-heading: 'ET Book', 'Palatino Linotype', Palatino, Georgia, serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, monospace;
}

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

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s ease;
}

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

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* --- Layout --- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.container--wide {
  max-width: var(--max-width-wide);
}

/* --- Header & Navigation --- */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 249, 247, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-light);
  height: var(--nav-height);
}

nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: var(--nav-height);
}

.logo {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--text);
  letter-spacing: -0.02em;
}

.logo a {
  color: inherit;
  text-decoration: none;
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 2rem;
}

.nav-links a {
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 450;
  letter-spacing: -0.01em;
  transition: color 0.2s ease;
}

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

/* --- Hero / Intro --- */
.hero {
  padding: 4rem 0 3rem;
  border-bottom: 1px solid var(--border-light);
}

.hero-content {
  display: flex;
  align-items: flex-start;
  gap: 2.5rem;
}

.hero-text {
  flex: 1;
}

.hero h1 {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  font-weight: 400;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 0.75rem;
  letter-spacing: -0.02em;
}

.hero-bio {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
  max-width: 520px;
}

.hero-bio a {
  color: var(--text);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  transition: border-color 0.2s ease;
}

.hero-bio a:hover {
  border-color: var(--text);
  color: var(--text);
}

.social-links {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.social-links a {
  color: var(--text-muted);
  font-size: 1.1rem;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: color 0.2s ease, background 0.2s ease;
}

.social-links a:hover {
  color: var(--text);
  background: var(--surface);
}

.profile-photo {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid var(--border-light);
  cursor: pointer;
  perspective: 600px;
}

.profile-photo-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transition: transform 0.6s ease-in-out;
  transform-style: preserve-3d;
}

.profile-photo.flipped .profile-photo-inner {
  transform: rotateY(180deg);
}

.profile-photo-front,
.profile-photo-back {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  backface-visibility: hidden;
}

.profile-photo-back {
  transform: rotateY(180deg);
}

.profile-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* --- Sections --- */
.section {
  padding: 3rem 0;
}

.section + .section {
  border-top: 1px solid var(--border-light);
}

.section-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--text);
  margin-bottom: 1.5rem;
  letter-spacing: -0.02em;
}

/* --- Cards (for notes listing, publications) --- */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.card {
  display: block;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border-light);
  text-decoration: none;
  transition: opacity 0.15s ease;
}

.card:first-child {
  padding-top: 0;
}

.card:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.card:hover {
  opacity: 0.7;
}

.card-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--text);
  margin-bottom: 0.2rem;
  letter-spacing: -0.01em;
  line-height: 1.4;
}

.card-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.card-description {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* --- Publication cards --- */
.pub-card {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border-light);
}

.pub-card:last-child {
  border-bottom: none;
}

.pub-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.25rem;
  line-height: 1.4;
}

.pub-title a {
  color: var(--text);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.pub-title a:hover {
  border-color: var(--text-secondary);
}

.pub-authors {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.2rem;
}

.pub-venue {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.pub-description {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.badge-row {
  display: flex;
  gap: 0.5rem;
  margin: 0.4rem 0;
  flex-wrap: wrap;
}

.badge-row img {
  height: 18px;
}

/* --- Project pills --- */
.project-item {
  font-size: 0.9rem;
  line-height: 1.6;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
}

.project-item:last-child {
  border-bottom: none;
}

.project-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.project-pill:hover {
  background: #eef2ff;
  border-color: #dbe3ff;
  color: var(--accent);
}

.project-pill i {
  font-size: 0.85rem;
}

/* --- Post Page Layout --- */
.post-header {
  padding: 3rem 0 2rem;
}

.post-back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  transition: color 0.2s ease;
}

.post-back:hover {
  color: var(--text);
}

.post-title {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 400;
  color: var(--text);
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.post-date {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* --- Post Content (Prose) --- */
.post-content {
  padding: 2rem 0 4rem;
}

.post-content p {
  margin-bottom: 1.25rem;
}

.post-content h2 {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 400;
  color: var(--text);
  margin: 2.5rem 0 1rem;
  letter-spacing: -0.02em;
}

.post-content h3 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 400;
  color: var(--text);
  margin: 2rem 0 0.75rem;
  letter-spacing: -0.01em;
}

.post-content strong {
  font-weight: 600;
  color: var(--text);
}

.post-content em {
  font-style: italic;
}

.post-content ul, .post-content ol {
  margin: 1rem 0 1.25rem;
  padding-left: 1.5rem;
}

.post-content li {
  margin-bottom: 0.4rem;
}

.post-content blockquote {
  border-left: 3px solid var(--border);
  padding-left: 1.25rem;
  margin: 1.5rem 0;
  color: var(--text-secondary);
  font-style: italic;
}

.post-content hr {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 2.5rem 0;
}

.post-content a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(37, 99, 235, 0.3);
  text-underline-offset: 2px;
  transition: text-decoration-color 0.2s ease;
}

.post-content a:hover {
  text-decoration-color: var(--accent);
}

/* Code */
.post-content code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

.post-content pre {
  background: var(--code-bg);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  line-height: 1.5;
}

.post-content pre code {
  background: none;
  padding: 0;
  font-size: 0.8rem;
  border-radius: 0;
}

/* Images & Figures */
.post-content figure {
  margin: 2rem 0;
  text-align: center;
}

.post-content figure img {
  border-radius: 12px;
  margin: 0 auto;
}

.post-content figcaption {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  line-height: 1.4;
}

.post-content .img-row {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin: 2rem 0;
}

.post-content .img-row img {
  border-radius: 12px;
}

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

/* Footnotes */
.post-content .footnotes {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-light);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.post-content .footnote-ref {
  font-size: 0.75em;
  vertical-align: super;
  margin-left: 1px;
}

/* --- Interactive Visualization Containers --- */
.viz-container {
  margin: 2.5rem 0;
  padding: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}

.viz-container--wide {
  margin-left: -2rem;
  margin-right: -2rem;
  padding: 2rem;
}

.viz-title {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.viz-canvas {
  width: 100%;
  border-radius: 8px;
  display: block;
  touch-action: none;
}

.viz-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.viz-controls label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.viz-controls input[type="range"] {
  width: 120px;
  accent-color: var(--accent);
}

.viz-controls button {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.4rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.viz-controls button:hover {
  background: var(--bg-card);
  border-color: var(--text-muted);
}

.viz-controls button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.viz-controls .viz-value {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  min-width: 2.5rem;
}

/* --- Footer --- */
footer {
  border-top: 1px solid var(--border-light);
  padding: 2rem 0;
  margin-top: 3rem;
}

footer p {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* --- Research page specifics --- */
.research-cards {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.research-card {
  display: block;
  text-decoration: none;
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

.research-card:hover {
  border-color: #d4cfc5;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  transform: translateY(-1px);
}

.research-card h3 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--text);
  margin-bottom: 0.2rem;
}

.research-card-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.research-card-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.research-card-link {
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 500;
  margin-top: 0.4rem;
  display: inline-block;
}

/* Research post pills */
.research-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.research-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.research-pill:hover {
  background: #eef2ff;
  border-color: #dbe3ff;
  color: var(--accent);
}

.research-pill i {
  font-size: 0.8rem;
}

.research-pill.disabled {
  color: var(--text-muted);
  cursor: default;
  pointer-events: none;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  :root {
    --max-width: 100%;
  }

  .container {
    padding: 0 1.25rem;
  }

  .hero {
    padding: 2.5rem 0 2rem;
  }

  .hero-content {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1.5rem;
  }

  .hero-bio {
    max-width: 100%;
  }

  .profile-photo {
    width: 110px;
    height: 110px;
    order: -1;
  }

  .social-links {
    justify-content: center;
  }

  .hero h1 {
    font-size: 1.75rem;
  }

  .nav-links {
    gap: 1.25rem;
  }

  .section {
    padding: 2rem 0;
  }

  .post-title {
    font-size: 1.6rem;
  }

  .viz-container--wide {
    margin-left: -1.25rem;
    margin-right: -1.25rem;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
}

@media (max-width: 480px) {
  .nav-links {
    gap: 1rem;
  }

  .nav-links a {
    font-size: 0.8rem;
  }

  .post-content pre {
    border-radius: 0;
    margin-left: -1.25rem;
    margin-right: -1.25rem;
    padding: 1rem 1.25rem;
  }
}
