/*
 * Cosboo Cards：フッター（デザイン案 D「切手シート」）
 * - 協賛ロゴ（#cb-footer-sponsors）は TOP の切手ローテーションと同じミシン目の切手に入れて4枚並べる
 * - その下に「ロゴ｜説明文＋ページへのリンク｜SNS」を1段でまとめる
 * テーマの footer の組み方（.inner の flex・row-reverse など）は .cb-footer（cosboo-footer.js が付ける）で上書きする。
 * テーマの responsive.css がこの CSS より後に読み込まれるので、フッターの組み方は body を足して強くしている。
 */

/* ===== 協賛ブロック（JS が動かず、ページの下に出たときもこのまま見られる） ===== */
.cb-fs {
  --cb-or-l: #ffac7f;
  --cb-fs-h: 96px; /* 切手の中の、ロゴを置く白い枠の高さ */

  max-width: 980px;
  margin: 0 auto;
  padding: 0 16px;
  text-align: center;
  color: #fff;
  box-sizing: border-box;
}
.cb-fs__title {
  margin: 0 0 22px;
  font-family: "Dela Gothic One", "M PLUS 2", sans-serif;
  font-size: 22px;
  font-weight: 400;
  letter-spacing: .08em;
  line-height: 1.3;
  color: inherit;
}
.cb-fs__title small {
  display: block;
  margin-top: 4px;
  font-family: "M PLUS 2", sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .1em;
  opacity: .9;
}
.cb-fs__sheet {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 22px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.cb-fs__item {
  margin: 0;
  padding: 0;
  list-style: none;
}
.cb-fs__item:nth-child(4n+1) .cb-fs__stamp { transform: rotate(-2deg); }
.cb-fs__item:nth-child(4n+2) .cb-fs__stamp { transform: rotate(1.5deg); }
.cb-fs__item:nth-child(4n+3) .cb-fs__stamp { transform: rotate(-1deg); }
.cb-fs__item:nth-child(4n+4) .cb-fs__stamp { transform: rotate(2deg); }

/* 切手：縁だけギザギザ（外側 7px に丸い穴を並べ、内側 content-box は全面を残す） */
.cb-fs .cb-fs__stamp {
  display: block;
  padding: 7px;
  background: #fff;
  box-sizing: border-box;
  -webkit-mask:
    radial-gradient(circle, transparent 4.5px, #000 5px) -7px -7px / 14px 14px round,
    linear-gradient(#000 0 0) content-box;
  mask:
    radial-gradient(circle, transparent 4.5px, #000 5px) -7px -7px / 14px 14px round,
    linear-gradient(#000 0 0) content-box;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .12));
  transition: transform .2s ease;
}
.cb-fs a.cb-fs__stamp:hover,
.cb-fs a.cb-fs__stamp:focus-visible {
  transform: rotate(0) translateY(-4px);
}
a.cb-fs__stamp:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}
/*
 * ロゴを置く白い枠。ロゴは枠の内側に絶対配置で固定し、object-fit: contain で縦横比を変えずに収める
 * （高さを % で決めると、ブラウザや幅によって正方形の GR のロゴが枠からはみ出すことがあったため）
 */
.cb-fs .cb-fs__inner {
  display: block;
  position: relative;
  height: var(--cb-fs-h);
  margin: 7px;
  border: 2px solid var(--cb-or-l);
  box-sizing: border-box;
}
.cb-fs .cb-fs__inner img {
  position: absolute;
  top: 10px;
  right: 14px;
  bottom: 10px;
  left: 14px;
  width: calc(100% - 28px);
  height: calc(100% - 20px);
  max-width: none;
  margin: 0;
  object-fit: contain;
}

@media (max-width: 860px) {
  .cb-fs {
    --cb-fs-h: 72px;
  }
  .cb-fs__sheet {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }
  .cb-fs .cb-fs__inner img {
    top: 8px;
    right: 10px;
    bottom: 8px;
    left: 10px;
    width: calc(100% - 20px);
    height: calc(100% - 16px);
  }
}

/* JS が動かず、ページの下に出たとき用（フッターの外ではオレンジの地を敷く） */
body > .cb-fs {
  max-width: none;
  padding: 40px 16px;
  background: rgba(var(--tcd-key2-color, 255, 172, 127), 1);
}

/* ===== フッターの組み直し（.cb-footer） ===== */
body #footer.cb-footer > .inner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  column-gap: 28px;
  row-gap: 8px;
  align-items: center;
  width: auto;
  max-width: 1012px;
  margin: 0 auto;
  padding: 48px 16px 28px;
  flex-direction: initial;
}
body #footer.cb-footer .cb-fs {
  grid-column: 1 / -1;
  width: 100%;
  margin-bottom: 44px;
  padding: 0;
}
/*
 * 404 のページなど、テーマがフッターの中身（.inner）を出さないページ：協賛ブロックがフッターの直下に入るので、
 * 上下と左右に余白を取る（無いとタイトルがフッターの上端にくっつく）。
 * 後ろのスマホ用の指定（.cb-fs の padding）に負けないよう、footer を足して強くしている
 */
body footer#footer.cb-footer > .cb-fs {
  max-width: 1012px;
  margin: 0 auto;
  padding: 44px 16px 36px;
}
@media (max-width: 860px) {
  body footer#footer.cb-footer > .cb-fs {
    padding: 36px 16px 28px;
  }
}
/* ロゴ・説明文・SNS の箱をほどいて、.inner の格子に直接並べる */
body #footer.cb-footer #footer_top {
  display: contents;
}
body #footer.cb-footer #footer_logo {
  grid-column: 1;
  grid-row: 2 / span 2;
}
body #footer.cb-footer #footer_logo img {
  width: 120px;
  max-width: 120px;
  height: auto;
}
body #footer.cb-footer #footer_top .site_description:empty {
  display: none;
}
body #footer.cb-footer #footer_top .desc,
body #footer.cb-footer #footer_top .site_description {
  grid-column: 2;
  align-self: end; /* ロゴの高さで行が伸びても、説明文とリンクは中央に寄せて並べる */
  margin: 0;
  font-size: 14px;
  line-height: 1.7;
  text-align: left;
  color: #fff;
}
body #footer.cb-footer #footer_sns {
  grid-column: 3;
  grid-row: 2 / span 2;
  margin: 0;
}

/* ページへのリンク：テーマのフッターメニュー（いまは隠れている）の1つ目だけを横1列で出す */
body #footer.cb-footer #footer_menu {
  display: block !important;
  grid-column: 2;
  grid-row: 3;
  align-self: start;
  width: auto;
  margin: 0;
  padding: 0;
}
body #footer.cb-footer #footer_menu .footer_menu {
  padding: 0;
  border: 0;
}
body #footer.cb-footer #footer_menu .footer_menu ~ .footer_menu {
  display: none;
}
body #footer.cb-footer #footer_menu ul {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 22px;
  margin: 0;
  padding: 0;
  list-style: none;
}
body #footer.cb-footer #footer_menu li,
body #footer.cb-footer #footer_menu li:first-of-type {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.6;
}
body #footer.cb-footer #footer_menu a,
body #footer.cb-footer #footer_menu li:first-of-type a {
  display: inline;
  color: #fff;
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
body #footer.cb-footer #footer_menu a:hover {
  border-color: currentColor;
}
body #footer.cb-footer #copyright {
  border-top: 1px solid rgba(255, 255, 255, .35);
}

/*
 * PC でも幅が狭いとき：右下に固定の「ページの上へ」ボタン（#return_top）が SNS に重なるので、
 * SNS をリンクの下へ移す
 */
@media (min-width: 861px) and (max-width: 1299px) {
  body #footer.cb-footer #footer_logo {
    grid-row: 2 / span 3;
  }
  body #footer.cb-footer #footer_sns {
    grid-column: 2;
    grid-row: 4;
    justify-self: start;
    margin-top: 6px;
  }
}

/* スマホ・タブレット：1列で中央そろえ */
@media (max-width: 860px) {
  body #footer.cb-footer > .inner {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    row-gap: 14px;
    padding: 40px 0 24px;
    text-align: center;
  }
  body #footer.cb-footer .cb-fs {
    margin-bottom: 28px;
    padding: 0 16px;
  }
  body #footer.cb-footer #footer_logo,
  body #footer.cb-footer #footer_top .desc,
  body #footer.cb-footer #footer_top .site_description,
  body #footer.cb-footer #footer_menu,
  body #footer.cb-footer #footer_sns {
    grid-column: 1;
    grid-row: auto;
  }
  body #footer.cb-footer #footer_top .desc,
  body #footer.cb-footer #footer_top .site_description {
    padding: 0 16px;
    text-align: center;
  }
  /* 並び順：協賛 → ロゴ → 説明文 → リンク → SNS（HTML ではリンクがロゴより前にある） */
  body #footer.cb-footer #footer_logo { order: 1; }
  body #footer.cb-footer #footer_top .site_description,
  body #footer.cb-footer #footer_top .desc { order: 2; }
  body #footer.cb-footer #footer_menu { order: 3; }
  body #footer.cb-footer #footer_sns { order: 4; }
  body #footer.cb-footer #footer_menu ul {
    justify-content: center;
    padding: 0 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cb-fs .cb-fs__stamp {
    transition: none;
  }
}
