/* =========================================================
   piper.art
   A white wall, a signature, two words. The paintings are
   the only colour and the only design.
   ========================================================= */

:root {
  --wall: #fff;
  --ink: #111;
  --quiet: #9b9b9b;
  --accent: transparent;                      /* the colour of the painting you are standing at */
  --u: 1vh;                                   /* one hundredth of the wall's height; set by script.js */

  --script: "Allison", "Snell Roundhand", "Bradley Hand", cursive;
  --serif: "EB Garamond", "Iowan Old Style", Georgia, serif;
  --ease: cubic-bezier(.22, .8, .2, 1);

  /* a canvas resting just off the wall, and the same canvas lifted */
  --shadow: 0 1px 2px rgba(0, 0, 0, .16), 0 8px 16px -4px rgba(0, 0, 0, .18), 0 28px 48px -14px rgba(0, 0, 0, .36);
  --shadow-up: 0 2px 4px rgba(0, 0, 0, .16), 0 16px 28px -6px rgba(0, 0, 0, .22), 0 52px 84px -22px rgba(0, 0, 0, .46);

  color-scheme: light;
}

/* lights off: the same room, after hours */
:root[data-lights="off"] {
  --wall: #0e0e0e;
  --ink: #efefef;
  --quiet: #7c7c7c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 16px 34px -10px rgba(0, 0, 0, .8);
  --shadow-up: 0 2px 4px rgba(0, 0, 0, .5), 0 34px 64px -16px rgba(0, 0, 0, .9);
  color-scheme: dark;
}

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

html, body { height: 100%; margin: 0; background: var(--wall); overflow: hidden; }
html { transition: background-color .7s ease; }

body {
  transition: background-color .7s ease, color .7s ease;
  color: var(--ink);
  font: 400 18px/1.6 var(--serif);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
.script { font-family: var(--script); font-weight: 400; }
:focus-visible { outline: 1px solid currentColor; outline-offset: 6px; }

/* ---------- the only fixed things ---------- */

/* White ink + difference blending reads as black on the wall and
   stays legible when a painting passes behind it. */
.ui {
  position: fixed; z-index: 30;
  color: #fff; mix-blend-mode: difference;
  opacity: 0; transition: opacity 1.4s ease .3s;
}
.is-ready .ui { opacity: 1; }

.sig {
  top: clamp(12px, 3vh, 32px);
  left: clamp(20px, 3.4vw, 56px);
  font: 400 clamp(54px, calc(6.4vh + 20px), 88px)/1 var(--script);
  padding: 4px 6px 0 0;
}

/* The full stop after the signature. It sits outside the signature itself so its colour is not
   inverted by the blending above; script.js places it on the signature's baseline. */
.sig__anchor { display: inline-block; width: 0; height: 0; }
.sig-mark {
  position: fixed; z-index: 30; left: -99px; top: -99px;
  width: 12px; height: 12px; overflow: visible; pointer-events: none;
  fill: var(--mark, var(--ink));
  opacity: 0; transition: fill .5s ease, opacity 1.4s ease .3s;
}
.is-ready .sig-mark { opacity: 1; }
.sig-mark.pop { animation: mark-pop .55s var(--ease); }
@keyframes mark-pop { from { transform: scale(.2) rotate(-50deg); } }

.nav {
  right: clamp(20px, 3.6vw, 60px);
  bottom: clamp(12px, 3.2vh, 34px);
  display: flex; gap: clamp(20px, 2.6vw, 42px);
  font: 400 clamp(32px, calc(3vh + 16px), 46px)/1 var(--script);
}
.nav a { padding: 6px 2px; transition: opacity .35s ease; }
.nav a:hover { opacity: .55; }
.nav a[aria-current="page"] { opacity: .35; }

.close {
  top: clamp(14px, 3.4vh, 38px);
  right: clamp(14px, 3.2vw, 52px);
  display: grid; place-items: center;
  width: 44px; height: 44px; padding: 0; border: 0; background: none;
  cursor: pointer; pointer-events: none;
}
.close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1; }
.is-ready .close { opacity: 0; transition: opacity .4s ease; }
.is-ready.in-view .close { opacity: 1; pointer-events: auto; }

/* lights: one small half-moon, bottom left */
.lights {
  left: clamp(14px, 3vw, 50px);
  bottom: clamp(10px, 3vh, 32px);
  display: grid; place-items: center;
  width: 44px; height: 44px; padding: 0; border: 0; background: none;
  cursor: pointer;
}
.lights i {
  width: 12px; height: 12px; border-radius: 50%;
  border: 1px solid currentColor;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
  transition: rotate .7s var(--ease);
}
.lights:hover i { rotate: 30deg; }
[data-lights="off"] .lights i { rotate: 180deg; }
[data-lights="off"] .lights:hover i { rotate: 210deg; }

/* the wall's index: one quiet shape per painting; the one in front of you takes its colour */
.index {
  position: fixed; z-index: 30;
  left: 50%; bottom: clamp(10px, 3vh, 32px); translate: -50% 0;
  display: flex; margin: 0; padding: 0; list-style: none;
  opacity: 0; transition: opacity 1.4s ease .5s;
}
.is-ready .index { opacity: 1; }
.is-ready[data-view="about"] .index,
.is-ready[data-view="contact"] .index { opacity: 0; pointer-events: none; transition: opacity .3s ease; }

.index button {
  display: grid; place-items: center;
  width: 26px; height: 44px; padding: 0; border: 0; background: none; cursor: pointer;
}
.index svg {
  width: 10px; height: 10px; overflow: visible;
  fill: transparent; stroke: var(--ink); stroke-width: 2.6;
  opacity: .38;
  transition: fill .5s ease, stroke .5s ease, opacity .5s ease, scale .5s var(--ease);
}
.index button:hover svg { opacity: .9; }
.index button[aria-current="true"] svg { fill: var(--c); stroke: var(--c); opacity: 1; scale: 1.2; }

/* a hairline that fills as you walk the wall */
.progress {
  position: fixed; z-index: 6; left: 0; right: 0; bottom: 0; height: 1px;
  background: var(--accent);
  transform: scaleX(0); transform-origin: left;
  transition: background-color .6s ease, opacity .4s ease;
}
.in-view .progress { opacity: 0; }

.arrow {
  position: fixed; top: 50%; z-index: 5;
  display: grid; place-items: center;
  width: 64px; height: 64px; margin-top: -32px; padding: 0; border: 0; background: none;
  color: #fff; mix-blend-mode: difference;
  opacity: 0; pointer-events: none; cursor: pointer;
  transition: opacity .6s ease, translate .4s var(--ease);
}
.arrow svg { width: 34px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1; }
.arrow--left { left: clamp(4px, 1.4vw, 26px); }
.arrow--right { right: clamp(4px, 1.4vw, 26px); }
.arrow.is-on { opacity: 1; pointer-events: auto; }
.arrow--left:hover { translate: -5px 0; }
.arrow--right:hover { translate: 5px 0; }
@media (hover: none) { .arrow { display: none; } }

/* ---------- the wall ---------- */

.gallery {
  position: fixed; inset: 0;
  overflow-x: auto; overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  outline: none;
}
.gallery::-webkit-scrollbar { display: none; }

.wall { position: relative; height: 100%; min-width: 100%; }

.piece {
  position: absolute; display: block;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  will-change: translate;
}
.piece.is-away { visibility: hidden; }
.piece:focus-visible { outline-offset: 10px; }

.piece__lift {
  display: block; width: 100%; height: 100%;
  background: rgba(128, 128, 128, .08);
  box-shadow: var(--shadow);
  opacity: 0; transform: translateY(calc(var(--u) * 1.8));
  transition: opacity 1.1s ease, transform 1.4s var(--ease), scale .38s var(--ease), box-shadow .38s ease;
}
.piece.is-hung .piece__lift { opacity: 1; transform: none; }

.piece img {
  display: block; width: 100%; height: 100%;
  user-select: none; -webkit-user-drag: none;
}

/* plates and other round pieces: the same canvas rules, with a circular edge and shadow */
.piece.is-round .piece__lift,
.piece.is-round img,
.detail.is-round .detail__img,
.zoom.is-round img { border-radius: 50%; }

/* bowls, vases and other objects cut out of their photos: the shadow follows the object's own outline */
.piece.is-cutout .piece__lift {
  background: none; box-shadow: none;
  filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, .22)) drop-shadow(0 14px 16px rgba(0, 0, 0, .26));
  transition: opacity 1.1s ease, transform 1.4s var(--ease), scale .38s var(--ease), filter .38s ease;
}
.detail.is-cutout .detail__img {
  box-shadow: none;
  filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, .22)) drop-shadow(0 16px 20px rgba(0, 0, 0, .26));
}
@media (hover: hover) {
  .piece.is-cutout:hover .piece__lift {
    box-shadow: none;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .22)) drop-shadow(0 26px 28px rgba(0, 0, 0, .34));
  }
}
.piece.is-cutout:focus-visible .piece__lift { box-shadow: none; }

.piece__title {
  position: absolute; left: 2px; top: 100%;
  margin-top: calc(var(--u) * 1.4);
  font: 400 clamp(28px, calc(var(--u) * 3.8), 40px)/1.05 var(--script);
  width: max-content; max-width: calc(var(--u) * 26);      /* a short title stays on one line; a long one wraps */
  pointer-events: none;
  opacity: 0; translate: 0 5px;
  transition: opacity .38s ease, translate .38s var(--ease);
}
/* the script hangs each title beside its painting, on clear wall (see placeTitle in script.js);
   if it cannot find room anywhere, the title sits underneath */
.piece__title[data-side] { margin-top: 0; }
.piece__title[data-side="right"] { translate: -6px 0; }
.piece__title[data-side="left"] { translate: 6px 0; text-align: right; }
.piece__title[data-side="above-end"] { text-align: right; }

.piece__title.is-long { font-size: clamp(22px, calc(var(--u) * 2.9), 30px); }

/* the year, beside a painting's name: small, quiet, printed rather than handwritten */
.year {
  margin-left: .8em;
  font: 400 clamp(14px, .38em, 19px)/1 var(--serif);
  letter-spacing: .05em;
  color: var(--ink); opacity: .62;      /* quieter than the name, but still readable over a painting's shadow */
  white-space: nowrap;
}
.piece__title .year { font-size: clamp(14px, .44em, 17px); }

@media (hover: hover) {
  .piece:hover .piece__lift { scale: 1.025; box-shadow: var(--shadow-up); }
  .piece:hover .piece__title { opacity: 1; translate: 0 0; }
}
.piece:focus-visible .piece__lift { scale: 1.025; box-shadow: var(--shadow-up); }
.piece:focus-visible .piece__title { opacity: 1; translate: 0 0; }

/* ---------- views that open over the wall ---------- */

.view {
  position: fixed; inset: 0; z-index: 10;
  visibility: hidden; pointer-events: none;
  transition: visibility 0s linear .6s;
}
.view.is-open, .view.is-flying { visibility: visible; transition-delay: 0s; }
.view.is-open { pointer-events: auto; }

.view__bg {
  position: absolute; inset: 0; background: var(--wall);
  opacity: 0; transition: opacity .5s ease, background-color .7s ease;
}
.view.is-open .view__bg { opacity: 1; }

/* a painting, up close */
.detail {
  --ar: .8;
  position: relative; height: 100%;
  display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(260px, 1fr);
  align-items: center; gap: clamp(32px, 6vw, 110px);
  padding: 10vh clamp(48px, 9vw, 150px) 11vh clamp(72px, 13vw, 220px);
}

.detail__stage {
  container-type: size;
  width: 100%; height: 100%; min-height: 0;
  display: grid; place-items: center;
  opacity: 0; transition: opacity .28s ease;
}
.view--detail.is-open .detail__stage { opacity: 1; }
.view--detail.is-flying .detail__stage { opacity: 1; transition: none; }
.view--detail.is-swapping .detail__stage { opacity: 0; }

.detail__img {
  display: block;
  width: auto; height: min(100cqh, 100cqw / var(--ar));
  aspect-ratio: var(--ar);
  max-width: none;
  box-shadow: var(--shadow);
  transform-origin: 0 0;
  cursor: zoom-in;
  user-select: none; -webkit-user-drag: none;
}
@supports not (height: 1cqh) {
  .detail__img { height: auto; max-width: 100%; max-height: 80vh; }
}

.detail__text {
  max-width: 30rem; max-height: 100%;
  overflow-y: auto; scrollbar-width: none;       /* a long note scrolls inside its own column */
  opacity: 0; translate: 0 10px;
  transition: opacity .25s ease, translate .4s var(--ease);
}
.detail__text::-webkit-scrollbar { display: none; }
/* when the note is longer than the space, it fades out at the bottom to show there is more */
.detail__text.is-long {
  padding-bottom: 48px;
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 48px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 48px), transparent);
}
.view--detail.is-open:not(.is-swapping) .detail__text {
  opacity: 1; translate: 0 0;
  transition: opacity .8s ease .3s, translate 1s var(--ease) .3s;
}

.detail__title {
  margin: 0 0 .3em;
  font-size: clamp(40px, min(5.2vw, 11vh), 88px); line-height: .92;
}
/* a title that is a whole sentence is set smaller, so it reads as a line of handwriting, not a headline */
.detail__title.is-long { font-size: clamp(30px, min(3.3vw, 7.4vh), 56px); line-height: 1.02; margin-bottom: .45em; }
.detail__story p { margin: 0 0 1em; max-width: 38ch; }
/* a link inside the words: a fine underline that firms up when pointed at */
.detail__story a {
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em;
  text-decoration-color: var(--quiet); transition: text-decoration-color .25s ease;
}
.detail__story a:hover, .detail__story a:focus-visible { text-decoration-color: currentColor; }
/* the small print under the words: year, medium, size */
.detail__meta {
  display: grid; grid-template-columns: max-content 1fr; align-items: baseline; gap: .1em 1.2em;
  margin: 1.7em 0 0; max-width: 38ch;
  font-size: 14px; line-height: 1.55;
}
.detail__meta dt { font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--quiet); }
.detail__meta dd { margin: 0; color: var(--ink); opacity: .72; }
.detail__meta:empty, .detail__story:empty, .detail__note:empty { display: none; }
/* the last line of small print: whether it is for sale, and whose it is */
.detail__note { margin: 1.7em 0 0; max-width: 38ch; font-size: 14px; line-height: 1.55; color: var(--ink); opacity: .72; }
.detail__meta:not(:empty) + .detail__note { margin-top: .75em; }

.detail__steps { display: flex; gap: 10px; margin: 2.2em 0 0 -12px; }
.step {
  display: grid; place-items: center;
  width: 58px; height: 44px; padding: 0; border: 0; background: none;
  cursor: pointer; opacity: .5;
  transition: opacity .35s ease, translate .4s var(--ease);
}
.step svg { width: 34px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1; }
.step:hover { opacity: 1; }
.step[data-step="-1"]:hover { translate: -4px 0; }
.step[data-step="1"]:hover { translate: 4px 0; }

.placeholder { color: var(--quiet); font-style: italic; }

/* about and contact: a letter */
.letter {
  position: relative; height: 100%; overflow-y: auto;
  padding: clamp(110px, 16vh, 180px) 28px 150px clamp(28px, 27vw, 480px);
  opacity: 0; translate: 0 12px;
  transition: opacity .3s ease, translate .5s var(--ease);
}
.view.is-open .letter {
  opacity: 1; translate: 0 0;
  transition: opacity .9s ease .2s, translate 1.1s var(--ease) .2s;
}
.letter__inner { max-width: 31rem; }
.letter__hello {
  margin: 0 0 .45em; font-size: clamp(58px, 5.8vw, 92px); line-height: .92;
  width: max-content; max-width: min(100%, 86vw);      /* the opening line may run wider than the letter */
}
.letter__inner > .letter__hello { max-width: calc(100vw - 56px - clamp(28px, 27vw, 480px)); }
.letter p { margin: 0 0 1.1em; }
.letter__sign { margin: .7em 0 0; font-size: 52px; line-height: 1; }
.letter__photo { display: block; width: min(100%, 320px); height: auto; margin: 2.4em 0 0; box-shadow: var(--shadow); }
.letter__line { margin: 0 0 .35em; font-size: 23px; }
.letter__line a { transition: opacity .35s ease; }
.letter__line a:hover { opacity: .5; }
.letter__line span { color: var(--quiet); font-size: 16px; font-style: italic; margin-left: .5em; }

/* closer still */
.zoom {
  position: fixed; inset: 0; z-index: 40;
  overflow: auto; overscroll-behavior: contain; scrollbar-width: none;
  background: transparent;
  visibility: hidden; pointer-events: none; cursor: zoom-out;
  transition: background-color .4s ease, visibility 0s linear .4s;
}
.zoom::-webkit-scrollbar { display: none; }
.zoom.is-open { visibility: visible; pointer-events: auto; background: var(--wall); transition-delay: 0s; }
.zoom.is-closing { visibility: visible; transition-delay: 0s; }
.zoom.is-dragging { cursor: grabbing; }
.zoom__pad { display: flex; width: max-content; min-width: 100%; min-height: 100%; }
.zoom img {
  display: block; margin: auto; max-width: none;
  transform-origin: 0 0;
  user-select: none; -webkit-user-drag: none;
}

/* ---------- phones ---------- */

@media (max-width: 820px) {
  .sig { font-size: 58px; }
  .detail {
    display: block; overflow-y: auto;
    padding: 116px 24px 140px;
  }
  .detail__steps { display: none; }      /* on a phone the three shapes step between paintings */
  .detail__stage { height: min(62dvh, calc((100vw - 48px) / var(--ar))); }
  .detail__text { margin-top: 34px; max-height: none; }
  .detail__title { font-size: 56px; }
  .detail__title.is-long { font-size: 36px; }
  .letter { padding: 130px 28px 140px; }
  /* long text fades out before it reaches the signature above or the links below */
  .letter, .detail {
    -webkit-mask-image: linear-gradient(to bottom, transparent 56px, #000 112px, #000 calc(100% - 124px), transparent calc(100% - 70px));
    mask-image: linear-gradient(to bottom, transparent 56px, #000 112px, #000 calc(100% - 124px), transparent calc(100% - 70px));
  }
  /* the shapes move beside the lights so they never sit under "about / contact" */
  .index { left: clamp(52px, 14vw, 70px); translate: none; }
  .index.is-long { display: none; }
}

/* ---------- calmer for people who ask for it ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01s !important; transition-delay: 0s !important; }
  .piece__lift { transform: none; }
  .sig-mark.pop { animation: none; }
}
