/* Madhesh T — portfolio
   Plain CSS, system font stacks only (no web-font requests).
   Type roles: serif for name, headings and the About text; sans for body;
   mono for dates, tags and tech stacks. */

:root {
  --bg: #ffffff;
  --text: #111111;
  --muted: #666666;
  --faint: #8a8a8a;
  --border: #e8e8e8;
  --link: #0b4fb3;
  --link-hover: #072f6b;
  --underline: #a9bfe3;
  --serif: Charter, "Bitstream Charter", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media screen {
  :root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #191b1d;
    --text: #e9e6df;
    --muted: #b3b3ad;
    --faint: #91938e;
    --border: #393c3e;
    --link: #a4c9ed;
    --link-hover: #d2e7fa;
    --underline: #617d95;
  }
}
.theme-toggle {
  float: right;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--text); border-color: currentColor; }
.theme-toggle:focus-visible { outline: 2px solid var(--link); outline-offset: 3px; }
.theme-toggle[hidden], .theme-toggle .sun, [data-theme="dark"] .theme-toggle .moon { display: none; }
[data-theme="dark"] .theme-toggle .sun { display: block; }

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

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

body {
  margin: 72px auto;
  padding: 0 24px;
  max-width: 800px;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }
img { display: block; max-width: 100%; height: auto; }

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--underline);
  text-underline-offset: 2px;
}
a:hover { color: var(--link-hover); text-decoration-color: currentColor; }
a:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; border-radius: 2px; }

/* ---------- Header ---------- */
.site-header { margin-bottom: 56px; }
.portfolio-return { display: inline-block; margin-bottom: 36px; font-size: 0.9rem; }

.site-header h1 {
  font-family: var(--serif);
  font-size: 2.6rem;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.015em;
}

.site-header .wordmark {
  margin-bottom: 14px;
  font-size: clamp(2.8rem, 7vw, 4rem);
  letter-spacing: -0.045em;
}
.skip { position: absolute; left: -10000px; }
.skip:focus { position: static; }
.contents {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin-top: 24px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
}
.contents a { padding: 3px 0; }
section[id] { scroll-margin-top: 20px; }

.focus {
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.focus li + li::before { content: "\00b7"; margin-right: 10px; color: var(--faint); }

.links { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; font-size: 0.9rem; }
.links a { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; }
.links a:hover { color: var(--text); }
.links svg { width: 15px; height: 15px; flex: none; }
.links .resume {
  margin-left: auto;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}
.links .resume:hover { border-color: var(--text); }

/* ---------- Sections ---------- */
section { margin-bottom: 56px; }

h2 {
  font-family: var(--serif);
  font-size: 1.45rem;
  font-weight: 500;
  margin-bottom: 22px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* About: editorial serif */
#about p, .personal-notes p:not(.more) { font-family: var(--serif); font-size: 1.08rem; line-height: 1.75; }
#about .lede { font-size: 1.18rem; }

.personal-notes { max-width: 58ch; }
.personal-notes section { margin: 32px 0; }
.personal-notes h2 { margin-bottom: 12px; }

.areas {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin: 28px 0 0;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}
.areas div { min-width: 0; }
.areas dt {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.areas dd { margin: 0; font-size: 0.92rem; line-height: 1.55; }

/* ---------- Project and contribution rows ---------- */
.entry {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  padding: 24px 0;
  border-bottom: 1px solid var(--border);
}
.entry:first-of-type { padding-top: 0; }
.entry:last-child { border-bottom: 0; padding-bottom: 0; }

.thumb {
  flex: none;
  width: 136px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  line-height: 0;
  cursor: zoom-in;
}
.thumb img { width: 100%; aspect-ratio: 16 / 9; object-fit: contain; }

.entry .body { flex: 1; min-width: 0; font-size: 0.95rem; }
.entry h3 {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  font-size: 1.05rem;
  line-height: 1.35;
}
.entry h3 a { color: var(--link); text-decoration: none; }
.entry h3 a:hover { text-decoration: underline; }

.status {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
}
.stack { font-family: var(--mono); font-size: 0.76rem; color: var(--muted); margin: 4px 0 10px; }
.entry p:not(.stack) { margin: 0; }
.project-note { margin-top: 10px; }
.project-note summary { width: fit-content; cursor: pointer; color: var(--link); font-size: 0.88rem; }
.project-note summary:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
.project-note[open] p { margin-top: 8px; padding-left: 14px; border-left: 2px solid var(--border); }

/* ---------- Recognition ---------- */
.awards { list-style: none; margin: 0; padding: 0; }
.awards li {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}
.awards li:last-child { border-bottom: 0; }
.awards .when { font-family: var(--mono); font-size: 0.76rem; color: var(--muted); padding-top: 4px; }
.awards strong { font-weight: 600; }

/* ---------- Blog ---------- */
.post { border-left: 2px solid var(--border); padding: 2px 0 2px 16px; margin-bottom: 22px; }
.post:last-of-type { margin-bottom: 0; }
.post h3 { font-family: var(--serif); font-size: 1.15rem; font-weight: 500; line-height: 1.35; }
.post h3 a { color: var(--text); text-decoration: none; }
.post h3 a:hover { color: var(--link); text-decoration: underline; }
.post .meta { font-family: var(--serif); font-style: italic; font-size: 0.93rem; color: var(--muted); margin: 3px 0 6px; }
.post p { margin: 0; font-size: 0.95rem; }
.more { margin-top: 20px; font-size: 0.9rem; }

/* ---------- Footer ---------- */
footer {
  margin-top: 72px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--muted);
}
footer a { color: inherit; }

/* ---------- Lightbox (native <dialog>) ---------- */
#lightbox {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  display: none;
  place-items: center;
  cursor: zoom-out;
}
#lightbox[open] { display: grid; }
#lightbox::backdrop {
  background: rgba(10, 10, 10, 0.8);
}
#lightbox figure { margin: 0; display: grid; gap: 12px; justify-items: center; cursor: default; }
#lightbox img {
  width: auto;
  max-width: min(92vw, 960px);
  max-height: 82vh;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
#lightbox img[src$=".svg"] { width: min(92vw, 960px); }
#lightbox img[src$="-thumb.webp"] { width: min(92vw, 300px); }
#lightbox figcaption a { color: inherit; }
#lightbox figcaption {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.8);
}
#lightbox .close {
  position: fixed;
  top: 14px;
  right: 18px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font: 26px/1 var(--sans);
  cursor: pointer;
}
#lightbox .close:hover { background: rgba(255, 255, 255, 0.24); }
body:has(#lightbox[open]) { overflow: hidden; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  body { margin: 40px auto; padding: 0 18px; }
  .site-header h1 { font-size: 2.1rem; }
  .links .resume { margin-left: 0; }
  .areas { grid-template-columns: 1fr; gap: 16px; }
  .entry { flex-direction: column; gap: 14px; }
  .thumb { width: 100%; max-width: 360px; }
  .awards li { grid-template-columns: 1fr; gap: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

@media print {
  .theme-toggle { display: none; }
  body { margin: 0 auto; font-size: 11pt; }
  .thumb, #lightbox, .links svg, .contents, .skip, footer a[href="#top"] { display: none; }
  a { color: inherit; text-decoration: none; }
  .entry, .awards li, .post { break-inside: avoid; }
}
