/* =====================================================================
   "ยกแผง" shell layout for the P.SHOP-family skins (pshop, clay, mint, orbit, cyber).
   Loaded only when one of those skins is active (body.store.shell-ui).
   Adapted from the shop owner's base.css: rounded floating shell, curved side rail
   with icon-only navigation (desktop), white product cards with a stock tag and a
   tinted picture well, square add button, floating dock with a lifted active circle (mobile).
   Colours come from tokens in tokens.css / skins.css (--rail-c, --shell-bg, --art-a/b, ...).
   ===================================================================== */

.store.shell-ui {
  --shell-r: 28px;
  --rank-a: #ffe07a; --rank-b: #f0b400; --on-rank: #3b2a00;   /* gold "ขายดี" ribbon: 9.6:1 */
  --rail-ink: #ffffff;                                         /* icons on the rail: >= 5:1 on every --rail-c */
}

/* ---------- Product cards (all widths) ---------- */
.store.shell-ui .pcard {
  gap: 12px; padding: 16px;
  border-radius: var(--card-radius, 20px);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: var(--card-ring, 0 0 0 0 transparent), 0 1px 2px var(--card-sh), 0 14px 34px -14px var(--card-sh);
}
.store.shell-ui .pcard::before { display: none; }
.store.shell-ui .pcard:hover {
  transform: translateY(-5px);
  border-color: color-mix(in srgb, var(--rail-c) 35%, var(--color-border));
  box-shadow: var(--card-ring, 0 0 0 0 transparent), 0 2px 4px var(--card-sh), 0 22px 44px -16px var(--card-sh);
}
.store.shell-ui .pcard.is-best { box-shadow: 0 0 0 2px color-mix(in srgb, var(--rail-c) 28%, transparent), 0 14px 34px -14px var(--card-sh); }
.store.shell-ui .pcard:has(.pcard-title a:focus-visible) { box-shadow: var(--focus-ring); }

/* Stock tag row ("พร้อมส่ง" pill, top right) */
.store.shell-ui .pcard-top { display: flex; justify-content: flex-end; align-items: center; min-height: 28px; }
.pcard-tag { padding: 3px 12px; border-radius: var(--radius-full); font-size: var(--fs-xs); font-weight: 700; line-height: 1.6; }
.pcard-tag.stock-in  { background: var(--color-success-soft); color: var(--color-success); }
.pcard-tag.stock-low { background: var(--color-warning-soft); color: var(--color-warning); }
.pcard-tag.stock-out { background: var(--color-danger-soft);  color: var(--color-danger); }
.store.shell-ui .pcard-meta .stock-in,
.store.shell-ui .pcard-meta .stock-low,
.store.shell-ui .pcard-meta .stock-out { display: none; } /* shown in the tag instead */

/* Picture well: tinted gradient, soft circle in the corner, picture centred */
.store.shell-ui .pcard .pcard-media {
  aspect-ratio: auto; height: 150px; border-radius: 16px; overflow: hidden;
  background: linear-gradient(135deg, var(--art-a, var(--color-surface-2)), var(--art-b, var(--color-primary-soft)));
  box-shadow: none;
}
.store.shell-ui .pcard .pcard-media::before {
  content: ""; position: absolute; z-index: 0; width: 120px; height: 120px; border-radius: 50%;
  right: -30px; top: -40px; background: color-mix(in srgb, var(--color-surface) 22%, transparent);
}
.store.shell-ui .pcard .pcard-media img { width: 100%; height: 100%; padding: 10px; object-fit: contain; filter: drop-shadow(0 10px 14px var(--card-sh)); }
.store.shell-ui .pcard .pcard-media > .icon { width: 56px; height: 56px; color: var(--color-primary); filter: drop-shadow(0 10px 14px var(--card-sh)); }
.store.shell-ui .pcard-floor { display: none; }
.store.shell-ui .pcard-badge.badge-hot { background: linear-gradient(135deg, var(--rank-a), var(--rank-b)); color: var(--on-rank); box-shadow: 0 6px 14px color-mix(in srgb, var(--rank-b) 40%, transparent); }
.store.shell-ui .pcard-badge:not(.badge-hot) { background: var(--btn-grad, var(--color-primary)); background-color: var(--color-primary); color: var(--color-on-primary); }

/* Text, price, add button */
.store.shell-ui .pcard-body { padding: 0; gap: 4px; }
.store.shell-ui .pcard-title { font-family: var(--font-heading); font-weight: 800; font-size: 1.0625rem; line-height: 1.3; }
.store.shell-ui .pcard-foot { padding-top: var(--sp-2); align-items: center; }
.store.shell-ui .pcard-price .price { font-family: var(--font-heading); font-weight: 800; font-size: 1.5rem; letter-spacing: -0.01em; color: var(--color-primary); }
.store.shell-ui .add-btn {
  width: var(--tap); height: var(--tap); border-radius: 14px;
  background-color: var(--color-primary); background-image: var(--btn-grad, none);
  box-shadow: 0 10px 22px -8px var(--glow);
}
.store.shell-ui .add-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }

/* Popular row cards follow the same look */
.store.shell-ui .mini-card { border-radius: var(--card-radius, 20px); background: var(--color-surface); border: 1px solid var(--color-border); }
.store.shell-ui .mini-media.pcard-media {
  border-radius: 16px; background: linear-gradient(135deg, var(--art-a, var(--color-surface-2)), var(--art-b, var(--color-primary-soft)));
}
.store.shell-ui .mini-foot .price { color: var(--color-primary); font-weight: 800; }

/* Category tiles: white cards like the reference chips */
.store.shell-ui .cat-tile { background: var(--color-surface); border-color: var(--color-border); box-shadow: 0 4px 12px color-mix(in srgb, var(--color-text) 6%, transparent); }
.store.shell-ui .cat-tile[aria-current] { background: var(--color-primary); background-image: var(--btn-grad, none); border-color: transparent; color: var(--color-on-primary); }

/* ---------- Desktop: floating shell + curved rail ---------- */
@media (min-width: 900px) {
  .store.shell-ui { padding: 16px; }
  .store.shell-ui .shell {
    max-width: 1380px; margin: 0 auto; min-height: calc(100vh - 32px);
    display: grid; grid-template-columns: 88px minmax(0, 1fr); align-items: start;
    background: var(--shell-bg); border-radius: var(--shell-r); box-shadow: var(--shell-shadow);
  }
  @supports (backdrop-filter: blur(1px)) { .store.shell-ui .shell { backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); } }
  .store.shell-ui .shell-content { min-width: 0; padding: 22px 28px 28px; }
  .store.shell-ui .shell-content .container { max-width: none; padding-inline: 0; }
  .store.shell-ui main { padding-bottom: var(--sp-6); }

  /* Header sits inside the shell: no bar, no border */
  .store.shell-ui .site-header { position: relative; z-index: 35; background: none; border: 0; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
  .store.shell-ui .header-row { min-height: 56px; gap: 14px 18px; }
  .store.shell-ui .brand-mark, .store.shell-ui .brand-logo { width: 44px; height: 44px; border-radius: 14px; }
  .store.shell-ui .brand-mark { background-color: var(--color-primary); background-image: var(--btn-grad, none); }
  .store.shell-ui .brand { font-weight: 800; font-size: 1.25rem; }
  .store.shell-ui .header-search .search-field input { background: var(--color-surface); border-color: var(--color-border); border-radius: 14px; box-shadow: 0 1px 2px var(--card-sh), 0 12px 32px -18px var(--card-sh); }
  .store.shell-ui .icon-btn { border-radius: 14px; background: none; }
  .store.shell-ui .icon-btn:hover { background: var(--color-surface); }
  .store.shell-ui .wallet-chip { background: var(--color-surface); box-shadow: 0 1px 2px var(--card-sh), 0 12px 32px -18px var(--card-sh); }
  /* Dark "ตะกร้า" pill */
  .store.shell-ui .header-actions a.icon-btn[href="/cart"] {
    width: auto; display: inline-flex; align-items: center; gap: 8px; padding: 0 18px; white-space: nowrap;
    background: var(--color-text); color: var(--color-surface); font-weight: 700; font-size: var(--fs-sm);
    box-shadow: 0 10px 22px -8px color-mix(in srgb, var(--color-text) 55%, transparent);
  }
  .store.shell-ui .header-actions a.icon-btn[href="/cart"]:hover { filter: brightness(1.15); background: var(--color-text); }
  .store.shell-ui .cart-lb { display: inline; }
  .store.shell-ui .header-actions a.icon-btn[href="/cart"] .count-badge { position: static; background: var(--color-primary); color: var(--color-on-primary); }
  .store.shell-ui .announce { border-radius: 16px; margin-bottom: var(--sp-3); }

  /* Curved rail (shape from the reference: two curved caps + a straight middle) */
  .store.shell-ui .rail {
    --rail: var(--rail-c);
    position: sticky; top: 16px; z-index: 30;
    display: flex; flex-direction: column; align-items: center;
    width: 88px; margin: 90px 0 0; padding: 66px 0 72px; color: var(--rail-ink);
    background: linear-gradient(var(--rail), var(--rail)) 0 70px / 100% calc(100% - 140px) no-repeat;
    filter: drop-shadow(16px 22px 26px color-mix(in srgb, var(--rail) 38%, transparent)) drop-shadow(0 0 38px color-mix(in srgb, var(--rail) 22%, transparent));
  }
  .store.shell-ui .rail::before, .store.shell-ui .rail::after {
    content: ""; position: absolute; left: 0; width: 88px; height: 72px; z-index: -1; background: var(--rail);
    clip-path: path('M0 0C26 22 60 24 78 36Q88 42 88 56L88 72L0 72Z');
  }
  .store.shell-ui .rail::before { top: 0; }
  .store.shell-ui .rail::after { bottom: 0; transform: scaleY(-1); }
  .store.shell-ui .rail-nav { display: flex; flex-direction: column; align-items: center; gap: 2px; }
  .store.shell-ui .rail-a {
    position: relative; width: 52px; height: 52px; border-radius: 18px;
    display: grid; place-items: center; color: var(--rail-ink); text-decoration: none;
    transition: background-color var(--dur-base), color var(--dur-base);
  }
  .store.shell-ui .rail-a .icon { width: 22px; height: 22px; stroke-width: 1.7; }
  .store.shell-ui .rail-a:hover { background: color-mix(in srgb, var(--rail-ink) 16%, transparent); }
  .store.shell-ui .rail-a.on { margin: 4px 0; background: var(--rail-ink); color: var(--rail); box-shadow: 0 12px 22px -8px color-mix(in srgb, var(--rail) 70%, #000); }
  .store.shell-ui .rail-a:focus-visible, .store.shell-ui .rail-av:focus-visible { outline: 3px solid var(--rail-ink); outline-offset: 2px; }
  .store.shell-ui .rail-sep { width: 26px; height: 1px; border: 0; margin: 14px 0; background: color-mix(in srgb, var(--rail-ink) 30%, transparent); }
  .store.shell-ui .rail-av {
    position: relative; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
    border: 2px solid color-mix(in srgb, var(--rail-ink) 85%, transparent); color: var(--rail-ink); text-decoration: none; font-weight: 700;
    background: linear-gradient(135deg, color-mix(in srgb, var(--rail) 40%, #d946ef), color-mix(in srgb, var(--rail) 70%, #000));
    box-shadow: 0 8px 16px -6px color-mix(in srgb, var(--rail) 60%, #000);
  }
  .store.shell-ui .rail-av img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
  .store.shell-ui .rail-av .icon { width: 20px; height: 20px; }
  .store.shell-ui .rail-av .dot { position: absolute; right: -2px; bottom: -1px; width: 13px; height: 13px; border-radius: 50%; background: var(--color-success); border: 2px solid var(--rail); }
  /* Labels on hover / keyboard focus (the links also carry aria-label) */
  .store.shell-ui .rail [data-tip]::after {
    content: attr(data-tip); position: absolute; left: calc(100% + 24px); top: 50%; transform: translate(-6px, -50%);
    padding: 8px 12px; border-radius: 10px; white-space: nowrap; pointer-events: none; opacity: 0;
    background: var(--color-text); color: var(--color-surface); font-size: var(--fs-xs); font-weight: 700; line-height: 1;
    box-shadow: 0 10px 20px -6px var(--card-sh); transition: opacity var(--dur-base), transform var(--dur-base);
  }
  .store.shell-ui .rail [data-tip]:hover::after, .store.shell-ui .rail [data-tip]:focus-visible::after { opacity: 1; transform: translate(0, -50%); }

  .store.shell-ui .bottom-nav { display: none; }
}

/* ---------- Mobile: compact cards + floating dock ---------- */
@media (max-width: 899px) {
  .store.shell-ui .site-header { background: color-mix(in srgb, var(--color-surface) 90%, transparent); }
  .store.shell-ui .grid { gap: 14px; }
  .store.shell-ui .pcard { padding: 10px 10px 14px; gap: 8px; border-radius: 22px; }
  .store.shell-ui .pcard .pcard-media { height: 118px; aspect-ratio: auto; border-radius: 16px; }
  .store.shell-ui .pcard .pcard-media img { padding: 8px; width: 100%; height: 100%; }
  .store.shell-ui .pcard-top { min-height: 24px; }
  .store.shell-ui .pcard-title { font-size: 0.9375rem; }
  .store.shell-ui .pcard-price .price { font-size: 1.1875rem; }

  /* Dock: icons only, the current page lifts into a circle with its name in a bubble above */
  .store.shell-ui .bottom-nav {
    left: 12px; right: 12px; max-width: 440px; margin: 0 auto;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    padding: 8px 6px; border-radius: var(--radius-full);
    background: var(--color-surface); border: 1px solid var(--color-border);
    box-shadow: 0 16px 40px color-mix(in srgb, var(--color-text) 20%, transparent);
  }
  @supports (backdrop-filter: blur(1px)) { .store.shell-ui .bottom-nav { backdrop-filter: none; -webkit-backdrop-filter: none; } }
  .store.shell-ui .bottom-nav a { min-height: 44px; height: 44px; border-radius: 0; background: none; color: var(--color-text-muted); -webkit-tap-highlight-color: transparent; }
  .store.shell-ui .bottom-nav a > .icon { position: relative; z-index: 1; width: 22px; height: 22px; transition: transform var(--dur-base) var(--ease-out); }
  .store.shell-ui .bottom-nav a > span:not(.count-badge) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } /* name stays for screen readers */
  .store.shell-ui .bottom-nav a[aria-current="page"] { background: none; color: var(--color-on-primary); }
  .store.shell-ui .bottom-nav a[aria-current="page"]::before {
    content: ""; position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; margin: -24px 0 0 -24px; border-radius: 50%;
    background-color: var(--color-primary); background-image: var(--btn-grad, none);
    box-shadow: 0 10px 22px -8px var(--glow); transform: translateY(-6px);
    animation: dock-up 450ms cubic-bezier(.2, 1.4, .4, 1);
  }
  .store.shell-ui .bottom-nav a[aria-current="page"] > .icon { transform: translateY(-6px); }
  .store.shell-ui .bottom-nav a[aria-current="page"] > span:not(.count-badge) {
    width: auto; height: auto; overflow: visible; clip: auto;
    left: 50%; bottom: calc(100% + 12px); transform: translateX(-50%);
    padding: 7px 11px; border-radius: 10px; background: var(--color-text); color: var(--color-surface);
    font-size: var(--fs-xs); font-weight: 700; line-height: 1; pointer-events: none;
    animation: dock-bubble 500ms cubic-bezier(.2, 1.5, .4, 1);
  }
  .store.shell-ui .bottom-nav a[aria-current="page"] > span:not(.count-badge)::after {
    content: ""; position: absolute; left: 50%; top: 100%; margin-left: -5px; border: 5px solid transparent; border-top-color: var(--color-text);
  }
  .store.shell-ui .bottom-nav .count-badge { top: 0; z-index: 2; }
  @keyframes dock-up { from { transform: translateY(6px) scale(.6); } to { transform: translateY(-6px) scale(1); } }
  @keyframes dock-bubble { from { opacity: 0; transform: translateX(-50%) translateY(10px) scale(.7); } to { opacity: 1; transform: translateX(-50%); } }
}

@media (prefers-reduced-motion: reduce) {
  .store.shell-ui .rail-a, .store.shell-ui .rail [data-tip]::after, .store.shell-ui .bottom-nav a > .icon { transition: none; }
  .store.shell-ui .bottom-nav a[aria-current="page"]::before, .store.shell-ui .bottom-nav a[aria-current="page"] > span { animation: none; }
  .store.shell-ui .pcard:hover, .store.shell-ui .add-btn:hover { transform: none; }
}
/* Rail only on desktop; on phones the dock replaces it */
@media (max-width: 899px) { .store.shell-ui .rail { display: none; } }
.store.shell-ui .pcard-meta .pcard-sold::before { content: none; }
/* Picture fills the well exactly. Without absolute sizing the grid row grew to the picture's
   natural height (400px) and only the top half showed. */
.store.shell-ui .pcard .pcard-media img,
.store.shell-ui .mini-media.pcard-media img {
  position: absolute; inset: 0; z-index: 1;
  width: 100%; height: 100%; box-sizing: border-box; padding: 10px;
  object-fit: contain;
}
.store.shell-ui .pcard-media .pcard-badge, .store.shell-ui .pcard-media .pcard-off { z-index: 2; }
