@font-face {
  font-family: "Aspekta";
  src: url("https://cdn.jsdelivr.net/gh/ivodolenc/aspekta@2.000/fonts/variable/AspektaVF.woff2")
    format("woff2-variations");
  font-weight: 50 1000;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #14141d;
  --text: #fff;
  --font-display: "Aspekta", "Inter", sans-serif;
  --font-ui: "Inter", system-ui, sans-serif;

  --radius: 16px;
  --caption-size: 18px;
  --wordmark-size: 60px;
  --wordmark-sub-size: 14px;
  --header-pad: 24px;

  --vignette-strength: 0.7;
  --vignette-size: 200px;
  --overlay-opacity: 0.6;
  --overlay-duration: 0.8s;
}

@media (max-width: 809.98px) {
  :root {
    --caption-size: 15px;
    --wordmark-size: 56px;
    --wordmark-sub-size: 15px;
    /* 200px from each side would cover a whole phone screen; keep the middle clear. */
    --vignette-strength: 0.5;
    --vignette-size: 90px;
  }
}

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

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.stage {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: clip;
}

/* ---------- Header & footer (float above the grid) ---------- */

/* Above everything in the gallery, including the vignette while a card closes.
   Clicks pass through so dragging works anywhere. */
.site-header,
.site-footer {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 200;
  padding: 0 16px;
  text-align: center;
  pointer-events: none;
  user-select: none;
  transition:
    opacity var(--overlay-duration) cubic-bezier(0.9, 0, 0.1, 1),
    transform 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.site-header {
  top: 0;
  padding-top: var(--header-pad);
}

.site-footer {
  bottom: 0;
  padding-bottom: 20px;
  /* Keeps the text clear of the replay button in the corner. */
  padding-left: 60px;
  padding-right: 60px;
}

/* Intro: the wordmark waits in the middle of the screen and rises to the top as the
   photos burst out from behind it. gallery.js removes .is-intro when the burst starts. */
.is-intro .site-header {
  transform: translateY(calc(50vh - 50% - var(--header-pad) / 2));
  transform: translateY(calc(50dvh - 50% - var(--header-pad) / 2));
}

.is-intro .site-footer {
  opacity: 0;
}

.is-intro :is(.replay, .wordmark__link) {
  pointer-events: none;
}

.is-intro .replay {
  opacity: 0;
}

/* Step aside while a card is open, in step with the dark overlay. */
body:has(.gallery.is-expanded:not(.is-closing)) :is(.site-header, .site-footer, .replay) {
  opacity: 0;
}

body:has(.gallery.is-expanded:not(.is-closing)) :is(.replay, .wordmark__link) {
  pointer-events: none;
}

/* "Lume Photography" and the corner button both replay the intro. */
.wordmark__link {
  display: inline-block;
  color: inherit;
  text-decoration: none;
  pointer-events: auto;
  cursor: pointer;
  border-radius: 4px;
}

.replay {
  position: fixed;
  right: 16px;
  bottom: 12px;
  z-index: 200;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: rgba(255, 255, 255, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    opacity var(--overlay-duration) cubic-bezier(0.9, 0, 0.1, 1),
    color 0.2s;
}

.replay svg {
  width: 20px;
  height: 20px;
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.replay:hover {
  color: #fff;
}

.replay:hover svg {
  transform: rotate(180deg);
}

:is(.replay, .wordmark__link):focus-visible {
  outline: 2px solid #fff;
  outline-offset: 4px;
}

.site-footer p {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.6);
  opacity: 0;
  animation: fade-in 0.8s cubic-bezier(0.34, 1.25, 0.64, 1) forwards;
}

/* On phones, "All rights reserved." gets its own line. */
@media (max-width: 809.98px) {
  .site-footer__rights {
    display: block;
  }
}

.wordmark {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--wordmark-size);
  font-weight: 450;
  font-variation-settings: "wght" 450;
  text-transform: uppercase;
  letter-spacing: -0.03em;
  line-height: 1em;
  color: var(--text);
  opacity: 0;
  animation: fade-in 0.8s cubic-bezier(0.34, 1.25, 0.64, 1) forwards;
}

.wordmark__sub {
  display: block;
  font-size: var(--wordmark-sub-size);
  font-weight: 400;
  text-transform: uppercase;
  font-variation-settings: "wght" 400;
  letter-spacing: 0;
  line-height: 1.2em;
}

@keyframes fade-in {
  to {
    opacity: 1;
  }
}

/* ---------- Gallery ---------- */

.gallery {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  background: transparent;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none; /* no "Save image" sheet on iOS long-press */
  cursor: grab;
  outline: none;
}

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

.gallery.is-expanded {
  cursor: auto;
}

.gallery__canvas {
  position: absolute;
  left: 0;
  top: 0;
  will-change: transform;
  opacity: 0;
}

/* Shown at once when the burst starts; the tiles animate their own fade. */
.gallery__canvas.is-visible {
  opacity: 1;
}

.gallery__vignette {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 2;
  background:
    linear-gradient(
      to right,
      rgba(0, 0, 0, var(--vignette-strength)) 0%,
      transparent var(--vignette-size),
      transparent calc(100% - var(--vignette-size)),
      rgba(0, 0, 0, var(--vignette-strength)) 100%
    ),
    linear-gradient(
      to bottom,
      rgba(0, 0, 0, var(--vignette-strength)) 0%,
      transparent var(--vignette-size),
      transparent calc(100% - var(--vignette-size)),
      rgba(0, 0, 0, var(--vignette-strength)) 100%
    );
}

/* Keep the vignette above the card while it flies back into the grid. */
.gallery.is-closing .gallery__vignette {
  z-index: 101;
  transition: z-index 0s linear 0.4s;
}

.gallery__overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(0, 0, 0, var(--overlay-opacity));
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--overlay-duration) cubic-bezier(0.9, 0, 0.1, 1);
}

.gallery.is-expanded .gallery__overlay {
  pointer-events: auto;
}

.gallery.is-expanded:not(.is-closing) .gallery__overlay {
  opacity: 1;
}

/* ---------- Tiles ---------- */

.tile {
  position: absolute;
  border-radius: var(--radius);
  overflow: hidden;
  background: #111;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  z-index: 1;
  transition: box-shadow 0.3s;
}

.gallery.is-expanded .tile {
  cursor: auto;
}

.tile.is-expanded {
  opacity: 0;
  pointer-events: none;
  z-index: 11;
}

.tile__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  user-select: none;
  transform: scale(1);
  transition:
    transform 0.2s cubic-bezier(0.4, 0, 0.2, 1),
    filter 0.2s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.25s ease-out;
  will-change: transform;
}

/* Grid photos fade in once loaded; until then the tile's dark background shows. */
.tile .tile__img {
  opacity: 0;
}

.tile .tile__img.is-loaded {
  opacity: 1;
}

.tile.is-hovered .tile__img {
  transform: scale(var(--hover-scale, 1.05));
}

.caption {
  position: absolute;
  left: 0;
  bottom: 0;
  z-index: 2;
  width: 100%;
  height: 50%;
  display: flex;
  /* display: none; */
  flex-direction: column;
  justify-content: flex-end;
  padding: 16px 20px 12px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.5) 100%);
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
  color: #fff;
  font-family: var(--font-ui);
  font-size: var(--caption-size);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2em;
  pointer-events: none;
  user-select: none;
}

/* ---------- Expanded card ---------- */

.card {
  position: fixed;
  z-index: 100;
  perspective: 2000px;
  will-change: left, top, width, height;
  outline: none;
}

.card__inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.card.is-flipped .card__inner {
  transform: rotateY(180deg);
}

.card__face {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.card__front {
  cursor: pointer;
}

.card__front .tile__img {
  transition: none;
  will-change: auto;
}

.card__info {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 3;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    transform 0.2s,
    opacity 0.2s;
}

.card__info svg {
  display: block;
  width: 24px;
  height: 24px;
}

.card__info:hover {
  --info-scale: 1.1;
}

.card__info:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
  border-radius: 6px;
}

.card.is-flipped .card__info {
  opacity: 0 !important;
  pointer-events: none;
}

.card__back {
  transform: rotateY(180deg);
  display: flex;
  flex-direction: column;
  padding: 40px;
  cursor: pointer;
}

.card__back-img {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.card__back-shade {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: rgba(0, 0, 0, var(--overlay-opacity));
}

.card__back-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.card__title {
  margin: 0 0 20px;
  color: #fff;
  font-size: var(--caption-size);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2em;
}

.card__body {
  flex: 1;
  margin: 0;
  overflow-y: auto;
  color: rgb(224, 224, 224);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.6em;
}

@media (max-width: 809.98px) {
  .card__back {
    padding: 28px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .wordmark {
    animation-duration: 0.01s;
  }
  /* No burst or rising wordmark: the gallery simply fades in. */
  .site-header,
  .site-footer {
    transition: opacity 0.3s;
  }
  .gallery__canvas.is-visible {
    transition: opacity 0.6s ease-out;
  }
  .card__inner {
    transition-duration: 0.01s;
  }
}

/* ---------- Background pattern ----------
   Static and drawn once, so it costs nothing while you drag. Chosen by the class on <body>
   in index.html (currently bg-grid). Other options: bg-lines (diagonal hairlines), bg-dots,
   bg-pinstripe and bg-grain (fine film grain). Remove the class for plain black. */

:root {
  --pattern-opacity: 0.08; /* how visible the lines and dots are */
  --grid-size: 120px; /* size of each bg-grid square */
}

body {
  --pattern: rgb(255 255 255 / var(--pattern-opacity));
}

body.bg-lines {
  background-image: repeating-linear-gradient(-45deg, var(--pattern) 0 1px, transparent 1px 22px);
}

body.bg-grid {
  background-image:
    linear-gradient(var(--pattern) 1px, transparent 1px),
    linear-gradient(90deg, var(--pattern) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
  background-position: center;
}

/* Dots are small, so they're drawn a bit brighter than lines to read at the same strength. */
body.bg-dots {
  background-image: radial-gradient(
    circle,
    rgb(255 255 255 / calc(var(--pattern-opacity) * 2.5)) 1.2px,
    transparent 1.7px
  );
  background-size: 24px 24px;
  background-position: center;
}

body.bg-pinstripe {
  background-image: repeating-linear-gradient(90deg, var(--pattern) 0 1px, transparent 1px 40px);
  background-position: center;
}

/* Grain is a tiny noise texture made by the browser from an SVG filter and tiled. */
body.bg-grain {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0.35 0 0 0 -0.12'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
}
