/* ============================================================
 * /triauto/world-currencies/ ページ専用CSS
 * 参照Figma: サイト 通貨ペア一覧 (node 315:8230)
 * 基本トークン・タイポグラフィ・.ta-hero / .ta-heading--bar は
 * /assets/css/app.css を使用し、ここではページ固有レイアウトのみ定義する。
 * /cfd/stocklist/ と同系統のカード一覧レイアウト。
 * ============================================================ */

.world-currencies-page {
  width: 100%;
}

.world-currencies-inner {
  width: min(1000px, calc(100% - 40px));
  margin: 0 auto;
}

/* hero 下の余白は 40px 固定（サイト共通ルール） */
.world-currencies-intro {
  padding-top: 40px;
}

.world-currencies-section {
  padding: 40px 0;
  scroll-margin-top: 64px;
}

.world-currencies-section:focus {
  outline: none;
}

.world-currencies-section--pale {
  background: var(--ta-color-primary-pale);
}

.world-currencies-lead {
  max-width: 800px;
  margin: 0 auto;
  text-align: center;
}

/* ------------------------------------------------------------
 * カテゴリボタン: 日本円 / 米ドル・ユーロ / 特徴的
 * 押下でそのセクションへスクロール（js/page.js）
 * ---------------------------------------------------------- */
.world-currencies-category-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 40px;
}

.world-currencies-category-link {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 10px 24px;
  border: 2px solid var(--ta-color-border);
  border-radius: 40px;
  background: var(--ta-color-bg);
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
}

.world-currencies-category-link:hover,
.world-currencies-category-link:focus-visible,
.world-currencies-category-link.is-active {
  background: var(--ta-color-main);
  border-color: var(--ta-color-main);
  color: #fff;
}

/* SP用カテゴリプルダウン（cfd/stocklist の .stocklist-category-select と同型）。
   PCでは非表示・SP表示は下の @media (max-width: 768px) 参照 */
.world-currencies-category-select {
  display: none;
}

.world-currencies-section-title {
  margin: 0;
  text-align: center;
}

/* セクション見出し内のSP専用改行（PCでは下の @media で無効化） */
.world-currencies-sp-break {
  display: inline;
}

/* ------------------------------------------------------------
 * カードグリッド / カード
 * ---------------------------------------------------------- */
.world-currencies-card-grid {
  display: grid;
  /* 基準は3列（stocklist と同じ。940px以上はPC用 repeat(4, 232px) で上書き） */
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px 12px;
  margin-top: 40px;
}

.world-currencies-card {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 147px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 13px;
  padding: 20px 12px;
  background: var(--ta-color-bg);
  border: 2px solid var(--ta-color-card-border);
  border-radius: var(--ta-radius-l);
  box-shadow: var(--ta-shadow-card);
  overflow: hidden;
}

.world-currencies-card__flag {
  display: block;
  width: 102px;
  height: 60px;
  object-fit: contain;
}

/* 通貨ペアの2国旗重ね（サイト共通の合成旗と同じ構図:
 * 基軸通貨=左上・前面 / 決済通貨=右下・背面。64x48 の旗2枚・重なり14pxで全体 114x60） */
.world-currencies-card__flags {
  position: relative;
  display: block;
  width: 114px;
  height: 60px;
}

.world-currencies-card__flags-base {
  position: absolute;
  top: 0;
  left: 0;
  width: 64px;
  height: 48px;
  z-index: 1; /* 基軸通貨を前面に */
}

.world-currencies-card__flags-quote {
  position: absolute;
  top: 12px;
  left: 50px;
  width: 64px;
  height: 48px;
}

/* 単体国旗が未格納の通貨を含むペアの仮枠 */
.world-currencies-card__flag--placeholder {
  background: var(--ta-color-bg-light);
  border: 1px dashed var(--ta-color-border);
  border-radius: 4px;
}

.world-currencies-card__name {
  width: 100%;
  margin: 0;
  text-align: center;
  overflow-wrap: anywhere;
}

/* NEW リボン: Figma の回転ポリゴン装飾を CSS の角リボンで再現（stocklist と同型）
 * PC/SP とも stocklist と同じ top:9px/left:-25px。
 * （旧SPは旗との重なり回避で top:4px/left:-30px に角寄せしていたが、
 *   帯が角丸に食い込み左上角が全部青く見えるため戻した 2026-07-13） */
.world-currencies-card__ribbon {
  position: absolute;
  /* top+left の合計が角からの距離。左右ズレ（NEWのWはみ出し）は top/left を逆方向に同量動かして調整する */
  top: 9px;
  left: -25px;
  width: 88px;
  transform: rotate(-45deg);
  background: var(--ta-color-main);
  color: #fff;
  font: var(--ta-type-caption);
  text-align: center;
  padding: 2px 0;
  pointer-events: none;
  /* 旗の前面に出す（.world-currencies-card__flags-base が z-index:1 のため、
     未指定だとSPの狭いカードでリボンが旗の下に隠れる） */
  z-index: 2;
}

/* SPは cfd/stocklist のSPカードと同じ縮小版で3列（ユーザー指定 2026-07-14）:
   文字11px・旗を縮小（比率維持）・枠色 primary-pale・NEWリボン小型化。
   ブレークポイントも stocklist と同じ 768px（939px だと 769〜939px 帯で
   stocklist と NEW のサイズが揃わない）。
   リボンの上書きは同一詳細度のため、必ず上の base 定義より後に置くこと */
@media (max-width: 768px) {
  /* カテゴリ選択はSPではピルではなくプルダウンバー（cfd/stocklist と同型・同値） */
  .world-currencies-category-nav {
    display: none;
  }

  .world-currencies-category-select {
    display: block;
    position: relative;
    margin-top: 40px; /* リード文との間隔（ピル nav と同じ） */
  }

  .world-currencies-category-select-toggle {
    display: flex;
    width: 100%;
    min-height: 44px;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 19px;
    background: var(--ta-color-bg);
    border: 2px solid #c8d4e3; /* stocklist Figma 1200:7704 固有色（トークン未定義） */
    border-radius: 10px;
    font: 700 14px/1.7 var(--ta-font-family-ja); /* Figma指定14px（UI部品。本文16pxルール対象外） */
    letter-spacing: 1px;
    color: var(--primary-dark, #0a2463);
    text-align: left;
    cursor: pointer;
  }

  .world-currencies-category-select-toggle:hover,
  .world-currencies-category-select-toggle:focus-visible {
    background: var(--ta-color-primary-pale);
    border-color: var(--ta-color-main);
  }

  .world-currencies-category-select-icon {
    flex-shrink: 0;
    transition: transform 0.2s;
  }

  .world-currencies-category-select-toggle[aria-expanded="true"] .world-currencies-category-select-icon {
    transform: rotate(180deg);
  }

  .world-currencies-category-select-menu {
    position: absolute;
    z-index: 10;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    margin: 0;
    padding: 0;
    list-style: none;
    background: var(--ta-color-bg);
    border: 2px solid #c8d4e3; /* .world-currencies-category-select-toggle と同色 */
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--ta-shadow-card);
  }

  .world-currencies-category-select-menu[hidden] {
    display: none;
  }

  .world-currencies-category-select-option {
    display: block;
    padding: 10px 19px;
    font: 700 14px/1.7 var(--ta-font-family-ja); /* Figma指定14px（UI部品） */
    letter-spacing: 1px;
    color: var(--primary-dark, #0a2463);
    text-decoration: none;
  }

  .world-currencies-category-select-menu li + li .world-currencies-category-select-option {
    border-top: 1px solid var(--ta-color-border);
  }

  /* 項目の背景は白のまま。カーソル/フォーカス中のみ青背景+白文字（stocklist と同じ） */
  .world-currencies-category-select-option:hover,
  .world-currencies-category-select-option:focus-visible {
    background: var(--ta-color-main);
    color: var(--ta-color-bg);
  }

  .world-currencies-card-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .world-currencies-card {
    min-height: 0;
    /* 上padding 24px: 左上斜めのNEWリボンと旗が被らないよう下げる（stocklist SP と同じ） */
    padding: 24px 8px 16px;
    gap: 5px;
    border-color: var(--ta-color-primary-pale);
  }

  /* 旗2枚重ねを約0.69倍に縮小（64x48→44x33・重なり構図維持で全体 114x60→78x41） */
  .world-currencies-card__flags {
    width: 78px;
    height: 41px;
  }

  .world-currencies-card__flags-base,
  .world-currencies-card__flags-quote {
    width: 44px;
    height: 33px;
  }

  .world-currencies-card__flags-quote {
    top: 8px;
    left: 34px;
  }

  .world-currencies-card__flag {
    width: 70px;
    height: 41px;
  }

  .world-currencies-card__name {
    font: 700 11px/1.3 var(--ta-font-family-ja); /* stocklist SP と同じ 11px（カードUI部品） */
    letter-spacing: 1px;
  }

  /* NEWリボン小型化（stocklist SP の現行値 2026-07-14 と同値） */
  .world-currencies-card__ribbon {
    top: 4px;
    left: -17px;
    width: 60px;
    padding: 1px 0;
    font: 700 10px/1.4 var(--ta-font-family-ja); /* 青帯の太さ ≒ 10px×1.4+2px */
    letter-spacing: 0.5px;
  }
}

@media (min-width: 940px) {
  .world-currencies-inner {
    width: 1000px;
  }

  .world-currencies-section {
    padding: 80px 0;
    scroll-margin-top: 120px;
  }

  .world-currencies-category-nav {
    flex-wrap: nowrap;
    gap: 52px;
    margin-top: 40px;
  }

  .world-currencies-category-link {
    padding: 10px 40px;
  }

  .world-currencies-card-grid {
    grid-template-columns: repeat(4, 232px);
    gap: 30px 24px;
    justify-content: center;
    margin-top: 80px;
  }

  /* PC ではSP専用改行を無効化 */
  .world-currencies-sp-break {
    display: none;
  }
}
