@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("assets/fonts/inter-latin-wght-normal.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: "Instrument Serif";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("assets/fonts/instrument-serif-latin-400-normal.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;
}

:root {
  color-scheme: light;
  --bg:          oklch(98.6% 0.003 85);
  --bg-hover:    oklch(96.2% 0.005 85);
  --fg:          oklch(20% 0.008 265);
  --fg-muted:    oklch(48% 0.010 265);
  --fg-faint:    oklch(62% 0.008 265);
  --line:        oklch(90.5% 0.004 265);
  --accent:      oklch(52% 0.170 258);
  --selection:   oklch(52% 0.170 258 / 0.16);

  --step--2: clamp(0.6875rem, 0.672rem + 0.078vw, 0.75rem);
  --step--1: clamp(0.8125rem, 0.797rem + 0.078vw, 0.875rem);
  --step-0:  clamp(1rem,      0.977rem + 0.117vw, 1.0625rem);
  --step-1:  clamp(1.125rem,  1.086rem + 0.195vw, 1.25rem);
  --step-4:  clamp(2.25rem,   1.688rem + 2.813vw, 3.75rem);

  --gutter:  1.5rem;
  --measure: 38rem;
  --section-gap: clamp(4rem, 3rem + 5vw, 6.5rem);

  --radius: 10px;
  --ease:   cubic-bezier(0.2, 0, 0, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:          oklch(16.5% 0.006 265);
  --bg-hover:    oklch(21% 0.008 265);
  --fg:          oklch(94% 0.004 85);
  --fg-muted:    oklch(70% 0.010 265);
  --fg-faint:    oklch(55% 0.010 265);
  --line:        oklch(27% 0.009 265);
  --accent:      oklch(76% 0.130 258);
  --selection:   oklch(76% 0.130 258 / 0.22);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg:          oklch(16.5% 0.006 265);
    --bg-hover:    oklch(21% 0.008 265);
    --fg:          oklch(94% 0.004 85);
    --fg-muted:    oklch(70% 0.010 265);
    --fg-faint:    oklch(55% 0.010 265);
    --line:        oklch(27% 0.009 265);
    --accent:      oklch(76% 0.130 258);
    --selection:   oklch(76% 0.130 258 / 0.22);
  }
}

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

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100svh;
  background: var(--bg);
  color: var(--fg);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
               system-ui, sans-serif;
  font-size: var(--step-0);
  line-height: 1.65;
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv11", "ss01";
}

ul, ol { list-style: none; padding: 0; }

a { color: inherit; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

svg { display: block; }

::selection { background: var(--selection); }

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

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: 0;
  z-index: 10;
  padding: 0.625rem 1rem;
  background: var(--fg);
  color: var(--bg);
  font-size: var(--step--1);
  font-weight: 500;
  border-radius: 0 0 var(--radius) var(--radius);
  transform: translateY(-110%);
  transition: transform 0.2s var(--ease);
}
.skip-link:focus-visible { transform: translateY(0); }

h1, h2, h3 {
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.022em;
  text-wrap: balance;
}

p { text-wrap: pretty; }

.wrap {
  width: min(100% - (var(--gutter) * 2), var(--measure));
  margin-inline: auto;
}

main { padding-block: clamp(3rem, 2rem + 5vw, 5.5rem) 0; }

.section + .section { margin-top: var(--section-gap); }

.header {
  display: flex;
  justify-content: flex-end;
  padding-top: 1.25rem;
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  margin-right: -0.625rem;
  border-radius: 50%;
  color: var(--fg-muted);
  transition: color 0.2s var(--ease), background-color 0.2s var(--ease);
}
.theme-toggle:hover {
  color: var(--fg);
  background: var(--bg-hover);
}
.theme-toggle svg { width: 1.125rem; height: 1.125rem; }

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

/* Instrument Serif ships a single weight. Leave it at 400 and untouched —
   faking weight with a stroke closes up the counters and the name reads as
   though it had been squeezed from the sides. */
.hero__name {
  font-family: "Instrument Serif", ui-serif, Georgia, serif;
  font-size: var(--step-4);
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.05;
}

.hero__bio {
  max-width: 32rem;
  margin-top: 1.5rem;
  font-size: var(--step-1);
  line-height: 1.55;
  color: var(--fg-muted);
}

.hero__bio strong {
  font-weight: 500;
  color: var(--fg);
}

.section__label {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
  font-size: var(--step--2);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-faint);
}
.section__label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.project { border-bottom: 1px solid var(--line); }

.project__link {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  padding: 1.125rem 1rem;
  margin-inline: -1rem;
  border-radius: var(--radius);
  text-decoration: none;
  transition: background-color 0.2s var(--ease);
}
.project__link:hover { background: var(--bg-hover); }

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

.project__icon {
  position: relative;
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  margin-top: 0.1875rem;
  border-radius: 11px;
  overflow: hidden;
  background: var(--bg-hover);
  box-shadow: inset 0 0 0 1px var(--line);
}
.project__icon::before {
  content: attr(data-initial);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 1rem;
  font-weight: 550;
  letter-spacing: 0;
  color: var(--fg-faint);
}
.project__icon img {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* Real logos bring their own shape and colour — the placeholder tile and its
   initial only belong behind projects that have no icon yet. */
.project__icon:has(img) {
  background: none;
  box-shadow: none;
}
.project__icon:has(img)::before { content: none; }

.project__head {
  display: flex;
  align-items: baseline;
  gap: 1rem;
}

.project__name {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-weight: 500;
  letter-spacing: -0.012em;
}

.project__arrow {
  width: 0.75rem;
  height: 0.75rem;
  color: var(--fg-faint);
  transition: transform 0.2s var(--ease), color 0.2s var(--ease);
}
.project__link:hover .project__arrow,
.project__link:focus-visible .project__arrow {
  color: var(--accent);
  transform: translate(2px, -2px);
}

.project__year {
  margin-left: auto;
  flex-shrink: 0;
  font-size: var(--step--1);
  font-variant-numeric: tabular-nums;
  color: var(--fg-faint);
}

.project__desc {
  display: block;
  max-width: 30rem;
  margin-top: 0.25rem;
  font-size: var(--step--1);
  line-height: 1.55;
  color: var(--fg-muted);
}

.project__link:not([href]) { cursor: default; }
.project__link:not([href]):hover { background: none; }

.contact { display: flex; flex-direction: column; align-items: flex-start; }

.contact__link {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  padding-block: 0.6rem;
  text-decoration-line: underline;
  text-decoration-color: var(--line);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.25em;
  transition: text-decoration-color 0.2s var(--ease),
              text-underline-offset 0.2s var(--ease),
              color 0.2s var(--ease);
}
.contact__link:hover {
  color: var(--accent);
  text-decoration-color: currentColor;
  text-underline-offset: 0.35em;
}

.section__note {
  max-width: 30rem;
  margin-top: 1.25rem;
  font-size: var(--step--1);
  line-height: 1.6;
  color: var(--fg-muted);
}

.footer {
  margin-top: var(--section-gap);
  padding-block: 2rem 3rem;
  border-top: 1px solid var(--line);
  font-size: var(--step--1);
  color: var(--fg-faint);
}

.notfound {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 76svh;
}

.notfound__code {
  font-size: var(--step--1);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.14em;
  color: var(--fg-faint);
}

.notfound__title {
  margin-top: 0.75rem;
  font-size: clamp(1.75rem, 1.4rem + 1.75vw, 2.5rem);
}

.notfound__text {
  max-width: 28rem;
  margin-top: 1rem;
  color: var(--fg-muted);
}

.notfound__back {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 2rem;
  padding: 0.7rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: var(--step--1);
  font-weight: 500;
  text-decoration: none;
  transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease);
}
.notfound__back:hover {
  background: var(--bg-hover);
  border-color: var(--fg-faint);
}
.notfound__back svg { width: 0.875rem; height: 0.875rem; }

@view-transition { navigation: auto; }

/* Opening sequence: the page settles into place top to bottom, once, on load.
   Each .intro section starts its own run of the ladder from --t; items inside
   it are offset from there, so a section can move without retiming the rest.
   The section-level .reveal still handles the scroll-in on narrow screens. */
@media (prefers-reduced-motion: no-preference) {
  .hero > *,
  .intro > .section__label,
  .intro .project,
  .intro .contact__link,
  .intro > .section__note,
  .footer > * {
    animation: settle 0.75s var(--ease) backwards;
  }

  .hero__name { animation-delay: 0.05s; }
  .hero__bio  { animation-delay: 0.14s; }

  /* Section starts, in document order: projects, then contact. */
  main > .section:nth-of-type(2) { --t: 0.24s; }
  main > .section:nth-of-type(3) { --t: 0.56s; }

  .intro > .section__label { animation-delay: var(--t); }

  .intro .project:nth-child(1),
  .intro .contact__link:nth-child(1) { animation-delay: calc(var(--t) + 0.07s); }
  .intro .project:nth-child(2),
  .intro .contact__link:nth-child(2) { animation-delay: calc(var(--t) + 0.14s); }
  .intro .project:nth-child(3),
  .intro .contact__link:nth-child(3) { animation-delay: calc(var(--t) + 0.21s); }

  .intro > .section__note { animation-delay: calc(var(--t) + 0.28s); }

  /* 404 runs the same ladder, just a shorter one. */
  .notfound > * { animation: settle 0.75s var(--ease) backwards; }
  .notfound__code  { animation-delay: 0.05s; }
  .notfound__title { animation-delay: 0.12s; }
  .notfound__text  { animation-delay: 0.20s; }
  .notfound__back  { animation-delay: 0.28s; }

  .footer > * { animation-delay: 0.92s; }
  .notfound ~ .footer > * { animation-delay: 0.40s; }

  /* The rule beside each section label draws itself out. */
  .intro > .section__label::after {
    transform-origin: left;
    animation: draw 0.9s var(--ease) calc(var(--t) + 0.1s) backwards;
  }

  /* The toggle only fades — moving it would tug the corner of the page. */
  .theme-toggle { animation: fade 0.6s var(--ease) 0.6s backwards; }
}

@keyframes settle {
  from { opacity: 0; transform: translateY(12px); filter: blur(5px); }
  to   { opacity: 1; transform: none; filter: blur(0); }
}

@keyframes draw {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

@keyframes fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .reveal {
      animation: reveal linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 38%;
    }
  }
}

@keyframes reveal {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

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