/* The West Room of Arroyo Hall: a sparse grid of photographs that turns into one long row. Every card is placed by
   script.js (x, y, width, height); inside it the page turns in 3D around its left edge, and inside the page the leaf
   tilts under the pointer. One element for GSAP, its child for the CSS. */
:root {
  --wall: #ebe8e2;          /* the wall of the room, a warm white */
  --wall-deep: #e1ddd5;     /* the wall in the corners */
  --ink: #161514;           /* the words */
  --muted: #8b877f;         /* the small words */
  --line: rgba(22, 21, 20, 0.12); /* hairlines */
  --paper: #f6f3ec;         /* the back of the prints */
  --thumb: #161514;         /* the sliding part of the switch */
  --thumb-ink: #f6f3ec;     /* the words on it */
  --accent: #b2502f;        /* the one colour: a terracotta for the room name and the active step */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--wall);
  color: var(--ink);
  font-family: 'Instrument Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  position: relative;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% 40%, var(--wall) 55%, var(--wall-deep) 100%);
  user-select: none;
  -webkit-user-select: none;
}

.grain {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0.32;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .42 0 0 0 0 .38 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ------------------------------------------------------------------ the head */
.head {
  position: relative;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: clamp(10px, 2.4vh, 22px) clamp(14px, 3.4vw, 40px);
  flex: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  text-decoration: none;
  min-width: 0;
}

.brand__mark {
  width: clamp(22px, 5vh, 28px);
  height: clamp(22px, 5vh, 28px);
  flex: none;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.2;
  stroke-linecap: round;
}

.brand__words {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
  min-width: 0;
}

.brand__name {
  font-family: 'Fraunces Variable', Georgia, serif;
  font-weight: 380;
  font-size: clamp(14px, 3.4vh, 19px);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand__show {
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
}

/* the switch: a pill, the four squares that line up, a thumb that slides on a spring */
.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 4px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  box-shadow:
    inset 0 0 0 1px rgba(22, 21, 20, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 1px 2px rgba(22, 21, 20, 0.06),
    0 8px 24px -12px rgba(22, 21, 20, 0.22);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  flex: none;
}

.switch__glyph {
  position: relative;
  width: 12px;
  height: 12px;
  flex: none;
}

.switch__glyph i {
  position: absolute;
  left: 0;
  top: 0;
  width: 4px;
  height: 4px;
  border-radius: 1px;
  background: var(--ink);
}

.switch__track {
  position: relative;
  display: flex;
}

.switch__thumb {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 60px;
  border-radius: 999px;
  background: var(--thumb);
  box-shadow:
    0 1px 1px rgba(0, 0, 0, 0.18),
    0 6px 14px -6px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.switch__shine {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 55%);
}

.switch__opt {
  position: relative;
  appearance: none;
  border: 0;
  background: none;
  margin: 0;
  padding: 7px clamp(12px, 3vw, 16px);
  font: inherit;
  font-size: 12.5px;
  font-weight: 520;
  font-variation-settings: 'wdth' 100;
  letter-spacing: 0.01em;
  color: var(--muted);
  cursor: pointer;
  border-radius: 999px;
  transition: color 0.45s cubic-bezier(.39, .57, .56, 1), font-variation-settings 0.5s cubic-bezier(.39, .57, .56, 1);
}

.switch__opt span {
  display: inline-block;
}

.switch__opt.is-on {
  color: var(--thumb-ink);
  font-variation-settings: 'wdth' 112;
}

.switch__opt:focus-visible,
.zoom__btn:focus-visible {
  outline: 1.5px solid var(--accent);
  outline-offset: 2px;
}

@media (hover: hover) {
  .switch__opt:not(.is-on):hover {
    color: var(--ink);
  }
}

/* ------------------------------------------------------------------ the room */
.view {
  position: relative;
  z-index: 2;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

.view.is-dragging {
  cursor: grabbing;
}

.lens {
  position: absolute;
  inset: 0;
  transform-origin: 50% 50%;
}

.track {
  position: absolute;
  left: 0;
  top: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.edge {
  position: absolute;
  z-index: 3;
  pointer-events: none;
}

.edge--a,
.edge--b {
  left: 0;
  right: 0;
  height: 18px;
}

.edge--a {
  top: 0;
  background: linear-gradient(var(--wall), rgba(235, 232, 226, 0));
}

.edge--b {
  bottom: 0;
  background: linear-gradient(rgba(235, 232, 226, 0), var(--wall));
}

.stage.is-list .edge--a,
.stage.is-list .edge--b {
  top: 0;
  bottom: 0;
  width: 22px;
  height: auto;
  right: auto;
  background: linear-gradient(90deg, var(--wall-deep), rgba(225, 221, 213, 0));
}

.stage.is-list .edge--b {
  left: auto;
  right: 0;
  background: linear-gradient(270deg, var(--wall-deep), rgba(225, 221, 213, 0));
}

/* a work: the card is placed by GSAP, the page turns, the leaf tilts */
.card {
  position: absolute;
  left: 0;
  top: 0;
  width: 100px;
  height: 100px;
  opacity: 0;
}

.card__shadow {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -6px;
  height: 18px;
  transform-origin: 0 50%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(40, 32, 24, 0.34), rgba(40, 32, 24, 0));
  filter: blur(4px);
  opacity: 0.55;
  pointer-events: none;
}

.page {
  position: absolute;
  inset: 0;
  transform-origin: 0 50%;
  transform-style: preserve-3d;
}

.leaf {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}

.face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  border-radius: 1px;
}

.face--front {
  background: #d8d3ca;
  box-shadow:
    0 0 0 1px rgba(22, 21, 20, 0.05),
    0 1px 2px rgba(22, 21, 20, 0.08),
    0 14px 30px -18px rgba(22, 21, 20, 0.45);
  transition: box-shadow 0.6s cubic-bezier(.39, .57, .56, 1);
}

.face--front img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
}

.face--back {
  transform: rotateY(180deg);
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0) 30%),
    var(--paper);
  box-shadow: inset 0 0 0 1px rgba(22, 21, 20, 0.06);
}

/* the back of the print: the gallery stamp, pressed lightly */
.face--back::after {
  content: '';
  position: absolute;
  right: 10%;
  bottom: 10%;
  width: 22%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid rgba(178, 80, 47, 0.28);
}

.shade,
.sheen {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* the shadow of the page while it turns: dark at the spine, opening towards the edge */
.shade {
  background: linear-gradient(90deg, rgba(20, 16, 12, 0.55), rgba(20, 16, 12, 0.08) 45%, rgba(255, 255, 255, 0.08) 80%, rgba(20, 16, 12, 0.2));
  opacity: 0;
}

/* a soft light that slides over the print under the pointer */
.sheen {
  background: radial-gradient(60% 50% at var(--sx, 30%) var(--sy, 20%), rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 70%);
  opacity: 0;
  mix-blend-mode: soft-light;
  transition: opacity 0.6s cubic-bezier(.39, .57, .56, 1);
}

.cap {
  position: absolute;
  display: flex;
  gap: 6px;
  align-items: baseline;
  white-space: nowrap;
  font-size: 10.5px;
  line-height: 1;
  letter-spacing: 0.01em;
  color: var(--ink);
  pointer-events: none;
}

.cap__year {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.cap--tl { left: 0; bottom: calc(100% + 6px); }
.cap--tr { right: 0; bottom: calc(100% + 6px); }
.cap--bl { left: 0; top: calc(100% + 7px); }
.cap--br { right: 0; top: calc(100% + 7px); }

.stage.is-list .cap {
  left: 0;
  right: 0;
  top: auto;
  bottom: calc(100% + 8px);
  justify-content: space-between;
}

.card.is-tiny .cap {
  display: none;
}

@media (hover: hover) {
  .card.is-hover .sheen {
    opacity: 1;
  }

  .card.is-hover .face--front {
    box-shadow:
      0 0 0 1px rgba(22, 21, 20, 0.06),
      0 2px 4px rgba(22, 21, 20, 0.1),
      0 26px 40px -20px rgba(22, 21, 20, 0.55);
  }
}

/* ------------------------------------------------------------------ the foot */
.foot {
  position: relative;
  z-index: 4;
  flex: none;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 10px;
  padding: clamp(8px, 2vh, 18px) clamp(14px, 3.4vw, 40px) clamp(10px, 2.6vh, 22px);
  border-top: 1px solid var(--line);
  margin: 0 clamp(14px, 3.4vw, 40px);
  padding-left: 0;
  padding-right: 0;
}

.room {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.room__name {
  font-family: 'Fraunces Variable', Georgia, serif;
  font-weight: 400;
  font-size: 13px;
  color: var(--accent);
}

.room__count,
.now {
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.now {
  margin: 0;
  text-align: center;
  overflow: hidden;
}

.now__in {
  display: inline-block;
}

.zoom {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 8px;
}

.zoom__btn {
  appearance: none;
  width: 28px;
  height: 28px;
  margin: 0;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.5);
  box-shadow: inset 0 0 0 1px rgba(22, 21, 20, 0.16), 0 4px 12px -8px rgba(22, 21, 20, 0.4);
  color: var(--ink);
  cursor: pointer;
  transition: background-color 0.4s cubic-bezier(.39, .57, .56, 1), opacity 0.4s;
}

.zoom__btn svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
  stroke-linecap: round;
}

.zoom__btn:disabled {
  opacity: 0.35;
  cursor: default;
}

@media (hover: hover) {
  .zoom__btn:not(:disabled):hover {
    background: #fff;
  }
}

.zoom__steps {
  display: flex;
  align-items: end;
  gap: 3px;
  height: 12px;
}

.zoom__steps i {
  display: block;
  width: 1.5px;
  border-radius: 1px;
  background: var(--line);
  transform-origin: 50% 100%;
}

.zoom__steps i:nth-child(1) { height: 5px; }
.zoom__steps i:nth-child(2) { height: 8px; }
.zoom__steps i:nth-child(3) { height: 12px; }

.zoom__steps i.is-on {
  background: var(--accent);
}

@media (max-width: 520px) {
  .now {
    display: none;
  }

  .foot {
    grid-template-columns: 1fr auto;
  }
}

@media (max-height: 460px) {
  .brand__show {
    display: none;
  }
}
