/*
  한 달 요금제 신청 화면(pay/index.html) 전용.
  랜딩의 토큰과 클래스(.section-title, .section-lead, .record, .btn, .text-link, .action-row, .biz-info, 머리말·꼬리말)를 그대로 쓰고,
  여기에는 랜딩에 없는 것(입력칸, 요금제 고르기, 동의 체크, 입금 안내, 내 요금제·계약 내용, 해지·환불, 시트, 토스트)만 둔다.
  - 휴대폰 390px 기준 한 줄 칸. 넓은 화면에서도 같은 칸을 가운데에 좁게 둔다.
  - 형광펜 노랑(--memory-mark)은 '기억' 전용색이라 쓰지 않는다. 강조는 먹색 굵은 테두리와 글 크기로 한다.
  - 손님이 적는 이름처럼 미리 알 수 없는 글자는 부분 글꼴(fonts.css)에 없을 수 있어서, 한 단어 안에서 글꼴이 갈라지지 않게 시스템 글꼴로 그린다(.pay-sysfont).
*/

/* 이 화면에만 필요한 토큰 (base → semantic) */
:root {
  --red-700: #B42318;

  --text-danger: var(--red-700);
  --line-danger: var(--red-700);
  --font-system: -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --pay-measure: 28rem;
  --r-check: calc(var(--r-action) / 3);
}

/* 화면 단계 전환은 hidden 속성으로 한다. 아래 클래스들의 display보다 항상 이긴다 */
[hidden] {
  display: none !important;
}

.pay-sysfont {
  font-family: var(--font-system);
}

/* 레이아웃: 내용이 짧은 단계(오류·링크)에서도 꼬리말이 화면 바닥에 붙게 본문을 늘린다 */
.pay-page {
  display: flex;
  flex-direction: column;
}

.pay-main {
  flex: 1 0 auto;
}

.pay-wrap {
  width: 100%;
  max-width: calc(var(--pay-measure) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.pay-main {
  padding-top: var(--s-5);
}

/* 머리말·꼬리말 브랜드 표시: 브랜드 칸의 mark 그림을 pay-brand.js가 넣는다(없으면 이 칸을 숨기고 이름만 보인다) */
.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
}

.pay-demo {
  padding: var(--s-2) var(--gutter);
  background: var(--bg-sunken);
  color: var(--text-secondary);
  font-size: var(--t-meta-size);
  line-height: var(--t-meta-lh);
  font-weight: var(--weight-semibold);
  text-align: center;
}

/* 단계 칸은 세로 flex다. 랜딩의 .record는 넓은 화면에서 grid-column(운영사 칸 배치용)을 갖고 있어 grid 안에 두면 칸이 쪼개진다 */
.pay-view {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

.pay-view > .pay-linkbtn {
  align-self: flex-start;
}

/* 단계가 바뀌면 제목으로 읽기 위치를 옮긴다. 그 포커스에는 테두리를 그리지 않는다 */
.pay-view [tabindex="-1"]:focus,
.pay-sheet [tabindex="-1"]:focus {
  outline: none;
}

.pay-view--loading {
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  min-height: 40dvh;
  text-align: center;
}

.pay-spinner {
  width: 2rem;
  height: 2rem;
  border: 3px solid var(--line);
  border-top-color: var(--text-primary);
  border-radius: 50%;
  animation: pay-spin 0.8s linear infinite;
}

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

.pay-note {
  color: var(--text-secondary);
  font-size: var(--t-small-size);
  line-height: var(--t-small-lh);
}

.pay-meta,
.pay-help {
  color: var(--text-meta);
  font-size: var(--t-small-size);
  line-height: var(--t-small-lh);
}

.pay-meta {
  font-size: var(--t-meta-size);
  line-height: var(--t-meta-lh);
}

.pay-actions {
  margin-top: var(--s-2);
}

.pay-btn-block {
  width: 100%;
}

/* '지금 전화하기' 옆 번호. 좁은 폰에서 넘치면 번호만 다음 줄로 */
.pay-btn-block:has(.pay-btn-tel) {
  flex-wrap: wrap;
  column-gap: 0.4em;
  white-space: normal;
}

.pay-btn-tel {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.btn:disabled {
  background: var(--cta-bg-hover);
  cursor: progress;
}

/* 버튼으로 쓰는 밑줄 링크(.text-link) */
.pay-linkbtn {
  padding: 0;
  border: 0;
  background: none;
  font-size: var(--t-small-size);
  line-height: var(--t-small-lh);
  text-align: left;
  cursor: pointer;
}

.pay-inline-link {
  /* 문장 속 링크라 줄 높이는 그대로 두고, 누르는 영역만 위아래로 넓힌다(랜딩 .care-note a와 같다) */
  padding-block: 0.75em;
  color: var(--text-primary);
  font-weight: var(--weight-semibold);
  text-decoration-thickness: 2px;
}

/* 연회색 시트(랜딩의 시트와 같은 면·모서리) */
.pay-sheetcard {
  padding: var(--s-5);
  border-radius: var(--r-sheet);
  background: var(--bg-sheet);
}

/* 신청서 */
.pay-form {
  display: grid;
  gap: var(--s-6);
  margin-top: var(--s-4);
}

.pay-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.pay-label {
  display: block;
  margin-bottom: var(--s-2);
  padding: 0;
  color: var(--text-primary);
  font-size: var(--t-small-size);
  line-height: var(--t-small-lh);
  font-weight: var(--weight-semibold);
}

.pay-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-2);
}

.pay-label-row .pay-label {
  margin-bottom: 0;
}

.pay-help {
  margin-top: var(--s-2);
}

/* 오류: 색만으로 알리지 않게 느낌표 표시와 글을 같이 둔다. 비어 있으면 자리를 차지하지 않는다(aria-live 영역은 그대로 둔다) */
.pay-error {
  color: var(--text-danger);
  font-size: var(--t-small-size);
  line-height: var(--t-small-lh);
  font-weight: var(--weight-semibold);
}

.pay-error:not(:empty) {
  display: flex;
  align-items: flex-start;
  gap: var(--s-2);
  margin-top: var(--s-2);
  text-align: left;
}

.pay-error:not(:empty)::before {
  content: "!";
  flex: none;
  display: grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  margin-top: 0.1rem;
  border-radius: 50%;
  background: var(--text-danger);
  color: var(--text-on-ink);
  font-size: var(--t-meta-size);
  font-weight: var(--weight-bold);
}

/* 요금제를 쓸 번호: 고칠 수 없는 칸(자물쇠) */
.pay-phone {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: var(--cta-height);
  padding-inline: var(--s-4);
  border-radius: var(--r-action);
  background: var(--bg-sheet);
  font-size: var(--t-lead-size);
  line-height: var(--t-lead-lh);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
}

.pay-lock {
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  color: var(--text-meta);
}

/* 요금제 고르기: 흰 칸 + 테두리, 고르면 먹색 테두리(랜딩 입금 그림의 이름 칸과 같은 모양) */
.pay-products {
  display: grid;
  gap: var(--s-2);
}

.pay-product {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: var(--s-3);
  min-height: 4.25rem;
  padding: var(--s-3) var(--s-4);
  border: 2px solid var(--line);
  border-radius: var(--r-action);
  background: var(--bg-page);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color var(--dur-fast) var(--ease-out);
}

.pay-product:hover {
  border-color: var(--text-meta);
}

.pay-product:has(input:checked) {
  border-color: var(--line-strong);
}

.pay-product:has(input:focus-visible) {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

.pay-radio {
  -webkit-appearance: none;
  appearance: none;
  display: grid;
  place-content: center;
  width: 1.375rem;
  height: 1.375rem;
  margin: 0;
  border: 2px solid var(--text-meta);
  border-radius: 50%;
  background: var(--bg-page);
}

.pay-radio::before {
  content: "";
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
  background: var(--text-primary);
  transform: scale(0);
  transition: transform var(--dur-fast) var(--ease-out);
}

.pay-radio:checked {
  border-color: var(--text-primary);
}

.pay-radio:checked::before {
  transform: scale(1);
}

.pay-radio:focus-visible {
  outline: none;
}

.pay-product-text {
  display: grid;
  min-width: 0;
}

.pay-product-name {
  font-weight: var(--weight-semibold);
}

.pay-product-sub {
  color: var(--text-meta);
  font-size: var(--t-meta-size);
  line-height: var(--t-meta-lh);
}

.pay-product-sub strong {
  color: var(--text-primary);
  font-weight: var(--weight-bold);
}

.pay-product-price {
  font-size: var(--t-lead-size);
  line-height: var(--t-lead-lh);
  font-weight: var(--weight-bold);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* 입금자명 칸: 글자 16px 이상(iOS 확대 방지). maxLength는 두지 않는다(5자 경계에서 마지막 모음이 잘린다) */
.pay-input {
  display: block;
  width: 100%;
  min-height: var(--cta-height);
  margin: 0;
  padding: 0 var(--s-4);
  border: 1px solid var(--text-meta);
  border-radius: var(--r-action);
  background: var(--bg-page);
  color: var(--text-primary);
  font-size: var(--t-lead-size);
  line-height: var(--t-lead-lh);
  font-weight: var(--weight-semibold);
  -webkit-appearance: none;
  appearance: none;
}

.pay-input::placeholder {
  color: var(--text-meta);
  font-weight: var(--weight-regular);
  opacity: 1;
}

.pay-input:focus {
  outline: none;
  border-color: var(--line-strong);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.pay-input[aria-invalid="true"] {
  border-color: var(--line-danger);
  box-shadow: inset 0 0 0 1px var(--line-danger);
}

.pay-prev {
  margin: calc(var(--s-2) * -1) 0 var(--s-1);
}

/* 결제 전 고지: 한 번 체크로 동의 */
.pay-agree {
  display: grid;
  justify-items: start;
  gap: var(--s-2);
  padding-block: var(--s-3) var(--s-4);
}

.pay-check {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 3rem;
  font-weight: var(--weight-semibold);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.pay-check input {
  -webkit-appearance: none;
  appearance: none;
  display: grid;
  place-content: center;
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  margin: 0;
  border: 2px solid var(--text-meta);
  border-radius: var(--r-check);
  background: var(--bg-page);
}

.pay-check input::after {
  content: "";
  width: 0.375rem;
  height: 0.7rem;
  margin-top: -0.15rem;
  border: solid var(--text-on-ink);
  border-width: 0 0.18rem 0.18rem 0;
  transform: rotate(45deg) scale(0);
  transition: transform var(--dur-fast) var(--ease-out);
}

.pay-check input:checked {
  border-color: var(--text-primary);
  background: var(--text-primary);
}

.pay-check input:checked::after {
  transform: rotate(45deg) scale(1);
}

.pay-check input[aria-invalid="true"] {
  border-color: var(--line-danger);
}

.pay-agree-list {
  display: grid;
  gap: var(--s-1);
  padding-left: 1.25em;
  list-style: disc;
  color: var(--text-secondary);
  font-size: var(--t-small-size);
  line-height: var(--t-small-lh);
}

.pay-agree-links {
  display: flex;
  flex-wrap: wrap;
  column-gap: var(--s-5);
}

.pay-agree .text-link {
  font-size: var(--t-small-size);
  line-height: var(--t-small-lh);
}

.pay-agree .pay-error:not(:empty) {
  margin-top: 0;
}

.pay-submit {
  display: grid;
  justify-items: center;
  gap: var(--s-3);
  text-align: center;
}

.pay-submit .pay-error {
  justify-self: stretch;
}

/* [입금 신청] 바로 위 보장 한 줄(11-08): 동의 상자 속 사실을 첫 화면에 */
.pay-promise {
  color: var(--text-primary);
  font-size: var(--t-small-size);
  line-height: var(--t-small-lh);
  font-weight: var(--weight-semibold);
}

/* 한 장 신청서(10-22): 제목 → 요금제 → 입금자명 → [입금 신청]이 첫 화면에 들어오게 간격을 줄인다 */
.pay-form--one {
  gap: var(--s-5);
  margin-top: 0;
}

.pay-form-head {
  display: grid;
  gap: var(--s-3);
}

.pay-agree-lead {
  color: var(--text-secondary);
  font-size: var(--t-small-size);
  line-height: var(--t-small-lh);
  font-weight: var(--weight-semibold);
}

/* [입금 신청]을 누를 때 계좌번호를 복사해 뒀다는 한 줄 */
.pay-copied {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  color: var(--text-primary);
  font-size: var(--t-small-size);
  line-height: 1.5;
  font-weight: var(--weight-semibold);
}

.pay-copied svg {
  flex: none;
  width: 1.125rem;
  height: 1.125rem;
}

/* 입금 안내 맨 아래에 붙는 줄(10-22): 은행 앱에서 돌아온 손님이 스크롤 없이 상태를 보고 [입금했어요]를 누르게 */
.pay-donebar {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: grid;
  gap: var(--s-2);
  padding: var(--s-3) 0 calc(var(--s-3) + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  background: var(--bg-page);
}

.pay-donebar .pay-status {
  justify-content: center;
  margin-top: 0;
  text-align: center;
}

/* 입금 안내 */
.pay-timer {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  color: var(--text-secondary);
  font-size: var(--t-small-size);
  line-height: var(--t-small-lh);
}

.pay-timer strong {
  color: var(--text-primary);
  font-size: var(--t-h3-size);
  line-height: var(--t-h3-lh);
  font-weight: var(--weight-bold);
  font-variant-numeric: tabular-nums;
}

.pay-account {
  margin-top: var(--s-2);
}

/* 입금 직전 안심 두 줄(자동결제 없음, 해지·환불) */
.pay-assure {
  display: grid;
  gap: var(--s-1);
  margin: var(--s-3) 0 0;
  padding: 0;
  list-style: none;
  color: var(--text-secondary);
  font-size: var(--t-small-size);
  line-height: 1.5;
}

.pay-assure li {
  display: flex;
  gap: var(--s-2);
}

.pay-assure li::before {
  content: '✓';
  flex: none;
  color: var(--text-primary);
  font-weight: var(--weight-bold);
}

.pay-copy-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2) var(--s-3);
}

.pay-amount {
  font-size: var(--t-h2-size);
  line-height: var(--t-h2-lh);
  font-weight: var(--weight-bold);
  letter-spacing: var(--track-display);
}

/* 계좌번호·금액은 한 번 누르면 통째로 골라진다(복사가 막힌 기기에서 길게 눌러 복사) */
.pay-select,
.pay-amount {
  -webkit-user-select: all;
  user-select: all;
}

/* 복사 버튼: 랜딩의 움직임 멈춤 버튼과 같은 테두리 캡슐 */
.pay-copy {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 4rem;
  min-height: var(--touch-min);
  padding: 0 var(--s-4);
  border: 1px solid var(--text-meta);
  border-radius: var(--r-pill);
  background: var(--bg-page);
  color: var(--text-primary);
  font-size: var(--t-small-size);
  line-height: var(--t-small-lh);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.pay-copy:hover {
  background: var(--bg-sheet);
}

/* 입금자명: 이 화면에서 가장 중요한 글. 먹색 굵은 테두리와 큰 글자로만 강조한다 */
.pay-depositor {
  display: grid;
  gap: var(--s-1);
  padding: var(--s-5);
  border: 2px solid var(--line-strong);
  border-radius: var(--r-card);
}

.pay-depositor .pay-label {
  margin-bottom: 0;
  color: var(--text-meta);
}

.pay-depositor-name {
  font-size: var(--t-name-size);
  line-height: var(--t-name-lh);
  font-weight: var(--weight-bold);
  letter-spacing: var(--track-display);
  overflow-wrap: anywhere;
}

.pay-depositor-must {
  margin-top: var(--s-2);
  font-weight: var(--weight-bold);
}

.pay-depositor .pay-help {
  margin-top: 0;
}

.pay-figure {
  margin: var(--s-2) 0 0;
}

.pay-status {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-top: var(--s-2);
  color: var(--text-secondary);
  font-size: var(--t-small-size);
  line-height: var(--t-small-lh);
  font-weight: var(--weight-semibold);
}

.pay-pulse {
  flex: none;
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
  background: var(--text-primary);
  animation: pay-pulse 1.6s ease-in-out infinite;
}

.pay-status[data-offline] .pay-pulse {
  animation: none;
  background: var(--text-meta);
}

@keyframes pay-pulse {
  50% {
    opacity: 0.25;
  }
}

.pay-summary {
  font-size: var(--t-small-size);
  line-height: var(--t-small-lh);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.pay-summary dt {
  min-width: 5.5rem;
}

/* 입금 확인(요금제 시작) */
.pay-done {
  width: 3.5rem;
  height: 3.5rem;
  color: var(--text-primary);
}

.pay-done-check {
  stroke: var(--text-on-ink);
}

/* 시트: 휴대폰은 아래에서 올라오는 판, 넓은 화면은 가운데 창 */
.pay-sheet {
  position: fixed;
  inset: auto 0 0;
  width: 100%;
  max-width: 100%;
  max-height: calc(100dvh - var(--s-6));
  margin: 0;
  padding: var(--s-6) var(--gutter) calc(var(--s-5) + env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 0;
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  background: var(--bg-page);
  color: var(--text-primary);
}

/* ::backdrop은 옛 브라우저에서 :root 변수를 못 읽어서 먹색(--ink-900, #1A2029)을 직접 적는다 */
.pay-sheet::backdrop {
  background: rgb(26 32 41 / 0.5);
}

.pay-sheet-close {
  position: absolute;
  top: var(--s-3);
  right: var(--s-3);
  display: grid;
  place-items: center;
  width: var(--touch-min);
  height: var(--touch-min);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
}

.pay-sheet-close svg {
  width: 1.5rem;
  height: 1.5rem;
}

.pay-sheet-pane {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.pay-sheet-title {
  padding-right: var(--s-7);
  font-size: var(--t-h3-size);
  line-height: var(--t-h3-lh);
  font-weight: var(--weight-bold);
  letter-spacing: var(--track-heading);
}

.pay-sheet .record {
  margin-top: var(--s-2);
}

.pay-sheet-actions {
  display: grid;
  justify-items: center;
  gap: var(--s-2);
  margin-top: var(--s-3);
}

.pay-warn {
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-action);
  background: var(--bg-sheet);
  font-weight: var(--weight-bold);
}

/* 복사 알림 */
.pay-toast {
  position: fixed;
  inset-inline: var(--gutter);
  bottom: calc(var(--s-6) + env(safe-area-inset-bottom));
  z-index: 20;
  width: fit-content;
  max-width: calc(100% - var(--gutter) * 2);
  margin-inline: auto;
  padding: var(--s-3) var(--s-5);
  border-radius: var(--r-action);
  background: var(--cta-bg);
  color: var(--cta-text);
  font-size: var(--t-small-size);
  line-height: var(--t-small-lh);
  font-weight: var(--weight-semibold);
  text-align: center;
  opacity: 0;
  transform: translateY(var(--s-2));
  transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
  pointer-events: none;
}

.pay-toast.is-shown {
  opacity: 1;
  transform: none;
}

/* 알림이 없을 때는 크기를 0으로 둔다(투명도만 0인 빈 알약이 어떤 화면에서도 비치지 않게). 읽기 프로그램용 aria-live 영역은 그대로 남는다 */
.pay-toast:empty {
  padding: 0;
}

@media (min-width: 40rem) {
  .pay-main {
    padding-top: var(--s-7);
  }

  /* 랜딩 기록표(.record)의 이름표 칸(10rem)은 넓은 운영사 칸에 맞춘 폭이다. 좁은 입금 칸에서는 값과 복사 버튼이 한 줄에 들어가게 줄인다 */
  .pay-page .record div {
    grid-template-columns: 6.5rem minmax(0, 1fr);
  }

  .pay-sheet {
    inset: 0;
    width: min(calc(var(--pay-measure) + var(--s-6) * 2), calc(100% - var(--gutter) * 2));
    height: fit-content;
    margin: auto;
    padding: var(--s-6);
    border-radius: var(--r-sheet);
  }
}

/* ── 한 달 요금제(10-13): 번호 적기 화면의 요금표, 안내 목록, 내 요금제·계약 내용, 해지·환불 ── */
.pay-plan-table dd {
  text-align: left;
}

/* 동의 상자 밖에서 쓰는 안내 목록(문자 보냄·해지 화면) */
.pay-plain-list {
  margin-block: var(--s-2);
}

.pay-periods {
  display: grid;
  gap: var(--s-3);
}

.pay-period-label {
  margin-top: var(--s-3);
}

.pay-period dd {
  word-break: keep-all;
}

/* 계약 내용: 랜딩 꼬리말의 사업자 정보(.biz-info)와 같은 모양. 휴대폰에서는 이름 줄 아래에 내용 줄 */
.pay-contract {
  display: grid;
  gap: var(--s-3);
  margin-top: var(--s-5);
  padding-top: var(--s-5);
  border-top: 1px solid var(--line);
}

.pay-contract-title {
  font-size: var(--t-lead-size);
  line-height: var(--t-lead-lh);
  font-weight: var(--weight-semibold);
}

.pay-contract-list {
  gap: var(--s-3);
  font-size: var(--t-small-size);
  line-height: var(--t-small-lh);
}

.pay-contract-list div {
  display: grid;
  gap: 2px;
}

.pay-contract-list dd {
  color: var(--text-secondary);
  word-break: keep-all;
}

@media (min-width: 40rem) {
  .pay-contract-list div {
    grid-template-columns: 7.5rem minmax(0, 1fr);
    column-gap: var(--s-4);
  }
}
