/* ═══════════════════════════════════════════
   CIRCA — Home Page
   循物 — 首页
═══════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@300;400;500;600&family=DM+Sans:wght@400;500;600;700&display=swap');

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

:root {
  --bg: #FAF8F5;
  --surface: #F0EFE9;
  --card: #FFFFFF;
  --text: #111111;
  --text-secondary: #6B6B6B;
  --text-muted: #9B9B9B;
  --border: #E5E4E0;
  --accent: #C8FF00;
  --accent-muted: rgba(200, 255, 0, 0.15);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.08);
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 20px);
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: 'DM Sans', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

::selection {
  background: var(--accent);
  color: var(--text);
}

/* ═══════════════════════════════════════════
   Header
═══════════════════════════════════════════ */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(250, 248, 245, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 6px 20px 8px;
  padding-top: calc(env(safe-area-inset-top, 8px) + 4px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 600px;
  margin: 0 auto;
  min-height: 28px;
}

.header-logo {
  font-family: 'Cormorant Garamond', serif;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--text);
}

.header-logo span {
  font-size: 11px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-left: 8px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  transition: all 0.3s var(--ease-out);
  position: relative;
}

.header-btn:hover {
  background: var(--surface);
}

.header-btn svg {
  width: 20px;
  height: 20px;
}

.notification-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  border: 2px solid var(--bg);
}

/* ═══════════════════════════════════════════
   Search Bar
═══════════════════════════════════════════ */
.search-container {
  padding: calc(58px + env(safe-area-inset-top, 0px)) 20px 10px;
  max-width: 600px;
  margin: 0 auto;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 50px;
  padding: 12px 20px;
  transition: all 0.3s var(--ease-out);
}

.search-bar:focus-within {
  border-color: var(--text);
  box-shadow: 0 0 0 4px rgba(0,0,0,0.04);
}

.search-bar svg {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-bar input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  outline: none;
}

.search-bar input::placeholder {
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════
   Categories
═══════════════════════════════════════════ */
.categories {
  padding: 12px 20px 0;
  max-width: 600px;
  margin: 0 auto;
}

.categories-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.categories-scroll::-webkit-scrollbar {
  display: none;
}

.category-chip {
  flex-shrink: 0;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s var(--ease-out);
  white-space: nowrap;
}

.category-chip:hover {
  border-color: var(--text);
  color: var(--text);
}

.category-chip.active {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

/* ═══════════════════════════════════════════
   Main Content
═══════════════════════════════════════════ */
.main-content {
  padding: 20px 20px 110px;
  max-width: 600px;
  margin: 0 auto;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 20px;
  font-weight: 500;
  color: var(--text);
}

.section-count {
  font-size: 12px;
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════
   Product Grid (Clean Uniform Grid)
═══════════════════════════════════════════ */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  align-items: start;
}

.product-card {
  background: var(--card);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: all 0.4s var(--ease-out);
  cursor: pointer;
  position: relative;
  box-shadow: var(--shadow-sm);
}

.product-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

/* Square image containers */
.product-image-wrapper {
  position: relative;
  width: 100%;
  padding-top: 100%; /* 1:1 Square */
  overflow: hidden;
}

.product-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s var(--ease-out);
}

.product-card:hover .product-image {
  transform: scale(1.06);
}

/* Product tag (NEW, HOT, etc) */
.product-tag {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 4px 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--accent);
  color: var(--text);
  border-radius: 50px;
  z-index: 2;
}

.product-tag.new {
  background: var(--text);
  color: var(--bg);
}

/* Wishlist button */
.wishlist-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(8px);
  border-radius: 50%;
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.3s var(--ease-out);
  z-index: 2;
  border: none;
  cursor: pointer;
}

.product-card:hover .wishlist-btn {
  opacity: 1;
  transform: scale(1);
}

.wishlist-btn svg {
  width: 16px;
  height: 16px;
  color: var(--text);
  transition: all 0.3s var(--ease-out);
}

.wishlist-btn.active svg {
  fill: #FF4757;
  color: #FF4757;
}

.wishlist-btn:active {
  transform: scale(0.95);
}

/* Quick view overlay */
.product-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.5) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.3s var(--ease-out);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 14px;
}

.product-card:hover .product-overlay {
  opacity: 1;
}

.product-quick-view {
  padding: 8px 20px;
  background: rgba(255,255,255,0.95);
  border-radius: 50px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  transform: translateY(10px);
  transition: all 0.3s var(--ease-out);
}

.product-card:hover .product-quick-view {
  transform: translateY(0);
}

/* Product Info */
.product-info {
  padding: 12px;
}

.product-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.product-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.product-price {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.product-price-original {
  font-size: 11px;
  color: var(--text-muted);
  text-decoration: line-through;
}

/* ═══════════════════════════════════════════
   Bottom Navigation
═══════════════════════════════════════════ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(250, 248, 245, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  padding: 2px 20px;
  padding-bottom: calc(2px + var(--safe-bottom));
  z-index: 100;
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-around;
  max-width: 440px;
  margin: 0 auto;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 4px 2px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.3s var(--ease-out);
}

/* Center raised FAB inside bottom nav */
.nav-fab {
  flex: 0 0 auto;
  margin: -22px 6px 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--text);
  color: var(--bg);
  border: 4px solid var(--bg);
  border-radius: 50%;
  box-shadow: 0 6px 18px rgba(0,0,0,0.20);
  cursor: pointer;
  transition: transform 0.3s var(--ease-out), box-shadow 0.3s var(--ease-out);
}
.nav-fab:hover { transform: scale(1.06); box-shadow: 0 10px 22px rgba(0,0,0,0.24); }
.nav-fab:active { transform: scale(0.96); }
.nav-fab svg { width: 20px; height: 20px; }

.nav-item:hover {
  color: var(--text);
}

.nav-item.active {
  color: var(--text);
  background: var(--accent-muted);
}

.nav-item svg {
  width: 20px;
  height: 20px;
}

.nav-item span {
  font-size: 9px;
  font-weight: 600;
}

/* ═══════════════════════════════════════════
   Floating Action Button
═══════════════════════════════════════════ */
.fab {
  position: fixed;
  bottom: calc(85px + var(--safe-bottom));
  right: 20px;
  width: 54px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--text);
  color: var(--bg);
  border-radius: 50%;
  box-shadow: 0 6px 20px rgba(0,0,0,0.18);
  cursor: pointer;
  transition: all 0.4s var(--ease-out);
  z-index: 90;
  border: none;
}

.fab:hover {
  transform: scale(1.08);
  box-shadow: 0 10px 28px rgba(0,0,0,0.22);
}

.fab:active {
  transform: scale(0.96);
}

.fab svg {
  width: 22px;
  height: 22px;
}

/* ═══════════════════════════════════════════
   Toast
═══════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: calc(160px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  pointer-events: none;
}

.toast {
  padding: 12px 24px;
  background: var(--text);
  color: var(--bg);
  border-radius: 50px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  animation: toastIn 0.3s var(--ease-out);
}

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

/* ═══════════════════════════════════════════
   Responsive
═══════════════════════════════════════════ */

/* ── 竖屏手机 (< 640px) ── 图片改 3:4 比例，增大间距 */
@media (max-width: 639px) {
  .product-grid {
    gap: 14px;
  }

  .product-image-wrapper {
    padding-top: 56.25%; /* 16:9 更宽的图，竖屏视觉更舒展 */
  }

  .product-info {
    padding: 10px;
  }

  .product-title {
    font-size: 12px;
  }

  .product-price {
    font-size: 14px;
  }

  .section-header {
    margin-bottom: 12px;
  }
}

@media (min-width: 640px) {
  .product-image-wrapper {
    padding-top: 100%; /* 1:1 方图 */
  }
}

@media (min-width: 768px) and (min-height: 600px) {
  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(172px, 1fr));
    gap: 18px;
  }

  .header-inner,
  .search-container,
  .categories,
  .main-content {
    max-width: 820px;
  }
}

/* ── 横屏手机 (宽 >=640 且 高 <500) ── 压缩 chrome，避开 fab/toast 叠叠乐 ── */
@media (min-width: 640px) and (max-height: 500px) {
  .header {
    padding: calc(6px + var(--safe-top)) 72px 6px 18px;
  }

  .header-inner {
    max-width: none;
  }

  .search-container {
    max-width: none;
    margin: 0;
    padding: calc(46px + var(--safe-top)) 72px 6px 18px;
  }

  .search-bar {
    max-width: 440px;
    padding: 9px 16px;
  }

  .categories {
    max-width: none;
    margin: 0;
    padding: 4px 72px 0 18px;
  }

  .categories-scroll {
    gap: 6px;
    padding-bottom: 6px;
  }

  .category-chip {
    padding: 6px 14px;
    font-size: 12px;
  }

  .main-content {
    max-width: none;
    padding: 10px 72px 24px 18px;
  }

  .section-header {
    margin-bottom: 10px;
  }

  .bottom-nav {
    top: calc(10px + var(--safe-top));
    right: 10px;
    bottom: 10px;
    left: auto;
    width: 52px;
    border-top: 0;
    border-left: 1px solid var(--border);
    border-radius: 26px;
    padding: 8px 6px;
  }

  .nav-inner {
    height: 100%;
    max-width: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
  }

  .nav-item {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    justify-content: center;
    padding: 0;
    border-radius: 50%;
  }

  .nav-item span {
    display: none;
  }

  .nav-item svg {
    width: 18px;
    height: 18px;
  }

  .nav-fab {
    margin: 4px 0;
    width: 40px;
    height: 40px;
    border-width: 3px;
  }

  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 10px;
  }

  .product-image-wrapper {
    padding-top: 62%;
  }

  .product-info {
    padding: 8px 10px 9px;
  }

  .product-title {
    font-size: 12px;
    margin-bottom: 4px;
  }

  .product-price {
    font-size: 14px;
  }

  .wishlist-btn,
  .product-card:hover .wishlist-btn {
    opacity: 1;
    transform: scale(1);
    width: 28px;
    height: 28px;
  }

  .fab {
    bottom: calc(60px + var(--safe-bottom));
    width: 44px;
    height: 44px;
  }
  .toast-container {
    bottom: calc(110px + var(--safe-bottom));
  }
}

/* ── 桌面端：从手机放大，改为稳定的商品浏览布局 ── */
@media (min-width: 1024px) and (min-height: 600px) {
  body {
    background:
      linear-gradient(90deg, rgba(240,239,233,0.88) 0 1px, transparent 1px) 0 0 / 72px 72px,
      var(--surface);
  }

  .header {
    height: 54px;
    padding: 6px 32px 8px;
  }

  .header-inner,
  .search-container,
  .categories,
  .main-content {
    max-width: 1180px;
  }

  .header-inner {
    min-height: 42px;
  }

  .header-logo {
    font-size: 18px;
  }

  .search-container {
    padding: calc(78px + var(--safe-top)) 32px 12px;
  }

  .search-bar {
    max-width: 520px;
    margin: 0 auto;
    padding: 13px 20px;
    box-shadow: var(--shadow-sm);
  }

  .categories {
    padding: 8px 32px 0;
  }

  .categories-scroll {
    width: fit-content;
    max-width: 100%;
    margin: 0 auto;
    flex-wrap: wrap;
    justify-content: center;
    overflow: visible;
    gap: 10px;
  }

  .category-chip {
    padding: 8px 18px;
    background: rgba(255, 255, 255, 0.76);
    box-shadow: var(--shadow-sm);
  }

  .main-content {
    padding: 28px 32px 120px;
  }

  .section-header {
    justify-content: flex-start;
    gap: 14px;
    margin-bottom: 20px;
  }

  .section-title {
    font-size: 28px;
  }

  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 20px;
  }

  .product-card {
    border: 1px solid rgba(229, 228, 224, 0.8);
  }

  .product-info {
    padding: 14px;
  }

  .product-title {
    font-size: 14px;
  }

  .product-price {
    font-size: 16px;
  }

  .bottom-nav {
    left: 50%;
    right: auto;
    bottom: 18px;
    width: min(520px, calc(100vw - 48px));
    transform: translateX(-50%);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 6px 18px;
    background: rgba(250, 248, 245, 0.92);
    box-shadow: var(--shadow-lg);
  }

  .nav-inner {
    max-width: none;
  }

  .nav-item {
    padding: 8px 10px 6px;
  }
}

@media (min-width: 1280px) and (min-height: 600px) {
  .product-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}
