/* ============================================================
   FABBRUCCIO: THE CART PAGE

   Layer 3 (section). Enqueued on /cart/ only by the child functions.php
   $sections map (handle `fab-cart`, depends on `fab-tokens`).

   Markup:    templates/page-cart.html -> wp:fabbruccio/cart
   Render:    inc/cart.php
   Behaviour: assets/js/cart.js

   NOT TO BE CONFUSED WITH fab-minicart.css, which is the DRAWER behind
   the nav's CART pill and is sitewide chrome. This file is the cart
   ROUTE. Both are ours now:

     fab-minicart.css  the drawer      ours, top to bottom
     fab-cart.css      the /cart/ page ours, top to bottom  <- this file

   ------------------------------------------------------------
   WHAT THIS REPLACES
   ------------------------------------------------------------
   This file used to be ONE RULE. It countered the weight of the
   parent's `.iw-cart-heading` and stopped, with a header explaining
   that rebuilding /cart/ was "a real design decision ... explicitly NOT
   this pass's job", flagged for the user.

   That decision came back: rebuild it as Fabbruccio's own. So the single
   rule is gone along with the template that made it necessary. There is
   no `.iw-cart-heading` on this route any more (the parent's page-cart.html
   no longer renders at all), and countering a selector that cannot appear
   would be dead CSS pointing at a surface we removed.

   ------------------------------------------------------------
   NO BETA CART TO COPY
   ------------------------------------------------------------
   The design bar has no cart page: beta's nav pill links straight out to
   the checkout host (fabbruccio-v2/index.html:276). So this is composed
   FROM beta's language rather than lifted from a beta component, exactly
   as the mini-cart was, and every value below names the beta rule or the
   token it comes from:

     square corners            beta --btn radius 2px, never the pill
     uppercase + letterspaced  beta .eyebrow / .nav-links / .btn
     Playfair 500 for display  beta h1 / .doc h2, never >= 700
     gold as accent only       beta uses --gold for links + rules, never fills
     cream page, --bg2 panel   beta .ccard sits on --bg2 inside --bg
     doc-top head              beta .doc-top: eyebrow + h1 over a hairline

   The head is beta's .doc-top, the same one /contact/ uses, so the two
   rebuilt routes open identically instead of each inventing a header.
   ============================================================ */

/* ------------------------------------------------------------
   THE ROUTE
   ------------------------------------------------------------
   The parent's `.site-main` carries its own padding-block, which would
   stack on top of the head's own. Zero it and let this section own its
   vertical rhythm, the same way .fab-shop-main does on the archive.
   ------------------------------------------------------------ */

.fab-cart-main {
  padding-block: 0;
}

.fab-cart {
  padding-bottom: clamp(70px, 10vw, 120px); /* beta .doc bottom */
  background: var(--fab-bg);
}

/* --fab-wrap (1440) + --fab-gut is the brand's measure, but a cart is a
   reading surface, not a gallery: 1100 keeps the line items from running
   to a metre wide on a large display while staying wider than beta's
   760px .doc, which is set for prose. */
.fab-cart__wrap {
  max-width: 1100px;
  margin-inline: auto;
  padding-inline: var(--fab-gut);
}

/* ------------------------------------------------------------
   HEAD  (beta .doc-top)
   ------------------------------------------------------------
   The top padding clears the fixed nav. --fab-nav-h is READ rather than
   re-guessed so this follows the bar if its height ever changes.
   ------------------------------------------------------------ */

.fab-cart__head {
  padding-top: calc(var(--fab-nav-h) + clamp(38px, 6vh, 70px));
  padding-bottom: clamp(28px, 4vw, 46px);   /* beta .doc-top */
  margin-bottom: clamp(34px, 4vw, 50px);
  border-bottom: 1px solid var(--fab-line); /* beta .doc-top */
}

/* Playfair 500. beta .doc-top h1, verbatim. */
.fab-cart__title {
  margin: 16px 0 0;
  font-family: var(--fab-serif);
  font-size: clamp(2.4rem, 5vw, 4rem);
  font-weight: var(--fab-display-weight);
  line-height: 1;
  letter-spacing: var(--fab-tracking-display);
  color: var(--fab-ink);
}

/* ------------------------------------------------------------
   LAYOUT
   ------------------------------------------------------------
   Items left, summary right. The summary is sticky on wide viewports so
   the Checkout button stays reachable down a long cart.

   STICKY, AND THE GUARD IT NEEDS. instawhew's layout.css:22 sets
   `body { overflow-x: hidden }`. Per CSS Overflow 3 that forces the
   body's computed overflow-y to `auto`, which makes BODY a scroll
   container, and a position:sticky element only sticks against its
   nearest scrolling ancestor. So sticky is dead sitewide unless the
   route opts out. Other routes already do this individually
   (body.home in fab-hero.css, body.single-product in fab-pdp.css);
   this is the same guard for this route, and `clip` is the value
   because it stops horizontal overflow WITHOUT creating a scroll
   container the way `hidden` does. The parent is untouched.
   ------------------------------------------------------------ */

body.woocommerce-cart {
  overflow-x: clip;
}

.fab-cart__layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  align-items: start;
  gap: clamp(32px, 4vw, 64px);
}

/* ------------------------------------------------------------
   LINE ITEMS
   ------------------------------------------------------------
   Five columns: thumb / info / qty / line total / remove. The info
   column is the only flexible one, so a long model name wraps rather
   than pushing the price off its own row.
   ------------------------------------------------------------ */

.fab-cart__list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--fab-line);
}

.fab-cart__item {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: clamp(14px, 2vw, 24px);
  padding-block: 24px;
  border-bottom: 1px solid var(--fab-line);
}

.fab-cart__thumb {
  display: block;
  background: var(--fab-bg-3);   /* the plate a boot shot sits on */
  line-height: 0;
}
.fab-cart__thumb-img {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  /* contain, never cover: a boot may not be cropped out of its own
     frame. Same rule the shop cards and the mini-cart hold to. */
  object-fit: contain;
}

.fab-cart__info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

/* Playfair, because this is the product's NAME: the same treatment the
   shop card, the mini-cart and the PDP give it. 500, always. */
.fab-cart__name {
  font-family: var(--fab-serif);
  font-size: 1.12rem;
  font-weight: var(--fab-display-weight);
  line-height: 1.2;
  color: var(--fab-ink);
  text-decoration: none;
  transition: color var(--fab-speed) var(--fab-ease);
}
.fab-cart__name:hover { color: var(--fab-gold); }
.fab-cart__name:focus-visible {
  outline: 2px solid var(--fab-gold);
  outline-offset: 2px;
}

/* WooCommerce prints variation data (the size) as a <dl>. Flatten it:
   a definition list rendered as a block is three stacked lines for
   "Size: US 8". Same treatment as fab-minicart.css. */
.fab-cart__meta,
.fab-cart__meta dl,
.fab-cart__meta dt,
.fab-cart__meta dd,
.fab-cart__meta p {
  margin: 0;
  padding: 0;
  font-family: var(--fab-sans);
  font-size: .72rem;
  font-weight: 400;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--fab-ink-3);
}
.fab-cart__meta dl { display: flex; flex-wrap: wrap; gap: 0 .4em; }
.fab-cart__meta dt::after { content: ":"; }

.fab-cart__unit {
  font-family: var(--fab-sans);
  font-size: .82rem;
  color: var(--fab-ink-2);
  font-variant-numeric: tabular-nums;
}
.fab-cart__unit .woocommerce-Price-amount { color: inherit; }

/* ------------------------------------------------------------
   QUANTITY
   ------------------------------------------------------------ */

/* The label is for screen readers only. It names WHICH product's
   quantity this is, which a bare spinner in a list of five rows cannot
   say. Not display:none: that would take it out of the a11y tree, which
   is the one place it is doing its job. */
.fab-cart__qty-label {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.fab-cart__qty-input {
  width: 64px;
  padding: 9px 8px;
  border: 1px solid var(--fab-line-2);  /* beta .cform-field input */
  border-radius: 0;                     /* square, always */
  background: var(--fab-bg-2);          /* beta .cform-field input */
  color: var(--fab-ink);
  font-family: var(--fab-sans);
  font-size: .9rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
  transition: border-color .25s var(--fab-ease);
}
.fab-cart__qty-input:focus {
  outline: none;
  border-color: var(--fab-gold);        /* beta input:focus */
}
.fab-cart__qty-input:focus-visible {
  outline: 2px solid var(--fab-gold);
  outline-offset: 2px;
}

.fab-cart__qty-fixed {
  display: inline-block;
  min-width: 64px;
  font-family: var(--fab-sans);
  font-size: .9rem;
  text-align: center;
  color: var(--fab-ink-2);
  font-variant-numeric: tabular-nums;
}

.fab-cart__line {
  font-family: var(--fab-serif);
  font-size: 1.05rem;
  font-weight: var(--fab-display-weight);
  color: var(--fab-ink);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.fab-cart__line .woocommerce-Price-amount {
  font-family: inherit;
  font-weight: inherit;
  color: inherit;
}

/* A text link, not a button: removing a line is a small, reversible act
   (WooCommerce offers an Undo notice), and a filled button here would
   compete with Checkout for the eye. Wine on hover is the brand's only
   destructive colour, same as the mini-cart's remove. */
.fab-cart__remove {
  font-family: var(--fab-sans);
  font-size: .66rem;
  font-weight: 400;
  letter-spacing: .14em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--fab-ink-3);
  white-space: nowrap;
  transition: color var(--fab-speed) var(--fab-ease);
}
.fab-cart__remove:hover { color: var(--fab-wine); }
.fab-cart__remove:focus-visible {
  outline: 2px solid var(--fab-gold);
  outline-offset: 2px;
  color: var(--fab-ink);
}

/* ------------------------------------------------------------
   UPDATE
   ------------------------------------------------------------
   assets/js/cart.js adds .fab-cart__actions--js when it takes over, so
   the button is hidden ONLY once something is really listening for the
   change event. Hiding it from CSS unconditionally would strand every
   no-JS shopper with a quantity box that cannot submit.
   ------------------------------------------------------------ */

.fab-cart__actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 22px;
}
.fab-cart__actions--js { display: none; }

/* ------------------------------------------------------------
   SUMMARY
   ------------------------------------------------------------ */

.fab-cart__summary {
  position: sticky;
  top: calc(var(--fab-nav-h) + 24px);   /* clear the fixed bar */
  padding: clamp(22px, 2.6vw, 30px);    /* beta .ccard */
  border: 1px solid var(--fab-line);    /* beta .ccard */
  background: var(--fab-bg-2);          /* beta .ccard */
}

/* An <h2>, so theme.json's element style would make it Playfair 500 with
   negative tracking, which is display type. This is a LABEL, and it is
   set like every other label on the brand (beta .ccard h3 / .eyebrow).
   Class specificity (0,1,0) ties with theme.json's `:root :where(h2)`
   and wins on source order, since the section layer is enqueued after
   global-styles. Same mechanism .fab-minicart__title uses; no
   !important anywhere. */
.fab-cart__summary-title {
  margin: 0 0 18px;
  font-family: var(--fab-sans);
  font-size: .68rem;
  font-weight: 400;
  letter-spacing: .2em;
  line-height: 1;
  text-transform: uppercase;
  color: var(--fab-ink-2);
}

.fab-cart__totals {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-top: 18px;
  border-top: 1px solid var(--fab-line);
}
.fab-cart__totals-label {
  font-family: var(--fab-sans);
  font-size: .72rem;
  font-weight: 400;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--fab-ink-2);
}
.fab-cart__totals-value {
  font-family: var(--fab-serif);
  font-size: 1.5rem;
  font-weight: var(--fab-display-weight);
  color: var(--fab-ink);
  font-variant-numeric: tabular-nums;
}
/* WooCommerce wraps the amount in its own span; it must not re-introduce
   a weight or a family of its own inside our line. */
.fab-cart__totals-value .woocommerce-Price-amount {
  font-family: inherit;
  font-weight: inherit;
  color: inherit;
}

.fab-cart__promise {
  margin: 10px 0 20px;
  font-size: .72rem;
  line-height: 1.5;
  color: var(--fab-ink-3);
}

/* fab-btn does the button; only the summary's own geometry is set here. */
.fab-cart__checkout {
  display: flex;
  width: 100%;
}

.fab-cart__continue {
  display: block;
  margin-top: 14px;
  padding-bottom: 3px;
  font-family: var(--fab-sans);
  font-size: .72rem;
  font-weight: 400;
  letter-spacing: .16em;
  text-align: center;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--fab-ink-2);
  transition: color var(--fab-speed) var(--fab-ease);
}
.fab-cart__continue:hover { color: var(--fab-ink); }
.fab-cart__continue:focus-visible {
  outline: 2px solid var(--fab-gold);
  outline-offset: 3px;
  color: var(--fab-ink);
}

/* ------------------------------------------------------------
   EMPTY STATE
   ------------------------------------------------------------ */

.fab-cart__empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 26px;
  padding-block: clamp(30px, 8vh, 70px);
}
.fab-cart__empty-msg {
  margin: 0;
  font-family: var(--fab-serif);
  font-size: clamp(1.3rem, 2.4vw, 1.8rem);
  font-weight: var(--fab-display-weight);
  color: var(--fab-ink-2);
}

/* ------------------------------------------------------------
   WOOCOMMERCE NOTICES
   ------------------------------------------------------------
   The cart telling the shopper what it just did ("... removed. Undo?",
   stock limits). WooCommerce ships these with `woocommerce-message`,
   which its own dequeued stylesheet would have painted, so without a
   rule here they arrive as a bare list with a stray bullet. Square,
   cream, gold-ruled: the brand's own voice.
   ------------------------------------------------------------ */

.fab-cart .woocommerce-notices-wrapper:empty { display: none; }

.fab-cart .woocommerce-message,
.fab-cart .woocommerce-info,
.fab-cart .woocommerce-error {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin: 0 0 26px;
  padding: 14px 18px;
  border: 1px solid var(--fab-line-2);
  border-left: 2px solid var(--fab-gold);
  border-radius: 0;
  background: var(--fab-bg-2);
  list-style: none;
  font-size: .86rem;
  color: var(--fab-ink-2);
}
/* An error is the one notice that is not gold: it is the only state the
   brand paints in wine. */
.fab-cart .woocommerce-error {
  border-left-color: var(--fab-wine);
}
.fab-cart .woocommerce-message li,
.fab-cart .woocommerce-info li,
.fab-cart .woocommerce-error li {
  list-style: none;
}
/* The action link WooCommerce puts inside a notice: "View cart" on an
   add, "Undo?" on a removal. It ships as an <a class="button wc-forward">,
   and on this install WooCommerce also stamps it `wp-element-button`
   (body carries woocommerce-block-theme-has-button-styles), so fab-base's
   core-button guard would otherwise paint it a solid ink pill inside a
   cream notice. Re-clothe it as the brand's own quiet gold link instead:
   a notice is a whisper, not a second call to action competing with
   Checkout. Every class WC might stamp is named so the rule cannot be
   dodged, and each selector clears (0,3,0), which beats both the guard's
   `.wp-element-button` (0,1,0) and the parent's `.woocommerce a.button`
   (0,2,1). No !important. */
.fab-cart .woocommerce-message a.button,
.fab-cart .woocommerce-info a.button,
.fab-cart .woocommerce-error a.button,
.fab-cart .woocommerce-message a.wp-element-button,
.fab-cart .woocommerce-info a.wp-element-button,
.fab-cart .woocommerce-error a.wp-element-button,
.fab-cart .woocommerce-message a.wc-forward,
.fab-cart .woocommerce-message a.restore-item {
  order: 2;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: var(--fab-gold);
  font-family: var(--fab-sans);
  font-size: .68rem;
  font-weight: 400;
  letter-spacing: .14em;
  line-height: 1;
  text-transform: uppercase;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.fab-cart .woocommerce-message a.button:hover,
.fab-cart .woocommerce-info a.button:hover,
.fab-cart .woocommerce-error a.button:hover,
.fab-cart .woocommerce-message a.wp-element-button:hover,
.fab-cart .woocommerce-info a.wp-element-button:hover,
.fab-cart .woocommerce-error a.wp-element-button:hover,
.fab-cart .woocommerce-message a.wc-forward:hover,
.fab-cart .woocommerce-message a.restore-item:hover {
  background: none;
  color: var(--fab-ink);
}

/* ------------------------------------------------------------
   RESPONSIVE
   ------------------------------------------------------------ */

/* The summary drops under the items before the two columns get too
   narrow to hold a price and a name on one line. */
@media (max-width: 900px) {
  .fab-cart__layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .fab-cart__summary {
    position: static;   /* nothing to stick to once it is stacked */
  }
}

/* Below this the five-column row cannot hold. Re-lay it as a two-column
   grid: the thumb spans both rows on the left, everything else stacks
   beside and under it. The line total sits with the quantity rather than
   on its own row, because on a phone the shopper is comparing "how many"
   against "how much" and those two must be adjacent. */
@media (max-width: 560px) {
  .fab-cart__item {
    grid-template-columns: 72px minmax(0, 1fr);
    grid-template-areas:
      "thumb info"
      "thumb qty"
      "thumb remove";
    align-items: start;
    gap: 6px 16px;
    padding-block: 20px;
  }
  .fab-cart__thumb  { grid-area: thumb; align-self: start; }
  .fab-cart__info   { grid-area: info; }
  .fab-cart__qty    { grid-area: qty; display: flex; align-items: center; gap: 12px; margin-top: 6px; }
  .fab-cart__line   { grid-area: qty; justify-self: end; align-self: center; margin-top: 6px; }
  .fab-cart__remove { grid-area: remove; justify-self: start; margin-top: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .fab-cart__name,
  .fab-cart__remove,
  .fab-cart__continue,
  .fab-cart__qty-input { transition: none; }
}
