/* ==========================================================================
   maze-maker 전용 스타일
   공통 패턴은 css/common.css, 용지 조판은 css/print-sheet.css 에 있습니다.
   여기에는 이 툴의 도메인(미로 그림, 풀이판, 용지 위 미로 배치)만 둡니다.

   🔴 인라인 style 금지 — 서버 CSP 가 style-src 'self' 라 style="" 은 차단됩니다.
      치수·상태는 data-* 속성이나 SVG 표현 속성(stroke-width 등)으로 넘깁니다.
   🔴 인쇄물에는 --color-* 를 쓰지 않습니다. 다크 모드에서 밝은 회색이 되어
      흰 종이에 거의 찍히지 않습니다. 용지 안은 --ink-* 만 씁니다.
   ========================================================================== */

/* --- 미로 그림 색 (이 툴 전용 데이터 색) ------------------------------------
   STYLE.md: 데이터 색은 UI 토큰에서 빌려 쓰지 않습니다. 접근성 때문에 토큰을
   바꿀 때 "정답 경로"와 "내가 그린 길"의 구분이 함께 흔들리기 때문입니다.
   흰 종이(.maze-board) 위 대비: 벽 15.4 · 정답 5.4 · 내 길 5.2 · 출발 6.5
   (모두 SC 1.4.11 의 비텍스트 3:1 을 넘습니다)
   색만으로 구분하지 않도록 정답은 파선, 내가 그린 길은 실선으로 모양도 다릅니다.
   -------------------------------------------------------------------------- */
.maze-board {
  --maze-wall: #1A2333;
  --maze-solution: #C0392B;
  --maze-trail: #1D6FB8;
  --maze-start: #116B4C;
  --maze-goal: #C0392B;
}

/* --- 화면에서 풀기 --------------------------------------------------------- */
.maze-play {
  display: grid;
  gap: var(--space-4);
  margin-top: var(--space-5);
}

.maze-play__head {
  display: grid;
  gap: var(--space-1);
}

.maze-play__title {
  margin: 0;
  font-size: var(--text-lg);
}

.maze-play__head .field-hint {
  margin: 0;
}

/* 종이처럼 늘 흰 바탕입니다. 다크 모드에서도 뒤집지 않습니다.
   미로 선은 연필로 그리는 종이를 흉내 낸 것이라 반전되면 오히려 읽기 어렵습니다. */
.maze-board {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: var(--space-3);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: #FFFFFF;
  color-scheme: light;
  /* 🔴 손가락으로 길을 그리는 동안 페이지가 같이 스크롤되면 안 됩니다.
     포인터 이벤트는 이 상자에서 받으므로 상자에도 함께 걸어 둡니다. */
  touch-action: none;
}

.maze-board svg {
  display: block;
  width: 100%;
  height: auto;
  /* 🔴 손가락으로 길을 그리는 동안 페이지가 같이 스크롤되면 안 됩니다. */
  touch-action: none;
}

.maze-play__meters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3) var(--space-6);
  margin: 0;
}

.maze-play__meters .stat {
  margin: 0;
  text-align: center;
}

.maze-play__message {
  min-height: 1.7em;
  margin: 0;
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.maze-play__message[data-state="done"] {
  color: var(--color-success);
  font-weight: var(--weight-bold);
}

.maze-play__actions {
  flex-wrap: wrap;
  justify-content: center;
}

.maze-play__actions .button {
  min-height: 44px;
}

/* --- SVG 미로 그림 --------------------------------------------------------- */
.maze-wall {
  fill: none;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

.maze-solution,
.maze-trail {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 정답 보기 토글. hidden 속성 대신 data-* 로 다룹니다(전역 [hidden] 과 뒤엉키지 않도록). */
.maze-solution[data-shown="no"] { display: none; }

.maze-board .maze-wall { stroke: var(--maze-wall); }
.maze-board .maze-solution { stroke: var(--maze-solution); stroke-dasharray: 3 3; }
.maze-board .maze-trail { stroke: var(--maze-trail); }
.maze-board .maze-arrow { fill: var(--maze-start); stroke: none; }
.maze-board .maze-mark--start { fill: var(--maze-start); stroke: none; }
.maze-board .maze-mark--goal { fill: var(--maze-goal); stroke: none; }

/* 용지 위에서는 먹 농도만 씁니다. */
.sheet .maze-wall { stroke: var(--ink-900); }
.sheet .maze-solution { stroke: var(--ink-500); }
.sheet .maze-arrow { fill: var(--ink-900); stroke: none; }
.sheet .maze-mark--start { fill: var(--ink-900); stroke: none; }
.sheet .maze-mark--goal { fill: var(--ink-700); stroke: none; }

/* --- 인쇄 미리보기 --------------------------------------------------------- */
/* 210mm 용지는 좁은 화면보다 넓습니다. 미리보기 안에서만 가로로 스크롤시켜
   페이지 전체가 밀리지 않게 합니다. 인쇄에는 영향이 없습니다. */
.sheet-stack {
  display: grid;
  gap: var(--space-5);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.print-scope {
  margin-top: var(--space-5);
}

/* 인쇄에서 뺄 용지는 이 클래스로 감춥니다.
   🔴 hidden 속성을 쓰면 전역 [hidden]{display:none!important} 때문에
      화면 미리보기에서도 사라져 버립니다. */
.sheet.is-excluded {
  display: none;
}

/* --- 용지 위 미로 배치 ------------------------------------------------------ */
.maze-guide {
  margin: 0 0 4mm;
  font-size: 10pt;
  color: var(--ink-700);
}

.maze-grid {
  display: grid;
  gap: 6mm;
}

.maze-grid[data-per="1"],
.maze-grid[data-per="2"] {
  grid-template-columns: 1fr;
}

.maze-grid[data-per="4"] {
  grid-template-columns: 1fr 1fr;
}

.maze-cell {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

/* 용지 안쪽 높이 267mm 에서 머리말·안내·꼬리말을 뺀 값입니다.
   높이를 못 박아 두면 미로가 다음 장으로 흘러넘칩니다.
   🔴 실측(2026-08-23) 218mm 로 두었을 때 문제지 내용 높이가 269mm 가 되어
      한 장을 넘겼습니다. 두 줄짜리(2·4개)는 101mm × 2 + 6mm 간격 = 208mm 로 맞춥니다. */
.maze-grid[data-per="1"] .maze-cell { height: 208mm; }
.maze-grid[data-per="2"] .maze-cell { height: 101mm; }
.maze-grid[data-per="4"] .maze-cell { height: 101mm; }

.maze-cell__no {
  margin: 0 0 1.5mm;
  font-size: 9.5pt;
  color: var(--ink-700);
}

.maze-cell__frame {
  min-height: 0;
  flex: 1 1 auto;
}

.maze-cell__frame svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* --- 모바일 ----------------------------------------------------------------- */
@media (max-width: 760px) {
  .maze-board {
    padding: var(--space-2);
  }

  .maze-play__meters {
    gap: var(--space-3) var(--space-4);
  }

  .maze-play__actions .button {
    flex: 1 1 auto;
  }
}
