/* ====================================================
   style.css - 誕生日本屋さん 共通スタイル
   ==================================================== */

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

body {
  font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
  background: #fafafa;
  color: #333;
  line-height: 1.6;
}

a { color: #e75480; }
button { font-family: inherit; }

/* ─── ヘッダー ─── */
.site-header {
  background: linear-gradient(135deg, #e75480 0%, #ff8fab 100%);
  color: white;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(231,84,128,.3);
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  gap: 12px;
}
.site-title {
  display: flex;
  align-items: center;
  gap: 12px;
}
.title-emoji { font-size: 2rem; }
.site-title h1 { font-size: 1.4rem; font-weight: 800; line-height: 1.2; }
.subtitle { font-size: .85rem; opacity: .9; }

/* ─── カートボタン ─── */
.cart-btn {
  background: white;
  color: #e75480;
  border: none;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: transform .1s, box-shadow .1s;
  flex-shrink: 0;
}
.cart-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.cart-badge {
  background: #e75480;
  color: white;
  width: 22px; height: 22px;
  border-radius: 50%;
  font-size: .8rem;
  display: flex; align-items: center; justify-content: center;
}

/* ─── 検索・フィルターバー ─── */
.filter-bar {
  max-width: 1200px;
  margin: 20px auto 0;
  padding: 0 16px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.filter-bar input, .filter-bar select {
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  background: white;
}
.filter-bar input { flex: 1; min-width: 200px; }
.filter-bar input:focus, .filter-bar select:focus { outline: none; border-color: #e75480; }
.count-display { color: #888; font-size: .9rem; white-space: nowrap; }

/* ─── 本のグリッド ─── */
.book-grid {
  max-width: 1200px;
  margin: 16px auto 80px;
  padding: 0 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

/* ─── 本カード ─── */
.book-card {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  display: flex;
  flex-direction: column;
  transition: transform .15s, box-shadow .15s;
  border: 2px solid transparent;
}
.book-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,.12); }
.book-card.in-cart { border-color: #e75480; background: #fff5f8; }

/* 表紙画像 */
.book-cover {
  width: 100%;
  aspect-ratio: 3/4;
  overflow: hidden;
  background: #f0f0f0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.book-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cover-fallback {
  position: absolute;
  font-size: 3rem;
  display: none;
}
.book-cover.no-cover img { display: none; }
.book-cover.no-cover .cover-fallback { display: block; }
.book-cover.no-cover { background: #f5f0eb; }

/* カード内情報 */
.book-info {
  padding: 10px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.book-title {
  font-size: .88rem;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.book-prices {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.list-price {
  font-size: .78rem;
  color: #999;
  text-decoration: line-through;
}
.sell-price {
  font-size: 1.1rem;
  font-weight: 800;
  color: #e75480;
}

/* ジャンルバッジ */
.genre-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: .72rem;
  font-weight: 700;
  align-self: flex-start;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  /* デフォルト色 */
  background: #e8eaf6;
  color: #3949ab;
}
/* ジャンル別カラー */
.genre-ビジネス_経済         { background: #dbeafe; color: #1d4ed8; }
.genre-人文_思想              { background: #ede9fe; color: #5b21b6; }
.genre-ノンフィクション       { background: #d1fae5; color: #065f46; }
.genre-投資_金融_会社経営     { background: #fef9c3; color: #854d0e; }
.genre-暮らし_健康_子育て     { background: #fce7f3; color: #9d174d; }
.genre-エンターテイメント     { background: #ffedd5; color: #c2410c; }
.genre-コンピュータ_IT        { background: #e0f2fe; color: #0369a1; }
.genre-文学_評論              { background: #fef3c7; color: #92400e; }
.genre-趣味_実用              { background: #ecfdf5; color: #065f46; }
.genre-アート_建築_デザイン   { background: #f5f3ff; color: #6d28d9; }
.genre-社会_政治              { background: #fef2f2; color: #991b1b; }
.genre-科学_テクノロジー      { background: #e0fdf4; color: #065f46; }
.genre-語学_辞事典_年鑑       { background: #f0f9ff; color: #0c4a6e; }
.genre-歴史_地理              { background: #fff7ed; color: #9a3412; }
.genre-スポーツ_アウトドア    { background: #f0fdf4; color: #166534; }
.genre-洋書                   { background: #f8fafc; color: #334155; }
.genre-楽譜_スコア_音楽書     { background: #fdf4ff; color: #701a75; }
.genre-本のキャンペーン       { background: #fff1f2; color: #be123c; }

/* カードのボタン */
.add-btn {
  margin: 0 12px 12px;
  padding: 8px;
  background: #e75480;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: .88rem;
  font-weight: 600;
  transition: background .15s;
}
.add-btn:hover { background: #c0365a; }
.book-card.in-cart .add-btn { background: #666; }
.book-card.in-cart .add-btn:hover { background: #444; }

/* ─── カートパネル ─── */
.cart-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 200;
  opacity: 0; pointer-events: none;
  transition: opacity .25s;
}
.cart-overlay.open { opacity: 1; pointer-events: auto; }

.cart-panel {
  position: fixed;
  top: 0; right: 0;
  width: 360px; max-width: 100vw;
  height: 100vh;
  background: white;
  z-index: 201;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .25s ease;
  box-shadow: -4px 0 24px rgba(0,0,0,.15);
}
.cart-panel.open { transform: translateX(0); }

.cart-header {
  padding: 20px;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.cart-header h2 { font-size: 1.2rem; }

.cart-items { flex: 1; overflow-y: auto; padding: 16px; }
.cart-empty { color: #aaa; text-align: center; padding: 32px 0; }

.cart-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
}
.cart-item-title { flex: 1; font-size: .88rem; line-height: 1.3; }
.cart-item-price { font-weight: 700; color: #e75480; white-space: nowrap; }
.remove-btn {
  background: none;
  border: none;
  color: #aaa;
  cursor: pointer;
  font-size: 1rem;
  padding: 4px;
  line-height: 1;
}
.remove-btn:hover { color: #e75480; }

.cart-footer {
  padding: 20px;
  border-top: 1px solid #eee;
  background: #fafafa;
}
.cart-total {
  font-size: 1.1rem;
  margin-bottom: 12px;
}
.cart-total strong { font-size: 1.4rem; color: #e75480; }

.order-btn {
  width: 100%;
  padding: 14px;
  background: #e75480;
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
}
.order-btn:hover:not(:disabled) { background: #c0365a; }
.order-btn:disabled { background: #ccc; cursor: not-allowed; }

/* ─── モーダル ─── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }

.modal {
  background: white;
  border-radius: 16px;
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,.2);
}
.modal-sm { max-width: 380px; text-align: center; padding: 40px 32px; }
.modal-sm .done-icon { font-size: 3rem; margin-bottom: 16px; }
.modal-sm p { color: #666; margin: 12px 0 24px; white-space: pre-wrap; }

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: white;
}
.modal-body { padding: 20px 24px 24px; }

.close-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: #aaa;
  cursor: pointer;
  padding: 4px 8px;
}
.close-btn:hover { color: #333; }

/* 注文サマリー */
.order-summary {
  background: #fef5f8;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 20px;
}
.order-summary h3 { font-size: .95rem; margin-bottom: 10px; color: #666; }
.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  font-size: .88rem;
  border-bottom: 1px solid #f0e0e8;
}
.summary-total {
  display: flex;
  justify-content: flex-end;
  font-size: 1rem;
  padding-top: 10px;
  margin-top: 4px;
}
.summary-total strong { color: #e75480; font-size: 1.2rem; margin-left: 8px; }

/* フォーム */
.form-row { margin-bottom: 16px; }
.form-row label {
  display: block;
  font-size: .9rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: #444;
}
.required { color: #e75480; }
.form-row input, .form-row textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color .2s;
}
.form-row input:focus, .form-row textarea:focus {
  outline: none;
  border-color: #e75480;
}
.form-error { color: #e75480; font-size: .9rem; margin-bottom: 12px; min-height: 1.4em; }

.submit-btn {
  width: 100%;
  padding: 14px;
  background: #e75480;
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
}
.submit-btn:hover:not(:disabled) { background: #c0365a; }
.submit-btn:disabled { background: #ccc; cursor: not-allowed; }

/* ─── ユーティリティ ─── */
.loading, .no-result, .error {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: #888;
  font-size: 1.1rem;
}
.error { color: #e75480; }
.no-scroll { overflow: hidden; }

/* ─── レスポンシブ ─── */
@media (max-width: 600px) {
  .site-title h1 { font-size: 1.1rem; }
  .subtitle { display: none; }
  .book-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .cart-panel { width: 100vw; }
}
