/*
 * 공간 상세 — places/show 전용.
 *
 * 이 파일은 stylesheet_link_tag :app 이 모든 화면에 함께 싣습니다. 그래서 모든
 * 규칙이 .place-detail 안에서만 성립하도록 이름을 짓고, body 를 건드리는 규칙은
 * :has(.place-detail) 로 잠급니다. 값은 전부 tokens.css 를 씁니다.
 *
 * 색 주의: --pink/--accent/--rose-* 는 연한 와인(#b08a91)이라 글자·아이콘에 쓰면
 * 대비가 모자랍니다. 텍스트로 쓰는 와인은 --brand-pink-strong(#6d4a51) 입니다.
 */

/* ── 페이지 셸 ─────────────────────────────────────── */

/* application.css 의 html, body { height: 100% } 는 스크롤 페이지에서 방해가 됩니다. */
html body:has(.place-detail) {
  height: auto;
  min-height: 100%;
}

/* 액션바 높이는 body 에 둡니다. 커스텀 속성은 아래로만 흐르므로, 자식(.place-detail)에
   선언하면 body 의 padding-bottom 이 이 값을 읽지 못합니다. */
body:has(.place-detail) {
  --place-actions-height: 58px;

  padding-bottom: calc(var(--place-actions-height) + env(safe-area-inset-bottom, 0px));
  background: var(--surface-page);
}

.place-detail {
  --place-gutter: 20px;
  --place-column: 680px;

  position: relative;
  max-width: var(--place-column);
  margin: 0 auto;
  padding-bottom: var(--space-8);
  background: linear-gradient(180deg, var(--gray-50), var(--gray-100));
}

/* ── 헤더 52px ─────────────────────────────────────── */

.place-detail__bar {
  position: sticky;
  z-index: var(--z-sticky);
  top: 0;
  display: grid;
  height: 52px;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  padding: 0 var(--space-2);
  border-bottom: 1px solid var(--border-default);
  background: var(--surface-veil);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 2px 14px rgb(28 26 23 / 5%);
}

.place-detail__back {
  display: grid;
  width: 44px;
  height: 44px;
  color: var(--gray-900);
  place-items: center;
}

.place-detail__bar-title {
  color: var(--gray-900);
  font-size: var(--text-sm);
  font-weight: var(--weight-strong);
  text-align: center;
}

/* ── 대표 사진 16:11 ───────────────────────────────── */

.place-detail__hero {
  overflow: hidden;
  margin: 0;
  aspect-ratio: 16 / 11;
  background: var(--gray-200);
}

.place-detail__hero-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── 제목 · 소개문 ─────────────────────────────────── */

.place-detail__head {
  padding: var(--space-5) var(--place-gutter) 0;
}

.place-detail__headline {
  display: flex;
  gap: var(--space-3);
  align-items: baseline;
  justify-content: space-between;
}

.place-detail__name {
  margin: 0;
  color: var(--gray-900);
  font-family: var(--font-serif);
  font-size: 23px;
  font-weight: var(--weight-strong);
  line-height: 1.35;
  letter-spacing: -0.015em;
  word-break: keep-all;
}

.place-detail__category {
  display: inline-flex;
  flex: none;
  gap: var(--space-1);
  align-items: center;
  margin: 0;
  color: var(--gray-500);
  font-size: var(--text-2xs);
  font-weight: var(--weight-strong);
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.place-detail__lead {
  margin: var(--space-3) 0 0;
  color: var(--gray-600);
  font-size: var(--text-sm);
  line-height: 1.9;
  word-break: keep-all;
  white-space: pre-line;
}

/* ── 기본 정보 카드 ────────────────────────────────── */

.place-facts {
  display: grid;
  gap: var(--space-2);
  margin: var(--space-6) var(--place-gutter) 0;
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-4);
  background: var(--surface-card);
  box-shadow: var(--shadow-card);
}

.place-facts__row {
  display: flex;
  gap: 14px;
}

.place-facts__label {
  flex: none;
  width: 48px;
  color: var(--gray-500);
  font-size: var(--text-2xs);
  font-weight: var(--weight-strong);
  line-height: 1.7;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.place-facts__value {
  margin: 0;
  color: var(--gray-600);
  font-size: var(--text-xs);
  line-height: 1.7;
  word-break: keep-all;
}

.place-facts__lines {
  color: var(--gray-500);
}

/* ── 섹션 공통 ─────────────────────────────────────── */

.place-detail__section {
  padding: var(--space-7) var(--place-gutter) 0;
}

.place-detail__section-head {
  display: flex;
  gap: var(--space-3);
  align-items: baseline;
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--gray-900);
}

.place-detail__section-title {
  margin: 0;
  color: var(--gray-900);
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: var(--weight-strong);
  letter-spacing: -0.01em;
}

.place-detail__section-count {
  color: var(--gray-500);
  font-size: var(--text-2xs);
  font-variant-numeric: tabular-nums;
}

.place-detail__section-link {
  margin-left: auto;
  color: var(--gray-500);
  font-size: var(--text-2xs);
  font-weight: var(--weight-strong);
  text-decoration: none;
}

.place-detail__section-link:hover {
  color: var(--gray-900);
}

/* ── 설레인의 기록 ─────────────────────────────────── */

.place-record {
  display: block;
  margin-top: 14px;
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-4);
  color: inherit;
  text-decoration: none;
  background: var(--surface-card);
  box-shadow: var(--shadow-card);
}

.place-record__quote {
  display: block;
  color: var(--gray-900);
  font-family: var(--font-serif);
  font-size: var(--text-md);
  font-weight: var(--weight-strong);
  line-height: 1.6;
  word-break: keep-all;
}

.place-record__quote::before { content: "\201C"; }
.place-record__quote::after { content: "\201D"; }

.place-record__meta {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  margin-top: var(--space-3);
  color: var(--gray-500);
  font-size: var(--text-2xs);
  font-variant-numeric: tabular-nums;
}

.place-record__likes {
  display: inline-flex;
  gap: var(--space-1);
  align-items: center;
}

.place-record__date {
  margin-left: auto;
}

/* ── 근처 공간 · 이 근처에서 해볼 것 (같은 행 컴포넌트) ─ */

.place-neighbor {
  display: grid;
  gap: 14px;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-default);
  color: inherit;
  text-decoration: none;
}

.place-neighbor:last-child {
  border-bottom: 0;
}

.place-neighbor__thumb {
  display: block;
  overflow: hidden;
  aspect-ratio: 1;
  border-radius: var(--radius-3);
  background: var(--gray-200);
}

.place-neighbor__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.place-neighbor__body {
  min-width: 0;
}

.place-neighbor__name {
  display: block;
  overflow: hidden;
  color: var(--gray-900);
  font-size: var(--text-sm);
  font-weight: var(--weight-strong);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.place-neighbor__meta {
  display: block;
  margin-top: 2px;
  color: var(--gray-500);
  font-size: var(--text-2xs);
  font-style: normal;
}

.place-neighbor__arrow {
  display: grid;
  color: var(--gray-400);
  place-items: center;
}

.place-neighbor:hover .place-neighbor__name {
  color: var(--brand-pink-strong);
}

/* ── 기록 더 보기 ──────────────────────────────────
   장수가 2~3장인 경우가 많아 격자로 깔면 빈 칸이 남습니다. 가로 스트립은 몇 장이든
   왼쪽부터 채워지고, 많아지면 그대로 밀립니다. (스크롤바는 감춥니다) */

.place-shots {
  display: flex;
  overflow-x: auto;
  gap: var(--space-2);
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}

.place-shots::-webkit-scrollbar {
  display: none;
}

.place-shot {
  display: block;
  overflow: hidden;
  width: 124px;
  flex: none;
  aspect-ratio: 1;
  border-radius: var(--radius-3);
  background: var(--gray-200);
  scroll-snap-align: start;
}

.place-shot img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity var(--duration-fast) var(--ease-standard);
}

.place-shot:hover img {
  opacity: 0.86;
}

/* ── 혜택 ──────────────────────────────────────────
   .perk / .perk--used 는 perk_controller.js 가 붙이는 이름입니다. 바꾸려면 JS 도 함께. */

.perk {
  margin-top: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-4);
  background: var(--surface-card);
  box-shadow: var(--shadow-card);
}

.perk__top {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.perk__kind,
.perk__sample {
  display: inline-flex;
  height: 20px;
  align-items: center;
  padding: 0 var(--space-2);
  border: 1px solid var(--brand-pink-tint);
  border-radius: var(--radius-full);
  color: var(--brand-pink-strong);
  font-size: 9px;
  font-weight: var(--weight-strong);
  letter-spacing: 0.06em;
}

.perk__sample {
  border-color: var(--border-default);
  color: var(--gray-500);
}

.perk__title {
  margin: var(--space-3) 0 0;
  color: var(--gray-900);
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: var(--weight-strong);
  line-height: 1.6;
  word-break: keep-all;
}

.perk__meta {
  display: grid;
  gap: var(--space-2);
  margin: var(--space-3) 0 0;
}

.perk__meta div {
  display: flex;
  gap: 14px;
}

.perk__meta dt {
  flex: none;
  width: 48px;
  color: var(--gray-500);
  font-size: var(--text-2xs);
  font-weight: var(--weight-strong);
  line-height: 1.7;
  letter-spacing: 0.02em;
}

.perk__meta dd {
  margin: 0;
  color: var(--gray-600);
  font-size: var(--text-xs);
  line-height: 1.7;
  word-break: keep-all;
}

.perk__button {
  /* 모양은 .ds-btn.ds-btn--primary.ds-btn--block 이 갖습니다. */
  margin-top: var(--space-4);
}

.perk__button:disabled {
  cursor: default;
}

/* 사용 완료 — 매장에 보여주는 상태라 눈에 띄되 요란하지 않게. */
.perk--used {
  border-color: var(--brand-pink-strong);
}

.perk--used .perk__button {
  color: var(--brand-pink-strong);
  background: var(--brand-pink-tint);
}

.perk__status {
  margin: var(--space-2) 0 0;
  min-height: 16px;
  color: var(--gray-500);
  font-size: var(--text-2xs);
  text-align: center;
}

/* ── 하단 고정 액션바 ──────────────────────────────── */

.place-detail__actions {
  position: fixed;
  z-index: var(--z-header);
  bottom: 0;
  left: 50%;
  display: grid;
  width: min(var(--place-column, 680px), 100%);
  grid-template-columns: repeat(3, 1fr);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-veil);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 -6px 20px rgb(28 26 23 / 7%);
  transform: translateX(-50%);
}

/* button_to 가 감싸는 form 이 칸 하나를 그대로 채우게 합니다. */
.place-detail__action-cell {
  display: grid;
}

.place-detail__action {
  display: grid;
  height: 58px;
  gap: 2px;
  align-content: center;
  justify-items: center;
  padding: 0;
  border: 0;
  color: var(--gray-600);
  font-family: inherit;
  text-decoration: none;
  background: none;
  cursor: pointer;
}

.place-detail__action-icon {
  display: grid;
  place-items: center;
}

.place-detail__action-label {
  font-size: 10px;
  font-weight: 500;
}

.place-detail__action:hover {
  color: var(--gray-900);
}

.place-detail__action.is-saved,
.place-detail__action.is-saved:hover {
  color: var(--brand-pink-strong);
}

.place-detail__action.is-saved .place-detail__action-label {
  font-weight: var(--weight-strong);
}

/* 다녀온 곳은 먹색으로 가라앉힙니다. 와인은 아직 안 가 본 곳 하나에만 씁니다. */
.place-detail__action.is-saved.is-visited,
.place-detail__action.is-saved.is-visited:hover {
  color: var(--gray-900);
}

/* 하트는 선 아이콘이라 저장된 상태에서만 속을 채웁니다. */
.place-detail__action.is-saved svg {
  fill: currentColor;
}

/* ── 저장 상태 시트 ─────────────────────────────────
   길찾기 시트와 같은 껍데기(.place-sheet)를 쓰고, 안쪽 선택지만 따로 그립니다. */

.favorite-choice__cell {
  display: block;
}

.favorite-choice {
  display: flex;
  width: 100%;
  min-height: 52px;
  gap: var(--space-3);
  align-items: center;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--border-default);
  color: var(--gray-900);
  font-family: inherit;
  font-size: var(--text-md);
  font-weight: var(--weight-strong);
  text-align: left;
  background: none;
  cursor: pointer;
}

.favorite-choice__dot {
  width: 10px;
  height: 10px;
  flex: none;
  border-radius: var(--radius-full);
}

.favorite-choice.is-wish .favorite-choice__dot {
  background: var(--brand-pink-strong);
}

.favorite-choice.is-visited .favorite-choice__dot {
  background: var(--ink-gradient);
}

.favorite-choice__label {
  min-width: 0;
}

.favorite-choice__current {
  margin-left: auto;
  color: var(--gray-500);
  font-size: var(--text-2xs);
  font-weight: var(--weight-regular);
  letter-spacing: var(--tracking-body);
}

.favorite-choice:hover .favorite-choice__label {
  color: var(--brand-pink-strong);
}

.favorite-choice--remove {
  min-height: 48px;
  border-bottom: 0;
  color: var(--gray-500);
  font-size: var(--text-sm);
  font-weight: var(--weight-regular);
}

.favorite-choice--remove:hover {
  color: var(--danger);
}

/* ── 길찾기 바텀 시트 ──────────────────────────────── */

/* 공용 탭바가 아직 z-index 2000 리터럴을 쓰고 있어(tokens.css 13장의 이관 목록),
   시트는 그 위로 올라와야 배경 딤이 탭바를 덮습니다. */
.place-sheet {
  position: fixed;
  z-index: 3000;
  inset: 0;
}

.place-sheet[hidden] {
  display: none;
}

.place-sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgb(28 26 23 / 40%);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.place-sheet__panel {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: min(420px, 100%);
  padding: var(--space-2) var(--space-5) calc(var(--space-5) + env(safe-area-inset-bottom, 0px));

  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  background: var(--surface-page);
  box-shadow: 0 -20px 50px rgb(28 26 23 / 30%);
  transform: translateX(-50%);
}

@media (prefers-reduced-motion: no-preference) {
  .place-sheet__panel {
    animation: place-sheet-rise var(--duration-base) var(--ease-standard);
  }
}

@keyframes place-sheet-rise {
  from { transform: translate(-50%, 100%); }
  to { transform: translate(-50%, 0); }
}

.place-sheet__handle {
  display: block;
  width: 36px;
  height: 4px;
  margin: var(--space-2) auto var(--space-1);
  border-radius: var(--radius-full);
  background: var(--border-strong);
}

.place-sheet__head {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-default);
}

.place-sheet__title {
  margin: 0;
  color: var(--gray-900);
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: var(--weight-strong);
}

.place-sheet__close {
  display: grid;
  width: 32px;
  height: 32px;
  margin-left: auto;
  border: 0;
  border-radius: var(--radius-full);
  color: var(--gray-900);
  background: var(--surface-sunken);
  cursor: pointer;
  place-items: center;
}

.place-sheet__link {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-default);
  color: var(--gray-900);
  font-size: var(--text-sm);
  font-weight: var(--weight-strong);
  text-decoration: none;
}

.place-sheet__link:hover {
  color: var(--brand-pink-strong);
}

.place-sheet__link svg {
  color: var(--gray-400);
}

.place-sheet__note {
  margin: var(--space-3) 0 0;
  color: var(--gray-500);
  font-size: var(--text-2xs);
  line-height: 1.7;
  word-break: keep-all;
}

.place-sheet__note strong {
  color: var(--gray-600);
  font-weight: var(--weight-strong);
}

/* ── 토스트 ────────────────────────────────────────── */

/* 모양은 .ds-toast 가 갖습니다. 여기서는 감추는 규칙만 더합니다. */
.place-detail__toast {
  margin: 0;
}

.place-detail__toast[hidden] {
  display: none;
}

/* ── 접근성 ────────────────────────────────────────── */

.place-detail a:focus-visible,
.place-detail button:focus-visible {
  border-radius: var(--radius-2);
  outline: 2px solid var(--brand-pink-strong);
  outline-offset: 2px;
}

/* ── 모바일: 공용 탭바 위에 액션바를 얹습니다 ──────── */

@media (width <= 700px) {
  body.has-bottom-nav:has(.place-detail) {
    padding-bottom: calc(var(--place-actions-height, 58px) + var(--bottom-nav-total));
  }

  body.has-bottom-nav .place-detail__actions {
    bottom: var(--bottom-nav-total);
    padding-bottom: 0;
  }

  /* 탭바가 이미 화면 아래를 덮으므로 토스트만 한 칸 더 올립니다. */
  .place-detail__toast {
    bottom: calc(var(--bottom-nav-total) + var(--place-actions-height, 58px) + var(--space-3));
  }
}

/* ── 데스크톱: 넉넉한 단일 칼럼 ────────────────────── */

@media (width > 700px) {
  .place-detail {
    --place-gutter: 32px;

    margin-block: var(--space-6);
    border-radius: var(--radius-4);
    box-shadow: 0 0 0 1px var(--border-subtle), var(--shadow-lg);
  }

  .place-detail__bar {
    border-radius: var(--radius-4) var(--radius-4) 0 0;
  }

  .place-detail__name {
    font-size: var(--text-2xl);
  }

  .place-detail__lead {
    font-size: var(--text-md);
  }

  .place-detail__actions {
    border-radius: var(--radius-4) var(--radius-4) 0 0;
  }

  .place-detail__toast {
    bottom: calc(var(--place-actions-height, 58px) + var(--space-3));
  }
}

@media (prefers-reduced-motion: reduce) {
  .place-shot img {
    transition: none;
  }
}
