/* ============================================================
   E-計算！ Math — 年齢計算（age-calculator.html）だけで使う見た目
   共通（../assets/css/ek.css・css/math.css）の上に重ねる。色は変数だけを使う。
   ============================================================ */

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

/* ---- 入力 ---- */
/* 日付の欄：文字で入れる欄 ＋ カレンダーのボタン（日数計算のページの .dc-date と同じ形） */
.ag-date { position: relative; display: flex; align-items: center; gap: 8px; min-width: 0; }
html[data-ui="v2"] .ag-date input[type="text"] {
  flex: 1 1 auto; width: 100%; min-width: 0; height: 44px; padding: 0 12px; font-size: 15px; font-variant-numeric: tabular-nums;
  color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r);
}
html[data-ui="v2"] .ag-date input[type="text"]:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
@media (max-width: 560px) { html[data-ui="v2"] .ag-date input[type="text"] { font-size: 16px; } }   /* iOS で入力時に拡大されないように */
.ag-pick {
  flex: none; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 0;
  border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); color: var(--ink-2); cursor: pointer;
}
.ag-pick:hover { background: var(--accent-soft); color: var(--accent); }
.ag-pick:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ag-pick svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.ag-pick[hidden] { display: none; }
/* カレンダーを開くための日付の欄（見えない。ボタンの下に置き、選ぶ画面がボタンの近くに出るようにする） */
.ag-native { position: absolute; right: 0; bottom: 0; width: 44px; height: 1px; padding: 0; border: 0; opacity: 0; pointer-events: none; }
/* 入力の誤り（math.css の .vp-row input.bad と同じ見た目） */
html[data-ui="v2"] .ag-date input.bad, html[data-ui="v2"] .input-unit input.bad { border-color: var(--s2, #B4442C); border-width: 2px; }
/* 基準日の横のボタン */
.ag-refbtn { margin: 8px 0 0; }

/* ---- 結果 ---- */
html[data-ui="v2"] .ag-out .res-hero .big b { font-size: clamp(32px, 9vw, 44px); overflow-wrap: normal; }
/* 日付を大きく出すとき（○歳になる日）。日付は折り返さず1行（「2055年5月15日」は 320px の画面で24pxなら約175px） */
html[data-ui="v2"] .ag-out .res-hero .big b .ag-dt { font-size: clamp(24px, 7vw, 34px); white-space: nowrap; }
html[data-ui="v2"] .ag-out .res-mini .v { overflow-wrap: normal; word-break: normal; }
html[data-ui="v2"] .ag-out .res-mini .v small { white-space: nowrap; }
/* 文字の値（小学3年生・高校卒業後など）は、<wbr> の所でだけ2行に折れる */
html[data-ui="v2"] .ag-out .res-mini .v.text { word-break: keep-all; line-height: 1.35; }
html[data-ui="v2"] .ag-out .res-mini .s { overflow-wrap: anywhere; }
@media (max-width: 400px) {
  html[data-ui="v2"] .ag-out .res-mini .v { font-size: 15px; }
  html[data-ui="v2"] .ag-out .res-mini .v.text { font-size: 14px; }
}
/* 読み込み直後（計算の前）は欄の高さを確保する（計算のあとに下の要素が動かないように）。計算が最初に .ag-pending を外す */
/* 値は初期表示の実測（2026-10-16、統括の描画確認）より少し小さめ：#resultPanel 1280px幅 1,199px・375px幅 1,416px、
   #raOut 227px・277px、#hyOut 1,218px・1,741px。861〜1279px と 481〜860px は測っていないので、狭い側の値に寄せすぎない */
#resultPanel.ag-pending { min-height: 1160px; }
#raOut.ag-pending { min-height: 220px; }
@media (max-width: 860px) {
  #resultPanel.ag-pending { min-height: 1180px; }
  #raOut.ag-pending { min-height: 230px; }
}
@media (max-width: 480px) {
  #resultPanel.ag-pending { min-height: 1370px; }
  #raOut.ag-pending { min-height: 265px; }
}
#result { min-height: 230px; }
#resultPanel [hidden], #reach [hidden], #hayami [hidden] { display: none !important; }
.ag-h3 { margin: 20px 0 4px; font-size: 15px; }
.ag-note { margin-top: 12px; }

/* くわしい結果の表（項目｜値） */
html[data-ui="v2"] table.data.ag-kv th { width: 7.5em; text-align: left; vertical-align: top; font-size: 12.5px; font-weight: 600; color: var(--ink-2); white-space: normal; word-break: keep-all; }
html[data-ui="v2"] table.data.ag-kv td { white-space: normal; overflow-wrap: anywhere; }
@media (max-width: 400px) {
  html[data-ui="v2"] table.data.ag-kv th, html[data-ui="v2"] table.data.ag-kv td { padding-left: 6px; padding-right: 6px; }
  html[data-ui="v2"] table.data.ag-kv th { width: 5.6em; }
}
.ag-fl { display: block; margin: 0 0 6px; overflow-wrap: anywhere; }

/* ---- 学年の図：同じ学年になる生年月日（4月2日〜翌年4月1日）の帯 ---- */
.ag-fig { margin: 18px 0 0; padding: 14px 16px 10px; border: 1px solid var(--grid); border-radius: var(--r); background: var(--surface); min-width: 0; }
.ag-fig figcaption { font-size: 14px; font-weight: 700; color: var(--ink); line-height: 1.6; }
.ag-fig figcaption small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.ag-band { position: relative; margin: 22px 6px 2px; }
.ag-bar { position: relative; height: 16px; border-radius: 3px; background: var(--accent-soft); overflow: hidden; }
.ag-haya { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--accent) 42%, var(--surface)); }
.ag-tick { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--surface); }
.ag-mark { position: absolute; top: -9px; bottom: -3px; width: 0; border-left: 2px solid var(--ink); }
.ag-mark::before { content: ""; position: absolute; top: -1px; left: -4px; border: 5px solid transparent; border-top: 6px solid var(--ink); }
.ag-scale { position: relative; height: 18px; margin-top: 3px; font-size: 11px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.ag-scale span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
.ag-scale span.l { transform: none; }
.ag-scale span.r { transform: translateX(-100%); }
.ag-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 0; margin: 6px 0 0; font-size: 12px; color: var(--ink-2); }
.ag-legend li { display: flex; align-items: center; gap: 6px; }
.ag-legend i { display: inline-block; width: 14px; height: 10px; border-radius: 2px; flex: none; }
.ag-legend i.k-haya { background: color-mix(in srgb, var(--accent) 42%, var(--surface)); }
.ag-legend i.k-rest { background: var(--accent-soft); }
.ag-legend i.k-mark { width: 2px; height: 14px; border-radius: 0; background: var(--ink); }

/* ---- ○歳になる日（入力 | 結果 の2列。狭い画面では縦に並べる） ---- */
.ag-split { display: grid; grid-template-columns: minmax(0, 320px) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 860px) { .ag-split { grid-template-columns: minmax(0, 1fr); } }
.ag-split > * { min-width: 0; }
html[data-ui="v2"] .ag-age input[type="text"] { max-width: 8em; }
#raOut .res-hero { margin-top: 0; }

/* ---- 年齢早見表 ---- */
.ag-hy-ctl { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
/* flex の子は既定で中身（長い選択肢の文字）より縮まないので、欄の幅を超えないようにする（320px で7px はみ出していた） */
.ag-hy-ctl .field { margin-bottom: 0; flex: 0 1 auto; min-width: 0; max-width: 100%; }
html[data-ui="v2"] .ag-hy-ctl select { width: auto; min-width: 8em; max-width: 100%; }
.ag-hy-btns { display: flex; flex-wrap: wrap; gap: 6px 8px; padding-bottom: 6px; }
#hyOut, #uyOut { margin-top: 14px; }
details.ag-dec { border-top: 1px solid var(--grid); }
details.ag-dec:last-child { border-bottom: 1px solid var(--grid); }
details.ag-dec > summary {
  list-style: none; cursor: pointer; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px;
  padding: 11px 4px 11px 22px; position: relative; font-size: 13.5px; color: var(--ink-2); user-select: none;
}
details.ag-dec > summary::-webkit-details-marker { display: none; }
details.ag-dec > summary::before {
  content: ""; position: absolute; left: 4px; top: 17px; width: 7px; height: 7px;
  border-right: 2px solid var(--accent); border-bottom: 2px solid var(--accent); transform: rotate(-45deg); transition: transform 0.15s;
}
details.ag-dec[open] > summary::before { transform: rotate(45deg); top: 15px; }
details.ag-dec > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ag-dec-y { font-size: 15px; font-weight: 700; color: var(--ink); }
.ag-dec-a { margin-left: auto; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
details.ag-dec .table-scroll { margin: 0 0 12px; }
/* 4列（生まれ年と和暦／干支／誕生日のあと／前）。320px の画面の枠（約260px）に収まるよう、見出しは「誕生日」「のあと」の <wbr> で2行に折る */
html[data-ui="v2"] table.data.ag-hy { width: 100%; }
html[data-ui="v2"] table.data.ag-hy td { white-space: nowrap; }
html[data-ui="v2"] table.data.ag-hy td.ag-w { white-space: normal; min-width: 7.5em; }
html[data-ui="v2"] table.data.ag-hy th.n { white-space: normal; word-break: keep-all; }
html[data-ui="v2"] table.data.ag-hy th.n, html[data-ui="v2"] table.data.ag-hy td.n { padding-left: 6px; }
@media (max-width: 400px) {
  html[data-ui="v2"] table.data.ag-hy th, html[data-ui="v2"] table.data.ag-hy td { padding-left: 6px; padding-right: 6px; }
  html[data-ui="v2"] table.data.ag-hy th { font-size: 11.5px; }
  html[data-ui="v2"] table.data.ag-hy td.ag-w { min-width: 6.8em; }
}

/* ---- ○歳は何年生まれ（3列：年齢／誕生日のあと／誕生日の前。2026-10-21） ---- */
.ag-um-lede { margin: 0 0 12px; }
html[data-ui="v2"] table.data.ag-um { width: 100%; max-width: 760px; }
html[data-ui="v2"] table.data.ag-um th, html[data-ui="v2"] table.data.ag-um td { text-align: left; }
html[data-ui="v2"] table.data.ag-um th { white-space: normal; word-break: keep-all; vertical-align: bottom; }
html[data-ui="v2"] table.data.ag-um th.ag-um-age { white-space: nowrap; vertical-align: top; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
html[data-ui="v2"] table.data.ag-um td.ag-w { white-space: normal; vertical-align: top; width: 44%; }
html[data-ui="v2"] table.data tbody tr.hit th.ag-um-age { color: var(--accent); }
html[data-ui="v2"] table.data.ag-um tbody tr:last-child th { border-bottom: 0; }
.ag-eto { margin-left: 6px; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
/* 学年：「高校3年生（早生まれは高校卒業後）」は、かっこの前で折れる */
.ag-gr { display: block; margin-top: 2px; font-size: 12px; line-height: 1.4; color: var(--ink-2); word-break: keep-all; overflow-wrap: anywhere; }
html[data-ui="v2"] table.data tbody tr.hit td .ag-gr, html[data-ui="v2"] table.data tbody tr.hit td .ag-eto { color: var(--ink-2); font-weight: 400; }
@media (max-width: 400px) {
  html[data-ui="v2"] table.data.ag-um th, html[data-ui="v2"] table.data.ag-um td { padding-left: 6px; padding-right: 6px; }
  html[data-ui="v2"] table.data.ag-um thead th { font-size: 11.5px; }
}

/* 本文の表 */
table.ag-wrap td, table.ag-wrap th { white-space: normal; }
table.ag-wrap td.n { white-space: nowrap; }
.ag-era-tbl td:first-child { white-space: nowrap; font-weight: 600; }

/* ---- 印刷 ---- */
@media print {
  /* 「表を印刷」のとき：年齢早見表だけを出す */
  html.ag-print-hy body > *:not(main), html.ag-print-hy main > *:not(#hayami):not(:has(#hayami)) { display: none !important; }
  /* PC の右の欄（ek.js の OC.rail）で #hayami が2列の枠の中に入っているときは、同じ枠のほかの表を隠す */
  html.ag-print-hy main :has(> #hayami) > *:not(#hayami) { display: none !important; }
  html.ag-print-hy .ag-hy-ctl, html.ag-print-hy .ag-hy-hint { display: none !important; }
  html.ag-print-hy #hayami { box-shadow: none; border: 0; padding: 0; }
  #hayami details.ag-dec > summary::before { display: none; }
  #hayami details.ag-dec > summary { padding-left: 0; }
  #hayami details.ag-dec { break-inside: avoid; }
  #hayami table.data { font-size: 10pt; }
  #hayami table.data th, #hayami table.data td { padding: 3px 6px; }
}
