/* ══════════════════════════════════════════════
   RESET & BASICS
══════════════════════════════════════════════ */

/* ── Light theme (default) — warm paper ── */
:root,
[data-theme="light"] {
  --bg-color:        #f0ebe1;        /* warm parchment page */
  --surface-color:   #faf7f2;        /* slightly warmer card white */
  --border-color:    #d6cfc4;        /* warm taupe border */
  --border-hover:    #9e8f80;        /* darker taupe on hover */
  --text-color:      #18130e;        /* deep warm ink */
  --text-dim:        #7a6f63;        /* warm grey for secondary text */
  --link-color:      #18130e;        /* ink links */
  --accent-color:    #1e6b5a;        /* slate-teal accent (hover glow) */
  --badge-color:     #1e6b5a;        /* Current badge */
  --icon-fill:       #3d342a;        /* dark warm brown for icons */
  --icon-bg:         #e8e1d8;        /* warm cream icon button bg */
  --code-bg:         #e8e1d8;
  --shadow:          0 2px 16px rgba(60,40,20,0.10), 0 1px 3px rgba(60,40,20,0.06);
  --font-main:       'Fira Code', 'Consolas', 'Monaco', monospace;
}

/* ── Dark theme ── */
[data-theme="dark"] {
  --bg-color:        #1e1e1e;        /* Softer dark gray bg */
  --surface-color:   #252526;        /* Softer dark gray surface */
  --border-color:    #3e3e42;
  --border-hover:    #555555;
  --text-color:      #d4d4d4;        /* Lower contrast text */
  --text-dim:        #858585;
  --link-color:      #569cd6;        /* Better link contrast in dark mode */
  --accent-color:    #4ec9b0;
  --badge-color:     #4ec9b0;
  --icon-fill:       #d4d4d4;
  --icon-bg:         #2d2d30;
  --code-bg:         #2d2d30;
  --shadow:          0 2px 12px rgba(0,0,0,0.5);
  --font-main:       'Fira Code', 'Consolas', 'Monaco', monospace;
}

/* ══════════════════════════════════════════════
   BASE
══════════════════════════════════════════════ */
body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: var(--font-main);
  line-height: 1.6;
  margin: 0;
  padding: 0;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s, color 0.2s;
}

/* ══════════════════════════════════════════════
   LAYOUT
══════════════════════════════════════════════ */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* ══════════════════════════════════════════════
   HEADER & NAV
══════════════════════════════════════════════ */
header {
  margin-bottom: 3rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.site-title a {
  text-decoration: none;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text-color);
  border: none;
}

nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

nav a {
  margin-left: 12px;
  text-decoration: none;
  color: var(--text-dim);
  font-size: 0.95rem;
}

nav a:hover, nav a.active {
  color: var(--link-color);
  text-decoration: underline;
  text-decoration-thickness: 1px;
}

/* ── Theme toggle button ── */
.theme-toggle {
  margin-left: 14px;
  background: var(--icon-bg);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 4px 10px;
  cursor: pointer;
  color: var(--text-color);
  font-family: var(--font-main);
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: border-color 0.15s, color 0.15s;
}
.theme-toggle:hover {
  border-color: var(--border-hover);
}

/* Show correct icon per theme */
[data-theme="dark"]  .theme-icon-light  { display: none; }
[data-theme="dark"]  .theme-icon-dark   { display: inline-flex; }
[data-theme="light"] .theme-icon-dark   { display: none; }
[data-theme="light"] .theme-icon-light  { display: inline-flex; }

/* ── Light mode component overrides ── */

/* Card: slightly elevated, warmer hover */
[data-theme="light"] .card {
  background: var(--surface-color);
  box-shadow: var(--shadow);
}
[data-theme="light"] .card:hover {
  border-color: #9e8f80;
  box-shadow: 0 4px 24px rgba(60,40,20,0.13), 0 1px 4px rgba(60,40,20,0.08);
}

/* Timeline dot: teal in light mode */
[data-theme="light"] .update-dot {
  background: var(--badge-color);
  border-color: var(--bg-color);
}

/* Icon link hover: warm teal ring */
[data-theme="light"] .icon-links a:hover {
  border-color: var(--badge-color);
}

/* Badge: filled teal pill in light mode for better readability */
[data-theme="light"] .badge-current {
  background: #e8f4f0;
  color: #1e6b5a;
  border-color: #a8d5c8;
}

/* Nav active / hover: teal underline */
[data-theme="light"] nav a:hover,
[data-theme="light"] nav a.active {
  color: var(--text-color);
  text-decoration-color: var(--badge-color);
}

/* ══════════════════════════════════════════════
   LINKS & TYPOGRAPHY
══════════════════════════════════════════════ */
a {
  color: var(--link-color);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.15s;
}

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

h1, h2, h3 {
  font-weight: 600;
  color: var(--text-color);
  margin-top: 2rem;
  margin-bottom: 1rem;
}

h1 { font-size: 1.8rem; }
h2 { font-size: 1.4rem; border-bottom: 1px solid var(--border-color); padding-bottom: 0.5rem; }
h3 { font-size: 1.1rem; }

/* ══════════════════════════════════════════════
   PROJECT & BLOG LISTS
══════════════════════════════════════════════ */
.post-list, .project-list { list-style: none; padding: 0; }
.post-item, .project-item { margin-bottom: 1.5rem; }

.post-date, .project-tech {
  display: inline-block;
  min-width: 120px;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.project-title, .post-title { font-weight: 600; }

code {
  background: var(--code-bg);
  padding: 2px 5px;
  border-radius: 3px;
  font-size: 0.9em;
  border: 1px solid var(--border-color);
}

/* ══════════════════════════════════════════════
   CARDS & GRIDS
══════════════════════════════════════════════ */
.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 820px) {
  .card-grid { grid-template-columns: 1fr 1fr; }
}

.card {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 20px;
  position: relative;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
  min-height: 200px;
}

.card:hover {
  border-color: var(--border-hover);
}

.card-row {
  display: flex;
  gap: 18px;
  align-items: flex-start;
}

/* ── Card header: title + badge ── */
.card-header-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.card-header-row .card-title { margin: 0; }

/* ── Titles, subtitles, body ── */
.card-title {
  margin: 0 0 4px 0;
  font-size: 1.05rem;
}

.card-subtitle {
  margin: 0 0 10px 0;
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.5;
}

.card-body {
  margin: 0 0 36px 0;   /* bottom gap keeps text above duration label */
  font-size: 0.88rem;
  color: var(--text-color);
  line-height: 1.55;
}

/* ── "Current" badge ── */
.badge-current {
  display: inline-block;
  font-size: 0.68rem;
  font-family: var(--font-main);
  color: var(--badge-color);
  border: 1px solid var(--badge-color);
  border-radius: 20px;
  padding: 1px 8px;
  letter-spacing: 0.05em;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Duration label — bottom-right ── */
.card-duration {
  position: absolute;
  bottom: 14px;
  right: 18px;
  font-size: 0.7rem;
  color: var(--text-dim);
  font-family: var(--font-main);
  white-space: nowrap;
}

/* ══════════════════════════════════════════════
   CARD IMAGES
══════════════════════════════════════════════ */
.card-img-wrap {
  display: flex;
  align-items: flex-start;
  flex-shrink: 0;
}

/* Static / animated card thumbnail */
.card-img {
  width: 160px;
  height: 140px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  filter: none !important;
}

/* ══════════════════════════════════════════════
   ICON LINKS
══════════════════════════════════════════════ */
.icon-links {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.icon-links a {
  display: inline-flex;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--icon-bg);
  border: 1px solid var(--border-color);
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: border-color 0.15s;
}

.icon-links a:hover { border-color: var(--border-hover); }

/* Make sure SVG icons adapt to theme */
.icon-links a svg { fill: var(--icon-fill); }
/* For stroke-only SVGs (sun icon lines etc) */
.icon-links a svg line { stroke: var(--icon-fill); }

/* ══════════════════════════════════════════════
   PROFESSOR LINK
══════════════════════════════════════════════ */
.prof-link {
  color: var(--text-dim);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}
.prof-link:hover {
  color: var(--link-color);
  text-decoration-style: solid;
}

/* ══════════════════════════════════════════════
   MISC
══════════════════════════════════════════════ */
.muted { color: var(--text-dim); font-size: 0.9rem; }

/* PROFILE IMAGE - NEVER INVERT */
.profile-img { filter: none !important; }

/* ══════════════════════════════════════════════
   BLOG POST IMAGES
══════════════════════════════════════════════ */
[data-theme="dark"] .container img:not(.card-img):not(.profile-img):not([src*="logo"]):not([src*="icon"]) {
  display: block;
  width: 80%;
  max-width: 750px;
  height: auto;
  margin: 1.5rem auto;
  border-radius: 10px;
  filter: invert(0.92) hue-rotate(180deg);
  border: 1px solid var(--border-color);
}

[data-theme="light"] .container img:not(.card-img):not(.profile-img):not([src*="logo"]):not([src*="icon"]) {
  display: block;
  width: 80%;
  max-width: 750px;
  height: auto;
  margin: 1.5rem auto;
  border-radius: 10px;
  filter: none;
  border: 1px solid var(--border-color);
}

/* Smaller images for formulas and definitions */
.container img[alt*="definition"]:not(.card-img):not(.profile-img),
.container img[alt*="formulation"]:not(.card-img):not(.profile-img),
.container img[alt*="formula"]:not(.card-img):not(.profile-img),
.container img[alt*="PGR"]:not(.card-img):not(.profile-img),
.container img[alt*="diagram"]:not(.card-img):not(.profile-img) {
  width: 60%;
  max-width: 550px;
}

/* Medium images */
.container img[alt*="template"]:not(.card-img):not(.profile-img),
.container img[alt*="Effect"]:not(.card-img):not(.profile-img),
.container img[alt*="baseline"]:not(.card-img):not(.profile-img) {
  width: 70%;
  max-width: 650px;
}

/* Larger images for tables and results */
.container img[alt*="table"]:not(.card-img):not(.profile-img),
.container img[alt*="results"]:not(.card-img):not(.profile-img),
.container img[alt*="across"]:not(.card-img):not(.profile-img) {
  width: 90%;
  max-width: 850px;
}

/* ══════════════════════════════════════════════
   CURRENT UPDATES TIMELINE
══════════════════════════════════════════════ */
.updates-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border-left: 1px solid var(--border-color);
  padding-left: 0;
}

.update-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 10px 0 10px 20px;
  position: relative;
  margin-left: -1px; /* sit flush against the border */
}

/* The timeline dot */
.update-dot {
  position: absolute;
  left: -5px;
  top: 16px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--badge-color);
  border: 1px solid var(--bg-color);
  flex-shrink: 0;
}

.update-dot--dim {
  background: var(--text-dim);
}

/* Light mode: make old updates clearly duller than new ones */
[data-theme="light"] .update-dot--dim {
  background: #c5bdb4;          /* pale warm grey — clearly lighter than teal */
  border-color: var(--bg-color);
}

[data-theme="light"] .update-item:has(.update-dot--dim) .update-date {
  color: #b0a79e;               /* even more muted date for old items */
}

[data-theme="light"] .update-item:has(.update-dot--dim) .update-text {
  color: #8a7f75;               /* warm-grey body text for old items */
}

/* Date + text row */
.update-content {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.88rem;
  line-height: 1.5;
}

.update-date {
  font-size: 0.75rem;
  color: var(--text-dim);
  white-space: nowrap;
  min-width: 54px;
  font-family: var(--font-main);
}

.update-text {
  color: var(--text-color);
  flex: 1;
}

/* ══════════════════════════════════════════════
   PROJECT DETAIL PAGES
══════════════════════════════════════════════ */
.project-page-header {
  margin-bottom: 0.5rem;
}

.breadcrumb {
  margin: 0 0 0.5rem 0;
  font-size: 0.82rem;
}

.breadcrumb a {
  color: var(--text-dim);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--accent-color);
  text-decoration: underline;
}

.card-duration-inline {
  margin: 0.3rem 0 0;
  font-size: 0.75rem;
  color: var(--text-dim);
  font-family: var(--font-main);
}

.project-divider {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 1rem 0 0;
}

/* ══════════════════════════════════════════════
   FOOTNOTES
══════════════════════════════════════════════ */
.footnotes {
  font-size: 0.8rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border-color);
  margin-top: 2rem;
  padding-top: 1rem;
}

.footnotes ol {
  margin-top: 0;
  padding-left: 1.25rem;
}

.footnotes li {
  margin-bottom: 0.25rem;
}

.footnotes li p {
  margin: 0;
  display: inline;
}
