/* ==========================================================================
   Shop — Adafruit-inspired styling (Rails + Hotwire)
   Near-black header, blue links, list-style category pages, gallery product
   pages. Loaded on top of Bootstrap 5 (Wt theme).
   ========================================================================== */

:root {
  --shop-dark:   #1a1919;   /* header / footer, like adafruit's #1a1919 */
  --shop-link:   #0b5ed7;
  --shop-accent: #17a2b8;
  --shop-green:  #1e7e34;
  --shop-red:    #c0392b;
  --shop-border: #e3e3e3;
  --shop-muted:  #6c757d;
}

body {
  background: #ffffff;
  color: #212529;
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--shop-link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Header ---------- */
.shop-header {
  background: var(--shop-dark);
  color: #fff;
  padding: 0.6rem 1rem;
}
.shop-header .shop-brand {
  color: #fff;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-decoration: none;
}
.shop-header .shop-brand:hover { color: #ddd; text-decoration: none; }

.shop-header-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  max-width: 1200px;
  margin: 0 auto;
}

.shop-search { flex: 1 1 320px; display: flex; }
.shop-search input {
  border: none;
  border-radius: 3px 0 0 3px;
  padding: 0.45rem 0.75rem;
  width: 100%;
}
.shop-search .btn {
  border-radius: 0 3px 3px 0;
  background: #444;
  color: #fff;
  border: none;
}
.shop-search .btn:hover { background: #666; color: #fff; }

.shop-header-links { display: flex; align-items: center; gap: 0.75rem; }
.shop-header-links a, .shop-header-links .btn-link {
  color: #ddd; font-size: 0.95rem; text-decoration: none;
}
.shop-header-links a:hover { color: #fff; }

.shop-cart-link {
  background: #333;
  border-radius: 3px;
  padding: 0.35rem 0.8rem;
  color: #fff !important;
  font-weight: 600;
}
.shop-cart-link:hover { background: #555; text-decoration: none; }

/* ---------- Category strip + mega menu ----------
   These selectors match the markup in shared/_header.html.erb and
   shared/_category_nav.html.erb. (An earlier revision shipped rules for a
   different set of class names, so none of this was applying.) */

/* The header is the positioning context for the full-width mega panel. */
.shop-header { position: relative; }

.mega-wrap { position: static; }

/* Invisible bridge across the header padding between the trigger and the
   panel, so moving the pointer down doesn't leave the menu. */
.mega-wrap::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  top: 100%;
  height: 0;
}
.mega-wrap:hover::after { height: 14px; }

.mega-toggle {
  background: #333;
  border: 1px solid #4a4a4a;
  border-radius: 3px;
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}
.mega-toggle:hover { background: #4a4a4a; }
.mega-wrap:hover .mega-toggle { background: var(--shop-link); border-color: var(--shop-link); }

.mega-panel {
  display: none;
  position: absolute;
  left: 0; right: 0; top: 100%;
  background: #fff;
  color: #212529;
  border-bottom: 3px solid var(--shop-link);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
  z-index: 1000;
}
.mega-wrap:hover .mega-panel,
.mega-panel.mega-open { display: block; }

.mega-cols {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  gap: 2.5rem;
  padding: 1.25rem 1rem 1.5rem;
  flex-wrap: wrap;
}
.mega-col-cats { flex: 2 1 420px; min-width: 0; }
.mega-col-list { flex: 1 1 240px; min-width: 230px; }

.mega-title {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  border-bottom: 1px solid var(--shop-border);
  padding-bottom: 0.35rem;
  margin-bottom: 0.75rem;
  font-weight: 700;
  font-size: 1.05rem;
}
.mega-title .viewall { font-size: 0.85rem; font-weight: 400; }

.mega-cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 0.1rem 1.5rem;
}
.mega-cat-grid a { display: block; padding: 0.22rem 0; font-size: 0.95rem; }

.mega-item {
  display: flex;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
  align-items: flex-start;
}
.mega-item img {
  width: 68px; height: 51px; object-fit: cover;
  border-radius: 3px; border: 1px solid var(--shop-border);
  flex: 0 0 auto;
}
.mega-item .noimg {
  width: 68px; height: 51px; background: #f2f2f2;
  border-radius: 3px; flex: 0 0 auto; display: block;
}
.mega-item-name { font-size: 0.9rem; font-weight: 600; line-height: 1.3; }
.mega-item-price { font-weight: 700; font-size: 0.9rem; margin-top: 0.1rem; }

.bulk-link { color: #ddd; font-size: 0.9rem; white-space: nowrap; }
.bulk-link:hover { color: #fff; }

/* ---------- Category strip under the header ---------- */
.shop-catnav {
  background: #f5f5f5;
  border-bottom: 1px solid var(--shop-border);
  padding: 0.4rem 1rem;
}
.shop-catnav-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.1rem;
}
.shop-catnav a {
  color: #333;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.15rem 0;
}
.shop-catnav a:hover { color: var(--shop-link); text-decoration: none; }

@media (max-width: 991px) {
  .mega-cols { flex-direction: column; gap: 1.5rem; }
  .mega-panel { max-height: 70vh; overflow-y: auto; }
}

/* ---------- Content wrapper ---------- */
.shop-content { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }

/* ---------- Breadcrumb ---------- */
.shop-breadcrumb { font-size: 0.9rem; color: var(--shop-muted); margin-bottom: 0.75rem; }
.shop-breadcrumb a { color: var(--shop-muted); }
.shop-breadcrumb a:hover { color: var(--shop-link); }

/* Category page H1: "Power / USB Battery Packs" */
.shop-cat-title { font-size: 1.9rem; font-weight: 700; margin-bottom: 1rem; }
.shop-cat-title a { color: var(--shop-link); }

.category-desc img { max-width: 100%; height: auto; }

/* ---------- Subcategory chips ---------- */
.shop-subcats { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 0.5rem 0 1.5rem; }
.shop-subcat-card {
  border: 1px solid var(--shop-border);
  border-radius: 4px;
  padding: 0.6rem 0.9rem;
  display: flex; align-items: center; gap: 0.6rem;
  background: #fafafa;
}
.shop-subcat-card:hover { border-color: var(--shop-link); background: #fff; }
.shop-subcat-card img { width: 48px; height: 36px; object-fit: cover; border-radius: 3px; }
.shop-subcat-card a { font-weight: 600; }

/* ---------- Adafruit-style product LIST rows ---------- */
.product-row {
  display: flex;
  gap: 1.25rem;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--shop-border);
  align-items: flex-start;
}
.product-row-thumb {
  flex: 0 0 180px;
}
.product-row-thumb img {
  width: 180px; height: 135px; object-fit: cover;
  border-radius: 3px; border: 1px solid var(--shop-border);
}
.product-row-thumb .noimg {
  width: 180px; height: 135px; display: flex; align-items: center; justify-content: center;
  background: #f2f2f2; color: #aaa; border-radius: 3px; font-size: 0.85rem;
}
.product-row-main { flex: 1 1 auto; min-width: 0; }
.product-row-main h2 { font-size: 1.25rem; font-weight: 700; margin: 0 0 0.15rem; }
.product-row-main h2 a { color: var(--shop-link); }
.product-row-pid { color: var(--shop-muted); font-size: 0.85rem; margin-bottom: 0.4rem; }
.product-row-desc { color: #333; font-size: 0.95rem; line-height: 1.45; margin-bottom: 0.5rem; }

.product-row-buy {
  flex: 0 0 170px;
  text-align: right;
  display: flex; flex-direction: column; align-items: flex-end; gap: 0.35rem;
}
.product-price { font-size: 1.2rem; font-weight: 700; }
.stock-in  { color: var(--shop-green); font-size: 0.9rem; }
.stock-out { color: var(--shop-red);   font-size: 0.9rem; }
.stock-disc{ color: var(--shop-muted); font-size: 0.9rem; font-style: italic; }

.btn-addcart {
  background: var(--shop-dark); color: #fff; border: none;
  padding: 0.45rem 1.1rem; border-radius: 3px; font-weight: 600;
}
.btn-addcart:hover { background: #000; color: #fff; }
.btn-addcart:disabled { background: #999; }

@media (max-width: 767px) {
  .product-row { flex-wrap: wrap; }
  .product-row-buy { flex-basis: 100%; align-items: flex-start; text-align: left; }
}

/* ---------- Product detail ---------- */
.pd-title { font-size: 1.8rem; font-weight: 700; margin-bottom: 0.15rem; }
.pd-pid { color: var(--shop-muted); margin-bottom: 1rem; }

.pd-gallery-main img {
  /* Fills the column. A photo smaller than the column gets upscaled, so keep
     product shots reasonably large; swap width to `auto` if you'd rather a
     small image sat at its native size than stretched. */
  width: 100%; max-width: 100%;
  /* height:auto keeps the aspect ratio when the src is an unresized original
     (no libvips), where the width/height attributes aren't set. */
  height: auto;
  border: 1px solid var(--shop-border); border-radius: 4px;
}
.pd-thumbs { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.6rem; }
.pd-thumbs img {
  width: 88px; height: 66px; object-fit: cover;
  border: 2px solid transparent; border-radius: 3px; cursor: pointer;
  outline: 1px solid var(--shop-border);
}
.pd-thumbs img:hover, .pd-thumbs img.active { border-color: var(--shop-link); }

.pd-buybox {
  border: 1px solid var(--shop-border);
  border-radius: 4px;
  padding: 1.25rem;
  background: #fafafa;
}

/* Sticky purchase column (like adafruit.com/product/1620) */
.pd-sticky {
  position: sticky;
  top: 1rem;
}
@media (max-width: 991px) {
  .pd-sticky { position: static; }
}

/* Jump links to page sections, under the buy box */
.pd-jumplinks {
  margin-top: 0.9rem;
  border: 1px solid var(--shop-border);
  border-radius: 4px;
  padding: 0.6rem 0.9rem;
  background: #fff;
}
.pd-jumplink {
  display: block;
  color: var(--shop-link);
  cursor: pointer;
  padding: 0.25rem 0;
  font-size: 0.95rem;
}
.pd-jumplink:hover { text-decoration: underline; }

/* Anchor targets: leave room for smooth-scroll landing */
.pd-anchor { scroll-margin-top: 1rem; }
.pd-price { font-size: 1.7rem; font-weight: 700; margin-bottom: 0.5rem; }

.pd-tiers { width: 100%; margin: 0.5rem 0 0.75rem; border-collapse: collapse; font-size: 0.92rem; }
.pd-tiers th, .pd-tiers td { border: 1px solid var(--shop-border); padding: 0.3rem 0.6rem; text-align: left; background: #fff; }
.pd-tiers th { background: #efefef; font-weight: 600; }

.pd-qty-row { display: flex; align-items: center; gap: 0.6rem; margin: 0.75rem 0; }
.pd-qty-row .form-control { width: 90px; }

.pd-section-title {
  font-size: 1.35rem; font-weight: 700;
  border-bottom: 2px solid var(--shop-dark);
  padding-bottom: 0.3rem; margin: 2.25rem 0 1rem;
}
.pd-description img, .pd-tech img { max-width: 100%; height: auto; }

/* ---------- "May We Also Suggest" ---------- */
.suggest-grid { display: flex; flex-wrap: wrap; gap: 1rem; }
.suggest-card {
  flex: 0 0 calc(25% - 0.75rem);
  min-width: 180px;
  border: 1px solid var(--shop-border);
  border-radius: 4px;
  padding: 0.6rem;
  text-align: center;
}
.suggest-card img { width: 100%; height: 110px; object-fit: cover; border-radius: 3px; }
.suggest-card .noimg { width: 100%; height: 110px; background: #f2f2f2; border-radius: 3px; }
.suggest-card a { display: block; margin-top: 0.5rem; font-size: 0.9rem; font-weight: 600; line-height: 1.3; }
.suggest-card .sprice { margin-top: 0.25rem; font-weight: 700; }

/* ---------- Home ---------- */
.home-hero {
  background: var(--shop-dark);
  color: #fff;
  border-radius: 6px;
  padding: 2.25rem 2rem;
  margin-bottom: 2rem;
}
.home-hero h1 { font-weight: 800; }
.home-hero p { color: #ccc; max-width: 640px; }

/* Flex rather than a floated link: the float sat outside the heading's flow,
   so on a narrow screen the "view all" link overlapped the title instead of
   moving below it. */
.home-section-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  font-size: 1.4rem; font-weight: 700;
  border-bottom: 2px solid var(--shop-dark);
  padding-bottom: 0.3rem; margin: 1.5rem 0 1rem;
}
.home-section-title .viewall {
  float: none;                 /* beats .float-end in the markup */
  font-size: 0.9rem;
  font-weight: 400;
}

/* ---------- Cart ---------- */
.cart-row {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.9rem 0; border-bottom: 1px solid var(--shop-border);
}
.cart-thumb img { width: 90px; height: 68px; object-fit: cover; border-radius: 3px; border: 1px solid var(--shop-border); }
.cart-name { flex: 1 1 auto; }
.cart-name a { font-weight: 600; }
.cart-unit { flex: 0 0 110px; }
.cart-qty  { flex: 0 0 100px; }
.cart-line { flex: 0 0 110px; font-weight: 700; text-align: right; }
.cart-total-row { text-align: right; font-size: 1.3rem; font-weight: 700; margin-top: 1rem; }
.tier-note { color: var(--shop-green); font-size: 0.85rem; }

/* ---------- Footer ---------- */
.shop-footer {
  background: var(--shop-dark);
  color: #bbb;
  padding: 2rem 1rem;
  margin-top: 3rem;
  font-size: 0.9rem;
}
.shop-footer-inner { max-width: 1200px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 3rem; }
.shop-footer a { color: #ddd; }
.shop-footer a:hover { color: #fff; }

/* ==========================================================================
   v3 additions: mega menu + Adafruit-style cart
   ========================================================================== */

/* ---------- Cart (Adafruit shopping_cart style) ---------- */
.cart-panel-title {
  background: #3a3a3a;
  color: #fff;
  font-weight: 600;
  padding: 0.5rem 0.9rem;
  border-radius: 3px 3px 0 0;
}
.cart-panel {
  border: 1px solid var(--shop-border);
  border-top: none;
  padding: 1rem;
  border-radius: 0 0 3px 3px;
}

.cart-topbar {
  display: flex; justify-content: flex-end; align-items: center;
  gap: 0.75rem; margin-bottom: 0.75rem;
}

.btn-checkout {
  background: var(--shop-link); color: #fff; border: none;
  padding: 0.5rem 1.25rem; border-radius: 3px; font-weight: 700;
}
.btn-checkout:hover { background: #094db1; color: #fff; }

.cart-table { width: 100%; }
.cart-head, .cart-item-row {
  display: grid;
  grid-template-columns: 90px 1fr 110px 110px 80px 110px;
  gap: 0.75rem;
  align-items: center;
}
.cart-head {
  border-bottom: 2px solid #333;
  padding-bottom: 0.4rem;
  font-weight: 600;
  color: #444;
}
.cart-item-row { padding: 0.9rem 0; border-bottom: 1px solid var(--shop-border); }
.cart-item-row .cart-img img {
  width: 80px; height: 60px; object-fit: cover;
  border: 1px solid var(--shop-border); border-radius: 3px;
}
.cart-item-name a { font-weight: 600; }
.cart-item-pid { color: var(--shop-muted); font-size: 0.85rem; }
.cart-col-right { text-align: right; font-weight: 700; }

.btn-trash {
  background: transparent; border: none; color: var(--shop-muted);
  font-size: 1.1rem; cursor: pointer; padding: 0.2rem 0.5rem;
}
.btn-trash:hover { color: var(--shop-red); }

.cart-bottom {
  display: flex; flex-wrap: wrap; gap: 1.5rem;
  margin-top: 1rem; align-items: flex-start;
}
.cart-coupon { flex: 1 1 300px; }
.cart-coupon .form-control { max-width: 260px; display: inline-block; }
.cart-summary { flex: 1 1 300px; margin-left: auto; max-width: 380px; }
.cart-summary-row {
  display: flex; justify-content: space-between;
  padding: 0.25rem 0; font-size: 0.98rem;
}
.cart-summary-row .muted { color: var(--shop-muted); font-size: 0.85rem; }
.cart-summary-total {
  border-top: 2px solid #333; margin-top: 0.4rem; padding-top: 0.5rem;
  font-weight: 800; font-size: 1.15rem;
  display: flex; justify-content: space-between;
}

.cart-actions {
  display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--shop-border);
}
.cart-actions .spacer { flex: 1 1 auto; }

.payment-area { margin-top: 1.25rem; max-width: 420px; margin-left: auto; }

/* "You may also like" sidebar */
.cart-aside-title {
  background: #3a3a3a; color: #fff; font-weight: 600;
  padding: 0.5rem 0.9rem; border-radius: 3px 3px 0 0;
}
.cart-aside {
  border: 1px solid var(--shop-border); border-top: none;
  border-radius: 0 0 3px 3px; padding: 0.75rem;
}
.cart-aside-item {
  display: flex; gap: 0.7rem; padding: 0.7rem 0;
  border-bottom: 1px solid var(--shop-border);
}
.cart-aside-item:last-child { border-bottom: none; }
.cart-aside-item img {
  width: 72px; height: 54px; object-fit: cover;
  border: 1px solid var(--shop-border); border-radius: 3px; flex: 0 0 72px;
}
.cart-aside-item .noimg { width: 72px; height: 54px; background: #f2f2f2; border-radius: 3px; flex: 0 0 72px; }
.cart-aside-name { font-size: 0.9rem; line-height: 1.3; }
.cart-aside-price { font-weight: 700; margin: 0.15rem 0 0.3rem; }
.btn-aside-add {
  background: var(--shop-link); color: #fff; border: none;
  padding: 0.3rem 0.75rem; border-radius: 3px; font-size: 0.85rem; font-weight: 600;
}
.btn-aside-add:hover { background: #094db1; }


/* ==========================================================================
   Hotwire/Rails additions
   ========================================================================== */

/* Smooth scrolling for the product-page jump links (no JS needed) */
html { scroll-behavior: smooth; }

/* Mega menu open state is toggled by the Stimulus controller */
.mega-panel.mega-open { display: block; }

/* Trix (Action Text) editor — replaces TinyMCE */
trix-editor {
  min-height: 220px;
  border: 1px solid var(--shop-border);
  border-radius: 4px;
  background: #fff;
  padding: 0.75rem;
}
trix-editor:focus { outline: 2px solid var(--shop-link); outline-offset: -1px; }
trix-toolbar .trix-button-group { border-color: var(--shop-border); }

/* Action Text attachments inside product copy */
.pd-description action-text-attachment img,
.pd-tech action-text-attachment img,
.category-desc action-text-attachment img { max-width: 100%; height: auto; }

/* "Added ✓" confirmation swapped in by Turbo after add-to-cart */
.added-badge {
  display: inline-block;
  background: var(--shop-green);
  color: #fff;
  border-radius: 3px;
  padding: 0.45rem 1.1rem;
  font-weight: 600;
}

/* button_to renders a <form>; inline-block keeps it a proper flex item
   (display:inline collapsed its height and let siblings overlap it). */
.product-row-buy form, .cart-actions form, .btn-group form,
.cart-row-actions form { display: inline-block; margin: 0; }
.btn-trash { line-height: 1; }

/* ==========================================================================
   v2 additions: urgency, filters, coupons, dashboard, accessibility
   ========================================================================== */

/* ---------- Accessibility ---------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: #fff;
  color: var(--shop-link);
  padding: 0.6rem 1rem;
  z-index: 2000;
  border-radius: 0 0 4px 0;
}
.skip-link:focus { left: 0; }

/* Visible focus everywhere — the default Bootstrap ring is easy to lose
   against the dark header. */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid #ffbf47;
  outline-offset: 2px;
}
main:focus { outline: none; }

/* ---------- Stock urgency ---------- */
.low-stock-badge {
  display: inline-block;
  background: #fff4e5;
  color: #a05a00;
  border: 1px solid #ffd8a8;
  border-radius: 3px;
  padding: 0.1rem 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  margin-top: 0.2rem;
}

/* ---------- Notify me ---------- */
.notify-form { display: flex; gap: 0.4rem; }
.notify-form .form-control { flex: 1 1 auto; }

/* ---------- Tags ---------- */
.pd-tags { margin-top: 0.9rem; display: flex; flex-wrap: wrap; gap: 0.35rem; }
.tag-chip {
  display: inline-block;
  background: #f1f3f5;
  border: 1px solid var(--shop-border);
  border-radius: 999px;
  padding: 0.15rem 0.7rem;
  font-size: 0.85rem;
  color: #444;
}
.tag-chip:hover { background: #fff; border-color: var(--shop-link); color: var(--shop-link); text-decoration: none; }

/* ---------- Filter bar ---------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  padding: 0.75rem;
  background: #f8f9fa;
  border: 1px solid var(--shop-border);
  border-radius: 4px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.filter-bar label { display: flex; align-items: center; gap: 0.4rem; margin: 0; }
.filter-bar .form-select, .filter-bar .form-control { width: auto; min-width: 110px; }
.filter-price { max-width: 100px; }
.filter-check { gap: 0.3rem; }

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem 0;
}
.page-link {
  border: 1px solid var(--shop-border);
  border-radius: 3px;
  padding: 0.4rem 0.9rem;
  font-weight: 600;
}
.page-link:hover { border-color: var(--shop-link); text-decoration: none; }
.page-status { color: var(--shop-muted); font-size: 0.9rem; }

/* ---------- Coupons ---------- */
.coupon-form { display: flex; gap: 0.4rem; max-width: 320px; }
.coupon-applied {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: #e8f5e9;
  border: 1px solid #a5d6a7;
  border-radius: 3px;
  padding: 0.5rem 0.8rem;
  max-width: 360px;
}

/* ---------- Orders ---------- */
.order-line { grid-template-columns: 1fr 80px 110px; }

/* ---------- Admin dashboard ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.stat-card {
  border: 1px solid var(--shop-border);
  border-radius: 4px;
  padding: 1rem 1.25rem;
  background: #fff;
}
.stat-card.stat-warn { border-color: #ffd8a8; background: #fff9f0; }
.stat-value { font-size: 1.9rem; font-weight: 800; line-height: 1.1; }
.stat-label { color: var(--shop-muted); font-size: 0.85rem; margin-top: 0.2rem; }
.stat-pill {
  display: inline-block;
  background: #eef1f4;
  border-radius: 999px;
  padding: 0.05rem 0.55rem;
  font-size: 0.78rem;
  color: #555;
}
.admin-list { list-style: none; padding: 0; margin: 0; }
.admin-list li {
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--shop-border);
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

/* Turbo Frame loading state — subtle, so filtering doesn't feel broken */
turbo-frame[busy] { opacity: 0.55; transition: opacity 120ms ease-in; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  turbo-frame[busy] { transition: none; }
}

/* ---------- Admin section nav ---------- */
.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  padding: 0.6rem 0.9rem;
  background: #f1f3f5;
  border: 1px solid var(--shop-border);
  border-radius: 4px;
  margin-bottom: 1.5rem;
  font-weight: 600;
  font-size: 0.92rem;
}

/* ==========================================================================
   v3: mini-cart, typeahead, live stock, specs, ledger, fulfilment
   ========================================================================== */

/* ---------- Mini-cart drawer ---------- */
.mini-cart {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(420px, 92vw);
  background: #fff;
  z-index: 1200;
  box-shadow: -8px 0 32px rgba(0,0,0,0.22);
  transform: translateX(100%);
  transition: transform 200ms ease-out;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.mini-cart-open .mini-cart { transform: translateX(0); }

.mini-cart-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 1100;
  opacity: 0;
  transition: opacity 200ms ease-out;
}
.mini-cart-open .mini-cart-backdrop { opacity: 1; }

.mini-cart-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--shop-border);
  position: sticky; top: 0; background: #fff; z-index: 1;
}
.mini-cart-close {
  background: none; border: none; font-size: 1.6rem; line-height: 1;
  cursor: pointer; color: var(--shop-muted);
}
.mini-cart-items { padding: 0.5rem 1rem; flex: 1 1 auto; }
.mini-cart-item {
  display: grid;
  grid-template-columns: 60px 1fr auto;
  gap: 0.7rem; align-items: center;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--shop-border);
}
.mini-cart-item img { width: 60px; height: 45px; object-fit: cover; border-radius: 3px; }
.mini-cart-item .noimg { width: 60px; height: 45px; background: #f2f2f2; border-radius: 3px; }
.mini-cart-name { font-size: 0.92rem; font-weight: 600; }
.mini-cart-foot {
  padding: 1rem;
  border-top: 1px solid var(--shop-border);
  position: sticky; bottom: 0; background: #fff;
}

/* Free-shipping progress nudge */
.ship-nudge {
  background: #f1f8ff;
  border: 1px solid #cfe2ff;
  border-radius: 4px;
  padding: 0.5rem 0.7rem;
  font-size: 0.88rem;
  margin-bottom: 0.75rem;
}
.ship-nudge-win { background: #e8f5e9; border-color: #a5d6a7; font-weight: 600; }
.ship-meter {
  height: 6px; background: #dbe7f5; border-radius: 999px;
  margin-top: 0.4rem; overflow: hidden;
}
.ship-meter span { display: block; height: 100%; background: var(--shop-link); border-radius: 999px; }

/* ---------- Search typeahead ---------- */
.shop-search-wrap { position: relative; flex: 1 1 320px; }
.typeahead-panel {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: #fff; color: #212529;
  border: 1px solid var(--shop-border);
  border-radius: 4px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.22);
  z-index: 1050;
  overflow: hidden;
}
.typeahead-item {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 0.7rem; align-items: center;
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid #f1f1f1;
  color: #212529;
}
.typeahead-item:hover, .typeahead-item:focus {
  background: #f4f8ff; text-decoration: none; outline: none;
}
.typeahead-item img { width: 44px; height: 33px; object-fit: cover; border-radius: 3px; }
.typeahead-item .noimg { width: 44px; height: 33px; background: #f2f2f2; border-radius: 3px; }
.typeahead-name { font-size: 0.92rem; }
.typeahead-price { font-weight: 700; font-size: 0.9rem; }
.typeahead-tags { padding: 0.5rem 0.8rem; display: flex; gap: 0.3rem; flex-wrap: wrap; }
.typeahead-all {
  display: block; padding: 0.55rem 0.8rem;
  background: #fafafa; font-weight: 600; font-size: 0.9rem;
}
.typeahead-empty { padding: 0.8rem; color: var(--shop-muted); font-size: 0.9rem; }

/* ---------- Live availability ---------- */
.availability { margin-bottom: 0.5rem; }
.held-note { color: var(--shop-muted); font-size: 0.82rem; font-style: italic; }
.lifecycle-badge {
  display: inline-block; border-radius: 3px; padding: 0.1rem 0.5rem;
  font-size: 0.8rem; font-weight: 600; margin-top: 0.25rem;
}
.lifecycle-nrnd { background: #fff4e5; color: #a05a00; border: 1px solid #ffd8a8; }
.lifecycle-eol  { background: #fdecea; color: #a02020; border: 1px solid #f5c2bd; }

/* ---------- Spec table & downloads ---------- */
.spec-table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: 0.94rem; }
.spec-table th, .spec-table td {
  border: 1px solid var(--shop-border); padding: 0.45rem 0.7rem; text-align: left;
}
.spec-table th { background: #f6f7f8; width: 40%; font-weight: 600; }

.download-list { list-style: none; padding: 0; margin: 0.5rem 0; }
.download-list li {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.5rem 0; border-bottom: 1px solid var(--shop-border);
}
.download-icon { font-size: 1.1rem; }
.download-kind {
  margin-left: auto; font-size: 0.78rem; color: var(--shop-muted);
  background: #f1f3f5; border-radius: 999px; padding: 0.05rem 0.55rem;
}
.pd-downloads-side {
  margin-top: 0.9rem; border: 1px solid var(--shop-border);
  border-radius: 4px; padding: 0.75rem 0.9rem; background: #fff;
}
.pd-side-title { font-weight: 700; margin-bottom: 0.3rem; }

/* ---------- BOM bulk order ---------- */
.bom-input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9rem; }
.bom-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.bom-table th, .bom-table td {
  padding: 0.5rem; border-bottom: 1px solid var(--shop-border); text-align: left;
  vertical-align: top;
}
.bom-ok  td { background: #f6fff8; }
.bom-bad td { background: #fffaf6; }
.bulk-link { color: #ddd; font-size: 0.9rem; }

/* ---------- Cart extras ---------- */
.cart-row-actions { display: flex; flex-direction: column; gap: 0.2rem; align-items: flex-start; }
.btn-link-sm {
  background: none; border: none; color: var(--shop-link);
  font-size: 0.8rem; padding: 0; cursor: pointer;
}
.saved-row { grid-template-columns: 90px 1fr 110px 140px; opacity: 0.95; }

/* ---------- Admin: orders & ledger ---------- */
.status-tabs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; }
.status-tab {
  border: 1px solid var(--shop-border); border-radius: 999px;
  padding: 0.25rem 0.8rem; font-size: 0.88rem; color: #444;
}
.status-tab.active { background: var(--shop-dark); color: #fff; border-color: var(--shop-dark); }
.status-tab:hover { text-decoration: none; border-color: var(--shop-link); }

.status-pill {
  display: inline-block; border-radius: 999px; padding: 0.05rem 0.6rem;
  font-size: 0.78rem; font-weight: 600; text-transform: capitalize;
}
.status-paid      { background: #e7f1ff; color: #0b5ed7; }
.status-packed    { background: #fff4e5; color: #a05a00; }
.status-shipped   { background: #e8f5e9; color: #1e7e34; }
.status-delivered { background: #e9ecef; color: #444; }
.status-cancelled,
.status-refunded  { background: #fdecea; color: #a02020; }

.order-row { display: flex; justify-content: space-between; align-items: center; }

.fulfil-actions {
  display: flex; flex-direction: column; gap: 0.9rem;
  border: 1px solid var(--shop-border); border-radius: 4px; padding: 1rem;
}
.ship-form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.ship-form .form-control, .ship-form .form-select { width: auto; min-width: 150px; }

.timeline { list-style: none; padding: 0; margin: 0; font-size: 0.9rem; }
.timeline li { padding: 0.25rem 0; border-bottom: 1px dashed var(--shop-border); }

.ledger-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.ledger-table th, .ledger-table td {
  padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--shop-border); text-align: left;
}
.ledger-table thead th { background: #f6f7f8; }
.ledger-in  { color: var(--shop-green); font-weight: 700; }
.ledger-out { color: var(--shop-red);   font-weight: 700; }

/* Admin: spec + download row inputs */
.spec-row-inputs, .download-row-inputs {
  display: grid; gap: 0.5rem; margin-bottom: 0.5rem; align-items: center;
}
.spec-row-inputs { grid-template-columns: 1fr 1fr; }
.download-row-inputs { grid-template-columns: 1.2fr 0.8fr 1.5fr 1.2fr auto; }
@media (max-width: 991px) {
  .download-row-inputs { grid-template-columns: 1fr; }
}
fieldset legend { font-size: 1rem; font-weight: 600; }

/* ==========================================================================
   v4: variants, reviews, checkout, comparison, RMA, analytics
   ========================================================================== */

/* ---------- Variant picker ---------- */
.variant-picker { margin: 0.75rem 0 1rem; }
.variant-option { margin-bottom: 0.6rem; }
.variant-option-label {
  display: block; font-size: 0.82rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--shop-muted);
  margin-bottom: 0.25rem;
}
.variant-swatches { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.variant-swatch {
  border: 1px solid var(--shop-border); background: #fff; border-radius: 3px;
  padding: 0.35rem 0.8rem; font-size: 0.9rem; cursor: pointer;
}
.variant-swatch:hover { border-color: var(--shop-link); }
.variant-swatch.selected {
  border-color: var(--shop-dark); background: var(--shop-dark); color: #fff; font-weight: 600;
}
.variant-swatch.unavailable {
  opacity: 0.45; text-decoration: line-through;
}
.variant-swatch:disabled { cursor: not-allowed; }
.variant-sku { margin: 0.4rem 0 0; }
.variant-note { color: var(--shop-muted); font-size: 0.85rem; }

/* ---------- Kits ---------- */
.kit-callout {
  background: #f1f8ff; border: 1px solid #cfe2ff; border-radius: 4px;
  padding: 0.6rem 0.8rem; font-size: 0.9rem; margin-bottom: 0.75rem;
}
.kit-table { width: 100%; border-collapse: collapse; font-size: 0.94rem; }
.kit-table td { padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--shop-border); }
.kit-table .kit-total td { background: #fafafa; }

/* ---------- Reviews ---------- */
.reviews-summary { display: flex; gap: 2rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.reviews-average { text-align: center; }
.reviews-score { font-size: 2.6rem; font-weight: 800; line-height: 1; }
.reviews-bars { flex: 1 1 260px; max-width: 340px; }
.reviews-bar-row { display: grid; grid-template-columns: 28px 1fr 28px; gap: 0.5rem; align-items: center; }
.reviews-bar { height: 8px; background: #eceff2; border-radius: 999px; overflow: hidden; }
.reviews-bar span { display: block; height: 100%; background: #f0a92b; }

.stars { display: inline-flex; gap: 1px; vertical-align: middle; }
.star path { fill: #dcdfe3; }
.star-full path { fill: #f0a92b; }
.star-half path { fill: url(#half); }
.star-half { position: relative; }
.card-rating { display: flex; align-items: center; gap: 0.25rem; margin-top: 0.15rem; }

.review { border-bottom: 1px solid var(--shop-border); padding: 0.9rem 0; }
.review header { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.review-body { margin: 0.4rem 0 0.3rem; }
.verified-badge {
  background: #e8f5e9; color: #1e7e34; border: 1px solid #a5d6a7;
  border-radius: 999px; padding: 0.05rem 0.55rem; font-size: 0.78rem; font-weight: 600;
}

/* Star rating input: reversed row so hover highlights left-to-right */
.star-input { display: inline-flex; flex-direction: row-reverse; gap: 0.15rem; margin-bottom: 0.5rem; }
.star-input input { position: absolute; opacity: 0; width: 0; }
.star-input label { font-size: 1.8rem; color: #dcdfe3; cursor: pointer; line-height: 1; }
.star-input label:hover, .star-input label:hover ~ label,
.star-input input:checked ~ label { color: #f0a92b; }
.star-input input:focus-visible + label { outline: 3px solid #ffbf47; }

/* ---------- Checkout ---------- */
.checkout-steps {
  display: flex; gap: 0.5rem; list-style: none; padding: 0; margin: 0 0 1.5rem;
  flex-wrap: wrap; font-size: 0.92rem;
}
.checkout-steps li {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.35rem 0.9rem; border: 1px solid var(--shop-border);
  border-radius: 999px; color: var(--shop-muted);
}
.checkout-steps .step-num {
  width: 1.4rem; height: 1.4rem; border-radius: 50%;
  background: #eceff2; display: inline-flex; align-items: center;
  justify-content: center; font-size: 0.78rem; font-weight: 700;
}
.checkout-steps li.current {
  border-color: var(--shop-dark); color: #111; font-weight: 600;
}
.checkout-steps li.current .step-num { background: var(--shop-dark); color: #fff; }
.checkout-steps li.done { color: var(--shop-green); border-color: #a5d6a7; }
.checkout-steps li.done .step-num { background: var(--shop-green); color: #fff; }

.saved-address {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  border: 1px solid var(--shop-border); border-radius: 4px;
  padding: 0.6rem 0.8rem; margin-bottom: 0.5rem;
}
.delivery-option {
  display: grid; grid-template-columns: auto 1fr auto; gap: 0.75rem;
  align-items: center; border: 1px solid var(--shop-border); border-radius: 4px;
  padding: 0.75rem 0.9rem; margin-bottom: 0.5rem; cursor: pointer;
}
.delivery-option:has(input:checked) { border-color: var(--shop-link); background: #f8fbff; }
.delivery-price { font-weight: 700; }

.address-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.address-card {
  border: 1px solid var(--shop-border); border-radius: 4px; padding: 0.9rem;
}
.address-card.default { border-color: var(--shop-link); }

/* ---------- Comparison ---------- */
.compare-scroll { overflow-x: auto; }
.compare-table { border-collapse: collapse; min-width: 640px; width: 100%; font-size: 0.92rem; }
.compare-table th, .compare-table td {
  border: 1px solid var(--shop-border); padding: 0.55rem 0.7rem;
  text-align: left; vertical-align: top;
}
.compare-table thead th { background: #fafafa; width: 22%; }
.compare-rowhead { background: #f6f7f8; font-weight: 600; white-space: nowrap; }
.compare-table img { width: 100%; max-width: 160px; border-radius: 3px; }
.compare-price { font-weight: 700; font-size: 1.05rem; }
.compare-missing { color: #bbb; }

.compare-tray {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 900;
  background: var(--shop-dark); color: #fff;
  display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
  padding: 0.6rem 1rem; box-shadow: 0 -4px 18px rgba(0,0,0,0.25);
}
.compare-tray-label { font-weight: 600; font-size: 0.9rem; }
.compare-chip {
  background: #2c2c2c; border-radius: 999px; padding: 0.15rem 0.5rem 0.15rem 0.7rem;
  font-size: 0.82rem; display: inline-flex; align-items: center; gap: 0.3rem;
}
.compare-chip-remove { background: none; border: none; color: #bbb; cursor: pointer; }
.compare-chip-remove:hover { color: #fff; }

/* ---------- Returns ---------- */
.return-table { width: 100%; border-collapse: collapse; }
.return-table th, .return-table td {
  padding: 0.5rem; border-bottom: 1px solid var(--shop-border); text-align: left;
}
.rma-note {
  border-left: 3px solid var(--shop-border); padding-left: 0.75rem;
  margin: 0; color: #444; font-style: italic;
}

/* ---------- Admin analytics ---------- */
.chart-spark, .chart-bars { width: 100%; height: auto; display: block; margin-bottom: 1rem; }
.delta { font-weight: 700; font-size: 0.82rem; }
.delta-up { color: var(--shop-green); }
.delta-down { color: var(--shop-red); }

.urgency {
  display: inline-block; border-radius: 3px; padding: 0.05rem 0.5rem;
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
}
.urgency-critical { background: #fdecea; color: #a02020; }
.urgency-soon     { background: #fff4e5; color: #a05a00; }
.urgency-watch    { background: #f1f3f5; color: #555; }
.urgency-fine     { background: #e8f5e9; color: #1e7e34; }

.audit-changes { margin: 0.25rem 0 0; padding-left: 1.1rem; font-size: 0.82rem; color: #555; }

@media (max-width: 767px) {
  .compare-tray { font-size: 0.85rem; }
  .reviews-summary { gap: 1rem; }
}

/* ---------- Stragglers found by the class-vs-CSS audit ---------- */
.mini-cart-inner {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}
.review-meta { margin: 0.2rem 0; }
.saved-addresses { border-bottom: 1px solid var(--shop-border); padding-bottom: 0.75rem; }

/* ==========================================================================
   v5: sale pricing, image zoom, mobile navigation
   ========================================================================== */

/* ---------- Prices & sale treatment ---------- */
.price { display: inline-flex; align-items: baseline; gap: 0.4rem; flex-wrap: wrap; }
.price-from { font-size: 0.8em; color: var(--shop-muted); font-weight: 400; }
.price-now { font-weight: 700; }
.price-sm .price-now { font-size: 1rem; }
.price-md .price-now { font-size: 1.2rem; }
.price-lg .price-now { font-size: 1.75rem; }

.price.is-sale .price-now { color: var(--shop-red); }
.price-was {
  color: var(--shop-muted);
  font-weight: 400;
  font-size: 0.85em;
  text-decoration-thickness: 1px;
}
.price-save {
  background: var(--shop-red);
  color: #fff;
  border-radius: 3px;
  padding: 0.05rem 0.4rem;
  font-size: 0.75em;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Corner ribbon on cards and listing thumbnails */
.suggest-card, .product-row-thumb { position: relative; }
.sale-flag {
  position: absolute;
  top: 0.4rem; left: 0.4rem;
  z-index: 2;
  background: var(--shop-red);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.sale-note {
  background: #fdecea;
  border: 1px solid #f5c2bd;
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}
.sale-countdown {
  display: block;
  margin-top: 0.2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.catnav-sale { color: var(--shop-red) !important; }

/* ---------- Hover magnifier ---------- */
.pd-gallery-main { position: relative; overflow: hidden; }
.pd-main-image { cursor: zoom-in; display: block; }

/* While the lens is up, hide the cursor and mute the base image so the
   magnified crop is what the eye follows. */
.pd-gallery-main.zooming .pd-main-image { cursor: none; filter: brightness(0.96); }
.pd-gallery-main.zooming .zoom-open { opacity: 0; }

.zoom-lens {
  position: absolute;
  width: 190px; height: 190px;
  margin-left: -95px; margin-top: -95px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  background-repeat: no-repeat;
  background-color: #fff;
  pointer-events: none;
  z-index: 3;
}

.zoom-open {
  position: absolute;
  right: 0.6rem; bottom: 0.6rem;
  background: rgba(26, 25, 25, 0.82);
  color: #fff;
  border: none;
  border-radius: 3px;
  padding: 0.3rem 0.7rem;
  font-size: 0.82rem;
  cursor: pointer;
  z-index: 4;
}
.zoom-open:hover { background: #000; }

/* ---------- Lightbox ---------- */
.zoom-overlay {
  position: fixed; inset: 0;
  z-index: 2000;
  background: rgba(12, 12, 14, 0.94);
  display: grid;
  grid-template-columns: 3.5rem 1fr 3.5rem;
  grid-template-rows: 1fr auto;
  align-items: center;
  opacity: 0;
  transition: opacity 160ms ease-out;
}
.zoom-overlay.is-open { opacity: 1; }

.zoom-stage {
  grid-column: 2;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  max-height: 88vh;
}
.zoom-image {
  max-width: 100%;
  max-height: 88vh;
  cursor: zoom-in;
  transition: scale 180ms ease-out;
  touch-action: none;
}
.zoom-image.is-magnified { scale: 2.2; cursor: grab; }
.zoom-image.is-magnified:active { cursor: grabbing; }

.zoom-nav, .zoom-close {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: none;
  cursor: pointer;
  border-radius: 50%;
}
.zoom-nav { width: 3rem; height: 3rem; font-size: 2rem; line-height: 1; }
.zoom-nav:hover, .zoom-close:hover { background: rgba(255, 255, 255, 0.22); }
.zoom-prev { grid-column: 1; justify-self: center; }
.zoom-next { grid-column: 3; justify-self: center; }
.zoom-close {
  position: absolute; top: 1rem; right: 1rem;
  width: 2.6rem; height: 2.6rem; font-size: 1.8rem; line-height: 1;
}
.zoom-counter {
  grid-column: 2; grid-row: 2;
  text-align: center; color: #fff;
  font-variant-numeric: tabular-nums;
  padding-bottom: 0.25rem;
}
.zoom-hint {
  grid-column: 1 / -1; grid-row: 2;
  text-align: center; color: rgba(255, 255, 255, 0.5);
  font-size: 0.8rem; margin: 0; padding-bottom: 1rem;
  align-self: end;
}

@media (max-width: 767px) {
  .zoom-overlay { grid-template-columns: 2.5rem 1fr 2.5rem; }
  .zoom-nav { width: 2.2rem; height: 2.2rem; font-size: 1.5rem; }
  .zoom-hint { display: none; }
}

/* ---------- Mobile navigation ---------- */
.mobile-nav-toggle {
  display: none;
  align-items: center;
  gap: 0.45rem;
  background: #333;
  border: 1px solid #4a4a4a;
  border-radius: 3px;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.4rem 0.7rem;
  cursor: pointer;
}
.hamburger { display: inline-flex; flex-direction: column; gap: 3px; }
.hamburger span {
  display: block; width: 16px; height: 2px; background: #fff; border-radius: 1px;
  transition: transform 180ms ease, opacity 180ms ease;
}
.mobile-nav-open .hamburger span:nth-child(1) { transform: translateY(5px) rotate(45deg); }
.mobile-nav-open .hamburger span:nth-child(2) { opacity: 0; }
.mobile-nav-open .hamburger span:nth-child(3) { transform: translateY(-5px) rotate(-45deg); }

.mobile-nav-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1300;
  opacity: 0;
  transition: opacity 200ms ease-out;
}
.mobile-nav-open .mobile-nav-backdrop { opacity: 1; }

.mobile-nav-panel {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: min(330px, 88vw);
  background: #fff;
  z-index: 1400;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 220ms ease-out;
  box-shadow: 6px 0 26px rgba(0, 0, 0, 0.25);
  padding-bottom: 2rem;
}
.mobile-nav-open .mobile-nav-panel { transform: translateX(0); }

.mobile-nav-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.9rem 1rem;
  background: var(--shop-dark); color: #fff;
  position: sticky; top: 0; z-index: 1;
}
.mobile-nav-close {
  background: none; border: none; color: #fff; font-size: 1.7rem;
  line-height: 1; cursor: pointer;
}

.mobile-nav-search { display: flex; gap: 0.4rem; padding: 0.8rem 1rem; }
.mobile-nav-search input {
  flex: 1 1 auto; border: 1px solid #ced4da; border-radius: 3px;
  padding: 0.45rem 0.6rem; font-size: 0.95rem; min-width: 0;
}
.mobile-nav-search input[type="submit"] {
  flex: 0 0 auto; background: var(--shop-link); color: #fff;
  border-color: var(--shop-link); font-weight: 600; cursor: pointer;
}

.mobile-nav-list { list-style: none; margin: 0; padding: 0; }
.mobile-nav-row {
  display: flex; align-items: stretch;
  border-bottom: 1px solid var(--shop-border);
}
.mobile-nav-link {
  flex: 1 1 auto; padding: 0.85rem 1rem;
  color: #212529; font-weight: 600;
}
.mobile-nav-link:hover { background: #f6f7f8; text-decoration: none; }
.mobile-nav-expand {
  flex: 0 0 3rem;
  background: none; border: none; border-left: 1px solid var(--shop-border);
  color: #666; cursor: pointer; font-size: 0.9rem;
}
.mobile-nav-expand span { display: inline-block; transition: transform 180ms ease; }
.expanded .mobile-nav-expand span { transform: rotate(180deg); }

.mobile-nav-children { list-style: none; margin: 0; padding: 0; background: #f8f9fa; }
.mobile-nav-children li { border-bottom: 1px solid var(--shop-border); }
.mobile-nav-children a {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.65rem 1rem 0.65rem 2rem; color: #333; font-size: 0.94rem;
}
.mobile-nav-count {
  background: #e9ecef; border-radius: 999px; padding: 0 0.45rem;
  font-size: 0.78rem; color: #555;
}

.mobile-nav-section {
  display: flex; flex-direction: column; gap: 0.15rem;
  padding: 0.9rem 1rem;
  border-top: 8px solid #f1f3f5;
}
.mobile-nav-section a { padding: 0.35rem 0; font-weight: 600; }

/* Swap desktop chrome for the drawer below the grid breakpoint. */
@media (max-width: 991px) {
  .desktop-only { display: none !important; }
  .mobile-nav-toggle { display: inline-flex; }
  .shop-header-inner { gap: 0.6rem; }
  .shop-brand { font-size: 1.15rem; }
  .shop-search-wrap { order: 10; flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .mobile-nav-panel, .mobile-nav-backdrop, .zoom-overlay, .zoom-image,
  .hamburger span { transition: none; }
}

/* ==========================================================================
   v6: deep category trees and rolled-up counts
   ========================================================================== */

/* ---------- Count pills ---------- */
.cat-count {
  display: inline-block;
  background: #eceff2;
  color: #555;
  border-radius: 999px;
  padding: 0 0.45rem;
  font-size: 0.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
}
.cat-total {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--shop-muted);
  margin-left: 0.5rem;
}
.title-sep { color: var(--shop-muted); font-weight: 400; margin: 0 0.15rem; }
.branch-note { margin: 0.25rem 0 0.75rem; }

/* ---------- Public category tree ---------- */
.cat-tree-columns { columns: 3 260px; column-gap: 2.5rem; }
@media (max-width: 767px) { .cat-tree-columns { columns: 1; } }

.cat-tree { list-style: none; margin: 0; padding: 0; }
.cat-tree > li { break-inside: avoid; margin-bottom: 0.15rem; }

.cat-tree-depth-0 > li { margin-bottom: 1.1rem; }
.cat-tree-depth-0 > li > .cat-tree-row .cat-tree-link {
  font-weight: 700; font-size: 1.05rem;
}
.cat-tree-depth-0 > li > .cat-tree-row {
  border-bottom: 1px solid var(--shop-border);
  padding-bottom: 0.25rem; margin-bottom: 0.3rem;
}

/* Each nested level indents and gains a guide rail. */
.cat-tree .cat-tree {
  margin-left: 0.55rem;
  padding-left: 0.7rem;
  border-left: 1px solid var(--shop-border);
}
.cat-tree-row { display: flex; align-items: center; gap: 0.45rem; }
.cat-tree-link { font-size: 0.94rem; }
.cat-tree-depth-2 .cat-tree-link, .cat-tree-depth-3 .cat-tree-link { font-size: 0.9rem; }

/* ---------- Subcategory chips ---------- */
.subcat-header {
  display: flex; align-items: baseline; gap: 0.75rem;
  font-weight: 700; margin: 1rem 0 0.5rem;
}
.shop-subcat-card { text-decoration: none; color: inherit; }
.shop-subcat-card:hover { text-decoration: none; }
.subcat-name { font-weight: 600; }
.subcat-more {
  display: block; width: 100%;
  font-size: 0.78rem; color: var(--shop-muted);
}

/* ---------- Mega menu: two tiers ---------- */
.mega-cat-group { break-inside: avoid; margin-bottom: 0.9rem; }
.mega-cat-head {
  display: flex; align-items: center; gap: 0.4rem;
  font-weight: 700; font-size: 0.95rem; padding: 0.1rem 0;
}
.mega-cat-children { list-style: none; margin: 0.15rem 0 0; padding: 0 0 0 0.6rem; }
.mega-cat-children li { padding: 0.1rem 0; }
.mega-cat-children a { font-size: 0.88rem; color: #444; }
.mega-cat-children a:hover { color: var(--shop-link); }

/* ---------- Mobile drawer: nested levels ---------- */
.mobile-nav-list.level-1 { background: #f8f9fa; }
.mobile-nav-list.level-2 { background: #f1f3f5; }
.mobile-nav-list.level-3 { background: #e9ecef; }
.mobile-nav-list.level-1 .mobile-nav-link { padding-left: 2rem; font-weight: 500; }
.mobile-nav-list.level-2 .mobile-nav-link { padding-left: 3rem; font-weight: 400; }
.mobile-nav-list.level-3 .mobile-nav-link { padding-left: 4rem; font-weight: 400; }
.mobile-nav-link { display: flex; align-items: center; gap: 0.5rem; }

/* ---------- Admin tree ---------- */
.admin-tree { border: 1px solid var(--shop-border); border-radius: 4px; overflow: hidden; }
.admin-tree-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  padding: 0.5rem 0.9rem;
  padding-left: calc(0.9rem + var(--depth, 0) * 1.6rem);
  border-bottom: 1px solid var(--shop-border);
  background: #fff;
}
.admin-tree-row:last-child { border-bottom: none; }
.admin-tree-row:nth-child(even) { background: #fcfcfd; }
.admin-tree-actions { flex: 0 0 auto; }
.admin-tree-actions form { display: inline-block; margin: 0; }
.admin-tree-main { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; }
.admin-tree-name { font-weight: 600; }
.admin-tree-rail {
  width: 0.8rem; height: 1px; background: var(--shop-border);
  display: inline-block;
}
.admin-tree-row[style*="--depth: 0"] .admin-tree-rail { display: none; }

/* ==========================================================================
   v7: content pages, order lookup, footer
   ========================================================================== */

.content-page { max-width: 760px; }
.content-body { font-size: 1.02rem; line-height: 1.7; }
.content-body h2 { margin: 1.6rem 0 0.6rem; font-size: 1.25rem; }
.content-body ul { padding-left: 1.2rem; }
.content-body li { margin-bottom: 0.35rem; }

.faq-list { margin-top: 1.25rem; }
.faq-item {
  border: 1px solid var(--shop-border);
  border-radius: 4px;
  margin-bottom: 0.5rem;
  background: #fff;
}
.faq-item summary {
  cursor: pointer;
  padding: 0.75rem 1rem;
  font-weight: 600;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; color: var(--shop-muted); font-weight: 700; }
.faq-item[open] summary::after { content: "−"; }
.faq-item[open] summary { border-bottom: 1px solid var(--shop-border); }
.faq-answer { padding: 0.75rem 1rem; color: #333; }

.faq-row-inputs {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
@media (max-width: 767px) { .faq-row-inputs { grid-template-columns: 1fr; } }

/* Footer columns */
.shop-footer-inner { gap: 2.5rem; }
.footer-col { display: flex; flex-direction: column; gap: 0.3rem; min-width: 160px; }
.footer-col strong { color: #fff; margin-bottom: 0.2rem; }
.footer-contact { margin-top: 0.5rem; }

/* ---------- Dummy payment form ---------- */
.payment-form { margin-top: 0.5rem; }
.payment-form .form-select { max-width: 260px; }

/* ==========================================================================
   v8.7: cart on small screens
   ========================================================================== */

/* The cart is a six-column grid (image, name, price, qty, remove, total)
   totalling ~600px, so on a phone the last columns fall off the right edge.
   Below 768px the same cells are stacked into three rows beside the image,
   and the column headings — which no longer line up with anything — go away. */
@media (max-width: 767px) {
  .cart-head { display: none; }

  .cart-item-row {
    grid-template-columns: 72px minmax(0, 1fr) auto;
    grid-template-areas:
      "img name    name"
      "img price   qty"
      "img actions total";
    gap: 0.35rem 0.6rem;
    align-items: start;
  }

  .cart-item-row .cart-img { grid-area: img; }
  .cart-item-row .cart-img img { width: 64px; height: 48px; }

  .cart-item-name    { grid-area: name; min-width: 0; }
  .cart-cell-price   { grid-area: price; text-align: left; align-self: center; }
  .cart-cell-qty     { grid-area: qty; justify-self: end; }
  .cart-cell-actions { grid-area: actions; flex-direction: row; align-items: center; gap: 0.75rem; }
  .cart-cell-total   { grid-area: total; align-self: center; }

  .cart-cell-qty .form-control { width: 4.5rem; }

  /* The checkout button and its "or" wrap rather than squeezing. */
  .cart-topbar { flex-wrap: wrap; gap: 0.5rem; }
}

/* The hero's two buttons are inline-block, so their only separation was a
   utility margin that disappears when they wrap onto separate lines. */
.home-hero .btn { margin-bottom: 0.5rem; }

@media (max-width: 767px) {
  .home-hero { padding: 1.5rem 1.25rem; }
  .home-hero h1 { font-size: 1.8rem; }

  /* Full-width stacked buttons read better than two half-width ones. */
  .home-hero .btn { display: block; width: 100%; margin-right: 0; text-align: center; }
}

/* Listing "Add to Cart" buttons were sized for a mouse. On a touch screen
   anything under ~44px tall is awkward to hit, so give them a comfortable
   target on phones and let them fill the buy column. */
@media (max-width: 767px) {
  .btn-addcart {
    padding: 0.7rem 1.2rem;
    font-size: 1rem;
    min-height: 44px;
  }

  .product-row-buy { width: 100%; }
  .product-row-buy form,
  .product-row-buy .btn-addcart { width: 100%; }
}

/* Product page layout.
   Three blocks — gallery, buy box, long-form sections — as direct children of
   .pd-row so their order can differ between breakpoints.

   Desktop: a two-column grid. The buy box spans both rows of the left column,
   which is what lets it stay sticky for the whole scroll.
   Mobile: a single column ordered photo -> buy box -> detail, so "Add to
   Cart" is visible without scrolling past the description and reviews. */
.pd-row { display: flex; flex-direction: column; }

.pd-row > .pd-gallery-col { order: 1; }
.pd-row > .pd-right       { order: 2; margin-bottom: 1.5rem; }
.pd-row > .pd-sections    { order: 3; }

@media (min-width: 992px) {
  .pd-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    column-gap: 1.5rem;
  }

  .pd-row > .pd-gallery-col { grid-column: 1; grid-row: 1; }
  .pd-row > .pd-sections    { grid-column: 1; grid-row: 2; }

  /* Stretched on purpose: position:sticky moves within its containing block,
     so this column must span the full height of the page content for the buy
     box to travel with the scroll. align-items:start here would collapse it
     to the height of the box and kill the stickiness. */
  .pd-row > .pd-right {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: stretch;
    margin-bottom: 0;
  }
}

/* The jump links exist to navigate a long page from the sticky sidebar. On a
   phone there's no sidebar and the sections are already in reading order
   below, so they're just another list to scroll past. */
@media (max-width: 991px) {
  .pd-jumplinks { display: none; }
}

/* ---------- Sticky cart bar (mobile only) ----------
   Shown once there's something in the cart, on every page except the cart and
   checkout. Deliberately short, dismissible, and paired with a spacer so it
   never hides the end of the page. */
.mobile-cart-bar,
.mcb-spacer { display: none; }

/* Cart and checkout pages already show all of this. */
body.no-cart-bar .mobile-cart-bar,
body.no-cart-bar .mcb-spacer { display: none !important; }

@media (max-width: 991px) {
  .mobile-cart-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    /* Above the compare tray (900) and the page, below the slide-over
       drawer (1200) so the drawer covers it when open. */
    z-index: 1000;
    padding: 0.55rem 0.8rem;
    padding-bottom: calc(0.55rem + env(safe-area-inset-bottom, 0px));
    background: #fff;
    border-top: 1px solid var(--shop-border);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.14);
  }

  .mcb-info { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
  .mcb-info strong { font-size: 0.85rem; }
  .mcb-total { font-size: 1.05rem; font-weight: 700; }

  .mcb-btn {
    margin-left: auto;
    background: var(--shop-dark); color: #fff;
    border-radius: 4px; font-weight: 700;
    padding: 0.6rem 1.1rem; min-height: 44px;
    display: inline-flex; align-items: center;
    text-decoration: none;
  }
  .mcb-btn:hover, .mcb-btn:focus { color: #fff; background: #000; }

  .mcb-close {
    background: none; border: 0; color: var(--shop-muted);
    font-size: 1.5rem; line-height: 1;
    padding: 0 0.15rem; min-width: 32px; min-height: 44px;
  }

  /* Matches the bar's height so the footer stays reachable. */
  .mcb-spacer { display: block; height: 72px; }

  /* The compare tray is also bottom-fixed; stack it above the cart bar so
     the two don't overlap when a phone user has both. */
  .compare-tray { bottom: 72px; }
}

/* ==========================================================================
   Blog
   ========================================================================== */

.blog-head {
  display: flex; flex-wrap: wrap; align-items: baseline;
  justify-content: space-between; gap: 0.5rem 1rem;
}
.blog-feed-link { font-size: 0.9rem; }

.blog-list { display: flex; flex-direction: column; gap: 1.5rem; margin-top: 1rem; }

.blog-card {
  display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 1.25rem;
  border: 1px solid var(--shop-border); border-radius: 6px;
  padding: 1rem; background: #fff;
}
.blog-card-image img { width: 100%; height: auto; border-radius: 4px; display: block; }
.blog-card-body h2 { font-size: 1.3rem; margin: 0 0 0.3rem; }
.blog-card-body h2 a { color: var(--shop-dark); text-decoration: none; }
.blog-card-body h2 a:hover { color: var(--shop-link); }
.blog-excerpt { margin: 0.5rem 0; }
.blog-more { font-weight: 600; }

.blog-meta { font-size: 0.85rem; color: var(--shop-muted); }

/* Post page: a readable measure rather than the full content width. */
.blog-post { max-width: 46rem; }
.blog-post h1 { font-weight: 800; margin-bottom: 0.4rem; }
.blog-cover { margin: 1.25rem 0; }
.blog-cover img { width: 100%; height: auto; border-radius: 6px; display: block; }
.blog-body { margin-top: 1.25rem; line-height: 1.7; font-size: 1.05rem; }
.blog-body img { max-width: 100%; height: auto; border-radius: 4px; }
.blog-body h2 { margin-top: 1.8rem; font-size: 1.4rem; }
.blog-body pre {
  background: #f6f6f6; border: 1px solid var(--shop-border); border-radius: 4px;
  padding: 0.8rem; overflow-x: auto;
}
.blog-tags { margin-top: 1.5rem; display: flex; flex-wrap: wrap; gap: 0.4rem; }

.blog-products, .blog-more-posts { margin-top: 2.5rem; }
.blog-more-list { list-style: none; padding: 0; }
.blog-more-list li { padding: 0.4rem 0; border-bottom: 1px solid var(--shop-border); }

@media (max-width: 767px) {
  .blog-card { grid-template-columns: 1fr; }
  .blog-post { max-width: none; }
}
