.motion-field-page {
  --motion-field-paper: #fbfaf3;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100dvh;
  min-height: 22rem;
  overflow: hidden;
  background: var(--motion-field-paper);
}

.motion-field-page[data-controls-hidden="true"] {
  grid-template-rows: minmax(0, 1fr);
}

.motion-field-page,
.motion-field-page * {
  overscroll-behavior: none;
}

.motion-field-chrome {
  display: contents;
}

.motion-field-chrome[hidden] {
  display: none;
}

.motion-field-header {
  position: relative;
  z-index: 2;
  grid-row: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  min-height: 3.25rem;
  padding:
    env(safe-area-inset-top)
    max(6.5rem, calc(env(safe-area-inset-right) + 5.5rem))
    0
    max(1rem, env(safe-area-inset-left));
  border-bottom: 1px solid var(--strong-line);
  background: var(--paper);
  font-size: 0.8125rem;
}

.motion-field-lens-panel[hidden] {
  display: none;
}

.motion-field-header a {
  justify-self: start;
  font-weight: 600;
}

.motion-field-header h1 {
  max-width: none;
  font-size: inherit;
  font-weight: 600;
  letter-spacing: 0;
  line-height: inherit;
}

.motion-field-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  text-align: right;
}

.motion-field-utility {
  display: flex;
  justify-self: end;
  align-items: center;
  gap: 0.25rem;
}

.motion-field-playback,
.motion-field-stepper {
  display: inline-grid;
  align-items: stretch;
  border: 1px solid var(--strong-line);
  background: var(--paper);
}

.motion-field-playback {
  grid-template-columns: auto auto;
}

.motion-field-stepper {
  grid-template-columns: 2.75rem minmax(2.75rem, auto) 2.75rem;
}

.motion-field-playback button,
.motion-field-stepper button,
.motion-field-lens-toggle {
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0;
  border: 0;
  background: var(--paper);
  cursor: pointer;
  line-height: 1;
}

.motion-field-playback button {
  padding: 0.55rem 0.625rem;
  border-left: 1px solid var(--strong-line);
  font-size: 0.6875rem;
  font-weight: 600;
  white-space: nowrap;
}

.motion-field-playback button:first-child {
  border-left: 0;
}

.motion-field-playback button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

.motion-field-stepper button {
  font-size: 1rem;
}

.motion-field-stepper output {
  display: grid;
  min-width: 2.75rem;
  place-items: center;
  padding-inline: 0.35rem;
  border-inline: 1px solid var(--strong-line);
  color: var(--muted);
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.motion-field-speed output {
  width: 2.75rem;
}

.motion-field-zoom output {
  width: 2.75rem;
}

.motion-field-stepper button:disabled {
  color: var(--muted);
  cursor: default;
  opacity: 0.45;
}

.motion-field-lens-toggle {
  min-width: 4rem;
  border: 1px solid var(--strong-line);
  padding-inline: 0.625rem;
  font-size: 0.6875rem;
  font-weight: 600;
  white-space: nowrap;
}

.motion-field-lens-toggle[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

.motion-field-lens-toggle[aria-disabled="true"] {
  cursor: default;
  opacity: 0.45;
}

.motion-field-controls-toggle {
  position: fixed;
  z-index: 5;
  inset-block-start: calc(env(safe-area-inset-top) + 0.25rem);
  inset-inline-end: max(0.25rem, env(safe-area-inset-right));
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0.55rem 0.625rem;
  border: 0;
  background: var(--paper);
  cursor: pointer;
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.motion-field-page[data-controls-hidden="true"]
  .motion-field-controls-toggle {
  background: rgb(255 255 255 / 88%);
}

.motion-field-story-link {
  position: fixed;
  z-index: 5;
  inset-block-end: max(0.5rem, env(safe-area-inset-bottom));
  inset-inline-end: max(0.5rem, env(safe-area-inset-right));
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  gap: 0.35rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--strong-line);
  background: rgb(255 255 255 / 88%);
  color: var(--ink);
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.motion-field-lens-panel {
  position: fixed;
  z-index: 4;
  inset-block-start: calc(
    env(safe-area-inset-top) + 3.25rem + 0.75rem
  );
  inset-inline-start: max(1rem, env(safe-area-inset-left));
  inset-inline-end: max(1rem, env(safe-area-inset-right));
  display: grid;
  width: auto;
  max-width: 19rem;
  margin-inline-start: auto;
  gap: 0.5rem;
  padding: 0.75rem;
  border: 1px solid var(--strong-line);
  background: var(--paper);
  box-shadow: 0 0.25rem 1rem rgb(17 17 17 / 8%);
}

.motion-field-lens-control {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  align-items: center;
  min-height: 2.75rem;
  gap: 0.75rem;
}

.motion-field-lens-control > div {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--ink);
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.motion-field-lens-panel output {
  color: var(--muted);
}

.motion-field-lens-control input[type="range"] {
  width: 100%;
  min-height: 2.75rem;
  margin: 0;
  accent-color: var(--ink);
  cursor: pointer;
}

.motion-field-lens-control input[type="range"]:disabled {
  cursor: default;
  opacity: 0.45;
}

@media (hover: hover) and (pointer: fine) {
  .motion-field-playback button:hover:not([aria-pressed="true"]),
  .motion-field-stepper button:hover:not(:disabled),
  .motion-field-lens-toggle:hover:not([aria-pressed="true"]):not(
      [aria-disabled="true"]
    ),
  .motion-field-controls-toggle:hover,
  .motion-field-story-link:hover {
    background: var(--quiet);
  }
}

.motion-field-story-link:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.motion-field-skip {
  position: fixed;
  z-index: 4;
  inset-block-start: 0.5rem;
  inset-inline-start: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--paper);
  color: var(--ink);
  transform: translateY(-150%);
}

.motion-field-skip:focus {
  transform: translateY(0);
}

.motion-field-canvas {
  position: relative;
  z-index: 1;
  grid-row: 2;
  min-height: 0;
  overflow: hidden;
  background: var(--motion-field-paper);
  cursor: grab;
  outline-offset: -3px;
  touch-action: none;
  user-select: none;
}

.motion-field-page[data-controls-hidden="true"] .motion-field-canvas {
  grid-row: 1;
}

.motion-field-canvas[data-dragging="true"] {
  cursor: grabbing;
}

.motion-field-plane {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.motion-field-tile {
  position: absolute;
  contain: strict;
  pointer-events: auto;
  transform-origin: 50% 50%;
}

.motion-field-tile video {
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: contain;
  background: var(--motion-field-paper);
  cursor: inherit;
  -webkit-user-drag: none;
}

.motion-field-tile video:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.motion-field-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 80rem) {
  .motion-field-utility p {
    display: none;
  }
}

@media (max-width: 56rem) {
  .motion-field-header {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .motion-field-header h1 {
    display: none;
  }

  .motion-field-utility {
    max-width: 100%;
    justify-self: stretch;
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .motion-field-utility::-webkit-scrollbar {
    display: none;
  }
}

@media (max-width: 40rem) {
  .motion-field-header {
    grid-template-columns: minmax(0, 1fr);
    padding-inline-start: max(0.5rem, env(safe-area-inset-left));
  }

  .motion-field-header > a {
    display: none;
  }

  .motion-field-playback button {
    min-width: 3rem;
    padding-inline: 0.45rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .motion-field-skip {
    transition: none;
  }
}
