.ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.ambient::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.34;
  background-image:
    linear-gradient(var(--rule) 1px, transparent 1px),
    linear-gradient(90deg, var(--rule) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(circle at 64% 46%, black 0, transparent 68%);
  -webkit-mask-image: radial-gradient(circle at 64% 46%, black 0, transparent 68%);
}

.ambient-tiles {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  mask-image: radial-gradient(circle at 64% 46%, black 0, transparent 68%);
  -webkit-mask-image: radial-gradient(circle at 64% 46%, black 0, transparent 68%);
}

.ambient-orb {
  position: absolute;
  width: 28rem;
  aspect-ratio: 1;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.08;
}

.ambient-orb--violet {
  top: 4%;
  right: 4%;
  background: var(--violet);
}

.ambient-orb--mint {
  right: 28%;
  bottom: -22rem;
  background: var(--mint);
}

.page {
  width: min(100%, calc(var(--page) + (var(--pad-inline) * 2)));
  min-height: 100vh;
  min-height: 100svh;
  margin-inline: auto;
  padding: env(safe-area-inset-top) var(--pad-inline) max(16px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(18px, 3vh, 32px);
}

.masthead {
  position: relative;
  z-index: 3;
  min-width: 0;
  min-height: 74px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 16px clamp(20px, 4vw, 56px);
  border-bottom: 1px solid var(--edge);
  color: var(--dim);
}

.lockup {
  justify-self: start;
  width: max-content;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.lockup .marksvg {
  width: 38px;
  height: auto;
  flex: 0 0 auto;
  opacity: 0.9;
}

.lockup .wm-sm {
  font-size: 22px;
  font-weight: 650;
  line-height: 1;
  letter-spacing: -0.045em;
}

.nav {
  justify-self: end;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: clamp(14px, 2.1vw, 30px);
}

.nav a {
  position: relative;
  padding: 8px 0;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1;
  letter-spacing: 0.035em;
  transition: color 200ms ease;
}

.nav a::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 1px;
  content: "";
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 260ms cubic-bezier(0.32, 0.72, 0, 1);
}

.nav a:hover,
.nav a:focus-visible {
  color: var(--ink-soft);
}

.nav a:hover::after,
.nav a:focus-visible::after {
  transform: scaleX(1);
}

.offsite {
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 7px;
}

.offsite a {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  transition: transform 160ms ease, border-color 160ms ease, background-color 160ms ease;
}

.offsite svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.35;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.62;
  transition: opacity 160ms ease;
}

.offsite .github {
  fill: currentColor;
  stroke: none;
}

.offsite a:hover,
.offsite a:focus-visible {
  transform: translateY(-1px);
  border-color: var(--edge);
  background: var(--panel-soft);
}

.offsite a:hover svg,
.offsite a:focus-visible svg {
  opacity: 1;
}

#view {
  min-width: 0;
  display: grid;
  align-items: center;
  view-transition-name: view;
}

.colophon {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--faint);
  font-size: 12px;
  line-height: 1.2;
}

.heart {
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
  background: var(--violet);
  transform-origin: center;
  transition: background-color 160ms ease;
  animation: heartbeat 2.4s ease-in-out infinite;
  -webkit-mask: url('../svg/heart.svg') center / contain no-repeat;
  mask: url('../svg/heart.svg') center / contain no-repeat;
}

@keyframes heartbeat {
  0%, 55%, 100% { transform: scale(1) }
  10% { transform: scale(1.22) }
  20% { transform: scale(1) }
  30% { transform: scale(1.14) }
  40% { transform: scale(1) }
}

.colophon:hover .heart {
  background: #f05b7f;
}

.by {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--dim);
  transition: color 160ms ease;
}

.by:hover,
.by:focus-visible {
  color: var(--ink-soft);
}

.by img {
  width: 13px;
  height: 15px;
  opacity: 0.74;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(9px);
  }
}

@keyframes view-out {
  to {
    opacity: 0;
    transform: translateY(-4px);
  }
}

::view-transition-group(root),
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

/* the box interpolates its own size, which is most of the smoothness when
   two views are different heights */
::view-transition-group(view) {
  animation-duration: 460ms;
  animation-timing-function: cubic-bezier(0.32, 0.72, 0, 1);
}

::view-transition-old(view) {
  animation: view-out 200ms cubic-bezier(0.4, 0, 0.8, 1) forwards;
}

/* held back until the old one is most of the way out, so the two stop
   fighting over the same pixels */
::view-transition-new(view) {
  animation: view-in 420ms cubic-bezier(0.32, 0.72, 0, 1) 140ms backwards;
}

.no-vt #view {
  animation: view-in 420ms cubic-bezier(0.32, 0.72, 0, 1);
}

@media (max-width: 760px) {
  .page {
    grid-template-rows: auto auto auto;
    gap: 26px;
  }

  .masthead {
    grid-template-columns: 1fr auto;
    row-gap: 8px;
    padding-inline: 18px;
  }

  .offsite {
    justify-self: end;
  }

  .nav {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: stretch;
    justify-content: space-between;
    gap: 18px;
  }

  .nav a {
    font-size: 9px;
  }
}

@media (max-width: 420px) {
  .page {
    padding-inline: 18px;
  }

  .lockup .marksvg {
    width: 34px;
  }

  .lockup .wm-sm {
    font-size: 20px;
  }

  .nav {
    width: 100%;
    gap: 10px;
  }

  .nav a {
    font-size: 9px;
  }
}
