/* ═══════════════════════════════════════════════════════════
   甜熊风格展示 H5
   样式移植自麦芽纪小程序 maiyaji-xcx/src/app/globals.css
   (.waterfall-* / .detail-* / .gallery-header 三组,去掉小程序专属部分)
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg: #fafafa;
  --bg-card: #ffffff;
  --text: #1a1a1a;
  --text-secondary: #666;
  --text-muted: #999;
  --border: #f0f0f0;
  --primary: #1a1a1a;
  --radius: 12px;
  --radius-sm: 8px;
  --safe-bottom: constant(safe-area-inset-bottom, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: constant(safe-area-inset-top, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'PingFang SC',
               'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  -webkit-overscroll-behavior-y: none;
}

img { display: block; }

/* ═══════ 列表页 ═══════ */

.gallery-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.gallery-top-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(12px + var(--safe-top)) 16px 12px;
}

.brand-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--text);
}

.brand-sub {
  font-size: 0.6rem;
  font-weight: 400;
  letter-spacing: 2px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 2px;
}

.brand-lockup { text-align: center; }

/* 瀑布流 — 固定 3:4 卡片,两列 */
.waterfall {
  display: flex;
  gap: 8px;
  padding: 8px 8px 0;
}

.waterfall-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.waterfall-item {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  animation: fadeUp 0.4s ease-out both;
}

.waterfall-item:active {
  transform: scale(0.98);
  transition: transform 0.1s;
}

.waterfall-cover-wrap {
  position: relative;
  width: 100%;
  padding-bottom: 133%; /* 3:4 竖版 */
  background: linear-gradient(110deg, #f0f0f0 30%, #fafafa 50%, #f0f0f0 70%);
  background-size: 200% 100%;
  overflow: hidden;
}

.waterfall-cover-wrap.loading {
  animation: shimmer 1.2s ease-in-out infinite;
}

.waterfall-cover {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.waterfall-info {
  padding: 8px 10px 10px;
}

.waterfall-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-footer {
  padding: 24px 16px calc(32px + var(--safe-bottom));
  text-align: center;
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 1px;
  line-height: 1.9;
}

/* ═══════ 详情页 ═══════ */

.detail-page {
  position: relative;
  min-height: 100vh;
  background: #fff;
  animation: slideUpPage 0.22s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.detail-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.detail-back {
  position: absolute;
  left: 12px;
  bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  font-size: 1.1rem;
  color: var(--text);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.detail-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 1px;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-count-badge {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.detail-photos { padding-top: calc(48px + var(--safe-top)); }

.detail-photo-wrap {
  position: relative;
  width: 100%;
  background: linear-gradient(110deg, #f0f0f0 30%, #fafafa 50%, #f0f0f0 70%);
  background-size: 200% 100%;
}

.detail-photo-wrap.loading { animation: shimmer 1.2s ease-in-out infinite; }

.detail-photo {
  width: 100%;
  display: block;
  opacity: 0;
  transition: opacity 0.35s ease;
  -webkit-touch-callout: default;
}

.detail-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(52px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 100;
}

.detail-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 32px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 24px;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.2s;
}

.detail-action:active { opacity: 0.85; }

.detail-action svg { width: 15px; height: 15px; }

.detail-action.ghost {
  background: #f2f2f2;
  color: var(--text-secondary);
}

.detail-spacer { height: calc(52px + var(--safe-bottom)); }

/* ═══════ 全屏看图(非微信环境降级) ═══════ */

.image-viewer-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #000;
  animation: viewerFadeIn 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: pan-y;
}

.image-viewer-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.image-viewer-close {
  position: absolute;
  top: calc(var(--safe-top) + 12px);
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.image-viewer-counter {
  position: absolute;
  bottom: calc(var(--safe-bottom) + 20px);
  left: 0;
  right: 0;
  text-align: center;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.75rem;
  letter-spacing: 1px;
}

/* ═══════ 轻提示 ═══════ */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 96px);
  transform: translate(-50%, 8px);
  max-width: 78vw;
  padding: 10px 20px;
  background: rgba(0, 0, 0, 0.82);
  color: #fff;
  font-size: 0.8rem;
  line-height: 1.6;
  text-align: center;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 10000;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ═══════ 动画 ═══════ */

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideUpPage {
  from { transform: translateY(24px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes viewerFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
