/* The home page: screens glowing in a dark room. One card is always in focus: it grows a
   little, glows in its demo's colour, plays its loop, and its light spills into the room.
   The others rest as stills with a faint glow of their own. */

/* Registered so the room's light can fade from one demo's colour to the next. */
@property --tint {
  syntax: "<color>";
  inherits: true;
  initial-value: #08090B;
}

:root {
  --room: #08090B;
  --ink: #F2F1EE;
  --muted: #8B8A90;
  --tint: #08090B;
  --radius: 14px;
  --gutter: clamp(16px, 4vw, 56px);
  --ease-out: cubic-bezier(.2, .8, .2, 1);

  color-scheme: dark;
  background: var(--room);
  transition: --tint 1.4s ease;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  font: 15px/1.4 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* The light of the card in focus, washing over the room from above. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: radial-gradient(120% 70% at 50% 0%, color-mix(in srgb, var(--tint) 14%, transparent), transparent 72%);
  pointer-events: none;
}

a { color: inherit; }

.masthead {
  padding: calc(env(safe-area-inset-top, 0px) + clamp(20px, 3.2vw, 40px)) var(--gutter) 0;
}

.wordmark {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -.01em;
}

.wordmark span {
  color: var(--muted);
  font-weight: 500;
}

/* The cards sit in the middle of the room; with only one or two they're larger. */
.room {
  flex: 1;
  display: grid;
  align-content: center;
  padding: clamp(40px, 6vw, 88px) var(--gutter);
}

.grid {
  list-style: none;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(44px, 6vw, 88px) clamp(28px, 4.4vw, 64px);
}

.room[data-count="one"] .grid { max-width: 860px; }

@media (min-width: 760px) {
  .room[data-count="two"] .grid,
  .room[data-count="many"] .grid { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 1100px) {
  .room[data-count="many"] .grid { grid-template-columns: repeat(3, 1fr); }
}

.card-link {
  display: block;
  text-decoration: none;
  outline: none;
}

.media {
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius);
  /* A card in focus grows up and out, never down into its caption. */
  transform-origin: 50% 100%;
  transition: transform .8s var(--ease-out);
}

/* The glow is drawn once; waking a card only changes its opacity. */
.media::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow:
    0 0 18px 1px color-mix(in srgb, var(--card) 60%, transparent),
    0 0 90px 14px color-mix(in srgb, var(--card) 30%, transparent);
  opacity: .42;
  transition: opacity .8s ease;
}

.screen {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
  background: color-mix(in srgb, var(--card) 16%, var(--room));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--card) 28%, transparent);
  transition: box-shadow .8s ease;
}

.screen img,
.screen video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.screen video {
  opacity: 0;
  transition: opacity .6s ease;
}

/* Resting screens are a little dimmer. */
.screen::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--room);
  opacity: .16;
  transition: opacity .8s ease;
}

.card.is-awake .media { transform: scale(1.04); }
.room[data-count="one"] .card.is-awake .media { transform: none; }
/* Once lit, the glow breathes slowly. */
.card.is-awake .media::before {
  opacity: 1;
  animation: breathe 5s ease-in-out .8s infinite;
}

@keyframes breathe {
  50% { opacity: .68; }
}

.card.is-awake .screen { box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--card) 80%, white); }
.card.is-awake .screen::after { opacity: 0; }
.card.is-playing video { opacity: 1; }

.card-link:focus-visible .screen {
  outline: 2px solid var(--ink);
  outline-offset: 6px;
}

.caption {
  padding: 18px 2px 0;
}

.title {
  margin: 0;
  font-size: .9375rem;
  font-weight: 550;
  letter-spacing: -.005em;
}

.room[data-count="one"] .title { font-size: 1.0625rem; }

.caption time {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: .8125rem;
  font-variant-numeric: tabular-nums;
}

.foot {
  padding: 0 var(--gutter) calc(env(safe-area-inset-bottom, 0px) + 28px);
  color: var(--muted);
  font-size: .75rem;
  letter-spacing: .02em;
  text-align: center;
}

.foot p { margin: 0; }

.foot a {
  color: var(--ink);
  text-decoration: none;
  text-underline-offset: 3px;
}

.foot a:hover { text-decoration: underline; }

.lost {
  flex: 1;
  display: grid;
  place-content: center;
  gap: 12px;
  padding: var(--gutter);
  text-align: center;
  color: var(--muted);
}

.lost .wordmark { color: var(--ink); font-size: 1.5rem; }
.lost p { margin: 0; }

@media (max-width: 759px) {
  .room { padding-top: 36px; }
  .card.is-awake .media { transform: scale(1.02); }
}

/* Opening a demo: its page colour grows out of the card to fill the screen (home.js). */
.veil {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

/* First visit of a session: the room settles in once, quickly. */
.intro .masthead { animation: appear .9s ease both; }
.intro .card { animation: rise .9s var(--ease-out) both; }
.intro .card { animation-delay: calc(min(var(--i), 6) * 80ms + 120ms); }

@keyframes appear {
  from { opacity: 0; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(24px); }
}

@media (prefers-reduced-motion: reduce) {
  :root,
  .media,
  .media::before,
  .screen,
  .screen::after,
  .screen video { transition: none; }
  .intro .masthead,
  .intro .card,
  .card.is-awake .media::before { animation: none; }
  .card.is-awake .media { transform: none; }
}
