/* GloveHub basket (Solvus-inspired local candidate): header count, explicit Add to basket, keyboard-safe add bar,
   desktop side drawer and full-width phone basket with scrolling lines and a pinned total and action.
   Uses the page's own colour tokens; light, dark, large text, forced colours and reduced motion are respected. */

/* ---- Header basket control, on every page that loads this file ---- */
.gh-basket-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem;
  min-width: 48px; min-height: 48px; padding: 6px 12px; border: 1px solid var(--field, #6f8296); border-radius: 24px;
  background: transparent; color: var(--night, #0d2c47); font: inherit; font-size: min(1rem, 22px); font-weight: 600;
  line-height: 1.2; text-decoration: none; white-space: nowrap; cursor: pointer; overflow-wrap: normal;
}
.gh-basket-btn:hover { background: var(--foam, #eaf3fb); color: var(--night, #0d2c47); text-decoration: none; }
.gh-basket-btn[aria-expanded="true"] { border-color: var(--ocean, #1b5f9a); background: var(--foam, #eaf3fb); }
.gh-bag { flex: none; width: 1.375rem; height: 1.375rem; }
.gh-badge {
  display: inline-grid; place-items: center; min-width: 1.5rem; height: 1.5rem; padding: 0 0.375rem; border-radius: 999px;
  background: var(--ocean, #1b5f9a); color: var(--on-action, #fff); font-size: 0.8125rem; font-weight: 700;
  font-variant-numeric: tabular-nums; line-height: 1;
}
.gh-basket-sr, .gh-sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0;
}
@media (prefers-reduced-motion: no-preference) {
  .gh-basket-btn.gh-bump .gh-badge { animation: gh-bump 0.6s ease-out; }
  @keyframes gh-bump { 0% { transform: scale(1); } 30% { transform: scale(1.35); } 100% { transform: scale(1); } }
}
@media (max-width: 22.4rem) { .gh-basket-word { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; } }

/* Shopping pages: the header stays in view so the count is always visible. While a size field has the soft
   keyboard open it scrolls away again, to leave the most room for the field and the add bar. */
.site-header.gh-sticky { position: sticky; top: 0; z-index: 30; background: var(--paper); grid-template-columns: minmax(0, 1fr) auto auto; }
.site-header.gh-sticky .gh-basket-btn { justify-self: end; }
html.gh-typing .site-header.gh-sticky { position: relative; }
html:has(.site-header.gh-sticky) { scroll-padding-top: 4.75rem; }
@media (min-width: 62rem) {
  .site-header.gh-sticky { grid-template-columns: auto minmax(0, 1fr) auto; }
  html:has(.site-header.gh-sticky) .panel { top: 5rem; max-height: calc(100vh - 6rem); }
}
/* Home page header (flex layout): the count sits before Menu on phones. */
@media (max-width: 760px) {
  .site-header > .gh-basket-home { order: 1; margin-left: auto; }
  .site-header:has(> .gh-basket-home) > .mobile-menu { order: 2; margin-left: 0.5rem; }
}

/* ---- Planner cards: size fields are a draft until Add to basket ---- */
#mix-anchor { display: none !important; }
body:has(dialog.gh-drawer) { padding-bottom: 0; }
.gh-add { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.625rem; margin-top: 0.75rem; }
.gh-add .sizes { margin-top: 0; }
.gh-add-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.gh-add-button { width: 100%; }
@media (min-width: 40rem) { .gh-add-button { width: auto; min-width: 12rem; } }
.gh-add-status:empty { display: none; }
.gh-add-status, #product-plan-status:not(:empty) {
  padding: 0.5rem 0.75rem; border-left: 3px solid var(--ocean, #1b5f9a); border-radius: 0.5rem;
  background: var(--foam, #eaf3fb); color: var(--night, #0d2c47); font-weight: 600;
}
.gh-link-button {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0.25rem 0.5rem; border: 0; background: none;
  color: var(--ocean, #1b5f9a); font: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 0.2em; cursor: pointer;
}
.gh-link-button:hover { color: var(--deep, #1b4f7e); }

/* ---- On-page basket summary beside the products ---- */
.gh-summary { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.625rem; }
.gh-summary-lines { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.375rem; }
.gh-summary-lines li { padding: 0.5rem min(0.75rem, 3vw); border: 1px solid var(--line); border-radius: 0.625rem; background: var(--paper); }

/* ---- Product detail pages ---- */
#product-in-basket { margin-top: 0.5rem; color: var(--night, #0d2c47); }
#product-view-basket { margin-top: 0.5rem; }
#product-view-basket .button { width: auto; }

/* ---- Keyboard-safe add bar (shown only while a size field has the soft keyboard open) ---- */
.gh-kbd-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  padding: 0.5rem max(0.75rem, env(safe-area-inset-right, 0px)) 0.5rem max(0.75rem, env(safe-area-inset-left, 0px));
  border-top: 1px solid var(--line, #d3dfeb); background: var(--paper, #fff); box-shadow: 0 -0.5rem 1rem rgb(13 44 71 / 0.14);
}
.gh-kbd-bar .button { width: 100%; }

/* ---- The basket: side drawer on wide screens, full width on phones ---- */
dialog.gh-drawer {
  position: fixed; inset: var(--gh-vvtop, 0px) 0 auto auto; margin: 0; padding: 0; border: 0;
  width: min(30rem, 100vw); max-width: 100vw; height: 100vh; height: var(--gh-vvh, 100dvh); max-height: none;
  border-left: 1px solid var(--line); background: var(--paper); color: var(--ink); overflow: hidden;
  box-shadow: -1rem 0 2rem rgb(13 44 71 / 0.2);
}
dialog.gh-drawer[open] { display: flex; flex-direction: column; }
dialog.gh-drawer::backdrop { background: rgb(13 44 71 / 0.45); }
@media (max-width: 39.99rem) { dialog.gh-drawer { width: 100vw; border-left: 0; box-shadow: none; } }
@media (prefers-reduced-motion: no-preference) {
  dialog.gh-drawer[open] { animation: gh-drawer-in 0.22s ease-out; }
  @keyframes gh-drawer-in { from { transform: translateX(2.5rem); opacity: 0; } to { transform: none; opacity: 1; } }
}
html.gh-basket-open { overflow: hidden; }
.gh-drawer-head {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "title close" "count close"; align-items: center; column-gap: 0.75rem; flex: none;
  padding: max(0.625rem, env(safe-area-inset-top, 0px)) max(1rem, env(safe-area-inset-right, 0px)) 0.625rem max(1rem, env(safe-area-inset-left, 0px));
  border-bottom: 1px solid var(--line);
}
.gh-drawer-head h2 { grid-area: title; min-width: 0; }
.gh-drawer-count { grid-area: count; color: var(--muted); font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.gh-drawer-close {
  grid-area: close; display: inline-grid; place-items: center; width: 48px; height: 48px; padding: 0; border: 1px solid var(--field);
  border-radius: 24px; background: transparent; color: var(--night); font: inherit; font-size: 1.5rem; line-height: 1; cursor: pointer;
}
.gh-drawer-close:hover { background: var(--foam); }
.gh-drawer-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: 1rem;
  padding: 1rem max(1rem, env(safe-area-inset-right, 0px)) 1.25rem max(1rem, env(safe-area-inset-left, 0px));
}
.gh-drawer-body > section { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.625rem; min-width: 0; }
.gh-drawer-body > section + section { padding-top: 1rem; border-top: 1px solid var(--line); }
.gh-drawer-body #mix-lines { display: none !important; } /* the visual lines below say the same thing */
.gh-drawer-foot {
  flex: none; display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.5rem;
  padding: 0.75rem max(1rem, env(safe-area-inset-right, 0px)) max(0.75rem, env(safe-area-inset-bottom, 0px)) max(1rem, env(safe-area-inset-left, 0px));
  border-top: 1px solid var(--line); background: var(--ice); box-shadow: 0 -0.5rem 1rem rgb(13 44 71 / 0.08);
}
.gh-total-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0.25rem 0.75rem; }
.gh-total-row span { color: var(--night); font-weight: 600; }
.gh-total-row strong { color: var(--night); font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.gh-drawer-foot .fine { margin: 0; }
.gh-drawer-foot #checkout-status { font-size: 0.875rem; }
.gh-empty { display: grid; gap: 0.75rem; justify-items: start; padding: 0.75rem 0; }

/* Lines: photo, product and size, purchase type and recurrence, both prices, line amount, count and remove */
.gh-lines { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.75rem; }
.gh-line {
  display: grid; grid-template-columns: 4.5rem minmax(0, 1fr) auto; column-gap: 0.75rem; row-gap: 0.5rem; align-items: start;
  grid-template-areas: "photo info amount" "photo controls controls" "msg msg msg";
  padding: 0.75rem; border: 1px solid var(--line); border-radius: 0.875rem; background: var(--paper);
}
.gh-line-photo { grid-area: photo; width: 4.5rem; height: 4.5rem; object-fit: contain; border-radius: 0.625rem; background: var(--foam); }
.gh-line-main { grid-area: info; display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.25rem; min-width: 0; }
.gh-line-name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.125rem 0.5rem; color: var(--night); font-weight: 600; line-height: 1.3; }
.gh-line-size { padding: 0 0.375rem; border-radius: 0.375rem; background: var(--foam); color: var(--night); font-size: 0.875rem; }
.gh-line-type { justify-self: start; padding: 0.125rem 0.5rem; border: 1px solid var(--line); border-radius: 999px; font-size: 0.8125rem; color: var(--ink); }
.gh-line-type[data-mode="repeat"] { border-color: var(--ocean); color: var(--ocean); font-weight: 600; }
.gh-line-prices { display: grid; font-size: 0.8125rem; color: var(--muted); }
.gh-line-prices b { font-weight: 600; }
.gh-line-prices .is-applied { color: var(--ink); }
.gh-line-prices .is-applied b { font-weight: 700; }
.gh-line-controls { grid-area: controls; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; }
.gh-stepper { display: inline-grid; grid-template-columns: 44px 3.5rem 44px; height: 44px; border: 1px solid var(--field); border-radius: 0.75rem; overflow: hidden; background: var(--paper); }
.gh-step { min-width: 44px; min-height: 42px; padding: 0; border: 0; background: transparent; color: var(--night); font: inherit; font-size: 1.25rem; line-height: 1; cursor: pointer; }
.gh-step:hover:not(:disabled) { background: var(--foam); }
.gh-step:disabled { color: var(--muted); opacity: 0.45; cursor: not-allowed; }
.gh-qty {
  width: 100%; min-width: 0; height: 42px; min-height: 42px; padding: 0; border: 0; border-inline: 1px solid var(--line); border-radius: 0;
  background: var(--paper); color: var(--ink); font: inherit; font-size: 1rem; text-align: center; font-variant-numeric: tabular-nums;
}
.gh-qty:focus-visible { outline-offset: -3px; }
.gh-remove { min-height: 44px; padding: 0 0.25rem; border: 0; background: none; color: var(--ocean); font: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 0.2em; cursor: pointer; }
.gh-line-msg { grid-area: msg; color: var(--red); font-size: 0.875rem; }
.gh-line-amount { grid-area: amount; color: var(--night); font-weight: 700; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.gh-line-amount small { display: block; color: var(--muted); font-size: 0.75rem; font-weight: 400; }
@media (max-width: 30rem) {
  .gh-line { grid-template-columns: 3.75rem minmax(0, 1fr) auto; grid-template-areas: "photo info info" "controls controls amount" "msg msg msg"; }
  .gh-line-photo { width: 3.75rem; height: 3.75rem; }
  .gh-line-amount { align-self: center; }
}
@media (max-width: 22rem) {
  .gh-line { grid-template-areas: "photo info info" "controls controls controls" "amount amount amount" "msg msg msg"; }
  .gh-line-amount { text-align: left; }
  .gh-line-amount small { display: inline; margin-left: 0.375rem; }
}
@media (forced-colors: active) {
  .gh-badge { border: 1px solid CanvasText; }
  dialog.gh-drawer { border: 1px solid CanvasText; }
  .gh-line-prices .is-applied { text-decoration: underline; }
}

/* R3: the recurring agreement sits directly under the reviewed First order / Future deliveries totals. */
.recurring-agreement { display: grid; gap: 0.25rem; padding: min(0.75rem, 3vw); border-radius: 0.75rem; background: var(--foam, #eef7f8); border: 1px solid rgba(0,0,0,0.08); scroll-margin-block: 0.75rem; }
.recurring-agreement .consent { min-height: 44px; }
.gh-review-retry { justify-self: start; min-height: 44px; }
/* Product photos are cropped by the SVG viewBox with overflow visible, so the full image's transparent margin can sit over
   the card above and swallow taps (at 320px it covers the Black "Add to basket"). Photos are decorative: let taps through. */
article.product svg image { pointer-events: none; }
