/*
 * Training store: cart, checkout, success (docs/plans/marketing-site-phase-3.md, slice S5), plus the buying pieces on
 * the hub and the course pages (docs/plans/website-conversion-plan.md, Phase A / A5: seat picker, whole-district
 * preset, phone Add bar). Loaded as /site/store.css?v=N after /site/site.css on the store pages, the hub and the three
 * course pages. Same tokens as site.css; no new colours. The store-page rules are scoped under main.store, because
 * the store scripts build markup with generic class names (.panel, .line, .summary, .amt …) that must not leak into,
 * or pick up rules from, the rest of the site; the hub/course rules use their own class names (end of the file).
 * The class names are a contract with the inline store scripts (§6 of the plan; tested in site-routes.test.js).
 * Money: mono stack, tabular figures, right-aligned, two decimals (the scripts format the figures).
 */

/* ── Page frame ─────────────────────────────────────────────────────────── */
main.store .store-hero { padding-bottom: clamp(24px, 3vw, 36px); }
main.store .store-hero h1 { font-size: clamp(2.1rem, 3.6vw, 2.9rem); }
main.store .store-hero .lede { margin: 14px 0 0; }
main.store .store-body { padding-top: 0; }
main.store [hidden] { display: none !important; }
main.store .amt, main.store .line-total, main.store .line-unit .price, main.store .order-no {
  font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: 0;
}

/* Two columns: the work on the left, the order summary on the right (sticky on wide screens) */
main.store .store-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: 28px clamp(28px, 4vw, 48px); align-items: start;
}
main.store .panel {
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: clamp(20px, 3vw, 32px);
}
main.store .summary { box-shadow: var(--shadow-shot); }
main.store .summary-head, main.store .step-head {
  font-size: 1.4rem; line-height: 1.2; letter-spacing: -.01em; max-width: none; margin-bottom: 18px;
}
@media (min-width: 900px) {
  main.store .summary { position: sticky; top: calc(var(--header-h) + 24px); }
}
@media (max-width: 899.98px) {
  main.store .store-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ── Cart lines ─────────────────────────────────────────────────────────── */
main.store .lines { padding-block: 4px; }
main.store .line {
  display: grid; grid-template-columns: minmax(0, 1fr) auto 7.5em; gap: 12px 24px; align-items: center;
  padding: 22px 0;
}
main.store .line + .line { border-top: 1px solid var(--rule); }
main.store .line-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
main.store .line-name { font-family: var(--display); font-weight: 700; font-size: 1.3rem; line-height: 1.2; }
main.store .line-code {
  font: 600 .9rem/1 var(--body); color: var(--water-deep); background: var(--wash); border: 1px solid var(--wash-2);
  border-radius: 6px; padding: 4px 7px; letter-spacing: .03em;
}
main.store .line-meta { color: var(--ink-2); font-size: 1rem; margin-top: 4px; }
main.store .line-unit { font-size: 1rem; margin-top: 2px; color: var(--ink); }
main.store .line-unit .per { color: var(--ink-2); }
main.store .line-remove {
  display: inline-flex; align-items: center; min-height: 44px; margin: 2px 0 -10px; padding: 0;
  font: 500 1rem/1 var(--body); color: var(--ink-2); background: none; border: 0; cursor: pointer;
  text-decoration: underline; text-underline-offset: .2em; text-decoration-color: var(--rule-strong);
}
main.store .line-remove:hover { color: var(--danger); text-decoration-color: currentColor; }
main.store .line-total { text-align: right; font-size: 1.1rem; font-weight: 600; white-space: nowrap; }

/* Quantity stepper: 44 px targets */
main.store .stepper {
  display: inline-flex; align-items: stretch; border: 1.5px solid var(--rule-strong); border-radius: 10px;
  background: var(--surface);
}
main.store .stepper button {
  width: 44px; min-height: 44px; border: 0; background: none; color: var(--ink); cursor: pointer;
  font: 500 1.35rem/1 var(--body); border-radius: 8px;
}
main.store .stepper button:hover { background: var(--wash); color: var(--water-deep); }
main.store .stepper button:focus-visible { outline-offset: -2px; }
main.store .stepper input {
  width: 3.4em; border: 0; border-inline: 1px solid var(--rule); text-align: center; background: none;
  font: 600 1.05rem/1 var(--mono); font-variant-numeric: tabular-nums; color: var(--ink);
  -moz-appearance: textfield; appearance: textfield;
}
main.store .stepper input::-webkit-outer-spin-button,
main.store .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
main.store .stepper input:focus-visible { outline-offset: -2px; border-radius: 2px; }

@media (max-width: 599.98px) {
  main.store .line { grid-template-columns: auto minmax(0, 1fr); padding: 20px 0; }
  main.store .line-info { grid-column: 1 / -1; }
  main.store .line-total { align-self: center; }
}

/* ── Order summary ──────────────────────────────────────────────────────── */
main.store .sum-row, main.store .mini-line {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px; font-size: 1rem;
}
main.store .sum-row + .sum-row, main.store .mini-line + .mini-line { margin-top: 8px; }
main.store .sum-row .amt, main.store .mini-line .amt { text-align: right; white-space: nowrap; }
main.store .muted { color: var(--ink-2); }
main.store .discount { color: var(--success); font-weight: 600; }
main.store .mini-line .qty { color: var(--ink-2); font-family: var(--mono); font-variant-numeric: tabular-nums; margin-left: 4px; }
main.store #summary-lines { padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--rule); }
/* Checkout fills these after it prices the cart: hold the smallest filled size (one line; subtotal and total) so the
 * fine print below doesn't jump down when they arrive (layout shift). Only while empty, so it never adds space. */
main.store #summary-lines:empty { min-height: 40px; }
main.store #summary-totals:empty { min-height: 95px; }
main.store .vol-note { margin-top: 12px; font-size: 1rem; line-height: 1.45; color: var(--success); font-weight: 500; }
main.store .vol-note.dim { color: var(--ink-2); font-weight: 400; }
main.store .sum-total {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--rule-strong);
}
main.store .sum-total .lbl { font-family: var(--display); font-weight: 700; font-size: 1.3rem; }
main.store .sum-total .amt { font-size: 1.45rem; font-weight: 700; }
main.store .summary .btn { width: 100%; margin-top: 20px; }
main.store .fineprint { margin-top: 16px; font-size: 1rem; line-height: 1.5; color: var(--ink-2); }
main.store .fineprint a { color: var(--water-deep); }
main.store .edit-cart { display: inline-flex; align-items: center; min-height: 44px; margin-top: 4px; font-size: 1rem; font-weight: 600; }

/* Empty cart */
main.store .empty { max-width: 560px; }
main.store .empty h2 { font-size: 1.6rem; margin-bottom: 8px; }
main.store .empty p { color: var(--ink-2); margin-bottom: 20px; }

/* ── Checkout ───────────────────────────────────────────────────────────── */
main.store #buyer-form { display: grid; gap: 18px; }
main.store .field .opt { font-weight: 400; }
main.store .form-alert {
  padding: 12px 14px; border-left: 4px solid var(--danger); border-radius: 4px;
  color: var(--danger); font-weight: 600; font-size: 1rem; background: var(--page);
}
main.store .form-alert:empty { display: none; }
main.store #buyer-form .btn { width: 100%; }
main.store .checkout-steps:has(#pay-step:not([hidden])) #continue-btn { display: none; }   /* the Pay button takes over */
main.store .store-note { color: var(--ink-2); }
main.store #pay-step { margin-top: 28px; padding-top: 28px; border-top: 1px solid var(--rule); scroll-margin-top: calc(var(--header-h) + 24px); }
main.store #payment-element { margin-bottom: 20px; min-height: 40px; }
main.store #pay-btn { width: 100%; }
main.store .pay-status { margin-top: 14px; font-size: 1rem; font-weight: 600; }
main.store .pay-status:empty { display: none; }
main.store .pay-status.info { color: var(--ink-2); }
main.store .pay-status.err { color: var(--danger); }
main.store .lock { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 1rem; color: var(--ink-2); }
main.store .lock svg { flex: none; color: var(--water); }

/* ── Success ────────────────────────────────────────────────────────────── */
main.store .success-wrap { max-width: 640px; margin: 0 auto; text-align: center; padding: clamp(40px, 6vw, 72px) 0 var(--section-y); }
main.store .success-wrap .title { font-size: clamp(2.1rem, 3.8vw, 2.9rem); line-height: 1.08; margin: 0 auto; max-width: 20ch; }
main.store .success-wrap .sub { color: var(--ink-2); font-size: 1.12rem; max-width: 52ch; margin: 18px auto 0; }
main.store .success-wrap .sub strong { color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }
main.store .success-wrap > .btn { margin-top: 32px; }
main.store .order-no {
  display: inline-block; margin-top: 16px; padding: 6px 12px; border: 1px solid var(--rule-strong); border-radius: 8px;
  background: var(--surface); color: var(--ink); font-size: 1rem;
}
main.store .next-steps {
  text-align: left; margin: 28px auto 0; max-width: 56ch; padding: 20px 24px 20px 44px;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); color: var(--ink-2); font-size: 1rem;
}
main.store .next-steps li + li { margin-top: 10px; }
main.store .next-steps li::marker { color: var(--water); }
/* A quiet line about WUBS under the confirmation (Phase A / A5) */
main.store .cross-sell { margin: 40px auto 0; padding-top: 20px; border-top: 1px solid var(--rule); max-width: 56ch; color: var(--ink-2); font-size: 1rem; }
main.store .cross-sell a { color: var(--water-deep); font-weight: 600; }
main.store .checkmark {
  width: 72px; height: 72px; margin: 0 auto 24px; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid var(--success); color: var(--success);
}
main.store .checkmark svg { width: 34px; height: 34px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
@media (prefers-reduced-motion: no-preference) {
  /* Draws once when the page confirms the payment: it answers the buyer's action */
  main.store .checkmark path { stroke-dasharray: 26; stroke-dashoffset: 26; animation: store-draw .5s ease-out .15s forwards; }
}
@keyframes store-draw { to { stroke-dashoffset: 0; } }

/* Toast ("Removed"): same look as the site's cart toast */
main.store #toast {
  position: fixed; right: 24px; bottom: 24px; z-index: 50; max-width: 420px; padding: 14px 18px;
  border-radius: var(--radius); background: var(--surface); color: var(--ink); font-size: 1rem;
  border: 1px solid var(--rule); border-left: 4px solid var(--water); box-shadow: 0 18px 40px -18px rgba(28, 25, 23, .45);
  transform: translateY(calc(100% + 40px)); visibility: hidden;
  transition: transform .45s cubic-bezier(.34, 1.56, .64, 1), visibility 0s linear .45s;
}
main.store #toast.show { transform: none; visibility: visible; transition: transform .45s cubic-bezier(.34, 1.56, .64, 1); }
@media (max-width: 559.98px) { main.store #toast { left: 16px; right: 16px; bottom: 16px; max-width: none; } }
@media (prefers-reduced-motion: reduce) { main.store #toast, main.store #toast.show { transition: none; } }

/* ── Print (buyers print the confirmation) ─────────────────────────────── */
@media print {
  main.store .btn, main.store .stepper button, main.store .line-remove, main.store .edit-cart, main.store #toast,
  main.store #payment-element, main.store .lock, main.store .cross-sell { display: none !important; }
  main.store .panel, main.store .summary, main.store .next-steps, main.store .order-no { box-shadow: none; }
  main.store .summary { position: static; }
  main.store .success-wrap { padding: 0; }
  main.store .success-wrap .sub, main.store .next-steps, main.store .fineprint { color: #000; }
  main.store .checkmark path { animation: none; stroke-dashoffset: 0; }
}
main.store [tabindex="-1"]:focus { outline: none; }
/* After "Continue", the buyer details are fixed for this order: shown read-only */
main.store .field input:disabled { background: var(--page); color: var(--ink-2); border-color: var(--rule); }

/* ── Hub and course pages (Phase A / A5) ────────────────────────────────── */
/* Seat picker on the course page's price card: the cart's stepper look, 44 px targets, 1–99 seats */
.seat-pick { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 8px 14px; margin: 0 0 18px; }
.seat-pick label { grid-column: 1 / -1; font-weight: 600; font-size: 1rem; }
.seat-pick .stepper {
  display: inline-flex; align-items: stretch; border: 1.5px solid var(--rule-strong); border-radius: 10px; background: var(--surface);
}
.seat-pick .stepper button {
  width: 44px; min-height: 44px; border: 0; background: none; color: var(--ink); cursor: pointer;
  font: 500 1.35rem/1 var(--body); border-radius: 8px;
}
.seat-pick .stepper button:hover:not(:disabled) { background: var(--wash); color: var(--water-deep); }
.seat-pick .stepper button:disabled { color: var(--rule-strong); cursor: default; }
.seat-pick .stepper button:focus-visible { outline-offset: -2px; }
.seat-pick .stepper input {
  width: 3.2em; border: 0; border-inline: 1px solid var(--rule); text-align: center; background: none;
  font: 600 1.05rem/1 var(--mono); font-variant-numeric: tabular-nums; color: var(--ink);
  -moz-appearance: textfield; appearance: textfield;
}
.seat-pick .stepper input::-webkit-outer-spin-button,
.seat-pick .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.seat-pick .stepper input:focus-visible { outline-offset: -2px; border-radius: 2px; }
.seat-pick .seat-total { font-size: 1rem; line-height: 1.35; color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.seat-pick .seat-hint { display: block; color: var(--ink-2); font-weight: 400; }
.price-card .btn + .btn { margin-top: 10px; }

/* Whole-district preset on the hub, under the course rows */
.preset {
  display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 18px clamp(32px, 5vw, 72px); align-items: center;
  margin-top: 28px; padding: clamp(20px, 3vw, 28px); background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--radius); box-shadow: var(--shadow-shot);
}
.preset h3 { font-size: clamp(1.4rem, 2vw, 1.7rem); margin-bottom: 8px; }
.preset-main p { color: var(--ink-2); max-width: 62ch; }
.preset-main .preset-detail { margin-top: 6px; font-size: 1rem; font-variant-numeric: tabular-nums; }
.preset-buy { display: grid; gap: 10px; }
.preset-price { font-family: var(--display); font-weight: 700; font-size: 2.2rem; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.preset-price:empty { display: none; }
.preset-buy .btn { width: 100%; }
@media (max-width: 899.98px) {
  .preset { grid-template-columns: minmax(0, 1fr); }
  .preset-buy { max-width: 360px; }
}

/* Phone Add bar on the course pages (the site's .sticky-cta; shown by site.js once the price card scrolls away) */
.course-bar .bar-price { flex: 0 0 auto; align-self: center; font-size: 1rem; color: var(--ink-2); white-space: nowrap; }
.course-bar .bar-price b { font-family: var(--display); font-size: 1.35rem; color: var(--ink); font-variant-numeric: tabular-nums; margin-right: 4px; }
@media (max-width: 759.98px) {
  /* Steps aside while the closing band (with its own Add button) is on screen */
  .course-bar.is-shown.near-end { visibility: hidden; transform: translateY(110%); transition: transform .22s ease, visibility 0s linear .22s; }
  /* The "added" toast sits above the bar, not under it */
  body:has(> .course-bar) .cart-toast { bottom: calc(86px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) { .course-bar.is-shown.near-end { transition: none; } }
@media print { .seat-pick, .preset-buy .btn, .price-card .btn { display: none !important; } }
