/* Richard England — built to the client's page layouts:
   white pages, Times New Roman, everything centred; title pages carry two artworks side by side.
   Type sizes keep the documents' 22pt / 16pt / 13pt proportions. */

:root {
  --paper: #ffffff;
  --ink: #000000;
  --ink-soft: #3a3a3a;
  --rule: rgba(0, 0, 0, .14);

  --serif: "Times New Roman", Tinos, Times, "Liberation Serif", serif;

  --fs-plate: clamp(1.5rem, 1.05rem + 1.55vw, 2.5rem);    /* 22pt section titles */
  --fs-head: clamp(1.25rem, 1.02rem + .8vw, 1.75rem);      /* 16pt headings */
  --fs-body: clamp(1.0625rem, .96rem + .42vw, 1.375rem);   /* 13pt text */
  --fs-small: clamp(.9rem, .86rem + .18vw, 1.02rem);        /* captions */

  --page: min(92vw, 1500px);
  --measure: 40em;
  --gap: clamp(1rem, 3.2vw, 3.25rem);                       /* space between paired images */
  --section: clamp(4.5rem, 10vw, 9rem);

  --ease: cubic-bezier(.22, .61, .36, 1);
}

*, *::before, *::after { box-sizing: border-box; }
/* No smooth scrolling: a menu jump happens instantly beneath the closing overlay
   rather than gliding past (and loading) every gallery on the way. */
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--fs-body);
  line-height: 1.5;
  text-align: center;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { display: block; max-width: 100%; height: auto; }
h1, h2, p, ul, ol, figure, blockquote { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .18em; }
a:hover { text-decoration-color: var(--ink-soft); }
:focus-visible { outline: 1px solid var(--ink); outline-offset: 4px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.skip {
  position: absolute; left: 1rem; top: -4rem; z-index: 60;
  padding: .6em 1em; background: var(--paper); color: var(--ink);
}
.skip:focus { top: 1rem; }

/* ---------------------------------------------------------------- Cover */

.cover {
  position: relative;
  height: 100vh;
  height: 100svh;
  min-height: 420px;
  overflow: hidden;
  background: #16263f;
}
/* Soft, blurred copy of the artwork fills any space the artwork itself can't (very wide screens). */
.cover::before {
  content: "";
  position: absolute; inset: -40px;
  background: url("../images/cover.webp") center / cover no-repeat;
  filter: blur(32px) brightness(.62);
}
.cover__img {
  position: relative;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: 50% 45%;
}
/* The artwork has its lettering built in, so it is never cropped enough to lose any of it. */
@media (min-aspect-ratio: 21/10) {
  .cover__img { object-fit: contain; }
}
/* Portrait screens: show the whole artwork, with a band of its own blurred sky above it to hold the menu. */
@media (max-aspect-ratio: 6/5) {
  .cover { height: auto; min-height: 0; padding-top: 3.25rem; }
  .cover__img {
    height: auto;
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 14%);
            mask-image: linear-gradient(to bottom, transparent, #000 14%);
  }
}

/* ---------------------------------------------------------------- Menu */

.menu-toggle {
  position: fixed; top: clamp(.75rem, 2vw, 1.5rem); right: clamp(.75rem, 2.4vw, 2rem); z-index: 50;
  padding: .7em .2em;
  border: 0; background: none; cursor: pointer;
  font: 400 .8125rem/1 var(--serif);
  letter-spacing: .28em; text-transform: uppercase;
  color: #fff; mix-blend-mode: difference;
}
.menu-toggle::after {
  content: ""; display: block; height: 1px; margin-top: .55em;
  background: currentColor; transform: scaleX(.35); transform-origin: left;
  transition: transform .4s var(--ease);
}
.menu-toggle:hover::after, .menu-toggle[aria-expanded="true"]::after { transform: scaleX(1); }

.menu {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center;
  overflow-y: auto;
  padding: 5rem 1.5rem;
  background: var(--paper);
}
.menu[hidden] { display: none; }
.menu.is-leaving { opacity: 0; pointer-events: none; transition: opacity .5s var(--ease); }
/* Sections take focus after a menu jump (so keyboard users land there); no ring around a whole section. */
section[tabindex="-1"]:focus, header[tabindex="-1"]:focus { outline: none; }
.menu ol { counter-reset: s; }
.menu li { counter-increment: s; }
.menu a {
  display: inline-block;
  padding: .32em 0;
  font-size: clamp(1.05rem, .9rem + 1vw, 1.6rem);
  letter-spacing: .14em; text-transform: uppercase;
  text-decoration: none;
}
.menu a:hover, .menu a:focus-visible { text-decoration: underline; }
.js .menu:not([hidden]) li { animation: rise .6s var(--ease) both; animation-delay: calc(var(--i, 0) * 28ms); }

/* ---------------------------------------------------------------- Text pages */

.text {
  width: min(92vw, var(--measure));
  margin-inline: auto;
  padding-block: var(--section);
}
.text h2 {
  margin-bottom: 1.4em;
  font-size: var(--fs-head);
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.text p, .text li, .pair figcaption { text-wrap: pretty; }
.text h2, .plate__title, .appointments li { text-wrap: balance; }
.text p + p { margin-top: 1.1em; }
.text + .text { padding-top: 0; }
/* Richard England's signature, under his CV. */
.signature { width: min(100%, 17rem); margin: 2.2em auto 1.6em; }

/* The documents set Appointments in small capitals. */
.small-caps { font-variant-caps: all-small-caps; letter-spacing: .06em; }
/* Each appointment sits on one line: the column is wider here, and the type eases down on
   smaller screens so the longest entry (~37.5em) still fits. Phones are too narrow, so it wraps there. */
.text--wide { width: min(92vw, 46em); }
.appointments { font-size: clamp(.9em, 2.35vw, 1.12em); line-height: 1.6; }
@media (min-width: 720px) { .appointments li { white-space: nowrap; } }

.review + .review { margin-top: 2.2em; }
.review figcaption {
  margin-top: .75em;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.interviews li + li { margin-top: .8em; }
.interviews a { text-decoration-color: var(--rule); transition: text-decoration-color .2s; }
.interviews a:hover, .interviews a:focus-visible { text-decoration-color: currentColor; }
.interviews a::after { content: "\2009\2197"; font-size: .8em; color: var(--ink-soft); }   /* thin space + ↗ : opens elsewhere */

/* ---------------------------------------------------------------- Work sections */

.work { padding-bottom: clamp(2rem, 5vw, 4rem); }

/* Metropoli + Mythopoli: the section's last drawing fills the screen behind the section and holds
   still while the works scroll over it. It is a sticky layer, not a fixed one: phones let a fixed layer
   escape the section's clip (covering the whole page, on top of everything), but a sticky one can
   never leave its section. The -100lvh margin means it takes no space, so the section's content
   starts at the top as usual and paints over it; isolation keeps z-index -1 inside this section, and
   clip-path trims the last screen of it where it runs past the section's end.
   Tune the strength with --backdrop-opacity. */
.work--backdrop { position: relative; isolation: isolate; clip-path: inset(0); }
.backdrop {
  --backdrop-opacity: .10;
  position: -webkit-sticky; position: sticky; top: 0; z-index: -1;
  height: 100vh; height: 100lvh;          /* lvh: still covers the screen once a phone's toolbar slides away */
  margin-bottom: -100vh; margin-bottom: -100lvh;
  background: url("../images/mythopoli-backdrop.webp") center / cover no-repeat;
  opacity: var(--backdrop-opacity);
  pointer-events: none;
}
/* The works here are ink on white: multiply lets the white melt into the drawing behind.
   It sits on the figure, not the img: the figure is what fades in, and while it fades it is
   isolated, so a blend on the img inside would only switch on once the fade ended. */
.work--backdrop .pair__item,
.work--backdrop .plate__art { mix-blend-mode: multiply; }

/* Title page: the section name, then two artworks side by side — one page per section. */
.plate {
  width: var(--page);
  min-height: 100vh;
  min-height: 100svh;
  margin-inline: auto;
  padding-block: clamp(3.5rem, 8vh, 6rem);
  display: flex; flex-direction: column; justify-content: center;
  gap: clamp(2rem, 6vh, 4.5rem);
}
.plate__title {
  font-size: var(--fs-plate);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.plate__pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: var(--gap);
}

/* Gallery: the section's works in pairs of equal height, continuing the title-page rhythm. */
.gallery {
  --row-gap: clamp(3rem, 7vw, 6rem);
  width: var(--page);
  margin-inline: auto;
  display: grid;
  gap: var(--row-gap);
}
.pair {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: var(--gap);
}
.pair__item { flex: var(--ar) 1 0; min-width: 0; }
.pair__item--lone { flex: 0 0 var(--basis); }

.zoom { display: block; cursor: zoom-in; }
.zoom img { width: 100%; background: #f3f2ef; }

.pair figcaption {
  margin-top: .9em;
  padding-inline: .5em;
  font-size: var(--fs-small);
  line-height: 1.4;
  color: var(--ink-soft);
}

@media (max-width: 700px) {
  .plate { min-height: 0; padding-block: var(--section) clamp(2.5rem, 8vw, 4rem); }
  .plate__pair { grid-template-columns: 1fr; }
  .pair { flex-direction: column; gap: var(--row-gap); }
  .pair__item, .pair__item--lone { flex: none; width: 100%; }
}

/* ---------------------------------------------------------------- Books */

.books { width: min(92vw, 1060px); }
.books__grid {
  --cols: 3;
  --col-gap: clamp(1.25rem, 4vw, 3.5rem);
  display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end;
  gap: clamp(2.25rem, 5vw, 4rem) var(--col-gap);
}
.books__grid li { flex: 0 0 calc((100% - (var(--cols) - 1) * var(--col-gap)) / var(--cols)); }
.books__grid a { display: flex; justify-content: center; }
.books__grid img {
  width: auto; height: auto;
  max-width: 100%;
  max-height: clamp(150px, 24vw, 290px);
  background: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 14px 28px -18px rgba(0, 0, 0, .45);
}
@media (max-width: 560px) { .books__grid { --cols: 2; } }

/* ---------------------------------------------------------------- Footer */

.footer {
  padding: clamp(3rem, 7vw, 5rem) 1rem clamp(2.5rem, 5vw, 3.5rem);
  border-top: 1px solid var(--rule);
  width: min(92vw, var(--measure));
  margin-inline: auto;
  font-size: var(--fs-small);
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-soft);
}
.footer p + p { margin-top: .9em; }

/* ---------------------------------------------------------------- Lightbox */

.lightbox {
  position: fixed; inset: 0; z-index: 70;
  display: grid; place-items: center;
  padding: clamp(3.5rem, 7vh, 5rem) clamp(1rem, 7vw, 6.5rem);
  background: var(--paper);
}
.lightbox[hidden] { display: none; }
.lightbox__figure { display: grid; justify-items: center; gap: 1em; max-height: 100%; }
.lightbox__img {
  max-width: 100%;
  max-height: calc(100vh - clamp(3.5rem, 7vh, 5rem) * 2 - 3em);
  max-height: calc(100svh - clamp(3.5rem, 7vh, 5rem) * 2 - 3em);
  width: auto; height: auto;
  object-fit: contain;
  transition: opacity .35s var(--ease);
}
.lightbox__img.is-loading { opacity: 0; }
.lightbox__caption { min-height: 1.4em; font-size: var(--fs-small); color: var(--ink-soft); }
.lightbox__count, .lightbox__close {
  position: absolute; top: clamp(.9rem, 2.2vw, 1.6rem);
  font: 400 .8125rem/1 var(--serif); letter-spacing: .28em; text-transform: uppercase;
}
.lightbox__count { left: clamp(1rem, 2.4vw, 2rem); margin: 0; padding: .7em 0; color: var(--ink-soft); }
.lightbox__close { right: clamp(.75rem, 2.4vw, 2rem); }
.lightbox button {
  border: 0; background: none; color: var(--ink); cursor: pointer; padding: .7em .2em;
}
.lightbox__nav {
  position: absolute; top: 50%; translate: 0 -50%;
  font: 300 clamp(1.5rem, 2.4vw, 2rem)/1 var(--serif);
  padding: 1em !important;
  opacity: .55; transition: opacity .2s;
}
.lightbox__nav:hover, .lightbox__nav:focus-visible { opacity: 1; }
.lightbox__nav--prev { left: clamp(0rem, 1.5vw, 1.5rem); }
.lightbox__nav--next { right: clamp(0rem, 1.5vw, 1.5rem); }
.lightbox--single .lightbox__nav, .lightbox--single .lightbox__count { display: none; }
@media (max-width: 700px) {
  .lightbox__nav { top: auto; bottom: .25rem; translate: none; }
}

/* ---------------------------------------------------------------- Reveal */

@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

@media (prefers-reduced-motion: no-preference) {
  .js .reveal { opacity: 0; transform: translateY(18px); transition: opacity 1s var(--ease), transform 1s var(--ease); }
  .js .reveal.is-in { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .js .menu:not([hidden]) li { animation: none; }
}
