/* ==========================================================================
   orders.css — Open orders (orders.html), v4 / LOCK3. Page-only styles, prefix or-.
   Composition = the reference "Top Tokens | Top X Profiles": a titled grid of order cards
   with logo pills and a pager on the left, a column of profile-style cards on the
   right. Built on nett.css (.nt-ocard, .nt-dcard, .nt-bcard, .nt-pilltabs, .nt-pager).

   Layout answers to the width the sidebar leaves (container "orders"):
     < 900   one column: grid (2 / 3 / 4 up), then Top apps, then the desk card
     >= 900  two columns: grid (3 up) | 300px side
     >= 1060 two columns: grid (4 up) | 340px side (at 1440)
   In two columns both sides share one set of row tracks (subgrid), so each row of
   order cards lines up with one app card, as on the reference. JS reads --or-cols and
   --or-rows to size a page of the pager.
   ========================================================================== */

.or-wrap { container: orders / inline-size; }
.or-main, .or-side { min-width: 0; }
.or-main { --or-cols: 2; --or-rows: 4; }

/* ---------------------------------------------------------------- heads */
/* The title lives in the head card; the grid's head is a filter bar: pills on the left
   (one line, scrolls sideways when narrow), the pager on the right. */
.or-head { flex-wrap: nowrap; row-gap: 12px; }
.or-head__title { flex: none; }
.or-head__end { flex: none; margin-left: auto; }
.or-filters {
  flex: 0 1 auto;
  min-width: 0;
  flex-wrap: nowrap;
  gap: 6px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  scroll-padding-inline: 16px;
  padding-right: 24px;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent);
  mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent);
}
/* Phones: the pills get the whole row; the pager steps aside (new orders stream in). */
@container orders (max-width: 519px) { .or-head__end { display: none; } }
.or-filters::-webkit-scrollbar { display: none; }
.or-filters .nt-pilltab > svg { width: 16px; height: 16px; }
.or-filters .nt-pilltab .nt-lg { --s: 18px; }
@container orders (min-width: 720px) {
  .or-filters { padding-right: 0; -webkit-mask-image: none; mask-image: none; }
}
.or-headcard + .or-wrap { margin-top: 32px; }

/* ---------------------------------------------------------------- order grid */
.or-grid {
  display: grid;
  grid-template-columns: repeat(var(--or-cols), minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.or-grid > li, .or-apps > li { display: flex; min-width: 0; }
/* Until orders.js fills them, the grid, the app list and the provider card hold about their
   height, so the footer and the provider card never paint in view only to jump down. The
   grid's placeholder is a spanning item, not a min-height: from 900px the grid is a subgrid,
   and a subgrid's own min-height does not size the shared rows. */
.or-grid:empty::before { content: ""; grid-column: 1 / -1; height: 1000px; }
.or-apps:empty { min-height: 768px; }
.or-cta__desks:empty { min-height: 113px; }
.or-grid > li > *, .or-apps > li > * { flex: 1 1 auto; min-width: 0; }

@container orders (min-width: 520px) { .or-main { --or-cols: 3; } .or-grid { gap: 16px; } }
@container orders (min-width: 720px) { .or-main { --or-cols: 4; } }

/* Order card = the reference token card: art square with the funding chip (top left), the
   deadline pill (top right) and the app pill (bottom left); then "to @handle" and the amount. */
.or-card { padding: 8px; }
/* The lock veil sits under the pills (a filter on the art would dim them too). */
.or-card .nt-ocard__art::before { content: ""; position: absolute; inset: 0; border-radius: inherit; background: rgba(10, 10, 10, 0.58); -webkit-backdrop-filter: saturate(0.3); backdrop-filter: saturate(0.3); opacity: 0; transition: opacity 400ms var(--nt-ease); pointer-events: none; }
.or-card__fund {
  position: absolute;
  top: 8px;
  left: 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 9px 0 4px;
  border-radius: var(--nt-r-pill);
  background: rgba(10, 10, 10, 0.72);
  font-size: 11px;
  line-height: 1;
  font-weight: var(--nt-w-bold);
  color: var(--nt-text-strong);
  white-space: nowrap;
}
.or-card__fund .nt-lg { --s: 18px; box-shadow: none; }
.or-card .nt-ocard__deadline { gap: 4px; }
.or-card .nt-ocard__deadline > svg { width: 11px; height: 11px; }
.or-card .nt-ocard__body { gap: 5px; padding: 14px 6px 9px; }
.or-card__to {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--nt-fs-ui);
  line-height: 1.35;
  color: var(--nt-muted);
}
.or-card__to .nt-at { color: var(--nt-text); }
.or-card__amount {
  font-size: 17px;
  line-height: 1.25;
  letter-spacing: -0.01em;
  font-weight: var(--nt-w-bold);
  color: var(--nt-text-strong);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
/* A desk locked it: the art dims, the pill reads "Locked", then a new order takes the slot. */
.or-card.is-locked .nt-ocard__art::before { opacity: 1; }
.or-card.is-locked .nt-ocard__deadline { background: var(--nt-inverse-bg); color: var(--nt-inverse-fg); }
.or-card.is-new { animation: or-in 420ms var(--nt-ease-out) both; }
@keyframes or-in { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: none; } }

.or-empty {
  grid-column: 1 / -1;
  padding: 40px 16px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: var(--nt-r-row);
  font-size: var(--nt-fs-ui);
  color: var(--nt-muted);
  text-align: center;
}

/* ---------------------------------------------------------------- top apps (profile cards) */
.or-side { display: flex; flex-direction: column; }
.or-apps { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin: 0; padding: 0; list-style: none; }
@container orders (min-width: 600px) { .or-apps { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; } }
@container orders (min-width: 600px) and (max-width: 899px) { .or-apps:empty { min-height: 252px; } }
@container orders (min-width: 900px) { .or-cta__desks:empty { min-height: 174px; } }

/* the reference proportions: banner, 64px avatar half over it, bold name, grey handle, a chip,
   then "12 open   $48,210.00" with the small label under the amount. */
.or-app .nt-dcard__banner { height: 96px; }
.or-app > .nt-avatar { top: 54px; }
.or-app .nt-dcard__body { gap: 0; padding: 27px 16px 13px; }
.or-app .nt-dcard__handle { margin-top: 1px; }
.or-app .nt-dcard__chip { margin-top: 5px; color: var(--nt-text-2); }
.or-app .nt-dcard__chip .nt-lg { --s: 14px; box-shadow: none; }
/* 3-up cards on tablets are ~200px wide: the chip keeps the coin and its name only. */
@container orders (min-width: 600px) and (max-width: 899px) { .or-app__on { display: none; } }
.or-app__stats { display: grid; grid-template-columns: auto auto; justify-content: start; align-items: baseline; column-gap: 20px; margin-top: 7px; }
.or-app__stat { display: inline-flex; align-items: baseline; gap: 5px; font-size: 15px; line-height: 1.3; color: var(--nt-muted); white-space: nowrap; }
.or-app__stat b { font-size: 16px; font-weight: var(--nt-w-bold); color: var(--nt-text-strong); font-variant-numeric: tabular-nums; }
.or-app__sub { grid-column: 2; margin-top: 2px; font-size: 11px; line-height: 1.3; color: var(--nt-muted); white-space: nowrap; }
@container orders (max-width: 599px) {
  .or-app .nt-dcard__banner { height: 88px; }
  .or-app > .nt-avatar { top: 48px; }
  .or-app .nt-dcard__body { padding-top: 31px; }
}

/* ---------------------------------------------------------------- desk CTA (bento card) */
.or-cta { margin-top: 16px; height: auto; min-height: 216px; }
.or-cta__body { padding: 16px 16px 0; }
.or-cta__desks { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.or-cta__desk {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 9px 12px 9px 9px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--nt-r-inner);
  background: #1B1B1B;
}
.or-cta__desk .nt-avatar { --nt-av-size: 30px; }
.or-cta__who { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.or-cta__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--nt-fs-ui); font-weight: var(--nt-w-bold); color: var(--nt-text-strong); }
.or-cta__handle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--nt-fs-micro); color: var(--nt-muted); }
.or-cta__fills { margin-left: auto; font-size: var(--nt-fs-small); color: var(--nt-muted); white-space: nowrap; }
.or-cta__fills b { font-weight: var(--nt-w-bold); color: var(--nt-text-strong); font-variant-numeric: tabular-nums; }
.or-cta .nt-bcard__title { color: var(--nt-text-strong); }
/* The footer label sits under the rows, in flow: in two columns the card is only as tall as its
   rows (0 to 3 providers), and the kit's absolute foot (and its fade) would paint over them. */
.or-cta .nt-bcard__foot { position: relative; margin-top: auto; padding-top: 14px; }
.or-cta::after { display: none; }

/* ---------------------------------------------------------------- one column */
.or-layout { display: grid; grid-template-columns: minmax(0, 1fr); row-gap: 56px; }
@container orders (max-width: 899px) {
  .or-layout { row-gap: 48px; }
  .or-cta__desks > li:nth-child(n+3) { display: none; }
}

/* ---------------------------------------------------------------- two columns */
@container orders (min-width: 900px) {
  .or-layout { grid-template-columns: minmax(0, 1fr) 300px; column-gap: 40px; row-gap: 0; align-items: start; }
  .or-main { --or-cols: 3; }
  .or-grid { gap: 16px; }
  .or-apps { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .or-cta { min-height: 0; }
}
@container orders (min-width: 1060px) {
  .or-layout { grid-template-columns: minmax(0, 1fr) 340px; }
  .or-main { --or-cols: 4; }
}
/* One set of row tracks for both columns: head row + 4 card rows. Order rows and app
   cards (3 apps + the desk card) line up. */
@supports (grid-template-rows: subgrid) {
  @container orders (min-width: 900px) {
    .or-layout { grid-template-rows: auto repeat(4, auto); row-gap: 16px; align-items: stretch; }
    .or-main, .or-side { grid-row: 1 / span 5; display: grid; grid-template-rows: subgrid; }
    .or-main { grid-template-columns: repeat(var(--or-cols), minmax(0, 1fr)); column-gap: 16px; }
    .or-side { grid-template-columns: minmax(0, 1fr); }
    .or-head { margin-bottom: 0; align-self: start; }
    .or-main > .or-head { grid-column: 1 / -1; }
    .or-grid { grid-column: 1 / -1; grid-row: 2 / span 4; grid-template-columns: subgrid; grid-template-rows: subgrid; }
    .or-apps { grid-row: 2 / span 3; grid-template-rows: subgrid; }
    .or-cta { grid-row: 5; margin-top: 0; height: auto; }
  }
}

/* ---------------------------------------------------------------- real cards (orders.js real mode)
   The card opens the receipt through a stretched link; "Take" sits above it and opens the
   provider desk on that order. An expired card dims (the payer can refund it) and loses "Take". */
.or-card--real { position: relative; }
.or-card--real:hover { border-color: rgba(255, 255, 255, 0.14); }
.or-card__link { color: inherit; text-decoration: none; }
.or-card__link::after { content: ""; position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.or-card__link:focus-visible { outline: none; }
.or-card--real:has(.or-card__link:focus-visible) { outline: var(--nt-focus); outline-offset: 2px; }
.or-card__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 32px; }
.or-card__take { position: relative; z-index: 2; flex: none; min-width: 64px; }
.or-card__fee { font-size: var(--nt-fs-micro); line-height: 1.3; color: var(--nt-muted); font-variant-numeric: tabular-nums; }
.or-card--real .nt-ocard__body { gap: 4px; }
/* Real deadlines read "4h 32m left": the funding chip keeps its coin only (name in its title). */
.or-card--real .or-card__fund { padding: 0 4px; }
.or-card--real .or-card__fund > span:not(.nt-lg) { display: none; }
/* An empty grid, an error or the upgrade notice: one item across the columns. */
.or-emptyli { grid-column: 1 / -1; list-style: none; }
.or-emptyli > .nt-empty:not(.nt-empty--bare) { min-height: 320px; }
/* The network upgrade: the calm notice, centred in an empty-state card. */
.or-note .nt-notice { padding: 0; border: 0; background: none; }
/* Two columns: the empty grid keeps most of its loading height, so the provider card below
   the apps does not jump up into view when the (empty) answer arrives. */
@container orders (min-width: 900px) { .or-emptyli > .nt-empty:not(.nt-empty--bare) { min-height: 480px; } }
/* Top apps beside an empty grid, the upgrade notice or an error: the same quiet card, shorter
   in one column, as tall as the grid's card in two. */
.or-apps .or-emptyli { align-self: start; }
.or-apps .or-emptyli > .nt-empty:not(.nt-empty--bare) { min-height: 168px; }
@container orders (min-width: 900px) { .or-apps .or-emptyli > .nt-empty:not(.nt-empty--bare) { min-height: 480px; } }
.or-app__addr { position: relative; color: var(--nt-muted); font-size: var(--nt-fs-small); text-decoration: none; }
.or-app__addr:hover { color: var(--nt-text-strong); }
.or-cta__desk--open .or-cta__name { font-weight: var(--nt-w-medium); }
/* USDC on Solana is not live yet: a quiet pill with its "Soon" tag, no filter behind it. */
.or-soon { cursor: default; color: var(--nt-muted); }
.or-soon:hover { color: var(--nt-muted); }
.or-soon .nt-lg { opacity: 0.55; }
.or-soon .nt-tag { height: 18px; margin-left: 2px; padding: 0 6px; font-size: 9px; }
/* "Demo data" chip, top right of the head card (demo mode only; nett.data fills it). */
.or-demochip { position: absolute; top: 16px; right: 16px; z-index: 2; }

/* ---------------------------------------------------------------- motion */
@media (prefers-reduced-motion: reduce) {
  .or-card.is-new { animation: none; }
  .or-card .nt-ocard__art::before { transition: none; }
}

/* Phones: the top bar already carries "Send payout" right above the head card. */
@media (max-width: 767px) { .or-headcard .nt-headcard__end { display: none; } }
