/* ==========================================================================
   Card on file — the few pieces the existing system did not already have
   --------------------------------------------------------------------------
   Used by the account (Payment methods), the cart drawer, card-setup.html,
   the Store Portal and the admin. Tokens only (styles.css), so light and
   dark follow the site; buttons are the site's own pill .btn.
   ========================================================================== */

/* the brand, as a small word — never a logo */
.cof-mark {
  display: inline-grid; place-items: center; flex: 0 0 auto;
  min-width: 46px; height: 30px; padding: 0 0.45rem;
  border-radius: 7px; border: 1px solid var(--line-strong);
  background: var(--surface-sunk); color: var(--text);
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em;
}
.cof-mark--visa { color: #1A1F71; }
.cof-mark--mastercard { color: #C1360B; }
.cof-mark--amex { color: #006FCF; }
[data-theme="dark"] .cof-mark--visa, [data-theme="dark"] .cof-mark--mastercard, [data-theme="dark"] .cof-mark--amex { color: var(--text); }

/* a list of saved cards */
.cof-list { display: grid; gap: 0.6rem; margin: 0; padding: 0; list-style: none; }
.cof-card {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1rem;
  padding: 0.9rem 1rem; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface);
}
.cof-card--off { opacity: 0.72; }
.cof-card__main { flex: 1 1 200px; min-width: 0; }
.cof-card__title { font-weight: 600; letter-spacing: -0.01em; }
.cof-card__meta { font-size: 0.88rem; color: var(--text-3); margin-top: 0.15rem; }
.cof-card__badges { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.cof-card__end { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-left: auto; }

/* the agreement, readable in place: a focusable scroll region */
.cof-agreement {
  max-height: min(46vh, 360px); overflow: auto; overscroll-behavior: contain;
  padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface-sunk); font-size: 0.95rem; line-height: 1.65; color: var(--text);
}
.cof-agreement:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cof-agreement h3 { margin: 0 0 0.6rem; font-size: 1rem; letter-spacing: -0.01em; }
.cof-agreement p { margin: 0 0 0.75rem; }
.cof-agreement p:last-child { margin-bottom: 0; }
.cof-agreement__ver { font-size: 0.8rem; color: var(--text-3); margin-top: 0.6rem; }
details.cof-details > summary { cursor: pointer; font-weight: 600; color: var(--accent); }
details.cof-details[open] > summary { margin-bottom: 0.6rem; }

/* the drawn signature */
.cof-sign { position: relative; border: 1.5px dashed var(--line-strong); border-radius: var(--r-sm); background: var(--surface); }
.cof-sign canvas { display: block; width: 100%; height: 150px; touch-action: none; cursor: crosshair; border-radius: inherit; }
.cof-sign__line { position: absolute; left: 1rem; right: 1rem; bottom: 34px; border-bottom: 1px solid var(--line-strong); pointer-events: none; }
.cof-sign__bar { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-top: 0.4rem; font-size: 0.85rem; color: var(--text-3); }

/* where a person is: sign → card → done */
.cof-steps { display: flex; gap: 0.4rem; margin: 0 0 1.25rem; padding: 0; list-style: none; font-size: 0.85rem; color: var(--text-3); }
.cof-steps li { display: flex; align-items: center; gap: 0.4rem; }
.cof-steps li + li::before { content: ''; width: 18px; height: 1px; background: var(--line-strong); }
.cof-steps b { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line-strong); font-weight: 600; font-size: 0.75rem; }
.cof-steps .is-on { color: var(--text); font-weight: 600; }
.cof-steps .is-on b { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.cof-steps .is-done b { background: var(--ok); border-color: var(--ok); color: #fff; }
/* on a phone only the current step is named (the others stay readable to
   screen readers) */
@media (max-width: 520px) {
  .cof-steps li:not(.is-on) span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* a store device handed to the customer */
.cof-handover {
  display: flex; gap: 0.75rem; align-items: flex-start; margin-bottom: 1.25rem;
  padding: 0.85rem 1rem; border-radius: var(--r-sm); background: var(--accent-soft); color: var(--text); font-size: 0.95rem;
}

/* an amount and what it is made of */
.cof-sum { display: grid; grid-template-columns: 1fr auto; gap: 0.35rem 0; margin: 0; font-size: 0.97rem; }
.cof-sum dt { color: var(--text-2); padding-right: 1rem; }
.cof-sum dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.cof-sum .is-total { padding-top: 0.5rem; border-top: 1px solid var(--line); font-weight: 700; color: var(--text); font-size: 1.05rem; }

/* choosing a card: one row each */
.cof-opts { display: grid; gap: 0.5rem; margin: 0; padding: 0; border: 0; }
.cof-opt {
  display: flex; align-items: center; gap: 0.7rem; padding: 0.7rem 0.85rem;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); cursor: pointer;
}
.cof-opt:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.cof-opt:has(input:disabled) { cursor: not-allowed; opacity: 0.6; }
.cof-opt input { width: 18px; height: 18px; accent-color: var(--accent); flex: 0 0 auto; }
.cof-opt__text { flex: 1 1 auto; min-width: 0; }
.cof-opt__title { display: block; font-weight: 600; }
.cof-opt__meta { display: block; font-size: 0.85rem; color: var(--text-3); }

/* the QR a customer scans at the counter */
.cof-qr { display: grid; justify-items: center; gap: 0.5rem; padding: 1rem; text-align: center; }
.cof-qr svg { width: min(220px, 60vw); height: auto; background: #fff; padding: 10px; border-radius: 12px; }

.cof-note { font-size: 0.88rem; color: var(--text-3); line-height: 1.55; }
.cof-lock { display: inline-flex; align-items: center; gap: 0.35rem; }
.cof-lock svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; }

/* the cart drawer's saved-card block */
.drawer__cof { display: grid; gap: 0.6rem; margin: 0.25rem 0 0.75rem; }
.drawer__cof[hidden] { display: none; }
.drawer__cof .cof-opt { padding: 0.55rem 0.7rem; }
.drawer__cof select.input { padding-block: 0.55rem; }
.drawer__cof-save { display: grid; gap: 0.5rem; padding: 0.7rem 0.8rem; border: 1px solid var(--line); border-radius: var(--r-sm); }
.drawer__cof-save[hidden] { display: none; }

/* the saved-card block can make the cart's footer taller than the window:
   the footer then scrolls on its own, and the pay button stays in view at
   its foot. Only while the block shows — the cart is otherwise unchanged. */
.drawer__foot:has(.drawer__cof:not([hidden])) {
  max-height: min(80dvh, calc(100dvh - 96px)); overflow-y: auto; overscroll-behavior: contain;
}
.drawer__foot:has(.drawer__cof:not([hidden])) #checkoutBtn {
  position: sticky; bottom: 0; z-index: 1; box-shadow: 0 -12px 16px -4px var(--surface-2, var(--surface));
}

/* the storefront does not load dashboard.css: the drawer's own form bits */
.drawer__cof .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.drawer__cof .label { display: block; font-size: 0.85rem; font-weight: 600; margin: 0 0 0.3rem; color: var(--text); }
.drawer__cof .input {
  width: 100%; padding: 0.55rem 0.7rem; border: 1px solid var(--line-strong); border-radius: var(--r-xs);
  background: var(--surface); color: var(--text); font: inherit; font-size: 0.95rem;
}
.drawer__cof .input:focus { outline: 2px solid var(--accent-ring); outline-offset: 1px; border-color: var(--accent); }
.drawer__cof .checkline { display: flex; gap: 0.55rem; align-items: flex-start; font-size: 0.92rem; line-height: 1.45; cursor: pointer; }
.drawer__cof .checkline input { flex: none; width: 18px; height: 18px; margin-top: 1px; accent-color: var(--accent); cursor: pointer; }
.drawer__cof .cof-note a, .cof-note a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.drawer__cof .cof-agreement { font-size: 0.88rem; padding: 0.75rem 0.85rem; }

/* a card sheet opened from the Store Portal's payment panel sits above it */
.sheet-scrim.cof-over { z-index: 320; }

@media (prefers-reduced-motion: reduce) {
  .cof-opt, .cof-card { transition: none; }
}
