/* The page content is the only scrolling surface on phones. The village is
   painted on the viewport underneath it, outside of that scroll container. */
@media (pointer: coarse), (max-width: 760px) {
  html[data-theme] {
    position: relative;
    width: 100%;
    height: 100%;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    isolation: isolate;
    overscroll-behavior: none;
  }
  html[data-theme] body[class] {
    box-sizing: border-box;
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: none;
    background: transparent !important;
  }
  html[data-theme] body.glass-interior > :is(header, nav, main, footer) { flex-shrink: 0; }
  html[data-theme] body::before { content: none; }
  /* The foreground follows the available window. Both wallpaper pieces use
     the same crop, recorded once per width, measured from its top edge. */
  html[data-theme] {
    --village-height: var(--portrait-area, 100svh);
    --village-image: url("/assets/teracota-mobil-v123.webp");
    --village-size: 100% var(--village-height);
  }
  html[data-theme][data-mobile-art="landscape"] {
    --village-image: url("/assets/teracota-desktop-v123.webp");
    /* The landscape source is 1536 × 1024, bottom-aligned and cropped to cover. */
    --village-size: auto max(var(--village-height), 66.666667vw);
  }
  html[data-theme]::before,
  html[data-theme]::after {
    content: "";
    position: fixed;
    inset: 0 0 auto;
    z-index: -1;
    width: 100%;
    pointer-events: none;
    transform: translateZ(0);
    background: var(--terra-canvas, #f8e3ca) var(--village-image) center bottom / var(--village-size) no-repeat;
  }
  html[data-theme]::before { height: var(--village-height); }
  html[data-theme="terracotta"]::before {
    background-image: linear-gradient(to bottom, #f9e5cf80, #f9e5cfdc 42px, transparent 116px), var(--village-image);
    background-size: 100% 100%, var(--village-size);
  }
  /* Blend the visible hillside into a quieter painted foreground below it.
     Its geometry does not depend on the toolbar height. */
  html[data-theme]::after {
    --near-hill: #bc7259;
    --middle-hill: #da9672;
    --earth: linear-gradient(95deg, #bd6248, #e29670 26%, #f2c5a6 52%, #df9470 75%, #d08065);
    top: calc(var(--village-height) - 13px);
    height: max(330px, var(--art-height, 100lvh));
    background-color: #edc1a1;
    background-image: radial-gradient(ellipse 88vw 85px at 15% 154px, var(--near-hill) 98%, transparent),
      radial-gradient(ellipse 109vw 110px at 88% 154px, var(--middle-hill) 98%, transparent),
      var(--earth), var(--village-image);
    background-size: 100% 240px, 100% 240px, 100% 100%, 250% auto;
    background-position: center top, center top, center, 50% 47%;
    background-repeat: no-repeat;
    background-blend-mode: multiply, multiply, multiply, normal;
    -webkit-mask-image: linear-gradient(transparent, black 13px);
    mask-image: linear-gradient(transparent, black 13px);
  }
  html[data-theme="studio"]::before {
    background-color: #132338;
    background-blend-mode: soft-light;
  }
  html[data-theme="studio"]::after {
    --near-hill: #344454;
    --middle-hill: #415364;
    --earth: linear-gradient(95deg, #28323f, #394858 45%, #394858 60%, #283541);
    background-color: #132338;
    background-blend-mode: normal, normal, normal, soft-light;
  }

  html[data-theme="studio"] body.creator-page > .site-backdrop { display: none; }

  /* Short phones may scroll Home as well. The footer belongs to the bottom
     of the scene, even if the scene is taller than the visible area. */
  html[data-theme] body.cinematic-home {
    display: grid;
    grid-template: "scene" minmax(min-content, 1fr) / minmax(0, 1fr);
  }
  html[data-theme] body.cinematic-home > main { grid-area: scene; }
  html[data-theme] body.cinematic-home > .compact-footer {
    grid-area: scene;
    position: relative;
    align-self: end;
    bottom: auto;
    margin-block-end: 4px;
  }
}

/* Size the home portrait against its pinned layer, including its crop when
   the phone turns. Only foreground content follows the available page height. */
html[data-mobile-art][data-theme="terracotta"] body.home-page > .site-backdrop {
  container: portrait-art / size;
  inset: 0 0 auto;
  height: var(--portrait-area);
  min-height: 0;
}
html[data-mobile-art][data-theme="terracotta"] body.home-page .site-backdrop .backdrop-sharp {
  inset: 0;
  width: 100%;
  height: 100%;
  transform: none;
  background-position: center -6cqh;
  background-size: auto 105%;
  -webkit-mask-image: linear-gradient(black 0 35%, transparent 55%);
  mask-image: linear-gradient(black 0 35%, transparent 55%);
}
@container portrait-art (orientation: landscape) or (min-width: 1000px) {
  html[data-mobile-art][data-theme="terracotta"] body.home-page .site-backdrop .backdrop-sharp {
    inset: 0 auto auto 50%;
    width: min(57cqh, 50cqw);
    height: 44cqh;
    transform: translateX(-56%);
    background-size: 100% auto;
    background-position: center max(-15cqh, -13.2cqw);
    -webkit-mask-image: linear-gradient(to right, transparent, black 9% 92%, transparent), linear-gradient(black 0 68%, transparent 100%);
    mask-image: linear-gradient(to right, transparent, black 9% 92%, transparent), linear-gradient(black 0 68%, transparent 100%);
    -webkit-mask-composite: source-in;
    mask-composite: intersect;
  }
}
@container portrait-art (orientation: landscape) and (max-height: 650px) {
  html[data-mobile-art][data-theme="terracotta"] body.home-page .site-backdrop .backdrop-sharp {
    width: min(51cqh, 48cqw);
    height: 38cqh;
  }
}
@container portrait-art (orientation: landscape) and (max-height: 550px) {
  html[data-mobile-art][data-theme="terracotta"] body.home-page .site-backdrop .backdrop-sharp {
    width: min(49cqh, 36cqw);
    height: 35cqh;
    background-position: center -15cqh;
  }
}
@container portrait-art (orientation: landscape) and (max-height: 350px) {
  html[data-mobile-art][data-theme="terracotta"] body.home-page .site-backdrop .backdrop-sharp { height: 31cqh; }
}

/* Keep the focus ring and pointer target in place while a social icon lifts. */
@media (prefers-reduced-motion: no-preference) {
  .home-community .community-mark,
  .site-header .header-actions .header-music > :is(svg, img),
  .media-platforms .hub-link .hub-icon {
    transition: translate 150ms ease-out, scale 100ms ease-out,
                box-shadow 180ms ease, border-color 180ms ease;
  }
  .home-community .community-link:focus-visible .community-mark,
  .site-header .header-actions .header-music:focus-visible > :is(svg, img),
  .media-platforms .hub-link:focus-visible .hub-icon {
    translate: 0 -2px;
  }
  /* Creator's stylesheet already lifts the entire circle on mouse hover. */
  body.creator-page .creator-socials .social-icon-link:focus-visible {
    transform: translateY(-2px);
  }
  @media (hover: hover) and (pointer: fine) {
    .home-community .community-link:hover .community-mark,
    .site-header .header-actions .header-music:hover > :is(svg, img),
    .media-platforms .hub-link:hover .hub-icon {
      translate: 0 -2px;
    }
  }
  .home-community .community-link:active .community-mark,
  .site-header .header-actions .header-music:active > :is(svg, img),
  .media-platforms .hub-link:active .hub-icon {
    translate: 0;
    scale: .96;
  }
  /* The icon provides the header press feedback inside its stationary disc. */
  html body .site-header .header-actions a.header-music:active { transform: none; }

  html body :is(.header-personalized, .header-home-return, .creator-contact,
                .atelier-tabs button, .atelier-live, .atelier-whatsapp,
                .atelier-examples-trigger, .carousel-arrow, .sample-controls .button) {
    transition: scale 110ms ease-out, background-color 180ms ease,
                border-color 180ms ease, color 180ms ease, box-shadow 180ms ease;
  }
  html body :is(.header-personalized, .header-home-return, .creator-contact,
                .atelier-tabs button, .atelier-live, .atelier-whatsapp,
                .atelier-examples-trigger, .carousel-arrow, .sample-controls .button):not(:disabled, [aria-disabled="true"]):active {
    scale: .975;
    transition-duration: 65ms;
  }
  html body .site-header .header-actions a.header-personalized:active { transform: none; }
}
