html {
  scroll-behavior: smooth;
}

/* Mirrors app/globals.css. html is the scrolling element, so clipping on body
   alone does not stop off-canvas panels - a closed SlideMenu parked at
   translate-x-full, a navbar pushed out by -translate-y-full - from widening
   the document. Measured on a 390px viewport, the closed slide menu takes
   document.scrollWidth to 780px, which is the horizontal scrollbar and the
   empty gutter down the right-hand side of the exported page. */
html,
body {
  overflow-x: hidden;
}

/* A thin scrollbar for the page and every scrolling panel (the mobile
   menu, modals). A translucent mid grey, so it reads on light and dark
   sites alike, with no arrows and an invisible track. The transparent
   border insets the thumb from the edge. Firefox only has the standard
   properties, and Chrome ignores the ::-webkit rules once scrollbar-color
   is set, so the standard ones are kept to browsers without them. */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track,
::-webkit-scrollbar-corner {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background-color: rgba(128, 128, 128, 0.45);
  background-clip: padding-box;
  border: 3px solid transparent;
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background-color: rgba(128, 128, 128, 0.7);
}
::-webkit-scrollbar-button {
  display: none;
}
@supports not selector(::-webkit-scrollbar) {
  * {
    scrollbar-width: thin;
    scrollbar-color: rgba(128, 128, 128, 0.45) transparent;
  }
}

/* The page background (colour and image) is set by buildTheme above,
   which mirrors the editor canvas (BuilderIframe) and /preview. */
body {
  margin: 0;
  padding: 0;
}

/* Mirrors app/globals.css. A text's Font Weight setting is an inline style
   on the element, so without this every <strong> the canvas toolbar wrote
   inside it would keep its own bold and the setting would look ignored.
   Only elements that carry a weight are marked, so bold survives
   everywhere else. */
[data-text-weight] * {
  font-weight: inherit;
}

/* Mirrors app/globals.css: the section under a transparent navbar starts
   its content below the bar (navbarScroll's overlay script sets the
   variables), on top of its own padding. */
[data-nav-overlay-target] {
  padding-top: calc(
    var(--nav-overlay-base, 0px) + var(--nav-overlay-height, 0px)
  ) !important;
}

/* Mirrors app/globals.css: a button's hover settings arrive as custom
   properties, each switched on by its own attribute. */
[data-btn-hover-bg]:hover {
  background-color: var(--btn-hover-bg) !important;
}
[data-btn-hover-color]:hover {
  color: var(--btn-hover-color) !important;
}
[data-btn-hover-border]:hover {
  border-color: var(--btn-hover-border) !important;
}
[data-btn-hover-shadow]:hover {
  box-shadow: var(--btn-hover-shadow) !important;
}
[data-btn-hover-effect="lift"]:hover {
  transform: translateY(-3px);
}
[data-btn-hover-effect="grow"]:hover {
  transform: scale(1.05);
}
[data-btn-hover-effect="shrink"]:hover {
  transform: scale(0.96);
}

/* Mirrors app/globals.css: a block image's settings arrive as custom
   properties on its frame, each switched on by its own attribute. */
[data-img-fit] img {
  object-fit: var(--img-fit) !important;
}
[data-img-pos] img {
  object-position: var(--img-pos) !important;
}
[data-img-filter] img {
  filter: grayscale(var(--img-gray, 0%)) invert(var(--img-invert, 0%));
}
[data-img-hover],
[data-img-hover] img {
  transition-property: scale, opacity, filter;
  transition-duration: var(--img-hover-duration, 300ms);
  transition-timing-function: var(--img-hover-easing, ease);
}
[data-img-hover~="zoom"]:hover img {
  scale: 1.05;
}
[data-img-hover~="scale"]:hover {
  scale: 1.05;
}
[data-img-hover~="fade"]:hover img {
  opacity: 0.7 !important;
}
[data-img-hover~="gray"]:hover {
  --img-gray: 0% !important;
}

/* Mirrors app/globals.css: the background carousel's Zoom Animation. */
@keyframes builder-carousel-zoom {
  from {
    scale: 1.06;
  }
  to {
    scale: 1;
  }
}
[data-carousel-zoom="true"] [data-carousel-media]:not([aria-hidden]) {
  animation: builder-carousel-zoom var(--carousel-zoom-duration, 7000ms)
    ease-out forwards;
}
@media (prefers-reduced-motion: reduce) {
  [data-carousel-zoom="true"] [data-carousel-media] {
    animation: none;
  }
}

/* Mirrors app/globals.css: the background carousel's arrows, off. */
[data-carousel-arrows="false"] [data-carousel-control="prev"],
[data-carousel-arrows="false"] [data-carousel-control="next"] {
  display: none;
}

/* Mirrors app/globals.css: captions revealed on hover. */
[data-caption-reveal] {
  opacity: 0;
  transition-property: opacity, transform, scale;
  transition-duration: var(--img-hover-duration, 300ms);
  transition-timing-function: var(--img-hover-easing, ease);
}
[data-caption-reveal="slide"] {
  transform: translateY(0.75rem);
}
[data-caption-reveal="zoom"] {
  scale: 0.9;
}
[data-image-frame]:hover [data-caption-reveal],
[data-image-frame]:focus-within [data-caption-reveal] {
  opacity: 1;
  transform: none;
  scale: 1;
}
