@view-transition {
  navigation: auto;
}
* {
  box-sizing: border-box;
}
:root {
  --screen-height: 100svh;
  --drawer-top-margin: 2rem;
  --drawer-midpoint: 14rem;
  --collapsed-height: 4rem;
}
html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Arial', sans-serif;
  background: #eee;
}
@keyframes drawer-height {
  0% { --current-drawer-height: var(--collapsed-height); }
  /* variable values are discrete, so we don't need to be accurate with our percentages */
  10% { --current-drawer-height: var(--drawer-midpoint); }
  100% { --current-drawer-height: calc(100dvh - var(--drawer-top-margin)); }
}
html {
  scroll-snap-type: y mandatory;
  scroll-timeline: --page-scroll block;
  scrollbar-width: none;
  animation: drawer-height auto linear;
  animation-timeline: --page-scroll;
  overscroll-behavior: none;
}
.screen-top {
  scroll-snap-align: start;
}
.main-wrapper {
  height: var(--screen-height);
  position: sticky;
  top: 0;
  z-index: 0;
  background: #000;
}
@keyframes main-scroll-opacity {
  0% { opacity: 1; }
  90% { opacity: 1; }
  100% { opacity: 0.7; }
}
.main-content {
  height: 100%;
  animation: main-scroll-opacity auto linear;
  animation-timeline: --page-scroll;

  /* this is just for the sake of an example image as a map */
  /* you won't need these rules if you're embedding a real map or something else */
  scrollbar-width: none;
  overflow: scroll;
  overscroll-behavior: none;
}
@keyframes slide-drawer-in {
  0% { transform: translateY(var(--current-drawer-height)); }
  100% { transform: translateY(0); }
}
@keyframes fade-drawer {
  0% { filter: brightness(1); }
  100% { filter: brightness(0.95); }
}
::view-transition-new(drawer) {
  animation: 350ms ease slide-drawer-in;
}
::view-transition-old(drawer) {
  animation: 300ms ease fade-drawer;
  filter: brightness(0.95);
}
html:active-view-transition-type(backward) {
  &::view-transition-new(drawer) {    
    animation: 300ms ease fade-drawer reverse;
    z-index: 2;
  }
  &::view-transition-old(drawer) {
    animation: 350ms ease slide-drawer-in reverse;
    transform: translateY(var(--current-drawer-height));
    filter: none;
    z-index: 3;
  }
}
.drawer {
  view-transition-name: drawer;
  z-index: 2;
  position: relative;
}

.drawer-header {
  scroll-snap-align: start;
  scroll-snap-stop: always;
  scroll-margin-top: calc(var(--screen-height) - var(--drawer-midpoint));

  /* we overlay the drawer on the map, so we can use border-radius etc */
  margin-top: calc(var(--collapsed-height) * -1);
  height: var(--collapsed-height);

  border-radius: 15px 15px 0 0;
  background: #fff;
  border-bottom: 0.5px solid #00000022;
  display: flex;
  align-items: center;
  corner-shape: squircle;

  /* prevents the box shadow from bleeding out the bottom */
  clip-path: rect(-15px 100% 100% 0px);
  box-shadow: 0 3px 15px -2px #00000033;

  /* renders a pill at the top of the header */
  &::before {
    content: "";
    background: #00000044;
    position: absolute;
    top: 0.25rem;
    left: 50%;
    height: 0.25rem;
    width: 2rem;
    margin-left: -1rem;
    border-radius: 0.375rem; 
    display: flex;
  }

  & div {
    padding: 0.125rem 0.75rem 0;
    flex: 1;
  }
  & h1 {
    margin: 0;
    font-size: 1.25rem;
    letter-spacing: -0.25px;
  }
  & p {
    font-size: 0.9rem;
    margin: 0;
    color: #444;
  }
  & button {
    background: transparent;
    border: 0;
    font-size: 2rem;
    margin-right: 0.75rem;
    height: 2rem;
    width: 2rem;
    line-height: 2rem;
    color: #666;
    border-radius: 12px;
    corner-shape: squircle;

    &:hover {
      background: #00000011;
    }
    &:active {
      opacity: 0.7;
    }
  }
}
.drawer-wrapper {
  scroll-snap-align: start;
  scroll-snap-stop: always;
  scroll-margin-top: var(--collapsed-height);
  height: calc(100dvh - var(--collapsed-height) - var(--drawer-top-margin));
  background: #fafafa;
}
@keyframes drawer-content {
  0% { overflow-y: hidden; }
  99% { overflow-y: hidden; }
  100% { overflow-y: scroll; }
}
.drawer-content {
  animation: drawer-content auto linear;
  animation-timeline: --page-scroll;
  overflow-y: scroll;
  height: 100%;
  padding: 0.75rem;
  font-size: 15px;
  line-height: 1.3;

  & a {
    display: block;
    background: #007AFF;
    color: #fff;
    text-decoration: none;
    text-align: center;
    border: 0;
    font-size: 0.9rem;
    width: 100%;
    border-radius: 8px;
    padding: 0.5rem 0;

    &:active {
      background: #005cbf;
    }

    @supports (corner-shape: squircle) {
      corner-shape: squircle;
      border-radius: 12px;
    }
  }
}
