/* ============================================
   若见茶舍 - 响应式样式
   v4: 图片点击放大灯箱
   ============================================ */

/* --- 桌面超大屏 (1400px+) --- */
@media (min-width: 1400px) {
  .container { max-width: 1320px; }
  .hero h1 { font-size: 4rem; }
}

/* --- 笔记本/小桌面 (1024px - 1199px) --- */
@media (max-width: 1199px) {
  .hero h1 { font-size: 2.8rem; }
  .entry-grid { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: repeat(2, 1fr); }
}

/* --- 平板竖屏 (768px - 1023px) --- */
@media (max-width: 1023px) {
  :root { font-size: 15px; }

  .section { padding: 48px 0; }
  .section-title { font-size: 1.7rem; }

  /* 导航 */
  .nav-links { gap: 20px; }
  .nav-links a { font-size: 0.9rem; }

  /* Hero */
  .hero { min-height: 90vh; }
  .hero h1 { font-size: 2.4rem; }
  .hero p { font-size: 1rem; }

  /* 快捷入口 */
  .entry-grid { gap: 20px; }
  .entry-card { padding: 32px 16px; }

  /* 页脚 */
  .footer-grid { gap: 32px; }
}

/* --- 手机横屏 (576px - 767px) --- */
@media (max-width: 767px) {
  :root { font-size: 14px; }

  .section { padding: 40px 0; }
  .section-title { font-size: 1.5rem; margin-bottom: 24px; }

  /* 导航：汉堡菜单 */
  .nav-toggle { display: flex; }
  .nav-links {
    display: none;
    position: fixed;
    top: 70px; left: 0; right: 0;
    background: rgba(250,250,245,0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    flex-direction: column;
    align-items: stretch;
    padding: 16px 24px 24px;
    gap: 0;
    border-bottom: 1px solid var(--color-border);
    box-shadow: 0 8px 30px var(--color-shadow);
  }

  .nav-links.open { display: flex; }

  .nav-links a {
    padding: 14px 0;
    font-size: 1rem;
    border-bottom: 1px solid var(--color-border);
  }

  .nav-links a:last-child { border-bottom: none; }
  .nav-links a::after { display: none; }

  /* Hero */
  .hero { min-height: 100vh; padding-top: 70px; }
  .hero h1 { font-size: 2rem; }
  .hero p { font-size: 0.95rem; margin-bottom: 32px; }
  .hero-actions { flex-direction: column; align-items: center; }
  .hero-actions .btn { width: 80%; max-width: 260px; }

  /* 快捷入口：两列 */
  .entry-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .entry-card { padding: 24px 12px; }
  .entry-icon { width: 48px; height: 48px; font-size: 1.4rem; }
  .entry-card h3 { font-size: 0.95rem; }
  .entry-card p { font-size: 0.78rem; }

  /* 通用网格 → 1列 */
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr !important;
  }

  /* 页脚 */
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .footer-bottom {
    flex-direction: column;
    gap: 12px;
    text-align: center;
    font-size: 0.8rem;
  }
}

/* --- 手机竖屏 (≤575px) --- */
@media (max-width: 575px) {
  :root { font-size: 13px; }

  .container { padding: 0 12px; }

  /* Hero */
  .hero h1 { font-size: 1.7rem; }
  .hero-badge { font-size: 0.75rem; padding: 4px 14px; }

  /* 快捷入口：单列 */
  .entry-grid { grid-template-columns: 1fr; }

  /* 按钮满宽 */
  .btn { width: 100%; max-width: 280px; }

  /* 卡片内边距缩小 */
  .card-body { padding: 16px; }
}

/* --- 普通手机适配（覆盖 HTML 内联 style）--- */
@media (max-width: 767px) {
  html { -webkit-text-size-adjust: 100%; }

  body {
    overflow-x: hidden;
    min-width: 0;
  }

  /*
   * 各页 nav-links 写了 style="display:flex"，会盖过媒体查询。
   * 普通手机上一屏只剩导航「目录」，正文被挤到下面或看不见。
   */
  .nav-links:not(.open) {
    display: none !important;
  }

  .nav-links.open {
    display: flex !important;
    flex-direction: column;
    align-items: stretch !important;
    position: fixed;
    top: 70px;
    left: 0;
    right: 0;
    z-index: 999;
    max-height: calc(100dvh - 70px);
    overflow-y: auto;
    background: rgba(250, 250, 245, 0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 16px 24px 24px;
    gap: 0 !important;
    border-bottom: 1px solid var(--color-border);
    box-shadow: 0 8px 30px var(--color-shadow);
  }

  .nav-links.open a {
    padding: 14px 0;
    font-size: 1rem;
    border-bottom: 1px solid var(--color-border);
  }

  .nav-links.open a:last-child { border-bottom: none; }

  /* nav-toggle 内联 display:none 导致汉堡永不出现 */
  .nav-toggle {
    display: flex !important;
    flex-shrink: 0;
    z-index: 1001;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
  }

  .navbar .container {
    width: 100%;
    max-width: 100%;
    padding-left: 12px;
    padding-right: 12px;
    gap: 8px;
  }

  .nav-logo span {
    font-size: 1.15rem !important;
  }

  /* 四列快捷入口 + 页脚四列网格 → 防横向溢出 */
  [style*="repeat(4,1fr)"],
  [style*="repeat(4, 1fr)"],
  [style*="2fr 1fr 1fr 1fr"],
  [style*="2fr 1fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
    gap: 12px !important;
  }

  /* 内联三列/两列网格 → 手机两列或单列 */
  [style*="repeat(3,1fr)"],
  [style*="repeat(3, 1fr)"],
  [style*="repeat(2,1fr)"],
  [style*="repeat(2, 1fr)"] {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  .hero-content[style] {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto;
    box-sizing: border-box;
  }

  .hero[style*="min-height:100vh"],
  .hero[style*="min-height: 100vh"] {
    width: 100% !important;
    max-width: 100vw;
    overflow-x: hidden;
  }

  section.section[style],
  footer[style] {
    max-width: 100vw;
    overflow-x: hidden;
  }

  /* 底栏占位，避免内容被挡住 */
  body.has-mobile-bottom-nav {
    padding-bottom: calc(62px + env(safe-area-inset-bottom, 0px));
  }

  /* 内联大标题 */
  .hero h1[style],
  section h1[style] {
    font-size: 1.75rem !important;
    line-height: 1.35 !important;
  }

  section[style*="height:340px"],
  section[style*="height: 340px"] {
    height: auto !important;
    min-height: 200px !important;
    padding-top: 90px !important;
    padding-bottom: 32px !important;
  }

  section[style*="height:340px"] h1,
  section[style*="height: 340px"] h1 {
    font-size: 1.8rem !important;
  }

  .hero[style*="min-height:100vh"],
  .hero[style*="min-height: 100vh"] {
    min-height: calc(100dvh - 70px) !important;
    padding-top: 80px !important;
    padding-bottom: 32px !important;
    box-sizing: border-box;
  }

  .hero p[style] {
    font-size: 0.95rem !important;
    margin-bottom: 24px !important;
  }

  /* 滚动动画在部分手机 WebView 不触发 → 内容一直 opacity:0 */
  .fade-in-up,
  .fade-in-left,
  .fade-in-right,
  .scale-in {
    opacity: 1 !important;
    transform: none !important;
  }

  /* 卡片内联 padding 缩小 */
  .card[style*="padding:32px"] {
    padding: 20px !important;
  }
}

@media (min-width: 480px) and (max-width: 767px) {
  [style*="repeat(4,1fr)"],
  [style*="repeat(4, 1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  [style*="repeat(3,1fr)"],
  [style*="repeat(3, 1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media (max-width: 575px) {
  [style*="repeat(4,1fr)"],
  [style*="repeat(4, 1fr)"],
  [style*="2fr 1fr 1fr 1fr"],
  [style*="2fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
}

/* --- 手机底栏快捷导航 --- */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 767px) {
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 998;
    background: rgba(250, 250, 245, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--color-border);
    box-shadow: 0 -4px 20px var(--color-shadow);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .mobile-bottom-nav a,
  .mobile-bottom-nav button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 8px 4px 10px;
    min-height: 56px;
    border: none;
    background: none;
    color: #7A6E5E;
    font-size: 0.68rem;
    font-family: var(--font-body);
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-bottom-nav a.active,
  .mobile-bottom-nav a:active,
  .mobile-bottom-nav button:active {
    color: var(--color-green);
  }

  .mobile-bottom-nav .mbn-icon {
    font-size: 1.25rem;
    line-height: 1;
  }
}

/* --- 打印样式 --- */
@media print {
  .navbar, .hero-actions, .btn, .footer-social,
  .toast, .leaf-particle, .mobile-bottom-nav { display: none !important; }

  body { background: white; color: black; }

  .hero {
    min-height: auto;
    padding: 40px 0;
    background: white !important;
  }

  a { color: #000; text-decoration: underline; }
}

/* --- 图片灯箱：点击放大 --- */
img.rj-zoomable {
  cursor: zoom-in;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.rj-photo-wrap {
  cursor: zoom-in;
  position: relative;
}

.rj-photo-wrap::after {
  content: '🔍 点击放大';
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(20, 16, 12, 0.55);
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.75rem;
  line-height: 1.4;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.rj-photo-wrap:hover::after {
  opacity: 1;
}

img.rj-zoomable:hover,
.rj-photo-wrap:hover img.rj-zoomable {
  transform: scale(1.02);
  box-shadow: 0 4px 20px rgba(62, 50, 40, 0.15);
}

.rj-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: rgba(20, 16, 12, 0.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.rj-lightbox.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.rj-lightbox-inner {
  max-width: min(96vw, 1400px);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.rj-lightbox-img {
  display: block;
  max-width: 100%;
  max-height: calc(92vh - 48px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.45);
  transform: scale(0.96);
  transition: transform 0.25s ease;
}

.rj-lightbox.open .rj-lightbox-img {
  transform: scale(1);
}

.rj-lightbox-caption {
  margin: 14px 0 0;
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.95rem;
  text-align: center;
  line-height: 1.5;
}

.rj-lightbox-close {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10051;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease;
}

.rj-lightbox-close:hover {
  background: rgba(255, 255, 255, 0.28);
}

body.rj-lightbox-open {
  overflow: hidden;
}

@media (max-width: 767px) {
  .rj-lightbox {
    padding: 12px 8px;
  }

  .rj-lightbox-img {
    max-height: calc(100vh - 80px);
    border-radius: 6px;
  }

  .rj-lightbox-close {
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
  }

  img.rj-zoomable:hover,
  .rj-photo-wrap:hover img.rj-zoomable {
    transform: none;
  }

  .rj-photo-wrap::after {
    opacity: 1;
  }
}
