/* =========================================================================
   Impossible Lab — 多言語対応のスタイル
   style.css（日本語を基準に設計）への上書きだけをここに集める。
   <html> の属性は assets/js/i18n.js が設定する:
     data-lang="fr"  表示言語      data-fg="latn"  書体グループ
     data-cjk        日中韓        data-tall       行高の必要な文字（アラビア・インド系・タイ系など）
     dir="rtl"       右から左（アラビア語・ヘブライ語・ペルシア語・ウルドゥー語・パシュトー語・ディベヒ語）
   ========================================================================= */

/* ---------- 言語ボタン ---------- */
.langbtn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 11px 0 9px; border-radius: 999px; border: 1px solid var(--line2); background: transparent; color: var(--tx2); font: 600 11.5px/1 var(--mono); letter-spacing: .08em; cursor: pointer; transition: border-color .2s, color .2s; }
.langbtn:hover { border-color: var(--line3); color: var(--tx); }
.langbtn .ic { width: 16px; height: 16px; }
.ftr-lang { display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
.ftr-lang:hover { color: var(--tx); }
.ftr-lang .ic { width: 14px; height: 14px; }
.ftr-lang span, .set-r .fine, .mnav-cta [data-act="lang"] { font-family: var(--sans), system-ui, sans-serif; }
.mnav-cta { display: flex; flex-direction: column; gap: 10px; }

/* ---------- 言語・地域の選択 ---------- */
.m-lang .modal-card { width: min(640px, 100%); }
.lg-sub { margin: 6px 0 0; color: var(--tx3); font: 500 12px/1.5 var(--mono); }
.lg-q { display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 14px; margin: 16px 0 10px; border: 1px solid var(--line2); border-radius: 12px; background: rgba(0, 0, 0, .28); color: var(--tx3); }
.lg-q:focus-within { border-color: var(--acc); }
.lg-q input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; color: var(--tx); font: 500 15px var(--sans); }
.lg-q input::-webkit-search-cancel-button { filter: invert(.6); }
.lg-list { list-style: none; margin: 0; padding: 0; max-height: min(50vh, 440px); overflow: auto; overscroll-behavior: contain; border: 1px solid var(--line); border-radius: 12px; }
.lg-list li { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.lg-list li:last-child { border-bottom: 0; }
.lg-list li[hidden] { display: none; }
.lg-cc { flex: none; width: 24px; font: 600 10.5px/1 var(--mono); letter-spacing: .06em; color: var(--tx3); }
.lg-cn { flex: 1; min-width: 0; font-size: 14px; line-height: 1.4; }
.lg-ls { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; max-width: 62%; }
.lg-ls button { min-height: 28px; padding: 3px 11px; border-radius: 999px; border: 1px solid var(--line2); background: transparent; color: var(--tx2); font: 500 12.5px/1.3 system-ui, -apple-system, "Segoe UI", "Noto Sans", sans-serif; cursor: pointer; transition: color .2s, border-color .2s; }
.lg-ls button:hover { color: var(--tx); border-color: var(--line3); }
.lg-ls button.on { color: var(--acc); border-color: var(--acc); }
.lg-none { margin: 0; padding: 22px 0; text-align: center; color: var(--tx3); font-size: 13.5px; }

/* ---------- 日中韓以外：語が長くなる言語のための組版 ---------- */
html:not([data-cjk]) :is(h1, h2, h3, h4, .step-ja, .mf) { word-break: normal; font-feature-settings: normal; }
/* 長い単語（独・芬・氷・タミル語など）は、はみ出す前に単語の途中でも折り返す。言語が対応していればハイフンも入れる */
html:not([data-cjk]) :is(h1, h2, h3, h4, p, li, dd, summary, .step-ja, .mf, .stack-l span, .fk span, .axis li span, .unit p, .it-b b, .bcell b, .prin b, .contact b, .ph-b h4, .log-b h4, .ms-l, .lbl) { overflow-wrap: anywhere; hyphens: auto; -webkit-hyphens: auto; hyphenate-limit-chars: 12 5 5; }
html:not([data-cjk]) .hero-t { font-size: clamp(38px, 5.5vw, 86px); line-height: 1.08; letter-spacing: -.015em; }
html:not([data-cjk]) .hero-t .ln { white-space: normal; }
html:not([data-cjk]) .hero-t em { font-size: 1.06em; }
html:not([data-cjk]) .hero-lead { line-height: 1.8; }
html:not([data-cjk]) .sh-t { font-size: clamp(27px, 3.5vw, 48px); line-height: 1.16; letter-spacing: -.005em; }
html:not([data-cjk]) .page-t { font-size: clamp(31px, 4.4vw, 62px); line-height: 1.12; }
html:not([data-cjk]) .pd-t { font-size: clamp(29px, 4.1vw, 58px); line-height: 1.14; }
html:not([data-cjk]) .final-t { font-size: clamp(33px, 5.2vw, 76px); line-height: 1.14; }
html:not([data-cjk]) .feat-t { font-size: clamp(25px, 2.8vw, 38px); line-height: 1.2; }
html:not([data-cjk]) .pc-t { font-size: 19px; line-height: 1.32; }
html:not([data-cjk]) .mf { font-size: clamp(19px, 2.1vw, 28px); line-height: 1.6; letter-spacing: 0; }
html:not([data-cjk]) .mf-last { font-size: clamp(26px, 3.4vw, 46px); line-height: 1.3; }
html:not([data-cjk]) .tm-h h3 { font-size: 23px; line-height: 1.25; }
html:not([data-cjk]) .axis-ja { font-size: 18px; }
html:not([data-cjk]) .step-ja { font-size: 12.5px; line-height: 1.3; hyphens: auto; }
html:not([data-cjk]) .mnav nav a { font-size: 21px; padding: 15px 0; }
html:not([data-cjk]) .sh-lead, html:not([data-cjk]) .page-lead { line-height: 1.75; }
html:not([data-cjk]) .cm-t { line-height: 1.7; }
/* 長いラベルは折り返す（日本語では1行に収まる前提だった箇所） */
html:not([data-cjk]) .btn { height: auto; min-height: 44px; padding-top: 9px; padding-bottom: 9px; line-height: 1.25; white-space: normal; text-align: center; }
html:not([data-cjk]) .btn-lg { min-height: 56px; }
html:not([data-cjk]) .btn-sm { min-height: 36px; padding-top: 6px; padding-bottom: 6px; }
html:not([data-cjk]) .btn-xs { min-height: 28px; padding-top: 4px; padding-bottom: 4px; }
html:not([data-cjk]) .lnk { white-space: normal; line-height: 1.3; }
html:not([data-cjk]) .chip { height: auto; min-height: 34px; padding-top: 6px; padding-bottom: 6px; line-height: 1.2; }
html:not([data-cjk]) .chips-sm .chip { min-height: 30px; }
html:not([data-cjk]) :is(.earn li b, .axis li b, .msn li b, .mj-ms li b, .ms-s, .bk-t) { white-space: normal; text-align: end; }
html:not([data-cjk]) .hist li p { white-space: normal; }
html:not([data-cjk]) .fig-a2 { writing-mode: horizontal-tb; top: 40%; right: -6%; max-width: 13ch; letter-spacing: .08em; line-height: 1.5; }
html:not([data-cjk]) .tbl-kv th { width: 34%; }
html:not([data-cjk]) .hero-stats em { line-height: 1.4; }
html:not([data-cjk]) .hero-stats .lbl { display: block; min-height: 2.9em; }
html:not([data-cjk]) .hero-stats .lbl i { display: block; }
html:not([data-cjk]) .week-b span, html:not([data-cjk]) .sc-found span { line-height: 1.5; }

/* ---------- 行高の必要な文字（アラビア・デーヴァナーガリー・タイ・クメール・ビルマ・チベット文字など） ---------- */
html[data-tall] body { line-height: 1.9; }
html[data-tall] .hero-t { line-height: 1.32; letter-spacing: 0; }
html[data-tall] :is(.sh-t, .page-t, .pd-t, .final-t, .feat-t) { line-height: 1.42; letter-spacing: 0; }
html[data-tall] :is(.pc-t, .tm-h h3, .axis-ja, .mf, .mf-last) { line-height: 1.6; }
html[data-tall] :is(.btn, .chip, .lnk, .nav a, .csort button, .pd-nav a, .lbl, .st em, .step-ja) { line-height: 1.5; }
html[data-tall] .mnav nav a { line-height: 1.5; padding: 12px 0; }
/* 画数の多い文字は、日本語・英字向けの極小サイズでは読めない。小さなラベルを底上げする */
html[data-tall] :is(.lbl, .fig-a, .pd-meta, .hero-stats em, .sc-pay, .cmp-r, .week-b span, .st em, .log-d em, .lm, .pc-cat, .tick, .fuel-meta, .sc-stats span, .step-p li, .ms-s, .axtag, .feat-kick, .pd-no, .vc-no, .eyebrow, .tbl th, .rar, .bk-t, .crown, .flag, .pop, .soon, .locked, .sponsor-slot, .season-t, .lg-sub) { font-size: 12.5px; }
html[data-tall] :is(.fine, .pc-h, .p-sm, .reactor-b p, .it-b p, .bcell p, .hist li, .mhist li) { font-size: 13.5px; }
html[data-tall] .week-d span, html[data-tall] .sc-quick em, html[data-tall] .tm-amts em { font-size: 9px; }
html[data-tall] :is(.lbl, .eyebrow, .fig-a, .pd-meta, .hero-stats em, .sc-pay, .tick, .pc-cat) { letter-spacing: .03em; }
/* 続け書きの文字は字間を空けない */
html:is([data-fg="arab"], [data-fg="thaa"], [data-fg="deva"], [data-fg="beng"], [data-fg="tibt"], [data-fg="mymr"], [data-fg="khmr"]) :is(h1, h2, h3, h4, p, span, em, b, i, a, li, td, th, button, label, div) { letter-spacing: 0 !important; }
html:is([data-fg="arab"], [data-fg="thaa"], [data-fg="hebr"], [data-fg="deva"], [data-fg="beng"], [data-fg="taml"], [data-fg="sinh"], [data-fg="thai"], [data-fg="laoo"], [data-fg="khmr"], [data-fg="mymr"], [data-fg="geor"], [data-fg="armn"], [data-fg="ethi"], [data-fg="tibt"]) :is(.lbl, .h-sm em) { text-transform: none; }
html[data-fg="tibt"] body { font-size: 16px; }
html[data-fg="tibt"] .hero-t { font-size: clamp(34px, 4.6vw, 70px); }

/* ---------- 右から左（RTL） ----------
   left/right の反転は rtl.css（tools/build-rtl.mjs が style.css から自動生成）が受け持つ。
   ここには、機械的な反転では決まらないものだけを書く。 */
/* 英数字のラベル・数値は、文中でも左から右のまま表示する（例: 「+20 IP」が「IP 20+」にならないように） */
[dir="rtl"] :is(b, em, small, strong, code, time, kbd, .mono, .lbl, .rk, .tier, .tc, .st, .flag, .crumb, .sh-en, .sh-no, .pc-no, .pd-no, .vc-no, .season-k, .found-no, .axtag, .it-c, .h-v, .cmp-r, .step-min, .lg-cc) { unicode-bidi: plaintext; text-align: -webkit-match-parent; text-align: match-parent; }
/* 流れる帯・図版・カード・グラフは向きを変えない */
[dir="rtl"] :is(.tk-rail, .roll, .idc, .fig, .wheel, .ladder, .ms-track, .pv-bar, .stack, .mchart, .fuel-track, .ix, .nx-bar, .rankbar-p, .vc-bar, .lpt-v, .week-d, .sv-mix, .lb-mix, .idc-axes, .ms-axes, .reactor-g, .cx-q, .qr-box, .wl-q, .lg-cc, .tm-custom, .ftr-giant, .ftr-pay) { direction: ltr; }
[dir="rtl"] .tk-track > * { margin-left: 0; margin-right: 18px; }
[dir="rtl"] .tk-track > span { direction: rtl; unicode-bidi: isolate; }
[dir="rtl"] :is(.step-info, .fig-a2, .fig-a3) { direction: rtl; }
[dir="rtl"] .step-info { text-align: right; }
[dir="rtl"] :is(code, input[type="number"], input[name="handle"], .wl-b code, .cx-addr code) { direction: ltr; text-align: left; }
/* 矢印アイコンは進行方向に合わせて反転 */
[dir="rtl"] .ic-arrow { transform: scaleX(-1); }
[dir="rtl"] .lnk:hover .ic-arrow { transform: scaleX(-1) translateX(3px); }

@media (max-width: 720px) {
  /* 1fr は中身の最小幅より狭くならないため、長い単語があると横にはみ出す。0 まで縮められるようにする */
  html:not([data-cjk]) :is(.pts, .pts.pts-1, .pts.pts-2, .reactor, .pts-1 .reactor) { grid-template-columns: minmax(0, 1fr); }
  html:not([data-cjk]) .reactor-b { min-width: 0; max-width: 100%; }
  html:not([data-cjk]) .reactor-b h4 { font-size: 21px; overflow-wrap: anywhere; }
  .lg-list { max-height: 52dvh; }
  .lg-list li { flex-wrap: wrap; gap: 6px 10px; }
  .lg-ls { max-width: none; width: 100%; justify-content: flex-start; padding-left: 34px; }
  [dir="rtl"] .lg-ls { padding-left: 0; padding-right: 34px; }
  html:not([data-cjk]) .hero-t { font-size: clamp(34px, 10vw, 54px); }
  html[data-tall] .hero-t { font-size: clamp(28px, 8.2vw, 46px); }
  html:not([data-cjk]) .fig-a2 { display: none; }
}
