:root {
  --bg: #f2f2f2;
  --fg: #1a1a1a;
  --muted: #5c5c5c;
  --card: #ffffff;
  --line: #0a0a0a;
  --accent: #1a1a1a;
  --wave: rgba(26, 26, 26, .16);
}

/* Night: black with white text */
:root[data-theme="night"] {
  --bg: #0a0a0a;
  --fg: #f5f5f5;
  --muted: #a3a3a3;
  --card: #141414;
  --line: #f5f5f5;
  --accent: #f5f5f5;
  --wave: rgba(245, 245, 245, .14);
}
.name, h1, h2, h3, .serif, .closing__email { color: var(--accent); }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 17px/1.65 Inter, system-ui, sans-serif;
  overflow-x: hidden;
}
h1, h2, h3, .logo { font-family: "Space Grotesk", sans-serif; }
a { color: inherit; }
::selection { background: var(--accent); color: var(--bg); }

/* Wavy line field behind the name in the opening */
.waves {
  position: absolute; inset: 0; width: 100%; height: 100%;
  /* Fade out toward the bottom so the opening flows into the page */
  mask-image: linear-gradient(to bottom, #000 60%, transparent);
  -webkit-mask-image: linear-gradient(to bottom, #000 60%, transparent);
}
.waves path { fill: none; stroke: var(--wave); stroke-width: 1; }

/* Nav */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px clamp(16px, 5vw, 64px);
  padding-bottom: 34px;
  background: linear-gradient(to bottom, color-mix(in srgb, var(--bg) 85%, transparent) 40%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  mask-image: linear-gradient(to bottom, #000 55%, transparent);
  -webkit-mask-image: linear-gradient(to bottom, #000 55%, transparent);
}
/* Name stacked small on the left; a tight group of quiet links on the right */
.logo { font: 500 1.05rem/1.05 Inter, system-ui, sans-serif; letter-spacing: -.01em; text-decoration: none; color: var(--fg); }
.nav nav { display: flex; gap: 22px; font-size: .95rem; }
.nav nav a { text-decoration: none; font-weight: 400; color: var(--muted); transition: color .2s; }
.nav nav a:hover { color: var(--fg); }

/* Opening: a hero area with the wavy lines behind the intro sentence */
.intro { position: relative; }
.intro__stage {
  position: relative; min-height: 78vh; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}

/* The opening line: one modest sentence, left-aligned, the same style as the other headings */
.intro__content {
  position: relative; width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 clamp(16px, 5vw, 64px);
  align-self: flex-end; padding-bottom: 4vh;   /* sit low in the hero so the page follows closely */
}
.name {
  font: 600 clamp(2rem, 4.8vw, 3.8rem)/1.08 Inter, system-ui, sans-serif; letter-spacing: -.035em;
  margin: 0; max-width: 20ch; transform-origin: 0 50%;
}
.name .at { font-size: 1.3em; line-height: .8; white-space: nowrap; }

.serif { font-family: "Cormorant Garamond", Georgia, serif; font-style: italic; font-weight: 500; letter-spacing: 0; }

.intro__outro { margin-top: .4em; }



/* A faint glow behind the opening line at night */
.intro__stage::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 55% 45% at 30% 47%, rgba(255, 255, 255, .05), transparent 70%);
}
:root[data-theme="day"] .intro__stage::before { background: none; }

.btn {
  display: inline-block; padding: 14px 26px; border-radius: 999px;
  font-weight: 600; text-decoration: none; border: 2px solid var(--fg);
  transition: transform .15s, background .15s, color .15s;
}
.btn:hover { transform: translateY(-2px); }
.btn.primary { background: var(--fg); color: var(--bg); }
.btn.primary:hover { background: transparent; color: var(--fg); }
.btn.ghost:hover { background: var(--fg); color: var(--bg); }
.btn.big { font-size: clamp(1rem, 3vw, 1.35rem); padding: 18px 34px; }

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

/* Sections */
.section { scroll-margin-top: 70px; max-width: 1200px; margin: 0 auto; padding: clamp(28px, 4vw, 44px) clamp(16px, 5vw, 64px); }
h2 { font-size: clamp(2rem, 5vw, 3.2rem); margin: 0 0 .7em; display: flex; align-items: baseline; gap: .5em; }
.num { font-size: .45em; color: var(--muted); }

/* About as an editorial statement */
.statement { font-family: Inter, system-ui, sans-serif; }
.statement__title {
  display: block; font: 600 clamp(2rem, 4.8vw, 3.8rem)/1.08 Inter, system-ui, sans-serif;
  letter-spacing: -.035em; margin: 0; max-width: 20ch;
}
.statement__title .at { font-size: 1.3em; line-height: .8; white-space: nowrap; }
.statement__grid {
  display: grid; grid-template-columns: 1.15fr 1fr; gap: clamp(28px, 6vw, 96px);
  align-items: start; margin-top: 0;
}
.statement__body { margin: 0; font-size: clamp(1.1rem, 1.9vw, 1.4rem); line-height: 1.45; text-align: justify; hyphens: auto; }
.statement__note { margin: 0; font-size: clamp(1.8rem, 3.6vw, 2.8rem); line-height: 1.02; }
.xp__more { display: inline-block; margin-top: .45em; font-size: .9rem; color: var(--fg); text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--fg) 35%, transparent); }
.xp__more:hover { text-decoration-color: currentColor; }

/* Skip bar, after Matthew's: a thin rule, a pill, then the sections as links */
.skipbar {
  margin: clamp(28px, 4vw, 44px) 0 0; padding-top: 18px; color: var(--muted); font-size: 1.05rem; line-height: 2.2;
  border-top: 1px solid color-mix(in srgb, var(--fg) 14%, transparent);
}
.skipbar__pill {
  display: inline-block; margin-right: .6em; padding: 4px 14px; border-radius: 10px; line-height: 1.5;
  background: var(--fg); color: var(--bg);
}
.skipbar a { color: var(--fg); text-underline-offset: 4px; text-decoration-thickness: 1.5px; white-space: nowrap; }
.skipbar a:hover { color: var(--muted); }
.statement__links { margin: .9em 0 0; color: var(--muted); font-size: .95rem; line-height: 1.8; }
.statement__links a { color: var(--fg); text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--fg) 35%, transparent); }
.tags__label { margin: 0 0 .6em; color: var(--muted); font-size: .9rem; }
.tags + .tags__label { margin-top: 1.4em; }
#skills { scroll-margin-top: 90px; }
.statement__programs { margin: 1.1em 0 0; font-size: 1rem; line-height: 1.6; color: var(--muted); max-width: 60ch; }
.statement__programs a { color: var(--fg); text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--fg) 35%, transparent); }
.statement__programs a:hover { color: var(--accent); }
.statement__tags { margin-top: clamp(40px, 6vw, 64px); }
.tags { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.tags li { padding: 8px 16px; border-radius: 999px; font-weight: 600; font-size: .95rem; border: 2px solid var(--fg); }
.tags li:nth-child(odd) { background: var(--fg); color: var(--bg); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 24px; }
.card {
  background: var(--card); border: 2px solid var(--line); border-radius: 20px;
  padding: 28px; transition: transform .2s, box-shadow .2s;
}
.card:hover { transform: translate(-4px, -4px); box-shadow: 8px 8px 0 var(--fg); }
.card h3 { font-size: 1.5rem; margin: 0 0 .4em; }
.card p { color: var(--muted); margin: 0 0 1.2em; }
/* Experience and competitions: date on the left, role @ organisation, one line of detail */
.xp { list-style: none; margin: 0; padding: 0; }
.xp li {
  display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 24px; padding: 22px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--fg) 12%, transparent);
}
.xp li:first-child { border-top: 1px solid color-mix(in srgb, var(--fg) 12%, transparent); }
.xp__date { color: var(--muted); font-size: .95rem; padding-top: .5em; font-variant-numeric: tabular-nums; }
.xp__head { margin: 0; line-height: 1.3; }
.xp__role { font-size: 1.65rem; color: var(--fg); }
.xp__at { color: var(--muted); margin: 0 .15em; }
.xp__org { font-weight: 500; font-size: 1.05rem; }
.xp__tag {
  display: inline-block; margin-left: .5em; padding: 1px 9px; border: 1px solid var(--muted); border-radius: 999px;
  font-size: .72rem; color: var(--muted); vertical-align: 3px;
}
.xp__desc { margin: .35em 0 0; color: var(--muted); font-size: .98rem; line-height: 1.55; max-width: 70ch; }
@media (max-width: 720px) {
  .xp li { grid-template-columns: 1fr; gap: 4px; }
  .xp__date { padding-top: 0; }
}

/* A quiet note on each project's impact */
.card__impact {
  margin: 0 0 1.2em; padding-top: .8em; font-size: .9rem; color: var(--muted);
  border-top: 1px solid color-mix(in srgb, var(--fg) 12%, transparent);
}
.card__impact span { font: italic 500 1.05rem "Cormorant Garamond", Georgia, serif; color: var(--accent); margin-right: .35em; }
.card a { font-weight: 600; text-decoration: none; border-bottom: 2px solid var(--accent); }

/* Silicon Hills Project photos: one compact row, same height, poster narrower */
.card .gallery { margin-top: 1.4em; }
.gallery { display: grid; grid-template-columns: minmax(0, .75fr) minmax(0, 1.2fr) minmax(0, 1.2fr); gap: 16px; }
.gallery__item { margin: 0; }
.gallery__item img {
  display: block; width: 100%; height: clamp(200px, 21vw, 290px); object-fit: cover; border-radius: 14px;
  filter: grayscale(1); transition: filter .6s ease;
}
.gallery__item--tall img { object-position: 50% 30%; }
.gallery__item:hover img { filter: grayscale(0); }
@media (hover: none) { .gallery__item img { filter: none; } }
.gallery__item figcaption { margin-top: 8px; font-size: 1.2rem; color: var(--muted); }


/* Custom cursor: a white circle with "difference" blending shows as the inverse of what's beneath */
html.has-cursor, html.has-cursor * { cursor: none; }
.cursor {
  position: fixed; top: 0; left: 0; z-index: 100;
  width: 28px; height: 28px; margin: -14px 0 0 -14px;
  border-radius: 50%; background: #fff; mix-blend-mode: difference;
  pointer-events: none; opacity: 0;
  transition: width .2s, height .2s, margin .2s, opacity .2s;
}
.cursor.on { opacity: 1; }
.cursor.big { width: 64px; height: 64px; margin: -32px 0 0 -32px; }

/* Closing: the email as the last big line of the page, with a small ASCII oak beside it */
.closing {
  scroll-margin-top: 40px; max-width: 1400px; margin: 0 auto;
  padding: clamp(80px, 12vw, 160px) clamp(16px, 4vw, 48px) 40px;
  border-top: 1px solid color-mix(in srgb, var(--fg) 12%, transparent);
}
.closing__row { display: flex; align-items: center; justify-content: space-between; gap: 32px; flex-wrap: wrap; }
.closing__email {
  font: 500 clamp(1.7rem, 8vw, 6.2rem)/1 Inter, system-ui, sans-serif; letter-spacing: -.04em;
  text-decoration: none; overflow-wrap: anywhere;
}
.closing__email:hover { text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 8px; }
.closing__tree { margin: 0; font: 400 clamp(.6rem, 1vw, .8rem)/1.05 "Space Mono", monospace; color: var(--muted); opacity: .8; }
@media (max-width: 520px) { .closing__tree { font-size: 2.2vw; } }
.closing__meta { margin: clamp(40px, 6vw, 72px) 0 0; font-size: .9rem; color: var(--muted); }
.closing__meta a { color: inherit; }

/* Day/night switch in the nav */
.theme-toggle {
  display: inline-grid; place-items: center; width: 28px; height: 28px; margin-left: 14px;
  border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0; transition: color .2s;
}
.theme-toggle:hover { color: var(--fg); }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="night"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="night"] .theme-toggle .icon-moon { display: none; }
.nav nav { align-items: center; }
.nav__sep { color: var(--muted); opacity: .45; font-weight: 300; }
.logo { white-space: nowrap; }
@media (max-width: 720px) {
  /* Name on its own line; links and the toggle in a row beneath */
  .nav { padding-left: 16px; padding-right: 16px; flex-wrap: wrap; row-gap: 6px; }
  .nav nav { width: 100%; justify-content: flex-end; gap: 14px; font-size: .85rem; }
  .nav__sep { display: none; }
  .theme-toggle { margin-left: 2px; }
}

@media (max-width: 720px) {
  .statement__grid { grid-template-columns: 1fr; }
  .gallery { grid-template-columns: 1fr; }
  .gallery__item img { height: auto; aspect-ratio: 3 / 2; }
  .gallery__item--tall img { aspect-ratio: 1 / 1; }
  .statement__note { text-align: left; }
  .btn.big { word-break: break-all; }
}

/* Splash: shown only when JS runs; JS fades it, and it fades itself after 3.5s as a fallback */
.splash { display: none; }
.js .splash {
  position: fixed; inset: 0; z-index: 9000; display: flex; align-items: center; justify-content: center;
  background: var(--bg); transition: opacity .5s ease-out;
  animation: splashOut .5s ease-out 3.5s forwards;
}
.splash span { font: 500 clamp(3rem, 8vw, 4.4rem)/1 "Noto Serif SC", "Songti SC", "STSong", serif; letter-spacing: .08em; animation: splashPulse 1.6s ease-in-out infinite; }
.splash.gone { opacity: 0; pointer-events: none; }
@keyframes splashPulse { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }
@keyframes splashOut { to { opacity: 0; visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .splash span { animation: none; } }
#about { padding-top: clamp(16px, 2.5vw, 28px); }
