/*
 * ASTRA VAPE 定期便のカート表示（表示専用）
 * 読み込むのはカートページ（日本語表示）だけ（mu-plugins/astra-subscription-cart.php）。
 * 印（astra-teikibin-*）は、まとめを作れた定期便の行にだけ付く。
 * 指定はすべて定期便の行（またはそれがあるカート）に限定し、通常商品には当てない。
 * 色・フォントはテーマ（astra-woo-checkout.css）の変数をそのまま使う。
 */

/* ── 子の行と、親の行の単価・小計 ───────────────────────── */

/* 子の行（プラン・ニコチン・各POD）。カートには残したまま、画面上だけ隠す。 */
tr.astra-teikibin-child {
  display: none !important;
}

/* 親の行の単価・小計（$106 の1行）。金額はまとめの中で「初回／2回目以降」に分けて出す。
 * セルごと消すと表の列がずれるので、見えなくするだけにする。 */
tr.astra-teikibin-parent td.product-price,
tr.astra-teikibin-parent td.product-subtotal {
  visibility: hidden;
}

/* ── まとめ表示 ─────────────────────────────────────── */
/* 見せる順: 初回の商品代 → 2回目以降 → プラン名 → 選択内容 */

.astra-teikibin-cart {
  margin-top: 12px;
  line-height: 1.6;
  color: #fff;
}

/* 3. プラン名 */
.astra-teikibin-cart__plan {
  font-size: 14px;
  font-weight: var(--astra-font-weight-bold, 700);
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.astra-teikibin-cart__prices {
  margin: 0;
  padding: 0;
  max-width: 34rem;
}

.astra-teikibin-cart__prices > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
}

.astra-teikibin-cart__prices dt,
.astra-teikibin-cart__prices dd {
  margin: 0;
}

.astra-teikibin-cart__prices dd {
  white-space: nowrap;
  font-family: var(--astra-source-code-pro, monospace);
}

/* 1. 初回の商品代 */
.astra-teikibin-cart__prices > div:first-child dt {
  font-size: 15px;
  font-weight: var(--astra-font-weight-bold, 700);
}

.astra-teikibin-cart__prices > div:first-child dd {
  font-size: 22px;
  font-weight: 700;
}

/* 2. 2回目以降 */
.astra-teikibin-cart__prices > div + div {
  margin-top: 2px;
}

.astra-teikibin-cart__prices > div + div dt {
  font-size: 14px;
  font-weight: var(--astra-font-weight-medium, 500);
}

.astra-teikibin-cart__prices > div + div dd {
  font-size: 16px;
  font-weight: 700;
}

/* 4. 選択内容。料金との間を空け、細い線で分ける */
.astra-teikibin-cart__heading {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--astra-line, rgba(255, 255, 255, 0.2));
  font-size: 13px;
  font-weight: var(--astra-font-weight-bold, 700);
  color: var(--astra-gray, rgba(255, 255, 255, 0.72));
}

.astra-teikibin-cart__items {
  list-style: none;
  margin: 4px 0 10px;
  padding: 0;
  font-size: 13px;
  color: var(--astra-gray, rgba(255, 255, 255, 0.72));
}

.astra-teikibin-cart__qty {
  font-size: 13px;
  color: var(--astra-gray, rgba(255, 255, 255, 0.72));
}

/* ── 商品行の横幅 ───────────────────────────────────── */

/* PC: 列の幅は全商品で共通なので変えない。定期便の行では右隣の単価の列が
 * 空いている（上で非表示）ため、まとめ表示だけをその列の幅（27rem）ぶん広げて重ねる。 */
@media screen and (min-width: 769px) {
  .woocommerce-cart table.shop_table.cart tr.astra-teikibin-parent td.product-name {
    overflow: visible;
  }
  .woocommerce-cart table.shop_table.cart tr.astra-teikibin-parent .astra-teikibin-cart {
    width: calc(100% + 27rem);
    position: relative;
  }
}

/* スマホ: 3列2段のグリッドのうち、定期便の行だけ商品名を小計の位置まで広げる。
 * 小計（非表示）はグリッドから外す。他の行の並びは変えない。 */
@media screen and (max-width: 768px) {
  .woocommerce-cart table.shop_table.cart tbody tr.astra-teikibin-parent > td.product-name {
    grid-column: 2 / 4;
  }
  .woocommerce-cart table.shop_table.cart tbody tr.astra-teikibin-parent > td.product-subtotal {
    display: none;
  }
  .astra-teikibin-cart__prices > div:first-child dd {
    font-size: 20px;
  }
}

/* ── カートの合計：初回の支払いと2回目以降の区切り ───────────── */
/* 定期便の行があるカートだけ。文言・金額・更新日は変えない。 */
/* 線は行（tr）に引く。スマホではセルが縦積みになり、セルに引くと見出しの幅しか引かれない。 */
body:has(tr.astra-teikibin-parent) .cart_totals tr.recurring-totals {
  border-top: 1px solid var(--astra-line-strong, rgba(255, 255, 255, 0.4));
}

body:has(tr.astra-teikibin-parent) .cart_totals tr.recurring-totals th,
body:has(tr.astra-teikibin-parent) .cart_totals tr.recurring-totals td {
  padding-top: 2.8rem;
  font-weight: var(--astra-font-weight-bold, 700);
}

/* 「初回50%OFF・3回継続プラン」の印（astra-subscription-commit.php） */
.astra-teikibin-cart__badge {
  display: inline-block;
  margin: 4px 0 6px;
  padding: 2px 10px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
