
/*기본 설정*/
* {
  box-sizing: border-box;
}

html,
body {
  overflow: hidden;
  font-family: "Noto Sans JP", sans-serif;
}

canvas {
  touch-action: none;
}

/*AR 로딩 화면*/
.arjs-loader {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.86);
  color: #fff;
  font-size: 15px;
  letter-spacing: 0.04em;
}

/*뒤로가기 버튼*/
.back {
  position: fixed;
  top: max(20px, env(safe-area-inset-top));
  left: max(20px, env(safe-area-inset-left));
  z-index: 9000;
  width: 46px;
  height: 46px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.58);
  border-radius: 50%;
  text-decoration: none;
  touch-action: manipulation;
}

.back img {
  display: block;
  width: 58%;
  height: auto;
}

.back:active {
  transform: scale(0.94);
}

/*간단 설명창*/
.info-panel {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  background: transparent;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.info-panel.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: none;
}

.info-card {
  position: relative;
  width: min(100%, 520px);
  max-height: 70dvh;
  overflow-y: auto;
  padding: 28px 24px 26px;
  background: rgba(248, 248, 240, 0.98);
  color: #163c31;
  border-radius: 24px 24px 16px 16px;
  transform: translateY(30px);
  transition: transform 0.2s ease;
  pointer-events: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.24);
}

.info-panel.is-open .info-card {
  transform: translateY(0);
}

/*설명창 닫기 버튼*/
.info-close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 56, 43, 0.1);
  color: #163c31;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.info-close:active {
  transform: scale(0.94);
}

/*설명창 텍스트*/
.info-category {
  margin: 0 44px 8px 0;
  color: #527065;
  font-size: 13px;
  letter-spacing: 0.08em;
}

.info-title {
  margin: 0 44px 14px 0;
  font-size: 26px;
  line-height: 1.25;
}

.info-description {
  margin: 0;
  font-size: 15px;
  line-height: 1.75;
  white-space: pre-line;
}

/*오른쪽 위 도감 아이콘*/
.encyclopedia-button {
  position: fixed;
  top: max(82px, calc(env(safe-area-inset-top) + 68px));
  right: max(18px, env(safe-area-inset-right));
  z-index: 10500;
  width: 68px;
  height: 68px;
  padding: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(18px);
  transition:
    opacity 0.2s ease,
    visibility 0.2s ease,
    transform 0.2s ease;
  touch-action: manipulation;
}

.encyclopedia-button.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(0);
}

.encyclopedia-button img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.encyclopedia-button:active {
  transform: scale(0.94);
}

/*도감 팝업 전체 배경*/
.encyclopedia-modal {
  position: fixed;
  inset: 0;
  z-index: 11000;
  display: flex;
  justify-content: center;
  align-items: center;
  padding:
    calc(14px + env(safe-area-inset-top))
    12px
    calc(14px + env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.58);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.encyclopedia-modal.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/*도감 본체*/
.encyclopedia-book {
  position: relative;
  width: min(94vw, 430px);
  height: min(92dvh, 680px);
  display: flex;
  flex-direction: column;
  padding: 54px 23px 22px;
  overflow: hidden;
  background: #0c5b43;
  color: #fff;
  border-radius: 0 40px 40px 40px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  transform: scale(0.94);
  transition: transform 0.2s ease;
}

.encyclopedia-modal.is-open .encyclopedia-book {
  transform: scale(1);
}

/*도감 닫기 버튼*/
.encyclopedia-close {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  width: 38px;
  height: 36px;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0;
  border: 0;
  border-radius: 0 0 6px 0;
  background: #079447;
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  touch-action: manipulation;
}

.encyclopedia-close:active {
  opacity: 0.75;
}


/*도감 상단 제목*/
.encyclopedia-header {
  position: relative;
  flex: 0 0 auto;
  min-height: 150px;
  display: flex;
  justify-content: flex-start;
  align-items: flex-end;
  margin-bottom: 20px;
}

/*도감 제목 영역*/
.encyclopedia-heading {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 5px;
  margin-left: 10px;
  max-width: 100%;
}

/*도감 작은 제목*/
.encyclopedia-heading p {
  flex: 0 0 auto;
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.05;
  white-space: pre-line;
}

/*도감 큰 제목*/
.encyclopedia-heading h2 {
  flex: 0 0 auto;
  margin: 0;
  font-size: 42px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

/*도감 상단 생물 장식*/
.encyclopedia-symbol {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 1;
  width: 140px;
  height: 150px;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
}

/*장식 이미지 기본 설정*/
.encyclopedia-symbol img {
  display: block;
  width: 150px;
  height: auto;
  max-width: none;
  object-fit: contain;
  flex-shrink: 0;
}

/*선택되지 않은 장식 숨김*/
.encyclopedia-symbol.is-hidden {
  display: none;
}

/*바위 위: 달팽이*/
.encyclopedia-symbol.snail img {
  transform: translate(-30px, -30px) scale(1);
}

/*바위 위: 이끼*/
.encyclopedia-symbol.moss img {
  transform: translate(0px, 0px) scale(1);
}

/*바위 위: 톡토기*/
.encyclopedia-symbol.toktok img {
  transform: translate(-30px, -10px) scale(1);
}

/*도감 생물 카드 2×2*/
.encyclopedia-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 16px 14px;
  min-height: 0;
}

.encyclopedia-species-card {
  min-width: 0;
  min-height: 0;
  padding: 9px 10px 12px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: stretch;
  border: 0;
  border-radius: 36px;
  background: #fff;
  color: #111;
  text-align: left;
  overflow: hidden;
  cursor: pointer;
  touch-action: manipulation;
}

.encyclopedia-species-card:active {
  transform: scale(0.97);
}

.encyclopedia-species-image {
  flex: 1;
  width: 100%;
  min-height: 0;
  display: block;
  object-fit: contain;
}

.encyclopedia-species-name {
  margin: 3px 7px 0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.15;
}

.encyclopedia-species-scientific {
  margin: 2px 7px 7px;
  font-size: 10.5px;
  line-height: 1.13;
  overflow-wrap: anywhere;
}

/*도감 페이지 점*/
.encyclopedia-pagination {
  min-height: 31px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  padding-top: 16px;
}

.encyclopedia-page-dot {
  width: 10px;
  height: 10px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  touch-action: manipulation;
}

.encyclopedia-page-dot.is-active {
  width: 14px;
  height: 14px;
  background: #fff;
}

/*개별 생물 상세 팝업*/
.species-modal {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: flex;
  justify-content: center;
  align-items: center;
  padding:
    calc(20px + env(safe-area-inset-top))
    20px
    calc(20px + env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.62);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.species-modal.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.species-card {
  position: relative;
  width: min(100%, 390px);
  max-height: 82dvh;
  overflow-y: auto;
  padding: 30px 24px 27px;
  background: #f8f8f0;
  color: #163c31;
  border-radius: 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
  transform: scale(0.94);
  transition: transform 0.2s ease;
}

.species-modal.is-open .species-card {
  transform: scale(1);
}

.species-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 56, 43, 0.1);
  color: #163c31;
  font-size: 27px;
  line-height: 1;
  touch-action: manipulation;
}

.species-close:active {
  transform: scale(0.94);
}

.species-image {
  width: 100%;
  height: 190px;
  display: block;
  margin: 12px 0 20px;
  object-fit: contain;
}

.species-category {
  margin: 0 44px 6px 0;
  color: #527065;
  font-size: 12px;
  line-height: 1.3;
  letter-spacing: 0.08em;
}

.species-name {
  margin: 0 44px 4px 0;
  font-size: 28px;
  line-height: 1.2;
}

.species-scientific-name {
  margin: 0 0 20px;
  color: #435d54;
  font-size: 13px;
  font-style: italic;
  line-height: 1.4;
}

/*바위 위 생물 서식 위도*/
.species-latitude {
  margin: 0 0 18px;
  color: #435d54;
  font-size: 13px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.species-description {
  margin: 0;
  font-size: 15px;
  line-height: 1.75;
  white-space: pre-line;
}

/*작은 스마트폰 대응*/
@media screen and (max-width: 380px) {
  .encyclopedia-book {
    width: 96vw;
    height: 94dvh;
    padding: 50px 17px 18px;
  }

  .encyclopedia-header {
    min-height: 132px;
    margin-bottom: 15px;
  }

  .encyclopedia-heading p {
    font-size: 17px;
  }

  .encyclopedia-heading h2 {
    margin: 0;
    font-size: 36px;
  }

  .encyclopedia-symbol {
    width: 104px;
    height: 123px;
  }

  .encyclopedia-symbol img {
    width: 120px;
  }

  .encyclopedia-grid {
    gap: 12px 10px;
  }

  .encyclopedia-species-card {
    padding: 7px 8px 10px;
    border-radius: 28px;
  }

  .encyclopedia-species-name {
    font-size: 13px;
  }

  .encyclopedia-species-scientific {
    font-size: 9.5px;
  }
}

/*태블릿 대응*/
@media screen and (min-width: 768px) {
  .encyclopedia-book {
    width: min(72vw, 480px);
    height: min(84dvh, 720px);
  }

  .info-card {
    width: min(72vw, 560px);
  }

  .species-card {
    width: min(70vw, 430px);
  }
}

/*중앙 터치 안내 가이드*/
.touch-guide {
  position: fixed;
  inset: 0;
  z-index: 8500;
  pointer-events: none;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.touch-guide-frame {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(46vw, 190px);
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
}

.touch-guide-corner {
  position: absolute;
  width: 28px;
  height: 28px;
  border-color: rgba(255, 255, 255, 0.9);
  border-style: solid;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.55));
}

.touch-guide-corner.top-left {
  top: 0;
  left: 0;
  border-width: 3px 0 0 3px;
  border-radius: 8px 0 0 0;
}

.touch-guide-corner.top-right {
  top: 0;
  right: 0;
  border-width: 3px 3px 0 0;
  border-radius: 0 8px 0 0;
}

.touch-guide-corner.bottom-left {
  bottom: 0;
  left: 0;
  border-width: 0 0 3px 3px;
  border-radius: 0 0 0 8px;
}

.touch-guide-corner.bottom-right {
  right: 0;
  bottom: 0;
  border-width: 0 3px 3px 0;
  border-radius: 0 0 8px 0;
}

.touch-guide-center {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  transform: translate(-50%, -50%);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.65);
}

.touch-guide-text {
  position: absolute;
  left: 50%;
  bottom: calc(30px + env(safe-area-inset-bottom));
  width: min(88vw, 430px);
  margin: 0;
  padding: 11px 18px;
  transform: translateX(-50%);
  background: rgba(0, 56, 43, 0.82);
  color: #fff;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  box-shadow: 0 5px 18px rgba(0, 0, 0, 0.22);
}

.touch-guide.is-hidden {
  opacity: 0;
  visibility: hidden;
}
