/*
 Theme Name: Storefront Child
 Template: storefront
*/

/* === WooCommerce標準カテゴリーリスト調整 === */

/* 子カテゴリーは初期状態で非表示 */
.wc-block-product-categories-list ul {
    display: none;
}

/* 階層の視認性を高めるためのインデント */
.wc-block-product-categories-list ul {
    margin-left: 14px;
}

/* リスト全体の余白調整 */
.wc-block-product-categories-list > li {
    margin-bottom: 6px;
}

/* 親カテゴリーのラベルを少し強調 */
.wc-block-product-categories-list > li > a {
    font-weight: 600;
}

/* トグルボタンの簡易スタイル */
.wc-block-product-categories-list .toggle {
    margin-right: 6px;
    cursor: pointer;
    background: none;
    border: none;
    font-size: 14px;
    line-height: 1;
}


/* === カラーパレット === */
:root {
  --main-color: #f6a17a;   /* 淡い夕焼け色 */
  --accent-color: #777777; /* 灰色 */
  --sub-color: #ffffff;    /* 白 */
}


/* === 親カテゴリーカードUI === */
.category-card {
  position: relative;
  text-align: center;
  border: 1px solid var(--accent-color);
  border-radius: 8px;
  padding: 12px;
  background: var(--sub-color);
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  transition: transform 0.2s;
  box-sizing: border-box;

  /* ▼追加：Grid内でのはみ出し防止 */
  min-width: 0;
  max-width: 100%;

  /* ▼追加：子カテゴリーが隠れないように */
  overflow: visible;
  z-index: auto;
}
.category-card:hover {
  transform: translateY(-3px);
}
.category-card img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  display: block;
}
.category-name {
  display: block;
  margin-top: 8px;
  font-weight: bold;
  color: var(--main-color);
}


/* === トグルアイコン（＞／∨） === */
.toggle {
  margin-top: 6px;
  cursor: pointer;
  background: none;
  border: none;
  font-size: 18px;
  color: var(--main-color);
  transition: transform 0.2s;
}


/* === 子カテゴリー（吹き出し風） === */
.subcategory-list {
  display: none;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 10px;
  background: var(--sub-color);
  border: 1px solid var(--accent-color);
  border-radius: 6px;
  padding: 10px 14px;
  list-style: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);

  /* ▼修正：他のカードより前面に出す */
  z-index: 9999;

  min-width: 280px;         /* 横幅を広めに確保 */
  white-space: nowrap;      /* 子カテゴリー名＋商品数を改行させない */
}
.subcategory-list::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  border: 10px solid transparent;
  border-bottom-color: var(--sub-color);
}
.subcategory-list li {
  margin: 6px 0;
}
.subcategory-list a {
  color: var(--accent-color);
  text-decoration: none;
}
.subcategory-list a:hover {
  color: var(--main-color);
}


/* === レイアウト調整 === */

/* Storefrontの中央寄せ制限を解除して横幅いっぱいに */
.site-main .col-full {
  max-width: 100% !important;
  padding-left: 0;
  padding-right: 0;
}

/* 共通：Gridで管理 */
.wc-block-product-categories-list--depth-0 {
  display: grid;
  grid-template-columns: repeat(4, 1fr); /* PCでは4列 */
  gap: 20px;
  width: 100%;
  box-sizing: border-box;
  padding: 0;
  margin: 0;
  list-style: none;
}

/* タブレットでは2列 */
@media (max-width: 1024px) {
  .wc-block-product-categories-list--depth-0 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* スマホでは2列＋overflow修正 */
@media (max-width: 600px) {
  .wc-block-product-categories-list--depth-0 {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;

    /* ▼修正：子カテゴリーが切り取られないように */
    overflow-x: auto;
    overflow-y: visible;
  }
  .category-card {
    width: 100%;        /* スマホでは必ずカラム幅に収める */
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
}
