/* =====================
   전체 레이아웃
===================== */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: sans-serif;
  touch-action: manipulation;
}

body {
  display: flex;
  flex-direction: column;
}

/* =====================
   상단 헤더
===================== */
#top-bar {
  height: 44px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  background: #222;
  color: #fff;
  border-bottom: 1px solid #111;
  flex-shrink: 0;
}

.brand {
  font-size: 16px;
  font-weight: 600;
  color: #ffffff;
}

.search-box input {
  padding: 6px 8px;
  width: 180px;
  border: none;
  border-radius: 4px;
  background: #444;
  color: #fff;
  font-size: 14px;
}

.search-box input::placeholder {
  color: #bbb;
}
/* ================================
   검색 결과 – 바둑판 썸네일
================================ */
#searchResults {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  width: min(1000px, 96%);
  max-height: 65vh;
  overflow-y: auto;
  background: #fff;
  padding: 12px;
  border: 1px solid #ddd;
  display: none;
  z-index: 1000;
}

/* 그리드 */
.search-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}

/* 아이템 */
.search-item {
  cursor: pointer;
  text-align: center;
}

/* 썸네일 */
.search-item img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border: 1px solid #ccc;
  background: #f8f8f8;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.search-item:hover img {
  transform: translateY(-3px);
  box-shadow: 0 6px 14px rgba(0,0,0,0.15);
}

/* 페이지 번호 */
.search-page {
  margin-top: 6px;
  font-size: 13px;
  color: #333;
}

/* 모바일 */
@media (max-width: 768px) {
  .search-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
}


/* =====================
   PDF 뷰어 영역
===================== */
#viewer {
  flex: 1;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #1e1e1e;
  overflow: hidden;
  height: calc(100vh - 88px); /* header + footer */
}

/* 캔버스 */
canvas {
  height: 100%;
  width: auto;
  max-width: 100%;
  background: white;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* 페이지 전환 애니메이션 */
.fade-out {
  opacity: 0;
  transform: translateX(-20px);
}

.fade-in {
  opacity: 1;
  transform: translateX(0);
}

/* =====================
   화살표
===================== */
.arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 36px;
  background: rgba(0, 0, 0, 0.55);
  color: white;
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  cursor: pointer;
  z-index: 10;
  transition: background 0.2s;
  touch-action: manipulation;
}

.arrow:hover {
  background: rgba(0, 0, 0, 0.75);
}

#arrow-left { left: 12px; }
#arrow-right { right: 12px; }

/* =====================
   하단 컨트롤
===================== */
#controls {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #222;
  color: white;
  flex-shrink: 0;
  border-top: 1px solid #111;
}

#page-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 240px;
  height: 6px;
  background: #555;
  border-radius: 10px;
  outline: none;
  cursor: pointer;
}

#page-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: #ddd;
  border-radius: 50%;
}

#page-slider::-webkit-slider-thumb:hover {
  background: #fff;
}

#page-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: #ddd;
  border-radius: 50%;
  border: none;
}

/* =====================
   모바일 전용
===================== */
@media (max-width: 768px) {
  #viewer {
    flex-direction: column;
    height: calc(100vh - 88px);
  }

  canvas {
    width: 100% !important;
    height: auto !important;
  }

  /* 오른쪽 페이지 숨김 */
  #canvas-right {
    display: none !important;
  }

  .arrow {
    width: 44px;
    height: 44px;
    font-size: 30px;
  }

  #page-slider {
    width: 100% !important;
  }

  .search-result {
    font-size: 14px;
    padding: 10px;
  }
}

#loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  display: none;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 5px solid #ddd;
  border-top: 5px solid #333;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

#page-preview {
  position: fixed;
  bottom: 80px;
  display: none;
  pointer-events: none;
  background: #111;
  padding: 6px;
  border-radius: 6px;
  z-index: 9999;
}

.preview-pages {
  display: flex;
  gap: 4px;
}

.preview-pages img {
  width: 90px;
  height: auto;
}

#preview-label {
  text-align: center;
  font-size: 12px;
  color: #fff;
  margin-top: 4px;
}


