@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;1,100;1,200;1,300;1,400;1,500;1,600;1,700&family=Roboto+Mono:ital,wght@0,100..700;1,100..700&display=swap');

:root {
  color-scheme: light;
  --paper: #f8f7f4;
  --surface: #fdfcf9;
  --ink: #292823;
  --muted: #6b675f;
  --accent: #894931;
  --line: #dfdcd4;
  --well: #eeece6;
  --button: #292823;
  --button-text: #fdfcf9;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco,
    Consolas, "Liberation Mono", monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #1b1b19;
  --surface: #242421;
  --ink: #ece9e1;
  --muted: #b1ada2;
  --accent: #d7a183;
  --line: #3c3b35;
  --well: #2b2b27;
  --button: #e6e2d8;
  --button-text: #242421;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 2rem;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 16px;
  line-height: 1.8;
  font-weight: 400;
  font-style: normal;
  font-optical-sizing: auto;
  line-height: 1.65;
}

h1,
h2,
h3 {
  font-weight: 600;
  letter-spacing: -0.02em;
}

.nav,
.eyebrow,
.meta,
.card-label {
  font-weight: 500;
}

::selection {
  background: var(--accent);
  color: var(--paper);
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
}

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

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

button {
  font: inherit;
}

/* ---------- Layout ---------- */
.wrap {
  width: min(800px, calc(100% - 64px));
  margin-inline: auto;
}

.skip {
  position: absolute;
  top: -100px;
  left: 20px;
  padding: 8px 16px;
  background: var(--ink);
  color: var(--paper);
  z-index: 10;
}

.skip:focus {
  top: 12px;
}

/* ---------- Masthead ---------- */
.masthead {
  min-height: 98px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.wordmark {
  text-decoration: none;
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.06em;
}

.wordmark span {
  color: var(--accent);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 28px;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 23px;
  font-size: 14px;
}

nav a {
  text-decoration: none;
  padding-block: 9px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.theme-toggle[hidden] {
  display: none;
}

.theme-toggle:hover {
  border-color: var(--muted);
}

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

.theme-toggle .sun {
  display: none;
}

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

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

/* ---------- Typography base ---------- */
h1,
h2,
h3,
p {
  margin: 0;
}

/* ---------- Hero ---------- */
.hero {
  padding: 52px 0 48px;
}

.hero-identity {
  display: flex;
  align-items: center;
  gap: 30px;
}

.portrait-frame {
  position: relative;
  display: block;
  width: 114px;
  height: 114px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--muted);
  flex-shrink: 0;
}

.portrait {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.eyebrow {
  color: var(--accent);
  font-size: 13px;
  margin-bottom: 8px;
}

h1 {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: clamp(1.5rem, 3.2vw, 2rem);
  line-height: 1.35;
  letter-spacing: -0.06em;
  font-weight: 600;
}

.pronounce-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  padding: 4px;
  margin: 0;
  color: var(--muted);
  cursor: pointer;
  border-radius: 4px;
  line-height: 1;
  transition: color 150ms ease;
}

.pronounce-btn:hover,
.pronounce-btn:focus-visible,
.pronounce-btn.is-playing {
  color: var(--accent);
}

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

.pronounce-btn svg {
  width: 20px;
  height: 20px;
  display: block;
}

.role-line {
  font-size: 15px;
  color: var(--muted);
  margin-top: 8px;
}

.intro {
  max-width: 740px;
  margin-top: 29px;
  font-size: 17px;
  line-height: 1.85;
}

.actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 25px;
  font-size: 14px;
  margin-top: 24px;
}

.social-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.social-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  color: var(--muted);
  border-radius: 5px;
  text-decoration: none;
}

.social-link:hover {
  color: var(--accent);
  background: var(--well);
}

.social-link svg {
  display: block;
  width: 20px;
  height: 20px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 8px 16px;
  border: 1px solid var(--button);
  border-radius: 5px;
  background: var(--button);
  color: var(--button-text);
  text-decoration: none;
}

.button:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--paper);
}

/* ---------- Sections ---------- */
.section {
  border-top: 1px solid var(--line);
  padding: 39px 0 43px;
}

@media (prefers-reduced-motion: no-preference) {
  .js-reveal .hero,
  .js-reveal .section {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 600ms cubic-bezier(0.2, 0.8, 0.2, 1),
                transform 600ms cubic-bezier(0.2, 0.8, 0.2, 1);
  }

  .js-reveal .section {
    transition-delay: 60ms;
  }

  .js-reveal .hero.in-view,
  .js-reveal .section.in-view,
  .js-reveal .section:target {
    opacity: 1;
    transform: translateY(0);
  }
}

.section-head {
  margin-bottom: 25px;
}

.section-head h2 {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.section-icon {
  width: 22px;
  height: 22px;
  color: var(--accent);
  flex-shrink: 0;
  margin-top: 2px;
}

h2 {
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.04em;
}

.number,
.section-note {
  display: none;
}

/* ---------- Projects ---------- */
.project-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.project {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 0;
  color: var(--ink);
  text-decoration: none;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.project:hover,
.project:focus-visible {
  color: var(--ink);
  border-color: var(--accent);
  box-shadow: 0 8px 24px rgb(0 0 0 / 9%);
}

.project:hover h3,
.project:focus-visible h3 {
  color: var(--accent);
}

@keyframes wiggle {
  0% { transform: rotate(0deg); }
  25% { transform: rotate(-7deg) translateX(-2px); }
  50% { transform: rotate(7deg) translateX(2px); }
  75% { transform: rotate(-4deg) translateX(-1px); }
  100% { transform: rotate(0deg); }
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .project:hover,
  .article-card:hover {
    transform: translateY(-4px);
  }

  .project-preview::after,
  .article-preview::after {
    transition: opacity 220ms ease;
  }

  .portrait-frame:hover {
    animation: wiggle 0.4s ease-in-out;
  }

}

.project-preview,
.article-preview {
  position: relative;
  display: block;
  background: var(--well);
  padding: 0;
  overflow: hidden;
}

.project-preview::after,
.article-preview::after {
  content: "";
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  pointer-events: none;
  opacity: 1;
}

[data-theme="dark"] .project-preview::after,
[data-theme="dark"] .article-preview::after {
  background: color-mix(in srgb, var(--accent) 14%, color-mix(in srgb, var(--paper) 20%, transparent));
}

.project:hover .project-preview::after,
.project:focus-visible .project-preview::after,
.article-card:hover .article-preview::after,
.article-card:focus-visible .article-preview::after {
  opacity: 0;
}

.project-preview img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1.82;
  object-fit: cover;
  object-position: center top;
  border-radius: 0;
}

.project-copy {
  padding: 17px 16px 20px;
}

.project h3 {
  font-size: 15px;
}

h3 {
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1.5;
}

h3 a {
  text-decoration: none;
}

.project p {
  color: var(--muted);
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.7;
}

.tags {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 12px;
}

/* ---------- Experience (timeline) ---------- */
.timeline {
  position: relative;
  margin: 0;
  padding-left: 24px;
}

.timeline::before {
  content: "";
  position: absolute;
  top: 9px;
  bottom: 24px;
  left: 3px;
  width: 1px;
  background: var(--line);
}

.job {
  position: relative;
  padding-bottom: 34px;
}

.job:last-child {
  padding-bottom: 0;
}

.job::before {
  content: "";
  position: absolute;
  top: 7px;
  left: -24px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--muted);
  box-sizing: border-box;
}

.job:first-child::before {
  background: var(--accent);
  border-color: var(--accent);
}

.job-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.job h3 {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--ink);
}

.job .date {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.job .role {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  margin-top: 3px;
}

.job .description {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.75;
  margin-top: 8px;
}

.experience-link {
  margin-top: 24px;
  margin-left: 24px;
  font-size: 14px;
}

/* ---------- Writing (Cards) ---------- */
.article-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.article-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 0;
  color: var(--ink);
  text-decoration: none;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.article-card:hover,
.article-card:focus-visible {
  color: var(--ink);
  border-color: var(--accent);
  box-shadow: 0 8px 24px rgb(0 0 0 / 9%);
}

.article-card:hover h3,
.article-card:focus-visible h3 {
  color: var(--accent);
}

.article-preview img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1.9;
  object-fit: cover;
  object-position: center;
  border-radius: 0;
}

.article-copy {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 17px 16px 20px;
}

.article-card h3 {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.5;
  margin: 0;
}

.article-card .meta {
  margin-top: auto;
  padding-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

/* ---------- Research ---------- */
.articles {
  list-style: none;
  margin: 0;
  padding: 0;
}

.articles li {
  padding: 10px 0;
}

.articles li:first-child {
  padding-top: 0;
}

.articles li:last-child {
  border: 0;
  padding-bottom: 0;
}

.articles a {
  display: block;
  font-size: 16px;
  text-decoration: none;
  line-height: 1.65;
}

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

.meta {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 7px;
}

/* ---------- Skills ---------- */
.toolbox {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px 32px;
  margin: 0;
}

.toolbox div {
  margin: 0;
}

dt {
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
}

dd {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

/* ---------- Education ---------- */

.education p {
  margin-bottom: 20px;
}

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

.education span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

/* ---------- Contact ---------- */
.contact .section-head {
  margin-bottom: 16px;
}

.contact h3 {
  font-size: 24px;
}

.contact p {
  color: var(--muted);
  margin-top: 12px;
}

.contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 15px 25px;
  font-size: 14px;
  margin-top: 23px;
}

/* ---------- Footer ---------- */
footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px 24px;
  border-top: 1px solid var(--line);
  padding: 24px 0 36px;
  color: var(--muted);
  font-size: 12px;
}

footer a {
  text-decoration: none;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .project-grid,
  .article-grid,
  .toolbox {
    grid-template-columns: 1fr;
    gap: 22px;
  }

  .wrap {
    width: calc(100% - 40px);
  }

  .masthead {
    min-height: 83px;
    gap: 16px;
    flex-wrap: wrap;
    padding-block: 15px;
  }

  .header-controls {
    gap: 16px;
  }

  nav {
    gap: 16px;
    font-size: 13px;
  }

  .hero {
    padding: 30px 0 35px;
  }

  .hero-identity {
    gap: 20px;
  }

  .portrait-frame {
    width: 80px;
    height: 80px;
  }

  .eyebrow {
    font-size: 12px;
  }

  h1 {
    font-size: 24px;
  }

  .role-line {
    font-size: 13px;
  }

  .intro {
    font-size: 16px;
    margin-top: 24px;
  }

  .actions {
    gap: 17px;
    font-size: 13px;
  }

  .section {
    padding: 31px 0 35px;
  }

  .job-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .project-copy,
  .article-copy {
    padding: 20px;
  }
}

@media (max-width: 440px) {
  nav {
    gap: 12px;
    font-size: 12px;
  }

  .header-controls {
    gap: 12px;
  }

  .theme-toggle {
    width: 38px;
  }

  .hero-identity {
    align-items: flex-start;
    flex-direction: column;
    gap: 18px;
  }

  .portrait-frame {
    width: 88px;
    height: 88px;
  }

  h1 {
    font-size: 25px;
  }
}

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

  .project,
  .article-card,
  .project-preview::after,
  .article-preview::after,
  .pronounce-btn,
  .hero,
  .section {
    transition: none;
    transform: none;
    opacity: 1;
  }
}

@media print {
  :root,
  :root[data-theme="dark"] {
    --paper: white;
    --ink: black;
    --muted: #444;
    --line: #ccc;
    --surface: white;
    --accent: black;
  }

  .wrap {
    width: 100%;
  }

  .header-controls,
  .actions,
  .project-preview,
  .article-preview,
  .skip,
  footer {
    display: none;
  }

  .hero {
    padding: 20px 0;
  }

  .section {
    padding: 20px 0;
  }

  .js-reveal .hero,
  .js-reveal .section {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .project,
  .job,
  .article-card,
  .articles li {
    break-inside: avoid;
  }
}
