:root {
  --ink: #07060c;
  --radius: 28px;
  --rim: 8px;
  /* A bold Clarendon, the face of the THIEL wordmark. Superclarendon ships with macOS and iOS. */
  --display: Superclarendon, Clarendon, "Clarendon BT", "Clarendon LT Std", Besley, Rockwell, "Roboto Slab", Georgia, serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html {
  background: var(--ink);
  scrollbar-width: none;
}

html::-webkit-scrollbar { display: none; }

body {
  margin: 0;
  color: #fff;
  font-family: var(--display);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

/* The scroll distance. The page itself never moves; flight.js reads the offset. */
.track { height: 480vh; }

.poster,
#stage {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100lvh;
}

/* The first frame, shown whole until the canvas takes over. flight.js sets its exact size. */
.poster { background: var(--ink) url(/frames/720/f0000.webp) center / contain no-repeat; }

/* Arriving back from a section, the page opens on the cards, so the sky stands in instead. */
.at-end .poster { background-image: url(/frames/720/f0640.webp); }

/* Opening a card grows its painting into the backdrop of the section, and back. */
@view-transition { navigation: auto; }

::view-transition-group(*) {
  animation-duration: .55s;
  animation-timing-function: cubic-bezier(.2, .7, .2, 1);
}

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
}

#stage {
  display: block;
  opacity: 0;
  transition: opacity .6s ease;
}

#stage.on { opacity: 1; }

/* Three upright cards in a row, as large as the window allows: the column width is the smaller
   of a third of the width and what a 3:4 card can take of the height. */
.cards {
  position: fixed;
  z-index: 2;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100svh;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, min(calc((100vw - 56px) / 3), calc((100svh - 150px) * 3 / 4))));
  gap: 14px;
  place-content: center;
  padding: 14px;
  pointer-events: none;
}

/* Each card is a painting set in a glass frame. The frame is painted by the stage shader
   under the card's box; the painting sits inside it, a rim's width in from the edge. */
.card {
  container-type: inline-size;
  position: relative;
  aspect-ratio: 3 / 4;
  padding: var(--rim);
  border-radius: var(--radius);
  color: #fff;
  text-decoration: none;
  opacity: 0;
  pointer-events: auto;
  will-change: transform, opacity;
  -webkit-tap-highlight-color: transparent;
}

.card:focus-visible {
  outline: 2px solid rgba(255, 255, 255, .9);
  outline-offset: 4px;
}

.card__art {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: calc(var(--radius) - var(--rim) + 1px);
  background: #0b0b12;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .10);
}

.card__art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .7s cubic-bezier(.2, .7, .2, 1);
}

.card:hover .card__art img { transform: scale(1.045); }

/* Darkens the foot of the painting so the lettering reads on any picture. */
.card__art::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(5, 5, 10, .90) 0%, rgba(5, 5, 10, .62) 26%, rgba(5, 5, 10, 0) 60%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .10);
  border-radius: inherit;
}

.card__body {
  position: absolute;
  left: calc(var(--rim) + 6.2cqw);
  right: calc(var(--rim) + 3cqw);
  bottom: calc(var(--rim) + 7.4cqw);
}

.card h2 {
  margin: 0;
  font-size: clamp(16px, 6.1cqw, 36px);
  font-weight: 700;
  letter-spacing: .012em;
  line-height: 1;
  text-transform: uppercase;
}

/* The way in: two words at the top right, in the lettering of the cards. It appears with them. */
.door {
  position: fixed;
  z-index: 3;
  top: max(10px, env(safe-area-inset-top));
  right: max(24px, env(safe-area-inset-right));
  padding: 16px 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .03em;
  line-height: 1.2;
  text-decoration: none;
  text-shadow: 0 1px 16px rgba(0, 0, 0, .7);
  text-transform: uppercase;
  color: #fff;
  opacity: 0;
}

.door:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 8px;
}

.door[hidden] { display: none; }

@media (max-width: 720px) {
  :root {
    --radius: 20px;
    --rim: 6px;
  }

  .track { height: 400vh; }

  /* one column, three rows that share the screen */
  .cards {
    grid-template-columns: minmax(0, 1fr);
    grid-auto-rows: min(260px, calc((100svh - 86px) / 3));
    gap: 8px;
    padding: 58px 12px 12px;
  }

  .card { aspect-ratio: auto; }

  .card__body { bottom: calc(var(--rim) + 5cqw); }

  .door { right: max(20px, env(safe-area-inset-right)); }
}

/* Without WebGL the frame falls back to a plain frosted edge. */
.no-gl .card {
  background: rgba(255, 255, 255, .10);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22), 0 24px 60px rgba(0, 0, 0, .4);
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
  backdrop-filter: blur(22px) saturate(1.3);
}
