/* Right-Side Contact Drawer Stylesheet */

/* Polyfill: 在不支持 HTML5 Popover 的老旧 Safari 下默认一律隐藏抽屉，防止遮挡主网页点击或滑动手势 */
.Drawer {
  display: none !important;
}

/* 激活状态下（支持 Popover 浏览器）显示 */
.Drawer:popover-open {
  display: block !important;
}

/* 激活状态下（老旧 Safari 降级方案）显示 */
.Drawer.legacy-show {
  display: block !important;
}

.Drawer {
  /* Set maximum sheet width on desktop, but cap on small screens so a sliver of page remains visible */
  --drawer-width: min(560px, 85dvw);
  
  /* Custom property driven by the scroll-driven animation.
     0 = drawer fully closed (transparent backdrop, offscreen sheet).
     1 = drawer fully open (visible backdrop, sheet aligned at viewport right edge). */
  --drawer-backdrop: 0;

  /* Reset default user-agent popover constraints so it fills the viewport */
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  overflow: visible;
  max-width: none;
  max-height: none;
  z-index: 9999;
}

/* Style the popover's ::backdrop to achieve the dim overlay effect */
.Drawer::backdrop {
  background: #000;
  opacity: calc(var(--drawer-backdrop) * 0.45);
  backdrop-filter: blur(calc(var(--drawer-backdrop) * 4px));
  transition: backdrop-filter 0.1s linear;
}

/* Scroll-snap container that spans 100vw + drawer width */
.Drawer-scroller {
  position: relative;
  display: grid;
  /* Spacer on the left (100% viewport), Sheet on the right (drawer width) */
  grid-template-columns: 100vw var(--drawer-width);
  width: 100%;
  height: 100%;
  overflow-x: scroll;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  scroll-snap-type: x mandatory;
}

.Drawer-scroller::-webkit-scrollbar {
  display: none;
}

/* Enable smooth scrolling natively, but respect user preferences */
@media (prefers-reduced-motion: no-preference) {
  .Drawer-scroller {
    scroll-behavior: smooth;
  }
}

/* The empty spacer creating the "closed" snap stop */
.Drawer-spacer {
  scroll-snap-align: start;
  width: 100vw;
  height: 100%;
  background: transparent;
}

/* The drawer panel containing the form content */
.Drawer-sheet {
  scroll-snap-align: end;
  width: var(--drawer-width);
  height: 100svh;
  background: var(--color-paper, #ffffff);
  color: var(--color-ink, #1e2124);
  overflow-y: auto;
  scrollbar-width: none;
  outline: none;
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.08);
  border-left: 1px solid var(--color-line-soft, #d8d8d8);
  display: flex;
  flex-direction: column;
}

.Drawer-sheet::-webkit-scrollbar {
  display: none;
}

.Drawer-content {
  padding: 40px clamp(24px, 5vw, 60px) 60px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* Top bar with Close button and link */
.Drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 36px;
}

.Drawer-close {
  background: transparent;
  border: none;
  padding: 8px;
  color: var(--color-ink, #1e2124);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease, transform 0.2s ease;
  margin-left: -8px;
}

.Drawer-close:hover {
  opacity: 0.7;
  transform: scale(1.05);
}

.Drawer-close svg {
  width: 22px;
  height: 22px;
}

.Drawer-header-link {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-ink, #1e2124);
  border-bottom: 1px solid var(--color-ink, #1e2124);
  padding-bottom: 2px;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.Drawer-header-link:hover {
  color: var(--color-ink-soft, #4a4f55);
  border-bottom-color: var(--color-ink-soft, #4a4f55);
}

/* Labels and Titles */
.Drawer-kicker {
  display: block;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--color-muted, #767676);
  margin-bottom: 10px;
  text-transform: uppercase;
}

.Drawer-title {
  font-size: clamp(24px, 2.5vw, 34px);
  font-weight: 600;
  line-height: 1.35;
  color: var(--color-ink, #1e2124);
  margin: 0 0 28px 0;
  letter-spacing: -0.01em;
}

.Drawer-body {
  position: relative;
  flex: 1;
}

/* Contact view */
.Drawer-view {
  display: block;
}

.Drawer-intro {
  margin: 0 0 30px;
  color: var(--color-ink-soft, #4a4f55);
  font-size: 15px;
  line-height: 1.7;
}

.Drawer-contact-details {
  display: grid;
  gap: 0;
  margin: 0;
}

.Drawer-contact-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 18px 0;
  border-top: 1px solid var(--color-line-subtle, #dedede);
}

.Drawer-contact-icon {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--color-line-subtle, #dedede);
  border-radius: 50%;
  color: var(--color-ink-soft, #4a4f55);
}

.Drawer-contact-icon svg {
  width: 18px;
  height: 18px;
}

.Drawer-contact-copy {
  min-width: 0;
}

.Drawer-contact-item dt {
  margin-bottom: 4px;
  color: var(--color-muted, #767676);
  font-size: 12px;
  letter-spacing: .08em;
}

.Drawer-contact-item dd {
  margin: 0;
  font-size: 19px;
  font-weight: 500;
}

.Drawer-contact-item a {
  color: var(--color-ink, #1e2124);
  text-decoration: none;
}

.Drawer-contact-item a:hover,
.Drawer-contact-item a:focus-visible {
  color: var(--color-muted, #767676);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.Drawer-qrcode-hint {
  margin: 28px 0 14px;
  color: var(--color-muted, #767676);
  font-size: 13px;
}

.Drawer-qrcodes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.Drawer-qrcode {
  margin: 0;
  text-align: center;
}

.Drawer-qrcode img {
  display: block;
  width: 100%;
  max-width: 160px;
  aspect-ratio: 1;
  margin: 0 auto 10px;
  object-fit: contain;
}

.Drawer-qrcode figcaption {
  color: var(--color-ink-soft, #4a4f55);
  font-size: 13px;
}

/* Tie the backdrop opacity to the scroll position using scroll-driven animation */
@supports (animation-timeline: scroll()) {
  .Drawer {
    timeline-scope: --drawer-fade;
    animation: fade-drawer-backdrop linear both;
    animation-timeline: --drawer-fade;
  }

  .Drawer-scroller {
    scroll-timeline: --drawer-fade x;
  }

  @property --drawer-backdrop {
    syntax: '<number>';
    inherits: true;
    initial-value: 0;
  }

  @keyframes fade-drawer-backdrop {
    /* Scroll position 0 = closed = backdrop transparent */
    0% { --drawer-backdrop: 0; }
    /* Scroll position 100% = open = backdrop visible */
    100% { --drawer-backdrop: 1; }
  }
}

/* Mobile Responsiveness Improvements */
@media (max-width: 600px) {
  .Drawer {
    --drawer-width: 100dvw;
  }
  .Drawer-scroller {
    grid-template-columns: 100vw 100dvw;
  }
  .Drawer-content {
    padding: 30px 20px 40px;
  }
  .Drawer-title {
    margin-bottom: 30px;
  }
  .Drawer-contact-item dd {
    font-size: 18px;
  }
}
