/* ==========================================================================
   Sourabh Khot - portfolio stylesheet
   Single source of truth for the whole site. Loaded via _includes/head.html.
   Layouts and pages must not carry their own <style> blocks.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design tokens
   -------------------------------------------------------------------------- */

:root {
  /* Palette - light */
  --bg:            #ffffff;
  --bg-subtle:     #f6f7f9;
  --bg-elevated:   #ffffff;
  --bg-inset:      #f1f3f5;

  --text:          #14171c;
  --text-muted:    #57606a;
  --text-faint:    #8b939f;

  --border:        #e3e6ea;
  --border-strong: #cfd4da;

  --accent:        #2456c8;
  --accent-hover:  #1b429b;
  --accent-subtle: rgba(36, 86, 200, 0.08);
  --accent-ring:   rgba(36, 86, 200, 0.35);
  /* Foreground for anything sitting ON --accent. Dark mode's accent is a light
     blue, so white-on-accent there would be ~2:1 contrast. */
  --on-accent:     #ffffff;

  /* Syntax tokens for Rouge output. */
  --syn-comment: #6a737d;
  --syn-keyword: #cf222e;
  --syn-string:  #0a3069;
  --syn-number:  #0550ae;
  --syn-func:    #8250df;
  --syn-type:    #953800;
  --syn-op:      #57606a;
  --syn-meta:    #116329;

  --shadow-sm: 0 1px 2px rgba(16, 22, 32, 0.06);
  --shadow-md: 0 4px 16px rgba(16, 22, 32, 0.08);

  /* Type */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;

  --step--1: 0.875rem;
  --step-0:  1rem;
  --step-1:  1.125rem;
  --step-2:  clamp(1.25rem, 1.1rem + 0.6vw, 1.4rem);
  --step-3:  clamp(1.5rem, 1.3rem + 1vw, 1.75rem);
  --step-4:  clamp(1.875rem, 1.5rem + 1.8vw, 2.5rem);
  --step-5:  clamp(2.25rem, 1.6rem + 3.2vw, 3.25rem);

  /* Space & shape */
  --container: 46rem;
  --header-h:  4rem;
  --radius-sm: 0.375rem;
  --radius:    0.625rem;
  --radius-lg: 0.875rem;
  --radius-pill: 100px;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Palette - dark. Applied on explicit choice, or by system preference when no
   choice has been stored. Every token defined above is redefined here. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg:            #0d1117;
    --bg-subtle:     #151b23;
    --bg-elevated:   #131920;
    --bg-inset:      #1b222c;

    --text:          #e6edf3;
    --text-muted:    #9aa4b2;
    --text-faint:    #6e7781;

    --border:        #262d38;
    --border-strong: #39414e;

    --accent:        #6ea8fe;
    --accent-hover:  #8fbcff;
    --accent-subtle: rgba(110, 168, 254, 0.12);
    --accent-ring:   rgba(110, 168, 254, 0.4);
    --on-accent:     #0d1117;

    /* Syntax tokens for Rouge output. */
    --syn-comment: #8b949e;
    --syn-keyword: #ff7b72;
    --syn-string:  #a5d6ff;
    --syn-number:  #79c0ff;
    --syn-func:    #d2a8ff;
    --syn-type:    #ffa657;
    --syn-op:      #9aa4b2;
    --syn-meta:    #7ee787;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
  }
}

:root[data-theme='dark'] {
  --bg:            #0d1117;
  --bg-subtle:     #151b23;
  --bg-elevated:   #131920;
  --bg-inset:      #1b222c;

  --text:          #e6edf3;
  --text-muted:    #9aa4b2;
  --text-faint:    #6e7781;

  --border:        #262d38;
  --border-strong: #39414e;

  --accent:        #6ea8fe;
  --accent-hover:  #8fbcff;
  --accent-subtle: rgba(110, 168, 254, 0.12);
  --accent-ring:   rgba(110, 168, 254, 0.4);
  --on-accent:     #0d1117;

  /* Syntax tokens for Rouge output. */
  --syn-comment: #8b949e;
  --syn-keyword: #ff7b72;
  --syn-string:  #a5d6ff;
  --syn-number:  #79c0ff;
  --syn-func:    #d2a8ff;
  --syn-type:    #ffa657;
  --syn-op:      #9aa4b2;
  --syn-meta:    #7ee787;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
}

/* --------------------------------------------------------------------------
   2. Reset & base
   -------------------------------------------------------------------------- */

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

* { margin: 0; }

html {
  font-size: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1rem);
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: 1.65;
  padding-top: var(--header-h);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}

h1, h2, h3, h4, h5, h6 {
  color: var(--text);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.018em;
  text-wrap: balance;
}

h1 { font-size: var(--step-4); }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-2); }

p { text-wrap: pretty; }

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

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

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

/* Inline SVG icons from the sprite in default.html. Stroke-based so they take
   their colour from the surrounding text. */
.icon {
  width: 1.05em;
  height: 1.05em;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

ul, ol { padding-left: 1.25rem; }

code, pre, kbd, samp { font-family: var(--font-mono); font-size: 0.9em; }

hr {
  border: 0;
  height: 1px;
  background: var(--border);
  margin: 3rem 0;
}

::selection { background: var(--accent-subtle); color: var(--text); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

.skip-link {
  position: absolute;
  left: 0.5rem;
  top: 0.5rem;
  z-index: 200;
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: var(--radius-sm);
  font-size: var(--step--1);
  font-weight: 500;
  transform: translateY(-200%);
  transition: transform 0.2s var(--ease);
}

.skip-link:focus { transform: translateY(0); text-decoration: none; color: var(--on-accent); }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------------------
   3. Layout
   -------------------------------------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: 1.5rem;
}

.site-main { flex: 1 0 auto; }

.page {
  padding-block: clamp(2.5rem, 5vw, 4.5rem);
}

/* Shared page masthead: h1 + one-line intro. */
.section-intro {
  margin-bottom: clamp(2.5rem, 4vw, 3.5rem);
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--border);
}

.section-intro h1 { margin-bottom: 0.75rem; }

.section-intro p {
  font-size: var(--step-1);
  color: var(--text-muted);
  max-width: 38rem;
}

/* --------------------------------------------------------------------------
   4. Header & navigation
   -------------------------------------------------------------------------- */

.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--header-h);
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
}

/* Fallback for browsers without color-mix() */
@supports not (background: color-mix(in srgb, red 50%, blue)) {
  .site-header { background: var(--bg); }
}

.header-inner {
  height: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--text);
  font-weight: 600;
  letter-spacing: -0.02em;
  border-radius: var(--radius);
  padding: 0.25rem;
  margin-left: -0.25rem;
  flex-shrink: 0;
}

.brand:hover { color: var(--text); text-decoration: none; }

/* Monogram tile. Drawn in CSS rather than shipped as an image so it stays sharp
   at any DPR and picks up the accent token. The favicon set mirrors it. */
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1;
  transition: transform 0.2s var(--ease), background-color 0.15s var(--ease);
}

.brand:hover .brand-mark {
  transform: scale(1.06);
  background: var(--accent-hover);
}

.brand-name { font-size: var(--step-0); }

.header-right {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.125rem;
}

.nav-link {
  position: relative;
  display: inline-block;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: var(--step--1);
  font-weight: 500;
  transition: color 0.15s var(--ease), background-color 0.15s var(--ease);
}

.nav-link:hover {
  color: var(--text);
  background: var(--bg-subtle);
  text-decoration: none;
}

.nav-link.is-active { color: var(--text); font-weight: 600; }

.nav-link.is-active::after {
  content: '';
  position: absolute;
  left: 0.7rem;
  right: 0.7rem;
  bottom: 0.05rem;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}

/* Icon buttons (theme toggle, mobile menu) */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-muted);
  font-size: 0.95rem;
  cursor: pointer;
  transition: color 0.15s var(--ease), background-color 0.15s var(--ease), border-color 0.15s var(--ease);
}

.icon-btn:hover {
  color: var(--text);
  background: var(--bg-subtle);
  border-color: var(--border);
}

/* Show the sun in light mode, the moon in dark. */
.theme-toggle .icon-moon { display: none; }
:root[data-theme='dark'] .theme-toggle .icon-moon { display: block; }
:root[data-theme='dark'] .theme-toggle .icon-sun { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .theme-toggle .icon-moon { display: block; }
  :root:not([data-theme='light']) .theme-toggle .icon-sun { display: none; }
}

/* Hamburger flips to a close icon straight off aria-expanded. */
.nav-toggle .icon-close { display: none; }
.nav-toggle[aria-expanded='true'] .icon-menu { display: none; }
.nav-toggle[aria-expanded='true'] .icon-close { display: block; }

.nav-toggle { display: none; }

/* Mobile navigation */
@media (max-width: 33.75rem) {
  .nav-toggle { display: inline-flex; }

  .site-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0.5rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    transform-origin: top;
    display: none;
  }

  .site-nav.is-open { display: flex; }

  .nav-link {
    padding: 0.7rem 0.75rem;
    font-size: var(--step-0);
    border-radius: var(--radius-sm);
  }

  .nav-link.is-active::after { display: none; }
  .nav-link.is-active { background: var(--accent-subtle); color: var(--accent); }
}

/* --------------------------------------------------------------------------
   5. Home - hero
   -------------------------------------------------------------------------- */

/* Vertical rhythm between the home page's divided sections: the space above a
   divider is the previous block's padding-bottom, the space below it is the next
   block's padding-top. */
.hero {
  padding-block: clamp(3rem, 7vw, 5rem) clamp(2.25rem, 4vw, 3.25rem);
}

.hero h1 {
  font-size: var(--step-5);
  font-weight: 700;
  letter-spacing: -0.032em;
  line-height: 1.1;
}

.hero-line-2 { display: block; margin-top: 0.25rem; color: var(--text-muted); }

.hero-description {
  margin-top: 1.75rem;
  font-size: var(--step-1);
  color: var(--text-muted);
  max-width: 36rem;
}

.hero-description p + p { margin-top: 1rem; }

.hero-description a {
  color: var(--text);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.hero-description a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

/* Quote */
.quote {
  margin-block: clamp(2.5rem, 5vw, 3.5rem);
  padding: 1.5rem 1.75rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
}

.quote p {
  font-size: var(--step-2);
  line-height: 1.45;
  font-weight: 500;
  letter-spacing: -0.015em;
  margin-bottom: 0.75rem;
}

.quote p a { color: var(--text); }
.quote p a:hover { color: var(--accent); text-decoration: none; }

.quote cite {
  display: block;
  font-size: var(--step--1);
  font-style: normal;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Contact + socials */
.contact-info { margin-block: 2rem; }

.contact-info > p {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--step--1);
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-bottom: 1.25rem;
}

.contact-info > p .icon { color: var(--text-faint); }

.social-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.social-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 1rem;
  transition: color 0.15s var(--ease), border-color 0.15s var(--ease),
              transform 0.15s var(--ease), background-color 0.15s var(--ease);
}

.social-links a:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-subtle);
  transform: translateY(-2px);
  text-decoration: none;
}

/* Buttons */
.cta-button {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 1.35rem;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--on-accent);
  font-size: var(--step-0);
  font-weight: 500;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.15s var(--ease), transform 0.15s var(--ease),
              box-shadow 0.15s var(--ease);
}

.cta-button .icon {
  width: 0.95em;
  height: 0.95em;
  transition: transform 0.2s var(--ease);
}

.cta-button:hover {
  background: var(--accent-hover);
  color: var(--on-accent);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.cta-button:hover .icon { transform: translateX(3px); }

/* Interests block */
.interests-section {
  padding-block: clamp(2rem, 3.5vw, 2.5rem) clamp(2.25rem, 4vw, 3.25rem);
  border-top: 1px solid var(--border);
}

.interests-section h2 {
  font-size: var(--step-2);
  margin-bottom: 0.875rem;
}

.interests-section p {
  color: var(--text-muted);
  max-width: 38rem;
}

/* --------------------------------------------------------------------------
   6. Post lists
   -------------------------------------------------------------------------- */

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
  padding-top: clamp(2rem, 3.5vw, 2.5rem);
  border-top: 1px solid var(--border);
}

.section-heading h2 { font-size: var(--step-2); }

.post-list { display: grid; gap: 0.5rem; }

.post-item {
  padding: 1.25rem;
  margin-inline: -1.25rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease);
}

.post-item:hover {
  background: var(--bg-subtle);
  border-color: var(--border);
}

.post-title {
  font-size: var(--step-1);
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 0.5rem;
}

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

.post-description { margin-bottom: 0.75rem; }

.post-description a,
.post-link-description {
  color: var(--text-muted);
  font-size: var(--step-0);
}

.post-description a:hover { color: var(--text-muted); text-decoration: none; }

.continue-reading { margin-bottom: 0.75rem; }

.continue-link {
  font-size: var(--step--1);
  font-weight: 500;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--step--1);
  color: var(--text-faint);
}

.post-meta time {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.post-author { color: var(--text-faint); }

/* Tags */
.tag,
.tech-tag {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.6;
  white-space: nowrap;
}

.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.view-all { margin-top: 1.5rem; text-align: right; }

.view-all-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: var(--step--1);
  font-weight: 500;
}

.view-all-link:hover { text-decoration: none; gap: 0.6rem; }

/* --------------------------------------------------------------------------
   7. Writing page - year groups
   -------------------------------------------------------------------------- */

.year-section { margin-bottom: 3rem; }
.year-section:last-child { margin-bottom: 0; }

.year-marker {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-family: var(--font-mono);
  font-size: var(--step-0);
  font-weight: 500;
  color: var(--text-faint);
  margin-bottom: 1rem;
  letter-spacing: 0.02em;
}

.year-marker::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* --------------------------------------------------------------------------
   8. Work page - timeline
   -------------------------------------------------------------------------- */

.job {
  position: relative;
  padding-left: 1.75rem;
  padding-bottom: 2.5rem;
}

.job::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.55rem;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
  z-index: 1;
}

/* Connecting rail, hidden on the final entry. */
.job::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 1.5rem;
  bottom: 0;
  width: 1px;
  background: var(--border);
}

.job:last-child { padding-bottom: 0; }
.job:last-child::after { display: none; }

.job-header { margin-bottom: 1.25rem; }

.job-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
}

.job-title h2 {
  font-size: var(--step-2);
  margin: 0;
}

.company { font-size: var(--step-0); color: var(--text-muted); }
.company::before { content: '· '; color: var(--text-faint); }

.duration {
  display: block;
  margin-top: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-faint);
}

.achievements {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.achievements li {
  position: relative;
  padding-left: 1.25rem;
  color: var(--text-muted);
  font-size: var(--step-0);
  line-height: 1.6;
}

.achievements li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--border-strong);
}

/* --------------------------------------------------------------------------
   9. Projects page
   -------------------------------------------------------------------------- */

.projects-grid { display: grid; gap: 1.25rem; }

.project-card {
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease),
              box-shadow 0.2s var(--ease);
}

.project-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.project-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.project-header h2 { font-size: var(--step-2); }

.project-links { display: flex; gap: 0.5rem; flex-shrink: 0; }

.project-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: color 0.15s var(--ease), border-color 0.15s var(--ease),
              background-color 0.15s var(--ease);
}

.project-link:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-subtle);
  text-decoration: none;
}

.project-description {
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.project-tech { display: flex; flex-wrap: wrap; gap: 0.4rem; }

/* --------------------------------------------------------------------------
   10. Post page
   -------------------------------------------------------------------------- */

.back-nav { margin-bottom: 2rem; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: var(--step--1);
  font-weight: 500;
  color: var(--text-muted);
}

.back-link:hover { color: var(--accent); text-decoration: none; }

.post-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--border);
}

.post-header .post-title {
  font-size: var(--step-4);
  font-weight: 700;
  letter-spacing: -0.028em;
  margin-bottom: 1rem;
}

.post-header .post-meta { gap: 0.6rem; }

/* Long-form prose */
.post-content {
  font-size: var(--step-1);
  line-height: 1.75;
  color: var(--text);
}

.post-content > * + * { margin-top: 1.5rem; }

.post-content h2 {
  font-size: var(--step-3);
  margin-top: 3rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.post-content h3 {
  font-size: var(--step-2);
  margin-top: 2.25rem;
}

.post-content h4 { font-size: var(--step-1); margin-top: 2rem; }

.post-content ul,
.post-content ol { padding-left: 1.5rem; }

.post-content li + li { margin-top: 0.5rem; }

.post-content li::marker { color: var(--text-faint); }

.post-content a {
  font-weight: 500;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

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

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

.post-content img {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-inline: auto;
}

.post-content code {
  padding: 0.15em 0.4em;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85em;
  color: var(--text);
  overflow-wrap: break-word;
}

.post-content pre {
  padding: 1.15rem 1.25rem;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.6;
  -webkit-overflow-scrolling: touch;
}

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

.post-content hr { margin-block: 2.5rem; }

.post-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--step-0);
  display: block;
  overflow-x: auto;
}

.post-content th,
.post-content td {
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  text-align: left;
}

.post-content th { background: var(--bg-subtle); font-weight: 600; }

.post-footer {
  margin-top: 3.5rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border);
}

/* --------------------------------------------------------------------------
   10b. Code blocks: Rouge syntax highlighting + language label and copy button
   -------------------------------------------------------------------------- */

/* Rouge wraps each fenced block in .highlighter-rouge. Make that the bordered
   container so the toolbar and the code share one outline. */
.post-content .highlighter-rouge {
  position: relative;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.post-content .highlighter-rouge pre,
.post-content .highlighter-rouge .highlight {
  margin: 0;
  border: 0;
  border-radius: 0;
  background: none;
}

.post-content .highlighter-rouge pre {
  padding: 1.15rem 1.25rem;
  overflow-x: auto;
}

/* Toolbar, injected by the script in default.html. */
.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.4rem 0.6rem 0.4rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-inset) 60%, var(--bg));
  min-height: 2.25rem;
}

.code-lang {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.code-copy {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-faint);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s var(--ease), color 0.15s var(--ease),
              border-color 0.15s var(--ease), background-color 0.15s var(--ease);
}

/* Reveal on hover, and always for keyboard users. */
.highlighter-rouge:hover .code-copy,
.code-copy:focus-visible { opacity: 1; }

.code-copy:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--bg);
}

.code-copy.is-copied { opacity: 1; color: var(--syn-meta); }

.code-copy .icon { width: 0.9em; height: 0.9em; }

@media (hover: none) {
  .code-copy { opacity: 1; }
}

/* Rouge tokens. Grouped by role rather than listed one class per line. */
.highlight .c, .highlight .ch, .highlight .cd, .highlight .cm,
.highlight .cpf, .highlight .c1, .highlight .cs { color: var(--syn-comment); font-style: italic; }

.highlight .k, .highlight .kc, .highlight .kd, .highlight .kn,
.highlight .kp, .highlight .kr, .highlight .ow { color: var(--syn-keyword); }

.highlight .s, .highlight .sa, .highlight .sb, .highlight .sc, .highlight .dl,
.highlight .sd, .highlight .s2, .highlight .sh, .highlight .si, .highlight .sx,
.highlight .sr, .highlight .s1, .highlight .ss { color: var(--syn-string); }

.highlight .m, .highlight .mb, .highlight .mf, .highlight .mh,
.highlight .mi, .highlight .il, .highlight .mo { color: var(--syn-number); }

.highlight .nf, .highlight .fm, .highlight .nb, .highlight .bp { color: var(--syn-func); }

.highlight .kt, .highlight .nc, .highlight .nn, .highlight .ne,
.highlight .nt { color: var(--syn-type); }

.highlight .o, .highlight .p, .highlight .pi { color: var(--syn-op); }

.highlight .na, .highlight .nv, .highlight .vc, .highlight .vg,
.highlight .vi, .highlight .vm { color: var(--syn-meta); }

.highlight .cp, .highlight .no, .highlight .nd, .highlight .ni,
.highlight .nl, .highlight .py { color: var(--syn-type); }

.highlight .se, .highlight .sensitive { color: var(--syn-keyword); }
.highlight .err { color: var(--syn-keyword); }
.highlight .gd { color: var(--syn-keyword); }
.highlight .gi { color: var(--syn-meta); }
.highlight .gh, .highlight .gu { color: var(--syn-func); font-weight: 600; }
.highlight .gs { font-weight: 600; }
.highlight .ge { font-style: italic; }

/* --------------------------------------------------------------------------
   10c. Reading progress + prev/next post navigation
   -------------------------------------------------------------------------- */

.read-progress {
  position: fixed;
  top: var(--header-h);
  left: 0;
  height: 2px;
  width: 0;
  background: var(--accent);
  z-index: 99;
  transition: width 0.08s linear;
}

.post-nav {
  display: grid;
  gap: 0.75rem;
  margin-top: 2rem;
  grid-template-columns: 1fr;
}

@media (min-width: 40rem) {
  .post-nav.has-both { grid-template-columns: 1fr 1fr; }
}

.post-nav-link {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  transition: border-color 0.15s var(--ease), transform 0.15s var(--ease),
              box-shadow 0.15s var(--ease);
}

.post-nav-link:hover {
  border-color: var(--border-strong);
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.post-nav-dir {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.post-nav-title {
  color: var(--text);
  font-size: var(--step-0);
  font-weight: 500;
  line-height: 1.4;
}

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

.post-nav-link.is-older { text-align: right; }
.post-nav-link.is-older .post-nav-dir { align-self: flex-end; }

/* --------------------------------------------------------------------------
   11. Footer
   -------------------------------------------------------------------------- */

.site-footer {
  margin-top: 4rem;
  padding-block: 2.25rem;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: var(--step--1);
  flex-shrink: 0;
}

.footer-inner {
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.75rem 1.5rem;
}

.footer-inner p {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.footer-sep { opacity: 0.4; }

.heart { color: #e25555; display: inline-block; }

@media (prefers-reduced-motion: no-preference) {
  .heart { animation: heartbeat 1.6s ease-in-out infinite; }
}

@keyframes heartbeat {
  0%, 28%, 70%, 100% { transform: scale(1); }
  14%, 42%           { transform: scale(1.14); }
}

/* --------------------------------------------------------------------------
   12. 404
   -------------------------------------------------------------------------- */

.error-page {
  text-align: center;
  padding-block: clamp(4rem, 12vw, 8rem);
}

.error-code {
  font-family: var(--font-mono);
  font-size: clamp(4rem, 16vw, 7rem);
  font-weight: 500;
  line-height: 1;
  color: var(--text);
  letter-spacing: -0.04em;
  margin-bottom: 1.25rem;
}

.error-page h1 { font-size: var(--step-3); margin-bottom: 0.75rem; }
.error-page p { color: var(--text-muted); margin-bottom: 2rem; }

/* --------------------------------------------------------------------------
   13. Motion & print
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media print {
  .site-header,
  .site-footer,
  .back-nav,
  .cta-button,
  .social-links { display: none !important; }

  body { padding-top: 0; color: #000; background: #fff; }
  .page, .hero { padding-block: 0; }
  a { color: #000; text-decoration: underline; }
  .project-card, .quote { break-inside: avoid; }
}
