/* 결제창 /c/:id — Figma 「WANNA Chain — 결제창」 30 화면에서 읽은 값 그대로 (docs/design/figma.md)
   토큰 = infra/explorer-web/src/styles/tokens.css 와 같은 이름 · 같은 값(WANNA 다크 단일 테마 — 그쪽도 다크만 있다).
   시그니처: 「시간 테두리」 — QR 둘레가 남은 시간만큼만 칠해지고, 1분 아래로 내려가면 호박색으로 바뀐다.
   🔴 style="" 를 쓰지 않는다(CSP style-src 'self'). 진행 정도는 SVG 의 stroke-dashoffset 속성으로 칠한다. */

:root {
  --paper: #0b0e16;
  --paper-raised: #141a29;
  --paper-sunken: #0e1220;
  --paper-deep: #1c2338;
  --ink: #f2f4f8;
  --ink-soft: #a6adc4;
  --ink-faint: #7a8299;
  --line: #232a3d;
  --line-strong: #333c58;
  --accent: #ff7818;
  --accent-hover: #ff8a33;
  --accent-text: #ff8f3d;
  --accent-ink: #1a1206;
  --success: #34d399;
  --pending: #fbbf24;
  --pending-bg: rgba(251, 191, 36, 0.14);
  --pending-band: rgba(251, 191, 36, 0.12);
  --info: #60a5fa;
  --focus-ring: 0 0 0 3px rgba(255, 120, 24, 0.75);
  --grad-flame: linear-gradient(135deg, #ff7818 0%, #ffb800 100%);

  --font-body: Pretendard, -apple-system, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;

  --r-card: 24px;
  --r-plate: 14px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);

  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

p,
h1,
h2,
dl,
dd,
ol {
  margin: 0;
}

a {
  color: inherit;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 6px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.ic {
  width: 1em;
  height: 1em;
  flex: none;
  vertical-align: -0.125em;
}

.mono {
  font-family: var(--font-mono);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
/* 글 속 숫자(USDT 견적) — 둘레 글보다 한 단계 진하게 · 자릿수가 바뀌어도 폭이 흔들리지 않게 */
.tnum {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--ink);
}

/* ── 틀 ─────────────────────────────────────────────────────────────────── */

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 0 40px;
  display: flex;
  flex-direction: column;
  gap: 56px;
  min-height: 100dvh;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 32px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.flame {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--grad-flame);
}

.test-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--pending-bg);
  color: var(--pending);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.foot {
  margin: auto auto 0;
  max-width: 576px;
  text-align: center;
  color: var(--ink-faint);
  font-size: 13px;
}

/* 모바일 전용 조각 — 다른 규칙(.get-wallet 의 display 등)이 덮지 못하게 */
@media (min-width: 900px) {
  .m-only {
    display: none !important;
  }
}

/* 데스크톱: 왼쪽 480(주문 요약) · 오른쪽 400(결제 카드) · 사이 64 */
.main {
  display: grid;
  grid-template-columns: 480px 400px;
  grid-template-areas:
    "head panel"
    "rows panel"
    "note panel"
    "wallet panel"
    ". panel";
  grid-template-rows: auto auto auto auto 1fr;
  column-gap: 64px;
  justify-content: center;
  align-items: start;
}

.main--solo {
  grid-template-columns: minmax(0, 400px);
  grid-template-areas: "panel";
  grid-template-rows: auto;
  padding-top: 40px;
}

.head {
  grid-area: head;
}
.rows {
  grid-area: rows;
}
.note {
  grid-area: note;
}
.main > .get-wallet {
  grid-area: wallet;
}
.panel {
  grid-area: panel;
}

/* ── 주문 요약 ───────────────────────────────────────────────────────────── */

.eyebrow {
  color: var(--ink-faint);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.12em;
}

.merchant {
  margin-top: 10px;
  font-size: 30px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.desc {
  margin-top: 6px;
  color: var(--ink-soft);
  font-size: 17px;
}

.amount {
  margin-top: 40px;
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.amount .num {
  font-size: 64px;
  letter-spacing: -0.02em;
}
.amount .unit {
  font-size: 30px;
}
.amount.is-dim {
  color: var(--ink-faint);
}

.sub {
  margin-top: 8px;
  color: var(--ink-faint);
  font-size: 15px;
}

.rows {
  margin-top: 36px;
  border-bottom: 1px solid var(--line);
}
.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.row dt {
  color: var(--ink-soft);
}
.row dd {
  font-weight: 500;
  text-align: right;
}

.link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent-text);
  text-decoration: none;
  transition: color 0.2s var(--ease);
}
.link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.note {
  margin-top: 28px;
  padding: 16px 20px;
  border-radius: var(--r-plate);
  background: var(--paper-raised);
  border: 1px solid var(--line);
}
.note-title {
  font-weight: 500;
}
.note p + p {
  margin-top: 6px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.55;
}

.get-wallet {
  display: inline-block;
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}
.get-wallet:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ── 오른쪽 카드 ─────────────────────────────────────────────────────────── */

.panel {
  grid-row: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 32px 32px 28px;
  border-radius: var(--r-card);
  background: var(--paper-raised);
  border: 1px solid var(--line);
}

.panel > hr {
  align-self: stretch;
  height: 1px;
  margin: 24px 0 20px;
  border: 0;
  background: var(--line);
}

.panel-title {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.25;
}

.para {
  margin-top: 8px;
  color: var(--ink-soft);
  line-height: 1.6;
}

.offline {
  align-self: stretch;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 20px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--pending-band);
  color: var(--pending);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  text-align: left;
}
.offline .ic {
  width: 19px;
  height: 19px;
  margin-top: 0;
}
.offline[hidden] {
  display: none;
}

/* 시간 테두리 — 284 정사각, QR 판은 20 들여서 244 */
.scan {
  margin-top: 24px;
}
.bezel {
  position: relative;
  width: 284px;
  height: 284px;
}
.ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: none;
  stroke-width: 4;
}
.ring .track,
.bar .track {
  stroke: var(--line-strong);
}
.ring .progress,
.bar .progress {
  stroke: var(--accent);
  transition:
    stroke-dashoffset 1s linear,
    stroke 0.4s var(--ease);
}
.is-low .ring .progress,
.is-low .bar .progress {
  stroke: var(--pending);
}
.qr {
  position: absolute;
  inset: 20px;
  padding: 16px;
  border-radius: var(--r-plate);
  background: var(--ink);
}
.qr svg {
  display: block;
  width: 100%;
  height: 100%;
}

.timer {
  margin-top: 20px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--ink-soft);
}
.timer .mono {
  color: var(--ink);
  font-size: 22px;
  font-weight: 500;
}
.is-low .timer .mono {
  color: var(--pending);
}

.panel > .d-only:has(> .steps) {
  align-self: stretch;
}
.steps {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
  align-self: stretch;
}
.step {
  display: flex;
  align-items: center;
  gap: 12px;
}
.step .n {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--paper-deep);
  font-size: 12px;
  font-weight: 700;
}
.step .n .ic {
  width: 14px;
  height: 14px;
}
.step.is-done .n {
  background: var(--success);
  color: var(--accent-ink);
}
.step.is-now .n {
  background: var(--accent);
  color: var(--accent-ink);
}
.step.is-now {
  font-weight: 500;
}
.step.is-todo {
  color: var(--ink-soft);
}
.step.is-todo .n {
  color: var(--ink-soft);
}

.panel .get-wallet {
  margin-top: 24px;
}

/* 확인 중 */
.confirm {
  align-self: stretch;
  margin-top: 28px;
}
.blocks {
  display: flex;
  gap: 8px;
}
.blocks span {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: var(--paper-deep);
  transition: background-color 0.4s var(--ease);
}
.blocks span.on {
  background: var(--accent);
}
.confirm-label {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: var(--ink-soft);
}
.confirm-label .mono {
  color: var(--ink);
  font-weight: 500;
}
.kv {
  align-self: stretch;
  margin-top: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: var(--ink-faint);
  font-size: 14px;
}

/* 결과(완료 · 환불 · 만료 · 취소 · 없음) */
.status-icon {
  margin-top: 12px;
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 999px;
  background: var(--paper-deep);
  font-size: 32px;
}
.status-icon.is-success {
  background: var(--success);
  color: var(--accent-ink);
  font-size: 36px;
}
.status-icon.is-info {
  color: var(--info);
}
.status-icon.is-muted {
  color: var(--ink-soft);
}
.result-title {
  margin-top: 20px;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
}
.status-icon.is-success + .result-title {
  font-size: 24px;
}
.panel--result .btn {
  margin-top: 32px;
}
.redirect {
  margin-top: 12px;
  color: var(--ink-faint);
  font-size: 13px;
}

/* ── 버튼 ────────────────────────────────────────────────────────────────── */

.btn {
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 14px 24px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background-color 0.25s var(--ease),
    border-color 0.25s var(--ease),
    transform 0.2s var(--ease);
}
.btn:active {
  transform: scale(0.98);
}
.btn:focus-visible {
  border-radius: 999px;
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover {
  background: var(--accent-hover);
}
.btn-secondary {
  border: 1px solid var(--line-strong);
  color: var(--ink);
  font-weight: 500;
}
.btn-secondary:hover {
  background: var(--paper-deep);
}

/* ── 모바일 (900 미만) — Figma 「결제 대기 (모바일)」 390 폭 ─────────────── */

@media (max-width: 899.98px) {
  .d-only {
    display: none !important;
  }
  .m-only {
    display: revert;
  }

  .page {
    max-width: 480px;
    padding: max(24px, env(safe-area-inset-top)) 20px max(34px, env(safe-area-inset-bottom));
    gap: 32px;
  }
  .brand {
    gap: 8px;
    font-size: 15px;
  }
  .flame {
    width: 12px;
    height: 12px;
  }
  .test-badge {
    padding: 4px 10px;
    font-size: 12px;
  }

  /* 순서: 주문 요약 → 결제 카드 → 표 → 지갑 받기 */
  .main {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "head"
      "panel"
      "rows"
      "wallet";
    grid-template-rows: none;
  }
  .main--solo {
    grid-template-areas: "panel";
    padding-top: 0;
  }
  .panel {
    grid-row: auto;
    margin-top: 28px;
    padding: 28px 20px 24px;
  }
  .main--solo .panel {
    margin-top: 0;
  }

  .eyebrow {
    font-size: 12px;
  }
  .merchant {
    margin-top: 8px;
    font-size: 24px;
  }
  .desc {
    margin-top: 4px;
    font-size: 15px;
  }
  .amount {
    margin-top: 20px;
    gap: 4px;
  }
  .amount .num {
    font-size: 48px;
  }
  .amount .unit {
    font-size: 24px;
  }
  .sub {
    margin-top: 4px;
    font-size: 13px;
  }

  .rows {
    margin-top: 28px;
  }
  .row {
    padding: 12px 0;
  }
  .row dt {
    font-size: 14px;
  }
  .row dd,
  .row .mono {
    font-size: 13px;
  }
  .main > .get-wallet {
    margin-top: 16px;
  }

  /* 결제 대기: 카드 없이 바로 — 큰 버튼 · 시간 막대 · 작은 QR */
  .panel--pending {
    margin-top: 28px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    align-items: stretch;
    text-align: left;
  }
  .m-pay .btn {
    min-height: 54px;
    font-size: 17px;
  }
  .bar {
    display: block;
    width: 100%;
    height: 4px;
    margin-top: 12px;
    border-radius: 2px;
    overflow: hidden;
    fill: none;
    /* 세로 4 = 그려지는 높이 4px — 가로로만 늘어나니 굵기는 그대로. 끝 둥글림은 border-radius 로 자른다
       (vector-effect: non-scaling-stroke 는 pathLength 를 무시해 점선이 되므로 쓰지 않는다) */
    stroke-width: 4;
  }
  .bar-label {
    margin-top: 8px;
    display: flex;
    justify-content: space-between;
    color: var(--ink-soft);
    font-size: 13px;
  }
  .bar-label .mono {
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
  }
  .is-low .bar-label .mono {
    color: var(--pending);
  }
  .bar-label [data-remaining] {
    font-family: var(--font-mono);
  }

  .scan {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 16px;
  }
  .bezel {
    width: 112px;
    height: 112px;
    flex: none;
  }
  .qr {
    inset: 0;
    padding: 8px;
    border-radius: 10px;
  }
  .scan-q {
    font-weight: 500;
  }
  .scan-text p + p {
    margin-top: 6px;
    color: var(--ink-soft);
    font-size: 13px;
    line-height: 1.5;
  }
  .panel--pending + .rows,
  .rows {
    margin-top: 20px;
  }
}

/* 아주 좁은 폰(320) — 금액이 넘치지 않게 */
@media (max-width: 359.98px) {
  .amount .num {
    font-size: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}

@media (forced-colors: active) {
  .ring .progress,
  .bar .progress {
    stroke: Highlight;
  }
}
