/* ==========================================================================
   张涵冰 × 孔杜威｜两周年小狗日记 - UI-v9 交互增强与手机平板深度适配 (重构优化版)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. 触控反馈与物理弹性交互 (Tactile & Spring Physics)
   -------------------------------------------------------------------------- */

button,
.command-button,
.icon-button,
.bucket-tab-btn,
.bucket-item,
.photo-slot,
.nav-audio-btn,
.nav-theme-opt {
  transition: transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}

button:active,
.command-button:active,
.icon-button:active,
.bucket-tab-btn:active,
.is-pressed {
  transform: scale(0.96) !important;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--v8-accent, #ff8e71);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   2. 双击点赞大爱心动效 (Double-Tap Heart Burst)
   -------------------------------------------------------------------------- */

.touch-heart-burst {
  position: fixed;
  z-index: 99999;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.touch-heart-svg {
  width: 86px;
  height: 86px;
  fill: #ff4757;
  filter: drop-shadow(0 6px 20px rgba(255, 71, 87, 0.45));
  animation: doubleTapHeart 0.85s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

@keyframes doubleTapHeart {
  0% {
    opacity: 0;
    transform: scale(0.2) rotate(-15deg);
  }
  35% {
    opacity: 1;
    transform: scale(1.3) rotate(0deg);
  }
  65% {
    opacity: 1;
    transform: scale(1.08) rotate(4deg);
  }
  100% {
    opacity: 0;
    transform: scale(1.5) translateY(-36px) rotate(-6deg);
  }
}

/* --------------------------------------------------------------------------
   3. 弹窗下拉手势指引条 (Modal Pull Handle)
   -------------------------------------------------------------------------- */

.gallery-viewer__panel::before,
.memory-viewer__panel::before,
.wishbook-modal::before,
.polaroid-modal__dialog::before {
  content: '';
  display: block;
  width: 42px;
  height: 5px;
  border-radius: 999px;
  background: rgba(120, 100, 90, 0.25);
  margin: 0 auto 14px auto;
}

/* --------------------------------------------------------------------------
   4. 手机端深度适配优化 (Mobile Deep Polish <= 620px)
   -------------------------------------------------------------------------- */

@media (max-width: 620px) {
  /* 防止 iOS 输入聚焦自动放大页面 */
  input[type="text"],
  input[type="date"],
  input[type="search"],
  input[type="password"],
  textarea,
  select {
    font-size: max(16px, 1rem) !important;
  }

  /* 记忆手账「心愿胶囊」单列响应式 */
  .memories-capsule__interactive {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  .memories-capsule__card {
    padding: 20px 16px !important;
  }

  .memories-capsule__header h2 {
    font-size: 24px !important;
  }

  /* 心愿册弹窗移动端满屏抽屉感 */
  .wishbook-modal {
    padding: 18px 14px !important;
    max-height: 90vh !important;
  }

  .wishbook-modal__list {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .wishbook-modal__tabs {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
    margin: 0 -6px 14px -6px;
    padding: 0 6px 4px 6px;
  }

  .wishbook-modal__tabs::-webkit-scrollbar {
    display: none;
  }

  .bucket-tab-btn {
    flex-shrink: 0;
    scroll-snap-align: start;
  }

  /* 导航内嵌小组件定位与极简触控优化 */
  .global-nav__controls {
    margin-left: auto !important;
    margin-right: 6px !important;
    gap: 6px !important;
  }

  .nav-audio-summary,
  .nav-theme-summary {
    padding: 6px 10px !important;
    font-size: 12px !important;
  }

  .nav-audio-panel {
    width: min(280px, calc(100vw - 32px)) !important;
    right: -20px !important;
  }

  .nav-theme-menu {
    right: 0 !important;
  }

  /* 拍立得预览弹窗移动端适配 */
  .polaroid-modal__dialog {
    padding: 16px !important;
    width: calc(100vw - 24px) !important;
    max-height: 88vh;
    overflow-y: auto;
  }

  .polaroid-modal__preview-box {
    min-height: 180px !important;
  }

  /* 全屏幻灯片 */
  .gallery-slideshow__stage {
    padding: 16px !important;
  }

  .gallery-slideshow__caption {
    font-size: 13px !important;
    padding: 6px 14px !important;
    bottom: 16px !important;
  }

  .gallery-slideshow__controls {
    padding: 0 12px !important;
    font-size: 12px !important;
  }
}

/* --------------------------------------------------------------------------
   5. 平板端深度适配 (Tablet Adaptation: 621px - 1024px)
   -------------------------------------------------------------------------- */

@media (min-width: 621px) and (max-width: 1024px) {
  .calendar-page,
  .gallery-page,
  .memories-page {
    padding-left: max(24px, env(safe-area-inset-left));
    padding-right: max(24px, env(safe-area-inset-right));
  }

  .calendar-hero h1,
  .gallery-hero h1,
  .memories-hero h1 {
    font-size: clamp(38px, 5.5vw, 52px) !important;
  }

  /* 平板日历双分栏 */
  .calendar-workspace {
    display: grid !important;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) !important;
    gap: 24px !important;
  }

  .calendar-grid button {
    min-height: 52px !important;
    font-size: 15px !important;
  }

  /* 平板照片墙 2~3 列平衡流 */
  .gallery-wall {
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)) !important;
    gap: 18px !important;
  }

  /* 平板记忆手账统计卡片 4 列均分 */
  .memories-stats {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 12px !important;
  }

  .memories-stats strong {
    font-size: clamp(28px, 3.8vw, 36px) !important;
  }

  /* 平板心愿册弹窗 */
  .wishbook-modal__list {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}
