/* Marinno — the shop app (components).
 *
 * Brand tokens live in /css/brand.css, linked before this file. Do not
 * redefine them here.
 *
 * Phone is the real case: this runs inside Telegram on a shop assistant's
 * device, often a cheap one in daylight. Big targets, high contrast, short
 * lines, nothing that depends on hover.
 *
 * From 820px up it becomes a proper desktop layout — the order form splits
 * into a product list and a sticky summary — because shop owners do open this
 * on a PC in the back office, and a 560px column stranded in the middle of a
 * monitor reads as broken.
 */

.frame {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  min-height: 100%;
}

/* --- Type ---------------------------------------------------------------- */

.t-lg {
  font-family: var(--disp);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
  text-wrap: balance;
}

.t-muted { color: var(--text-muted); font-size: 14px; margin: 0; }
.t-faint { color: var(--text-faint); font-size: 12.5px; margin: 0; }

.loading { padding: 56px 20px; text-align: center; color: var(--text-muted); }
.loading-sm { padding: 22px 14px; font-size: 13px; }

.brandmark { display: block; width: auto; height: 30px; max-width: 100%; }
.brandmark-sm { height: 20px; }

.sec-head {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 7px 2px;
}

/* --- Gate screens -------------------------------------------------------- */

.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px 18px; }

.gate-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 13px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 22px;
  box-shadow: var(--shadow);
  animation: site-rise var(--dur-base) var(--ease-out) both;
}
.gate-card .btn-primary { width: 100%; margin-top: 2px; }

/* The join code is read off a note or repeated down a phone line, so it is set
 * big, monospaced and widely tracked — each character has to be unmistakable. */
.codeinput {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-align: center;
  text-transform: uppercase;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 15px 12px;
  min-height: 60px;
  transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.codeinput::placeholder { color: var(--text-faint); letter-spacing: 0.22em; }
.codeinput:focus { outline: none; border-color: var(--accent); background: var(--surface); }

.alert {
  width: 100%;
  color: var(--red);
  background: var(--red-soft);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  animation: site-err var(--dur-base) var(--ease-out) both;
}

/* --- Shell --------------------------------------------------------------- */

.screen { display: flex; flex-direction: column; min-height: 100dvh; }

.head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--hair);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 5;
}
.head-brand { line-height: 0; flex: none; }

.head-shop { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.head-shopname {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.head-who { font-size: 11.5px; color: var(--text-muted); }

.iconback {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.iconback:active { transform: scale(0.94); }

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

/* --- Order rounds -------------------------------------------------------- */

.rounds {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 16px;
  box-shadow: var(--shadow);
}

.rounds-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 8px;
}
.clock { font-variant-numeric: tabular-nums; letter-spacing: 0.05em; }

.rounds-lead { margin: 0 0 13px; font-size: 14px; color: var(--text-muted); line-height: 1.45; }
.lead-strong { color: var(--text); font-weight: 600; }

.roundlist {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--hair);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.round {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  padding: 9px 12px;
  min-height: 52px;
}
/* An open round is the actionable one — lift it out of the sunken list. */
.round.open { background: var(--surface); }

.r-label { font-size: 14px; font-weight: 500; color: var(--text-muted); }
.round.open .r-label { color: var(--text); font-weight: 600; }

.r-cut { font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-faint); }
.round.open .r-cut { color: var(--text); }

.r-state { justify-self: end; }

.btn-round {
  font-family: var(--ui);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--on-accent);
  background: var(--accent);
  border: 0;
  border-radius: var(--radius-pill);
  padding: 7px 14px;
  min-height: 34px;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.btn-round:active { transform: scale(0.96); background: var(--accent-dark); }

.btn-wide { width: 100%; margin-top: 12px; }

.chip {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  border-radius: var(--radius-pill);
  padding: 3px 9px;
  white-space: nowrap;
}
.chip-ok { color: var(--green); background: var(--green-soft); }
.chip-wait { color: var(--amber); background: var(--amber-soft); }
.chip-done { color: var(--green); background: var(--green-soft); }
.chip-off { color: var(--text-muted); background: var(--gray-soft); }
.chip-bad { color: var(--red); background: var(--red-soft); }
.chip-late { color: var(--amber); background: var(--amber-soft); margin-left: 5px; }

/* Sending late is possible, not encouraged — so it gets the quiet outline
 * treatment rather than the filled brand pill an open round earns. */
.btn-round-late {
  color: var(--amber);
  background: transparent;
  border: 1px solid var(--amber);
}
.btn-round-late:active { background: var(--amber-soft); }

/* --- Order history ------------------------------------------------------- */

.olist {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--hair);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.orow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  text-align: left;
  font-family: var(--ui);
  background: var(--surface);
  border: 0;
  padding: 12px 15px;
  min-height: 56px;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
}
.orow:active { background: var(--surface-2); }

.o-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.o-title { font-size: 14.5px; font-weight: 600; }
.o-sub { font-size: 12px; color: var(--text-muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.empty-card { text-align: center; color: var(--text-muted); font-size: 13.5px; }

/* --- Order form ---------------------------------------------------------- */

.order-head { display: flex; flex-direction: column; gap: 3px; }

.banner {
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 13.5px;
  font-weight: 500;
}
.banner-open { color: var(--green); background: var(--green-soft); }
.banner-shut { color: var(--text-muted); background: var(--gray-soft); }
/* Amber, not red: this is a warning about an exception being requested, not an
 * error. Red is the brand here and would read as decoration rather than caution. */
.banner-late {
  color: var(--amber);
  background: var(--amber-soft);
  border: 1px solid color-mix(in oklab, var(--amber) 30%, transparent);
  line-height: 1.5;
}

.order-body { display: flex; flex-direction: column; gap: 16px; }

.picker { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.plist {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--hair);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.prow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  padding: 10px 13px;
  min-height: 60px;
  transition: background var(--dur-fast) var(--ease-out);
}
/* A line with a quantity on it is the signal worth carrying — tint the row so
 * the shop can see at a glance what it has actually put in the order. */
.prow.has { background: var(--accent-soft); }

.p-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.p-name { font-size: 14.5px; font-weight: 500; }
.p-price { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.stepper { display: flex; align-items: center; gap: 6px; flex: none; }

.step {
  width: 34px;
  height: 34px;
  font-size: 18px;
  line-height: 1;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.step:active:not(:disabled) { transform: scale(0.92); background: var(--border); }

.qty {
  width: 56px;
  font-family: var(--ui);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 4px;
  min-height: 38px;
}
.qty:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.qty::placeholder { color: var(--text-faint); font-weight: 400; }

/* --- Balance ------------------------------------------------------------- */

.balcard {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 20px 18px;
}
.bal-l { font-size: 12.5px; color: var(--text-muted); }
.bal-n { font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.bal-owed { background: var(--red-soft); }
.bal-owed .bal-l, .bal-owed .bal-n { color: var(--red); }
.bal-credit { background: var(--green-soft); }
.bal-credit .bal-l, .bal-credit .bal-n { color: var(--green); }

.amt-owed { color: var(--red); }
.amt-credit { color: var(--green); }

/* --- Link card ----------------------------------------------------------- */

.linkcard {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  text-align: left;
  font-family: var(--ui);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  min-height: 62px;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
}
.linkcard:active { background: var(--surface-2); }

.lc-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lc-title { font-size: 15px; font-weight: 600; }
.lc-sub { font-size: 12.5px; color: var(--text-muted); }
.lc-arrow { font-size: 22px; color: var(--text-faint); line-height: 1; flex: none; }

.orow-static { cursor: default; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.input {
  font-family: var(--ui);
  font-size: 15px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  min-height: 46px;
  width: 100%;
}
.input:focus { outline: none; border-color: var(--accent); background: var(--surface); }

/* --- What HQ decided ----------------------------------------------------- */

.dlist {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--hair);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.drow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  padding: 11px 13px;
  min-height: 58px;
}

.d-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.d-name { font-size: 14.5px; font-weight: 500; }
.d-sub { font-size: 12px; color: var(--text-muted); }
.d-sub b { color: var(--text); }

.d-side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; }
.d-qty { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.d-sum { font-size: 11.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.chip-added { color: var(--accent); background: var(--accent-soft); margin-left: 5px; }

.dtotal {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  margin-top: 10px;
  background: var(--surface-2);
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
}
.d-total-n { font-size: 18px; color: var(--text); font-variant-numeric: tabular-nums; }

/* --- Summary ------------------------------------------------------------- */

.sum-card {
  display: flex;
  flex-direction: column;
  gap: 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.sum-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 13.5px; color: var(--text-muted); }
.sum-n { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); }
.sum-total { font-size: 15px; padding-top: 8px; border-top: 1px solid var(--hair); }
.sum-total .sum-n { font-size: 18px; }

.btn-textdanger {
  font-family: var(--ui);
  font-size: 13px;
  font-weight: 600;
  color: var(--red);
  background: none;
  border: 0;
  padding: 9px;
  cursor: pointer;
  border-radius: var(--radius-pill);
}

/* --- Desktop ------------------------------------------------------------- */
/* Shop owners do open this on a PC in the back office. The order form is the
 * screen that actually benefits: the product list and the running total stop
 * competing for the same vertical space. */

@media (min-width: 820px) {
  .frame { max-width: 980px; }

  .head { padding: 16px 24px; }
  .brandmark-sm { height: 24px; }
  .head-shopname { font-size: 16px; }
  .head-who { font-size: 12.5px; }

  .main { padding: 24px; gap: 20px; }

  .order-body {
    flex-direction: row;
    align-items: flex-start;
    gap: 24px;
  }

  .picker { flex: 1; }

  .summary { flex: 0 0 296px; position: sticky; top: 92px; }

  /* Two columns of products once there is room for them. */
  .plist { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; }

  .prow { min-height: 64px; }

  .rounds { padding: 18px 20px; }
  .round { padding: 11px 14px; min-height: 56px; }
}

/* A phone in landscape, or a small tablet: keep one column but let it breathe. */
@media (min-width: 560px) and (max-width: 819px) {
  .main { padding: 20px; }
}

/* The sign-out label costs more than it earns on a narrow phone, where the
 * shop name needs the room. The icon still reads as sign-out. */
@media (max-width: 400px) {
  .btn-quiet-label { display: none; }
  .btn-quiet { padding: 8px 10px; }
}

@media (hover: hover) {
  .orow:hover { background: var(--surface-2); }
  .btn-round:hover { background: var(--accent-dark); }
  .step:hover:not(:disabled) { background: var(--border); }
  .iconback:hover { background: var(--border); color: var(--text); }
  .btn-textdanger:hover { background: var(--red-soft); }
}

/* --- Motion -------------------------------------------------------------- */

@keyframes site-rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

@keyframes site-err {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

/* Keep the fades — they say "something arrived" — but drop the travel. Not a
 * blanket transition kill, which would also remove useful press feedback. */
@media (prefers-reduced-motion: reduce) {
  @keyframes site-rise { from { opacity: 0; } to { opacity: 1; } }
  @keyframes site-err  { from { opacity: 0; } to { opacity: 1; } }

  .step:active:not(:disabled),
  .btn-round:active,
  .iconback:active { transform: none; }
}
