/* ==========================================================================
   Design tokens.
   Change a value here and it changes everywhere on the site.
   ========================================================================== */

:root {
  --bg-cream: #FDFAF3;
  --bg-purple: #F0EBFA;
  --ink: #211E2B;
  --muted: #5C5668;
  --accent: #6B3FA0;
  --rule: #D6D2DE;
  --overlay: rgba(20, 18, 26, 0.68);
  --overlay-soft: rgba(20, 18, 26, 0.55);
  --accent-glow: rgba(107, 63, 160, 0.38);

  --font-serif: "Iowan Old Style", Palatino, Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               Helvetica, Arial, sans-serif;

  --measure: 1160px;
  --gutter: 1.5rem;
  --section-pad: 5rem;
}

/* ==========================================================================
   Reset and base
   ========================================================================== */

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

html {
  /* Nav links jump within this one page. Without the offset the sticky top
     bar would cover the heading you just jumped to. */
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
}

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

body {
  margin: 0;
  background: var(--bg-cream);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1.125rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-serif);
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin: 0 0 0.5em;
}

h1 { font-size: clamp(2.5rem, 6vw, 3.75rem); }
h2 { font-size: clamp(1.9rem, 4vw, 2.5rem); }
h3 { font-size: 1.3rem; }

p { margin: 0 0 1rem; }

a {
  color: var(--accent);
  text-underline-offset: 0.18em;
}

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

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

.container {
  width: 100%;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--accent);
  color: var(--bg-cream);
  padding: 0.75rem 1.25rem;
  text-decoration: none;
}

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

/* ==========================================================================
   Top bar
   ========================================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-cream);
  border-bottom: 1px solid var(--rule);
}

.topbar__inner {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0.85rem var(--gutter);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
}

.topbar__name {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.nav__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.35rem;
}

.nav__list a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  padding: 0.15rem 0;
  border-bottom: 2px solid transparent;
}

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

/* ==========================================================================
   Section bands
   ========================================================================== */

.band {
  padding: var(--section-pad) 0;
}

.band--cream { background: var(--bg-cream); }
.band--purple { background: var(--bg-purple); }

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
  background: var(--ink);
  color: var(--bg-cream);
  padding: 3rem 0;
}

.footer a {
  color: var(--bg-cream);
}

.footer__links {
  list-style: none;
  margin: 0 0 1.25rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
}

.footer__note {
  margin: 0;
  color: var(--rule);
  font-size: 0.9rem;
}

/* ==========================================================================
   Hero
   ========================================================================== */

.hero__grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 3rem;
  align-items: center;
}

.hero__lede {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  color: var(--ink);
  margin-bottom: 0.75rem;
}

.hero__text p:not(.hero__lede) {
  color: var(--muted);
  max-width: 34em;
}

.hero__socials {
  list-style: none;
  margin: 1.75rem 0 0;
  padding: 0;
  display: flex;
  gap: 0.75rem;
}

.hero__socials a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--rule);
  border-radius: 50%;
  color: var(--accent);
}

.hero__socials a:hover {
  border-color: var(--accent);
}

.hero__photo {
  width: 100%;
  border-radius: 6px;
}

/* ==========================================================================
   Section head
   ========================================================================== */

.section__head {
  /* No cap: the intro should line up with the cards beneath it rather than
     sitting in a narrower column. */
  margin-bottom: 3rem;
}

.section__title {
  margin-bottom: 0.35rem;
}

.section__lede {
  color: var(--muted);
  font-size: 1.1rem;
  margin: 0;
}

/* An intro can run to more than one paragraph. */
.section__lede + .section__lede {
  margin-top: 1rem;
}

/* ==========================================================================
   Highlight cards
   ========================================================================== */

.cards {
  display: flex;
  flex-direction: column;
}

.card {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 2.25rem;
  align-items: start;
  padding: 2.25rem 0;
  border-top: 1px solid var(--rule);
}

.card:first-child {
  border-top: 0;
  padding-top: 0;
}

.card__media {
  width: 100%;
  border-radius: 6px;
}

/* Research figures are wide diagrams, not photographs. Sit them on a light
   panel so they read as figures against the coloured band. */
.card__media--figure {
  background: var(--bg-cream);
  padding: 0.5rem;
}

/* For media that needs a bit more room than a photo — a demo video, a site
   screenshot. Still side by side with the text, just a wider media column.
   Change the 560px to resize them. */
.card--wide {
  grid-template-columns: 560px 1fr;
}

video.card__media,
iframe.card__media {
  width: 100%;
  /* height:auto is required — without it the element's height attribute wins
     over aspect-ratio and the box comes out square-ish. */
  height: auto;
  aspect-ratio: 16 / 9;
  border: 0;
  background: var(--ink);
}

.card__title {
  margin-bottom: 0.6rem;
}

.card__points {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--muted);
}

.card__points li {
  margin-bottom: 0.4rem;
}

/* ==========================================================================
   Organisations and their projects (Service & Leadership)

   An organisation is a heading, a paragraph about the role, and then the
   projects run under it — each with a small photo gallery.
   ========================================================================== */

.org + .org {
  margin-top: 3.5rem;
  padding-top: 3.5rem;
  border-top: 1px solid var(--rule);
}

.org__title {
  font-size: clamp(1.4rem, 2.4vw, 1.85rem);
  margin-bottom: 0.5rem;
}

.org__lede {
  color: var(--muted);
  max-width: 42em;
  margin: 0 0 2.5rem;
}

/* Outbound links for an organisation — its site, a write-up. */
.org__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1.5rem 0 0;
}

.project + .project {
  margin-top: 2.5rem;
}

.project__title {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.9rem;
}

.project p {
  color: var(--muted);
  max-width: 42em;
  margin: 0 0 1.25rem;
}

.gallery {
  /* Phone photos are portrait, so that is the default. Add gallery--landscape
     for a gallery of wider shots. */
  --thumb-ratio: 3 / 4;

  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  /* Fixed three columns, not auto-fit: a gallery with two photos should leave
     the third slot empty rather than stretching to fill it, so every gallery
     on the page uses the same size tile. */
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
}

.gallery--landscape {
  --thumb-ratio: 4 / 3;
}

/* For a row mixing a portrait shot with a wide group shot: square crops both
   without cutting anyone out of the wide one. */
.gallery--square {
  --thumb-ratio: 1 / 1;
}

/* Screenshots and screen recordings, which are wider than a photograph. */
.gallery--wide {
  --thumb-ratio: 16 / 9;
}

/* Two photos across instead of three, so a pair fills the row rather than
   leaving an empty slot. */
.gallery--two {
  grid-template-columns: repeat(2, 1fr);
}

.gallery img {
  width: 100%;
  aspect-ratio: var(--thumb-ratio);
  object-fit: cover;
  border-radius: 6px;
}

/* A caption laid over the bottom of a photo. Wrap the image in a <figure>
   and add a <figcaption> after it. */
.gallery figure {
  position: relative;
  margin: 0;
  border-radius: 6px;
  overflow: hidden;
}

.gallery figcaption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.55rem 0.75rem;
  background: var(--overlay);
  color: var(--bg-cream);
  font-size: 0.85rem;
  line-height: 1.35;
}

/* A gallery slot can hold an embedded video instead of a photo. */
.gallery iframe {
  width: 100%;
  height: auto;
  aspect-ratio: var(--thumb-ratio);
  border: 0;
  border-radius: 6px;
  background: var(--ink);
}

/* Embedded posts from elsewhere — coverage of the work rather than photos of
   it. These are the only third-party requests the site makes. */
.embeds {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
  max-width: 52rem;
}

/* Browsers give <figure> a 40px side margin by default, which would eat the
   column width. */
.embeds figure {
  margin: 0;
}

.embeds iframe {
  width: 100%;
  /* Tall enough for Instagram's header, the vertical reel, and its action
     row, without leaving dead space underneath. */
  aspect-ratio: 0.58;
  border: 0;
  border-radius: 6px;
  background: var(--bg-cream);
}

.embeds figcaption {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

/* ==========================================================================
   Short stories

   A cover image with a title card offset over its lower edge. The whole tile
   is one link to the story.
   ========================================================================== */

.stories {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
}

.stories > li {
  /* Room for the title card, which hangs below the cover. */
  padding-bottom: 2.5rem;
}

.story {
  display: block;
  position: relative;
  text-decoration: none;
  color: inherit;
}

.story__cover {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 6px;
  transition: box-shadow 0.18s ease, transform 0.18s ease;
}

.story__label {
  position: absolute;
  left: 1.5rem;
  right: -0.75rem;
  bottom: -2rem;
  background: var(--bg-cream);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.85rem 1.1rem;
  transition: box-shadow 0.18s ease, transform 0.18s ease;
}

.story__title {
  display: block;
  font-family: var(--font-serif);
  font-size: 1.15rem;
  line-height: 1.25;
  color: var(--ink);
}

.story__meta {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
}

/* The glow is the click affordance: nothing else on the page lights up. */
.story:hover .story__cover,
.story:focus-visible .story__cover {
  box-shadow: 0 0 0 3px var(--accent), 0 8px 30px 4px var(--accent-glow);
  transform: translateY(-4px);
}

.story:hover .story__label,
.story:focus-visible .story__label {
  border-color: var(--accent);
  transform: translateY(-4px);
}

.story:focus-visible {
  outline: none;
}

@media (prefers-reduced-motion: reduce) {
  .story__cover,
  .story__label {
    transition: none;
  }

  .story:hover .story__cover,
  .story:focus-visible .story__cover,
  .story:hover .story__label,
  .story:focus-visible .story__label {
    transform: none;
  }
}

/* ==========================================================================
   Photo grid

   A contact sheet of the portfolio: small square tiles, each opening the full
   size image. Deliberately dense so twenty-odd photos stay one screen.
   ========================================================================== */

.subhead {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 3.5rem 0 1.1rem;
}

.subhead--first {
  margin-top: 0;
}

.photo-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  /* Multi-column rather than a grid: photos keep their own proportions and
     pack together like a contact sheet. Change the column count to resize. */
  columns: 3;
  column-gap: 0.8rem;
}

.photo-grid li {
  /* Never split a photo across two columns. */
  break-inside: avoid;
  page-break-inside: avoid;
  margin: 0 0 0.8rem;
}

.photo-grid img {
  width: 100%;
  height: auto;
  border-radius: 4px;
  transition: box-shadow 0.16s ease, transform 0.16s ease;
}

.photo-grid a {
  display: block;
  position: relative;
  border-radius: 4px;
  overflow: hidden;
}

/* Title card, revealed on hover. Present in the DOM at all times so screen
   readers still announce the title. */
.photo-grid__label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0.7rem 0.85rem;
  background: var(--overlay-soft);
  color: var(--bg-cream);
  opacity: 0;
  transition: opacity 0.18s ease;
}

.photo-grid__name {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.2;
}

.photo-grid__tag {
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.85;
  margin-top: 0.2rem;
}

.photo-grid a:hover .photo-grid__label,
.photo-grid a:focus-visible .photo-grid__label {
  opacity: 1;
}

.photo-grid a:hover img,
.photo-grid a:focus-visible img {
  box-shadow: 0 0 0 3px var(--accent), 0 6px 20px 2px var(--accent-glow);
}

.photo-grid a:focus-visible {
  outline: none;
}

@media (prefers-reduced-motion: reduce) {
  .photo-grid img {
    transition: none;
  }

  .photo-grid__label {
    transition: none;
  }
}

/* ==========================================================================
   Video tiles

   A thumbnail with a play badge. Clicking opens the player in the lightbox,
   so nothing is requested from YouTube until you actually watch something.
   ========================================================================== */

.video-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.video-tile {
  display: block;
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
}

.video-tile img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  transition: transform 0.2s ease;
}

.video-tile__play {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 68px;
  height: 68px;
  margin: -34px 0 0 -34px;
  border-radius: 50%;
  background: var(--overlay);
  transition: background 0.18s ease;
}

/* The play triangle. */
.video-tile__play::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  margin: -13px 0 0 -8px;
  border-style: solid;
  border-width: 13px 0 13px 22px;
  border-color: transparent transparent transparent var(--bg-cream);
}

.video-tile__label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 2.5rem 1rem 0.9rem;
  background: linear-gradient(to top, var(--overlay), transparent);
  color: var(--bg-cream);
}

.video-tile__title {
  display: block;
  font-family: var(--font-serif);
  font-size: 1.1rem;
  line-height: 1.25;
}

.video-tile__where {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.85rem;
  opacity: 0.85;
}

.video-tile:hover img,
.video-tile:focus-visible img {
  transform: scale(1.04);
}

.video-tile:hover .video-tile__play,
.video-tile:focus-visible .video-tile__play {
  background: var(--accent);
}

.video-tile:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .video-tile img {
    transition: none;
  }

  .video-tile:hover img,
  .video-tile:focus-visible img {
    transform: none;
  }
}

/* ==========================================================================
   Lightbox

   Pure CSS, using :target — clicking a thumbnail sets the hash, which reveals
   the matching overlay. No JavaScript, and the browser Back button closes it.
   ========================================================================== */

.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 4vh 4vw;
  background: var(--overlay);
}

.lightbox:target {
  display: flex;
}

/* Fills the overlay so clicking anywhere outside the photo closes it. */
.lightbox__backdrop {
  position: absolute;
  inset: 0;
}

.lightbox__figure {
  position: relative;
  margin: 0;
  max-width: 100%;
  text-align: center;
}

.lightbox__figure img {
  max-width: 100%;
  max-height: 80vh;
  width: auto;
  height: auto;
  margin: 0 auto;
  border-radius: 4px;
}

/* A video player needs a sized box; a photo sizes itself. */
.lightbox__figure--video {
  width: min(1100px, 92vw);
}

.lightbox__figure--video iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  border: 0;
  border-radius: 4px;
  background: var(--ink);
}

.lightbox__figure figcaption {
  margin-top: 0.9rem;
  color: var(--bg-cream);
  font-size: 0.95rem;
}

.lightbox__close {
  position: absolute;
  top: 2vh;
  right: 3vw;
  z-index: 1;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  line-height: 1;
  text-decoration: none;
  color: var(--bg-cream);
  border: 1px solid var(--rule);
  border-radius: 50%;
}

.lightbox__close:hover {
  background: var(--accent);
  border-color: var(--accent);
}

/* ==========================================================================
   Awards

   A plain list, no year headings. Each entry is its name with the qualifying
   detail beneath it.
   ========================================================================== */

.awards__list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 52em;
}

.awards__item {
  padding: 1rem 0;
  border-top: 1px solid var(--rule);
}

.awards__item:first-child {
  border-top: 0;
  padding-top: 0;
}

.awards__name {
  display: block;
}

.awards__date {
  color: var(--muted);
  white-space: nowrap;
}

.awards__note {
  display: block;
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.95rem;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-block;
  background: var(--accent);
  color: var(--bg-cream);
  padding: 0.6rem 1.4rem;
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.95rem;
}

.btn:hover {
  background: var(--ink);
}

.btn--ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.btn--ghost:hover {
  background: var(--accent);
  color: var(--bg-cream);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 900px) {
  .hero__grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .hero__photo {
    max-width: 320px;
  }

  .card {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .card__media {
    max-width: 480px;
  }

  .photo-grid {
    columns: 2;
  }

}

@media (max-width: 600px) {
  :root {
    --section-pad: 3rem;
    --gutter: 1.15rem;
  }

  /* Comfortable tap targets push the two-row nav past 130px tall. Sticking
     that to the top would cover a sixth of a phone screen, so on small
     screens the bar scrolls away with the page. */
  .topbar {
    position: static;
  }

  .topbar__inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
  }

  .nav__list {
    gap: 0 1.35rem;
  }

  .nav__list a {
    padding: 0.8rem 0;
  }

  /* Three tiles across is too cramped on a phone. */
  .gallery {
    grid-template-columns: repeat(2, 1fr);
  }

  .photo-grid {
    columns: 2;
  }

  .video-grid {
    grid-template-columns: 1fr;
  }

  /* A vertical reel in a half-width column is unwatchable; stack them. */
  .embeds {
    grid-template-columns: 1fr;
    max-width: 20rem;
  }
}
