/* =========================================================================
   The cart, and checkout.
   -------------------------------------------------------------------------
   Loaded only on the three shopping surfaces — storefront, product, checkout.
   The drawer slides from the right, which is the same edge the Tutorial Assets
   panel uses; they are never both open, because opening one is a deliberate
   act and the drawer closes on Escape and on a backdrop click.

   Color discipline: terracotta is the shop's "act now" accent and stays that
   way here. The panel's graphite belongs to the teaching layer and appears
   nowhere in this file.
   ========================================================================= */

/* --- the header control -------------------------------------------------- */

.cart-btn {
  display: inline-flex; align-items: center; gap: .5rem;
  margin-left: .4rem;
  background: rgba(255,255,255,.09);
  color: #cfdcd4;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 6px;
  padding: .45rem .68rem;
  font-family: var(--body);
  font-size: .7rem; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; white-space: nowrap;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.cart-btn:hover { background: rgba(255,255,255,.16); color: #fff; }
.cart-btn:focus-visible { outline: 2px solid var(--terracotta); outline-offset: 2px; }

.cart-btn__count {
  min-width: 1.45em; padding: 0 .35em;
  border-radius: 999px;
  background: var(--terracotta); color: #fff;
  font-family: var(--mono); font-size: .68rem; font-weight: 500;
  letter-spacing: 0; text-align: center;
}
.cart-btn__count[data-empty='true'] {
  background: rgba(255,255,255,.14); color: #93ab9c;
}

/* --- the drawer ---------------------------------------------------------- */

.cart-back {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(20,38,28,.34);
  backdrop-filter: blur(1.5px);
}

.cart {
  position: fixed; top: 0; right: 0; z-index: 950;
  width: min(400px, 100vw);
  height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--paper);
  border-left: 1px solid var(--hairline);
  box-shadow: var(--shadow-lg);
  /* The control that owns this drawer lives in the dark header, so without
     these the whole cart inherits pale-on-dark type and reads as disabled. */
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.6;
  text-align: left;
  transform: translateX(100%);
  transition: transform .22s cubic-bezier(.2,.7,.3,1);
}
.cart[data-open='true'] { transform: none; }

@media (prefers-reduced-motion: reduce) { .cart { transition: none; } }

.cart__head {
  display: flex; align-items: center; gap: .75rem;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--hairline);
}
.cart__title { font-family: var(--display); font-size: 1.15rem; margin: 0; flex: 1; }
.cart__close {
  background: none; border: 0; cursor: pointer;
  font-size: 1.6rem; line-height: 1; color: var(--ink-faint);
  padding: 0 .2rem;
}
.cart__close:hover { color: var(--ink); }
.cart__close:focus-visible { outline: 2px solid var(--terracotta); outline-offset: 2px; }

.cart__body { flex: 1; overflow-y: auto; padding: .5rem 1.25rem 1rem; }

.cart__empty {
  color: var(--ink-faint); font-size: .92rem;
  margin: 2.5rem 0; text-align: center;
}

.cart-line {
  display: grid; grid-template-columns: 56px 1fr auto;
  gap: .8rem; align-items: start;
  padding: .95rem 0;
  border-bottom: 1px solid var(--hairline);
}
.cart-line:last-child { border-bottom: 0; }

.cart-line__img {
  width: 56px; height: 56px; border-radius: 6px;
  object-fit: cover; background: var(--paper-warm);
  border: 1px solid var(--hairline);
}
.cart-line__main { min-width: 0; }
.cart-line__title { margin: 0; font-weight: 700; font-size: .95rem; line-height: 1.25; }
.cart-line__sku { margin: .1rem 0 .5rem; font-size: .68rem; color: var(--ink-faint); }
.cart-line__end { text-align: right; display: grid; gap: .35rem; justify-items: end; }
.cart-line__end strong { font-family: var(--display); font-size: 1.02rem; }

.cart-line__drop {
  background: none; border: 0; padding: 0; cursor: pointer;
  font-family: var(--mono); font-size: .64rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-faint);
}
.cart-line__drop:hover { color: var(--terracotta); }

.qty {
  display: inline-flex; align-items: center;
  border: 1px solid var(--hairline); border-radius: 6px;
  overflow: hidden;
}
.qty button {
  background: var(--paper-warm); border: 0; cursor: pointer;
  width: 1.9rem; height: 1.7rem; line-height: 1;
  font-size: .95rem; color: var(--ink-mid);
}
.qty button:hover { background: var(--paper-deep); color: var(--ink); }
.qty button:focus-visible { outline: 2px solid var(--terracotta); outline-offset: -2px; }
.qty span {
  min-width: 2.1rem; text-align: center;
  font-family: var(--mono); font-size: .82rem;
}

.cart__foot {
  border-top: 1px solid var(--hairline);
  background: var(--paper-warm);
  padding: 1.1rem 1.25rem calc(1.1rem + env(safe-area-inset-bottom));
  display: grid; gap: .6rem;
}
.cart__row {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 0; font-size: .95rem;
}
.cart__row strong { font-family: var(--display); font-size: 1.25rem; }
.cart__note { margin: 0; font-size: .78rem; color: var(--ink-faint); }
.cart__go { justify-content: center; text-align: center; }
.cart__clear {
  background: none; border: 0; padding: .2rem; cursor: pointer;
  font-family: var(--mono); font-size: .64rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-faint);
}
.cart__clear:hover { color: var(--terracotta); }

/* --- adding from the storefront ------------------------------------------ */

/* The packet is a link, so the add control cannot live inside it. It is a
   sibling positioned over the plate — which also keeps the whole card
   clickable for the far more common act of reading about a seed. */
.plates > li { position: relative; }

.quick-add {
  position: absolute; top: .7rem; right: .7rem; z-index: 2;
  width: 2.1rem; height: 2.1rem; border-radius: 999px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.94);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-sm);
  color: var(--ink); font-size: 1.1rem; line-height: 1;
  cursor: pointer;
  opacity: 0; transform: scale(.85);
  transition: opacity .16s, transform .16s, background .16s, color .16s;
}
.plates > li:hover .quick-add,
.quick-add:focus-visible { opacity: 1; transform: none; }
.quick-add:hover { background: var(--terracotta); border-color: var(--terracotta); color: #fff; }
.quick-add:focus-visible { outline: 2px solid var(--terracotta); outline-offset: 2px; }
.quick-add[data-done='true'] {
  opacity: 1; transform: none;
  background: var(--green); border-color: var(--green); color: #fff;
}
@media (hover: none) { .quick-add { opacity: 1; transform: none; } }

/* --- adding from a product page ------------------------------------------ */

.buy {
  display: flex; flex-wrap: wrap; align-items: center; gap: .75rem;
  margin: 1.4rem 0 .4rem;
}
.buy .qty button { width: 2.3rem; height: 2.2rem; font-size: 1.05rem; }
.buy .qty span { min-width: 2.6rem; font-size: .9rem; }
.buy__note {
  width: 100%; margin: 0; font-size: .8rem; color: var(--green);
  min-height: 1.2em;
}

/* --- checkout ------------------------------------------------------------ */

.checkout {
  display: grid; gap: clamp(1.5rem, 4vw, 3rem);
  grid-template-columns: minmax(0, 1fr);
  margin-block: clamp(1.5rem, 4vw, 2.5rem) 4rem;
  align-items: start;
}
@media (min-width: 900px) { .checkout { grid-template-columns: 7fr 5fr; } }

.co-card {
  border: 1px solid var(--hairline); border-radius: var(--radius);
  background: var(--paper);
  padding: clamp(1.1rem, 3vw, 1.6rem);
  margin-bottom: 1.25rem;
}
.co-card > h3 {
  margin: 0 0 .3rem; font-size: 1.15rem;
}
.co-card__lead { margin: 0 0 1rem; color: var(--ink-soft); font-size: .92rem; }

.co-who {
  display: grid; gap: .15rem;
  font-size: .95rem;
  padding: .9rem 1rem; border-radius: 8px;
  background: var(--paper-warm); border: 1px solid var(--hairline);
}
.co-who__flag {
  font-family: var(--mono); font-size: .62rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--terracotta);
  margin: 0 0 .35rem;
}
.co-who p { margin: 0; }
.co-who .mono { font-size: .82rem; color: var(--ink-soft); }

.co-lines { list-style: none; margin: 0; padding: 0; }
.co-line {
  display: grid; grid-template-columns: 48px 1fr auto;
  gap: .8rem; align-items: center;
  padding: .8rem 0; border-bottom: 1px solid var(--hairline);
}
.co-line:last-child { border-bottom: 0; }
.co-line img {
  width: 48px; height: 48px; border-radius: 6px; object-fit: cover;
  background: var(--paper-warm); border: 1px solid var(--hairline);
}
.co-line__title { margin: 0; font-weight: 700; font-size: .95rem; }
.co-line__sku { margin: .1rem 0 .4rem; font-family: var(--mono); font-size: .68rem; color: var(--ink-faint); }
.co-line__money { font-family: var(--display); font-size: 1.02rem; text-align: right; }

.co-totals { margin: 0; padding: 1rem 0 0; border-top: 1px solid var(--hairline); }
.co-totals div {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: .3rem 0; font-size: .95rem;
}
.co-totals dt { color: var(--ink-soft); }
.co-totals dd { margin: 0; font-variant-numeric: tabular-nums; }
.co-totals .co-totals__grand { border-top: 1px solid var(--hairline); margin-top: .5rem; padding-top: .7rem; }
.co-totals__grand dt { color: var(--ink); font-weight: 700; }
.co-totals__grand dd { font-family: var(--display); font-size: 1.4rem; font-weight: 600; }

/* The shipping line is the one number on the page a learner's flow decides.
   It says where it came from, every time, because "did my flow do that?" is
   the question the whole exercise turns on. */
.co-ship { display: grid; gap: .5rem; }
.co-ship__result {
  border-radius: 8px; padding: .85rem 1rem;
  border: 1px solid var(--hairline); background: var(--paper-warm);
  font-size: .92rem;
}
.co-ship__result[data-source='flow']     { border-color: #b9d9c6; background: #f1f9f4; }
.co-ship__result[data-source='raw']      { border-color: #e6cf9a; background: #fdf7ea; }
.co-ship__result[data-source='fallback'] { border-color: #e9c4b4; background: #fdf2ee; }
.co-ship__from {
  font-family: var(--mono); font-size: .62rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-faint);
  margin: 0 0 .3rem;
}
.co-ship__line { margin: 0; font-weight: 700; }
.co-ship__why { margin: .3rem 0 0; font-size: .84rem; color: var(--ink-soft); }
.co-ship__raw {
  margin: .5rem 0 0; padding: .6rem .7rem;
  background: var(--paper); border: 1px solid var(--hairline); border-radius: 6px;
  font-family: var(--mono); font-size: .74rem; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
  max-height: 12rem; overflow: auto;
}

.co-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }

/* Leaving without ordering — a timer the page holds, so closing the tab
   cancels it and Flowland stores nothing. */
.co-leave { display: grid; gap: .6rem; }
.co-leave__row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.co-leave select {
  font-family: var(--body); font-size: .9rem;
  padding: .5rem .6rem; border: 1px solid var(--hairline);
  border-radius: 6px; background: var(--paper);
}
.co-countdown {
  display: flex; align-items: center; gap: .7rem;
  padding: .8rem 1rem; border-radius: 8px;
  border: 1px solid var(--gold); background: #fdf9ef;
  font-size: .92rem;
}
.co-countdown strong { font-family: var(--mono); }

.co-done {
  border: 1px solid #b9d9c6; background: #f1f9f4;
  border-radius: var(--radius); padding: 1.2rem 1.4rem;
  margin-bottom: 1.25rem;
}
.co-done h3 { margin: 0 0 .4rem; }
.co-done p { margin: .2rem 0; font-size: .93rem; }
.co-done pre {
  margin: .7rem 0 0; padding: .7rem .8rem;
  background: var(--paper); border: 1px solid var(--hairline); border-radius: 6px;
  font-family: var(--mono); font-size: .74rem; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
  max-height: 16rem; overflow: auto;
}
.co-done[data-kind='error'] { border-color: #e9c4b4; background: #fdf2ee; }

/* --- the replayer -------------------------------------------------------- */

.replay-grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  list-style: none; padding: 0; margin: 1.5rem 0 4rem;
}
/* Fill the cell so Send sits on the same line across a row, however much
   explaining a particular defect needed. */
.replay-grid > li { display: flex; }

.rp {
  flex: 1;
  display: flex; flex-direction: column; gap: .55rem;
  border: 1px solid var(--hairline); border-radius: var(--radius);
  background: var(--paper); padding: 1.1rem 1.2rem 1.2rem;
}
.rp[data-defect='true'] { border-left: 3px solid var(--terracotta); }
.rp[data-defect='false'] { border-left: 3px solid var(--sage); }

.rp__code {
  font-family: var(--mono); font-size: .68rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-faint); margin: 0;
}
.rp__label { margin: 0; font-size: 1.05rem; line-height: 1.25; }
.rp__blurb { margin: 0; font-size: .88rem; color: var(--ink-soft); }

.rp__defect {
  margin: 0; padding: .7rem .8rem; border-radius: 6px;
  background: #fdf2ee; border: 1px solid #e9c4b4;
  font-size: .84rem;
}
.rp__defect strong { display: block; margin-bottom: .35rem; }
.rp__defect p { margin: 0 0 .4rem; }
.rp__defect p:last-child { margin-bottom: 0; }
.rp__defect code {
  font-family: var(--mono); font-size: .78rem;
  background: rgba(194,84,47,.1); padding: .05em .3em; border-radius: 3px;
}
/* The exact field, on its own line — a learner scanning eight cards for the
   one they broke should not have to read a sentence to find it. */
.rp__where {
  font-family: var(--mono); font-size: .74rem;
  color: var(--terracotta);
  padding: .25rem .45rem; border-radius: 4px;
  background: rgba(194,84,47,.09);
  display: inline-block;
}

.rp__facts {
  display: flex; flex-wrap: wrap; gap: .4rem .9rem;
  font-family: var(--mono); font-size: .68rem; color: var(--ink-faint);
  margin: 0;
}
.rp__foot { margin-top: auto; padding-top: .5rem; display: flex; gap: .5rem; align-items: center; }
.rp__status { font-family: var(--mono); font-size: .68rem; color: var(--ink-faint); }
.rp__status[data-ok='true']  { color: var(--green); }
.rp__status[data-ok='false'] { color: var(--terracotta); }
