/* ==========================================================================
   Cart and Checkout — the token bridge (§19, G1)
   --------------------------------------------------------------------------
   THE DOM IS WOOCOMMERCE'S AND STAYS THAT WAY.

   §19 puts the whole cart and checkout on the official Cart & Checkout Blocks
   over the Store API, and §19.4 makes the official Stripe extension the only
   payment surface. Rebuilding that markup would put Korotana between a
   customer and a payment form, which is exactly what those clauses exist to
   prevent — and every Woo release would then be a merge conflict against a
   thing nobody is allowed to touch.

   So this file changes NO structure. It contains no layout, no reordering, no
   element hiding and nothing that could alter what a customer is agreeing to.

   HOW IT WORKS. WooCommerce Blocks read their own custom properties —
   --wc-primary, --wc-form-border-color and the rest — and derive most of their
   appearance from them. Setting those from Korotana's tokens is a genuine
   bridge rather than an override war: one small block below re-points Woo's
   variables at §11's palette, and Woo's own stylesheet does the rest. The
   handful of rules after it exist only where Woo has no variable for something
   §12/§13 governs — type scale, uppercase utility labels, touch targets and
   the focus ring §25 requires.

   G1: "Woo Cart & Checkout Blocks inherit these presets." This is that
   inheritance, made explicit.

   WHAT IS DELIBERATELY NOT SET. The error colour. C1.3 is an open decision
   (docs/for-abdullah.md) and Woo's --wc-red is a functional state, not an
   editorial accent. Coupling one to the other before the ruling would be
   inventing a design decision.
   ========================================================================== */

.wc-block-cart,
.wc-block-checkout,
.wp-block-woocommerce-cart,
.wp-block-woocommerce-checkout {
  /* Actions. §11: Ink on Snow, no accent colour on a primary control. */
  --wc-primary: var(--k-ink);
  --wc-primary-text: var(--k-snow);
  --wc-secondary: var(--k-porcelain);
  --wc-secondary-text: var(--k-ink);

  /* Focus and selection. Ink, so the ring reads at AA on Snow. */
  --wc-highlight: var(--k-ink);
  --wc-highligh-text: var(--k-snow);   /* Woo's spelling, not ours */

  /*
   * Forms, matched to .k-field__input — TRULY, since Run 56 (R48-014).
   *
   * This line said "matched to .k-field__input rather than approximated"
   * while handing Woo --k-mist, and .k-field__input uses --k-border-control.
   * The comment was not a small inaccuracy: it is the reason nobody looked
   * again. Mist is #D5D3CE — 1.43:1 on Snow and 1.50:1 on white — against the
   * 3:1 SC 1.4.11 requires of a control boundary, and on these fields the
   * border is the ONLY visible boundary: fill and surround differ by 1.00–1.05:1.
   * --k-mist's own token comment says it is for "disabled, inactive; never
   * carries required information", which is exactly what an active field's
   * only edge must not be.
   */
  --wc-form-border-color: var(--k-border-control);
  --wc-form-border-width: var(--gap-hairline);
  --wc-form-border-radius: var(--gap-radius);

  --wc-content-bg: var(--k-surface-raised); /* J-51: the raised ROLE, not the snow COLOUR — the ground is Snow now */
  --wc-subtext: var(--k-graphite);
  --wc-card-border-radius: var(--gap-radius);

  color: var(--k-ink);
  background: var(--k-pad);
}

/* --------------------------------------------------------------------------
   Type. §12's scale, applied to the headings Woo emits.
   -------------------------------------------------------------------------- */

.wc-block-components-title,
.wc-block-cart__totals-title,
.wc-block-components-checkout-step__title,
.wc-block-components-checkout-order-summary__title-text {
  font-family: var(--k-font-ui);
  font-weight: var(--gap-weight-medium);
  color: var(--k-ink);
}

/* Step titles are utility labels, not headings in the editorial sense —
   §12's uppercase micro treatment, the same as .k-pagehead__kicker. */
.wc-block-components-checkout-step__title,
.wc-block-cart__totals-title,
.wc-block-components-checkout-order-summary__title-text {
  font-size: var(--k-type-micro);
  letter-spacing: var(--k-track-label);
  text-transform: uppercase;
  color: var(--k-graphite);
}

.wc-block-components-product-name {
  font-size: var(--k-type-body);
  color: var(--k-ink);
  text-decoration: none;
}

.wc-block-components-product-price,
.wc-block-components-formatted-money-amount,
.wc-block-components-totals-item__value {
  /* §11/§12: prices line up in columns, so they take tabular figures — the
     Korotana Sans figure set the DNA specifies for exactly this. */
  font-variant-numeric: tabular-nums;
}

.wc-block-components-totals-item__label { color: var(--k-graphite); }
.wc-block-components-totals-footer-item .wc-block-components-totals-item__label,
.wc-block-components-totals-footer-item .wc-block-components-totals-item__value {
  color: var(--k-ink);
  font-weight: var(--gap-weight-medium);
}

.wc-block-components-product-metadata__description,
.wc-block-components-totals-item__description {
  color: var(--k-graphite);
  font-size: var(--k-type-product);
}

/* --------------------------------------------------------------------------
   Controls. §25: 44px targets and a visible focus ring, both launch gates.
   -------------------------------------------------------------------------- */

/*
 * COLOUR LIVES IN theme.json, NOT HERE.
 *
 * The submit button rendered #32373C — WordPress core's default button
 * background, which is not in §11's palette at all. Setting --wc-primary did
 * not fix it, because the button never reads that variable: it inherits from
 * the block theme's `elements.button`, which the theme had simply not defined.
 * The fix belongs in theme.json, where it also corrects every other block
 * button on the site rather than only Woo's.
 */
.wc-block-components-button:not(.is-link) {
  font-family: var(--k-font-ui);
  font-size: var(--k-type-body);
  font-weight: var(--gap-weight-medium);
  letter-spacing: var(--k-track-label);
  text-transform: uppercase;
  min-height: var(--k-space-7);   /* 48px, the same band as .k-btn */
  border-radius: var(--gap-radius);
}

/*
 * §25 target size. --k-touch-min is documented as the minimum on BOTH axes.
 *
 * Two things had to be got right here, and both were found by measuring the
 * rendered cart rather than by reading the CSS:
 *
 *   1. Setting only min-height left the quantity plus and minus buttons 44px
 *      tall and 30px WIDE.
 *   2. Adding min-width at this specificity ALSO did nothing. Woo's own rule is
 *      `.wc-block-components-quantity-selector .wc-block-components-quantity-selector__button`,
 *      which scores (0,2,0) and outranks a single class. The computed min-width
 *      stayed at Woo's 30px while the stylesheet looked correct.
 *
 * So the quantity buttons are matched at Woo's own specificity below. This is
 * sizing to meet an accessibility requirement, not a structural change: nothing
 * is moved, reordered or hidden.
 */
.wc-block-cart-item__remove-link,
.wc-block-components-address-card__edit,
.wc-block-components-panel__button {
  min-height: var(--k-touch-min);
  min-width: var(--k-touch-min);
  color: var(--k-ink);
}

.wc-block-components-quantity-selector .wc-block-components-quantity-selector__button {
  min-height: var(--k-touch-min);
  min-width: var(--k-touch-min);
  color: var(--k-ink);
}

/* The container is sized from its children, so it has to be allowed to grow
   with them rather than holding them to its old width. */
.wc-block-components-quantity-selector { width: auto; }

/* One focus treatment across the whole journey. Woo's default is a soft inset
   shadow that vanishes against Snow; §25 asks for a visible ring with offset. */
.wc-block-components-button:focus-visible,
.wc-block-components-text-input input:focus-visible,
.wc-blocks-components-select__select:focus-visible,
.wc-block-components-checkbox__input:focus-visible,
.wc-block-components-panel__button:focus-visible,
.wc-block-cart-item__remove-link:focus-visible,
.wc-block-components-address-card__edit:focus-visible {
  outline: var(--k-focus-ring) solid var(--k-ink);
  outline-offset: var(--gap-focus-offset);
}

/*
 * FORM FIELDS: the one place the variable bridge does not reach.
 *
 * --wc-form-border-color and --wc-form-border-radius are set correctly at the
 * top of this file and the fields ignore both. WooCommerce hardcodes them:
 *
 *   .wc-block-components-form .wc-block-components-text-input input[type="email"] {
 *     border: 1px solid color-mix(in srgb, currentcolor 80%, transparent);
 *     border-radius: 4px; background-color: #fff; color: rgb(43,45,47);
 *   }
 *
 * That is (0,3,1) and off-palette on three counts at once — a 4px radius where
 * --gap-radius is 0, #fff where §11's white is Snow, and a text colour that is
 * not Ink. So these selectors are written to Woo's own weight. The VALUES are
 * still tokens; only the selector had to change, and nothing structural does.
 *
 * Checked by reading the computed border off a rendered checkout field, not by
 * assuming the variables had been honoured.
 */
.wc-block-checkout .wc-block-components-form .wc-block-components-text-input input[type],
.wc-block-cart .wc-block-components-form .wc-block-components-text-input input[type],
.wc-block-checkout .wc-blocks-components-select .wc-blocks-components-select__select,
.wc-block-cart .wc-blocks-components-select .wc-blocks-components-select__select,
.wc-block-checkout .wc-block-components-form textarea.wc-block-components-textarea {
  border: var(--gap-hairline) solid var(--k-border-control);  /* R48-014: 5.01:1, was Mist at 1.43:1 */
  border-radius: var(--gap-radius);
  background-color: var(--k-surface-raised); /* J-51: the raised ROLE, not the snow COLOUR — the ground is Snow now */
  color: var(--k-ink);
}

.wc-block-checkout .wc-block-components-form .wc-block-components-text-input input[type]:hover,
.wc-block-cart .wc-block-components-form .wc-block-components-text-input input[type]:hover {
  /* Matches .k-field__input:hover. */
  border-color: var(--k-graphite);
}

.wc-block-components-text-input input,
.wc-blocks-components-select__select,
.wc-block-components-textarea {
  font-family: var(--k-font-ui);
  font-size: var(--k-type-body);
  min-height: var(--k-space-7);
}

.wc-block-components-text-input label,
.wc-blocks-components-select__label {
  color: var(--k-graphite);
}

/* --------------------------------------------------------------------------
   Surfaces
   -------------------------------------------------------------------------- */

.wc-block-components-sidebar,
.wc-block-cart__sidebar,
.wc-block-checkout__sidebar {
  background: var(--k-porcelain);
}

.wc-block-cart-items__row,
.wc-block-components-totals-wrapper {
  border-color: var(--k-stone);
}

.wc-block-components-order-summary-item__image img,
.wc-block-cart-item__image img {
  background: var(--k-porcelain);
}

/* --------------------------------------------------------------------------
   The bottom of the page has to clear the dock.
   --------------------------------------------------------------------------
   §14.2: "interactive elements get bottom padding and are never obscured —
   including at 200% zoom and on short viewports." The cart keeps the dock
   (§14.2 says so explicitly), and its Proceed to Checkout button is the last
   thing on the page, so without this the primary action sits underneath it.

   Checkout renders no dock at all, so it needs no allowance.
   -------------------------------------------------------------------------- */

.wp-block-woocommerce-cart { padding-bottom: var(--k-page-pad-bottom); }

/* ==========================================================================
   Account (§20)
   --------------------------------------------------------------------------
   My Account is CLASSIC WooCommerce, not blocks — different markup, different
   class names, same rule: the DOM is Woo's and stays that way. Everything
   below is type, colour, spacing and target size, drawn from tokens.

   §20 gives the account its own navigation and views (Dashboard, Orders,
   Timeline, Saved, Addresses, Profile, Preferences, Support). The theme
   already has a .k-accountnav component for that, built on the states page.
   Rather than replace Woo's navigation markup with it, Woo's navigation is
   styled to match — same treatment, no rebuild, and Woo's endpoints keep
   working exactly as they do out of the box.
   ========================================================================== */

.woocommerce-account,
.woocommerce-account .woocommerce {
  font-family: var(--k-font-ui);
  color: var(--k-ink);
}

/*
 * §13 gutters. The account page renders inside a bare block group with no
 * padding at all, so at 390px every field ran edge to edge.
 */
.woocommerce-account .woocommerce {
  padding: var(--k-space-6) var(--k-gutter-mobile) var(--k-page-pad-bottom);
}

/* --- §20 account navigation, matched to .k-accountnav --- */

.woocommerce-MyAccount-navigation ul {
  list-style: none;
  margin: 0 0 var(--k-space-6);
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--k-space-2) var(--k-space-5);
  border-bottom: var(--gap-hairline) solid var(--k-stone);
}

.woocommerce-MyAccount-navigation a {
  display: inline-flex;
  align-items: center;
  min-height: var(--k-touch-min);
  font-size: var(--k-type-micro);
  letter-spacing: var(--k-track-label);
  text-transform: uppercase;
  color: var(--k-graphite);
  text-decoration: none;
}

/* §25: the current section is announced, not only coloured. Woo marks it with
   is-active; aria-current is added in inc/account.php so it reaches a screen
   reader too. */
.woocommerce-MyAccount-navigation li.is-active a,
.woocommerce-MyAccount-navigation a[aria-current] {
  color: var(--k-ink);
  box-shadow: inset 0 -2px 0 0 var(--k-ink);
}

.woocommerce-MyAccount-navigation a:focus-visible,
.woocommerce-account a:focus-visible,
.woocommerce-account button:focus-visible,
.woocommerce-account input:focus-visible,
.woocommerce-account select:focus-visible {
  outline: var(--k-focus-ring) solid var(--k-ink);
  outline-offset: var(--gap-focus-offset);
}

/* --- A28 sign-in: email -> one-time code (.k-otp) ---
   Replaces the Woo login/register forms via the form-login.php override.
   The old .woocommerce-form-login/-register rules below are kept only for
   the transitional case of a stale cache serving the retired markup. */

.k-otp {
  max-width: var(--gap-measure);
  border: var(--gap-hairline) solid var(--k-stone);
  border-radius: var(--gap-radius);
  padding: var(--k-space-6) var(--k-space-5);
  background: var(--k-surface-raised); /* J-51: the raised ROLE, not the snow COLOUR — the ground is Snow now */
}

.k-otp__title {
  font-family: var(--k-font-display);
  font-size: var(--k-type-h2);
  margin: 0 0 var(--k-space-3);
}

.k-otp__lede {
  font-size: var(--k-type-body);
  color: var(--k-graphite);
  margin: 0 0 var(--k-space-5);
}

.k-otp__row { margin: 0 0 var(--k-space-4); }
.k-otp__row:last-child { margin-bottom: 0; }

.k-otp__label {
  display: block;
  font-size: var(--k-type-product);
  font-weight: var(--gap-weight-medium);
  color: var(--k-ink);
  margin-bottom: var(--k-space-2);
}

.k-otp__input {
  box-sizing: border-box; /* width:100% + padding must stay inside the card */
  width: 100%;
  min-height: var(--k-touch-min);
  padding: var(--k-space-2) var(--k-space-3);
  border: var(--gap-hairline) solid var(--k-border-control);  /* R48-014 */
  border-radius: var(--gap-radius);
  background: var(--k-surface-raised); /* J-51: the raised ROLE, not the snow COLOUR — the ground is Snow now */
  font-size: var(--k-type-body);
  color: var(--k-ink);
}

/* The code is read back against an email: bigger, spaced, tabular. */
.k-otp__input--code {
  font-size: var(--k-type-h3);
  letter-spacing: 0.25em;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.k-otp__input:focus-visible {
  outline: var(--k-focus-ring) solid var(--k-ink);
  outline-offset: 2px;
}

.k-otp__submit { width: 100%; }

.k-otp__row--secondary {
  display: flex;
  gap: var(--k-space-5);
  justify-content: center;
}

.k-otp__linkbtn {
  background: none;
  border: 0;
  padding: var(--k-space-2);
  min-height: var(--k-touch-min);
  font-size: var(--k-type-product);
  color: var(--k-graphite);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

.k-otp__linkbtn:focus-visible {
  outline: var(--k-focus-ring) solid var(--k-ink);
  outline-offset: 2px;
}

.k-otp__status {
  font-size: var(--k-type-product);
  color: var(--k-graphite);
  min-height: 1.5em; /* Reserved: a message appearing must not shift layout. */
  margin: var(--k-space-4) 0 0;
}

.k-otp [disabled] { opacity: 0.55; }

/* --- Forms: login, register, addresses, profile --- */

.woocommerce-account form.woocommerce-form,
.woocommerce-account form.edit-account,
.woocommerce-account form.woocommerce-address-fields,
.woocommerce-account form.woocommerce-EditAccountForm {
  max-width: var(--gap-measure);
}

.woocommerce-account .woocommerce-form-login,
.woocommerce-account .woocommerce-form-register {
  border: var(--gap-hairline) solid var(--k-stone);
  border-radius: var(--gap-radius);
  padding: var(--k-space-6) var(--k-space-5);
  background: var(--k-surface-raised); /* J-51: the raised ROLE, not the snow COLOUR — the ground is Snow now */
}

.woocommerce-account .form-row { margin-bottom: var(--k-space-4); }

.woocommerce-account label,
.woocommerce-account .woocommerce-form__label {
  font-size: var(--k-type-product);
  font-weight: var(--gap-weight-medium);
  color: var(--k-ink);
  display: block;
  margin-bottom: var(--k-space-2);
}

/*
 * Matched to .k-field__input — TRULY, since Run 56 (R48-014). Woo's classic
 * inputs carry no radius or colour variables at all, so these are set
 * directly — from tokens, as everywhere. The border was --k-mist while this
 * comment claimed the match; it is --k-border-control now, which is what
 * .k-field__input actually uses and what SC 1.4.11's 3:1 needs.
 */
.woocommerce-account input.input-text,
.woocommerce-account select,
.woocommerce-account textarea {
  font-family: var(--k-font-ui);
  font-size: var(--k-type-body);
  color: var(--k-ink);
  background: var(--k-surface-raised); /* J-51: the raised ROLE, not the snow COLOUR — the ground is Snow now */
  border: var(--gap-hairline) solid var(--k-border-control);  /* R48-014 */
  border-radius: var(--gap-radius);
  min-height: var(--k-space-7);
  padding: 0 var(--k-space-3);
  width: 100%;
  box-sizing: border-box;
}
.woocommerce-account textarea { padding: var(--k-space-3); min-height: var(--k-space-9); }
.woocommerce-account input.input-text:hover { border-color: var(--k-graphite); }

/* Checkboxes keep a real target and sit beside their label. */
.woocommerce-account .woocommerce-form-login__rememberme {
  display: inline-flex;
  align-items: center;
  gap: var(--k-space-2);
  min-height: var(--k-touch-min);
}
.woocommerce-account .woocommerce-form-login__rememberme span { font-size: var(--k-type-product); }

.woocommerce-account .button,
.woocommerce-account button[type="submit"] {
  min-height: var(--k-space-7);
  min-width: var(--k-touch-min);
  padding: 0 var(--k-space-5);
  font-size: var(--k-type-body);
  font-weight: var(--gap-weight-medium);
  letter-spacing: var(--k-track-label);
  text-transform: uppercase;
  border-radius: var(--gap-radius);
}

/* --- Orders, addresses, order detail --- */

.woocommerce-account table.woocommerce-orders-table,
.woocommerce-account table.woocommerce-table--order-details,
.woocommerce-account table.shop_table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--k-type-product);
}
.woocommerce-account table.shop_table th,
.woocommerce-account table.shop_table td {
  text-align: left;
  padding: var(--k-space-3) var(--k-space-2);
  border-bottom: var(--gap-hairline) solid var(--k-stone);
}
.woocommerce-account table.shop_table th {
  font-size: var(--k-type-micro);
  letter-spacing: var(--k-track-label);
  text-transform: uppercase;
  color: var(--k-graphite);
  font-weight: var(--gap-weight-medium);
}
/* Money and order numbers line up in columns, so they take tabular figures. */
.woocommerce-account .woocommerce-Price-amount,
.woocommerce-account .woocommerce-orders-table__cell-order-number,
.woocommerce-account .woocommerce-orders-table__cell-order-date { font-variant-numeric: tabular-nums; }

/* A wide order table must scroll inside itself, never scroll the page
   sideways — the phone is the reference device (§36). */
.woocommerce-account .woocommerce-MyAccount-content { overflow-x: auto; }

.woocommerce-account .woocommerce-Address,
.woocommerce-account .woocommerce-customer-details address {
  border: var(--gap-hairline) solid var(--k-stone);
  padding: var(--k-space-5);
  font-style: normal;
  line-height: 1.6;
}
.woocommerce-account .woocommerce-Addresses {
  display: grid;
  gap: var(--k-space-5);
}

.woocommerce-account h2,
.woocommerce-account h3,
.woocommerce-account .woocommerce-column__title {
  font-size: var(--k-type-h3);
  font-weight: var(--gap-weight-medium);
  margin: var(--k-space-6) 0 var(--k-space-4);
}

/* --- Notices. Woo's own colours; only the type and spacing are ours.
       The error colour is C1.3 and stays Woo's until it is ruled on. --- */

.woocommerce-account .woocommerce-message,
.woocommerce-account .woocommerce-info,
.woocommerce-account .woocommerce-error {
  font-size: var(--k-type-product);
  padding: var(--k-space-4) var(--k-space-5);
  margin-bottom: var(--k-space-5);
  list-style: none;
}

@media (min-width: 768px) {
  .woocommerce-account .woocommerce {
    padding-left: var(--k-gutter-desktop);
    padding-right: var(--k-gutter-desktop);
  }
  .woocommerce-account .woocommerce-Addresses { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
