/* dan wilton — site styles */
:root {
  --bg: #f9f0ea;
  --ink: #2b2725;
  --muted: #8b807a;
  --line: #e4d6cd;
  --serif: "EB Garamond", "Times New Roman", Times, serif;
  --sans: "Inter", -apple-system, "Helvetica Neue", Arial, sans-serif;
  --gutter: clamp(16px, 2.2vw, 28px);
  --photoh: 620px;               /* set by "photo height" in content/site.txt */
  --rowh: var(--photoh);         /* side-by-side photos */
  --slideh: var(--photoh);       /* one-at-a-time photos */
  --gap: 12px;
  /* sizes (set in the editor's Settings → Design) */
  --menu-size: 17px;   /* menu, footer, projects list */
  --small-size: 12px;  /* project titles, captions, photo numbers */
  --title-size: calc(var(--text-size) * 1.15);   /* the title at the top of a project description */
  --text-size: 16px;   /* paragraphs and the contact page */
  --counter-size: 13px; /* the 2 / 12 cursor over photos */
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; overscroll-behavior-x: none; }
body {
  margin: 0; background: var(--bg); color: var(--ink); overscroll-behavior-x: none;
  font: 400 var(--small-size)/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--muted); }
img { display: block; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 1px solid var(--ink); outline-offset: 3px; }

/* ---------- header / footer ---------- */
.top, .bottom {
  position: fixed; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  padding: 12px var(--gutter);
  font: 400 var(--menu-size)/1.2 var(--serif); letter-spacing: .005em;
}
/* no background: photos stay visible right up to the top edge while scrolling */
.top { top: 0; pointer-events: none; }
.top a { pointer-events: auto; }
.bottom { bottom: 0; font-size: calc(var(--menu-size) * .88); pointer-events: none; }
.bottom a { pointer-events: auto; }
.site-name { font: inherit; margin: 0; }   /* the name is the page's main heading, for search engines; looks the same */
.nav { display: flex; flex-wrap: wrap; justify-content: flex-end; }
.nav .sep { padding: 0 .6em; color: var(--muted); }
.nav a[aria-current] { font-style: italic; }

main { padding: 120px 0 25vh; min-height: 100vh; }

/* ---------- a piece of work ---------- */
.work { margin: 0 auto 26vh; scroll-margin-top: 80px; }
.works--shop .work, .works--projects .work { margin-bottom: 14vh; }
.w-head { text-align: center; margin: 14px auto 0; padding: 0 var(--gutter); }
.w-title { font: 400 var(--small-size)/1.45 var(--serif); margin: 0; }   /* EB Garamond, at the small size */
.w-place { margin: 0; }
.w-price { margin: 10px 0 8px; font-weight: 500; }
.buy {
  display: inline-block; border: 1px solid var(--ink); border-radius: 99px;
  padding: 6px 18px; font-size: var(--small-size);
}
.buy:hover { background: var(--ink); color: var(--bg); }
.w-text {
  max-width: 640px; margin: 28px auto 0; padding: 0 var(--gutter);
  text-align: center; font: 400 var(--text-size)/1.45 var(--serif);
}
.w-text + .gallery { margin-top: 40px; }
.w-text p { margin: 0 0 1em; }
.w-text a, .contact a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.w-text hr, .contact hr { border: 0; border-top: 1px dotted var(--muted); width: 220px; margin: 2em auto; }
.works--shop .w-title { font: 400 var(--small-size)/1.45 var(--serif); }
.divider { text-align: center; font: 20px var(--serif); color: var(--muted); margin: -6vh 0 12vh; }

/* projects index */
.p-index {
  max-width: 760px; margin: 0 auto 12vh; padding: 0 var(--gutter);
  text-align: center; font: 400 var(--menu-size)/1.7 var(--serif);
}
.p-index a:not(:last-child)::after { content: " / "; color: var(--muted); }

/* contact */
.contact {
  max-width: 760px; margin: 0 auto; padding: 0 var(--gutter);
  text-align: center; font: 400 var(--text-size)/1.45 var(--serif);
}
.contact p { margin: 0 0 1.1em; }

/* ---------- photos ---------- */
.gallery { position: relative; }
.ph { margin: 0; min-width: 0; }
.ph-link { display: block; aspect-ratio: var(--ar); background: rgba(0, 0, 0, .035); }
.ph-link img { width: 100%; height: 100%; object-fit: contain; }

/* caption of the photo on show, under the project title */
.w-cap { margin: 6px auto 0; max-width: 560px; min-height: 1.5em; color: var(--muted); }

/* row: photos side by side, all the same height */
[data-layout="row"] .g-track {
  display: flex; justify-content: center; align-items: flex-start; gap: var(--gap);
  padding: 0 var(--gutter); margin: 0 auto;
}
[data-layout="row"] .ph { flex: var(--ar) 1 0; max-width: calc(var(--ar) * var(--rowh)); }

/* grid: justified rows, like a contact sheet */
[data-layout="grid"] .g-track {
  display: flex; flex-wrap: wrap; gap: var(--gap);
  padding: 0 var(--gutter); max-width: 1500px; margin: 0 auto;
}
[data-layout="grid"] .ph { flex: var(--ar) 1 calc(var(--ar) * 230px); }
[data-layout="grid"] .g-track::after { content: ""; flex: 999 1 0; }

/* slideshow: one photo at a time; clicking or swiping changes it instantly (no sliding) */
.g-track { touch-action: pan-y; }
[data-layout="slideshow"] .g-track { padding: 0 var(--gutter); }
[data-layout="slideshow"] .ph { display: flex; justify-content: center; }
[data-layout="slideshow"] .ph:not(.is-current) { display: none; }
[data-layout="slideshow"] .ph-link { height: var(--slideh); max-width: 100%; }
/* a row too wide to fit at full height shows one photo at a time too (desktop) */
@media (min-width: 761px) {
  [data-layout="row"].is-single .g-track { display: block; }
  [data-layout="row"].is-single .ph { display: flex; justify-content: center; max-width: none; }
  [data-layout="row"].is-single .ph:not(.is-current) { display: none; }
  [data-layout="row"].is-single .ph-link { height: var(--slideh); max-width: 100%; }
}

.g-ctl {
  display: none; justify-content: center; align-items: center; gap: 18px;
  margin-top: 10px; font: 400 calc(var(--small-size) * .92)/1 var(--sans); color: var(--muted); user-select: none;
}
.g-ctl button { display: none; }   /* no arrows: the counter cursor (or a swipe) changes the photo */
.g-ctl button:disabled { opacity: .25; cursor: default; }

/* ---------- phones ---------- */
@media (max-width: 760px) {
  :root { --gap: 8px; }
  .top { flex-direction: column; align-items: flex-start; gap: 4px; font-size: var(--menu-size); padding-top: max(12px, env(safe-area-inset-top)); }
  .nav { justify-content: flex-start; font-size: calc(var(--menu-size) * .94); }
  .nav .sep { padding: 0 .45em; }
  .nav a:first-child .long { display: none; }
  .bottom { position: static; padding: 0 var(--gutter) max(24px, env(safe-area-inset-bottom)); }
  main { padding: 112px 0 12vh; }
  .work { margin-bottom: 16vh; }
  .w-text { font-size: var(--text-size); text-align: left; }
  .p-index { text-align: left; font-size: calc(var(--menu-size) * .94); }
  .contact { font-size: calc(var(--text-size) * .94); }

  /* swipe mode: one photo at a time; swipe or tap the arrows to change it instantly.
     The frame keeps one height for the whole set, so the title doesn't jump around. */
  .mobile-swipe .gallery .g-track {
    display: block; padding: 0 var(--gutter); max-width: none;
    height: min(calc((100vw - 2 * var(--gutter)) / var(--minar)), var(--mob-h, 72svh));
  }
  .mobile-swipe .gallery .g-track::after { display: none; }
  .mobile-swipe .gallery .ph { display: block; height: 100%; max-width: none; }
  .mobile-swipe .gallery .ph:not(.is-current) { display: none; }
  .mobile-swipe .gallery .ph-link { width: 100%; height: 100%; max-width: none; aspect-ratio: auto; background: none; }

  /* stack mode: photos one under another, full width */
  .mobile-stack .gallery .g-track { display: flex; flex-direction: column; gap: 10px; padding: 0 var(--gutter); overflow: visible; }
  .mobile-stack .gallery .ph { flex: none; max-width: none; width: 100%; }
  .mobile-stack .gallery .ph-link { height: auto; width: 100%; }
}

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

/* ---------- flip scrolling: one project per screen ---------- */
html.flip {
  scroll-snap-type: y mandatory;
  /* 620px, unless the window is too short to fit it with the menu and caption */
  --rowh: min(var(--photoh), calc(100svh - 240px));
  --slideh: min(var(--photoh), calc(100svh - 240px));
}
.flip main { padding: 0; min-height: 0; }
.flip .work { margin: 0; }
.flip .screen {
  min-height: 100vh; min-height: 100svh;
  display: flex; flex-direction: column; justify-content: center;
  padding: 64px 0 52px;
  scroll-snap-align: start; scroll-snap-stop: always;
}
.flip .screen > .w-text:first-child { margin-top: 0; }
.flip .p-index { margin: 0 auto; }
.p-hint { text-align: center; font: 20px var(--serif); color: var(--muted); margin: 6vh 0 0; }

@media (max-width: 760px) {
  .flip .screen { padding: 96px 0 44px; }
  html.flip { --mob-h: calc(100svh - 280px); }
  html.flip .bottom {
    position: fixed; padding: 8px var(--gutter) max(10px, env(safe-area-inset-bottom));
    font-size: calc(var(--menu-size) * .82);
  }
  html.flip .bottom > :nth-child(2) { display: none; }
}

/* photo number under the photos (phones and tablets only — see the counter cursor below) */
.gallery:not([data-n="1"]) .g-ctl { display: flex; }
.gallery:not(.is-single) .g-ctl { display: none; }

/* the photo counter: on a computer the cursor over a photo becomes "2 / 12";
   on phones and tablets (no cursor) the number shows under the photo instead */
@media (hover: hover) and (pointer: fine) {
  .gallery .g-ctl { display: none !important; }
  html.counter-on, html.counter-on * { cursor: none !important; -webkit-user-select: none; user-select: none; }
}
.cursor-count {
  position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none;
  transform: translate(-50%, -50%); white-space: nowrap;
  font: 400 var(--counter-size)/1 var(--sans); letter-spacing: .02em;
  color: #fff; mix-blend-mode: difference;   /* readable on light and dark photos alike */
  opacity: 0; transition: opacity .12s;
}
.cursor-count.on { opacity: 1; }
/* a small solid arrowhead beside the number: on the left when a click goes back, on the right when it goes on */
.cursor-count[data-dir="prev"]::before, .cursor-count[data-dir="next"]::after {
  content: ""; display: inline-block; width: .4em; height: .7em; vertical-align: -.02em;
  background: currentColor;
  -webkit-mask: var(--chev) center / contain no-repeat; mask: var(--chev) center / contain no-repeat;
}
.cursor-count[data-dir="prev"]::before {
  margin-right: .5em;
  --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 6 10'%3E%3Cpath d='M6 0v10L0 5z'/%3E%3C/svg%3E");
}
.cursor-count[data-dir="next"]::after {
  margin-left: .5em;
  --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 6 10'%3E%3Cpath d='M0 0v10l6-5z'/%3E%3C/svg%3E");
}

/* ---------- project title on the left, centred up and down the page (computers) ----------
   The photos keep an equal margin on both sides, so they stay in the middle of the page. */
:root { --side: clamp(150px, 15vw, 240px); }   /* width of the title column */
@media (min-width: 761px) {
  .flip .screen { position: relative; }
  .flip .gallery.has-head { position: static; }       /* so the title centres on the whole screen */
  .gallery.has-head .g-track { padding-left: calc(var(--gutter) + var(--side)); padding-right: calc(var(--gutter) + var(--side)); }
  .gallery.has-head > .w-head {
    position: absolute; left: var(--gutter); top: 50%; transform: translateY(-50%);
    width: calc(var(--side) - 20px); margin: 0; padding: 0; text-align: left;
  }
  .gallery.has-head > .w-head .w-cap { margin: 6px 0 0; max-width: none; }
  /* photos too wide for the middle move over to the right of the title */
  .gallery.has-head.shifted .g-track { padding-right: var(--gutter); }
}
/* phones (upright): the title and caption sit centred under the photo */
@media (max-width: 760px) {
  /* each photo sits at the bottom of its frame, so the number, title and caption are right under it */
  .mobile-swipe .gallery .ph-link img { object-position: center bottom; }
  .gallery.has-head > .w-head { text-align: center; }
  .gallery.has-head > .w-head .w-cap { margin-left: auto; margin-right: auto; }
  /* under the photo: project title, then the photo number, then the caption */
  .gallery.has-head { display: flex; flex-direction: column; }
  .gallery.has-head > .g-track { order: 1; }
  .gallery.has-head > .w-head { display: contents; }
  .gallery.has-head > .w-head > .w-title { order: 2; margin-top: 14px; padding: 0 var(--gutter); }
  .gallery.has-head > .g-ctl { order: 3; margin-top: 4px; }
  .gallery.has-head > .w-head > * { order: 4; padding: 0 var(--gutter); }
  .gallery.has-head > .w-head > .w-cap { margin-top: 4px; }
}

/* pinned title: stays still while the photos scroll, and rolls over to the next project */
.fixed-head { display: none; }
html.fixed-titles .gallery.has-head > .w-head { visibility: hidden; }
html.fixed-titles .fixed-head {
  /* the title line sits just above the middle of the screen and never moves; place and caption hang below it */
  display: block; position: fixed; z-index: 5; left: var(--gutter); top: calc(50% - 1.6em);
  width: calc(var(--side) - 20px); overflow: hidden; text-align: left;
}
.fixed-head .w-cap { margin: 6px 0 0; max-width: none; }
.fh-layer { transition: transform .55s cubic-bezier(.25, .8, .25, 1), opacity .55s ease; }
/* projects page: no pinned title while the project's opening text is showing (it fades in with the photos) */
.fixed-head.on-text .fh-layer:not(.out) { opacity: 0; }
.fh-layer.out { position: absolute; top: 0; left: 0; right: 0; opacity: 0; }
.fh-layer.to-above { transform: translateY(-100%); }
.fh-layer.to-below { transform: translateY(100%); }
.fh-layer.from-below { transform: translateY(100%); opacity: 0; transition: none; }
.fh-layer.from-above { transform: translateY(-100%); opacity: 0; transition: none; }
@media (prefers-reduced-motion: reduce) { .fh-layer { transition: none; } }

/* clicking quickly through photos must never select them (no blue highlight), and photos can't be dragged off */
.g-track, .g-track * { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
.g-track img { -webkit-user-drag: none; }
.g-track ::selection, .g-track::selection { background: transparent; }

/* ---------- index and portraits: chosen photos scattered at random sizes and places ----------
   The page is split into 24 invisible columns (12 on phones). site.js gives each photo a random
   size (extra small to large), a random starting column and a random drop, on every visit. */
.picks {
  display: grid; grid-template-columns: repeat(24, minmax(0, 1fr));
  column-gap: 0; row-gap: clamp(36px, 7vh, 90px);
  padding: 4vh var(--gutter) 0; align-items: start;
}
.pick { display: block; grid-column: span 3; }
.pick-ph { margin: 0; }
.pick-ph .ph-link { width: 100%; aspect-ratio: var(--ar); background: none; }
.pick-ph img { width: 100%; height: 100%; object-fit: cover; transition: opacity .2s; }
.pick:hover img { opacity: .88; }
@media (max-width: 760px) {
  .picks { grid-template-columns: repeat(12, minmax(0, 1fr)); row-gap: 44px; }
}

/* contact page in two columns: details on the left, clients / press / exhibitions on the right */
.contact--cols {
  max-width: none; display: flex; justify-content: space-between; align-items: flex-start; gap: 48px;
  padding: 0 calc(var(--gutter) + 100px); text-align: left;   /* brought in ~100px from each edge */
}
.contact--cols .c-left { flex: 0 1 320px; text-align: left; }
.contact--cols .c-right { flex: 0 1 640px; text-align: right; }
.contact--cols .c-right hr { margin-left: auto; margin-right: 0; }
.contact--cols .c-left hr { margin-left: 0; }
/* computers: the two columns start at the same height, and together sit in the middle of the screen */
@media (min-width: 761px) {
  .page-contact main { min-height: 100vh; min-height: 100svh; padding: 80px 0; display: flex; align-items: center; }
  .page-contact .contact--cols { width: 100%; align-items: flex-start; }   /* tops line up; the block is centred */
  .contact--cols .c-left > :last-child, .contact--cols .c-right > :last-child { margin-bottom: 0; }
  /* the left column starts level with the first line under the "clients:" heading (one line + paragraph gap) */
  .contact--cols .c-left { padding-top: calc(1.45em + 1.1em); }
}
@media (max-width: 760px) {
  .contact--cols { flex-direction: column; gap: 8px; padding: 0 var(--gutter); }
  .contact--cols .c-left, .contact--cols .c-right { flex: none; text-align: left; }
  .contact--cols .c-right hr { margin-left: 0; }
}

/* the project name above a description that comes before the photos: phones only */
.w-text .t-phone { display: none; }
@media (max-width: 760px) { .w-text .t-phone { display: block; margin: 0 0 1.2em; font: 400 var(--small-size)/1.45 var(--serif); } }

/* projects page: the description is the first "slide", in the photo's place (same height, centred);
   a description too long for that space scrolls inside it */
.ph-text .ph-textbox {
  height: var(--slideh); width: 100%; max-width: 640px; margin: 0 auto;
  display: flex; flex-direction: column; overflow-y: auto; scrollbar-width: thin;   /* scrolling carries on to the page */
}
.ph-text .w-text { margin: auto 0; padding: 0; max-width: none; }   /* centred up and down when it fits */
.ph-text .w-text > :last-child { margin-bottom: 0; }
/* the project title at the top of its description: the body text font, bold and a little bigger, with a space below */
.ph-text .t-title { font: 400 var(--title-size)/1.3 var(--serif); margin: 0 0 1.4em; text-align: left; }
/* the text can be selected and its links clicked (the photo area otherwise blocks selection) */
.g-track .ph-text, .g-track .ph-text * { -webkit-user-select: text; user-select: text; }
@media (max-width: 760px) {
  /* phones: the text panel grows to fit, and the page scrolls through it */
  .mobile-swipe .gallery.on-text .g-track { height: auto; }
  .mobile-swipe .gallery .ph-text .ph-textbox { height: auto; max-width: none; overflow: visible; }
  .ph-text .w-text { font-size: calc(var(--text-size) * .88); }   /* a little smaller on phones */
  .gallery.on-text > .w-head > .w-title { display: none; }        /* no project title under the text */
}

/* projects page: descriptions are justified (straight edges on both sides) */
.works--projects .w-text { text-align: justify; -webkit-hyphens: auto; hyphens: auto; }
.works--projects .w-text hr { margin-left: auto; margin-right: auto; }

/* arriving at a particular project or photo: hidden for a moment while it's put in place */
html.arriving { scroll-behavior: auto; }
html.arriving main, html.arriving .fixed-head, html.arriving .cursor-count { visibility: hidden; }
/* home / portraits: hidden until the photos have their random sizes and places (shown anyway after 2.5s) */
html.js:not(.js-late) .picks[data-scatter]:not(.is-scattered) { visibility: hidden; }

/* ---------- phones held sideways (wide but short screens) ----------
   The window is wide enough for the computer layout (title on the left), but only ~400px tall,
   so the photos would come out tiny. Let them use nearly the whole height, slim the menu, and keep
   clear of the iPhone's notch and rounded corners. */
@media (orientation: landscape) and (max-height: 500px) {
  :root { --gutter: max(16px, env(safe-area-inset-left), env(safe-area-inset-right)); --side: clamp(130px, 18vw, 200px); }
  .top { padding-top: 8px; padding-bottom: 8px; font-size: calc(var(--menu-size) * .85); }
  html.flip { --rowh: calc(100svh - 78px); --slideh: calc(100svh - 78px); }
  .flip .screen { padding: 40px 0 10px; }
  .gallery .g-ctl { margin-top: 4px; }
  main { padding-top: 64px; }
  .flip main { padding-top: 0; }
}
/* sideways on a touch screen: the photo number sits under the photo and takes a little room */
@media (orientation: landscape) and (max-height: 500px) and (hover: none) {
  html.flip { --rowh: calc(100svh - 96px); --slideh: calc(100svh - 96px); }
}
.pick--solo { cursor: default; }
