/* ============================================================
   E-計算！ Math — 素因数分解・最大公約数・最小公倍数（prime-factorization.html）だけで使う見た目
   共通（../assets/css/ek.css・css/math.css）の上に重ねる。色は変数だけを使う。
   ============================================================ */

/* ページ上部の要点 */
.pf-quick { margin: 4px 0 20px; }
.pf-quick ul { margin: 2px 0 0; }
.pf-quick li { margin: 2px 0; }

/* 計算すること（2つの切り替え）：「最大公約数・最小公倍数」は「・」のところでだけ2行に折る */
html[data-ui="v2"] form .radio-row.pf-modes > label { word-break: keep-all; text-align: center; line-height: 1.4; }
@media (max-width: 400px) {
  html[data-ui="v2"] form .radio-row.pf-modes > label { padding-left: 6px; padding-right: 6px; font-size: 13.5px; }
}

/* 入力欄（整数を1つ、または空白で区切った数）。数の並びなので左寄せ */
html[data-ui="v2"] .input-unit input.pf-in { text-align: left; }
html[data-ui="v2"] .input-unit input.pf-in.bad { border-color: var(--s2, #B4442C); border-width: 2px; }
html[data-ui="v2"] .input-unit input.pf-in::placeholder { color: var(--muted); }

/* ---- 結果 ---- */
#result { min-height: 230px; }
/* 読み込み直後（計算の前）は、結果の欄の高さを確保する（初期表示〈1764〉の高さより小さい値）。calc が最初に .pf-pending を外す */
#resultPanel.pf-pending { min-height: 560px; }
#resultPanel [hidden] { display: none !important; }
.pf-out .verdict { margin-top: 12px; line-height: 1.8; }

/* 大きな数字：素因数分解の式は「×」のあとと、桁区切りのカンマのあとでだけ折り返す（ページの script が <wbr> を入れる） */
html[data-ui="v2"] .pf-out .res-hero .big { flex-wrap: wrap; row-gap: 2px; }
html[data-ui="v2"] .pf-out .res-hero .big b { font-size: clamp(26px, 7.5vw, 40px); overflow-wrap: normal; word-break: normal; line-height: 1.25; }
html[data-ui="v2"] .pf-out .res-hero .big b sup { font-size: 0.55em; vertical-align: 0; position: relative; top: -0.85em; margin-left: 1px; }
html[data-ui="v2"] .pf-out .res-hero .big b .pf-x { font-weight: 400; color: var(--ink-2); }
html[data-ui="v2"] .pf-out .pf-longexp .res-hero .big b { font-size: clamp(20px, 5.5vw, 30px); }   /* 素因数の多い式は字を小さく */
/* 最大公約数と最小公倍数を横に並べる（狭い画面では縦に） */
.pf-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; }
.pf-pair > div { min-width: 0; }
.pf-pair > div + div { border-left: 1px solid var(--grid); padding-left: 20px; }
@media (max-width: 480px) {
  .pf-pair { grid-template-columns: minmax(0, 1fr); }
  .pf-pair > div + div { border-left: 0; padding-left: 0; border-top: 1px solid var(--grid); padding-top: 12px; }
}
html[data-ui="v2"] .pf-pair .pf-long .res-hero .big b { font-size: clamp(20px, 5.5vw, 28px); }

/* 小さな箱：数の途中では折らない（カンマ・数と単位のあいだの <wbr> でだけ折る） */
html[data-ui="v2"] .pf-out .res-mini .v { overflow-wrap: normal; word-break: normal; }
html[data-ui="v2"] .pf-out .res-mini .v small { white-space: nowrap; }
html[data-ui="v2"] .pf-out .res-mini .s { overflow-wrap: anywhere; }
html[data-ui="v2"] .pf-out .res-mini.pf-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 400px) {
  html[data-ui="v2"] .pf-out .res-mini .v { font-size: 15px; }
  html[data-ui="v2"] .pf-out .res-mini .v.long { font-size: 14px; }
}
/* それでも欄からはみ出す数がある行は、箱を縦に並べる（ページの script の fitMinis が付ける） */
html[data-ui="v2"] .pf-out .res-mini.pf-stack { grid-template-columns: minmax(0, 1fr); row-gap: 10px; }
html[data-ui="v2"] .pf-out .res-mini.pf-stack > div { padding: 0; }
html[data-ui="v2"] .pf-out .res-mini.pf-stack > div + div { border-left: 0; padding: 10px 0 0; border-top: 1px solid var(--grid); }
/* √ の中の数の上の線 */
.pf-rad { border-top: 1.5px solid currentColor; padding: 0 1px; margin-left: 1px; }

/* ---- 図（すだれ算・割ってみる表・素因数の表） ---- */
.pf-fig { margin: 16px 0 0; padding: 14px 16px 10px; border: 1px solid var(--grid); border-radius: var(--r); background: var(--surface); min-width: 0; }
.pf-fig figcaption { font-size: 13.5px; font-weight: 700; color: var(--ink); margin-bottom: 4px; line-height: 1.6; }
.pf-fig-note { font-size: 12px; color: var(--ink-2); line-height: 1.8; padding-top: 8px; margin: 10px 0 0; border-top: 1px solid var(--grid); overflow-wrap: anywhere; }
.pf-fig-note + .pf-fig-note { border-top: 0; margin-top: 0; padding-top: 2px; }
.pf-fig .table-scroll { margin-top: 6px; }

/* すだれ算：割る素数（左）と、割られる数（右。左と下に線） */
.pf-lad-wrap { overflow-x: auto; padding: 4px 2px 6px; }
table.pf-ladder { border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 15px; line-height: 1.2; margin: 0; }
table.pf-ladder td { padding: 5px 10px; white-space: nowrap; text-align: right; }
table.pf-ladder td.pf-d { padding-right: 8px; color: var(--accent); font-weight: 700; min-width: 2em; }
table.pf-ladder td.pf-d.pf-d2 { color: var(--s2); }
table.pf-ladder tr:not(.pf-bottom) td.pf-n { border-bottom: 1.5px solid var(--ink-2); }
table.pf-ladder tr:not(.pf-bottom) td.pf-n:nth-child(2) { border-left: 1.5px solid var(--ink-2); }
table.pf-ladder td.pf-keep { color: var(--muted); }
table.pf-ladder tr.pf-bottom td.pf-n { font-weight: 700; color: var(--ink); }
table.pf-ladder tr.pf-gap td { color: var(--muted); font-size: 12px; text-align: center; border: 0 !important; }
.pf-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 2px 16px; padding: 0; margin: 6px 0 0; font-size: 12px; color: var(--ink-2); }
.pf-legend li { display: flex; align-items: center; gap: 6px; }
.pf-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; background: var(--accent); }
.pf-legend i.pf-i2 { background: var(--s2); }
.pf-legend i.pf-ik { background: color-mix(in srgb, var(--muted) 45%, var(--surface)); }
.pf-eq { margin: 8px 0 0; font-size: 13px; line-height: 1.8; overflow-wrap: anywhere; }
.pf-eq b { font-variant-numeric: tabular-nums; }

/* 素因数の表（数ごとの指数。最大公約数・最小公倍数の行） */
table.data.pf-ftab td, table.data.pf-ftab th { text-align: center; }
table.data.pf-ftab td:first-child { text-align: left; font-weight: 600; }
table.data.pf-ftab td .sub { font-weight: 700; color: var(--ink); font-size: 12.5px; }
table.data.pf-ftab tr.pf-res td { background: var(--page); }
table.data.pf-ftab td.pf-zero { color: var(--muted); }
table.data sup, .pf-fl sup, .pf-eq sup { font-size: 0.7em; line-height: 0; }

/* 割ってみる表（素数かどうか） */
table.data.pf-trial { width: auto; min-width: 15em; }
table.data.pf-trial tr.pf-gap td { color: var(--muted); text-align: center; }

/* 約数の表・一覧 */
table.data.pf-dtab { width: auto; }
table.data.pf-dtab th.pf-rh { text-align: right; color: var(--ink-2); font-weight: 600; background: var(--page); }
.pf-divs { margin: 10px 0 0; font-size: 13px; line-height: 1.9; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* ---- 計算式と内訳・互除法 ---- */
.pf-fl { display: block; margin: 0 0 6px; overflow-wrap: anywhere; }
.pf-eu { margin: 4px 0 10px; padding-left: 0; list-style: none; font-variant-numeric: tabular-nums; }
.pf-eu li { margin: 0; overflow-wrap: anywhere; }
.pf-eu-h { font-weight: 700; margin: 8px 0 2px; }

/* ---- 解説の表 ---- */
table.data.pf-sqtab { width: auto; min-width: 14em; }
