/* ============================================================
   💳 Checkout + billing page (js/billing.js)
   Calm, Stripe-like surfaces in the site's own tokens: a tinted
   order summary next to a white payment panel; one column on
   phones, two side by side from 860px.
   ============================================================ */

.screen-checkout, .screen-billing { background: #f6f8fa; }
/* our own display rules (grid, flex) would otherwise beat the hidden attribute */
.screen-checkout [hidden], .screen-billing [hidden] { display: none !important; }
.co-topbar { background: #fff; border-bottom: 1px solid var(--gray-border); }
.co-topbar-title { font-weight: 800; font-size: 16px; color: var(--navy); display: flex; gap: 6px; align-items: center; }

.co-body, .bl-body { flex: 1; overflow-y: auto; padding: 16px 16px 48px; }
.co-grid {
  display: grid; grid-template-columns: 1fr; gap: 16px;
  max-width: 980px; margin: 0 auto;
}
@media (min-width: 860px) {
  .co-body { padding: 32px 28px 56px; }
  .co-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 28px; align-items: start; }
  .co-summary { position: sticky; top: 0; }
}

/* ── order summary ───────────────────────────────────────── */
.co-summary {
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-shade) 100%);
  color: #fff; border-radius: 20px; padding: 22px 22px 18px;
  box-shadow: 0 10px 30px rgba(22, 40, 56, .18);
}
.co-brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 14px; color: #c9d4e6; }
.co-brand-logo {
  width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center;
  background: rgba(255,255,255,.12); font-size: 16px;
}
.co-plan-head { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
.co-plan-icon {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  background: rgba(255,255,255,.1); font-size: 24px; flex-shrink: 0;
}
.co-plan-label { font-size: 12.5px; color: #a9b6cc; font-weight: 700; }
.co-plan-name { font-size: 20px; font-weight: 800; line-height: 1.3; }
.co-price { font-size: 36px; font-weight: 800; margin-top: 14px; line-height: 1.1; }
.co-price small { font-size: 15px; color: #c9d4e6; font-weight: 700; }
.co-price-usd { font-size: 13px; color: #ffcf95; font-weight: 700; margin-top: 4px; }
.co-plan-tagline { font-size: 13.5px; color: #c9d4e6; margin-top: 10px; line-height: 1.6; }
.co-features { list-style: none; margin: 14px 0 0; display: flex; flex-direction: column; gap: 7px; }
.co-features li { font-size: 13.5px; color: #e6edf7; display: flex; gap: 8px; line-height: 1.5; }
.co-features li::before { content: '✓'; color: #7ee0b5; font-weight: 900; }
.co-lines { margin-top: 18px; border-top: 1px solid rgba(255,255,255,.14); padding-top: 12px; }
.co-line { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; color: #dbe4f0; padding: 6px 0; }
.co-line span:last-child { white-space: nowrap; unicode-bidi: isolate; }
.co-line-total { border-top: 1px solid rgba(255,255,255,.14); margin-top: 6px; padding-top: 12px; font-size: 16px; color: #fff; font-weight: 800; }
.co-switch {
  background: rgba(255,255,255,.1); color: #ffe08a; border: 1px dashed rgba(255,224,138,.5);
  font-family: var(--font); font-weight: 800; font-size: 12.5px;
  border-radius: 999px; padding: 5px 12px; cursor: pointer; margin: 2px 0 6px;
}
.co-switch:hover { background: rgba(255,255,255,.16); }
.co-renew-note { font-size: 12px; color: #a9b6cc; margin-top: 12px; line-height: 1.6; }

/* ── payment panel ───────────────────────────────────────── */
.co-pay {
  background: #fff; border: 1px solid #e3e8ee; border-radius: 20px; padding: 22px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.co-pay-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.co-pay-title { font-size: 18px; font-weight: 800; color: var(--navy); }
.co-accepted { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-soft); }
.co-accepted > span:last-child { display: flex; gap: 6px; }

.co-methods { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.co-method {
  position: relative; display: flex; align-items: center; gap: 12px;
  border: 1.5px solid #e3e8ee; border-radius: 14px; padding: 14px 14px;
  cursor: pointer; background: #fff; transition: border-color .15s, box-shadow .15s, background .15s;
}
.co-method:hover { border-color: #c9d2dc; }
.co-method.selected { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(28,107,120,.14); background: #fbfefe; }
.co-method input { position: absolute; opacity: 0; pointer-events: none; }
.co-method:focus-within { outline: 2px solid var(--primary); outline-offset: 2px; }
.co-method-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.co-method-text b { font-size: 15px; color: var(--navy); font-weight: 800; direction: ltr; text-align: right; }
.co-method-text small { font-size: 12.5px; color: var(--text-soft); font-weight: 700; }
.co-method-marks { display: flex; gap: 4px; }
.co-radio {
  width: 20px; height: 20px; border-radius: 50%; border: 2px solid #c9d2dc; flex-shrink: 0;
  display: grid; place-items: center; transition: border-color .15s;
}
.co-method.selected .co-radio { border-color: var(--primary); }
.co-method.selected .co-radio::after { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.co-new-icon {
  width: 44px; height: 30px; border-radius: 7px; border: 1.5px dashed #c9d2dc;
  display: grid; place-items: center; color: var(--primary); font-weight: 900; font-size: 16px; flex-shrink: 0;
}
.co-new-info {
  font-size: 13px; line-height: 1.7; color: var(--primary-text); font-weight: 700;
  background: var(--primary-light); border-radius: 12px; padding: 11px 14px;
}

.co-error {
  display: none; margin-top: 14px; font-size: 13.5px; font-weight: 800; line-height: 1.6;
  background: var(--red-light); color: var(--red-shade); border-radius: 12px; padding: 10px 14px;
}
.co-error.show { display: block; }
.co-pay-btn {
  width: 100%; margin-top: 18px; font-size: 17px; padding: 15px 18px;
  background: var(--primary); box-shadow: 0 4px 0 var(--primary-shade);
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.co-pay-btn:disabled { opacity: .7; cursor: default; }
.co-secure {
  display: flex; gap: 10px; align-items: flex-start; margin-top: 16px;
  font-size: 12.5px; color: var(--text-soft); line-height: 1.6; font-weight: 700;
}
.co-secure svg { width: 20px; height: 20px; color: var(--correct); flex-shrink: 0; margin-top: 1px; }
.co-terms { font-size: 11.5px; color: #9aa3ad; margin-top: 10px; line-height: 1.7; }
.co-terms .btn-linklike { font-size: 11.5px; }
.co-loading { display: flex; align-items: center; gap: 10px; color: var(--text-soft); font-size: 14px; padding: 14px 4px; }

/* ── card brand marks ────────────────────────────────────── */
.card-mark {
  display: inline-grid; place-items: center; flex-shrink: 0;
  background: #fff; border: 1px solid #e3e8ee; border-radius: 6px;
}
.card-mark svg { width: 100%; height: 100%; }
.card-mark-md { width: 44px; height: 30px; padding: 5px 6px; }
.card-mark-sm { width: 34px; height: 22px; padding: 3px 4px; vertical-align: middle; }
.card-mark-generic { color: var(--text-soft); }

/* ── spinner ─────────────────────────────────────────────── */
.co-spinner {
  width: 16px; height: 16px; border-radius: 50%; display: inline-block;
  border: 2.5px solid #d5dde5; border-top-color: var(--primary);
  animation: coSpin .8s linear infinite;
}
.co-spinner-light { border-color: rgba(255,255,255,.4); border-top-color: #fff; }
.co-spinner-big { width: 44px; height: 44px; border-width: 4px; }
@keyframes coSpin { to { transform: rotate(360deg); } }

/* ── result (paid / failed / waiting) ────────────────────── */
.co-result {
  max-width: 460px; margin: 40px auto 0; text-align: center;
  background: #fff; border: 1px solid #e3e8ee; border-radius: 24px; padding: 34px 24px 26px;
  box-shadow: 0 10px 30px rgba(22, 40, 56, .08);
}
.co-result-icon {
  width: 76px; height: 76px; border-radius: 50%; margin: 0 auto 14px;
  display: grid; place-items: center; font-size: 38px; font-weight: 900;
}
.co-result-ok .co-result-icon { background: var(--correct-light); color: var(--correct); animation: coPop .45s cubic-bezier(.2,1.6,.4,1) both; }
.co-result-fail .co-result-icon { background: var(--red-light); color: var(--red-shade); }
.co-result-title { font-size: 22px; font-weight: 800; color: var(--navy); }
.co-result-sub { font-size: 14.5px; color: var(--text-soft); line-height: 1.7; margin-top: 8px; }
.co-result-actions { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 20px; }
@keyframes coPop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ── billing page ────────────────────────────────────────── */
.bl-body { display: flex; flex-direction: column; gap: 18px; max-width: 720px; width: 100%; margin: 0 auto; }
.bl-title { font-size: 15px; font-weight: 800; color: var(--navy); margin: 0 4px 8px; }
.bl-box { background: #fff; border: 1px solid #e3e8ee; border-radius: 18px; padding: 18px; }
.bl-box-list { padding: 6px 18px; }
.bl-foot { font-size: 12px; color: var(--text-soft); margin: 8px 4px 0; line-height: 1.6; }
.bl-alert {
  background: var(--red-light); color: var(--red-shade); border-radius: 14px;
  padding: 12px 16px; font-size: 13.5px; line-height: 1.7;
}

.bl-plan-row { display: flex; align-items: center; gap: 12px; }
.bl-plan-icon {
  width: 46px; height: 46px; border-radius: 14px; background: var(--navy-light);
  display: grid; place-items: center; font-size: 24px; flex-shrink: 0;
}
.bl-plan-info { flex: 1; min-width: 0; }
.bl-plan-name { font-size: 18px; font-weight: 800; color: var(--navy); }
.bl-plan-meta { font-size: 13px; color: var(--text-soft); margin-top: 2px; }
.bl-plan-when { margin-top: 14px; font-size: 14px; color: var(--text); }
.bl-plan-card {
  margin-top: 10px; font-size: 13.5px; color: var(--text-soft); display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.bl-plan-card b { direction: ltr; color: var(--navy); }
.bl-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.bl-actions .btn { flex: 1 1 160px; font-size: 14.5px; padding: 11px 14px; }
.bl-hint { font-size: 13px; color: var(--text-soft); line-height: 1.7; margin-top: 10px; }
.bl-empty-plan { text-align: center; padding: 6px 0; }
.bl-empty-plan .btn { margin-top: 12px; padding: 11px 26px; }
.bl-empty-icon { font-size: 34px; }

.bl-pill {
  display: inline-block; font-size: 11.5px; font-weight: 800; padding: 3px 10px;
  border-radius: 999px; white-space: nowrap;
}
.bl-pill-ok { background: var(--correct-light); color: var(--correct-shade); }
.bl-pill-warn { background: #fff4d6; color: #9a6a00; }
.bl-pill-bad { background: var(--red-light); color: var(--red-shade); }
.bl-pill-off { background: #eef1f4; color: #6b7682; }
.bl-pill-default { background: var(--navy-light); color: var(--navy); }

.bl-card-row, .bl-history-row {
  display: flex; align-items: center; gap: 12px; padding: 14px 0;
  border-bottom: 1px solid #eef1f4;
}
.bl-card-row:last-child, .bl-history-row:last-child { border-bottom: none; }
.bl-card-text, .bl-history-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bl-card-text b { font-size: 15px; color: var(--navy); direction: ltr; text-align: right; }
.bl-card-text small, .bl-history-main small { font-size: 12.5px; color: var(--text-soft); }
.bl-history-main b { font-size: 14.5px; color: var(--navy); }
.bl-history-amount { font-size: 14.5px; font-weight: 800; color: var(--navy); white-space: nowrap; unicode-bidi: isolate; }
.bl-link {
  background: none; border: none; font-family: var(--font); font-weight: 800; font-size: 12.5px;
  color: var(--primary); cursor: pointer; padding: 4px 6px; white-space: nowrap;
}
.bl-icon-btn {
  background: none; border: none; cursor: pointer; color: #9aa3ad; padding: 6px; border-radius: 8px;
  display: grid; place-items: center;
}
.bl-icon-btn svg { width: 20px; height: 20px; }
.bl-icon-btn:hover { color: var(--red-shade); background: var(--red-light); }
.bl-empty { display: flex; align-items: center; gap: 12px; color: var(--text-soft); font-size: 14px; padding: 14px 0; line-height: 1.6; }

/* ── new card form (Stripe Elements) ─────────────────────── */
.co-card-form {
  margin-top: -2px; padding: 16px 14px 14px; border: 1.5px solid var(--primary); border-top: none;
  border-radius: 0 0 14px 14px; background: #fbfefe; box-shadow: 0 0 0 3px rgba(28,107,120,.14);
  animation: coSlide .22s ease-out both;
}
/* the "new card" row and the form read as one card */
.co-methods:has(+ .co-card-form:not([hidden])) .co-method-new { border-radius: 14px 14px 0 0; box-shadow: none; }
@keyframes coSlide { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.co-field-label { display: block; font-size: 13px; font-weight: 800; color: var(--navy); margin: 0 2px 6px; }
.co-field-label:not(:first-child) { margin-top: 12px; }
.co-input, .co-stripe-box {
  width: 100%; box-sizing: border-box; background: #fff; border: 1.5px solid #dfe5eb; border-radius: 12px;
  padding: 11px 13px; transition: border-color .15s, box-shadow .15s;
}
.co-input { font-family: var(--font); font-size: 16px; font-weight: 600; color: var(--navy); outline: none; }
.co-input::placeholder { color: #9aa3ad; }
.co-input:focus, .co-stripe-box.is-focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(28,107,120,.15); }
.co-stripe-box.is-invalid { border-color: var(--red); box-shadow: 0 0 0 3px rgba(255,75,75,.12); }
.co-stripe-box { min-height: 48px; }
.co-stripe-wrap { position: relative; }
.co-stripe-wrap .co-stripe-box { padding-right: 56px; }
.co-card-brand { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.co-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.co-card-error { min-height: 0; font-size: 12.5px; font-weight: 800; color: var(--red-shade); margin: 8px 2px 0; }
.co-card-error:empty { display: none; }
.co-save-card {
  display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; cursor: pointer;
  background: var(--primary-light); border-radius: 12px; padding: 11px 12px;
}
.co-save-card input { position: absolute; opacity: 0; pointer-events: none; }
.co-check {
  width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--primary); background: #fff;
  flex-shrink: 0; display: grid; place-items: center; margin-top: 2px; transition: background .15s;
}
.co-save-card input:checked + .co-check { background: var(--primary); }
.co-save-card input:checked + .co-check::after { content: '✓'; color: #fff; font-size: 13px; font-weight: 900; line-height: 1; }
.co-save-card input:focus-visible + .co-check { outline: 2px solid var(--primary); outline-offset: 2px; }
.co-save-text { display: flex; flex-direction: column; gap: 2px; }
.co-save-text b { font-size: 13.5px; color: var(--primary-text); }
.co-save-text small { font-size: 12px; color: var(--primary-text); opacity: .85; line-height: 1.6; font-weight: 600; }
.co-secure-sm { margin-top: 12px; font-size: 12px; }

/* ── billing page: add card ──────────────────────────────── */
.bl-add-card {
  width: 100%; margin: 6px 0 12px; padding: 12px; border-radius: 12px;
  border: 1.5px dashed #c9d2dc; background: #fafcfd; color: var(--primary);
  font-family: var(--font); font-weight: 800; font-size: 14.5px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px; transition: background .15s, border-color .15s;
}
.bl-add-card:hover { background: var(--primary-light); border-color: var(--primary); }
.bl-add-card span { font-size: 18px; }

/* ── dialogs (cancel, remove card, add card) ─────────────── */
.bl-dialog-wrap {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 16px;
  background: rgba(22, 40, 56, .45); backdrop-filter: blur(3px);
  opacity: 0; transition: opacity .18s;
}
.bl-dialog-wrap.open { opacity: 1; }
.bl-dialog {
  width: 100%; max-width: 420px; max-height: calc(100vh - 32px); overflow-y: auto;
  background: #fff; border-radius: 22px; padding: 24px 22px 20px; text-align: center;
  box-shadow: 0 20px 60px rgba(22, 40, 56, .3);
  transform: translateY(12px) scale(.97); transition: transform .2s cubic-bezier(.2,1.3,.4,1);
}
.bl-dialog-wrap.open .bl-dialog { transform: none; }
.bl-dialog-card { text-align: right; }
.bl-dialog-card .bl-dialog-icon, .bl-dialog-card .bl-dialog-title, .bl-dialog-card .bl-dialog-body { text-align: center; }
.bl-dialog-icon { font-size: 40px; line-height: 1; }
.bl-dialog-title { font-size: 19px; font-weight: 800; color: var(--navy); margin-top: 10px; }
.bl-dialog-body { font-size: 14px; color: var(--text-soft); line-height: 1.75; margin: 8px 0 14px; }
.bl-dialog-body b { color: var(--navy); }
.bl-dialog-lose-title { margin-top: 10px; font-weight: 800; color: var(--text); }
.bl-dialog-lose { list-style: none; margin: 6px auto 0; padding: 0; display: inline-flex; flex-direction: column; gap: 4px; text-align: right; }
.bl-dialog-lose li::before { content: '✕ '; color: var(--red-shade); font-weight: 900; }
.bl-dialog-hint { font-size: 12.5px; margin-top: 10px; }
.bl-dialog-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.bl-dialog-actions .btn { width: 100%; padding: 12px 16px; font-size: 15px; }
.btn-danger { background: var(--red); color: #fff; box-shadow: 0 4px 0 var(--red-shade); }
.btn-danger:active { box-shadow: 0 0 0 var(--red-shade); transform: translateY(4px); }

/* paywall: the accepted cards next to the payment note */
.paywall-pay-note { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
#paywall-marks { display: inline-flex; gap: 4px; }

/* phones: the learner just saw the features on the paywall — keep the
   summary short so the payment panel is in view without scrolling */
@media (max-width: 859px) {
  .co-features, .co-plan-tagline { display: none; }
  .co-plan-head { margin-top: 12px; }
  .co-price { font-size: 30px; margin-top: 10px; }
}
@media (max-width: 420px) {
  .co-pay, .co-summary { padding: 18px 16px; }
  .co-price { font-size: 30px; }
  .co-method-marks { display: none; }
  .bl-card-row { flex-wrap: wrap; }
}
@media (max-width: 380px) {
  .co-field-row { grid-template-columns: 1fr; gap: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .co-spinner { animation-duration: 2s; }
  .co-card-form, .bl-dialog { animation: none; transition: none; }
  .co-result-ok .co-result-icon { animation: none; }
}
