/* The whole site's styles. Phones first; wide screens at the bottom. */

@font-face {
  font-family: 'Literata';
  font-weight: 200 900;
  font-display: swap;
  src: url(fonts/literata.woff2) format('woff2');
}

:root {
  --paper: #faf3e8;
  --paper-deep: #ebdfcd;
  --ink: #2b2420;
  --ink-soft: rgb(43 36 32 / 0.62);
  --rule: rgb(43 36 32 / 0.18);
  --serif: 'Literata', 'Iowan Old Style', Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --ridge: clamp(2rem, 6vw, 3.5rem); /* height of a hill's ridgeline */
  --band: clamp(4.5rem, 12svh, 8rem); /* height of a hill below it */
}

/* Each section's colour, used for its hill and its page's header. */
.home     { --color: #e4cbb3; } /* sand */
.contact  { --color: #d4a990; } /* clay */
.about    { --color: #c27a5c; } /* terracotta */
.blog     { --color: #d6ab62; } /* ochre */
.research { --color: #5d6a4c; } /* forest */

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
}

/* ---- Layout ----
   Phones: the home page's intro and hills fill the first screen and the
   rest follows; inner pages put their content first and the hills last. */

header {
  padding: 1.75rem 1.25rem 2rem;
}

body.home header {
  min-height: calc(100svh - var(--ridge) - 5 * var(--band));
}

main {
  display: grid;
  align-content: start;
  gap: 3rem;
  padding: 3rem 1.25rem 2.5rem;
}

body:not(.home) {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

body:not(.home) main {
  flex: 1;
}

body:not(.home) nav {
  order: 1;
}

/* Inner pages: the title sits in a coloured box inset from the cream, and
   the text below lines up with the title inside it. */
body:not(.home) header {
  margin: 1.25rem 1.25rem 0;
  padding: 1rem 1.25rem;
  background: var(--color);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
}

body:not(.home) main {
  padding: 2rem 2.5rem 2.5rem;
}

body.research header {
  color: var(--paper);
}

header h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 650;
  line-height: 1.1;
}

header .name {
  font-size: 1.15rem;
  color: inherit;
  text-decoration: none;
}

/* ---- The hills (the menu) ---- */

nav {
  display: flex;
  flex-direction: column;
  padding-top: var(--ridge);
}

nav a {
  position: relative;
  display: flex;
  align-items: flex-start; /* just under its ridgeline, clear of the one in front */
  height: var(--band);
  padding: 0.4rem 1.25rem 0;
  background: var(--color);
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
}

nav a.research {
  color: #fff;
}

nav svg {
  position: absolute;
  left: 0;
  bottom: calc(100% - 1px);
  width: 100%;
  height: var(--ridge);
  fill: var(--color);
}

nav span {
  position: relative;
}

nav a:hover span,
nav a[aria-current] span {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

nav a[aria-current] {
  font-weight: 700;
}

/* The home page's own hill has no label; it's still there for screen readers. */
body.home nav .home span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---- Home page ---- */

body.home h1 {
  margin: 0 auto;
  max-width: 30ch;
  text-align: center;
  font-size: clamp(1.45rem, 2.8vw, 2.2rem);
  font-weight: 400;
  line-height: 1.2;
  text-wrap: pretty;
}

body.home h1 strong {
  font-weight: 650;
}

.photo {
  margin: 0 auto;
  width: min(80%, 22rem);
  aspect-ratio: 1;
  background: var(--paper-deep);
}

.photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 60% center;
}

/* ---- Logos ---- */

.affiliations {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1.75rem 2.5rem;
}

.affiliations li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.affiliations img {
  max-width: 100%;
  max-height: 2rem;
  opacity: 0.8;
}

/* Round marks need more height than the wide wordmarks to look as big. */
.affiliations img.tall {
  max-height: 2.75rem;
}

/* A colour logo, flattened to grey to match the others. */
.affiliations img.grey {
  filter: grayscale(1) contrast(1.5);
}

.affiliations span {
  font-size: 1.05rem;
  line-height: 1.15;
  color: var(--ink-soft);
}

/* ---- Running text on inner pages ---- */

.prose {
  max-width: 36rem;
  font-size: 1.05rem;
  line-height: 1.6;
}

.prose > :first-child {
  margin-top: 0;
}

.prose h2 {
  margin: 2.25rem 0 0.5rem;
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.25;
}

.prose p {
  margin: 0 0 1rem;
}

.prose a {
  color: inherit;
  text-underline-offset: 0.15em;
}

.prose .meta {
  display: block;
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--ink-soft);
}

/* Blog notes, divided by thin rules. */
.note {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--rule);
}

.note:first-child {
  padding-top: 0;
}

.prose .note h2 {
  margin-top: 0.25rem;
}

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

.prose .photos-title {
  margin-bottom: 1.25rem;
}

/* Photos: a grid of square thumbnails, each opening full-size over a dark
   backdrop, with arrows either side. */
.photos {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr));
  gap: 0.5rem;
}

.photos button {
  padding: 0;
  border: 0;
  background: none;
}

.photos li > button {
  display: block;
  width: 100%;
  cursor: zoom-in;
}

.photos li > button img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

/* The open photo fills the screen: arrows at the edges, and a click anywhere
   else closes it. */
.photos [popover] {
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
}

.photos [popover]:popover-open {
  display: flex;
}

.photos [popover]::backdrop {
  background: rgb(0 0 0 / 0.85);
}

.photos .full {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}

.photos .full img {
  display: block;
  max-width: calc(100vw - 6rem);
  max-height: 92vh;
}

.photos .arrow {
  width: 3rem;
  align-self: stretch;
  font-size: 2.5rem;
  line-height: 1;
  color: var(--paper);
  cursor: pointer;
}

/* ---- Wide screens: words on the left, hills on the right ---- */

@media (min-width: 48rem) {
  :root {
    --ridge: clamp(2rem, 4vw, 3.5rem);
  }

  body,
  body:not(.home) {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      'header nav'
      'main   nav';
  }

  header,
  body.home header {
    grid-area: header;
    min-height: 0;
    padding: 2.5rem 2.5rem 1rem;
  }

  main {
    grid-area: main;
    padding: 2rem 2.5rem 2.5rem;
  }

  body:not(.home) header {
    margin: 2.5rem 2.5rem 0;
    padding: 1.1rem 1.75rem;
  }

  body:not(.home) main {
    padding: 2rem 4.25rem 2.5rem;
  }

  /* The hills fill the full-height column, sharing it between them, and
     the furthest one runs flat to the top: no sky. */
  nav {
    grid-area: nav;
    position: sticky;
    top: 0;
    height: 100vh;
    padding-top: 0;
    overflow: hidden;
  }

  nav a {
    flex: 1;
    height: auto;
    padding: 0.3rem 2.5rem 0;
  }

  /* The top hill has no ridgeline above it, so give its label the same
     breathing room the others get. */
  nav a:first-child {
    padding-top: calc(var(--ridge) / 2 + 0.3rem);
  }
}
