/* ============================================================
   Rajath Pai — portfolio
   Shared design system (Home, Blog, Articles)
   Classy / editorial / minimal
   ============================================================ */

/* ---- Design tokens ---------------------------------------- */
:root {
  --bg:        #FBFAF6;   /* warm ivory */
  --surface:   #FFFFFF;
  --ink:       #1C1B19;   /* near-black, warm */
  --ink-soft:  #3C3A36;
  --muted:     #6E6A63;   /* warm gray */
  --faint:     #98938A;
  --line:      #E8E3D8;   /* hairline */
  --accent:    #9E5C33;   /* refined clay */
  --accent-hi: #7E4826;   /* darker clay (hover) */
  --code-bg:   #1E1D1A;
  --code-fg:   #EDE7DB;
  --shadow:    0 18px 50px rgba(28, 27, 25, 0.07);
  --shadow-sm: 0 6px 20px rgba(28, 27, 25, 0.06);

  --maxw: 720px;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans:  "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
  --bg:        #141310;
  --surface:   #1C1B17;
  --ink:       #ECE7DD;
  --ink-soft:  #D2CCC0;
  --muted:     #9A948A;
  --faint:     #726C62;
  --line:      #2C2A24;
  --accent:    #D89A6A;
  --accent-hi: #E8B98F;
  --code-bg:   #0F0E0C;
  --code-fg:   #E8E2D6;
  --shadow:    0 18px 50px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 6px 20px rgba(0, 0, 0, 0.4);
}

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

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

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink-soft);
  line-height: 1.7;
  font-size: 1.02rem;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background 0.35s ease, color 0.35s ease;
}

::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }

a { color: var(--accent); text-decoration: none; }
img { max-width: 100%; display: block; }

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

main { display: block; }

.section { padding: 46px 0; border-top: 1px solid var(--line); }
.section:first-of-type { border-top: none; }

/* ---- Header / nav ----------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav {
  max-width: var(--maxw); margin: 0 auto; padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand {
  font-family: var(--serif); font-weight: 600; font-size: 1.15rem;
  color: var(--ink); letter-spacing: 0.01em;
}
.brand:hover { color: var(--accent); }
.nav-links { display: flex; align-items: center; gap: 26px; }
.nav-links a {
  position: relative; font-size: 0.92rem; font-weight: 500;
  color: var(--muted); padding: 4px 0;
}
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--ink); }
.nav-links a::after {
  content: ""; position: absolute; left: 0; bottom: -2px; height: 1.5px; width: 0;
  background: var(--accent); transition: width 0.28s ease;
}
.nav-links a:hover::after, .nav-links a[aria-current="page"]::after { width: 100%; }

/* Theme toggle */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  cursor: pointer; transition: border-color 0.2s ease, transform 0.2s ease, color 0.2s ease;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---- Hero ------------------------------------------------- */
.hero { text-align: center; padding: 76px 0 40px; }
.hero .avatar {
  width: 116px; height: 116px; border-radius: 50%; object-fit: cover;
  margin: 0 auto 24px; border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.hero h1 {
  font-family: var(--serif); font-weight: 600; color: var(--ink);
  font-size: clamp(2.4rem, 6vw, 3.3rem); line-height: 1.06;
  letter-spacing: -0.015em; margin-bottom: 12px;
}
.hero .title {
  font-size: 1.02rem; color: var(--accent); font-weight: 500;
  letter-spacing: 0.14em; text-transform: uppercase; margin-bottom: 22px;
}
.hero .lede {
  max-width: 560px; margin: 0 auto; color: var(--muted); font-size: 1.06rem;
}

/* social row */
.socials { display: flex; justify-content: center; gap: 14px; margin-top: 28px; }
.socials a {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  transition: color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
.socials a:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-3px); }
.socials svg { width: 19px; height: 19px; }

/* ---- Section headings ------------------------------------- */
.section-label {
  font-family: var(--sans); font-size: 0.76rem; font-weight: 600;
  letter-spacing: 0.2em; text-transform: uppercase; color: var(--accent);
  margin-bottom: 8px;
}
.section-title {
  font-family: var(--serif); font-weight: 600; color: var(--ink);
  font-size: 1.85rem; letter-spacing: -0.01em; margin-bottom: 28px;
}

/* ---- Experience ------------------------------------------- */
.entry { margin-bottom: 30px; }
.entry:last-child { margin-bottom: 0; }
.entry-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 16px; margin-bottom: 8px;
}
.entry-role { font-weight: 600; color: var(--ink); font-size: 1.06rem; }
.entry-org { color: var(--accent); font-weight: 500; }
.entry-date {
  color: var(--faint); font-size: 0.85rem; font-weight: 500;
  white-space: nowrap; letter-spacing: 0.01em;
}
.entry ul { list-style: none; }
.entry li {
  position: relative; padding-left: 20px; margin-bottom: 6px;
  color: var(--ink-soft); font-size: 0.98rem;
}
.entry li::before {
  content: ""; position: absolute; left: 2px; top: 11px;
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
}

/* ---- Skills (categorized spec sheet) ---------------------- */
.skill-groups { display: grid; }
.skill-row {
  display: grid; grid-template-columns: 168px 1fr; gap: 28px;
  padding: 15px 0; border-top: 1px solid var(--line); align-items: baseline;
}
.skill-row:first-child { border-top: none; padding-top: 0; }
.skill-row:last-child { padding-bottom: 0; }
.skill-cat {
  font-size: 0.73rem; font-weight: 600; letter-spacing: 0.15em;
  text-transform: uppercase; color: var(--accent); line-height: 1.55;
}
.skill-items { color: var(--ink-soft); font-size: 1rem; line-height: 1.65; }
.skill-items b { color: var(--ink); font-weight: 600; }

/* ---- Card lists (Kaggle / Projects) ----------------------- */
.cards { display: grid; gap: 18px; }
.card {
  padding: 20px 22px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); border-left: 3px solid var(--accent);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-sm); }
.card h3 {
  font-family: var(--sans); font-size: 1.02rem; font-weight: 600;
  color: var(--ink); margin-bottom: 6px;
}
.card h3 a { color: var(--ink); }
.card h3 a:hover { color: var(--accent); }
.card p { color: var(--muted); font-size: 0.96rem; margin: 0; }
.note { color: var(--faint); font-size: 0.92rem; margin-top: 16px; font-style: italic; }
.lead-note { color: var(--muted); margin-bottom: 22px; }

/* ---- Blog listing ----------------------------------------- */
.post-list { display: grid; gap: 16px; }
.post-item {
  display: block; padding: 22px 24px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--surface);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.post-item:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.post-item .post-title {
  font-family: var(--serif); font-size: 1.4rem; font-weight: 600; color: var(--ink);
  margin-bottom: 4px; letter-spacing: -0.01em;
}
.post-item:hover .post-title { color: var(--accent); }
.post-item .post-date {
  font-size: 0.8rem; color: var(--faint); text-transform: uppercase;
  letter-spacing: 0.1em; margin-bottom: 10px;
}
.post-item .post-desc { color: var(--muted); font-size: 0.98rem; margin: 0; }

/* ---- Article (blog post) ---------------------------------- */
.article { max-width: 720px; margin: 0 auto; padding: 60px 24px 20px; }
.article-header { margin-bottom: 40px; }
.article-header .kicker {
  font-size: 0.78rem; font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 14px;
}
.article-header h1 {
  font-family: var(--serif); font-weight: 600; color: var(--ink);
  font-size: clamp(2rem, 5vw, 2.8rem); line-height: 1.12; letter-spacing: -0.015em;
  margin-bottom: 14px;
}
.article-header .meta { color: var(--faint); font-size: 0.9rem; }

.prose > * + * { margin-top: 20px; }
.prose h2 {
  font-family: var(--serif); font-weight: 600; color: var(--ink);
  font-size: 1.5rem; letter-spacing: -0.01em; margin-top: 44px; padding-top: 6px;
}
.prose h3 { font-size: 1.12rem; font-weight: 600; color: var(--ink); margin-top: 30px; }
.prose p, .prose li { color: var(--ink-soft); }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin-top: 6px; }
.prose li::marker { color: var(--accent); }
.prose strong { color: var(--ink); font-weight: 600; }
.prose blockquote {
  border-left: 3px solid var(--accent); padding: 4px 0 4px 18px;
  color: var(--muted); font-style: italic;
}
.prose hr { border: none; border-top: 1px solid var(--line); margin: 40px 0; }

/* inline + block code */
.prose :not(pre) > code {
  font-family: "SF Mono", "JetBrains Mono", "Fira Code", ui-monospace, Menlo, monospace;
  font-size: 0.86em; background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--accent-hi); padding: 2px 6px; border-radius: 5px;
  border: 1px solid var(--line);
}
[data-theme="dark"] .prose :not(pre) > code { color: var(--accent); }
.prose pre {
  background: var(--code-bg); color: var(--code-fg); border-radius: 12px;
  padding: 18px 20px; overflow-x: auto; font-size: 0.88rem; line-height: 1.6;
  border: 1px solid rgba(255,255,255,0.06);
}
.prose pre code {
  font-family: "SF Mono", "JetBrains Mono", "Fira Code", ui-monospace, Menlo, monospace;
  background: none; color: inherit; padding: 0; border: none;
}

/* tables */
.prose table { width: 100%; border-collapse: collapse; font-size: 0.94rem; }
.prose th, .prose td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.prose thead th {
  color: var(--ink); font-weight: 600; border-bottom: 2px solid var(--line);
  font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em;
}
.prose tbody tr:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }

.back-link {
  display: inline-flex; align-items: center; gap: 6px; font-size: 0.9rem;
  font-weight: 500; color: var(--muted); margin-top: 48px;
}
.back-link:hover { color: var(--accent); }

/* Mermaid diagrams — rendered as light figure cards (legible in both themes) */
.prose .mermaid {
  background: #FCFBF8; color: #1C1B19;
  border: 1px solid var(--line); border-radius: 12px;
  padding: 22px 20px; margin: 26px 0;
  text-align: center; overflow-x: auto;
  font-family: var(--sans); line-height: 1.4;
}
.prose .mermaid:not([data-processed="true"]) {
  color: var(--faint); font-size: 0.8rem; text-align: left; white-space: pre-wrap;
}
.prose .mermaid svg { max-width: 100%; height: auto; }

/* ---- Footer ----------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--line); text-align: center;
  padding: 40px 24px; color: var(--faint); font-size: 0.88rem;
}
.site-footer .socials { margin: 0 0 18px; }

/* ---- Reveal on scroll ------------------------------------- */
.js .reveal { opacity: 0; transform: translateY(16px); transition: opacity 0.7s ease, transform 0.7s ease; }
.js .reveal.is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
}

/* ---- Responsive ------------------------------------------- */
@media (max-width: 600px) {
  .section { padding: 38px 0; }
  .entry-head { flex-direction: column; gap: 2px; }
  .entry-date { white-space: normal; }
  .hero { padding: 54px 0 32px; }
  .nav-links { gap: 18px; }
  .skill-row { grid-template-columns: 1fr; gap: 6px; padding: 14px 0; }
}
