/* ===================================================
   鷹家Fun生買物社 - 合併佈局樣式
   來源: hybrid-layout.css + masonry-layout.css
   =================================================== */

/* ============================================
   手機端：團購雙排瀑布流 + 折扣碼單排
   ============================================ */
@media (max-width: 767px) {
  
  /* 團購卡片容器 - 雙排瀑布流 */
  .masonry-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2px;
    padding: 2px;
    grid-auto-flow: dense;
  }
  
  /* 折扣碼容器 - 單排顯示 */
  .coupon-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 8px;
  }
  
  /* 團購卡片樣式 */
  .masonry-card {
    break-inside: avoid;
    page-break-inside: avoid;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    transition: all 0.2s ease;
  }
  
  .masonry-card:active {
    transform: scale(0.98);
    opacity: 0.95;
  }
  
  /* 圖片容器 */
  .masonry-card-image-wrapper {
    position: relative;
    width: 100%;
    background: #f9fafb;
    overflow: hidden;
    margin: 0;
    padding: 0;
    cursor: pointer;
    transition: all 0.3s ease;
  }
  
  .masonry-card-image-wrapper:active .masonry-card-image {
    opacity: 0.85;
    transform: scale(0.98);
  }
  
  .masonry-card-image {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    user-select: none;
    -webkit-user-select: none;
  }
  
  /* 內容區 */
  .masonry-card-content {
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  
  /* 標題 */
  .masonry-card-title {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
    color: #1f2937;
  }
  
  /* 標籤容器 */
  .masonry-card-content .flex.flex-wrap {
    gap: 3px;
  }
  
  .masonry-card-content .flex.flex-wrap span {
    font-size: 10px;
    padding: 2px 5px;
    white-space: nowrap;
    border-radius: 2px;
  }
  
  /* 描述文字 */
  .masonry-card-content p {
    font-size: 11px;
    line-height: 1.4;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: #6b7280;
  }
  
  /* 按鈕 */
  .masonry-card-content button,
  .masonry-card-content a.block {
    font-size: 12px;
    padding: 6px 8px;
    border-radius: 3px;
    font-weight: 600;
    white-space: nowrap;
  }
  
  /* 倒數計時 */
  .masonry-card-content .flex.items-center.gap-2 {
    font-size: 11px;
  }
  
  /* 折扣碼卡片 */
  .coupon-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid #fcd34d;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  
  .coupon-card:active {
    opacity: 0.9;
  }
  
  /* 折扣碼標題 */
  .coupon-card-title {
    font-size: 16px;
    font-weight: 700;
    color: #78350f;
    margin: 0 0 8px 0;
  }
  
  /* 折扣碼顯示區 */
  .coupon-code-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px;
    background: #fef3c7;
    border-radius: 8px;
  }
  
  /* 折扣碼文字 */
  .coupon-code-text {
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: 700;
    color: #78350f;
    letter-spacing: 1px;
    flex: 1;
  }
  
  /* 複製按鈕 */
  .coupon-copy-button {
    font-size: 14px;
    padding: 8px 16px;
    background: #f59e0b;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
  }
  
  .coupon-copy-button:active {
    background: #d97706;
    transform: scale(0.95);
  }
  
  /* 折扣碼其他資訊 */
  .coupon-card-info {
    font-size: 13px;
    color: #6b7280;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  
  /* 折扣碼按鈕 */
  .coupon-card button,
  .coupon-card a.block {
    font-size: 14px;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
  }
}

/* ============================================
   平板端：3 欄網格
   ============================================ */
@media (min-width: 768px) and (max-width: 1023px) {
  .masonry-grid,
  .coupon-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    padding: 12px;
  }
  
  .masonry-card,
  .coupon-card {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    border: 2px solid #fcd34d;
    transition: all 0.3s ease;
  }
  
  .masonry-card:hover,
  .coupon-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    border-color: #f59e0b;
  }
  
  .masonry-card-image-wrapper {
    position: relative;
    width: 100%;
    padding-top: 75%;
    background: #f5f5f5;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
  }
  
  .masonry-card-image-wrapper:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }
  
  .masonry-card-image-wrapper:hover .masonry-card-image {
    opacity: 0.92;
    transform: scale(1.03);
  }
  
  .masonry-card-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    user-select: none;
    -webkit-user-select: none;
  }
  
  .masonry-card-content {
    padding: 16px;
  }
  
  .masonry-card-title {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.4;
    margin-bottom: 8px;
  }
  
  .coupon-code-display {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: #fef3c7;
    border-radius: 6px;
  }
  
  .coupon-code-text {
    font-size: 15px;
  }
  
  .coupon-copy-button {
    font-size: 13px;
    padding: 8px 14px;
  }
}

/* ============================================
   桌面端：3-4 欄網格
   ============================================ */
@media (min-width: 1024px) {
  .masonry-grid,
  .coupon-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    padding: 16px;
  }
  
  .masonry-card,
  .coupon-card {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    border: 2px solid #fcd34d;
    transition: all 0.3s ease;
  }
  
  .masonry-card:hover,
  .coupon-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
    border-color: #f59e0b;
  }
  
  .masonry-card-image-wrapper {
    position: relative;
    width: 100%;
    padding-top: 75%;
    background: #f5f5f5;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
  }
  
  .masonry-card-image-wrapper:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }
  
  .masonry-card-image-wrapper:hover .masonry-card-image {
    opacity: 0.92;
    transform: scale(1.03);
  }
  
  .masonry-card-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    user-select: none;
    -webkit-user-select: none;
  }
  
  .masonry-card-content {
    padding: 20px;
  }
  
  .masonry-card-title {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.4;
    margin-bottom: 12px;
  }
  
  .coupon-code-display {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #fef3c7;
    border-radius: 8px;
  }
  
  .coupon-code-text {
    font-size: 16px;
  }
  
  .coupon-copy-button {
    font-size: 14px;
    padding: 10px 16px;
  }
}

@media (min-width: 1280px) {
  .masonry-grid,
  .coupon-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ============================================
   通用樣式
   ============================================ */

/* 過期商品 */
.masonry-card.opacity-60,
.coupon-card.opacity-60 {
  opacity: 0.6;
  filter: grayscale(50%);
}

/* 載入動畫 */
.masonry-card.loading,
.coupon-card.loading {
  animation: shimmer 1.5s infinite;
  background: linear-gradient(
    90deg,
    #f0f0f0 25%,
    #e0e0e0 50%,
    #f0f0f0 75%
  );
  background-size: 200% 100%;
}

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

/* 圖片載入中的佔位 */
.masonry-card-image[loading="lazy"] {
  background: linear-gradient(135deg, #fef3c7 0%, #fcd34d 50%, #fef3c7 100%);
}

/* 文字行數限制 */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 平滑滾動 */
html {
  scroll-behavior: smooth;
}

/* 觸控回饋（僅手機） */
@media (max-width: 767px) {
  button:active,
  a:active {
    transform: scale(0.95);
  }
}

/* ============================================
   無障礙優化
   ============================================ */

/* 鍵盤焦點樣式 */
.masonry-card:focus-within,
.coupon-card:focus-within {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* 高對比模式支援 */
@media (prefers-contrast: high) {
  .masonry-card,
  .coupon-card {
    border-width: 2px;
  }
  
  .masonry-card-title,
  .coupon-card-title {
    font-weight: 800;
  }
}

/* 減少動畫（尊重用戶偏好） */
@media (prefers-reduced-motion: reduce) {
  .masonry-card,
  .coupon-card,
  .masonry-card-image,
  button,
  a {
    transition: none !important;
    animation: none !important;
  }
}

/* ============================================
   列印樣式
   ============================================ */
@media print {
  .masonry-grid,
  .coupon-grid {
    display: block;
  }
  
  .masonry-card,
  .coupon-card {
    page-break-inside: avoid;
    break-inside: avoid;
    margin-bottom: 20px;
    border: 1px solid #000;
  }
  
  button {
    display: none;
  }
}

/* SEO 專用：螢幕閱讀器可見，一般使用者不可見 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}


/* ============================================
   倒數計時樣式
   ============================================ */

/* 倒數計時脈動動畫 */
@keyframes pulse-subtle {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.8;
    transform: scale(1.05);
  }
}

.animate-pulse-subtle {
  animation: pulse-subtle 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* 倒數計時數字樣式 */
#countdownTime {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
}

/* ============================================
   清除篩選按鈕動畫
   ============================================ */

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.filter-clear-btn {
  animation: slideIn 0.3s ease-out;
}

/* ============================================
   響應式優化
   ============================================ */

/* 平板和手機適配 */
@media (max-width: 1023px) {
  header.header-compact {
    padding-top: 0.375rem !important;
    padding-bottom: 0.375rem !important;
  }

  /* 倒數計時手機版優化 */
  #todayCountdown .flex-wrap {
    justify-content: center;
  }

  #todayCountdown .text-sm {
    font-size: 0.75rem;
  }
}

/* 手機版 */
@media (max-width: 767px) {

  /* 倒數計時更緊湊 */
  #todayCountdown {
    padding: 0.5rem;
  }

  #countdownTime {
    font-size: 1.125rem;
    /* 手機版時間字體稍小，更緊湊 */
  }

  #todayCountdown .text-2xl {
    font-size: 1.5rem;
  }
  
  /* 確保手機版時間在第一排 */
  #todayCountdown .flex.flex-col {
    gap: 0.5rem;
  }
}

/* ============================================
   無障礙優化
   ============================================ */

/* 動畫優化 - 尊重用戶偏好 */
@media (prefers-reduced-motion: reduce) {

  header,
  header.header-compact,
  header.header-compact .hidden.lg\\:flex,
  header.header-compact .lg\\:hidden.text-center,
  header.header-compact #bannerSlot,
  .filter-clear-btn {
    transition: none !important;
    animation: none !important;
  }

  .animate-pulse-subtle {
    animation: none !important;
  }
}

/* 高對比模式 */
@media (prefers-contrast: high) {
  #todayCountdown {
    border-width: 3px;
  }

  .filter-clear-btn {
    border: 2px solid currentColor;
  }
}

/* ============================================
   列印樣式
   ============================================ */

@media print {
  header.header-compact {
    padding: 1rem !important;
  }

  header.header-compact .hidden.lg\\:flex,
  header.header-compact .lg\\:hidden.text-center {
    max-height: none;
    opacity: 1;
  }

  #todayCountdown,
  .filter-clear-btn {
    display: none;
  }
}
