/*
 * HPAY Subscriptions (/hpay/subscriptions). Builds on hpay-tools.css (.ht-*) and the HPAY workspace paper; base.css tokens
 * only (ink, line, red, fg, ok, warn, display, body, mono). One accent: red marks the primary action and paid time; green,
 * amber and red are status only. Square corners and hairline rules like the rest of the workspace. Numbers are tabular.
 *
 * Signature: paid time is drawn as LED cells, one cell per day of the current period window, lit while paid. The cells
 * run down with the chain clock, so the page shows how much time you have the way a meter would.
 */
/* Workspace: the action column on the left, the live plans board above the activity log on the right. */
.sb-grid { --cols: minmax(320px, 1fr) minmax(0, 1.2fr); grid-template-areas: "action plans" "action activity"; grid-template-rows: auto 1fr; }
.sb-grid > #sb-panel-action { grid-area: action; }
.sb-grid > #sb-panel-plans { grid-area: plans; }
.sb-grid > #sb-panel-activity { grid-area: activity; border-top: 1px solid var(--line-2); }

.sb-terms { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: var(--s5); }
.sb-terms dd { font-variant-numeric: tabular-nums; }

/* the plan card */
.sb-plan { border: 1px solid var(--line-2); padding: var(--s4); margin: 0 0 var(--s4); }
.sb-plan-kicker { margin: 0; font: 500 var(--t-xs)/1.4 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--fg-3); }
.sb-plan-name { margin: var(--s1) 0 0; font: 700 clamp(22px, 2.6vw, 30px)/1.1 var(--display); letter-spacing: -0.02em; overflow-wrap: anywhere; }
.sb-plan-price { margin: var(--s2) 0 0; font: 600 var(--t-lg)/1.3 var(--mono); }
.sb-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3) var(--s4); margin: var(--s4) 0; padding-top: var(--s3); border-top: 1px solid var(--line); }
.sb-facts dt { font: 500 var(--t-xs)/1.3 var(--body); letter-spacing: .12em; text-transform: uppercase; color: var(--fg-3); margin: 0 0 2px; }
.sb-facts dd { margin: 0; font: var(--t-sm)/1.5 var(--mono); overflow-wrap: anywhere; }

/* paid time: LED cells */
.sb-time { margin: 0 0 var(--s4); padding-top: var(--s3); border-top: 1px solid var(--line); }
.sb-time-label { margin: 0 0 var(--s2); font: var(--t-sm)/1.5 var(--mono); color: var(--fg-2); }
.sb-time[data-state="active"] .sb-time-label { color: var(--fg); }
.sb-cells { display: grid; grid-template-columns: repeat(var(--n, 30), minmax(0, 1fr)); gap: 2px; height: 14px; }
.sb-cells:empty { display: none; }
.sb-cell { background: var(--line-2); }
.sb-cell[data-lit] { background: var(--red); }
.sb-cell[data-today] { background: var(--red-hi); animation: sb-pulse 1.6s var(--ease) infinite; }
@keyframes sb-pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .sb-cell[data-today] { animation: none; } }

/* periods stepper */
.sb-stepper { display: grid; grid-template-columns: 52px minmax(0, 1fr) 52px; gap: var(--s2); align-items: stretch; }
.sb-stepper .btn { min-height: 52px; justify-content: center; font: 600 var(--t-lg) var(--mono); }
.sb-stepper input { text-align: center; }

/* the exact split ledger */
.sb-ledger { width: 100%; border-collapse: collapse; margin: var(--s4) 0 var(--s2); font: var(--t-sm)/1.5 var(--mono); }
.sb-ledger th { text-align: left; font-weight: 400; color: var(--fg-2); padding: var(--s2) var(--s2) var(--s2) 0; border-bottom: 1px solid var(--line); }
.sb-ledger td { text-align: right; padding: var(--s2) 0; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
.sb-ledger th span { color: var(--fg-3); }
.sb-ledger-total th, .sb-ledger-total td { color: var(--fg); font-weight: 600; border-bottom: 1px solid var(--line-2); }

/* the running transaction */
.sb-op { margin-top: var(--s4); padding: var(--s4); border: 1px solid var(--line-2); border-left: 3px solid var(--fg-3); }
.sb-op[data-state="pending"], .sb-op[data-state="awaiting wallet"] { border-left-color: var(--warn); }
.sb-op[data-state="confirmed"] { border-left-color: var(--ok); }
.sb-op[data-state="failed"], .sb-op[data-state="unknown"] { border-left-color: var(--red-hi); }
.sb-op-state { margin: 0; font: 600 var(--t-md)/1.4 var(--display); }

/* plans table */
.sb-filter { min-height: 44px; width: min(240px, 100%); }
#sb-plans td .sb-status { font-size: var(--t-xs); }
#sb-plans td .sb-status[data-state="active"] { color: var(--ok); }
#sb-plans td .sb-status[data-state="lapsed"] { color: var(--warn); }
#sb-plans tr[aria-current="true"] td:first-child { box-shadow: inset 3px 0 0 var(--red); padding-left: var(--s2); }

/* Dialogs sit outside main.ht-page, so they carry the page's spacing and type scale themselves. */
.sb-dialog {
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --t-xs: 11px; --t-sm: 12px; --t-base: 14px; --t-md: 16px; --t-lg: 20px; --t-xl: 28px;
  --ease: cubic-bezier(.2, 0, .2, 1);
  font-variant-numeric: tabular-nums;
  width: min(520px, calc(100vw - 32px));
}
.sb-dialog .ht-btn-row .btn { flex: 1 1 0; justify-content: center; min-height: 48px; }
.sb-raw { margin: var(--s2) 0 0; padding: var(--s3); max-height: 220px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--t-xs); border: 1px solid var(--line); }

@media (max-width: 820px) {
  .sb-grid > #sb-panel-activity { border-top: 0; }
  .sb-terms { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sb-facts { grid-template-columns: minmax(0, 1fr); }
  .sb-filter { width: 100%; }
}
