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

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

/* 按钮与卡片轻触微回弹 */
button,
.command-button,
.icon-button,
.bucket-tab-btn,
.bucket-item,
.photo-slot,
.theme-option-btn,
.audio-pill__btn {
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

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

/* 键盘与触屏焦点可访问性柔光环 */
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--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: 90px;
  height: 90px;
  fill: #ff4757;
  filter: drop-shadow(0 8px 24px rgba(255, 71, 87, 0.5));
  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.35) rotate(0deg);
  }
  60% {
    opacity: 1;
    transform: scale(1.1) rotate(5deg);
  }
  100% {
    opacity: 0;
    transform: scale(1.6) translateY(-40px) rotate(-8deg);
  }
}

/* --------------------------------------------------------------------------
   3. 弹窗下拉手势把手 (Modal Swipe Handle)
   -------------------------------------------------------------------------- */

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

/* --------------------------------------------------------------------------
   4. 恋爱清单交互增强 (Bucket List Micro-interactions)
   -------------------------------------------------------------------------- */

.bucket-item {
  position: relative;
  cursor: pointer;
  user-select: none;
}

/* 扩大触控热区（保证手机平板 >= 44x44px） */
.bucket-item__checkbox {
  position: relative;
}

.bucket-item__checkbox::before {
  content: '';
  position: absolute;
  inset: -12px;
  border-radius: 50%;
}

.bucket-item.is-completed {
  animation: bucketPulse 0.4s ease;
}

@keyframes bucketPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.02); box-shadow: 0 0 16px rgba(255, 142, 113, 0.28); }
  100% { transform: scale(1); }
}

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

@media (max-width: 620px) {
  /* 解决移动端软键盘输入自动放大问题 */
  input[type="text"],
  input[type="date"],
  input[type="search"],
  input[type="password"],
  textarea,
  select {
    font-size: max(16px, 1rem) !important;
  }

  /* 底部快捷导航与音频药丸防重叠 */
  .audio-pill {
    right: max(12px, env(safe-area-inset-right, 12px)) !important;
    bottom: calc(76px + env(safe-area-inset-bottom, 12px)) !important;
    z-index: 1070;
  }

  /* 记忆手账分类标签栏横向流畅滑动（吸顶与原生 App 手感） */
  .memories-bucket__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-right: -10px;
    margin-left: -10px;
    padding-right: 10px;
    padding-left: 10px;
  }

  .memories-bucket__tabs::-webkit-scrollbar {
    display: none;
  }

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

  /* 恋爱清单卡片紧凑排版 */
  .memories-bucket {
    padding: 18px 14px !important;
  }

  .memories-bucket__head {
    margin-bottom: 14px;
  }

  .memories-bucket__progress-wrap {
    padding: 10px 14px;
    margin-bottom: 16px;
  }

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

  .polaroid-modal__preview-box {
    max-height: 48vh;
  }

  /* 照片墙幻灯片放映移动端适配 */
  .gallery-slideshow__stage {
    padding: 16px !important;
  }

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

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

/* --------------------------------------------------------------------------
   6. 平板端深度适配 (Tablet Adaptation: 621px - 1024px)
   覆盖：iPad Mini, iPad 10.2", iPad Air, iPad Pro 11" & Android 平板
   -------------------------------------------------------------------------- */

@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;
  }

  /* 1. 平板日历：日历网格与侧栏比例优化 */
  .calendar-workspace {
    display: grid !important;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) !important;
    gap: 24px !important;
  }

  .calendar-grid {
    gap: 6px !important;
  }

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

  .calendar-rail {
    padding: 20px !important;
  }

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

  .gallery-hero__actions {
    flex-wrap: wrap;
  }

  .gallery-search-wrap {
    grid-template-columns: 1fr auto !important;
    gap: 14px !important;
  }

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

  .memories-stats article {
    padding: 16px 12px !important;
  }

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

  /* 平板端恋爱 100 件小事双列卡片 */
  .memories-bucket__list {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 14px !important;
  }

  /* 平板端拍立得明信片弹窗尺寸 */
  .polaroid-modal__dialog {
    width: 520px !important;
    padding: 24px !important;
  }

  /* 平板端音频药丸优雅定位 */
  .audio-pill {
    right: 20px;
    bottom: calc(76px + env(safe-area-inset-bottom, 12px));
  }
}
