:root {
  color-scheme: light dark;

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-serif: Georgia, "Times New Roman", serif;

  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-3: clamp(2rem, 1.4rem + 3vw, 2.75rem);

  --space-2xs: 0.25rem;
  --space-xs: 0.5rem;
  --space-s: 0.75rem;
  --space-m: 1rem;
  --space-l: 1.5rem;

  --color-bg: #fff;
  --color-text: #1a1a1a;
  --color-muted: #666;
  --color-accent: #0b5cff;
  --color-rule: #e2e2e2;

  --tile-gap: 0.5rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #111;
    --color-text: #ececec;
    --color-muted: #a0a0a0;
    --color-accent: #7da3ff;
    --color-rule: #2c2c2c;
  }
}

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

body {
  margin: 0;
  padding: var(--space-xs) 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 {
  font-weight: 300;
  line-height: 1.15;
}

h1 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: var(--step-3);
  margin: 0 0 var(--space-s);
}

h2 {
  font-size: var(--step-1);
  margin: 0 0 var(--space-xs);
}

a {
  color: inherit;
  text-decoration: none;
}

/* Links inside running text get a visible affordance. */
.bio a,
.cv dt a,
.cv dd a,
address a {
  text-decoration: underline;
  text-underline-offset: 0.15em;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--color-rule);
  transition: text-decoration-color 0.15s ease;
}

.bio a:hover,
.cv dt a:hover,
.cv dd a:hover,
address a:hover {
  text-decoration-color: currentColor;
}

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

.skip-link {
  position: absolute;
  left: var(--space-xs);
  top: -3rem;
  z-index: 10;
  padding: var(--space-2xs) var(--space-s);
  background: var(--color-text);
  color: var(--color-bg);
  border-radius: 0 0 4px 4px;
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 0;
}

.layout {
  display: grid;
  grid-template-columns: 1fr;
}

@media (min-width: 850px) {
  .layout {
    grid-template-columns: minmax(19rem, 1fr) 2fr;
    align-items: start;
  }
}

.cv {
  display: flex;
  flex-direction: column;
  gap: var(--space-l);
  min-height: 100vh;
  padding: var(--space-xs) var(--space-m) 0;
}

@media (min-width: 850px) {
  .cv {
    position: sticky;
    top: var(--space-xs);
    max-height: 100vh;
    overflow-y: auto;
  }
}

.cv header,
.cv section {
  margin: 0;
}

.cv footer {
  margin-top: auto;
  padding-block: var(--space-m);
}

.bio {
  margin: 0;
  max-width: 44ch;
  color: var(--color-muted);
}

dl {
  margin: 0;
}

dt {
  color: var(--color-text);
}

dt a {
  font-weight: 600;
}

dd {
  margin: 0 0 var(--space-m);
  color: var(--color-muted);
}

dd:last-child {
  margin-bottom: 0;
}

address {
  font-style: normal;
}

.emailicon {
  font-size: 1.6em;
  vertical-align: -0.15em;
}

/* Works — CSS multi-column masonry, no layout JS. */
.works {
  min-height: 100%;
  padding: var(--tile-gap);
}

.grid {
  columns: 1;
  column-gap: 0;
}

@media (min-width: 560px) {
  .grid { columns: 2; }
}

@media (min-width: 1100px) {
  .grid { columns: 3; }
}

.grid-item {
  break-inside: avoid;
  margin: 0;
  padding: var(--tile-gap);
}

.grid-item img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 2px;
  transition: opacity 0.15s ease;
}

.grid-item .work,
.grid-item .tile-link {
  display: block;
}

.grid-item:hover img {
  opacity: 0.85;
}

.grid .hidden {
  display: none;
}

/* External project tile (e.g. play with me). */
.grid-item--link .tile-link {
  position: relative;
}

.tile-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: var(--space-2xs) var(--space-xs);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 0.85rem;
  border-radius: 0 0 2px 2px;
  opacity: 0.9;
}

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