/*
  명찰(라벨) 디자인과 자동 글자 맞춤 공통 코드
  - 기본 크기: 가로 90mm x 세로 62mm (Brother QL-800 + DK-22205, 드라이버 용지 "62mm")
  - 배치는 사용자가 만든 P-touch 레이아웃(명찰 레이아웃.lbx)을 그대로 옮긴 것:
      소속+이름 테두리 상자: x 4.73mm, y 12.10mm, 80.50 x 37.82mm, 선 0.5pt
      소속: 상자 위쪽 12.14mm 칸, 굴림 Bold 19.4pt(6.84mm), 가운데, 한 줄 자동 축소
      이름: 그 아래 25.68mm 칸, 굴림 Bold 56pt(19.76mm), 가운데, 한글 이름은 "홍 길 동"처럼 띄어 씀
      상자 위쪽 빈 칸(0~12.1mm): 행사명(설정에서 켜면) / 아래쪽 빈 칸: 비워 둠
  - 기본 출력은 "소속과 이름만" (2026-11-20 사용자 결정: 라벨을 미리 만든 두꺼운 명찰 종이에 붙임).
    행사명(명찰에행사명표시)과 테두리(명찰테두리)는 설정에서 Y로 켤 때만 출력. 글자 위치는 그대로.
  - 명찰 크기는 설정(명찰가로mm, 명찰세로mm)으로 바꿀 수 있고, 배치와 글자 크기는 비율대로 따라갑니다.
  - Input.html(미리보기), Admin.html(미리보기와 출력)에서 함께 사용합니다.
*/
.nb-badge {
  --bw: 90mm;   /* 명찰 가로 */
  --bh: 62mm;   /* 명찰 세로 */
  --s: 1;       /* 글자 크기 배율 (90x62 기준) */
  position: relative;
  width: var(--bw);
  height: var(--bh);
  box-sizing: border-box;
  background: #fff;
  color: #000;
  font-family: 'Gulim', '굴림', 'Malgun Gothic', '맑은 고딕', 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  overflow: hidden;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
/* 위쪽 빈 칸: 행사명, 로고 */
.nb-top {
  position: absolute;
  left: calc(var(--bw) * 0.05256);
  right: calc(var(--bw) * 0.05256);
  top: calc(var(--bh) * 0.0242);           /* 1.5mm: 프린터 인쇄 불가 여백 */
  height: calc(var(--bh) * 0.1710);        /* 12.1mm 위치까지 */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(2mm * var(--s));
}
.nb-logo { flex: none; max-height: 82%; max-width: 30%; object-fit: contain; }
.nb-top .nb-line { flex: 1; min-width: 0; }
.nb-top.nb-has-logo .nb-line { text-align: left; }
.nb-top.nb-has-logo .nb-line > span { transform-origin: left center; }
/* 소속 + 이름 테두리 상자 */
.nb-box {
  position: absolute;
  left: calc(var(--bw) * 0.05256);         /* 4.73mm */
  width: calc(var(--bw) * 0.89444);        /* 80.50mm */
  top: calc(var(--bh) * 0.19516);          /* 12.10mm */
  height: calc(var(--bh) * 0.61);          /* 37.82mm */
  box-sizing: border-box;
  border: 0.5pt solid transparent;
  display: flex;
  flex-direction: column;
}
.nb-box.nb-border { border-color: #000; }
.nb-org-cell { flex: 0 0 32.1%; display: flex; align-items: center; min-height: 0; }   /* 12.14mm */
.nb-name-cell { flex: 1 1 auto; display: flex; align-items: center; min-height: 0; }   /* 25.68mm */
.nb-line {
  width: 100%;
  padding: 0 1.2mm;
  box-sizing: border-box;
  white-space: nowrap;
  overflow: hidden;
  text-align: center;
  line-height: 1.2;
  font-weight: 700;
  font-synthesis: weight;
}
/* 굴림에는 굵은 글꼴 파일이 없어 브라우저가 굵게 만들지 않는 경우가 있으므로,
   P-touch(굴림 Bold)처럼 보이도록 테두리를 살짝 입혀 굵게 표시 */
.nb-badge.nb-gulim .nb-line > span { -webkit-text-stroke: 0.045em #000; paint-order: stroke fill; }
.nb-line > span { display: inline-block; white-space: pre; transform-origin: center center; }

/* 출력 전용 영역: 화면에서는 보이지 않는 곳에 두고(크기 계산은 되도록), 인쇄할 때만 표시 */
#nb-print-area { position: fixed; left: -20000px; top: 0; }

@page { size: 90mm 62mm; margin: 0; }
@media print {
  body.nb-printing { margin: 0 !important; padding: 0 !important; background: #fff !important; }
  body.nb-printing > *:not(#nb-print-area) { display: none !important; }
  body.nb-printing #nb-print-area { position: static; left: auto; }
  #nb-print-area .nb-badge { height: calc(var(--bh) - 0.1mm); break-after: page; page-break-after: always; }
  #nb-print-area .nb-badge:last-child { break-after: auto; page-break-after: auto; }
}
