/*
 * dumitru.ca: site.css (2026 refresh)
 *
 * Warm paper, ink-blue links, Newsreader for reading and Inter for UI.
 * Mobile-first. Light and dark themes follow the visitor's system setting.
 * The old stylesheets (screen.css, syntax.css) are kept for legacy pages.
 */

/* ------------------------------------------------------------------ */
/* Design tokens                                                        */
/* ------------------------------------------------------------------ */

:root {
  color-scheme: light dark;

  --font-serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Fluid type scale: small phones -> large desktops, no breakpoints needed. */
  --step--1: clamp(0.8125rem, 0.79rem + 0.1vw, 0.875rem);
  --step-0: clamp(1.0625rem, 1.02rem + 0.22vw, 1.1875rem);
  --step-1: clamp(1.1875rem, 1.1rem + 0.45vw, 1.4375rem);
  --step-2: clamp(1.5rem, 1.3rem + 1vw, 2rem);
  --step-3: clamp(2.375rem, 1.75rem + 3.1vw, 3.75rem);
  --leading: 1.62;

  --gutter: clamp(1.25rem, 5vw, 2.5rem);
  --measure: 45rem;
  --label-col: 8.75rem;
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);

  /* Light theme */
  --bg: hsl(40 33% 97%);
  --surface: hsl(40 45% 99%);
  --text: hsl(222 22% 14%);
  --text-muted: hsl(222 9% 38%);
  --text-faint: hsl(222 7% 55%);
  --rule: hsl(34 20% 86%);
  --chip: hsl(222 22% 14% / 0.06);
  --accent: hsl(198 75% 29%);
  --accent-strong: hsl(198 88% 21%);
  --accent-line: hsl(198 60% 32% / 0.32);
  --selection: hsl(198 75% 45% / 0.22);
  --glow: hsl(36 90% 85% / 0.55);
  --noise-opacity: 0.055;
  --photo-shadow:
    0 1px 2px hsl(28 25% 20% / 0.08),
    0 18px 36px -18px hsl(28 35% 18% / 0.45);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: hsl(220 18% 9%);
    --surface: hsl(220 16% 12%);
    --text: hsl(40 22% 90%);
    --text-muted: hsl(220 10% 68%);
    --text-faint: hsl(220 8% 52%);
    --rule: hsl(220 12% 21%);
    --chip: hsl(40 22% 90% / 0.08);
    --accent: hsl(195 72% 71%);
    --accent-strong: hsl(195 90% 82%);
    --accent-line: hsl(195 72% 71% / 0.38);
    --selection: hsl(195 72% 60% / 0.3);
    --glow: hsl(200 65% 38% / 0.16);
    --noise-opacity: 0.04;
    --photo-shadow:
      0 1px 2px hsl(0 0% 0% / 0.5),
      0 22px 44px -20px hsl(0 0% 0% / 0.85);
  }
}

/* ------------------------------------------------------------------ */
/* Base                                                                 */
/* ------------------------------------------------------------------ */

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

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

body {
  position: relative;
  isolation: isolate;
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-serif);
  font-size: var(--step-0);
  font-optical-sizing: auto;
  line-height: var(--leading);
  color: var(--text);
  background:
    radial-gradient(64rem 30rem at 50% -10rem, var(--glow), transparent 70%) no-repeat,
    var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Paper grain: a faint, fixed noise layer that gives the page some tooth. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: var(--noise-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

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

img {
  display: block;
  max-width: 100%;
  height: auto;
}

p {
  margin: 0 0 1em;
  text-wrap: pretty;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

strong,
b {
  font-weight: 600;
}

a {
  color: var(--accent);
  text-decoration-line: underline;
  text-decoration-thickness: max(1px, 0.07em);
  text-decoration-color: var(--accent-line);
  text-underline-offset: 0.2em;
  transition:
    color 0.2s ease,
    text-decoration-color 0.2s ease,
    text-underline-offset 0.2s var(--ease-out);
}

a:hover {
  color: var(--accent-strong);
  text-decoration-color: currentColor;
  text-underline-offset: 0.28em;
}

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

.skip-link {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 10;
  padding: 0.5rem 0.9rem;
  font: 500 var(--step--1) / 1.2 var(--font-sans);
  color: var(--bg);
  background: var(--text);
  border-radius: 0.5rem;
  text-decoration: none;
  transform: translateY(-200%);
  transition: transform 0.2s var(--ease-out);
}

.skip-link:hover {
  color: var(--bg);
}

.skip-link:focus {
  transform: none;
}

/* ------------------------------------------------------------------ */
/* Layout                                                               */
/* ------------------------------------------------------------------ */

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

/* Header + navigation (inner pages) */

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
  padding-top: clamp(1rem, 3.5vw, 2rem);
}

.wordmark {
  font-family: var(--font-serif);
  font-size: var(--step-1);
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}

.wordmark:hover {
  color: var(--accent);
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  margin: 0 -0.65rem;
  padding: 0;
  list-style: none;
}

.site-nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem; /* 44px touch target */
  padding-inline: 0.65rem;
  font-family: var(--font-sans);
  font-size: var(--step--1);
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text-muted);
  text-decoration: none;
}

.site-nav a::after {
  content: "";
  position: absolute;
  inset-inline: 0.65rem;
  bottom: 0.6rem;
  height: 1.5px;
  border-radius: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.3s var(--ease-out);
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--text);
}

.site-nav a:hover::after,
.site-nav a[aria-current="page"]::after {
  transform: scaleX(1);
}

.site-nav a[aria-current="page"]::after {
  background: var(--accent);
}

/* Home page hero */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "name photo"
    "lede lede";
  gap: 1.5rem 1.25rem;
  align-items: center;
  padding-block: clamp(2.5rem, 10vw, 6rem) clamp(2rem, 6vw, 3.5rem);
}

/* Phones: the name sits beside the photo and the lede runs full width below. */
.hero__text {
  display: contents;
}

.hero__name {
  grid-area: name;
  font-size: var(--step-3);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.028em;
}

.hero__lede {
  grid-area: lede;
  margin: 0;
  font-size: var(--step-1);
  line-height: 1.5;
}

.portrait {
  grid-area: photo;
  justify-self: end;
  width: clamp(6rem, 28vw, 8.5rem);
  margin: 0;
}

.portrait img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 1.125rem;
  outline: 1px solid hsl(0 0% 0% / 0.06);
  outline-offset: -1px;
  background: var(--surface);
  box-shadow: var(--photo-shadow);
  rotate: 2deg;
  transition:
    rotate 0.6s var(--ease-out),
    scale 0.6s var(--ease-out);
}

@media (hover: hover) {
  .portrait:hover img {
    rotate: 0deg;
    scale: 1.025;
  }
}

@media (prefers-color-scheme: dark) {
  .portrait img {
    filter: brightness(0.92);
  }
}

@media (min-width: 40rem) {
  .hero {
    grid-template-areas: "text photo";
    column-gap: clamp(1.5rem, 5vw, 3rem);
  }

  .hero__text {
    display: block;
    grid-area: text;
  }

  .hero__lede {
    margin-top: 1.1rem;
  }

  .portrait {
    width: clamp(8.5rem, 30vw, 12.5rem);
  }
}

/* Labelled content blocks: label above on phones, in a side column on wider screens. */

.block {
  display: grid;
  gap: 0.5rem 2rem;
  padding-block: 1.5rem;
  border-top: 1px solid var(--rule);
}

.block__label {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.block__body > :last-child {
  margin-bottom: 0;
}

@media (min-width: 46rem) {
  .block {
    grid-template-columns: var(--label-col) minmax(0, 1fr);
    padding-block: 1.75rem;
  }

  /* Centre the label's first line on the first line of body text, while
     keeping a compact line-height so two-line labels don't drift apart. */
  .block__label {
    padding-top: calc((var(--step-0) * var(--leading) - 1.5em) / 2);
  }
}

/* Lists */

.block ul,
.prose ul {
  margin: 0 0 1em;
  padding-left: 1.15em;
}

.block li,
.prose li {
  margin-block: 0.4em;
  padding-left: 0.2em;
}

.block li::marker,
.prose li::marker {
  color: var(--text-faint);
}

.block .plain-list,
.prose .plain-list {
  padding-left: 0;
  list-style: none;
}

.block .plain-list > li,
.prose .plain-list > li {
  padding-left: 0;
}

.block .plain-list > li + li,
.prose .plain-list > li + li {
  margin-top: 0.65em;
}

.tag {
  display: inline-block;
  margin-left: 0.4em;
  padding: 0.15em 0.45em 0.1em;
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.06em;
  vertical-align: 0.15em;
  color: var(--text-muted);
  background: var(--chip);
  border-radius: 0.3rem;
}

/* Inner page headings and long-form text */

.page-header {
  padding-block: clamp(2.25rem, 8vw, 4.5rem) clamp(1.25rem, 4vw, 2rem);
}

.page-title {
  font-size: clamp(2rem, 1.55rem + 2.2vw, 3rem);
  line-height: 1.05;
  letter-spacing: -0.025em;
}

.page-intro {
  margin: 1rem 0 0;
  font-size: var(--step-1);
  line-height: 1.5;
  color: var(--text-muted);
}

.prose {
  padding-bottom: 1rem;
}

.prose h2 {
  margin: 2.25rem 0 0.75rem;
  font-size: var(--step-2);
}

.epigraph {
  margin: 0 0 2.25rem;
  max-width: 36rem;
}

.epigraph blockquote {
  margin: 0;
}

.epigraph blockquote p {
  margin: 0;
  font-size: var(--step-1);
  font-style: italic;
  line-height: 1.5;
}

.epigraph figcaption {
  margin-top: 0.85rem;
  font-family: var(--font-sans);
  font-size: var(--step--1);
  color: var(--text-muted);
}

/* Publications */

.pubs {
  display: grid;
  gap: 1.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pubs > .pub {
  margin: 0;
  padding: 0;
}

.pub__title {
  display: block;
  font-size: 1.05em;
  font-weight: 500;
  line-height: 1.35;
  color: var(--text);
}

a.pub__title {
  color: var(--accent);
  text-decoration-color: transparent;
}

a.pub__title:hover {
  text-decoration-color: currentColor;
}

.pub__authors,
.pub__venue {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.92em;
  line-height: 1.5;
  color: var(--text-muted);
}

.pub__authors strong {
  color: var(--text);
}

.pub__venue a {
  color: inherit;
  text-decoration-color: var(--rule);
}

.pub__venue a:hover {
  color: var(--text);
  text-decoration-color: currentColor;
}

/* Footer */

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.35rem 1.5rem;
  margin-top: clamp(1.5rem, 5vw, 2.5rem);
  padding-block: 1.5rem clamp(2rem, 7vw, 3.5rem);
  border-top: 1px solid var(--rule);
  font-family: var(--font-sans);
  font-size: var(--step--1);
  line-height: 1.6;
  color: var(--text-muted);
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: inherit;
  text-decoration-color: var(--rule);
}

.site-footer a:hover {
  color: var(--text);
  text-decoration-color: currentColor;
}

/* ------------------------------------------------------------------ */
/* Motion: a gentle staggered entrance, skipped for reduced-motion users */
/* ------------------------------------------------------------------ */

@media (prefers-reduced-motion: no-preference) {
  .reveal {
    animation: rise 0.9s var(--ease-out) both;
  }

  .reveal:nth-child(2) { animation-delay: 0.07s; }
  .reveal:nth-child(3) { animation-delay: 0.14s; }
  .reveal:nth-child(4) { animation-delay: 0.21s; }
  .reveal:nth-child(5) { animation-delay: 0.28s; }
  .reveal:nth-child(6) { animation-delay: 0.35s; }
  .reveal:nth-child(n + 7) { animation-delay: 0.42s; }

  @keyframes rise {
    from {
      opacity: 0;
      translate: 0 12px;
    }
  }
}

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

/* ------------------------------------------------------------------ */
/* Print                                                                */
/* ------------------------------------------------------------------ */

@media print {
  body {
    background: none;
    color: #000;
  }

  body::before,
  .site-nav,
  .skip-link {
    display: none;
  }

  a {
    color: inherit;
  }

  .portrait img {
    box-shadow: none;
    rotate: none;
  }
}
