/* Storess Cart — Shopify-style Buy Button + drawer + embedded checkout */

:root {
  --storess-fg: #111;
  --storess-bg: #fff;
  --storess-muted: #6b7280;
  --storess-border: #e5e7eb;
  --storess-accent: #111;
  --storess-accent-fg: #fff;
  --storess-radius: 10px;
  --storess-z-fab: 999990;
  --storess-z-drawer: 999995;
  --storess-z-modal: 999999;
}

/* Any element with data-storess-buy gets a pointer cursor and a clean
   transition for the disabled state. Add the .storess-buy class on top if
   you want the full pill-button look. Uses !important to win over theme
   rules (e.g. LayTheme forcing cursor:text on span/p). */
[data-storess-buy] {
  cursor: pointer !important;
  transition: opacity .15s ease;
}
[data-storess-buy][aria-disabled="true"],
.storess-buy--disabled {
  opacity: .45;
  cursor: not-allowed !important;
  pointer-events: none;
}

/* Optional opt-in pill button styling */
.storess-buy {
  display: inline-block;
  padding: .7rem 1.1rem;
  border-radius: var(--storess-radius);
  background: var(--storess-accent);
  color: var(--storess-accent-fg);
  border: none;
  font: inherit;
  line-height: 1.2;
}
.storess-buy:hover { opacity: .9; }

/* Buy button on LayTheme's "Button 2" (a solid #111 pill, 15px radius, that
   grows on hover): outline with a transparent background that fills on hover,
   tighter corners, no grow. The cart icon (::after) is currentColor, so it
   follows. !important + the attribute selector beat the theme's !important. */
a[data-storess-buy].laybutton2,
a[data-keffer-buy].laybutton2 {
  border-radius: 6px !important;
  background-color: transparent !important;
  color: #444 !important;
  border: 2px solid #444 !important;
  /* !important: the theme's own transition (200ms) is !important too. */
  transition: background-color .05s ease, color .05s ease, border-color .05s ease, opacity .15s ease !important;
}
a[data-storess-buy].laybutton2:hover,
a[data-keffer-buy].laybutton2:hover {
  transform: none !important;
}
/* The fill is for real pointers only. On a touch screen iOS Safari spends the
   first tap applying :hover and only the second one clicks — the button needed
   two taps to add to cart. No hover there, no swallowed tap. */
@media (hover: hover) and (pointer: fine) {
  a[data-storess-buy].laybutton2:hover,
  a[data-keffer-buy].laybutton2:hover {
    background-color: #111 !important;
    border-color: #111 !important;
    color: #f7f7f7 !important;
  }
}

/* Dark mode (LayTheme adds body.dark-mode from prefers-color-scheme): same
   outline in the theme's dark text colour. The theme's dark link rules repaint
   text + a 2px border-bottom #999 on hover; specificity (0,4,2) on the hover
   selectors is what beats its .dark-mode .caption.lay-textformat-parent a:hover
   (0,4,1) — don't shorten these selectors. */
body.dark-mode .lay-textformat-parent a[data-storess-buy],
body.dark-mode .lay-textformat-parent a[data-keffer-buy] {
  background-color: transparent !important;
  color: #999 !important;
  border: 2px solid #999 !important;
}
@media (hover: hover) and (pointer: fine) {
  body.dark-mode .lay-textformat-parent a[data-storess-buy]:hover,
  body.dark-mode .lay-textformat-parent a[data-keffer-buy]:hover {
    background-color: #eee !important;
    color: #111 !important;
    border: 2px solid #eee !important;
  }
}

/* Floating Action Button (cart icon, bottom-right) */
.storess-fab {
  position: fixed;
  right: 50px;
  bottom: 50px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--storess-accent);
  color: var(--storess-accent-fg);
  border: none;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(0,0,0,.2);
  z-index: var(--storess-z-fab);
  transform: scale(.4);
  opacity: 0;
  transition: transform .2s ease, opacity .2s ease;
}
.storess-fab.storess-fab--show {
  display: flex;
  transform: scale(1);
  opacity: 1;
}
/* Dark mode: the #111 button vanishes on LayTheme's #111 page. White 2px ring
   (box-shadow, not border: no size change, badge stays put). */
body.dark-mode .storess-fab {
  box-shadow: 0 0 0 2px #fff;
}
.storess-fab__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  background: #ef4444;
  color: #fff;
  border-radius: 100px;
  font: 600 11px/22px system-ui, sans-serif;
  text-align: center;
}

/* Backdrop (shared by drawer) */
.storess-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
  z-index: var(--storess-z-drawer);
}
.storess-backdrop.storess-backdrop--show {
  opacity: 1;
  pointer-events: auto;
}

/* Neutralize theme-wide form overrides (LayTheme sets input { width: 95% })
   that would otherwise blow up radios/checkboxes inside our drawer. */
.storess-drawer input[type="radio"],
.storess-drawer input[type="checkbox"] {
  width: auto !important;
  height: auto !important;
  min-width: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  flex: 0 0 auto !important;
  appearance: auto;
  -webkit-appearance: auto;
}
.storess-drawer label { max-width: 100%; }

/* Lock page scroll while the drawer is open without losing scroll position.
   body gets position:fixed + top offset (set by JS) so overflow:hidden on
   <html> alone is enough; restoring top+scrollY on close keeps the position. */
html.storess-no-scroll { overflow: hidden !important; }
body.storess-no-scroll {
  position: fixed !important;
  width: 100% !important;
  overflow-y: scroll !important;
}

/* Force readable filled-input text (theme often sets color:#999 globally). */
.storess-drawer input,
.storess-drawer textarea,
.storess-drawer select {
  color: #111 !important;
  -webkit-text-fill-color: #111 !important;
}
.storess-drawer input::placeholder,
.storess-drawer textarea::placeholder {
  color: #9ca3af !important;
  -webkit-text-fill-color: #9ca3af !important;
}

/* Drawer */
.storess-drawer {
  position: fixed;
  top: 0;
  right: 0;
  /* 100vh on mobile is measured against the "large" viewport (as if the
     browser's address/tool bars were hidden), so on browsers that keep those
     bars visible the drawer ends up taller than what's actually on screen and
     the footer (checkout buttons) gets pushed below the fold. 100svh ("small"
     viewport height) always assumes the bars are visible, so the drawer fits
     inside the space that's actually visible, guaranteeing the footer is
     reachable. Plain 100vh stays first as a fallback for older browsers that
     don't understand svh (they'll get the old, imperfect behavior). */
  height: 100vh;
  height: 100svh;
  width: 380px;
  max-width: 100vw;
  background: var(--storess-bg);
  color: var(--storess-fg);
  display: flex;
  flex-direction: column;
  transform: translateX(110%);
  transition: transform .25s ease-out;
  box-shadow: -8px 0 30px rgba(0,0,0,.15);
  z-index: var(--storess-z-drawer);
  font: 14px/1.45 system-ui, -apple-system, sans-serif;
}
.storess-drawer.storess-drawer--show { transform: translateX(0); }
@media (max-width: 600px) {
  .storess-drawer { width: 100vw; }
}
.storess-drawer__head {
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--storess-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.storess-drawer__head h2 { margin: 0; font-size: 1.05rem; font-weight: 600; }
.storess-drawer__body { flex: 1; overflow-y: auto; padding: .5rem 1.25rem; }
.storess-drawer__foot {
  border-top: 1px solid var(--storess-border);
  padding: 1rem 1.25rem 1.25rem;
  background: var(--storess-bg);
}

.storess-iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: inherit;
}
.storess-iconbtn:hover { background: rgba(0,0,0,.05); }

/* Empty state */
.storess-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--storess-muted);
}
.storess-empty p { margin: 0 0 1rem; }

/* Cart row */
.storess-row {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--storess-border);
  align-items: flex-start;
}
.storess-row:last-child { border-bottom: none; }
/* The image runs the full height of the row, down to the quantity controls. */
.storess-row__img {
  width: 80px;
  align-self: stretch;
  min-height: 80px;
  border-radius: 8px;
  overflow: hidden;
  background: #f3f4f6;
}
.storess-row__img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.storess-row__noimg {
  width: 100%; height: 100%; background: #f3f4f6;
}
.storess-row__name { font-weight: 500; line-height: 1.3; }
.storess-row__price { color: var(--storess-muted); font-size: .85rem; margin-top: 2px; }
.storess-row__pre { color: var(--storess-muted); font-size: .75rem; font-style: italic; margin-top: 2px; }
.storess-row__right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  min-width: 70px;
}
.storess-row__total { font-weight: 500; }
.storess-row__remove { color: var(--storess-muted); }
.storess-row__remove:hover { color: #b91c1c; }

/* Qty selector — minimal: − 1 + on a single line */
.storess-qty {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  color: var(--storess-muted);
  font-size: .8rem;
  line-height: 1;
}
.storess-qty__btn {
  width: 16px;
  height: 16px;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  color: inherit;
  opacity: .6;
}
.storess-qty__btn:hover { opacity: 1; }
.storess-qty__in {
  width: 22px;
  height: 16px;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  border-bottom: none !important;
  box-shadow: none !important;
  background: transparent !important;
  text-align: center;
  font: inherit;
  color: var(--storess-fg);
  -moz-appearance: textfield;
}
/* The theme paints a border/box-shadow on focused inputs that breaks the qty
   stepper's flush look — strip those, but keep a visible focus ring for
   keyboard users. :focus-visible only shows it for keyboard focus, so the
   mouse/touch appearance is unchanged. */
.storess-qty__in:focus { outline: none !important; border: none !important; box-shadow: none !important; }
.storess-qty__in:focus-visible { outline: 2px solid var(--storess-accent) !important; outline-offset: 1px !important; }
.storess-qty__in::-webkit-outer-spin-button,
.storess-qty__in::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Footer */
.storess-sub {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 4px;
}
.storess-note {
  margin: 0 0 .9rem;
  color: var(--storess-muted);
  font-size: .8rem;
}
.storess-btn {
  display: block;
  width: 100%;
  padding: .85rem 1rem;
  border-radius: 10px;
  border: none;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
}
.storess-btn--primary {
  background: var(--storess-accent);
  color: var(--storess-accent-fg);
}
.storess-btn--primary:hover { opacity: .92; }
.storess-btn--primary:disabled { opacity: .5; cursor: not-allowed; }
.storess-btn--secondary {
  background: #f3f4f6;
  color: var(--storess-fg);
}
.storess-err {
  margin-top: .6rem;
  padding: .55rem .8rem;
  background: #fee2e2;
  color: #991b1b;
  border-radius: 8px;
  font-size: .85rem;
}
