/* ─── Local fonts (SIL OFL; licenses in assets/fonts) ───── */
@font-face {
  font-family: 'Lato';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/asset?u=https%3A%2F%2Fkrahets.com%2Fassets%2Ffonts%2Flato-latin-ext-400-b85c84c655.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Lato';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/asset?u=https%3A%2F%2Fkrahets.com%2Fassets%2Ffonts%2Flato-latin-400-d4ae5188a6.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Lato';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(/asset?u=https%3A%2F%2Fkrahets.com%2Fassets%2Ffonts%2Flato-latin-ext-700-78e850d569.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Lato';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(/asset?u=https%3A%2F%2Fkrahets.com%2Fassets%2Ffonts%2Flato-latin-700-7a7ce1a34f.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'LXGW WenKai TC';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/asset?u=https%3A%2F%2Fkrahets.com%2Fassets%2Ffonts%2Flxgw-wenkai-tc-name-400-cd3afc4eb8.woff2) format('woff2');
  unicode-range: U+5b87, U+680b, U+9773;
}

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

/* ─── Theme and layout tokens ───────────────────────────── */
:root {
  --bg:             oklch(98.5% 0    0);    /* neutral white */
  --text-primary:   oklch(17%  0    0);    /* neutral near-black */
  --text-secondary: oklch(42%  0    0);    /* neutral medium gray */
  --text-muted:     oklch(52%  0    0);    /* neutral light gray */
  --accent:         #06c;               /* Apple blue — links */
  --accent-bg:      #e8f1ff;            /* light blue hover fill */
  --accent-border:  #b3d4f5;            /* light blue border */
  --button-hover-bg: #0076df;          /* Apple secondary button hover, both themes */
  --star-icon:      #e3b341;
  --border:         oklch(88%  0    0);    /* neutral divider */
  --media-placeholder: oklch(97% 0 0);    /* light gray while media loads */

  /* Type scale */
  --text-button: 0.8125rem; /* 13px */
  --text-sm:    0.875rem;   /* 14px */
  --text-base:  1rem;       /* 16px — body minimum */
  --text-lg:    1.25rem;   /* 20px */
  --text-name:  clamp(1.5rem, 4vw, 2rem);

  /* Families */
  --font-body:  'Lato', 'Helvetica Neue', Arial, sans-serif;

  --max-width: 760px;
  --radius: 5px;
  --interaction-duration: 0.04s;
}

[data-theme="dark"] {
  --bg:             #1e1e1e;
  --text-primary:   oklch(96%  0     0);    /* near-white */
  --text-secondary: oklch(80%  0     0);    /* medium gray */
  --text-muted:     oklch(68%  0     0);    /* dimmer gray */
  --accent:         #2997ff;            /* Apple dark blue — brighter on dark bg */
  --accent-bg:      #123a66;            /* dark blue hover fill */
  --accent-border:  #1a4a8a;            /* mid blue border */
  --star-icon:      #d4b65e;
  --border:         oklch(36%  0     0);    /* neutral separator */
  --media-placeholder: oklch(24% 0 0);    /* dark gray while media loads */
}

/* ─── Base ───────────────────────────────────────────────── */
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--text-primary);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

a:hover { text-decoration: underline; }

/* ─── Layout ─────────────────────────────────────────────── */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: clamp(40px, 8vw, 72px) clamp(20px, 5vw, 32px) 0;
}

/* ─── About ──────────────────────────────────────────────── */
.about {
  display: flex;
  gap: clamp(28px, 6vw, 52px);
  align-items: flex-start;
  margin-bottom: clamp(52px, 8vw, 80px);
}

.about__photo {
  flex-shrink: 0;
  width: clamp(108px, 20vw, 148px);
  height: clamp(108px, 20vw, 148px);
  border-radius: 50%;
  object-fit: cover;
  object-position: top center;
}

.about__content { flex: 1; min-width: 0; }

.about__name {
  font-size: var(--text-name);
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.15;
  margin-bottom: 0.6em;
  display: flex;
  align-items: baseline;
  gap: 0.5em;
}

.about__name-cn {
  font-family: 'LXGW WenKai TC', serif;
  letter-spacing: 0.05em;
}

.about__bio {
  font-size: var(--text-base);
  color: var(--text-primary);
  max-width: 58ch;
  margin-bottom: 0.6em;
}

/* ─── Contact links ──────────────────────────────────────── */
.contact {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
}

.contact__link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--interaction-duration) ease-out;
}

.contact__link:hover {
  color: var(--accent);
  text-decoration: none;
}

.contact__link svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

/* ─── Section ─────────────────────────────────────────────── */
section { margin-bottom: clamp(44px, 8vw, 68px); }

.section-title {
  font-size: var(--text-lg);
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--text-primary);
  margin-bottom: 1.25rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}

/* ─── Publications ───────────────────────────────────────── */
.pub-list, .book-list { display: flex; flex-direction: column; gap: 2rem; }

.pub, .book {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
}

.pub__thumb, .book__thumb {
  flex-shrink: 0;
  width: 240px;
  height: auto;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  object-fit: cover;
}

.pub__thumb { background-color: var(--media-placeholder); }
.pub__body, .book__body { flex: 1; min-width: 0; }

.badge {
  display: block;
  width: fit-content;
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.badge__accent {
  color: #9d565d;
  font-weight: 400;
  letter-spacing: 0.01em;
}

.pub__title, .book__title {
  font-size: var(--text-base);
  font-weight: 400;
  color: var(--text-primary);
}

.pub__title {
  line-height: 1.45;
  margin-bottom: 0.3rem;
}

.pub__authors {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: 0.6rem;
}

.pub__authors a, .award__desc a { color: inherit; }

.pub__author-mark {
  margin-left: 0.08em;
  font-size: 0.8em;
  line-height: 0;
  vertical-align: super;
}

.pill-links { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.pill {
  font-size: var(--text-button);
  font-weight: 400;
  color: var(--accent);
  text-decoration: none;
  padding: 2px 9px;
  border: 1px solid var(--accent);
  background-color: transparent;
  border-radius: 9999px;
  transition: background-color var(--interaction-duration) ease-out, color var(--interaction-duration) ease-out, border-color var(--interaction-duration) ease-out;
}

.pill:hover,
.pill:focus-visible {
  background-color: var(--button-hover-bg);
  border-color: transparent;
  color: #fff;
  text-decoration: none;
}

.badge-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.gh-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-left: 1px solid var(--accent-border);
  padding-left: 7px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transition: border-color var(--interaction-duration) ease-out;
}

[hidden] { display: none !important; }

.gh-badge__icon {
  width: 1em;
  height: 1em;
  flex-shrink: 0;
  color: var(--star-icon);
  fill: currentColor;
  transition: color var(--interaction-duration) ease-out;
}

.gh-badge__count {
  min-width: 0;
  font-weight: 400;
  text-align: right;
}

.badge-link:hover .gh-badge,
.badge-link:focus-visible .gh-badge {
  border-left-color: rgb(255 255 255 / 40%);
}

.badge-link:hover .gh-badge__icon,
.badge-link:focus-visible .gh-badge__icon {
  color: #fff;
}

.pill:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 9999px;
}

.book__title { margin-bottom: 0.25rem; }

.book__desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  max-width: 54ch;
  margin-bottom: 0.6rem;
}

/* ─── Experience ─────────────────────────────────────────── */
.exp-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.exp-card {
  display: flex;
  gap: 0.875rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.exp-card__icon {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.exp-card__body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.exp-card__role {
  font-size: var(--text-base);
  color: var(--text-primary);
}

.exp-card__mentor,
.exp-card__period {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* ─── Motion ─────────────────────────────────────────────── */
.theme-switching *,
.theme-switching *::before,
.theme-switching *::after {
  transition: none !important;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* ─── Awards ─────────────────────────────────────────────── */
.award {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.5rem 0;
}
.award__left { flex: 1; min-width: 0; }
.award__name { font-size: var(--text-base); color: var(--text-primary); font-weight: 400; margin: 0 0 0.15rem; }
.award__desc { font-size: var(--text-sm); color: var(--text-secondary); margin: 0; }
.award__year { font-size: var(--text-sm); color: var(--text-secondary); white-space: nowrap; flex-shrink: 0; }

/* ─── Footer ─────────────────────────────────────────────── */
.site-footer {
  margin-top: 6rem;
  padding-top: 0.75rem;
  padding-bottom: 1rem;
  border-top: 1px solid var(--border);
  font-size: var(--text-sm);
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-footer a { text-underline-offset: 2px; }

[data-theme="dark"] .pub__thumb,
[data-theme="dark"] .book__thumb,
[data-theme="dark"] .exp-card__icon {
  filter: brightness(0.82);
}

[data-theme="dark"] .badge__accent {
  color: oklch(82% 0.035 12);
}

/* ─── Theme toggle ───────────────────────────────────────── */
.theme-toggle {
  margin-left: auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  transition: background-color var(--interaction-duration) ease-out, color var(--interaction-duration) ease-out, border-color var(--interaction-duration) ease-out;
}

.theme-toggle:hover {
  background-color: var(--accent-bg);
  color: var(--accent);
  border-color: var(--accent-border);
}

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

.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle__sun { display: none; }
[data-theme="dark"] .theme-toggle__moon { display: none; }
[data-theme="dark"] .theme-toggle__sun { display: block; }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 560px) {
  .about {
    flex-direction: column;
    align-items: center;
    gap: 1.0em;
  }

  .about__content { width: 100%; }
  .about__name { justify-content: center; }

  .about__bio { max-width: none; }
  .contact { justify-content: center; }

  .pub, .book { flex-direction: column; }

  .pub__thumb, .book__thumb {
    width: 100%;
    height: auto;
  }

  .exp-grid { grid-template-columns: 1fr; }
}
