/* ==========================================================================
   Minimalist Editorial Stylesheet
   Typography: EB Garamond (All typography throughout the site)
   Author: Sai Karnati (skarnati.dev)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400..800;1,400..800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --font-editorial: 'EB Garamond', 'Garamond', 'Cormorant Garamond', 'Baskerville', 'Georgia', serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "SF Pro", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* White Mode (Default) */
  --bg-primary: #ffffff;
  --bg-secondary: #fcfcfc;
  --bg-subtle: #f7f7f7;
  --bg-modal: #ffffff;
  --modal-backdrop: rgba(0, 0, 0, 0.45);
  
  --border: #e8e8e8;
  --border-strong: #1a1a1a;
  
  --text-primary: #181818;
  --text-secondary: #3c3c3c;
  --text-muted: #737373;
  
  --link-color: #181818;
  --link-hover: #555555;
  --link-border: #cccccc;
  
  --code-bg: #f5f5f5;
  --code-border: #e0e0e0;
  
  --max-width: 690px;
}

[data-theme="dark"] {
  --bg-primary: #121212;
  --bg-secondary: #181818;
  --bg-subtle: #202020;
  --bg-modal: #181818;
  --modal-backdrop: rgba(0, 0, 0, 0.75);
  
  --border: #282828;
  --border-strong: #f0f0f0;
  
  --text-primary: #f0f0f0;
  --text-secondary: #d0d0d0;
  --text-muted: #8c8c8c;
  
  --link-color: #f0f0f0;
  --link-hover: #ffffff;
  --link-border: #555555;
  
  --code-bg: #1c1c1c;
  --code-border: #333333;
}

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

button, input, select, textarea {
  font-family: inherit;
}

html {
  font-size: 19px;
  background-color: var(--bg-primary);
}

body {
  font-family: var(--font-editorial);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.2s ease, color 0.2s ease;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

/* Header & Navigation */
site-header {
  display: block;
}

header.site-header {
  padding: 2.75rem 0 1.75rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2.75rem;
}

.header-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.site-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.site-title a {
  color: var(--text-primary);
  text-decoration: none;
}

.theme-toggle {
  background: none;
  border: none;
  font-family: var(--font-editorial);
  font-size: 0.95rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.15s ease;
}

.theme-toggle:hover {
  color: var(--text-primary);
}

nav.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.35rem;
  font-size: 1rem;
}

nav.main-nav a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

nav.main-nav a:hover,
nav.main-nav a.active {
  color: var(--text-primary);
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* Main Content Area */
main {
  flex: 1;
  padding-bottom: 4rem;
}

/* Typography */
h1, h2, h3, h4 {
  font-family: var(--font-editorial);
  color: var(--text-primary);
  font-weight: 700;
  line-height: 1.3;
}

h1 {
  font-size: 1.95rem;
  margin-bottom: 1.25rem;
}

h2 {
  font-size: 1.4rem;
  margin-top: 2.25rem;
  margin-bottom: 0.85rem;
}

h3 {
  font-size: 1.15rem;
  margin-bottom: 0.35rem;
}

p {
  color: var(--text-secondary);
  margin-bottom: 1.35rem;
}

a {
  color: var(--link-color);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--link-border);
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

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

.lead-intro {
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--text-secondary);
  text-align: center;
  max-width: 580px;
  margin: 0.35rem auto;
}

/* Social Icon Links on About Page */
.social-links {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-top: 1.25rem;
  margin-bottom: 2.75rem;
}

.social-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--link-border);
  font-size: 1rem;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

.social-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: currentColor;
  transition: transform 0.15s ease;
}

.social-link:hover {
  color: var(--link-hover);
  text-decoration-color: var(--text-primary);
}

.social-link:hover svg {
  transform: translateY(-1px);
}

/* Page Section Header */
.page-header {
  margin-bottom: 2.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.85rem;
  text-align: center;
}

.page-header h1 {
  margin-bottom: 0;
  text-align: center;
}

.section-title {
  text-align: center;
  font-size: 1.45rem;
  margin-top: 3.5rem;
  margin-bottom: 1.5rem;
}

/* Experience Listing */
.experience-stream {
  display: flex;
  flex-direction: column;
  gap: 3rem;
}

.experience-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.85rem;
  padding-bottom: 2.75rem;
  border-bottom: 1px dotted var(--border);
}

.experience-block:last-child {
  border-bottom: none;
}

.experience-firm {
  font-family: var(--font-sans);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: 0.5rem;
  letter-spacing: -0.015em;
}

.experience-emblem {
  width: 160px;
  height: 160px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 36px;
  background-color: #ffffff;
  overflow: hidden;
  padding: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.experience-emblem img,
.experience-emblem svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.experience-emblem.cognex-badge {
  background-color: #fff200;
  border-color: #e6da00;
  padding: 14px;
}

.experience-role {
  font-family: var(--font-sans);
  font-size: 1.02rem;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  text-align: center;
  margin-top: 0.2rem;
}

.experience-dates {
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 400;
  font-style: normal;
  color: var(--text-muted);
  letter-spacing: 0.01em;
  text-align: center;
}

/* Projects Listing */
.projects-stream {
  display: flex;
  flex-direction: column;
  gap: 3rem;
}

.project-entry {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.85rem;
  padding-bottom: 2.75rem;
  border-bottom: 1px dotted var(--border);
}

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

.project-head {
  margin: 0;
  text-align: center;
}

.project-name {
  font-family: var(--font-sans);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  letter-spacing: -0.015em;
}

.project-name a {
  color: var(--text-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border);
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

.project-name a:hover {
  text-decoration-color: var(--text-primary);
}

.project-badge {
  width: 160px;
  height: 160px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  background-color: var(--bg-secondary);
  overflow: hidden;
  padding: 0;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.project-badge:hover {
  transform: translateY(-4px);
  border-color: var(--border-strong);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.project-badge img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.project-badge svg {
  width: 96px;
  height: 96px;
  display: block;
}

.project-summary {
  display: none;
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.65;
  max-width: 600px;
  margin: 0.4rem auto;
  text-align: center;
}

.project-entry.expanded .project-summary {
  display: block;
}

.project-year {
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 400;
  font-style: normal;
  color: var(--text-muted);
  letter-spacing: 0.01em;
  text-align: center;
}

/* Essays Filter Bar */
.essays-filter-bar {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 2rem;
  font-family: var(--font-editorial);
  font-size: 1rem;
}

.essay-filter-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: transparent;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

.essay-filter-btn:hover {
  color: var(--text-primary);
  text-decoration-color: var(--text-muted);
}

.essay-filter-btn.active {
  color: var(--text-primary);
  font-weight: 700;
  text-decoration-color: var(--text-primary);
}

.filter-sep {
  color: var(--border);
  font-size: 0.9rem;
  user-select: none;
}

/* Article Lists (Essays) */
.writing-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.writing-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.writing-item-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.writing-title {
  font-size: 1.2rem;
  font-weight: 700;
}

.writing-date {
  font-family: var(--font-sans);
  font-size: 0.86rem;
  font-weight: 400;
  font-style: normal;
  color: var(--text-muted);
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.writing-synopsis {
  font-size: 0.98rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 0.25rem;
}

.writing-meta {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 400;
  font-style: normal;
  color: var(--text-muted);
}

/* ==========================================================================
   Reading Gallery (Pure Covers) & Thoughts Popup Modal
   ========================================================================== */

.reading-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 2rem 1.5rem;
  margin-top: 2rem;
}

.book-item {
  display: block;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  transition: transform 0.18s ease, filter 0.18s ease;
  line-height: 0;
}

.book-item:hover {
  transform: translateY(-4px);
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.08));
}

.book-item img {
  width: 100%;
  aspect-ratio: 180 / 260;
  display: block;
  border: 1px solid var(--border);
  border-radius: 4px;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  transition: border-color 0.18s ease;
}

.book-item:hover img {
  border-color: var(--border-strong);
}

/* Popup Modal Backdrop */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: var(--modal-backdrop);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
}

/* Popup Modal Window */
.modal-card {
  width: 100%;
  max-width: 560px;
  background-color: var(--bg-modal);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.75rem 2rem;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.2);
  position: relative;
  transform: translateY(8px);
  transition: transform 0.2s ease;
  font-family: var(--font-editorial);
}

.modal-overlay.active .modal-card {
  transform: translateY(0);
}

.modal-header-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.25rem;
  margin-bottom: 0.35rem;
}

.modal-book-title {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-primary);
  margin: 0;
  padding: 0;
}

.modal-close-btn {
  position: static;
  background: none;
  border: none;
  font-family: var(--font-editorial);
  font-size: 0.95rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
  flex-shrink: 0;
}

.modal-close-btn:hover {
  color: var(--text-primary);
}

.modal-book-author {
  font-size: 1.05rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 1.25rem;
}

.modal-meta-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  padding: 0.85rem 0;
  border-top: 1px dotted var(--border);
  border-bottom: 1px dotted var(--border);
  margin-bottom: 1.5rem;
  font-family: var(--font-editorial);
  font-size: 0.95rem;
  color: var(--text-muted);
}

.modal-meta-grid dt {
  font-weight: 600;
  color: var(--text-primary);
  display: inline;
}

.modal-meta-grid dd {
  display: inline;
  margin-left: 0.25rem;
  font-style: italic;
}

.modal-thoughts-label {
  font-family: var(--font-editorial);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}

.modal-thoughts-text {
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--text-secondary);
  margin-bottom: 0;
}

/* Article Reader View */
.back-link {
  display: inline-block;
  font-family: var(--font-editorial);
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

.article-header {
  margin-bottom: 2.25rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1.5rem;
}

.article-header h1 {
  font-size: 2.25rem;
  line-height: 1.25;
  margin-bottom: 0.5rem;
}

.article-meta-line {
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 400;
  font-style: normal;
  color: var(--text-muted);
}

.article-content {
  font-size: 1.1rem;
  line-height: 1.8;
}

.article-content h2 {
  font-size: 1.5rem;
  margin-top: 2.25rem;
  margin-bottom: 0.85rem;
}

.article-content h3 {
  font-size: 1.25rem;
  margin-top: 1.75rem;
  margin-bottom: 0.5rem;
}

.article-content blockquote {
  border-left: 2px solid var(--border-strong);
  padding: 0.5rem 0 0.5rem 1.25rem;
  margin: 1.75rem 0;
  font-style: italic;
  color: var(--text-primary);
}

.article-content ul,
.article-content ol {
  padding-left: 1.5rem;
  margin-bottom: 1.5rem;
  color: var(--text-secondary);
}

.article-content li {
  margin-bottom: 0.45rem;
}

.article-content code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background-color: var(--code-bg);
  border: 1px solid var(--code-border);
  padding: 0.1em 0.35em;
  border-radius: 2px;
}

.article-content pre {
  background-color: var(--code-bg);
  border: 1px solid var(--code-border);
  padding: 1.1rem;
  overflow-x: auto;
  margin: 1.75rem 0;
  border-radius: 3px;
}

.article-content pre code {
  background-color: transparent;
  border: none;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.6;
}

/* Footer ("Stuff at the bottom") */
footer.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem 0;
  margin-top: 3rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: var(--font-sans);
  letter-spacing: 0.01em;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

/* Mobile responsive */
@media (max-width: 600px) {
  html {
    font-size: 17.5px;
  }
  .header-top {
    flex-direction: column;
    align-items: flex-start;
  }
  nav.main-nav {
    gap: 0.9rem;
  }
  .project-entry,
  .experience-block {
    flex-direction: column;
  }
  .reading-gallery {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem 1rem;
  }
  .modal-card {
    padding: 1.5rem;
  }
}

/* Reading Sections and Lists */
.reading-section {
  margin-top: 2.75rem;
}

.reading-section h2 {
  font-size: 1.35rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.reading-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 0;
  margin: 0;
}

.reading-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px dotted var(--border);
}

.book-title {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text-primary);
}

.book-date {
  font-family: var(--font-sans);
  font-size: 0.86rem;
  font-weight: 400;
  font-style: normal;
  color: var(--text-muted);
  white-space: nowrap;
}

.book-meta-inline {
  margin-top: 0.6rem;
  line-height: 1.35;
  text-align: left;
}

.book-meta-title {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.book-meta-author,
.book-meta-date {
  display: block;
  font-family: var(--font-editorial);
  font-size: 0.85rem;
  font-style: italic;
  color: var(--text-muted);
}
