/* ---------- design tokens ----------
   Light-first defaults, dark applied via prefers-color-scheme
   (so the page follows system by default) and explicit overrides
   via [data-theme] from the toggle. */

:root {
  --bg: #faf9f5;
  --bg-card: #ffffff;
  --fg: #14141a;
  --fg-dim: #404048;
  --muted: #8c8c86;
  --rule: #e7e7e0;
  --rule-soft: #efefe8;
  --shadow-hover: 0 10px 28px -16px rgba(20, 20, 30, 0.22);
  --current: #1f7a3d;
  --r: 12px;
  --content: 56rem;
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --t: 160ms;
  --t-med: 240ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0d10;
    --bg-card: #15151a;
    --fg: #ecebe8;
    --fg-dim: #b6b6b1;
    --muted: #76767f;
    --rule: #25252e;
    --rule-soft: #1c1c24;
    --shadow-hover: 0 12px 30px -14px rgba(0, 0, 0, 0.55);
    --current: #2ea043;
  }
  .logo.dark-invert img {
    filter: invert(1) hue-rotate(180deg) brightness(0.96);
  }
}

[data-theme="light"] {
  --bg: #faf9f5;
  --bg-card: #ffffff;
  --fg: #14141a;
  --fg-dim: #404048;
  --muted: #8c8c86;
  --rule: #e7e7e0;
  --rule-soft: #efefe8;
  --shadow-hover: 0 10px 28px -16px rgba(20, 20, 30, 0.22);
  --current: #1f7a3d;
}
[data-theme="light"] .logo.dark-invert img { filter: none; }

[data-theme="dark"] {
  --bg: #0d0d10;
  --bg-card: #15151a;
  --fg: #ecebe8;
  --fg-dim: #b6b6b1;
  --muted: #76767f;
  --rule: #25252e;
  --rule-soft: #1c1c24;
  --shadow-hover: 0 12px 30px -14px rgba(0, 0, 0, 0.55);
  --current: #2ea043;
}
[data-theme="dark"] .logo.dark-invert img {
  filter: invert(1) hue-rotate(180deg) brightness(0.96);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }

body.resume {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background var(--t-med) var(--ease), color var(--t-med) var(--ease);
  isolation: isolate;
}

/* Subtle grid behind everything. Lines are faint by default;
   the radial mask fades the grid toward the bottom so it does not
   pull attention away from content. */
body.resume::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(to right, var(--rule) 1px, transparent 1px),
    linear-gradient(to bottom, var(--rule) 1px, transparent 1px);
  background-size: 56px 56px;
  background-position: center top;
  opacity: 0.45;
  -webkit-mask-image: radial-gradient(ellipse 90% 65% at 50% 0%, #000 30%, transparent 78%);
  mask-image: radial-gradient(ellipse 90% 65% at 50% 0%, #000 30%, transparent 78%);
}

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

a { color: inherit; text-decoration: none; }
a:hover { color: var(--fg); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem clamp(1rem, 4vw, 2rem);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--t) var(--ease);
}
.topbar.scrolled { border-bottom-color: var(--rule); }
.topbar .brand {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  color: var(--fg-dim);
}
.topbar .brand:hover { color: var(--fg); text-decoration: none; }
.topbar nav {
  margin-left: auto;
  display: flex;
  gap: 1.25rem;
  font-size: 0.875rem;
  color: var(--fg-dim);
}
.topbar nav a:hover { color: var(--fg); text-decoration: none; }
@media (max-width: 640px) {
  .topbar nav { gap: 0.85rem; font-size: 0.82rem; }
  .topbar nav a:nth-child(3), .topbar nav a:nth-child(4) { display: none; }
}

.theme-toggle {
  appearance: none;
  background: transparent;
  color: var(--fg-dim);
  border: 1px solid var(--rule);
  border-radius: 999px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color var(--t) var(--ease), border-color var(--t) var(--ease);
}
.theme-toggle:hover { color: var(--fg); border-color: var(--fg-dim); }
/* sun/moon toggle: follow system + respond to explicit override */
.theme-toggle .ic-sun { display: none; }
.theme-toggle .ic-moon { display: inline-block; }
@media (prefers-color-scheme: light) {
  .theme-toggle .ic-sun { display: inline-block; }
  .theme-toggle .ic-moon { display: none; }
}
[data-theme="light"] .theme-toggle .ic-sun { display: inline-block; }
[data-theme="light"] .theme-toggle .ic-moon { display: none; }
[data-theme="dark"] .theme-toggle .ic-sun { display: none; }
[data-theme="dark"] .theme-toggle .ic-moon { display: inline-block; }

/* ---------- layout ---------- */
main {
  max-width: var(--content);
  margin: 0 auto;
  padding: 0 clamp(1rem, 4vw, 2rem) 5rem;
}

.section { padding: 4.5rem 0 1rem; }
.section h2 {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg);
  margin: 0 0 1.6rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
}
.section h2::before {
  content: "#";
  font-family: var(--font-mono);
  font-weight: 400;
  color: var(--muted);
}
.section .sub {
  margin: -1rem 0 1.5rem;
  color: var(--muted);
  font-size: 0.92rem;
}

/* ---------- hero ---------- */
.hero {
  padding: 5rem 0 2.5rem;
}
.hero h1 {
  font-size: clamp(2.2rem, 5.5vw, 3rem);
  line-height: 1.06;
  letter-spacing: -0.02em;
  margin: 0 0 1.25rem;
  font-weight: 600;
}
.hero .lede {
  font-size: 1.05rem;
  color: var(--fg-dim);
  max-width: 44rem;
  margin: 0 0 1.5rem;
}

.contact-pills {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  font-size: 0.92rem;
  color: var(--fg-dim);
}
.contact-pills li, .contact-pills a {
  display: inline-flex; align-items: center; gap: 0.4rem;
}
.contact-pills a:hover { color: var(--fg); text-decoration: none; }
.contact-pills .ci {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

.cta-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.btn {
  display: inline-flex;
  align-items: center;
  padding: 0.55rem 0.95rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  font-size: 0.92rem;
  color: var(--fg);
  background: var(--bg-card);
  transition: border-color var(--t) var(--ease), color var(--t) var(--ease), transform 200ms var(--ease);
}
.btn:hover {
  border-color: var(--fg-dim);
  color: var(--fg);
  text-decoration: none;
  transform: translateY(-1px);
}
.btn.ghost { background: transparent; color: var(--fg-dim); }
.btn.ghost:hover { color: var(--fg); }

/* ---------- timeline ---------- */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 10px;
  bottom: 12px;
  width: 1px;
  background: var(--rule);
}

.entry {
  position: relative;
  padding: 0 0 2.25rem 2.5rem;
}
.entry:last-child { padding-bottom: 0; }

.entry .marker {
  position: absolute;
  left: 0;
  top: 1.5rem;
}
.entry .marker .dot {
  display: block;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--c, var(--muted));
  box-shadow: 0 0 0 3px var(--bg);
  position: relative;
}
.entry.current .marker .dot::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 1.5px solid var(--c, var(--muted));
  animation: ring 2.4s ease-out infinite;
}
@keyframes ring {
  0%   { transform: scale(1);   opacity: 0.7; }
  100% { transform: scale(1.9); opacity: 0;   }
}

.card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  overflow: hidden;
  transition:
    transform 220ms var(--ease),
    border-color var(--t) var(--ease),
    box-shadow var(--t) var(--ease);
}
.card:hover {
  transform: translateY(-2px);
  border-color: var(--fg-dim);
  box-shadow: var(--shadow-hover);
}

.logo {
  display: inline-flex;
  align-items: center;
  margin: 1.2rem 1.5rem 0.2rem;
  height: 28px;
}
.logo.logo-big    { height: 36px; }
.logo.logo-square { height: 42px; }
.logo img { display: block; height: 28px; width: auto; max-width: 200px; }
.logo.logo-big img    { height: 36px; max-width: 220px; }
.logo.logo-square img { height: 42px; }

.card-head {
  padding: 0.85rem 1.5rem 0.45rem;
}
.card-head .date {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.03em;
}
.card-head .badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.05rem 0.55rem;
  background: color-mix(in srgb, var(--current) 16%, transparent);
  color: var(--current);
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.card-head h3 {
  font-size: 1.1rem;
  margin: 0.35rem 0 0.15rem;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.card-head .org { margin: 0; color: var(--fg-dim); font-size: 0.94rem; }
.card-head .org strong { color: var(--fg); font-weight: 600; }
.card-head .loc {
  color: var(--muted);
  font-size: 0.85rem;
  margin-left: 0.5rem;
}

.card-body { padding: 0.4rem 1.5rem 1.4rem; }
.card-body p { color: var(--fg-dim); margin: 0 0 0.7rem; }
.card-body ul { padding-left: 1.1rem; margin: 0 0 0.85rem; }
.card-body li { margin: 0.3rem 0; color: var(--fg-dim); }
.card-body a { color: var(--fg-dim); border-bottom: 1px solid var(--rule); }
.card-body a:hover { color: var(--fg); border-bottom-color: var(--fg-dim); text-decoration: none; }

.stack {
  display: flex; flex-wrap: wrap; gap: 0.3rem;
  margin-top: 0.6rem;
}
.stack span {
  display: inline-block;
  padding: 0.18rem 0.6rem;
  border-radius: 4px;
  background: var(--rule-soft);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

/* ---------- skills ---------- */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}
.skill-group {
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 1.1rem 1.25rem;
  background: var(--bg-card);
  transition: border-color var(--t) var(--ease), transform 220ms var(--ease), box-shadow var(--t) var(--ease);
}
.skill-group:hover {
  border-color: var(--fg-dim);
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}
.skill-group h4 {
  margin: 0 0 0.7rem;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.skill-group ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.skill-group li {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.92rem;
  color: var(--fg-dim);
}
.skill-group img { display: block; }
.ic-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--muted);
  display: inline-block;
  margin-left: 6px;
  margin-right: 7px;
}

/* ---------- projects ---------- */
.projects {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.9rem;
}
.project {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 1.2rem 1.3rem;
  border: 1px solid var(--rule);
  border-radius: var(--r);
  background: var(--bg-card);
  color: inherit;
  transition: border-color var(--t) var(--ease), transform 220ms var(--ease), box-shadow var(--t) var(--ease);
}
.project:hover {
  border-color: var(--fg-dim);
  color: inherit;
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}
.project header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.project h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font-mono);
}
.proj-tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.project p { margin: 0; color: var(--fg-dim); font-size: 0.92rem; }
.project footer {
  margin-top: auto;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--muted);
}
.project footer span {
  display: inline-flex; align-items: center; gap: 0.4rem;
}

/* ---------- contact ---------- */
.contact-pills.wide {
  flex-direction: column;
  gap: 0;
  font-size: 0.98rem;
}
.contact-pills.wide li {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--rule-soft);
  width: 100%;
  transition: padding-left var(--t) var(--ease);
}
.contact-pills.wide li:hover { padding-left: 0.3rem; }
.contact-pills.wide li:last-child { border-bottom: 0; }
.contact-pills.wide a { color: var(--fg); }
.contact-pills.wide a:hover { color: var(--fg-dim); text-decoration: none; }
.contact-pills.wide .hint {
  margin-left: auto;
  padding-left: 1rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 400;
}

.footnote {
  margin: 1.75rem 0 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
}
.footnote a { color: var(--fg-dim); }
.footnote a:hover { color: var(--fg); text-decoration: none; }
.footnote.made-with {
  margin-top: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  text-align: center;
  opacity: 0.55;
}
.footnote.made-with .ic-heart,
.footnote.made-with .ic-claude {
  display: inline-block;
  vertical-align: middle;
}

/* ---------- reveal ---------- */
.reveal {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 520ms var(--ease), transform 520ms var(--ease);
}
.reveal.in { opacity: 1; transform: none; }

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  .hero { padding-top: 3.5rem; }
  .section { padding: 3.5rem 0 0.5rem; }
  .entry { padding-left: 2.2rem; padding-bottom: 1.75rem; }
  .logo img { max-height: 30px; }
  .logo { margin: 1rem 1.2rem 0.15rem; }
  .card-head, .card-body { padding-left: 1.2rem; padding-right: 1.2rem; }
}
