:root {
  /* Slate neutrals with a cyan accent; cards sit one layer above the page */
  --bg: #f7f8fb;
  --card: #ffffff;
  --surface: #f1f3f8;
  --text: #334155;
  --heading: #0f172a;
  --muted: #64748b;
  --border: #e2e6ee;
  --border-strong: #cbd2de;
  --accent: #0e7490;
  --accent-strong: #155e75;
  --accent-soft: #a5e3ef;
  --accent-tint: #e4f6fa;
  --on-accent: #ffffff;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 16px rgba(15, 23, 42, 0.04);
  --topbar-bg: rgba(247, 248, 251, 0.82);
  --texture-line: rgba(15, 23, 42, 0.09);
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light;
}

/* Dark theme: follows the system setting unless the visitor picks one */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e131d;
    --card: #151b27;
    --surface: #1b2230;
    --text: #cbd3e1;
    --heading: #f1f4f9;
    --muted: #8d98ab;
    --border: #232c3c;
    --border-strong: #334055;
    --accent: #22d3ee;
    --accent-strong: #67e8f9;
    --accent-soft: #1a5563;
    --accent-tint: #0f2c36;
    --on-accent: #0e131d;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    --topbar-bg: rgba(14, 19, 29, 0.8);
    --texture-line: rgba(255, 255, 255, 0.07);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0e131d;
  --card: #151b27;
  --surface: #1b2230;
  --text: #cbd3e1;
  --heading: #f1f4f9;
  --muted: #8d98ab;
  --border: #232c3c;
  --border-strong: #334055;
  --accent: #22d3ee;
  --accent-strong: #67e8f9;
  --accent-soft: #1a5563;
  --accent-tint: #0f2c36;
  --on-accent: #0e131d;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  --topbar-bg: rgba(14, 19, 29, 0.8);
  --texture-line: rgba(255, 255, 255, 0.07);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

/* Reserve the scrollbar's space so content doesn't shift sideways between short and long pages */
html {
  scrollbar-gutter: stable;
}

/* Smooth cross-fade between pages (supported browsers); the top bar stays put */
@view-transition {
  navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.2s;
  animation-timing-function: ease-out;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* Faint box-grid texture behind the page, even across the whole viewport */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(var(--texture-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--texture-line) 1px, transparent 1px);
  background-size: 32px 32px;
  background-position: 0 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

p a:hover {
  text-decoration-color: currentColor;
}

/* ---------- Top bar ---------- */
.topbar {
  view-transition-name: topbar;
  background: var(--topbar-bg);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.topbar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  color: var(--heading);
  font-weight: 600;
  font-size: 0.98rem;
  letter-spacing: -0.01em;
}

.brand:hover {
  text-decoration: none;
}

.topbar .nav {
  margin-top: 0;
  margin-left: auto;
  gap: 2px;
}

.nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.nav a {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.9rem;
  padding: 6px 12px;
  border-radius: 6px;
  transition: color 0.15s ease, background 0.15s ease;
}

.nav a:hover {
  color: var(--heading);
  background: var(--surface);
  text-decoration: none;
}

.nav a.active {
  color: var(--accent);
  background: var(--accent-tint);
}

/* ---------- Page header ---------- */
header {
  padding: 72px 0 8px 0;
}

.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 24px;
}

header h1 {
  color: var(--heading);
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.15;
}

.eyebrow {
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 500;
  margin: 0 0 10px 0;
}

.tagline {
  margin: 12px 0 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 620px;
  text-wrap: pretty;
}

/* ---------- Main content ---------- */
.section {
  width: 100%;
  max-width: 880px;
  margin: 48px auto 80px auto;
  padding: 0 24px;
}

h2 {
  color: var(--heading);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 56px 0 16px 0;
}

.section > h2:first-child {
  margin-top: 0;
}

h3 {
  color: var(--heading);
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: -0.005em;
}

h4 {
  color: var(--heading);
  font-weight: 600;
}

strong {
  font-weight: 600;
}

.project {
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 24px;
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-bottom: 14px;
  transition: border-color 0.15s ease;
}

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

.project h3 {
  margin: 0 0 2px 0;
}

.project p {
  margin: 10px 0;
}

.role-meta {
  color: var(--muted);
  font-size: 0.875rem;
  margin: 0 0 12px 0;
}

.project .role-meta {
  margin: 0 0 12px 0;
}

.project ul {
  margin: 12px 0 0 0;
  padding-left: 18px;
}

.project li {
  margin-bottom: 6px;
}

.project li::marker {
  color: var(--muted);
}

.project li:last-child {
  margin-bottom: 0;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 12px 0;
}

.tag {
  background: var(--accent-tint);
  color: var(--accent-strong);
  border: 1px solid transparent;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 2px 9px;
  border-radius: 6px;
}

/* ---------- Quick facts ---------- */
.facts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin: 32px 0 0 0;
  overflow: hidden;
  background: var(--card);
  box-shadow: var(--shadow);
}

.fact-card {
  display: flex;
  flex-direction: column;
  padding: 20px 22px;
}

.fact-card + .fact-card {
  border-left: 1px solid var(--border);
}

@media (max-width: 600px) {
  .facts-grid {
    grid-template-columns: 1fr;
  }

  .fact-card + .fact-card {
    border-left: none;
    border-top: 1px solid var(--border);
  }
}

.fact-card .fact-label {
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 500;
  margin: 0 0 6px 0;
}

.fact-card .fact-value {
  margin: 0;
  line-height: 1.4;
  font-weight: 600;
  color: var(--heading);
}

.fact-card .fact-sub {
  margin: 4px 0 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.featured-project {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  flex-wrap: wrap;
}

.featured-project p {
  margin-bottom: 0;
}

.featured-project a.btn-link {
  flex-shrink: 0;
}

.btn-link {
  color: var(--accent);
  font-weight: 500;
  font-size: 0.92rem;
  white-space: nowrap;
}

.project a {
  font-weight: 500;
  font-size: 0.92rem;
  text-decoration: none;
}

.project a:hover {
  text-decoration: underline;
}

/* ---------- Home hero ---------- */
.profile-row {
  display: flex;
  align-items: center;
  gap: 48px;
}

.profile-row > div {
  flex: 1;
  min-width: 0;
}

.profile-pic {
  width: 168px;
  height: 168px;
  flex-shrink: 0;
  object-fit: cover;
  border-radius: 50%;
  border: 4px solid var(--card);
  box-shadow: 0 0 0 1px var(--accent-soft);
}

.hero-location {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 10px 0 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.hero-location svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 24px 0 0 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.9rem;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.btn:hover {
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}

.btn-primary:hover {
  opacity: 0.85;
}

.btn-outline {
  border-color: var(--border-strong);
  color: var(--heading);
  background: var(--card);
}

.btn-outline:hover {
  background: var(--surface);
}

.card {
  background: var(--card);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 14px;
}

.card > p:first-child {
  margin-top: 0;
}

.card > p:last-child {
  margin-bottom: 0;
}

/* ---------- Skills ---------- */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 24px;
}

.skill-group h4 {
  margin: 0 0 8px 0;
  font-size: 0.875rem;
}

.skill-group ul {
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.9rem;
}

.skill-group li {
  margin-bottom: 4px;
}

/* ---------- Document links ---------- */
.documents {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
  margin: 0 0 20px 0;
}

.doc-link {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 14px 16px;
  border-radius: 10px;
  color: var(--heading);
  font-weight: 500;
  font-size: 0.92rem;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.doc-link:hover {
  border-color: var(--border-strong);
  background: var(--surface);
  text-decoration: none;
}

.doc-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--accent);
}

.doc-link span.doc-sub {
  display: block;
  font-weight: 400;
  color: var(--muted);
  font-size: 0.82rem;
}

/* ---------- Recommendations ---------- */
.rec-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 0 0 16px 0;
}

/* Three letters side by side; stack them when the columns get too narrow */
@media (max-width: 800px) {
  .rec-grid {
    grid-template-columns: 1fr;
  }
}

.rec-card {
  background: var(--card);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.rec-card .quote {
  margin: 0 0 20px 0;
  color: var(--text);
  flex-grow: 1;
}

/* Cards share the grid's rows (quote / author / link), so names, titles,
   and links line up across cards even when titles wrap to different lengths */
@supports (grid-template-rows: subgrid) {
  .rec-card {
    display: grid;
    grid-row: span 3;
    grid-template-rows: subgrid;
    row-gap: 0;
  }
}

.rec-card .quote::before {
  content: "\201C";
}

.rec-card .quote::after {
  content: "\201D";
}

.rec-author strong {
  display: block;
  color: var(--heading);
  font-size: 0.92rem;
}

.rec-author span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin: 2px 0 0 0;
}

.rec-card .btn-link {
  white-space: normal;
  margin-top: 14px;
}

/* ---------- Contact ---------- */
.contact-item {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
  background: var(--card);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 14px 16px;
  border-radius: 10px;
}

.contact-item svg {
  width: 18px;
  height: 18px;
  color: var(--accent);
  flex-shrink: 0;
}

.contact-item a,
.contact-item span {
  font-weight: 500;
  color: var(--heading);
}

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

.contact-intro {
  max-width: 620px;
}

.contact-cta {
  margin: 20px 0 32px 0;
}

.contact-cta .btn svg {
  width: 16px;
  height: 16px;
}

.contact-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.contact-grid .contact-item {
  margin-bottom: 0;
}

.contact-text {
  min-width: 0;
  flex: 1;
}

.contact-text a,
.contact-text span {
  overflow-wrap: anywhere;
}

.contact-label {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0;
}

@media (max-width: 600px) {
  .contact-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- Footer ---------- */
footer {
  margin-top: auto;
  padding: 28px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  border-top: 1px solid var(--border);
}

/* ---------- Small screens ---------- */
@media (max-width: 600px) {
  header {
    padding-top: 48px;
  }

  .profile-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 24px;
  }

  .profile-pic {
    width: 128px;
    height: 128px;
  }

  /* Name and theme toggle share the first row; links get their own row */
  .topbar .nav {
    order: 3;
    width: 100%;
    margin-left: -12px;
  }

  .theme-toggle {
    margin-left: auto;
  }
}

.heading-flush {
  margin: 0;
}

.section-gap-top {
  margin-top: 56px;
}

/* ---------- Education ---------- */
.edu-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.edu-head h3 {
  margin: 0;
}

.edu-location {
  margin: 0 0 6px 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.edu-badge {
  color: var(--accent-strong);
  background: var(--accent-tint);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 2px 10px;
  border-radius: 6px;
  white-space: nowrap;
}

.edu-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin: 0 0 16px 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.edu-stats strong {
  color: var(--heading);
  margin-left: 4px;
}

/* ---------- Accessibility ---------- */
.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 2000;
  background: var(--accent);
  color: var(--on-accent);
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 500;
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 12px;
}

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

/* ---------- Theme toggle ---------- */
/* JS-only controls are in the HTML but hidden until theme.js marks the page with .js,
   which happens before first paint, so nothing shifts once main.js loads */
.theme-toggle,
.filter-bar,
.filter-status,
.copy-btn {
  display: none;
}

.js .theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.js .filter-bar {
  display: flex;
}

.js .filter-status {
  display: block;
}

.js .copy-btn {
  display: inline-block;
}

/* Moon in light mode, sun in dark mode */
.theme-toggle::before {
  content: "\263E";
}

:root[data-theme="dark"] .theme-toggle::before {
  content: "\2600";
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle::before {
    content: "\2600";
  }
}

.theme-toggle {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.theme-toggle:hover {
  color: var(--heading);
  background: var(--surface);
}

/* ---------- Typing effect ---------- */
.typed.typing::after {
  content: "";
  display: inline-block;
  width: 1px;
  height: 0.95em;
  margin-left: 2px;
  vertical-align: -0.1em;
  background: var(--muted);
  animation: caret 1s steps(1) infinite;
}

@keyframes caret {
  50% {
    opacity: 0;
  }
}

/* ---------- Project filter ---------- */
.filter-bar {
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.filter-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 5px 14px;
  border-radius: 6px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.filter-btn:hover {
  color: var(--heading);
  border-color: var(--border-strong);
}

.filter-btn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.filter-status {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 0 0 20px 0;
}

/* ---------- Copy email button ---------- */
.copy-btn {
  margin-left: auto;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 6px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
}

.copy-btn:hover {
  color: var(--heading);
  border-color: var(--border-strong);
}

.copy-btn.copied {
  color: var(--heading);
  border-color: var(--border-strong);
}

/* ---------- Scroll reveal ---------- */
.reveal {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.35s ease-out, transform 0.35s ease-out;
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* ---------- Back to top ---------- */
.back-to-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  box-shadow: var(--shadow);
  font-size: 1rem;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease, color 0.15s ease, border-color 0.15s ease;
}

.back-to-top.show {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

.back-to-top:hover {
  color: var(--heading);
  border-color: var(--border-strong);
}

@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }

  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* ---------- 404 page ---------- */
.terminal-line {
  font-family: var(--mono);
  font-size: 0.9rem;
  margin: 0 0 6px 0;
  color: var(--text);
}

.terminal-line .prompt {
  color: var(--muted);
}

.terminal-out {
  color: var(--muted);
  margin-bottom: 18px;
}
