/* =============================================
  operational.css
  既存CSS（common/*.css）に追加する運用パーツ。
  既存ファイルは変更せず、components.css の後に読み込む。
  対応表：docs/parts-map.md
================================================ */
@layer components {
  /* ---------------------------------------------
    box
  ------------------------------------------------ */
  /* box_01・box_03 を2カラムで並べる入れ物 */
  .box-01-list,
  .box-03-list {
    display: grid;
    gap: 24px;
    grid-template-columns: repeat(2, 1fr);
  }

  @media (max-width: 767.98px) {
    .box-01-list,
    .box-03-list {
      gap: 16px;
      grid-template-columns: repeat(1, 1fr);
    }
  }

  /* box_05：画像を原寸で表示（拡大・切り抜きしない）。書影など小さい画像用 */
  .box-05 .figure[data-size="natural"] {
    width: auto;
    aspect-ratio: auto;
  }

  .box-05 .figure[data-size="natural"] > img {
    width: auto;
  }

  /* box_04 の2カラム指定（既定は3カラム。SPは既存どおり1カラム） */
  @media (min-width: 768px) {
    .box-04-list[data-column="2"] {
      grid-template-columns: repeat(2, 1fr);
    }
  }

  /* box_04：画像を原寸・元の比率で表示（縦長の表紙など。切り抜かない） */
  .box-04 .figure[data-size="natural"] {
    width: auto;
    aspect-ratio: auto;
  }

  .box-04 .figure[data-size="natural"] img {
    width: auto;
  }

  /* box_04：正方形の画像（顔写真など）を124pxで表示 */
  .box-04 .figure[data-shape="square"] {
    width: 124px;
    aspect-ratio: 1 / 1;
  }

  /* ---------------------------------------------
    panel
  ------------------------------------------------ */
  /* panel_01・panel_02 の2カラム指定（既定は3カラム） */
  .panel-01-list[data-column="2"],
  .panel-02-list[data-column="2"] {
    grid-template-columns: repeat(2, 1fr);
  }

  @media (max-width: 767.98px) {
    .panel-01-list[data-column="2"],
    .panel-02-list[data-column="2"] {
      grid-template-columns: repeat(1, 1fr);
    }
  }

  /* panel_02：説明文（.text）のないタイトルだけのパネルは1行分にする
     （既存CSSは説明文用に2行分を確保するため、下半分に余白が出る） */
  .panel-02:not(:has(.text)) {
    grid-row: span 1;
  }

  /* panel_01 の画像枠にアイコン・図版を入れる（イラストの代わり）
     ファイルは改変せず、高さで大きさをそろえる（幅は各画像の比率なり） */
  .panel-01 .figure[data-icon] {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 0;
    background-color: var(--color-yellow-02);
    gap: 16px;
    aspect-ratio: auto;
  }

  .panel-01 .figure[data-icon] img {
    width: auto;
    height: 140px;
  }

  @media (max-width: 767.98px) {
    .panel-01 .figure[data-icon] img {
      height: 104px;
    }
  }

  /* ---------------------------------------------
    table
  ------------------------------------------------ */
  /* 表をスマホで横スクロールさせず、画面幅に収める（data-sp="fit" を付けた表だけ） */
  @media (max-width: 767.98px) {
    .table-01[data-sp="fit"] table,
    .table-02[data-sp="fit"] table,
    .table-03[data-sp="fit"] table {
      min-width: 0;
    }

    .table-01[data-sp="fit"] table th,
    .table-01[data-sp="fit"] table td,
    .table-02[data-sp="fit"] table th,
    .table-02[data-sp="fit"] table td,
    .table-03[data-sp="fit"] table th,
    .table-03[data-sp="fit"] table td {
      padding: 10px 8px;
    }

    .table-01[data-sp="fit"] table th[scope="row"],
    .table-02[data-sp="fit"] table th[scope="row"],
    .table-03[data-sp="fit"] table th[scope="row"] {
      width: 30%;
    }
  }

  /* table_04：レベル表（レベル＆サンプル専用・新規）
     table_03 をもとに、見出し色を赤系の単色6段階にし、SPはレベルごとのカードに縦積みする。
     token.css にない色はデザインガイドラインのカラーパレット（赤系）の値をここで定義する */
  .table-04 {
    --table-04-j1p: #ab0000; /* Red dark 20 */
    --table-04-j1: var(--color-red-01); /* Red Primary #d50000 */
    --table-04-j2: var(--color-red-03); /* Red Light 20 #de3333 */
    --table-04-j3: #e66666; /* Red Light 40 */
    --table-04-j4: #f2b3b3; /* Red Light 70 */
    --table-04-j5: #fbe6e6; /* Red Light 90 */

    width: 100%;
  }

  .table-04 table {
    width: 100%;
  }

  .table-04 th,
  .table-04 td {
    padding: 14px 17px;
    border: 1px solid var(--color-gray-01);
    font-size: 1rem;
    line-height: 1.75;
  }

  .table-04 th {
    width: 120px;
    font-family: var(--font-family-base);
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    vertical-align: middle;
  }

  .table-04 td {
    background-color: var(--color-white);
    letter-spacing: 0.08em;
    vertical-align: top;
  }

  .table-04 tr:nth-child(1) th { background-color: var(--table-04-j1p); color: var(--color-white); }
  .table-04 tr:nth-child(2) th { background-color: var(--table-04-j1); color: var(--color-white); }
  .table-04 tr:nth-child(3) th { background-color: var(--table-04-j2); color: var(--color-white); }
  .table-04 tr:nth-child(4) th { background-color: var(--table-04-j3); color: var(--color-base); }
  .table-04 tr:nth-child(5) th { background-color: var(--table-04-j4); color: var(--color-base); }
  .table-04 tr:nth-child(6) th { background-color: var(--table-04-j5); color: var(--color-base); }

  @media (max-width: 767.98px) {
    .table-04 table,
    .table-04 tbody,
    .table-04 tr,
    .table-04 th,
    .table-04 td {
      display: block;
      width: 100%;
    }

    /* レベルごとに1枚のカード。枠線はその行の見出し色（J5のみ J4 の色） */
    .table-04 tr {
      border: 1px solid;
    }

    .table-04 tr + tr {
      margin-top: 12px;
    }

    .table-04 tr:nth-child(1) { border-color: var(--table-04-j1p); }
    .table-04 tr:nth-child(2) { border-color: var(--table-04-j1); }
    .table-04 tr:nth-child(3) { border-color: var(--table-04-j2); }
    .table-04 tr:nth-child(4) { border-color: var(--table-04-j3); }
    .table-04 tr:nth-child(5),
    .table-04 tr:nth-child(6) { border-color: var(--table-04-j4); }

    .table-04 th,
    .table-04 td {
      border: none;
    }

    .table-04 th {
      padding: 8px 16px;
      font-size: 1.25rem;
      text-align: left;
    }

    .table-04 td {
      padding: 16px;
    }
  }

  /* ---------------------------------------------
    movie
  ------------------------------------------------ */
  /* movie_01 を小さめ（最大520px）で表示する */
  .movie-01[data-size="sm"] {
    max-width: 520px;
  }

  /* panel_02・panel_03 のページ内アンカー：矢印を下向きにする
     （既存CSSは panel-01 だけ [data-scroll="smooth"] で下向きにしているため、同じ指定を追加） */
  .panel-02[data-scroll="smooth"] .title::before,
  .panel-02[data-scroll="smooth"] .title::after,
  .panel-03[data-scroll="smooth"] .title::before,
  .panel-03[data-scroll="smooth"] .title::after {
    transform: translateY(-50%) rotate(90deg);
  }

  /* ---------------------------------------------
    consent（Google 同意モードの同意バナー）
    HTMLは assets/js/consent.js が生成する。デザイン：docs/同意バナー_デザイン案.html
  ------------------------------------------------ */
  .consent-banner {
    --consent-banner-focus: #035eba; /* token にない色（フォーカスの枠） */
    position: fixed;
    z-index: calc(var(--z-index-header-overlay) - 1);
    right: 0;
    bottom: 0;
    left: 0;
    border-top: 3px solid var(--color-red-01);
    background-color: var(--color-white);
    box-shadow: 0 -6px 20px rgb(0 0 0 / 12%);
    color: var(--color-base);
  }

  .consent-banner[hidden] {
    display: none;
  }

  .consent-banner-inner {
    display: flex;
    max-width: 1000px;
    align-items: center;
    margin: 0 auto;
    padding: 18px 24px;
    gap: 28px;
  }

  .consent-banner-text {
    flex: 1;
    margin: 0;
    font-size: 0.8125rem;
    line-height: 1.85;
  }

  .consent-banner-text a {
    color: var(--color-red-01);
    font-weight: 500;
    text-decoration: underline;
  }

  .consent-banner-buttons {
    display: flex;
    flex: none;
    gap: 12px;
  }

  .consent-banner-button {
    min-width: 150px;
    height: 46px;
    padding: 0 16px;
    border: 1px solid var(--color-red-01);
    border-radius: 4px;
    background-color: var(--color-white);
    color: var(--color-red-01);
    font-family: var(--font-family-base);
    font-size: 0.875rem;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    transition: var(--transition-all);
  }

  .consent-banner-button:focus-visible {
    outline: 3px solid var(--consent-banner-focus);
    outline-offset: 2px;
  }

  /* 再表示のとき、選んでいる方を塗りにする */
  .consent-banner-button[aria-pressed="true"] {
    background-color: var(--color-red-01);
    color: var(--color-white);
  }

  @media (min-width: 768px) {
    .consent-banner-button:not([aria-pressed="true"]):hover {
      background-color: var(--color-yellow-03);
    }
  }

  @media (max-width: 767.98px) {
    .consent-banner-inner {
      flex-direction: column;
      align-items: stretch;
      padding: 16px;
      gap: 12px;
    }

    .consent-banner-text {
      font-size: 0.78125rem;
    }

    .consent-banner-buttons {
      gap: 10px;
    }

    .consent-banner-button {
      flex: 1;
      min-width: 0;
      height: 44px;
    }
  }

  /* 表示中：ページの最下部が隠れないよう余白を足し、ページトップへ戻るボタンをバナーの上に出す */
  .is-consent-open body {
    padding-bottom: var(--consent-banner-height, 0px);
  }

  .is-consent-open .footer-page-top {
    bottom: calc(var(--consent-banner-height, 0px) + 48px);
  }

  @media (max-width: 767px) {
    .is-consent-open .footer-page-top {
      bottom: calc(var(--consent-banner-height, 0px) + 24px);
    }
  }

  /* フッターの「Cookie設定」：ボタンの既定の見た目を消し、ほかのリンクと同じにする */
  .footer .link[data-consent-open] {
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font-family: inherit;
    cursor: pointer;
  }
}
