/* ==========================================================================
   PortfolioV2 — styles
   Tweak the tokens in :root to re-theme the whole site.
   ========================================================================== */
:root {
  --bg: #f6f1e7;          /* cream */
  --bg-raised: #fbf8f1;
  --bg-hover: #ece6d8;
  --text: #1f1d1a;
  --text-muted: #6f6a60;
  --text-faint: #a39d90;
  --border: #e2dac9;
  --accent: #2f6fed;
  /* film-grain texture laid over the background (opacity is baked into the SVG) */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.05'/%3E%3C/svg%3E");

  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  --font-serif: "Newsreader", "Iowan Old Style", Georgia, serif;

  --sidebar-w: 232px;
  --content-w: 600px;
  --radius: 8px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a09; --bg-raised: #141413; --bg-hover: #1a1a19;
    --text: #ececea; --text-muted: #9b9a96; --text-faint: #62615d;
    --border: #252523; --accent: #7aa2ff;
    --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.09'/%3E%3C/svg%3E");
  }
}
:root[data-theme="dark"] {
  --bg: #0a0a09; --bg-raised: #141413; --bg-hover: #1a1a19;
  --text: #ececea; --text-muted: #9b9a96; --text-faint: #62615d;
  --border: #252523; --accent: #7aa2ff;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.09'/%3E%3C/svg%3E");
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--grain), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.65 var(--font-sans);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
h1, h2, h3 { font-weight: 500; line-height: 1.3; margin: 0; letter-spacing: -0.01em; }
/* Type roles: serif for the name, mono for titles and controls, sans (Inter) for reading text. */
h1, h2, h3, button,
.row-title, .section-link, .card-links, .pager a, .socials, .back {
  font-family: var(--font-mono); letter-spacing: -0.02em;
}
.mono { font-family: var(--font-mono); font-size: 0.8em; letter-spacing: -0.01em; }
.muted { color: var(--text-muted); }
.slash { color: var(--text-faint); margin-right: 1px; font-weight: 400; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- layout ---------- */
/* The sidebar is fixed and slides over the page, so .main always centers in the full viewport. */
.shell { min-height: 100vh; }
.main {
  min-width: 0;
  padding: 88px 32px 48px;
  max-width: calc(var(--content-w) + 64px);
  margin: 0 auto;
  animation: fade-in .5s var(--ease) both;
}
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- sidebar ---------- */
.sidebar {
  position: fixed; z-index: 40; left: 0; top: 0;
  width: var(--sidebar-w); height: 100vh;
  display: flex; flex-direction: column;
  padding: 24px 14px;
  background: var(--grain), var(--bg); /* same grain so it stays seamless with the page */
  overflow-y: auto;
  transition: transform .25s var(--ease), visibility .25s;
}
:root[data-sidebar="closed"] .sidebar { transform: translateX(-100%); visibility: hidden; }

/* empty header keeps the space where the profile used to be; the X sits in it */
.sidebar-head { height: 56px; flex-shrink: 0; }

/* open (two lines) and close (X) buttons share the exact same spot */
.nav-open, .nav-close, .theme-toggle {
  position: fixed; top: 20px; left: 20px;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: none; border: 0; border-radius: 6px;
  color: var(--text-muted); cursor: pointer;
  transition: background .15s, color .15s, opacity .2s;
}
.nav-open:hover, .nav-close:hover, .theme-toggle:hover { background: var(--bg-hover); color: var(--text); }
.nav-open {
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
}
/* light/dark switch: mirror of the menu button in the top-right corner */
.theme-toggle {
  left: auto; right: 20px; z-index: 20;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
}
.nav-close { position: absolute; } /* relative to the fixed sidebar, so same screen position */
:root[data-sidebar="open"] .nav-open { opacity: 0; pointer-events: none; }

/* Spotify button sits just left of the theme toggle and shares its look */
.spotify-toggle {
  position: fixed; z-index: 20; top: 20px; right: 64px;
  width: 36px; height: 36px; display: grid; place-items: center;
  border: 0; border-radius: 6px; cursor: pointer; color: var(--text-muted);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  transition: background .15s, color .15s;
}
.spotify-toggle:hover, .spotify-toggle[aria-expanded="true"] { background: var(--bg-hover); color: var(--text); }

.spotify-panel {
  position: fixed; z-index: 25; top: 64px; right: 20px;
  width: min(320px, calc(100vw - 24px));
  padding: 14px; border-radius: 12px;
  background: var(--grain), var(--bg-raised);
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(0,0,0,.22);
  transform-origin: top right;
  transition: opacity .18s var(--ease), transform .18s var(--ease), visibility .18s;
}
.spotify-panel[hidden] { display: block; visibility: hidden; opacity: 0; transform: translateY(-4px) scale(.98); pointer-events: none; }

.sp-heading {
  margin: 0 0 8px; font-family: var(--font-mono); font-size: 11px; font-weight: 400;
  text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint);
  display: flex; align-items: center; gap: 8px;
}
.sp-heading + .sp-list { margin-bottom: 14px; }
.sp-list { list-style: none; margin: 0 -6px; padding: 0; }
.sp-list:last-child { margin-bottom: 0; }
.sp-track {
  display: flex; align-items: center; gap: 10px;
  padding: 6px; border-radius: 8px; transition: background .15s;
}
a.sp-track:hover { background: var(--bg-hover); }
.sp-art { width: 36px; height: 36px; border-radius: 4px; flex-shrink: 0; object-fit: cover; background: var(--bg-hover); }
.sp-now .sp-art { width: 48px; height: 48px; }
.sp-text { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.sp-title, .sp-artist { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-title { font-family: var(--font-mono); font-size: 13px; font-weight: 500; letter-spacing: -0.02em; }
.sp-artist { font-size: 12.5px; color: var(--text-muted); }
.sp-when { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); flex-shrink: 0; }
.sp-status { margin: 0; font-size: 13px; color: var(--text-muted); }

/* playhead under the now-playing track */
.sp-playhead { margin: 2px 0 16px; }
.sp-bar { height: 3px; border-radius: 2px; background: var(--border); overflow: hidden; }
.sp-fill { height: 100%; width: 0; background: var(--text); border-radius: 2px; transition: width 1s linear; }
.sp-times {
  display: flex; justify-content: space-between; margin-top: 5px;
  font-family: var(--font-mono); font-size: 10.5px; color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.sp-now { margin-bottom: 6px !important; }

/* little equalizer next to "Now playing" */
.sp-eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 10px; }
.sp-eq i { width: 2px; height: 100%; background: #1db954; border-radius: 1px; animation: sp-eq 1s ease-in-out infinite; }
.sp-eq i:nth-child(2) { animation-delay: -.4s; }
.sp-eq i:nth-child(3) { animation-delay: -.7s; }
@keyframes sp-eq { 0%, 100% { transform: scaleY(.3); } 50% { transform: scaleY(1); } }
.sp-eq i { transform-origin: bottom; }

/* mock file path next to the menu button: thomas-nguyen/posts/hello-world.md */
.crumbs {
  position: fixed; z-index: 20; top: 20px; left: 62px;
  height: 36px; max-width: calc(100vw - 176px);
  display: flex; align-items: center; padding: 0 8px; border-radius: 6px;
  font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text-muted);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
}
.crumb { transition: color .15s; }
a.crumb:hover { color: var(--text); text-decoration: underline; text-decoration-color: var(--text-faint); text-underline-offset: 3px; }
.crumb.is-current { color: var(--text); }
.crumb-sep { color: var(--text-faint); margin: 0 3px; }

/* page goes out of focus behind the open sidebar */
.scrim {
  position: fixed; inset: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 35%, transparent);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; transition: opacity .25s var(--ease);
}
.scrim[hidden] { display: block; opacity: 0; pointer-events: none; }
:root[data-sidebar="open"] .scrim { opacity: 1; }

.nav ul { list-style: none; margin: 0; padding: 0; }
.nav a {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 8px; border-radius: 6px;
  font-family: var(--font-mono); font-size: 13px;
  color: var(--text-muted);
  transition: background .15s, color .15s;
}
.nav a:hover { background: var(--bg-hover); color: var(--text); }
.nav a.is-active { background: var(--bg-hover); color: var(--text); }
.nav a.is-active .slash { color: var(--accent); }
.nav-count { font-size: 11.5px; color: var(--text-faint); }
.nav-divider { height: 1px; background: var(--border); margin: 10px 8px; }

/* social links: one row under the name divider on the home page */
.socials { list-style: none; margin: -32px 0 48px; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 12px; }
.socials a {
  color: var(--text-muted);
  text-decoration: underline; text-decoration-color: var(--text-faint);
  text-decoration-thickness: 1px; text-underline-offset: 3px;
  transition: color .15s, text-decoration-color .15s;
}
.socials a:hover { color: var(--text); text-decoration-color: var(--text); }


@media (max-width: 820px) {
  .nav-open, .nav-close { top: 12px; left: 12px; }
  .theme-toggle { top: 12px; right: 12px; }
  .spotify-toggle { top: 12px; right: 56px; }
  .spotify-panel { top: 56px; right: 12px; }
  .crumbs { top: 12px; left: 54px; max-width: calc(100vw - 152px); }
  .main { padding: 72px 20px 40px; }
}

/* ---------- content ---------- */
/* name block, with a short divider underneath that's only as wide as the text */
.intro {
  width: fit-content; max-width: 100%;
  padding-bottom: 20px; margin-bottom: 48px;
  border-bottom: 1px solid var(--border);
}
.intro h1 { font-family: var(--font-serif); font-size: 40px; font-weight: 400; letter-spacing: -0.02em; line-height: 1.1; }
.lede { color: var(--text-muted); margin: 6px 0 0; font-size: 16px; }

/* About / Now / Someday as a row of compact links */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 52px; }
.tile { display: flex; flex-direction: column; gap: 2px; }
.tile-label { text-transform: uppercase; color: var(--text-faint); font-size: 11.5px; letter-spacing: .02em; transition: color .15s; }
.tile-desc { font-weight: 500; font-size: 14px; color: var(--text); transition: color .15s; }
.tiles:hover .tile-desc { color: var(--text-muted); }
.tiles .tile:hover .tile-desc { color: var(--text); }
.tile:hover .tile-label { color: var(--accent); }
@media (max-width: 520px) { .tiles { grid-template-columns: 1fr; gap: 14px; } }

.page-head { margin-bottom: 36px; }
.page-head h1 { font-size: 20px; }
.page-head p { margin: 6px 0 0; }

.section { margin-bottom: 52px; }
.section-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 12px;
}
.section-head h2 { font-size: 13px; font-weight: 500; color: var(--text); }
.section-link { font-size: 12px; color: var(--text-muted); transition: color .15s; }
.section-link:hover { color: var(--text); }

.meta { color: var(--text-faint); margin-top: 12px; }

/* list rows — the main building block */
.rows { list-style: none; margin: 0 -10px; padding: 0; }
.row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  padding: 8px 10px; border-radius: var(--radius);
  transition: background .15s;
}
a.row:hover, summary.row:hover { background: var(--bg-hover); }
.row-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; min-width: 0; }
.row-title { font-weight: 500; font-size: 14px; }
.row-sub { color: var(--text-muted); font-size: 13px; }
/* title on one line, secondary text underneath in a smaller size */
.row-main--stack { flex: 1; flex-direction: column; align-items: stretch; flex-wrap: nowrap; gap: 1px; }
/* first line: title ——— dates */
.row-top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.row-rule { flex: 1; min-width: 16px; height: 1px; background: var(--border); }
.row-meta { color: var(--text-faint); white-space: nowrap; flex-shrink: 0; }
a.row:hover .row-meta { color: var(--text-muted); }

/* expandable work rows */
.row-expand summary { cursor: pointer; list-style: none; }
.row-expand summary::-webkit-details-marker { display: none; }
.row-expand[open] summary { background: var(--bg-hover); }
/* outer box gets its height animated (see main.js); padding lives on the inner box so it can collapse to 0 */
.row-body { overflow: hidden; color: var(--text-muted); font-size: 14px; }
.row-body-inner { padding: 4px 10px 12px; }
.row-body p { margin: 4px 0; }
.row-body ul { margin: 6px 0; padding-left: 18px; }
.row-body a { color: var(--accent); }

/* prose (Markdown) */
.prose { color: var(--text); }
.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol { margin: 0 0 1em; }
.prose a { text-decoration: underline; text-decoration-color: var(--text-faint); text-underline-offset: 3px; }
.prose a:hover { text-decoration-color: var(--text); }
.prose h2 { font-size: 15px; margin: 2em 0 .6em; }
.prose h3 { font-size: 14px; margin: 1.6em 0 .5em; }
.prose ul, .prose ol { padding-left: 20px; }
.prose li { margin: .25em 0; }
.prose blockquote { margin: 1.2em 0; padding-left: 14px; border-left: 2px solid var(--border); color: var(--text-muted); }
.prose code { font-family: var(--font-mono); font-size: .85em; background: var(--bg-hover); padding: 1px 5px; border-radius: 4px; }
.prose pre { background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }

/* someday checklist */
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { position: relative; padding: 4px 0 4px 24px; color: var(--text-muted); }
.checklist li::before {
  content: ""; position: absolute; left: 2px; top: 11px;
  width: 11px; height: 11px; border: 1.5px solid var(--text-faint); border-radius: 3px;
}

/* tags */
.tags { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tags li {
  font-family: var(--font-mono); font-size: 11.5px;
  padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--text-muted);
}

/* skills */
.skills { display: grid; grid-template-columns: 110px 1fr; gap: 10px 16px; margin: 0; }
.skills dt { color: var(--text-muted); padding-top: 3px; }
.skills dd { margin: 0; }
@media (max-width: 520px) { .skills { grid-template-columns: 1fr; } .skills dd { margin-bottom: 8px; } }

/* project cards */
.cards { display: grid; gap: 14px; }
.card {
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px 20px; transition: border-color .15s, transform .2s var(--ease);
}
.card:hover { border-color: var(--text-faint); transform: translateY(-1px); }
.card-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.card h2 { font-size: 14px; }
.card .prose { color: var(--text-muted); font-size: 14px; }
.card .prose p { margin-bottom: .8em; }
.card-links { display: flex; gap: 14px; margin-top: 12px; font-size: 12px; }
.card-links a { color: var(--text-muted); }
.card-links a:hover { color: var(--text); }

/* resume page */
.resume-links { display: flex; gap: 18px; margin-top: 10px; font-family: var(--font-mono); font-size: 12px; }
.resume-links a {
  color: var(--text-muted);
  text-decoration: underline; text-decoration-color: var(--text-faint); text-underline-offset: 3px;
  transition: color .15s, text-decoration-color .15s;
}
.resume-links a:hover { color: var(--text); text-decoration-color: var(--text); }
.resume-pages { display: grid; gap: 20px; min-height: 200px; }
.resume-page {
  position: relative; overflow: hidden;
  background: #fff; border-radius: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,.2), 0 8px 30px rgba(0,0,0,.25);
}
.resume-page canvas { display: block; width: 100%; height: auto; }
.resume-link { position: absolute; border-radius: 2px; }
.resume-link:hover { background: rgba(47, 111, 237, .12); }
.resume-status { color: var(--text-muted); font-size: 14px; }
.resume-status a { text-decoration: underline; text-underline-offset: 3px; }

/* post page */
.back { display: inline-block; color: var(--text-muted); margin-bottom: 24px; }
.back:hover { color: var(--text); }
.pager { display: flex; justify-content: space-between; gap: 16px; margin-top: 56px; padding-top: 20px; border-top: 1px solid var(--border); }
.pager a { display: flex; flex-direction: column; gap: 2px; font-weight: 500; font-size: 14px; }
.pager a.right { text-align: right; margin-left: auto; }

/* footer */
.footer { margin-top: 80px; padding-top: 20px; border-top: 1px solid var(--border); color: var(--text-faint); font-size: 13px; display: flex; flex-wrap: wrap; gap: 8px; }
.footer-credit { margin-left: auto; }
.clock { font-size: 12px; font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
