/* Quote drawer: the quote form rises from the bottom of the phone screen, over the page the visitor was
   reading, and goes back down when they tap outside it, press Escape or press Close. No script.

   It is the browser's own "popover": a button with popovertarget="quote" opens the element with id="quote".
   The rise and fall are the browser's own too (it can now animate a thing arriving and leaving).

   On a wide screen it is a card in the bottom right corner instead of a sheet.
   A browser with no popovers shows the form as an ordinary section of the page, where it sits in the markup.

   Set on :root to fit the site:
     --qd-bg, --qd-ink     the drawer's background and text
     --qd-accent           the handle and the focus ring
     --qd-time             how long it takes to rise (.32s) */
:root { --qd-bg: #fffdf8; --qd-ink: #1f1a17; --qd-accent: #f2b233; --qd-time: .32s; }

.qd {
  position: fixed;
  inset: auto 0 0 0;
  margin: 0;
  width: 100%;
  max-width: none;
  max-height: 88vh;
  max-height: min(88dvh, 46rem);
  padding: 1.6rem clamp(1rem, 5vw, 1.6rem) calc(1.4rem + env(safe-area-inset-bottom));
  border: 0;
  border-radius: 20px 20px 0 0;
  background: var(--qd-bg);
  color: var(--qd-ink);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, .3);
  overflow: auto;
  overscroll-behavior: contain;          /* scrolling to the end of the form does not start scrolling the page */
}
.qd::before {                            /* the little handle that says "this is a sheet" */
  content: "";
  position: absolute;
  top: .6rem;
  left: 50%;
  width: 2.6rem;
  height: .28rem;
  margin-left: -1.3rem;
  border-radius: 99px;
  background: currentColor;
  opacity: .22;
}
.qd-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin: 0 0 .8rem; }
.qd-title { margin: 0; font-size: 1.4rem; line-height: 1.15; }
.qd-close {
  flex: none;
  min-width: 2.8rem;
  min-height: 2.8rem;
  padding: 0 .9rem;
  border: 1px solid currentColor;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: .9rem;
  cursor: pointer;
  opacity: .8;
}
.qd-close:hover { opacity: 1; }
.qd :focus-visible { outline: 3px solid var(--qd-accent); outline-offset: 2px; }
.qd-next { margin: 1.1rem 0 0; padding: .9rem 0 0 1.2rem; border-top: 1px solid rgba(0, 0, 0, .12); font-size: .9rem; line-height: 1.5; }
.qd-next li + li { margin-top: .2rem; }
.qd-alt { display: none; }               /* a plain link to the form, for browsers with no popovers */

/* ---- Rising and falling ---- */
.qd::backdrop { background: rgb(0 0 0 / 0); }
@supports selector(:popover-open) {
  .qd:popover-open::backdrop { background: rgb(0 0 0 / .45); }
  @media (prefers-reduced-motion: no-preference) {
    .qd {
      translate: 0 100%;
      transition: translate var(--qd-time) cubic-bezier(.2, .9, .25, 1), overlay var(--qd-time) allow-discrete, display var(--qd-time) allow-discrete;
    }
    .qd:popover-open { translate: 0 0; }
    @starting-style { .qd:popover-open { translate: 0 100%; } }
    .qd::backdrop { transition: background-color var(--qd-time) ease, overlay var(--qd-time) allow-discrete, display var(--qd-time) allow-discrete; }
    @starting-style { .qd:popover-open::backdrop { background: rgb(0 0 0 / 0); } }
  }
}

/* ---- A wide screen: a card in the corner ---- */
@media (min-width: 48rem) {
  .qd {
    inset: auto 1.5rem 1.5rem auto;
    width: min(27rem, calc(100vw - 3rem));
    max-height: min(84vh, 44rem);
    border-radius: 20px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .3);
  }
  .qd::before { display: none; }
  @supports selector(:popover-open) {
    @media (prefers-reduced-motion: no-preference) {
      .qd { translate: 0 1.5rem; opacity: 0; transition: translate var(--qd-time) cubic-bezier(.2, .9, .25, 1), opacity var(--qd-time) ease, overlay var(--qd-time) allow-discrete, display var(--qd-time) allow-discrete; }
      .qd:popover-open { translate: 0 0; opacity: 1; }
      @starting-style { .qd:popover-open { translate: 0 1.5rem; opacity: 0; } }
    }
  }
}

/* ---- No popovers: an ordinary section, and a plain link to it ---- */
@supports not selector(:popover-open) {
  .qd { position: static; max-height: none; border-radius: 16px; box-shadow: none; border: 1px solid rgba(0, 0, 0, .15); }
  .qd::before, .qd-close, .qd-open { display: none; }
  .qd-alt { display: inline; }
}
@media print { .qd { display: none; } }
