/* 💌 방명록(리락쿠마 말풍선) + 🚌 전세버스
   index.html 에서 gallery.css 바로 아래에 추가:
   <link rel="stylesheet" href="css/guestbook.css" />
*/

:root {
  /* 말풍선 가로 크기: (청첩장 폭 - 좌우 여백 48px) x 92%  — 목록, 미리보기, 전체보기 팝업이 모두 같다 */
  --gb-bw: calc((min(100vw, 430px) - 48px) * 0.92);
}

/* =========================================================
   공통 폼 부품 (방명록 작성 창 / 전세버스 공용)
   ========================================================= */
.gb-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-sub);
  text-align: left;
}
.gb-label small { font-weight: 400; color: #a89888; }
.gb-label .gb-limit { float: right; font-weight: 400; color: #a89888; letter-spacing: 0.3px; }
.gb-write.is-over .gb-limit { color: var(--sun-color); }

.gb-field { margin-bottom: 16px; text-align: left; }

.gb-input {
  display: block;
  width: 100%;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  outline: none;
  background-color: #ffffff;
  font-family: 'Cafe24Dongdong', sans-serif;
  font-size: 16px; /* 16px 미만이면 iOS 에서 입력 시 화면이 확대된다 */
  color: var(--text-main);
  resize: none;
}
.gb-input:focus { border-color: var(--primary-color); }
.gb-field .gb-input { margin-bottom: 0; }

/* 봇 방지용 숨은 칸 */
.gb-hp {
  position: absolute !important;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.gb-error {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--sun-color);
  text-align: center;
}
.gb-error[hidden] { display: none; }

/* 선택 버튼(라디오) */
.gb-seg { display: flex; gap: 8px; }
.gb-seg label { position: relative; flex: 1; }
.gb-seg input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.gb-seg span {
  display: block;
  padding: 11px 4px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background-color: #ffffff;
  font-size: 14px;
  color: var(--text-main);
  text-align: center;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.gb-seg input:checked + span {
  border-color: var(--primary-color);
  background-color: var(--primary-color);
  color: #ffffff;
  font-weight: 600;
}
.gb-seg input:focus-visible + span { outline: 2px solid var(--primary-color); outline-offset: 2px; }

/* =========================================================
   방명록 — 편지함
   ========================================================= */
.gb-mailbox {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none; /* 투명 PNG 가 배경 없이 그대로 보이도록 */
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.2s ease;
}
.gb-mailbox:active { transform: scale(0.985); }
.gb-mailbox img {
  display: block;
  width: 100%;
  height: auto; /* 이미지 원래 비율 */
  filter: drop-shadow(0 8px 14px rgba(60, 40, 25, 0.18)); /* 투명 PNG 는 모양을 따라가는 그림자 */
}

.gb-open-btn { margin-top: 14px; }

/* =========================================================
   방명록 — 카톡 스타일 목록
   ========================================================= */
.gb-feed { margin-top: 36px; scroll-margin-top: 24px; }

.gb-feed-head {
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
  font-size: 13px;
  color: var(--text-sub);
  text-align: left;
}
.gb-feed-head b { color: var(--primary-color); font-weight: 700; }

.gb-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
  list-style: none;
}

.gb-state {
  padding: 28px 0;
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--text-sub);
  text-align: center;
}

.gb-msg {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.gb-msg--left { align-items: flex-start; }
.gb-msg--right { align-items: flex-end; }

.gb-msg--right .gb-name { align-self: flex-start; } /* 말풍선은 오른쪽이어도 이름은 왼쪽 */

.gb-name {
  padding: 0 4px;
  font-size: 12.5px;
  color: var(--text-main);
}

.gb-time {
  padding: 0 6px;
  font-size: 10.5px;
  color: #a89888;
}

/* 새로 남긴 메시지 살짝 튀어나오기 */
.gb-msg--new { animation: gb-pop 0.5s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes gb-pop {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.gb-more {
  display: block;
  width: 100%;
  margin-top: 22px;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background-color: #ffffff;
  font-family: 'Cafe24Dongdong', sans-serif;
  font-size: 13.5px;
  color: var(--primary-color);
  cursor: pointer;
}
.gb-more[hidden] { display: none; }

/* ───────── 말풍선 ─────────
   이미지 크기는 --ar(가로/세로 비율)로 잡고, 글자 칸은 이미지 대비 % (--bl/--bt/--bw/--bh)로 얹는다. */
.gb-bubble {
  position: relative;
  width: var(--gb-bw);
  aspect-ratio: var(--ar, 3);
}
.gb-bubble > img {
  display: block;
  width: 100%;
  height: 100%;
}

.gb-text {
  position: absolute;
  left: var(--bl);
  top: var(--bt);
  width: var(--bw);
  height: var(--bh);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.25;
  font-weight: 500;
  color: #5a3a28;
  text-align: center;
}
.gb-text-inner {
  display: block;
  width: 100%;
  white-space: pre-line;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.gb-text.is-placeholder { color: #b9a999; }

/* =========================================================
   방명록 — 작성 창(바텀시트)
   ========================================================= */
html.gb-lock,
html.gb-lock body { overflow: hidden; }

.gb-sheet {
  position: fixed;
  inset: 0;
  z-index: 9500; /* 지퍼 스크롤바(8000) 위, 갤러리 뷰어(10000) 아래 */
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s ease, visibility 0.2s;
}
.gb-sheet.open { visibility: visible; opacity: 1; }

.gb-sheet-dim {
  position: absolute;
  inset: 0;
  background: rgba(40, 26, 18, 0.55);
}

.gb-sheet-panel {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 100%;
  max-width: 430px;
  max-height: 92vh;
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  border-radius: 20px 20px 0 0;
  background-color: var(--bg-color);
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.18);
  outline: none;
  transform: translate(-50%, 100%);
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
.gb-sheet.open .gb-sheet-panel { transform: translate(-50%, 0); }

/* 전체 메시지 보기 팝업은 높게 */
.gb-sheet-panel--tall {
  height: 88vh;
  height: 88dvh;
}

.gb-sheet-head {
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px 12px;
  font-size: 16px;
  color: var(--primary-color);
}
.gb-sheet-head strong { font-weight: 700; }

/* 내용만 스크롤 (제목/닫기 버튼은 위에 고정) */
.gb-sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 20px calc(env(safe-area-inset-bottom, 0px) + 22px);
}
.gb-all-list { padding-top: 6px; }

.gb-x {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: rgba(138, 101, 82, 0.1);
  font-size: 14px;
  color: var(--primary-color);
  cursor: pointer;
}

/* 말풍선 친구 고르기 (2 x 2) */
.gb-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}
.gb-pick { position: relative; }
.gb-pick input { position: absolute; opacity: 0; pointer-events: none; }
.gb-pick-card {
  display: block;
  padding: 6px 6px 5px;
  border: 2px solid transparent;
  border-radius: 12px;
  background-color: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.gb-pick-card img { display: block; width: 100%; }
.gb-pick-card em {
  display: block;
  margin-top: 1px;
  font-size: 12px;
  font-style: normal;
  color: var(--text-sub);
}
.gb-pick input:checked + .gb-pick-card { border-color: var(--primary-color); background-color: #fffaf3; }
.gb-pick input:checked + .gb-pick-card em { font-weight: 600; color: var(--primary-color); }
.gb-pick input:focus-visible + .gb-pick-card { outline: 2px solid var(--primary-color); outline-offset: 2px; }

.gb-preview {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
  padding: 14px 0 10px;
  border-radius: 12px;
  background-color: rgba(138, 101, 82, 0.06);
}

.gb-sheet .btn-primary { margin-top: 2px; }
.gb-sheet .btn-primary:disabled { opacity: 0.6; cursor: default; }

/* 토스트 */
.gb-toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 28px);
  z-index: 9600;
  padding: 11px 18px;
  border-radius: 99px;
  background: rgba(61, 49, 42, 0.92);
  font-size: 13.5px;
  color: #ffffff;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.gb-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* =========================================================
   전세버스
   ========================================================= */
.bus-info {
  margin-bottom: 14px;
  padding: 14px 16px;
  border-radius: 8px;
  background-color: rgba(138, 101, 82, 0.07);
  text-align: left;
  list-style: none;
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--text-main);
}

.gb-field[hidden] { display: none; }

.gb-stepper {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 22px;
}
.gb-stepper button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  background-color: #ffffff;
  font-size: 18px;
  line-height: 1;
  color: var(--primary-color);
  cursor: pointer;
}
.gb-stepper button:active { background-color: var(--bg-color); }
.gb-stepper output {
  min-width: 36px;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-main);
  text-align: center;
}

.bus-done { padding: 18px 0 8px; text-align: center; }
.bus-done[hidden] { display: none; }
.bus-done-icon { margin-bottom: 10px; font-size: 34px; }
.bus-done p { font-size: 14.5px; line-height: 1.8; color: var(--text-main); }
.bus-done-actions { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 18px; }
.bus-done-actions .btn-primary { width: auto; padding: 10px 26px; margin: 0; font-size: 13.5px; }
.bus-redo {
  padding: 10px 16px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: #ffffff;
  font-family: 'Cafe24Dongdong', sans-serif;
  font-size: 12.5px;
  color: var(--text-sub);
  cursor: pointer;
}

.guestbook-section {
  font-family: 'Cafe24Dongdong', sans-serif;
}

.guestbook-section .main-title {
  font-family: 'Cafe24Dongdong', sans-serif;
}

.gb-sheet:has(.gb-write),
.gb-sheet:has(.gb-write) button,
.gb-sheet:has(.gb-all-list),
.gb-sheet:has(.gb-all-list) button {
  font-family: 'Cafe24Dongdong', sans-serif;
}
