/* ==========================================================================
   cart.css — cart.html
   Page-scoped only. Every value comes from css/tokens.css. The page classes
   below either wrap a shared component or stand entirely on their own; the
   only rules that reach into css/components.css are the contrast repairs
   marked in place, which lift text off --text-subtle.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Shell
   -------------------------------------------------------------------------- */
.cart-stepper { margin-top: var(--space-6); }

/* --text-subtle measures 3.7:1 on white and 4.4:1 on --surface-2, short of
   4.5:1 in both themes. The step hints tell a learner what happens next, so
   they are held at --text-muted until the token is retuned in tokens.css. */
.cart-stepper .step-hint { color: var(--text-muted); }

/* .cart-shell rides on .shell-aside. When the cart is empty the summary rail
   is not rendered at all, so the grid collapses to one full-width column. */
.cart-shell.is-single { grid-template-columns: minmax(0, 1fr); }

.cart-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-10);
  min-width: 0;
}

.cart-block {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  min-width: 0;
}

.cart-block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
}

.cart-block-title {
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-tight);
  color: var(--text);
}

.cart-block-count {
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.cart-list-note {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  line-height: var(--lh-relaxed);
}

/* --------------------------------------------------------------------------
   Line items
   -------------------------------------------------------------------------- */
.cart-list,
.saved-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

.cart-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "tile main price";
  gap: var(--space-4) var(--space-5);
  padding: var(--card-pad);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--dur-fast) var(--ease-standard),
              box-shadow var(--dur-fast) var(--ease-standard);
}
.cart-row:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.cart-row:focus-within { border-color: var(--primary-border); }

/* The gradient plate carries each course's own two stops, straight from data.js */
.cart-tile {
  grid-area: tile;
  background: linear-gradient(135deg, var(--course-from, var(--a-400)), var(--course-to, var(--a-600)));
  color: var(--text-on-brand);
}

.cart-row-main {
  grid-area: main;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
}

.cart-row-titles { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }

.cart-row-title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-tight);
  line-height: var(--lh-snug);
  color: var(--text);
}
.cart-row-title a { color: inherit; text-decoration: none; }
.cart-row-title a:hover { color: var(--primary); }

.cart-row-instructor {
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  color: var(--primary-soft-text);
}
.cart-row-instructor > span { color: var(--text-muted); font-weight: var(--fw-regular); }

/* --- tier selector ------------------------------------------------------- */
.cart-tier {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-top: var(--space-1);
}

.cart-tier-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
}

.cart-tier-label {
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--text-muted);
}

.cart-tier-hint {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  line-height: var(--lh-snug);
  max-width: 46ch;
}

/* --- row actions --------------------------------------------------------- */
.cart-row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding-top: var(--space-1);
}

/* --- price column -------------------------------------------------------- */
.cart-row-price {
  grid-area: price;
  align-items: flex-end;
  text-align: right;
  white-space: nowrap;
}
.cart-row-price .price-main { font-variant-numeric: tabular-nums; }
.cart-row-price .price-gst { display: block; }

/* "₹4,669.26 payable" is the figure a learner checks against the summary, so it
   is held at --text-muted. The shared .price-total default (--text-subtle) does
   not clear 4.5:1 in either theme. */
.cart-row-price .price-total { color: var(--text-muted); }

/* --------------------------------------------------------------------------
   Saved for later
   -------------------------------------------------------------------------- */
.saved-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3) var(--space-5);
  padding: var(--card-pad-tight);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-inset);
}

.saved-row-main { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }

.saved-row-title {
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
  color: var(--text);
  line-height: var(--lh-snug);
}
.saved-row-title a { color: inherit; text-decoration: none; }
.saved-row-title a:hover { color: var(--primary); }

.saved-row-meta {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.saved-row-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: flex-end; }

/* --------------------------------------------------------------------------
   Empty cart
   -------------------------------------------------------------------------- */
.cart-empty { padding-block: var(--space-14); }

.cart-empty-art {
  width: min(100%, 18rem);
  color: var(--border-strong);
  margin-bottom: var(--space-4);
}
.cart-empty-art > svg { width: 100%; height: auto; display: block; }
.cart-empty-art .art-plate { fill: var(--surface-2); stroke: currentColor; }
.cart-empty-art .art-line { stroke: currentColor; fill: none; }
.cart-empty-art .art-rule { stroke: var(--text-on-brand); fill: none; opacity: 0.85; }
.cart-empty-art .art-stop-a { stop-color: var(--a-400); }
.cart-empty-art .art-stop-b { stop-color: var(--a-600); }

.cart-empty h2 {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-extrabold);
  letter-spacing: var(--tracking-tight);
  color: var(--text);
}
.cart-empty p { max-width: 56ch; }

.cart-empty-points {
  list-style: none;
  margin: 0;
  padding: var(--space-6) 0 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-4);
  width: 100%;
  max-width: 46rem;
  text-align: left;
  border-top: 1px solid var(--border-subtle);
  margin-top: var(--space-4);
}

.cart-empty-point { display: flex; flex-direction: column; gap: var(--space-1); }
.cart-empty-point-title {
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  color: var(--text);
}
.cart-empty-point-text { font-size: var(--fs-sm); color: var(--text-muted); line-height: var(--lh-snug); }

/* --------------------------------------------------------------------------
   You might also like
   -------------------------------------------------------------------------- */
.recommend-rail { gap: var(--tile-gap); padding-bottom: var(--space-2); }

.rec-card {
  width: 17rem;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--card-pad-tight);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.rec-card-head { display: flex; align-items: flex-start; gap: var(--space-3); min-width: 0; }

.rec-card-title {
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-snug);
  color: var(--text);
}
.rec-card-title a { color: inherit; text-decoration: none; }
.rec-card-title a:hover { color: var(--primary); }

.rec-card-meta { font-size: var(--fs-xs); color: var(--text-muted); }
.rec-card-blurb {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  line-height: var(--lh-snug);
  flex: 1;
}
.rec-card-price {
  font-size: var(--fs-sm);
  color: var(--text);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
}
.rec-card-price > span { font-weight: var(--fw-regular); color: var(--text-muted); }

/* --------------------------------------------------------------------------
   Order summary rail
   -------------------------------------------------------------------------- */
.summary-body { display: flex; flex-direction: column; gap: var(--space-5); }

/* The GST explainer under the totals is the one line that tells a learner why
   the numbers add up the way they do — it is read, not decoration. */
.summary-body .totals-note { color: var(--text-muted); line-height: var(--lh-base); }

.summary-count-note { font-size: var(--fs-xs); color: var(--text-muted); }

.summary-foot { flex-direction: column; align-items: stretch; gap: var(--space-3); }

.summary-note {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  line-height: var(--lh-relaxed);
  text-align: center;
}

.summary-help-title {
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  color: var(--text);
  margin-bottom: var(--space-1);
}
.summary-help-text {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  line-height: var(--lh-relaxed);
  overflow-wrap: anywhere;
}

/* --- trust row ----------------------------------------------------------- */
.trust-list {
  list-style: none;
  margin: 0;
  padding: var(--space-4) 0 0;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.trust-item { display: flex; align-items: flex-start; gap: var(--space-3); }

.trust-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: var(--radius-full);
  background: var(--success-soft);
  color: var(--success-soft-text);
}
.trust-icon > svg { width: 1rem; height: 1rem; }

.trust-text { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.trust-name { font-size: var(--fs-md); font-weight: var(--fw-semibold); color: var(--text); }
.trust-hint { font-size: var(--fs-xs); color: var(--text-muted); line-height: var(--lh-snug); }

/* --- coupon -------------------------------------------------------------- */
.cart-coupon { display: block; }

/* The coupon service is unavailable in this release: a rejection shakes the
   block once so the inline warning is impossible to miss. Global reduced-motion
   rules in base.css neutralise this automatically. */
.cart-coupon.is-rejected { animation: cart-coupon-shake var(--dur-slow) var(--ease-standard) 1; }

@keyframes cart-coupon-shake {
  0%, 100% { transform: translateX(0); }
  15%      { transform: translateX(-0.4rem); }
  32%      { transform: translateX(0.34rem); }
  50%      { transform: translateX(-0.24rem); }
  68%      { transform: translateX(0.16rem); }
  85%      { transform: translateX(-0.08rem); }
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 860px) {
  .cart-empty-points { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 680px) {
  .cart-row {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "tile main"
      "price price";
  }
  .cart-row-price {
    align-items: flex-start;
    text-align: left;
    padding-top: var(--space-2);
    border-top: 1px solid var(--border-subtle);
  }
  .saved-row {
    grid-template-columns: auto minmax(0, 1fr);
  }
  .saved-row-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .rec-card { width: 15rem; }
}

@media (max-width: 420px) {
  .cart-row {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "tile" "main" "price";
  }
}
