/* JP 달력(/ja/calendar-<year> · /ja/) — 격자·월 확대·메모·인쇄 시트. 공통 style.css 위에 얹는다.
 *
 * 인쇄(설계 §4·정본 P7): A4 가로 1장. 화면에서는 인쇄 시트(#print-sheet)를 화면 밖에 mm 단위 고정 크기로 놓아
 * 두고 JS가 넘침을 잰다 — 넘치면 인쇄를 호출하지 않고 월간을 권한다(잘라내거나 계속 축소하지 않는다).
 * 인쇄 시에는 시트만 남긴다(body.has-sheet). JS·데이터가 없으면 정적 페이지가 그대로 인쇄된다.
 */

/* 일본어 본문 — 한글 우선 스택이면 한자가 한국식 자형으로 그려질 수 있다. */
html[lang="ja"] {
  --sans: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic",
    "Meiryo", "Noto Sans JP", "Noto Sans CJK JP", system-ui, sans-serif;
}
@media (min-width: 720px) { .wrap { max-width: 760px; } }

/* 스킵 링크 — 포커스 전에는 화면 밖 */
.skip { position: absolute; left: -999px; top: 8px; z-index: 30; background: var(--card); color: var(--accent);
  font-weight: 600; text-decoration: none; padding: 8px 12px; border: 2px solid var(--accent); border-radius: 8px; }
.skip:focus { left: 16px; }

/* 시각적으로만 숨김(표 캡션 등 — 낭독은 된다) */
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

/* ── 연간 격자 ── */
.cal-year { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 520px) { .cal-year { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 720px) { .cal-year { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.cal-month { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 10px 8px; min-width: 0; }
.cal-month h3 { font-size: 15px; font-weight: 700; margin: 0 0 6px; letter-spacing: -0.01em; }
.cal-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-variant-numeric: tabular-nums; }
.cal-table caption { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.cal-table th { font-size: 11px; font-weight: 600; color: var(--ink-soft); padding: 2px 0 3px; }
.cal-table td { text-align: center; vertical-align: top; padding: 0; height: 32px; font-size: 13.5px; }
.cal-day .cal-d { font-weight: 600; }
.cal-sun .cal-d, .cal-hol .cal-d { color: var(--warn); }
.cal-sat .cal-d { color: var(--accent); }
.cal-off { background: var(--line-soft); }
.cal-mk { display: inline-block; font-size: 9px; line-height: 1; margin-left: 1px; padding: 1px 2px; border-radius: 3px;
  border: 1px solid var(--ctrl-line); color: var(--ink-soft); vertical-align: 2px; }
.cal-btn { display: block; width: 100%; min-height: 32px; margin: 0; padding: 2px 0; font: inherit; color: inherit;
  background: transparent; border: 0; border-radius: 6px; cursor: pointer; }
.cal-btn:hover { background: var(--accent-bg); }
.cal-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
/* ≤767px 터치 타깃(design-spec 원칙 3 min-height 44, 라이브 테스트 W1 09-14: 연간 날짜 버튼 32px) — 연간 격자만, 높이만.
 * 셀 폭(table-layout fixed)·12개월 레이아웃은 그대로. 정적 격자(td)와 하이드레이션 후 버튼을 같은 값으로 두어 JS 적용 시 이동 0.
 * 확대 월(.cal-big 58px)·인쇄 시트(.ps-* mm, 버튼 없음)는 .cal-year 밖이라 무관. screen 한정이라 @media print 치수 불변. */
@media screen and (max-width: 767px) {
  .cal-year .cal-table td { height: 44px; }
  .cal-year .cal-btn { min-height: 44px; }
}
.cal-mh { margin: 6px 0 0; font-size: 12px; line-height: 1.5; color: var(--ink-soft); overflow-wrap: anywhere; }
.cal-mh b { color: var(--ink); font-weight: 600; margin-right: 4px; }
.cal-mh span { display: inline-block; margin-right: 8px; }
.cal-mh-none { color: var(--ink-faint); }
.cal-legend { margin: 0 0 8px; }
.cal-legend h3 { font-size: 13px; font-weight: 700; color: var(--ink-soft); margin: 0 0 4px; }
.cal-legend p { margin: 0 0 4px; font-size: 13px; color: var(--ink-soft); }
.cal-source { font-size: 12.5px; color: var(--ink-faint); margin: 0 0 12px; overflow-wrap: anywhere; }
.cal-source a { color: var(--ink-soft); }
.cal-controls .modes { margin-bottom: 12px; }
.cal-controls .printrow { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.cal-controls .printrow h2 { font-size: 15px; margin: 0 0 8px; }
.cal-controls .copyrow { margin-bottom: 4px; }
.cal-count { font-size: 14px; color: var(--ink-soft); margin: 0 0 8px; }
.cal-hlist td { white-space: normal; }
.cal-hlist td:first-child, .cal-hlist td:nth-child(2) { white-space: nowrap; }

/* ── 월 확대 패널 ── */
.cal-panelhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.cal-panelhead h2 { margin: 0; }
.cal-big .cal-month { padding: 14px; }
.cal-big .cal-table td { height: 58px; font-size: 16px; }
.cal-big .cal-btn { min-height: 58px; }
.cal-big .cal-mk { font-size: 11px; }
.cal-big .cal-mh { font-size: 13.5px; }

/* ── 메모 편집 ── */
#memo textarea { width: 100%; padding: 11px 12px; font: inherit; font-size: 16px; color: var(--ink); background: var(--card);
  border: 1px solid var(--ctrl-line); border-radius: 9px; resize: vertical; }
#memo textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
#memo .chip { margin-top: 10px; }
#memo-date { font-size: 15px; margin: 0 0 4px; }
.cal-holname { font-size: 14px; font-weight: 600; color: var(--warn); margin: 0 0 8px; }
#memo-error { margin-top: 8px; }

/* ── 확인 대화상자(삭제·미저장 이탈) ── */
.cal-dialog { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .45); padding: 16px; }
.cal-dialogbox { background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; width: 100%; max-width: 440px; }
.cal-dialogbox h2 { font-size: 16px; margin: 0 0 8px; }
.cal-dialogbox p { font-size: 14px; color: var(--ink-soft); margin: 0 0 12px; }
.cal-dialogbox .copyrow { margin: 0; }

/* ── 인쇄 시트(A4 가로 297×210mm, 여백 8mm → 281×194mm) — 화면에서는 밖에 두고 크기만 잰다 ── */
.print-sheet { position: absolute; left: -400vw; top: 0; width: 281mm; height: 194mm; overflow: hidden;
  background: #fff; color: #000; font-family: var(--sans); font-size: 8pt; line-height: 1.25; }
.print-sheet:empty { display: none; }
.ps-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2mm 6mm; margin: 0 0 2mm; }
.ps-head h2 { font-size: 14pt; font-weight: 700; margin: 0; }
.ps-ws { font-size: 9pt; }
.ps-exp { font-size: 9pt; font-weight: 700; }
.print-sheet .cal-month { background: none; border: 0; border-radius: 0; padding: 0; }
.print-sheet .cal-table caption { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.print-sheet .cal-table td { border: 0.2mm solid #888; }
.print-sheet .cal-day .cal-d { color: #000; }
.print-sheet .cal-sun .cal-d, .print-sheet .cal-hol .cal-d { font-weight: 700; text-decoration: underline; }
.print-sheet .cal-off { background: #e6e6e6; }
.print-sheet .cal-mk { border-color: #000; color: #000; }
.print-sheet .cal-mt { display: block; text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; }
.ps-annual { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2mm 3mm; }
.ps-annual .cal-month h3 { font-size: 9pt; margin: 0 0 0.8mm; }
.ps-annual .cal-table th { font-size: 6.5pt; padding: 0; }
.ps-annual .cal-table td { height: 6.4mm; font-size: 7pt; }
.ps-annual .cal-mk { font-size: 5.5pt; padding: 0.2mm 0.4mm; }
.ps-annual .cal-mt { font-size: 5.5pt; padding: 0 0.4mm; }
.ps-annual .cal-mh { font-size: 6.5pt; margin: 0.8mm 0 0; color: #000; }
.ps-annual .cal-mh b { color: #000; }
.ps-monthly .cal-month h3 { font-size: 12pt; margin: 0 0 1.5mm; }
.ps-monthly .cal-table th { font-size: 9pt; }
.ps-monthly .cal-table td { height: 25mm; font-size: 11pt; text-align: left; vertical-align: top; padding: 1mm; }
.ps-monthly .cal-mk { font-size: 8pt; }
.ps-monthly .cal-mt { font-size: 9pt; margin-top: 1mm; }
.ps-monthly .cal-mh { font-size: 9pt; margin: 2mm 0 0; color: #000; }
.ps-monthly .cal-mh b { color: #000; }
.ps-legend, .ps-src { font-size: 7.5pt; margin: 2mm 0 0; color: #000; }

@page { size: A4 landscape; margin: 8mm; }
@media print {
  body { background: #fff; color: #000; }
  /* 시트가 있으면 시트만. */
  body.has-sheet .wrap > :not(.print-sheet) { display: none !important; }
  body.has-sheet .wrap { max-width: none; margin: 0; padding: 0; }
  body.has-sheet .print-sheet { position: static; left: auto; width: auto; height: auto; overflow: visible; }
  /* 시트가 없으면(JS·데이터 없음) 정적 페이지 그대로 — 조작·대화상자는 뺀다. */
  .skip, .cal-controls, #memo, #copyrow, .cal-panelhead button, .cal-dialog, .toolnav { display: none !important; }
  .cal-year { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cal-month { break-inside: avoid; }
}
