/* ==========================================================================
   Pure white, paper.
   No colour, no cards, no shadows, no motion. Text on a page.
   ========================================================================== */

:root {
  /* A hair of warmth stops pure #fff reading as "screen". */
  --paper: #fffefc;
  --ink: #16171a;
  --ink-2: #4a4c52;
  --ink-3: #8b8d93;
  --rule: #e4e1da;

  --serif: "EB Garamond", "Iowan Old Style", "Palatino Linotype", Palatino,
    Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;

  --measure: 34rem; /* ~68 characters at this size */
  --gutter: 1.5rem;
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  /* Garamond runs small, so the base size is pushed up. */
  font-size: clamp(1.125rem, 0.95rem + 0.5vw, 1.3125rem);
  line-height: 1.62;
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Paper grain: a fine, low-contrast fibre that only shows up close. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)'/%3E%3C/svg%3E");
}

/* ==========================================================================
   Page column
   ========================================================================== */

.page {
  position: relative;
  z-index: 2;
  max-width: var(--measure);
  margin: 0 auto;
  padding: clamp(4rem, 12vh, 8rem) var(--gutter) 6rem;
}

/* ==========================================================================
   Masthead
   ========================================================================== */

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1.5rem 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 3rem;
}

.masthead__text {
  flex: 1 1 16rem;
  min-width: 0;
}

.portrait {
  order: 1;
  flex: 0 0 auto;
  width: 6rem;
  aspect-ratio: 1;
  object-fit: cover;
  object-position: 55% 40%;
  border-radius: 4px;
}

.name {
  margin: 0;
  font-size: clamp(2rem, 1.4rem + 2.4vw, 2.75rem);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.012em;
}

.affiliation {
  margin: 0.75rem 0 0;
  color: var(--ink-2);
  font-size: 0.95em;
  line-height: 1.45;
}

.links {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  margin-top: 1.5rem;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.links span {
  color: var(--ink-3);
}

/* ==========================================================================
   Sections
   ========================================================================== */

section {
  margin-bottom: 2.75rem;
}

h2 {
  margin: 0 0 1rem;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

p {
  margin: 0 0 1rem;
}

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

em {
  font-style: italic;
}

/* ==========================================================================
   Links — ink, not browser blue
   ========================================================================== */

a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.5px;
  transition: border-color 0.15s linear;
}

a:hover {
  border-bottom-color: var(--ink);
}

.links a {
  border-bottom-color: transparent;
}

.links a:hover {
  border-bottom-color: var(--ink);
}

/* ==========================================================================
   Lists
   ========================================================================== */

.plain {
  margin: 0;
  padding: 0;
  list-style: none;
}

.plain li {
  position: relative;
  padding-left: 1.5rem;
  margin-bottom: 0.35rem;
}

.plain li::before {
  content: "\2014";
  position: absolute;
  left: 0;
  color: var(--ink-3);
}

/* Dated definition list: year column, then the entry. */
.dated {
  margin: 0;
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  row-gap: 0.9rem;
  column-gap: 1.25rem;
}

.dated dt {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  padding-top: 0.3em;
  white-space: nowrap;
}

.dated dd {
  margin: 0;
}

.dated dd strong {
  font-weight: 600;
}

.address {
  color: var(--ink-2);
  font-size: 0.95em;
  line-height: 1.5;
}

/* ==========================================================================
   Colophon
   ========================================================================== */

.colophon {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}

.colophon p {
  margin: 0;
}

/* ==========================================================================
   Selection + focus
   ========================================================================== */

::selection {
  background: #e8e4da;
  color: var(--ink);
}

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

/* ==========================================================================
   Narrow screens
   ========================================================================== */

@media (max-width: 30rem) {
  .portrait {
    order: -1;
    width: 4.5rem;
  }
  .dated {
    grid-template-columns: 1fr;
    row-gap: 0.25rem;
  }
  .dated dt {
    padding-top: 0;
  }
  .dated dd {
    margin-bottom: 0.85rem;
  }
}

/* ==========================================================================
   Print — the obvious target for a page like this
   ========================================================================== */

@media print {
  body {
    background: #fff;
    font-size: 11pt;
  }
  body::before {
    display: none;
  }
  .page {
    max-width: none;
    padding: 0;
  }
  a {
    border-bottom: none;
  }
  section {
    break-inside: avoid;
  }
}

/* ==========================================================================
   Achievement list (competitions)
   Name on its own line, metadata beneath — reads the same at any width,
   with no grid to collapse.
   ========================================================================== */

.entries {
  margin: 0;
  padding: 0;
  list-style: none;
}

.entries > li {
  padding-block: 0.7rem;
}

.entries > li:first-child {
  padding-top: 0;
}

.entries > li:last-child {
  padding-bottom: 0;
}

.entry__title {
  display: inline;
}

.entry__meta {
  display: block;
  margin-top: 0.15rem;
  color: var(--ink-3);
  font-size: 0.85em;
}

.entry__year {
  font-family: var(--sans);
  font-size: 0.76em;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}

/* Credential line at the top of the Competitions section. */
.badge {
  margin-bottom: 1.75rem;
}

.badge__title {
  display: block;
  font-weight: 600;
}

.badge__detail {
  display: block;
  margin-top: 0.2rem;
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}

/* Standalone link that follows a list inside a section. */
.more {
  margin-top: 1.5rem;
  margin-bottom: 0;
}

/* ==========================================================================
   Projects — collapsed by default, using native <details>.
   No JavaScript: keyboard accessible, and prints correctly.
   ========================================================================== */

.projects {
  margin: 0;
}

.project {
  border-top: 1px solid var(--rule);
}

.project:last-child {
  border-bottom: 1px solid var(--rule);
}

.project > summary {
  display: flex;
  align-items: baseline;
  gap: 0.85rem;
  padding: 0.95rem 0;
  cursor: pointer;
  list-style: none;
}

.project > summary::-webkit-details-marker {
  display: none;
}

.project > summary::marker {
  content: "";
}

/* Plus that turns into a minus when the entry is open. */
.project__mark {
  position: relative;
  flex: none;
  /* Sit on the title's first line, not the middle of a wrapped summary. */
  align-self: flex-start;
  margin-top: 0.55em;
  width: 0.62rem;
  height: 0.62rem;
}

.project__mark::before,
.project__mark::after {
  content: "";
  position: absolute;
  background: var(--ink-3);
  transition: transform 0.18s ease, background-color 0.18s ease;
}

.project__mark::before {
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
}

.project__mark::after {
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
}

.project[open] .project__mark::after {
  transform: scaleY(0);
}

.project > summary:hover .project__mark::before,
.project > summary:hover .project__mark::after {
  background: var(--ink);
}

.project__head {
  flex: 1 1 auto;
  min-width: 0;
}

.project__title {
  display: block;
}

.project__summary {
  display: block;
  margin-top: 0.15rem;
  color: var(--ink-2);
  font-size: 0.95em;
}

.project__when {
  flex: none;
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}

/* Indented to line up with the title, not the marker. */
.project__body {
  padding: 0 0 1.4rem 1.47rem;
}

.project__body p {
  margin: 0 0 0.85rem;
}

.project__body p:last-child {
  margin-bottom: 0;
}

.project__tech {
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}

.project__links {
  font-size: 0.95em;
}

.project[open] .project__body {
  animation: project-open 0.18s ease;
}

@keyframes project-open {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media print {
  /* Closed entries would otherwise print as nothing. */
  .project__body {
    display: block !important;
  }
  .project__mark {
    display: none;
  }
}

/* Competitions sit under the project list inside the merged section. */
.competitions {
  margin-top: 2.25rem;
}

/* Blocks that appear inside an expanded project body. */
.project__body .badge {
  margin-bottom: 1.15rem;
}

.project__body .entries {
  margin-top: 1.15rem;
}

.project__body .entries + .project__tech {
  margin-top: 1.15rem;
}

.project__body .entries + .project__links {
  margin-top: 1.15rem;
}

/* ==========================================================================
   Grouped dataset list inside an expanded project
   ========================================================================== */

.groups {
  margin-top: 1.15rem;
}

/* A rule above every group but the first, so boundaries are unmistakable. */
.group + .group {
  margin-top: 1.9rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}

/* Label: small, but solid black so it reads as a heading, not a whisper. */
.group__label {
  margin: 0 0 0.5rem;
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--ink);
}

/* Note: italic and smaller, so it reads as a caption rather than an entry. */
.group__note {
  margin: 0 0 1.1rem;
  max-width: 42ch;
  font-family: var(--sans);
  font-size: 0.88em;
  font-style: italic;
  line-height: 1.5;
  color: var(--ink-2);
}

.project__body .groups + .project__tech {
  margin-top: 1.6rem;
}

/* Links inside an italic group note keep the page's underline treatment. */
.group__note a {
  border-bottom-color: var(--ink-3);
}

.group__note a:hover {
  border-bottom-color: var(--ink);
}

/* A linked group label reads as a link without shouting. */
.group__label a {
  border-bottom: 1px solid var(--rule);
}

.group__label a:hover {
  border-bottom-color: var(--ink);
}

/* Brief confirmation after an email is copied. */
[data-copied] {
  color: var(--ink-3);
  border-bottom-color: transparent !important;
}
