/* SCENTREAT cart drawer, Back Hero USA layout (12/10/2026, owner: "chỉnh cái add to cart drawer cho logic cha con này kia
   giống bên Back Hero USA"). Port of backherousa.com assets/bh-cart.css (skill shopify-cart-drawer), drawer only, in the
   SCENTREAT colours (light cream + honey brown, dark text): "Cart • n items" + Clear all, flat lines with dividers, gifts
   hung under their product (indent + honey rule, slim rows, FREE GIFT pill), per-unit colour selects, Shipping Protection
   card with a switch, "You save $X · See details" folded, one Check out • total, promise line.
   Loaded after the drawer's own {% stylesheet %} (layout/theme.liquid); the nesting keeps specificity above it. */

cart-drawer-component {
  --stc-ink: #1f1a14;
  --stc-body: #4a3d30;
  --stc-muted: #8a7a69;
  --stc-accent: #a4622c;
  --stc-accent-2: #c3894f;
  --stc-tint: #fbf3e8;
  --stc-ice: #efdcc2;
  --stc-green: #2f7d4a;
  --stc-line: rgb(31 26 20 / .12);
}

/* ============ header ============ */
cart-drawer-component .stc-cart-head {
  display: flex; align-items: center; gap: 0; border-block-end: 1px solid var(--stc-line);
  & .theme-drawer__title { margin-inline-end: auto; display: block; white-space: nowrap; color: var(--stc-ink); }
  & .theme-drawer__close-button { margin-inline-start: 0; flex: none; }
}
cart-drawer-component .stc-cart-head__dot { color: var(--stc-accent); margin: 0 2px; font-weight: 800; }
cart-drawer-component .stc-clear {
  flex: 0 0 auto; margin-inline-end: 12px; padding: 6px 0; border: 0; background: none; color: var(--stc-muted);
  font: 500 12.5px/1 var(--font-body--family); text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; cursor: pointer;
  &.is-confirming { color: #b3261e; font-weight: 800; }
  &[disabled] { opacity: .5; cursor: default; }
  &:focus-visible { outline: 2px solid var(--stc-accent); outline-offset: 3px; border-radius: 4px; }
}
@media (hover: hover) and (pointer: fine) { cart-drawer-component .stc-clear:hover { color: #b3261e; } }

/* the footer never fades while the list scrolls */
cart-drawer-component scroll-hint.cart-drawer__content,
cart-drawer-component scroll-hint.cart-drawer__items,
cart-drawer-component .cart-drawer__summary { mask-image: none !important; -webkit-mask-image: none !important; }

/* ============ line items ============ */
cart-drawer-component cart-items-component.cart-items-component {
  & .cart-drawer__items { padding-top: 12px; }
  & .cart-items__table-row {
    position: relative;
    grid-template-columns: 64px minmax(0, 1fr) auto;
    grid-template-areas: "media details details" "media price quantity" "media error error";
    column-gap: 12px; row-gap: 3px; align-items: start;
    padding: 0 0 12px; margin: 0 0 12px; border: 0; border-block-end: 1px solid var(--stc-line); border-radius: 0;
  }
  & .cart-items__table-row:has(+ .cart-items__nested-line),
  & .cart-items__table-row:last-child { border: 0; border-block-end: 1px solid var(--stc-line); margin-bottom: 12px; }
  /* the last visible row closes the list (the protection line is hidden and may sit after it) */
  & tbody .cart-items__table-row:not(:has(~ .cart-items__table-row:not(.cart-items__table-row--st-protection))) { padding-bottom: 0; margin-bottom: 0; border-block-end: 0; }

  /* gifts hang under the product that earned them: no divider in between, indent + honey rule, slim single rows */
  & .cart-items__table-row:has(+ .cart-items__nested-line) { padding-bottom: 8px; margin-bottom: 0; border-block-end: 0; }
  & .cart-items__nested-line {
    grid-template-columns: 36px minmax(0, 1fr) auto; column-gap: 10px; row-gap: 0;
    grid-template-areas: "media details quantity" "media price quantity" "media error error";
    padding: 0 0 6px 22px; margin: 0; border: 0; align-items: center;
  }
  & .cart-items__nested-line::before { content: ""; position: absolute; left: 8px; top: -4px; bottom: 6px; width: 2px; border-radius: 2px; background: var(--stc-ice); }
  & .cart-items__nested-line:not(:has(+ .cart-items__nested-line)) { padding-bottom: 12px; margin-bottom: 12px; border-block-end: 1px solid var(--stc-line); }
  & .cart-items__nested-line:not(:has(+ .cart-items__nested-line))::before { bottom: 12px; }
  & tbody .cart-items__nested-line:not(:has(~ .cart-items__table-row:not(.cart-items__table-row--st-protection))) { padding-bottom: 0; margin-bottom: 0; border-block-end: 0; }
  & tbody .cart-items__nested-line:not(:has(~ .cart-items__table-row:not(.cart-items__table-row--st-protection)))::before { bottom: 0; }

  /* photo */
  & .cart-items__table-row .cart-items__media { width: 64px; min-width: 64px; max-width: 64px; height: 64px; border-radius: 10px; background: var(--stc-tint); }
  & .cart-items__nested-line .cart-items__media,
  & .cart-items__nested-line td:first-child { width: 36px; min-width: 36px; max-width: 36px; height: 36px; border-radius: 7px; align-self: center; }
  & .cart-items__media img { border-radius: inherit !important; }

  /* title + one short variant line / per-unit selects */
  & .cart-items__title { font-size: 14.5px; line-height: 1.25; font-weight: 700; color: var(--stc-ink); }
  & .cart-items__nested-line .cart-items__title { font-size: 13px; -webkit-line-clamp: 1; }
  & .cart-items__nested-line .cart-items__title-row { padding-inline-end: 0 !important; }
  & .stc-line__variant { margin: 2px 0 0; padding-inline-end: 30px; font-size: 12.5px; line-height: 1.3; color: var(--stc-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* price row: ~~regular~~ paid [pill] / You saved $X */
  & .cart-items__price { grid-area: price; display: flex; align-items: baseline; flex-wrap: wrap; column-gap: 6px; row-gap: 1px; align-self: center; justify-self: stretch; min-width: 0; max-width: 100%; padding-inline-end: 8px; font-size: 14px; font-weight: 700; color: var(--stc-ink); }
  & .cart-items__price > text-component { font-weight: 800; color: var(--stc-ink); white-space: nowrap; }
  & .cart-items__table-row[data-st-gift] .cart-items__price > text-component { display: none; }
  & .st-line__was { margin-inline-end: 0; color: var(--stc-muted); font-weight: 400; white-space: nowrap; }
  & .stc-line__tags { display: inline-flex; flex-wrap: wrap; gap: 4px; align-self: center; min-width: 0; max-width: 100%; }
  & .stc-line__tags:empty { display: none; }
  & .st-line__saved { flex-basis: 100%; margin: 0; font-size: 11.5px; font-weight: 800; color: var(--stc-accent); white-space: nowrap; }
  & .stc-pill { display: inline-flex; min-width: 0; max-width: 100%; padding: 3px 8px; border-radius: 4px; background: var(--stc-tint); border: 1px solid var(--stc-ice); color: #7a4519; font: 800 10px/1.25 var(--font-body--family); letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
  & .stc-pill--free { background: #e7f6ec; border-color: #bfe3cc; color: var(--stc-green); }
  & .cart-items__nested-line .cart-items__price { font-size: 12.5px; line-height: 1.2; }
  & .cart-items__nested-line .stc-pill { padding: 2px 6px; font-size: 9.5px; }

  /* controls: stepper right of the price; trash top right (gift rows: middle right) */
  & .cart-items__quantity { grid-area: quantity; justify-self: end; align-self: center; margin: 0; }
  & .cart-items__quantity .quantity-selector { height: 34px; border: 1px solid var(--stc-line); border-radius: 8px; background: #fff; }
  & .cart-items__quantity .quantity-selector-wrapper button { width: 28px; height: 32px; }
  & .cart-items__quantity .quantity-selector-wrapper input { width: 24px; height: 32px; font-size: 14px; font-weight: 700; }
  & .cart-items__nested-line .cart-items__quantity { margin-inline-end: 28px; }
  & .cart-items__nested-line .cart-items__quantity .quantity-selector { height: 28px; }
  & .cart-items__nested-line .cart-items__quantity .quantity-selector-wrapper button { width: 24px; height: 26px; }
  & .cart-items__nested-line .cart-items__quantity .quantity-selector-wrapper input { width: 22px; height: 26px; font-size: 13px; }
  & .cart-items__remove { top: -2px; inset-inline-end: -4px; width: 30px; height: 30px; border-radius: 6px; color: var(--stc-muted) !important; background: transparent !important; box-shadow: none !important; }
  & .cart-items__remove svg { width: 16px; height: 16px; }
  & .cart-items__nested-line .cart-items__remove { top: 50%; margin-top: -15px; inset-inline-end: -4px; }
  & .cart-items__title-row { padding-inline-end: 30px !important; }

  /* colour per unit: "#1 [Silver]" "#2 [Black]" under the title */
  & .stc-line__units { display: flex; flex-wrap: wrap; gap: 6px 8px; margin: 5px 0 1px; padding-inline-end: 4px; }
  & .stc-line__size { position: relative; display: inline-flex; align-items: center; gap: 5px; flex: 0 1 auto; min-width: 0; max-width: 100%; }
  & .stc-line__size select {
    height: 28px; min-width: 0; max-width: 168px; padding: 0 24px 0 9px; border: 1px solid var(--stc-line); border-radius: 8px; background: #fff;
    font: 600 12.5px/1 var(--font-body--family); color: var(--stc-ink); appearance: none; -webkit-appearance: none; cursor: pointer; text-overflow: ellipsis;
  }
  & .stc-line__size::after { content: ""; position: absolute; right: 10px; top: 50%; width: 6px; height: 6px; margin-top: -5px; border-right: 1.8px solid var(--stc-accent); border-bottom: 1.8px solid var(--stc-accent); transform: rotate(45deg); pointer-events: none; }
  & .stc-line__size select:focus-visible { outline: 2px solid var(--stc-accent); outline-offset: 2px; }
  & .stc-line__unit-n { flex: none; font: 800 11.5px/1 var(--font-body--family); color: var(--stc-muted); letter-spacing: .02em; }
  & .stc-line__size.st-busy { color: inherit !important; }
  & .stc-line__size.st-busy > * { opacity: .35; }
}

/* ============ footer ============ */
cart-drawer-component .cart-drawer__summary { gap: 8px; padding: 10px var(--cart-drawer-padding, 1.5rem) 12px; border-block-start: 1px solid var(--stc-line); }
cart-drawer-component .st-footer {
  display: flex; flex-direction: column; gap: 8px; width: 100%; color: var(--stc-ink);

  /* opt-in Shipping Protection card */
  & st-shipping-protection { margin: 0; padding: 0; }
  & .stc-protect { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border: 1px solid var(--stc-ice); border-radius: 10px; background: var(--stc-tint); }
  & st-shipping-protection[loading] .stc-protect { opacity: .65; pointer-events: none; }
  & .stc-protect__icon { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #fff; color: var(--stc-accent); box-shadow: inset 0 0 0 1px var(--stc-ice); }
  & .stc-protect__icon svg { width: 16px; height: 16px; }
  & .stc-protect__body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
  & .stc-protect__name { font-size: 13.5px; font-weight: 800; line-height: 1.2; color: var(--stc-ink); }
  & .stc-protect__copy { font-size: 12px; line-height: 1.3; color: var(--stc-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  & .stc-protect__copy b { font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--stc-accent); font-size: 11px; }
  & .stc-protect__price { flex: none; font-size: 14px; font-weight: 800; }
  & .stc-protect__switch { flex: none; position: relative; width: 44px; height: 40px; cursor: pointer; }
  & .stc-protect__switch input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
  & .stc-protect__track { position: absolute; inset: 0 0 auto; height: 26px; border-radius: 26px; background: rgb(31 26 20 / .2); transition: background-color .2s; pointer-events: none; }
  & .stc-protect__track::before { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgb(0 0 0 / .2); transition: transform .2s; }
  & .stc-protect__switch input:checked + .stc-protect__track { background: var(--stc-accent); }
  & .stc-protect__switch input:checked + .stc-protect__track::before { transform: translateX(18px); }
  & .stc-protect__state { position: absolute; left: 0; right: 0; bottom: 0; text-align: center; font: 900 10px/1 var(--font-body--family); letter-spacing: .08em; color: var(--stc-muted); pointer-events: none; }
  & .stc-protect__state::after { content: "OFF"; }
  & .stc-protect__switch input:checked ~ .stc-protect__state { color: var(--stc-accent); }
  & .stc-protect__switch input:checked ~ .stc-protect__state::after { content: "ON"; }
  & .stc-protect__switch input:focus-visible + .stc-protect__track { outline: 2px solid var(--stc-accent); outline-offset: 2px; }

  /* "You save $X" folded */
  & .stc-foot__save { display: block; background: var(--stc-tint); border: 1px solid var(--stc-ice); border-radius: 10px; padding: 6px 12px; transition: opacity .15s; }
  & .stc-foot__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; cursor: pointer; list-style: none; font-size: 13.5px; font-weight: 800; color: var(--stc-ink); }
  & .stc-foot__head::-webkit-details-marker { display: none; }
  & .stc-foot__head:focus-visible { outline: 2px solid var(--stc-accent); outline-offset: 4px; border-radius: 6px; }
  & .stc-foot__lead { display: inline-flex; align-items: center; gap: 4px; min-width: 0; white-space: nowrap; }
  & .stc-foot__lead b { background: var(--stc-accent); color: #fff; border-radius: 999px; padding: 2px 9px; margin-inline-start: 4px; font-size: 13px; }
  & .stc-foot__toggle { flex: none; display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 800; color: var(--stc-accent); white-space: nowrap; }
  & .stc-foot__toggle::after { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-135deg) translateY(-1px); transition: transform .2s; }
  & .stc-foot__save:not([open]) .stc-foot__hide { display: none; }
  & .stc-foot__save[open] .stc-foot__show { display: none; }
  & .stc-foot__save:not([open]) .stc-foot__toggle::after { transform: rotate(45deg) translateY(-2px); }
  & .stc-foot__list { list-style: none; margin: 6px 0 0; padding: 6px 4px 0 0; border-top: 1px dashed rgb(164 98 44 / .35); display: grid; gap: 6px; max-height: min(34vh, 300px); overflow-y: auto; overscroll-behavior: contain; }
  & .stc-foot__item { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 13px; line-height: 1.35; color: var(--stc-body); font-variant-numeric: tabular-nums; }
  & .stc-foot__name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  & .stc-foot__price { flex: none; white-space: nowrap; }
  & .stc-foot__price s { color: var(--stc-muted); margin-inline-end: 4px; }
  & .stc-foot__item--code .stc-foot__price { color: var(--stc-accent); font-weight: 700; }
  & .stc-foot__free { color: var(--stc-green); font-weight: 800; }
  & .stc-foot__total { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed rgb(164 98 44 / .35); font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; }
  & .stc-foot__total s { color: var(--stc-muted); font-weight: 500; margin-inline-start: 2px; }
  & .stc-foot__now { color: var(--stc-ink); font-size: 16px; margin-inline-start: 2px; }

  /* no savings: plain rows */
  & .stc-foot__summary { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; font-size: 14px; }
  & .stc-foot__row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
  & .stc-foot__row--total { font-size: 16px; font-weight: 800; }

  & .st-footer__checkout { min-height: 50px; padding-block: 0; }
  & .stc-foot__promise { display: block; margin: -2px 0 0; text-align: center; font-size: 12.5px; line-height: 1.3; color: var(--stc-muted); }
  & .stc-foot__promise svg { display: inline-block; width: 15px; height: 15px; margin-inline-end: 5px; vertical-align: -3px; color: var(--stc-accent); }
  & .stc-foot__promise a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
}
html.st-cart-busy cart-drawer-component .stc-foot__save { opacity: .7; }

/* ============ phone: compact (owner rule 01/10/2026) ============ */
@media screen and (max-width: 749px) {
  cart-drawer-component .stc-cart-head { padding: 8px 10px 8px 16px; min-height: 0; }
  cart-drawer-component .stc-cart-head .theme-drawer__title.h4 { font-size: 18px; }
  cart-drawer-component .stc-cart-head .theme-drawer__close-button { width: 36px; height: 36px; }
  cart-drawer-component .cart-drawer__items { padding-inline: 14px; }
  cart-drawer-component .cart-drawer__summary { padding: 8px 14px calc(10px + env(safe-area-inset-bottom, 0px)); gap: 7px; }
  cart-drawer-component cart-items-component.cart-items-component {
    & .cart-items__table-row { grid-template-columns: 56px minmax(0, 1fr) auto; column-gap: 10px; padding-bottom: 10px; margin-bottom: 10px; }
    & .cart-items__table-row .cart-items__media { width: 56px; min-width: 56px; max-width: 56px; height: 56px; }
    & .cart-items__price { font-size: 13.5px; }
    & .cart-items__quantity .quantity-selector { height: 32px; border-radius: 8px; }
    & .cart-items__quantity .quantity-selector-wrapper button { width: 28px; height: 30px; }
    & .cart-items__quantity .quantity-selector-wrapper input { width: 22px; height: 30px; font-size: 14px; }
    & .cart-items__remove::before { content: ""; position: absolute; inset: -6px; }
    & .cart-items__remove svg { width: 17px; height: 17px; }
    & .stc-line__units { gap: 5px 6px; margin: 4px 0 1px; }
    & .stc-line__size select { height: 26px; font-size: 12px; padding-inline: 7px 20px; max-width: 150px; border-radius: 7px; }
    & .stc-line__size::after { right: 8px; width: 5px; height: 5px; }
    & .cart-items__nested-line { grid-template-columns: 32px minmax(0, 1fr) auto; column-gap: 8px; padding: 0 0 4px 18px; }
    & .cart-items__nested-line::before { left: 6px; top: -2px; bottom: 4px; }
    & .cart-items__nested-line .cart-items__media,
    & .cart-items__nested-line td:first-child { width: 32px; min-width: 32px; max-width: 32px; height: 32px; }
    & .cart-items__nested-line .cart-items__title { font-size: 12.5px; }
    & .cart-items__nested-line .cart-items__price { font-size: 12px; }
    & .cart-items__nested-line .cart-items__quantity { margin-inline-end: 26px; }
    & .cart-items__nested-line .cart-items__quantity .quantity-selector-wrapper button { width: 24px; height: 26px; }
    & .cart-items__nested-line .cart-items__remove { inset-inline-end: -6px; }
    & .cart-items__nested-line:not(:has(+ .cart-items__nested-line)) { padding-bottom: 10px; margin-bottom: 10px; }
    & .cart-items__nested-line:not(:has(+ .cart-items__nested-line))::before { bottom: 10px; }
  }
  cart-drawer-component .st-footer {
    gap: 7px;
    & .stc-protect { padding: 6px 10px; gap: 8px; }
    & .stc-protect__icon { width: 26px; height: 26px; }
    & .stc-protect__icon svg { width: 15px; height: 15px; }
    & .stc-protect__name { font-size: 13px; }
    & .stc-protect__copy { font-size: 11px; }
    & .stc-protect__copy b { font-size: 10px; }
    & .stc-protect__price { font-size: 13px; }
    & .stc-protect__switch { width: 40px; height: 38px; }
    & .stc-protect__track { height: 24px; }
    & .stc-protect__track::before { width: 18px; height: 18px; }
    & .stc-protect__switch input:checked + .stc-protect__track::before { transform: translateX(16px); }
    & .st-footer__checkout { min-height: 48px; font-size: 16px; }
    & .stc-foot__promise { font-size: 11.5px; }
  }
}

/* a colour swap / clear is on the wire: Check out rests (st-fast-cart dims it for its own writes) */
html.stc-busy cart-drawer-component [name="checkout"] { opacity: .6; pointer-events: none; transition: opacity .15s; }

/* "Add to your order" card (snippets/st-cart-upsells.liquid), Back Hero USA look */
cart-drawer-component .st-footer st-cart-upsells:has(.st-upsells__item)::before { content: "Add to your order"; display: block; margin: 0 0 5px; font: 800 10.5px/1.2 var(--font-body--family); letter-spacing: .08em; text-transform: uppercase; color: var(--stc-muted); }
cart-drawer-component .st-footer .st-upsells__item { grid-template-columns: 46px minmax(0, 1fr) auto; gap: 10px; padding: 5px 10px 5px 5px; border-color: var(--stc-line); border-radius: 10px; background: #fff; }
cart-drawer-component .st-footer .st-upsells__media { width: 46px; border-radius: 8px; background: var(--stc-tint); }
cart-drawer-component .st-footer .st-upsells__title { font-weight: 700; color: var(--stc-ink); }
cart-drawer-component .st-footer .st-upsells__sub b { font-weight: 800; color: var(--stc-ink); }
cart-drawer-component .st-footer .st-upsells__add { height: 28px; padding: 0 12px; border: 1.5px solid var(--stc-accent); color: var(--stc-accent); background: #fff; font-weight: 800; white-space: nowrap; }
@media (hover: hover) and (pointer: fine) { cart-drawer-component .st-footer .st-upsells__add:hover { background: var(--stc-accent); color: #fff; } }
@media screen and (max-width: 749px) {
  cart-drawer-component .st-footer .st-upsells__item { grid-template-columns: 42px minmax(0, 1fr) auto; gap: 8px; }
  cart-drawer-component .st-footer .st-upsells__media { width: 42px; }
  cart-drawer-component .st-footer .st-upsells__add { height: 26px; padding: 0 10px; }
}
cart-drawer-component .st-footer .stc-foot__head { min-height: 0; padding: 0; line-height: 1.3; }
