/* 증빙 크게 보기(receipt-viewer.js)와 한 지출에 붙은 증빙 목록. 값은 tokens.css, 움직임은 motion.css 의 결을 따른다. */

.receipt-viewer {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgb(12 16 28 / 92%);
  color: #fff;
  overflow: hidden;
}

.receipt-viewer[open] {
  display: grid;
  grid-template-rows: auto 1fr;
  animation: rv-in var(--motion-ui) both;
}

.receipt-viewer::backdrop {
  background: rgb(12 16 28 / 60%);
}

@keyframes rv-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.rv-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: rgb(12 16 28 / 70%);
}

.rv-title {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  min-width: 0;
  margin: 0;
}

.rv-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rv-title span {
  flex: 0 0 auto;
  color: rgb(255 255 255 / 72%);
  font-variant-numeric: tabular-nums;
}

.rv-tools {
  display: flex;
  flex: 0 0 auto;
  gap: var(--space-2);
}

.rv-button {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 var(--space-3);
  border: 1px solid rgb(255 255 255 / 28%);
  border-radius: var(--r-control);
  background: rgb(255 255 255 / 8%);
  color: #fff;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.rv-button:hover {
  background: rgb(255 255 255 / 16%);
}

.rv-stage {
  display: grid;
  place-items: center;
  min-height: 0;
  padding: var(--space-4) 72px;
  overflow: auto;
}

.rv-stage > img,
.rv-pages img {
  display: block;
  max-width: 100%;
  max-height: calc(100dvh - 96px);
  object-fit: contain;
  background: #fff;
  border-radius: 4px;
  cursor: zoom-in;
  animation: enter-up var(--motion-enter) both;
}

.rv-pages {
  display: grid;
  justify-items: center;
  gap: var(--space-4);
  width: 100%;
}

.rv-pages img {
  max-height: none;
  max-width: min(100%, 900px);
}

/* 원래 크기 — 그림의 실제 픽셀대로 두고 무대를 스크롤한다. 작은 글씨를 읽으려고 누르는 단추다. */
.receipt-viewer.is-actual .rv-stage {
  place-items: start center;
}

.receipt-viewer.is-actual .rv-stage > img,
.receipt-viewer.is-actual .rv-pages img {
  max-width: none;
  max-height: none;
  cursor: zoom-out;
}

.rv-note {
  margin: 0;
  color: rgb(255 255 255 / 80%);
}

.rv-nav {
  position: fixed;
  top: 50%;
  translate: 0 -50%;
  width: 48px;
  height: 64px;
  border: 0;
  border-radius: var(--r-control);
  background: rgb(255 255 255 / 14%);
  color: #fff;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
}

.rv-nav:hover {
  background: rgb(255 255 255 / 24%);
}

.rv-prev { left: var(--space-3); }
.rv-next { right: var(--space-3); }

@media (max-width: 760px) {
  .rv-bar {
    flex-wrap: wrap;
    padding: var(--space-2) var(--space-4);
  }

  .rv-title {
    flex: 1 1 100%;
  }

  .rv-tools {
    flex: 1 1 100%;
  }

  .rv-close {
    margin-left: auto;
  }

  /* 폰에서는 넘기기 단추를 아래로 내린다 — 그림 양옆에 두면 영수증 폭을 먹는다. */
  .rv-stage {
    padding: var(--space-3) var(--space-3) 88px;
  }

  .rv-nav {
    top: auto;
    bottom: var(--space-4);
    translate: none;
    width: 64px;
    height: 52px;
  }

  .rv-prev { left: var(--space-4); }
  .rv-next { right: var(--space-4); }
}

@media (prefers-reduced-motion: reduce) {
  .receipt-viewer[open],
  .rv-stage > img,
  .rv-pages img {
    animation: none;
  }
}

/* ---------- 한 지출에 붙은 증빙 목록(간략보기 · 등록 창) ---------- */

.receipt-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.receipt-tile {
  position: relative;
  display: grid;
  grid-template-rows: 88px auto;
  min-width: 0;
  border: 1px solid var(--c-line);
  border-radius: var(--r-control);
  background: var(--c-ground);
  overflow: hidden;
}

.receipt-tile-open {
  display: grid;
  grid-template-rows: subgrid;
  grid-row: span 2;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: zoom-in;
}

.receipt-tile-open:disabled {
  cursor: default;
}

.receipt-tile-thumb {
  display: grid;
  place-items: center;
  height: 88px;
  background: var(--c-sunken);
  color: var(--c-muted);
  font-size: var(--t-aux);
  font-weight: 700;
  overflow: hidden;
}

.receipt-tile-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}

.receipt-tile-name {
  padding: 4px 6px;
  overflow: hidden;
  color: var(--c-ink);
  font-size: var(--t-aux);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.receipt-tile.is-new .receipt-tile-name::before {
  content: "새 ";
  color: var(--c-action);
  font-weight: 700;
}

/* 서류 등록으로 붙인 것(10월 22일 피드백) — 영수증과 구분해 이름 앞에 작은 표시. */
.receipt-tile-kind {
  margin-right: 4px;
  border-radius: var(--r-pill);
  background: var(--c-sunken);
  padding: 0 6px;
  color: var(--c-ink);
  font-weight: 700;
}

.receipt-tile-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--c-line);
  border-radius: var(--r-pill);
  background: rgb(255 255 255 / 94%);
  color: var(--c-seal);
  font: inherit;
  font-size: var(--t-aux);
  font-weight: 700;
  cursor: pointer;
}

.receipt-attachments {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.receipt-attachments[hidden] {
  display: none;
}

.receipt-attachments-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  font-weight: 700;
}

.receipt-attachments-head small {
  color: var(--c-muted);
  font-weight: 400;
}

.receipt-upload-section .receipt-attachments {
  grid-column: 1 / -1;
}

.receipt-preview img.is-zoomable,
.ld-receipt-open {
  cursor: zoom-in;
}

.ld-receipt .receipt-tiles {
  margin-top: 6px;
}

/* 간략보기의 그림 한 장이 서류 등록으로 붙인 것이면 왼쪽 위에 '서류' 표시를 얹는다(10월 22일 기준 대조). */
.ld-receipt-open {
  position: relative;
}

.ld-receipt-open .receipt-tile-kind {
  position: absolute;
  top: 8px;
  left: 8px;
}
