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

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

/* ---- 入力 ---- */
/* 年・日付は文字（令和8、H31/4/30）も入るので左寄せ（共通の .input-unit input は右寄せ） */
html[data-ui="v2"] .er-in input[type="text"] { text-align: left; }
/* 入力の誤り（math.css の .vp-row input.bad と同じ見た目） */
html[data-ui="v2"] .er-in input.bad { border-color: var(--s2, #B4442C); border-width: 2px; }

/* ---- 結果 ---- */
/* 大きな文字（1997年・平成9年・昭和64年・平成元年）。改元の年の2つの元号は「・」のあとの <wbr> でだけ2行に折れる */
html[data-ui="v2"] .er-out .res-hero .big { flex-wrap: wrap; row-gap: 2px; }
html[data-ui="v2"] .er-out .res-hero .big b { font-size: clamp(26px, 8vw, 40px); overflow-wrap: normal; word-break: keep-all; }
/* 日付を大きく出すとき。日付は折り返さず1行（「令和100年12月31日」は 320px の画面で22pxなら約200px）。曜日は入らなければ次の行へ */
html[data-ui="v2"] .er-out .res-hero .big b .er-dt { font-size: clamp(22px, 6.4vw, 34px); white-space: nowrap; }
html[data-ui="v2"] .er-out .res-mini .v { overflow-wrap: normal; word-break: normal; }
html[data-ui="v2"] .er-out .res-mini .v small { white-space: nowrap; }
/* 文字の値（9＋88＝97、昭和64年・平成元年、1989年1月8日）は <wbr> の所でだけ折れる */
html[data-ui="v2"] .er-out .res-mini .v.text { word-break: keep-all; line-height: 1.35; }
html[data-ui="v2"] .er-out .res-mini .s { overflow-wrap: anywhere; }
@media (max-width: 400px) {
  html[data-ui="v2"] .er-out .res-mini .v { font-size: 15px; }
  html[data-ui="v2"] .er-out .res-mini .v.text { font-size: 14px; }
}
/* 読み込み直後（計算の前）は欄の高さを確保する（計算のあとに下の要素が動かないように）。計算が最初に .er-pending を外す。
   値は見積もり（描画での実測はしていない）。初期表示は「平成9年」（改元の年でないので帯の図なし）と「1989年1月7日」 */
#resultPanel.er-pending { min-height: 380px; }
#dOut.er-pending { min-height: 230px; }
#hyOut.er-pending { min-height: 1400px; }
@media (max-width: 480px) {
  #resultPanel.er-pending { min-height: 440px; }
  #dOut.er-pending { min-height: 280px; }
  #hyOut.er-pending { min-height: 1600px; }
}
#result { min-height: 230px; }
#resultPanel [hidden], #dateConv [hidden], #hayami [hidden] { display: none !important; }
.er-note { margin-top: 12px; }
.er-fl { display: block; margin: 0 0 6px; overflow-wrap: anywhere; }

/* 「25」のような数だけの入力の候補 */
html[data-ui="v2"] table.data.er-cand td, html[data-ui="v2"] table.data.er-cand th { white-space: normal; text-align: left; }
html[data-ui="v2"] table.data.er-cand td:first-child { width: 50%; }
.er-cand .er-pick { font-weight: 600; }

/* ---- 改元の年の帯：1月1日〜12月31日を元号で分ける（HTML の div で描く。文字は狭い画面でも縮まない） ---- */
.er-fig { margin: 18px 0 0; padding: 14px 16px 10px; border: 1px solid var(--grid); border-radius: var(--r); background: var(--surface); min-width: 0; }
.er-fig figcaption { font-size: 14px; font-weight: 700; color: var(--ink); line-height: 1.6; }
.er-band { position: relative; margin: 8px 4px 2px; padding-top: 22px; }
/* 変わった日の文字。帯の端に近いときは、はみ出さないよう片側に寄せる（l：線から右へ、r：線から左へ） */
.er-cutlab { position: absolute; top: 0; font-size: 12px; font-weight: 700; color: var(--ink); white-space: nowrap; transform: translateX(-50%); }
.er-cutlab.l { transform: translateX(-1px); }
.er-cutlab.r { transform: translateX(calc(-100% + 1px)); }
.er-bar { position: relative; height: 18px; border-radius: 3px; overflow: hidden; background: var(--accent-soft); }
.er-old { position: absolute; left: 0; top: 0; bottom: 0; background: color-mix(in srgb, var(--ink) 32%, var(--surface)); }
.er-new { position: absolute; top: 0; bottom: 0; right: 0; background: color-mix(in srgb, var(--accent) 45%, var(--surface)); }
.er-cut { position: absolute; top: 17px; height: 27px; width: 0; border-left: 2px solid var(--ink); }
.er-scale { position: relative; height: 18px; margin-top: 4px; font-size: 11px; color: var(--ink-2); }
.er-scale span { position: absolute; top: 0; white-space: nowrap; }
.er-scale span.l { left: 0; }
.er-scale span.r { right: 0; }
.er-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); }
.er-legend li { display: flex; align-items: center; gap: 6px; }
.er-legend i { display: inline-block; width: 14px; height: 10px; border-radius: 2px; flex: none; }
.er-legend i.k-old { background: color-mix(in srgb, var(--ink) 32%, var(--surface)); }
.er-legend i.k-new { background: color-mix(in srgb, var(--accent) 45%, var(--surface)); }

/* ---- 日付の変換（入力 | 結果 の2列。狭い画面では縦に並べる） ---- */
.er-split { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 860px) { .er-split { grid-template-columns: minmax(0, 1fr); } }
.er-split > * { min-width: 0; }
#dOut .res-hero { margin-top: 0; }

/* ---- 早見表 ---- */
.er-hy-ctl { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
html[data-ui="v2"] .er-hy-ctl .er-hy-hint { flex: 1 1 20em; min-width: 0; margin: 0; }
.er-hy-btns { display: flex; flex-wrap: wrap; gap: 6px 8px; }
#hyOut { margin-top: 14px; }
details.er-dec { border-top: 1px solid var(--grid); }
details.er-dec:last-child { border-bottom: 1px solid var(--grid); }
details.er-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.er-dec > summary::-webkit-details-marker { display: none; }
details.er-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.er-dec[open] > summary::before { transform: rotate(45deg); top: 15px; }
details.er-dec > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.er-dec-y { font-size: 15px; font-weight: 700; color: var(--ink); }
.er-dec-a { margin-left: auto; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
html[data-ui="v2"] .er-hy-note { margin: 0 0 6px; }
details.er-dec .table-scroll { margin: 0 0 12px; }
/* 4列（西暦／和暦／干支／年齢）。320px の画面の枠（約260px）に収まるよう、和暦だけ折り返し、年齢の見出しは <wbr> で折る */
html[data-ui="v2"] table.data.er-hy { width: 100%; }
html[data-ui="v2"] table.data.er-hy td { white-space: nowrap; }
html[data-ui="v2"] table.data.er-hy td.er-w { white-space: normal; text-align: left; min-width: 6.5em; }
html[data-ui="v2"] table.data.er-hy td.er-w b, html[data-ui="v2"] table.data.er-hy td.er-w .er-w2 { display: block; }
html[data-ui="v2"] table.data.er-hy td.er-w .er-w2 { font-weight: 400; color: var(--ink-2); }
html[data-ui="v2"] table.data.er-hy td.er-e { text-align: center; }
html[data-ui="v2"] table.data.er-hy th.n { white-space: normal; word-break: keep-all; }
html[data-ui="v2"] table.data.er-hy tr.er-fut td { color: var(--ink-2); }
@media (max-width: 400px) {
  html[data-ui="v2"] table.data.er-hy th, html[data-ui="v2"] table.data.er-hy td { padding-left: 6px; padding-right: 6px; }
  html[data-ui="v2"] table.data.er-hy th { font-size: 11.5px; }
}

/* 本文の表 */
table.er-wrap td, table.er-wrap th { white-space: normal; }
table.er-wrap td.n { white-space: nowrap; }
html[data-ui="v2"] table.data.er-era-tbl td { text-align: left; }
html[data-ui="v2"] table.data.er-era-tbl td.n { text-align: right; }
.er-era-tbl td:first-child { white-space: nowrap; font-weight: 600; }

/* ---- 印刷 ---- */
@media print {
  /* 「早見表を印刷」のとき：早見表だけを出す */
  html.er-print-hy body > *:not(main), html.er-print-hy main > *:not(#hayami) { display: none !important; }
  html.er-print-hy .er-hy-ctl { display: none !important; }
  html.er-print-hy #hayami { box-shadow: none; border: 0; padding: 0; }
  #hayami details.er-dec > summary::before { display: none; }
  #hayami details.er-dec > summary { padding-left: 0; }
  #hayami table.data { font-size: 10pt; }
  #hayami table.data th, #hayami table.data td { padding: 3px 6px; }
  #hayami table.data thead { display: table-header-group; }
  #hayami table.data tr { break-inside: avoid; }
  #hyOut.er-pending { min-height: 0; }
}
