.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: 0;
  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;
  align-items: center;
  gap: 24px;
  padding: 16px clamp(20px, 4vw, 56px);
  border-bottom: 1px solid var(--edge);
  color: var(--dim);
}

html[data-route="spec"] .masthead {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom-color: rgba(37, 35, 31, 0.10);
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.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: none;
  align-items: center;
  gap: 7px;
}

html[data-route="home"] .masthead {
  grid-template-columns: 1fr auto 1fr;
}

html[data-route="home"] .offsite {
  display: flex;
}

.offsite a {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--ink);
  transition: color 180ms ease;
}

.offsite a > * {
  grid-area: 1 / 1;
}

.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 180ms ease, transform 220ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.offsite img {
  width: 15px;
  height: auto;
  opacity: 0.62;
  transition: opacity 180ms ease, transform 220ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.offsite .mark-color { opacity: 0; }

.offsite .pypi .mark-color { width: 19px; }

.offsite a:hover img,
.offsite a:focus-visible img,
.offsite a:hover svg,
.offsite a:focus-visible svg {
  opacity: 1;
  transform: scale(1.3);
}

.offsite a:hover .mark-mono,
.offsite a:focus-visible .mark-mono,
.offsite .pypi:hover svg,
.offsite .pypi:focus-visible svg,
.offsite .rumi:hover svg,
.offsite .rumi:focus-visible svg { opacity: 0; }

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

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

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

html[data-route="home"] .colophon {
  display: flex;
}

.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,
.heart.is-loved { background: #f05b7f; }

.heart.is-loved {
  animation: heart-pop 1100ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes heart-pop {
  0% { transform: scale(1); }
  18% { transform: scale(2.6); }
  34% { transform: scale(1.6); }
  50% { transform: scale(2.2); }
  72% { transform: scale(0.9); }
  100% { transform: scale(1); }
}

.heart-spark {
  position: fixed;
  z-index: 10;
  width: var(--size, 11px);
  height: var(--size, 11px);
  background: var(--tint, #f05b7f);
  pointer-events: none;
  -webkit-mask: url('../svg/heart.svg') center / contain no-repeat;
  mask: url('../svg/heart.svg') center / contain no-repeat;
  animation: heart-spark 1500ms cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

@keyframes heart-spark {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(0.4) rotate(0deg); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.2) rotate(var(--spin)); }
}

.by {
  display: inline-flex;
  align-items: center;
  color: var(--dim);
  text-decoration: none;
  transition: color 160ms ease, text-decoration-color 160ms ease;
}

.by img {
  width: 109px;
  height: auto;
}

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

@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 {
    gap: 26px;
  }

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

  .offsite {
    justify-self: end;
  }

  html[data-route="home"] .masthead {
    grid-template-columns: 1fr auto;
  }

  .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: 480px) {
  .page {
    padding-inline: 16px;
  }
}

@media (max-width: 420px) {
  .nav {
    width: 100%;
    gap: 10px;
  }

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