/* HTML 매뉴얼 (content/{code}.html) 스타일 */
.manual {
  --manual-accent: #e53935;
  --manual-phone: #1c1c1e;
  /* 강조 박스와 대상 사이 여백 (모든 박스에 공통 적용) */
  --manual-box-pad: 4px;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 12px 0 40px;
  /* 한글을 글자 단위가 아니라 띄어쓰기 단위로 줄바꿈 (예: "포인/트" 대신 "포인트를" 통째로 넘김) */
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.manual-step {
  position: relative;
  margin-bottom: 40px;
}

/* 배정자 매뉴얼: 배정 여부 확인 전에는 본문을 숨깁니다 (manual-guard.ts). 자리는 유지해 화살표 계산이 맞도록 visibility 사용 */
.manual[data-guard="pending"] {
  visibility: hidden;
}

/* 로그인 필요 / 배정자 아님 안내 */
.manual-gate {
  margin: 48px auto;
  padding: 28px 20px;
  max-width: 360px;
  border: 1px solid #e5e0ea;
  border-radius: 12px;
  text-align: center;
  word-break: keep-all;
}

.manual-gate[hidden] {
  display: none;
}

.manual-gate__title {
  font-size: 17px;
  font-weight: 700;
}

.manual-gate__text {
  margin-top: 8px;
  color: #6b6b6b;
  font-size: 14px;
  line-height: 1.5;
}

.manual-gate__button {
  display: inline-block;
  margin-top: 20px;
  padding: 12px 28px;
  border-radius: 8px;
  background: var(--color-purple);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}

/* 매뉴얼 전체 PDF 다운로드 버튼 (PDF 가 있는 매뉴얼에만, manual_service.php) */
.manual-download {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.manual-download a {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 10px;
  border: 1px solid var(--color-purple);
  border-radius: 999px;
  background: #fff;
  color: var(--color-purple);
  font-size: 11px;
  font-weight: 600;
}

.manual-download a::before {
  content: "↓";
  font-weight: 700;
}

/* PDF 표지와 목차 (tools/manual-capture/pdf.mjs 가 넣음) */
.manual-pdf-cover {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 1000px;
  padding: 0 40px;
  break-after: page;
}

.manual-pdf-cover__logo {
  width: 120px;
  margin-bottom: 48px;
}

.manual-pdf-cover__kicker {
  color: var(--color-purple);
  font-size: 18px;
  font-weight: 700;
}

.manual-pdf-cover__title {
  margin: 12px 0 0;
  font-size: 40px;
  font-weight: 800;
  line-height: 1.3;
}

.manual-pdf-cover__desc {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 2px solid var(--color-purple);
  color: #555;
  font-size: 16px;
}

.manual-pdf-cover__date {
  margin-top: 8px;
  color: #888;
  font-size: 14px;
}

.manual-pdf-toc {
  max-width: 760px;
  margin: 0 auto;
  break-after: page;
}

.manual-pdf-toc__title {
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--color-purple);
  font-size: 24px;
  font-weight: 700;
}

.manual-pdf-toc__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.manual-pdf-toc__list a {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: inherit;
}

.manual-pdf-toc__section {
  margin-top: 16px;
  font-size: 16px;
  font-weight: 700;
}

.manual-pdf-toc__section:first-child {
  margin-top: 0;
}

.manual-pdf-toc__step {
  margin-top: 6px;
  padding-left: 20px;
  color: #444;
  font-size: 14px;
}

.manual-pdf-toc__dots {
  flex: 1;
  border-bottom: 1px dotted #bbb;
}

.manual-pdf-toc__page {
  min-width: 2em;
  text-align: right;
}

/* PDF 로 만들 때(인쇄): 화면 조작용 요소는 빼고, 한 단계가 두 쪽으로 나뉘지 않게 합니다 */
@media print {
  /* 구역(1. 이용 시간 정하기 …)은 새 쪽에서 시작합니다.
     웹의 구역 사이 여백(.manual-method margin-top)이 뒤에 선언되어 있어, 선택자를 한 단계 높여 위 여백을 없앱니다 */
  .manual .manual-method {
    margin-top: 0;
    break-before: page;
  }

  /* 첫 구역은 목차 다음 쪽에서 이미 시작하거나, 앞에 짧은 안내 문단만 있으므로 쪽을 넘기지 않습니다 */
  .manual .manual-method:first-of-type {
    break-before: auto;
  }

  /* 앱 기본 레이아웃은 화면 높이에 고정하고 본문만 스크롤하므로, 인쇄 때 첫 화면만 나오지 않게 풉니다 */
  html,
  body,
  .wrapper,
  main,
  .main__contents,
  .main__contents__inner {
    height: auto !important;
    overflow: visible !important;
    display: block !important;
  }

  .manual-download,
  .manual-jump {
    display: none !important;
  }

  /* 쪽마다 들어가는 단계 수가 몇 px 차이로 줄지 않도록 웹보다 여백을 줄입니다 */
  .manual {
    padding-top: 0;
    padding-bottom: 0; /* 마지막 쪽이 꽉 찼을 때 아래 여백만 빈 쪽으로 넘어가지 않게 */
  }

  .manual-step {
    margin-bottom: 24px;
    break-inside: avoid;
  }

  /* 세로로 긴 캡처는 pdf.mjs 가 폭을 줄여 높이를 맞추므로, 화면 칸 가운데에 둡니다 */
  .manual-step > .manual-shot {
    justify-self: center;
  }

  .manual-method__title,
  .manual-step__title {
    break-after: avoid;
  }
}

/* 같은 일을 하는 다른 방법(예: 달력 / 목록)을 나누는 구역 */
.manual-method {
  margin-top: 48px;
}

.manual-method__title {
  margin-bottom: 24px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--color-purple2);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  scroll-margin-top: 72px;
}

.manual-method {
  scroll-margin-top: 72px;
}

/* 매뉴얼 맨 위 안내 문단 */
.manual-intro {
  margin-bottom: 4px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-gray2);
}

/* 구역 바로가기 */
.manual-jump {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.manual-jump a {
  flex: 1;
  padding: 10px 4px;
  white-space: nowrap;
  border: 1.5px solid var(--color-purple2);
  border-radius: 8px;
  color: var(--color-purple2);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
}

/* 매뉴얼에 직접 놓인 바로가기는 그 위치를 지나 스크롤하면 화면 맨 위에 고정됩니다 */
.manual > .manual-jump {
  position: sticky;
  top: 0;
  z-index: 10;
  margin-left: -20px;
  margin-right: -20px;
  padding: 8px 20px;
  background: #fff;
  box-shadow: 0 4px 6px -4px rgba(0, 0, 0, 0.15);
}

/* 바로가기로 이동했을 때 소제목이 고정된 바로가기 밑에 가려지지 않도록 */
.manual-method {
  scroll-margin-top: 64px;
}

.manual-step__title {
  margin-bottom: 14px;
  font-size: 16px;
  font-weight: 700;
}

/* 설명 속 실제 버튼 모양 (화면 이미지에서 잘라냄, manual.js renderButtons) */
.manual-btn {
  display: inline-block;
  /* 앱 버튼 글자가 작아 너무 줄이면 읽기 어려우므로 글자보다 조금 크게 */
  height: 2em;
  aspect-ratio: var(--btn-ratio, 1);
  margin: 1px 2px;
  vertical-align: -0.65em;
  border-radius: 4px;
  background-repeat: no-repeat;
  background-color: #eee;
}

/* 배경 없이 화살표만 있는 버튼(<, >)은 옅은 회색 바탕을 깔아 버튼 영역을 보여줍니다 (흰색 → 회색, 글자는 그대로) */
.manual-btn--plain {
  /* 화살표만 있는 버튼은 글자 크기와 비슷하게 */
  height: 1.45em;
  vertical-align: -0.35em;
  background-color: #ececec;
  background-blend-mode: multiply;
  border-radius: 6px;
}

/* 동그란 아이콘 버튼(? 등)은 글자 크기에 맞게 */
.manual-btn--icon {
  height: 1.4em;
  vertical-align: -0.3em;
}

/* 공통 reset.css 가 strong 굵기를 없애므로 매뉴얼 안에서 되살립니다 */
.manual strong {
  font-weight: 700;
}

/* 괄호 (…) 는 한 덩어리로 줄바꿈 (manual.js groupParens) */
.manual-paren {
  display: inline-block;
}

/* 휴대폰 틀 + 화면 */
.manual-shot {
  width: min(100%, 280px);
  margin: 0 auto;
  padding: 9px;
  border-radius: 38px;
  background: var(--manual-phone);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}

/* 화면 높이는 이미지 비율을 그대로 따릅니다 (기기마다 비율이 달라도 잘리거나 박스가 어긋나지 않도록) */
.manual-shot__screen {
  position: relative;
  border-radius: 30px;
  background: #fff;
}

.manual-shot__screen img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 30px;
}

.manual-shot--pending .manual-shot__screen {
  aspect-ratio: 390 / 844;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f2f2f4;
  color: var(--color-gray);
  font-size: 14px;
}

/* 강조 박스 + 번호. --x/--y/--w/--h 는 이미지 대비 % (좌표 JSON 값) */
.manual-shot__box {
  /* 방향별 여백. 이웃 박스와 겹치면 manual.js 가 마주 보는 쪽만 줄입니다. */
  --pt: var(--manual-box-pad);
  --pr: var(--manual-box-pad);
  --pb: var(--manual-box-pad);
  --pl: var(--manual-box-pad);
  position: absolute;
  box-sizing: border-box;
  top: calc(var(--y) * 1% - var(--pt));
  left: calc(var(--x) * 1% - var(--pl));
  width: calc(var(--w) * 1% + var(--pl) + var(--pr));
  height: calc(var(--h) * 1% + var(--pt) + var(--pb));
  border: 2.5px solid var(--manual-accent);
  border-radius: 6px;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.75);
}

.manual-shot__box::before,
.manual-step__notes > li::before {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--manual-accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.manual-shot__box::before {
  content: attr(data-n);
  position: absolute;
  top: -12px;
  left: -12px;
}

/* 배지가 겹칠 때 manual.js 가 고르는 위치 (기본은 왼쪽 위) */
.manual-shot__box[data-badge="tr"]::before { left: auto; right: -12px; }
.manual-shot__box[data-badge="tc"]::before { left: calc(50% - 10px); }
.manual-shot__box[data-badge="bl"]::before { top: auto; bottom: -12px; }
.manual-shot__box[data-badge="br"]::before { top: auto; bottom: -12px; left: auto; right: -12px; }
.manual-shot__box[data-badge="lm"]::before { top: calc(50% - 10px); }
.manual-shot__box[data-badge="rm"]::before { top: calc(50% - 10px); left: auto; right: -12px; }

/* 설명 목록: 순서가 강조 박스 번호와 같습니다 */
.manual-step__notes {
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: manual-note;
}

.manual-step__notes > li {
  position: relative;
  margin-bottom: 8px;
  padding-left: 30px;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.6;
  counter-increment: manual-note;
}

.manual-step__notes > li::before {
  content: counter(manual-note);
  position: absolute;
  top: 2px;
  left: 0;
}

/* 설명 안의 경고 문장 (예: 차량번호를 틀리게 입력하면 단속·견인 대상) */
.manual-warn {
  display: block;
  margin-top: 4px;
  color: #e00000;
  font-weight: 700;
}

/* 설명 안의 짧은 목록 (입력 형식 등) */
.manual-step__notes ul {
  margin: 4px 0 0;
  padding-left: 18px;
}

.manual-step__notes ul > li {
  list-style: disc;
}

/* 중간에서 줄이 바뀌면 읽기 어려운 말(번호판 형식 ○○가○○○○, 단속·견인 등) */
.manual-nowrap {
  white-space: nowrap;
}

/*
 * 화면 속 색을 설명할 때 쓰는 색상 칸. 실제 화면 색을 --swatch 로 지정합니다.
 *   <span class="manual-legend">
 *     <span><i class="manual-swatch" style="--swatch:#2e7d32"></i>공유</span> …
 *   </span>
 * 세로선(현재 시간 등)은 manual-swatch--line.
 */
.manual-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 6px 0;
}

.manual-legend > span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.manual-swatch {
  display: inline-block;
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  vertical-align: -2px;
}

/* 문장 안에 바로 쓴 색상 칸 (범례 밖) */
.manual-step__notes li > .manual-swatch {
  margin: 0 4px 0 2px;
}

.manual-swatch--line {
  width: 3px;
  border-radius: 0;
  box-shadow: none;
}

/* 넓은 화면: 휴대폰 옆에 설명 상자 + 화살표 (manual.js) */
.manual-step__arrows {
  position: absolute;
  top: 0;
  left: 0;
  overflow: visible;
  pointer-events: none;
}

@media (min-width: 720px) {
  .manual-step {
    display: grid;
    grid-template-columns: 280px 1fr;
    /* 제목 / 설명 / 안내 문구. 화면 이미지 높이의 남는 공간은 마지막 줄이 가져가 안내 문구가 설명 바로 아래 붙습니다 */
    grid-template-rows: auto auto 1fr;
    column-gap: 80px;
    align-items: start;
  }

  .manual-step__title {
    grid-column: 1 / -1;
  }

  /* 단계 안의 안내 문구(설명 아래 추가 안내)는 설명 바로 아래, 오른쪽 칸에 둡니다 */
  .manual-step > .manual-shot {
    grid-row: 2 / span 2;
  }

  .manual-step > .manual-intro {
    grid-column: 2;
    align-self: start;
    margin-top: 12px;
  }

  /* 안내 문구를 설명보다 먼저 둔 단계: 안내 문구가 설명 자리(위)에, 설명이 그 아래에 옵니다 */
  .manual-step > .manual-intro:has(+ .manual-step__notes) {
    margin-top: 48px;
  }

  .manual-step > .manual-intro + .manual-step__notes {
    margin-top: 12px;
  }

  .manual-shot {
    margin: 0;
  }

  .manual-step__notes {
    margin-top: 48px;
    padding: 16px 16px 8px;
    border: 1.5px solid var(--manual-accent);
    border-radius: 8px;
    background: #fff;
  }
}
