/*
Theme Name: スピルプ
Description: モバイル特化 楽天商品タイルサイト
Version: 1.0
*/

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

:root {
  --primary: #e83e3e;
  --primary-dark: #c72b2b;
  --bg: #f5f5f5;
  --white: #fff;
  --text: #222;
  --text-sub: #777;
  --border: #e0e0e0;
  --star: #f5a623;
  --tile-gap: 6px;
  --header-h: 100px;
}

html { font-size: 14px; }
body { background: var(--bg); color: var(--text); font-family: -apple-system, "Hiragino Sans", "Yu Gothic", sans-serif; padding-top: var(--header-h); }

a { text-decoration: none; color: inherit; }
img { display: block; width: 100%; }

/* ========== HEADER ========== */
.site-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: var(--white); box-shadow: 0 1px 4px rgba(0,0,0,.1);
}
.header-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px 6px;
}
.site-title { font-size: 1.3rem; font-weight: 800; color: var(--primary); letter-spacing: -.5px; }
.header-subtitle { font-size: .7rem; color: var(--text-sub); }

/* カテゴリータブ横スクロール */
.cat-nav {
  display: flex; overflow-x: auto; gap: 8px; padding: 0 10px 8px;
  scrollbar-width: none;
}
.cat-nav::-webkit-scrollbar { display: none; }
.cat-nav a {
  flex-shrink: 0; padding: 5px 14px; border-radius: 20px;
  font-size: .8rem; font-weight: 600; white-space: nowrap;
  background: var(--bg); color: var(--text-sub); border: 1px solid var(--border);
  transition: all .2s;
}
.cat-nav a.active, .cat-nav a:hover {
  background: var(--primary); color: var(--white); border-color: var(--primary);
}

/* ========== RANKING BANNER ========== */
.ranking-section { padding: 10px 10px 4px; }
.section-title {
  font-size: .85rem; font-weight: 700; color: var(--text-sub);
  margin-bottom: 8px; display: flex; align-items: center; gap: 6px;
}
.section-title::before { content: ""; display: inline-block; width: 3px; height: 14px; background: var(--primary); border-radius: 2px; }

.ranking-scroll {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px;
  scrollbar-width: none;
}
.ranking-scroll::-webkit-scrollbar { display: none; }

.ranking-card {
  flex-shrink: 0; width: 120px; background: var(--white);
  border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.08);
  position: relative;
}
.ranking-card .rank-badge {
  position: absolute; top: 4px; left: 4px; z-index: 2;
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 800; color: var(--white);
}
.rank-1 { background: #d4af37; }
.rank-2 { background: #a8a9ad; }
.rank-3 { background: #cd7f32; }
.rank-other { background: rgba(0,0,0,.45); }

.ranking-card .card-img { width: 120px; height: 120px; object-fit: cover; }
.ranking-card .card-price {
  padding: 4px 6px; font-size: .75rem; font-weight: 700; color: var(--primary);
}

/* ========== TILE GRID ========== */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--tile-gap);
  padding: 10px var(--tile-gap);
}

.tile {
  background: var(--white); border-radius: 8px; overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.07);
  transition: transform .15s;
}
.tile:active { transform: scale(.97); }

.tile-img-wrap { position: relative; width: 100%; padding-top: 100%; overflow: hidden; }
.tile-img-wrap img {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover;
}
.tile-img-wrap .affiliate-badge {
  position: absolute; bottom: 4px; right: 4px;
  background: var(--primary); color: var(--white);
  font-size: .6rem; font-weight: 700; padding: 2px 5px; border-radius: 3px;
}

.tile-body { padding: 6px 8px 8px; }
.tile-name {
  font-size: .75rem; line-height: 1.4; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  margin-bottom: 4px;
}
.tile-price { font-size: .9rem; font-weight: 800; color: var(--primary); }
.tile-price span { font-size: .7rem; font-weight: 400; color: var(--text-sub); }

.tile-review {
  display: flex; align-items: center; gap: 3px; margin-top: 3px;
}
.stars { color: var(--star); font-size: .75rem; letter-spacing: -1px; }
.review-count { font-size: .65rem; color: var(--text-sub); }

/* ========== LOAD MORE ========== */
.load-more-wrap { text-align: center; padding: 16px; }
.btn-load {
  background: var(--white); border: 1.5px solid var(--primary); color: var(--primary);
  padding: 10px 32px; border-radius: 24px; font-size: .85rem; font-weight: 700;
  cursor: pointer; transition: all .2s;
}
.btn-load:hover { background: var(--primary); color: var(--white); }

/* ========== SINGLE PRODUCT ========== */
.product-hero img { width: 100%; max-height: 360px; object-fit: contain; background: #fafafa; }
.product-info { padding: 14px; }
.product-price { font-size: 1.4rem; font-weight: 800; color: var(--primary); margin-bottom: 6px; }
.product-name { font-size: .95rem; line-height: 1.6; margin-bottom: 10px; }
.product-review { display: flex; align-items: center; gap: 6px; margin-bottom: 14px; }
.product-review .stars { font-size: 1rem; }
.btn-buy {
  display: block; background: var(--primary); color: var(--white);
  text-align: center; padding: 14px; border-radius: 8px;
  font-size: 1rem; font-weight: 700; margin-bottom: 12px;
  box-shadow: 0 3px 8px rgba(232,62,62,.35);
}
.product-summary { font-size: .85rem; line-height: 1.7; color: var(--text-sub); margin-top: 14px; }

/* ========== FOOTER ========== */
.site-footer {
  text-align: center; padding: 24px 14px;
  font-size: .75rem; color: var(--text-sub);
  border-top: 1px solid var(--border); margin-top: 20px;
}

/* ========== NO IMAGE FALLBACK ========== */
.no-img {
  width: 100%; padding-top: 100%; background: linear-gradient(135deg, #f0f0f0, #e0e0e0);
  position: relative;
}
.no-img::after {
  content: "📦"; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%); font-size: 2rem;
}

@media (min-width: 480px) {
  .tile-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ========== SWIPE UI ========== */
.swipe-page {
  display: flex; flex-direction: column; align-items: center;
  min-height: calc(100vh - var(--header-h));
  padding: 12px 16px 100px;
}
.swipe-header { text-align: center; margin-bottom: 12px; }
.swipe-cat-title { font-size: 1.1rem; font-weight: 800; color: var(--text); }
.swipe-sub { font-size: .75rem; color: var(--text-sub); margin-top: 2px; }

#swipe-container {
  position: relative; width: 100%; max-width: 360px; height: 480px;
}

.swipe-card {
  position: absolute; inset: 0;
  background: var(--white); border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,.13);
  overflow: hidden; cursor: grab; user-select: none;
  display: flex; flex-direction: column;
  touch-action: pan-y;
}
.swipe-card:active { cursor: grabbing; }

.swipe-label {
  position: absolute; top: 20px; z-index: 10;
  font-size: 1.3rem; font-weight: 900; padding: 6px 14px;
  border-radius: 6px; border: 3px solid; opacity: 0;
  pointer-events: none; transition: opacity .1s;
}
.skip-label  { left: 16px;  color: #e83e3e; border-color: #e83e3e; transform: rotate(-15deg); }
.check-label { right: 16px; color: #2ecc71; border-color: #2ecc71; transform: rotate(15deg); }

.swipe-img {
  width: 100%; height: 300px; object-fit: contain;
  background: #fafafa; flex-shrink: 0;
}
.no-img-card {
  width: 100%; height: 300px; background: linear-gradient(135deg,#f0f0f0,#e0e0e0);
  display: flex; align-items: center; justify-content: center;
  font-size: 3rem;
}

.swipe-info { padding: 10px 14px 6px; flex: 1; overflow: hidden; }
.swipe-title {
  font-size: .82rem; line-height: 1.45; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  margin-bottom: 6px;
}
.swipe-price { font-size: 1.1rem; font-weight: 800; color: var(--primary); }
.swipe-review { display: flex; align-items: center; gap: 4px; margin-top: 4px; }
.swipe-review .stars { font-size: .8rem; color: var(--star); }
.rev-cnt { font-size: .7rem; color: var(--text-sub); }

.swipe-hint {
  display: flex; justify-content: space-between;
  padding: 6px 16px 8px; font-size: .7rem; color: #bbb;
}

/* ボタン */
.swipe-buttons {
  position: relative; z-index: 20;
  display: flex; gap: 32px; justify-content: center;
  margin-top: 20px;
}
.swipe-btn {
  width: 64px; height: 64px; border-radius: 50%; border: none;
  font-size: 1.6rem; cursor: pointer; box-shadow: 0 3px 10px rgba(0,0,0,.15);
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s;
}
.swipe-btn:active { transform: scale(.9); }
.skip-btn  { background: var(--white); color: var(--primary); }
.check-btn { background: var(--primary); color: var(--white); }

/* 空状態 */
#swipe-empty {
  width: 100%; max-width: 360px; height: 480px;
  display: flex; align-items: center; justify-content: center;
}
.empty-inner { text-align: center; }
