/* CropNow, Blog: the photographs and the stories, one page.
 *
 * The photographs are a field behind the whole page, at three depths
 * (blog-gallery.js places and moves them with the scroll and the hand): far
 * ones small and faded into the chalk, near ones large and full. At the top
 * they fill the window around the title; further down a soft mist of chalk
 * gathers behind the stories' column, and the photographs carry on in the
 * margins. Without JavaScript the photographs are a strip to scroll sideways.
 */

/* -- Without JavaScript: a strip ------------------------------------------------------- */

.bg__field {
  height: 60vh;
  overflow-x: auto;
  padding-top: calc(var(--header-h) + 1rem);
}

.bg__photos {
  display: flex;
  gap: 10px;
  height: 100%;
  margin: 0;
  padding: 0 var(--gutter);
  list-style: none;
}

.bg__photo {
  flex: none;
  height: 100%;
  aspect-ratio: var(--r);
}

.bg__link {
  display: block;
  width: 100%;
  height: 100%;
}

.bg__link img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  -webkit-user-drag: none;
  user-select: none;
}

.bg__link:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}

.bg__mist {
  display: none;
}

/* -- The field, behind the whole page ------------------------------------------------------- */

.bg-live .bg__field {
  position: fixed;
  inset: 0;
  z-index: 0;
  height: auto;
  padding: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: pan-y;
  user-select: none;
}

.bg-live .bg__field.is-dragging {
  cursor: grabbing;
}

.bg-live .bg__photos {
  position: absolute;
  inset: 0;
  display: block;
  padding: 0;
}

.bg-live .bg__photo {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform;
}

/* Each depth's strength: far ones fade into the chalk; one pointed at comes up. */
.bg-live .bg__link {
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 .8rem 1.6rem -1rem rgb(13 59 9 / calc(var(--light, 1) * .5));
  opacity: calc(.25 + var(--light, 1) * .75);
  transition: opacity .35s var(--ease);
}

.bg-live .bg__link img {
  filter: saturate(calc(.5 + var(--light, 1) * .5));
  transition: filter .35s var(--ease), scale .5s var(--ease);
}

.bg-live .bg__photo.is-lit .bg__link {
  opacity: 1;
}

.bg-live .bg__photo.is-lit img {
  filter: none;
  scale: 1.03;
}

/* The mist behind the stories' column: solid chalk in the middle, soft at its edges. */
.bg-live .bg__mist {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  z-index: 10;
  display: block;
  width: calc(var(--read, 56rem) + 8rem);
  max-width: 100vw;
  background: linear-gradient(90deg, rgb(248 250 247 / 0), var(--chalk) 4rem, var(--chalk) calc(100% - 4rem), rgb(248 250 247 / 0));
  opacity: 0;
  translate: -50% 0;
  pointer-events: none;
}

/* The page's words sit above the field. Only what can be used catches the
 * pointer, so the field can be dragged anywhere else, even under the words. */
.bg-live main {
  position: relative;
  z-index: 1;
}

.bg-live main > .bg,
.bg-live main > .b-hero,
.bg-live main > .b-body {
  position: relative;
  z-index: 1;
  pointer-events: none;
}

.bg-live main a,
.bg-live main button,
.bg-live main summary,
.bg-live main [tabindex],
.bg-live main dialog {
  pointer-events: auto;
}

/* The stories keep to a reading column on wide screens, with photographs either side. */
.page-blog {
  --read: 56rem;
}

@media (min-width: 1000px) {
  .bg-live.page-blog .b-hero {
    width: min(var(--read), 100vw - 2 * var(--gutter));
  }

  .bg-live.page-blog .b-body {
    width: min(calc(var(--read) - 4rem), 100vw - 2 * var(--gutter));
  }
}

/* On a phone the column is the screen: the mist covers it, softly. */
@media (max-width: 999px) {
  .bg-live .bg__mist {
    width: 100vw;
    background: rgb(248 250 247 / .94);
  }
}

/* The village at the page's edges would only crowd the photographs. */
.bg-live.page-blog .edge {
  display: none;
}

/* -- The title, over the field --------------------------------------------------------------- */

.bg {
  position: relative;
  display: grid;
  align-content: end;
  min-height: 100vh;
  min-height: 100svh;
  padding: calc(var(--header-h) + 1rem) var(--gutter) clamp(2rem, 7vh, 4rem);
}

.bg:not(.bg-live *) {
  min-height: 0;
}

.bg__title {
  max-width: 40rem;
  padding: 1.6rem 2rem 1.4rem 0;
  background: radial-gradient(ellipse at 20% 60%, rgb(248 250 247 / .92) 0, rgb(248 250 247 / .75) 45%, rgb(248 250 247 / 0) 72%);
}

.bg__kicker {
  margin: 0;
  color: var(--green);
  font: 600 .78rem/1.2 var(--font-text);
  letter-spacing: .16em;
  text-transform: uppercase;
}

.bg__h1 {
  margin: .4rem 0 0;
  font-family: var(--font-display);
  font-size: clamp(3.4rem, 1.6rem + 5.6vw, 7.6rem);
  font-weight: 900;
  line-height: .86;
}

.bg__h1 .dot {
  color: var(--green);
}

.bg__count {
  max-width: 28rem;
  margin: .7rem 0 0;
  color: rgb(13 59 9 / .82);
  font-size: 1rem;
  line-height: 1.5;
}

.bg__hint {
  position: absolute;
  top: calc(var(--header-h) + .4rem);
  left: 50%;
  margin: 0;
  padding: .45rem .95rem;
  border: 1px solid rgb(13 59 9 / .12);
  border-radius: 999px;
  background: rgb(248 250 247 / .9);
  color: rgb(13 59 9 / .75);
  font-size: .76rem;
  font-weight: 600;
  letter-spacing: .06em;
  white-space: nowrap;
  translate: -50% 0;
  transition: opacity .8s var(--ease), translate .8s var(--ease);
}

.bg__hint.is-gone {
  opacity: 0;
  translate: -50% -.4rem;
}

body:not(.bg-live) .bg__hint {
  display: none;
}

/* The name of the photograph under the pointer, at the window's corner. */
@media (max-width: 760px) {
  .bg {
    min-height: 88svh;
  }

  .bg__h1 {
    font-size: 3.6rem;
  }

  .bg__count {
    font-size: .9rem;
  }

  .bg__hint {
    font-size: .68rem;
  }

}

/* The stories follow straight on. */
.page-blog .bg + .b-hero {
  padding-top: clamp(2rem, 6vh, 4rem);
}

/* -- The viewer -------------------------------------------------------------------------- */

.g-viewer {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: #0b1d09;
  color: var(--chalk);
  overflow: hidden;
}

.g-viewer[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.g-viewer::backdrop {
  background: rgb(11 29 9 / .7);
}

.g-viewer__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem var(--gutter);
}

.g-viewer__where {
  margin: 0;
  color: rgb(248 250 247 / .7);
  font-size: .82rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.g-viewer__where span {
  color: #8fd18a;
  font-weight: 700;
}

.g-viewer__where b {
  margin-left: .6rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.g-viewer__btn {
  display: grid;
  place-items: center;
  width: 2.8rem;
  height: 2.8rem;
  padding: 0;
  border: 1px solid rgb(248 250 247 / .25);
  border-radius: 50%;
  background: rgb(248 250 247 / .06);
  cursor: pointer;
  transition: background .25s var(--ease);
}

.g-viewer__btn svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: var(--chalk);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.g-viewer__btn:hover {
  background: var(--chalk);
}

.g-viewer__btn:hover svg {
  stroke: var(--forest);
}

.g-viewer__btn--prev,
.g-viewer__btn--next {
  position: absolute;
  top: 50%;
  translate: 0 -50%;
}

.g-viewer__btn--prev { left: var(--gutter); }
.g-viewer__btn--next { right: var(--gutter); }

.g-viewer__stage {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  justify-items: center;
  gap: .9rem;
  min-height: 0;
  margin: 0;
  padding: 0 calc(var(--gutter) + 3.6rem) .4rem;
  touch-action: pan-y;
}

.g-viewer__img {
  align-self: center;
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
  border-radius: 4px;
  object-fit: contain;
  box-shadow: 0 1.4rem 3rem rgb(0 0 0 / .45);
}

.g-viewer__img.is-entering {
  animation: g-in .45s var(--ease);
}

@keyframes g-in {
  from { opacity: 0; scale: .97; }
}

.g-viewer__strip {
  display: flex;
  gap: 6px;
  margin: 0;
  padding: .7rem var(--gutter) 1rem;
  overflow-x: auto;
  scrollbar-width: none;
  list-style: none;
}

.g-viewer__strip::-webkit-scrollbar {
  display: none;
}

.g-viewer__strip button {
  display: block;
  flex: none;
  height: 3.6rem;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 4px;
  background: none;
  cursor: pointer;
  opacity: .45;
  outline: 2px solid transparent;
  outline-offset: 2px;
  transition: opacity .25s var(--ease), outline-color .25s var(--ease);
}

.g-viewer__strip img {
  display: block;
  width: auto;
  height: 100%;
}

.g-viewer__strip button:hover {
  opacity: .85;
}

.g-viewer__strip button[aria-current="true"] {
  opacity: 1;
  outline-color: var(--green);
}

@media (max-width: 640px) {
  .g-viewer__stage {
    padding: 0 .6rem .4rem;
  }

  .g-viewer__btn--prev,
  .g-viewer__btn--next {
    display: none;
  }

  .g-viewer__strip button {
    height: 3rem;
  }
}

html[data-motion="paused"] .g-viewer__img {
  animation: none !important;
}

/* The header reads over the photographs on a breath of chalk. */
.bg-live.page-blog .site-header {
  background: linear-gradient(180deg, rgb(248 250 247 / .92) 0, rgb(248 250 247 / .7) 60%, rgb(248 250 247 / 0));
}
