/* =====================================================================
   LANDING — layout of the five views. Colours/type come from tokens.css.
   ===================================================================== */

body { display: flex; flex-direction: column; }

.stage {
  flex: 1;
  display: flex;
  align-items: center;
  width: 100%;
  max-width: calc(var(--max) + 2 * var(--gutter));
  margin: 0 auto;
  padding: var(--s-6) var(--gutter) var(--s-9);
}

/* Two columns: words on the left, the invoice's mosaic on the right */
.view {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  align-items: center;
  gap: var(--s-8);
}
.view-copy { min-width: 0; }

.h-hero {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: var(--t-hero);
  line-height: var(--lh-display);
  letter-spacing: var(--track-display);
  text-wrap: balance;
}
.lead {
  margin-top: var(--s-6);
  max-width: 34ch;
  font-size: var(--t-lead);
  color: var(--c-ink);
}
.code { font-family: var(--f-code); color: var(--c-accent); overflow-wrap: anywhere; }

/* ---- Lookup form --------------------------------------------------- */
.lookup-form { margin-top: var(--s-8); max-width: 560px; }
.field-row { display: flex; gap: var(--s-2); }
.field-row .field-input { flex: 1; min-width: 0; font-size: 1.125rem; }

/* ---- Mosaic frame -------------------------------------------------- */
.mosaic-frame {
  justify-self: end;
  width: 100%;
  max-width: 520px;
  aspect-ratio: 1;
  padding: 7%;
  background: var(--c-surface);
  border-radius: var(--radius-card);
}
.mosaic-frame.is-empty .mosaic { opacity: 0.5; }
.mosaic-frame.is-loading rect { animation: cell-pulse 1.1s var(--ease-out) infinite alternate; animation-delay: calc(var(--i, 0) * 17ms); }
@keyframes cell-pulse { from { opacity: 1; } to { opacity: 0.25; } }

/* ---- Invoice: two columns on desktop ------------------------------
   Left: who + the big amount. Right: the details card + Continue.
   On a phone (≤860px, below) it collapses to one column.
   container-type lives on .invoice-head so the amount shrinks to the
   WIDTH OF ITS COLUMN, not the whole two-column wrap. */
.view-invoice { display: block; }
.invoice-wrap {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 420px);
  gap: var(--s-8);
  align-items: start;
}
.invoice-head { min-width: 0; container-type: inline-size; }
.invoice-detail { min-width: 0; }

.invoice-top { display: flex; align-items: center; gap: var(--s-3); }
.mosaic-badge { width: 36px; flex: none; }
.invoice-title { font-size: var(--t-body); font-weight: 500; line-height: 1.3; color: var(--c-ink-2); min-width: 0; }
.invoice-title .code { color: var(--c-ink); }

/* The amount shrinks to fit one line: app.js sets --amount-em to the
   estimated width of "1,250.50 USDT" in em. */
.amount {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  margin-top: var(--s-4);
  font-family: var(--f-display);
  font-weight: 700;
  line-height: var(--lh-display);
  letter-spacing: var(--track-display);
  font-size: min(var(--t-amount), calc(100cqi / var(--amount-em, 6.4)));
}
.amount-dec { font-size: 0.45em; color: var(--c-ink-2); }
.amount-cur { font-size: 0.3em; color: var(--c-accent); margin-left: 0.5em; letter-spacing: -0.01em; }

/* Details card. On desktop it tops the right column (no top margin);
   on a phone it stacks under the amount, so the margin is restored below. */
.card {
  padding: 0 var(--s-6);
  background: var(--c-surface);
  border-radius: var(--radius-card);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-5) 0;
  list-style: none;
  cursor: pointer;
}
.card-head::-webkit-details-marker { display: none; }
.card-title {
  font-family: var(--f-text);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-ink-2);
}
.chevron {
  width: 22px; height: 22px; flex: none;
  fill: none; stroke: var(--c-ink-2); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  transition: transform var(--dur) var(--ease-out), stroke var(--dur-fast);
}
.card:not([open]) .chevron { transform: rotate(180deg); }
.card-head:hover .chevron { stroke: var(--c-ink); }

.rows { padding-bottom: var(--s-2); }
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-5);
  min-height: 64px;
  padding: var(--s-3) 0;
}
.row + .row { border-top: 1px solid var(--c-line); }
.row dt { flex: none; color: var(--c-ink-2); font-size: 1.0625rem; }
.row dd {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s-3);
  min-width: 0;
  font-size: 1.0625rem;
  font-weight: 600;
  text-align: right;
  overflow-wrap: anywhere;
}

/* Network badge: coloured letter, or the logo from shared/networks/ (see shared/lists.js) */
.net-badge {
  display: inline-grid;
  place-items: center;
  width: 30px; height: 30px; flex: none;
  border-radius: 50%;
  overflow: hidden;
  background: var(--net, var(--c-surface-3));
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 700;
}
.net-badge img { width: 100%; height: 100%; object-fit: cover; }

.txid { font-family: var(--f-code); font-weight: 500; font-size: 0.9375rem; }
.tx-link {
  flex: none;
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--c-accent);
  color: var(--c-accent-ink);
  font-size: var(--t-small);
  font-weight: 600;
  text-decoration: none;
  transition: background-color var(--dur-fast), color var(--dur-fast), transform var(--dur-fast) var(--ease-out);
}
.tx-link:hover { background: var(--c-ink); color: var(--c-ground); }
.tx-link:active { transform: scale(0.97); }

.copy-btn {
  flex: none;
  border: 0;
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--c-surface-2);
  color: var(--c-ink-2);
  font-size: var(--t-small);
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--dur-fast), color var(--dur-fast);
}
.copy-btn:hover { background: var(--c-surface-3); color: var(--c-ink); }

.continue-btn { width: 100%; margin-top: var(--s-5); font-size: 1.0625rem; }
.invoice-actions:empty { display: none; }
.invoice-actions { margin-top: var(--s-5); display: flex; flex-wrap: wrap; gap: var(--s-3); }

.note { margin-top: var(--s-6); color: var(--c-ink-2); font-size: var(--t-small); }
.error-actions { margin-top: var(--s-7); }

/* ---- Entrance (transform + opacity only) --------------------------- */
.view:not([hidden]) .view-copy > *,
.view:not([hidden]) .invoice-head > *,
.view:not([hidden]) .invoice-detail > * {
  animation: rise var(--dur-slow) var(--ease-out) both;
}
.view:not([hidden]) .view-copy > :nth-child(2),
.view:not([hidden]) .invoice-head > :nth-child(2),
.view:not([hidden]) .invoice-detail > :nth-child(2) { animation-delay: 70ms; }
.view:not([hidden]) .view-copy > :nth-child(3),
.view:not([hidden]) .invoice-head > :nth-child(3),
.view:not([hidden]) .invoice-detail > :nth-child(3) { animation-delay: 140ms; }
.view:not([hidden]) .view-copy > :nth-child(4),
.view:not([hidden]) .invoice-detail > :nth-child(n+4) { animation-delay: 210ms; }
.view:not([hidden]) .mosaic-frame { animation: settle var(--dur-slow) var(--ease-out) both; }
@keyframes rise { from { opacity: 0; transform: translateY(24px); } }
@keyframes settle { from { opacity: 0; transform: scale(0.96); } }

/* ---- Phone --------------------------------------------------------- */
@media (max-width: 860px) {
  .stage { align-items: flex-start; padding-top: var(--s-4); padding-bottom: var(--s-8); }
  .view { grid-template-columns: 1fr; gap: var(--s-7); }
  .mosaic-frame { order: -1; justify-self: start; max-width: 180px; padding: 6%; }
  .lead { margin-top: var(--s-5); }
  .lookup-form { margin-top: var(--s-7); }

  /* Invoice collapses to one column: amount on top, card below it. */
  .invoice-wrap { grid-template-columns: 1fr; gap: 0; max-width: 600px; }
  .invoice-detail .card { margin-top: var(--s-6); }
}
@media (max-width: 520px) {
  .card { padding: 0 var(--s-5); }
  .row { min-height: 56px; gap: var(--s-4); }
  .row dt, .row dd { font-size: 1rem; }
  .field-row { flex-direction: column; }
  .field-row .btn { width: 100%; }
  /* Comfortable touch targets for the inline row actions. */
  .copy-btn, .tx-link { min-height: 36px; padding-left: 14px; padding-right: 14px; }
}
