/* === Tokens ==============================================================
   Light is the base. Dark is declared twice: once behind prefers-color-scheme
   for visitors who never touch the toggle, once behind [data-theme] so an
   explicit choice beats the operating system in both directions.
   ========================================================================= */
:root {
  --paper:        #FBFAF7;
  --surface:      #FFFFFF;
  --ink:          #17191B;
  --ink-2:        #3D4248;
  --muted:        #6B7076;
  --line:         #E4E2DC;
  --line-strong:  #CFCCC4;
  --accent:       #14504A;
  --accent-hover: #0C3A35;
  --accent-wash:  #F0F4F3;
  --accent-edge:  #DCE6E4;
  --header-bg:    rgba(251, 250, 247, 0.88);

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", "SF Mono", Consolas, Menlo, monospace;

  --radius:       4px;
  --radius-card: 12px;
  --radius-photo: 20px;
  --measure: 44rem;
  --wide:    68rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:        #15171B;
    --surface:      #1C1F25;
    --ink:          #E9EAE6;
    --ink-2:        #BCC1C7;
    --muted:        #8A9099;
    --line:         #282C33;
    --line-strong:  #3B4049;
    --accent:       #6FB3A8;
    --accent-hover: #8BC9BE;
    --accent-wash:  #182824;
    --accent-edge:  #2C4741;
    --header-bg:    rgba(21, 23, 27, 0.88);
  }
}

:root[data-theme="dark"] {
  --paper:        #15171B;
  --surface:      #1C1F25;
  --ink:          #E9EAE6;
  --ink-2:        #BCC1C7;
  --muted:        #8A9099;
  --line:         #282C33;
  --line-strong:  #3B4049;
  --accent:       #6FB3A8;
  --accent-hover: #8BC9BE;
  --accent-wash:  #182824;
  --accent-edge:  #2C4741;
  --header-bg:    rgba(21, 23, 27, 0.88);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: var(--radius); }

img { max-width: 100%; display: block; }

/* === Nav ================================================================= */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

nav {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 0.9rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.nav-name {
  font-weight: 650;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.nav-right { display: flex; align-items: center; gap: 1.5rem; }

nav ul { list-style: none; display: flex; flex-wrap: wrap; gap: 1.5rem; }

nav ul a {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

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

/* === Theme toggle ======================================================== */
.theme-toggle {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.16s ease, color 0.16s ease;
}

.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.theme-toggle svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-toggle .icon-moon { display: block; }
.theme-toggle .icon-sun  { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .icon-sun  { display: block; }
}

:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }

/* === Layout ============================================================== */
main { max-width: var(--wide); margin: 0 auto; padding: 0 2rem; }

section { padding: 4.5rem 0; border-bottom: 1px solid var(--line); }
section:last-of-type { border-bottom: none; }

section > h2 {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 2rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--line);
}

#about > p,
#contact > p { max-width: var(--measure); }

/* === Hero ================================================================ */
#hero { padding: 5rem 0 4rem; }

.hero-inner {
  display: flex;
  align-items: center;
  gap: 3.5rem;
  justify-content: space-between;
}

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

.hero-text h1 {
  font-size: clamp(2.4rem, 5.6vw, 3.9rem);
  line-height: 1.02;
  letter-spacing: -0.035em;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.65rem;
}

.hero-text .title {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.5rem;
}

.hero-text .bio {
  font-size: 1.09rem;
  color: var(--ink-2);
  max-width: 38rem;
  margin-bottom: 1.9rem;
}

.hero-links { display: flex; gap: 0.7rem; flex-wrap: wrap; }

.hero-links a {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.6rem 1.1rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  transition: border-color 0.16s ease, color 0.16s ease;
}

.hero-links a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

.hero-photo { flex: 0 0 auto; }

.hero-photo img {
  width: 190px;
  height: 190px;
  object-fit: cover;
  border-radius: var(--radius-photo);
  border: 1px solid var(--line-strong);
}

/* === About =============================================================== */
#about p { color: var(--ink-2); }

#about .location {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 1.5rem;
}

/* === Principles ========================================================== */
.principles {
  list-style: none;
  display: grid;
  gap: 2rem;
  max-width: 52rem;
}

.principles li + li { border-top: 1px solid var(--line); padding-top: 2rem; }

.principles h3 {
  font-size: 1.16rem;
  font-weight: 620;
  letter-spacing: -0.015em;
  line-height: 1.35;
  color: var(--ink);
  margin-bottom: 0.5rem;
  text-wrap: balance;
}

.principles p { font-size: 0.97rem; color: var(--ink-2); }

/* === Experience ========================================================== */
.job { padding-bottom: 2.25rem; margin-bottom: 2.25rem; border-bottom: 1px solid var(--line); }
.job:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.job-header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-bottom: 0.35rem;
}

.job-header h3 {
  font-size: 1.22rem;
  font-weight: 640;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.job-header .company { font-size: 1.02rem; color: var(--accent); font-weight: 520; }

.job-header .dates {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin-left: auto;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.job-subtitle { font-size: 0.93rem; color: var(--muted); margin-bottom: 0.9rem; }

.bullets { list-style: none; display: grid; gap: 0.6rem; margin-top: 1rem; }

.bullets li {
  position: relative;
  padding-left: 1.3rem;
  color: var(--ink-2);
  font-size: 0.97rem;
  max-width: 58rem;
}

.bullets li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.68em;
  width: 7px;
  height: 1px;
  background: var(--line-strong);
}

/* === Projects ============================================================ */
.project-grid { display: grid; gap: 1.5rem; }

.project-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 1.9rem;
}

.project-featured { border-color: var(--accent-edge); }

.project-impact {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-wash);
  border: 1px solid var(--accent-edge);
  border-radius: var(--radius);
  padding: 0.35rem 0.7rem;
  margin-bottom: 1.1rem;
}

.project-card-header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-bottom: 0.8rem;
}

.project-card-header h3 {
  font-size: 1.22rem;
  font-weight: 640;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.project-card-header h3 a { color: var(--ink); }
.project-card-header h3 a:hover { color: var(--accent); }

.project-category {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-left: auto;
  white-space: nowrap;
}

.project-card > p { color: var(--ink-2); font-size: 0.99rem; max-width: 56rem; }

.project-highlights {
  list-style: none;
  display: grid;
  gap: 0.55rem;
  margin: 1.3rem 0 0;
  padding-top: 1.3rem;
  border-top: 1px solid var(--line);
}

.project-highlights li {
  position: relative;
  padding-left: 1.3rem;
  font-size: 0.92rem;
  color: var(--ink-2);
  max-width: 56rem;
}

.project-highlights li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.68em;
  width: 7px;
  height: 1px;
  background: var(--line-strong);
}

.tags { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 1.4rem; }

.tag {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.3rem 0.6rem;
}

/* === Education & Certifications ========================================== */
.education-entry,
.cert-entry { padding: 1rem 0; border-bottom: 1px solid var(--line); }

.education-entry:last-child,
.cert-entry:last-child { border-bottom: none; }

.education-header,
.cert-header { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.35rem 1rem; }

.education-header h3,
.cert-header h3 {
  font-size: 1.03rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.education-header .school,
.cert-header .cert-issuer { font-size: 0.95rem; color: var(--muted); }

.cert-header .cert-dates {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin-left: auto;
  white-space: nowrap;
}

.cert-expired { opacity: 0.72; }

/* === Skills ============================================================== */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 2.25rem 2.5rem;
}

.skill-group h3 {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
  padding-bottom: 0.6rem;
  margin-bottom: 0.9rem;
  border-bottom: 1px solid var(--line);
}

.skill-group ul { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem; }

.skill-group li {
  font-size: 0.87rem;
  color: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.3rem 0.62rem;
  background: var(--surface);
}

/* === Contact ============================================================= */
#contact p { color: var(--ink-2); }

.contact-links { display: flex; flex-wrap: wrap; gap: 0.7rem; margin-top: 1.4rem; }

.contact-links a {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  padding: 0.6rem 1.1rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  transition: border-color 0.16s ease, color 0.16s ease;
}

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

/* === Footer ============================================================== */
footer { border-top: 1px solid var(--line); margin-top: 1rem; }

footer p {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 2rem;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

/* === Motion ============================================================== */
[data-animate] {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

[data-animate].animate-in { opacity: 1; transform: none; }

/* === Responsive ========================================================== */
@media (max-width: 760px) {
  body { font-size: 16px; }
  main { padding: 0 1.25rem; }
  nav { padding: 0.9rem 1.25rem; flex-wrap: wrap; gap: 0.7rem 1rem; }
  .nav-right { width: 100%; justify-content: space-between; gap: 1rem; }
  nav ul { gap: 1rem; }
  footer p { padding: 1.75rem 1.25rem; }
  .hero-inner { flex-direction: column-reverse; align-items: flex-start; gap: 2rem; }
  .hero-photo img { width: 128px; height: 128px; border-radius: 16px; }
  section { padding: 3rem 0; }
  #hero { padding: 3rem 0; }
  .job-header .dates,
  .project-category,
  .cert-header .cert-dates { margin-left: 0; }
  .project-card { padding: 1.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
  [data-animate] { opacity: 1; transform: none; }
}

/* === Print =============================================================== */
@media print {
  header, .hero-links, .contact-links { display: none; }
  body { background: #fff; color: #000; font-size: 11pt; }
  section { page-break-inside: avoid; }
  [data-animate] { opacity: 1; transform: none; }
}
