/* Scoped storefront polish: shared cards, sections and transaction surfaces.
 * Loads after design-system.css / ds-color-modes.css / ds-nav.css, before
 * purchase-pages.css (layout line ~356). Selectors verified against live
 * markup 2026-11-12. Consolidated from the accumulated appends: the duplicate
 * #all-games and #premium-accounts passes were merged (later rules won); the
 * premium stock badge is no longer hidden (readable chip in both themes).
 */

/* ================= section utilities ================= */
.ds-section{scroll-margin-top:84px}
.ds-section-head{align-items:flex-end}
.ds-section-title{letter-spacing:-.02em}
.ds-section-sub{max-width:44rem}
.ds-grid-games{align-items:stretch}
.ds-grid-games>li{min-width:0}

/* ================= A. product cards: base ================= */
.ds-product-card{
  border-radius:14px;
  box-shadow:0 1px 2px rgba(15,23,42,.05);
  transition:transform .18s ease,border-color .18s ease,box-shadow .18s ease;
  background:var(--ds-bg);
}
/* Card root is an <a>: visible focus ring (no movement on focus). */
a.ds-product-card:focus-visible{
  outline:none;
  border-color:var(--ds-primary);
  box-shadow:var(--ds-focus-ring);
}
/* The old conic glow ring and media sheen stay off. */
a.ds-game-card::before,
a.ds-premium-card:not(.is-disabled)::before,
.ds-game-card .ds-product-media::after,
.ds-premium-card .ds-product-media::after{display:none}

/* Media: aspect-ratio locked; --ds-bg-subtle behind the img so lazy images
   never flash white in dark mode. Games use cover, premium uses contain. */
.ds-product-media{aspect-ratio:1/1;min-height:0;background:var(--ds-bg-subtle)}
.ds-product-media img{object-fit:cover}
.ds-product-media--contain img{object-fit:contain;padding:9%}

/* Body: consistent name area so rows align; 2-line clamp, generous
   line-height for Khmer glyphs. */
.ds-product-body{gap:7px}
.ds-product-name,.ds-game-name{
  letter-spacing:-.01em;
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient:vertical;
  overflow:hidden;
  line-height:1.25;
  min-height:2.5em;
}
.ds-product-foot{gap:8px}
.ds-product-card .ds-btn{min-height:34px;border-radius:9px}
.ds-game-card{padding:7px;background:var(--ds-bg);border-radius:15px}
.ds-game-card .ds-product-media{border-radius:10px}
.ds-game-btn{min-height:34px;border-radius:9px}
.ds-premium-card .ds-product-media{background:var(--ds-bg-subtle)}
.ds-empty{border:1px dashed var(--ds-border);border-radius:14px}
.ds-card{box-shadow:0 1px 2px rgba(15,23,42,.04)}

/* Hover: desktop pointer only. Subtle lift, stronger border, soft shadow.
   No glow, no scale jumps (the conic glow from design-system is overridden
   by equal-specificity, later-file rules below). */
@media (hover:hover) and (pointer:fine){
  .ds-product-card:hover{
    transform:translateY(-3px);
    border-color:var(--ds-primary-border);
    box-shadow:0 12px 22px -14px rgba(15,23,42,.35);
  }
  a.ds-game-card:hover,
  a.ds-premium-card:not(.is-disabled):hover{
    border-color:var(--ds-primary-border);
    box-shadow:0 12px 22px -14px rgba(15,23,42,.35);
  }
  a.ds-game-card:active,
  a.ds-premium-card:not(.is-disabled):active{transform:translateY(-1px)}
}
@media (hover:none),(prefers-reduced-motion:reduce){
  .ds-product-card:hover{transform:none;box-shadow:var(--ds-shadow-sm)}
  a.ds-game-card:active,
  a.ds-premium-card:not(.is-disabled):active{transform:none}
}
@media (prefers-reduced-motion:reduce){
  .ds-product-card,.ds-product-card *{transition:none !important}
}

/* Dark theme: card chrome follows tokens (Norea palette below redefines
   them for html[data-theme=dark]). */
html[data-theme=dark] .ds-product-card{box-shadow:0 1px 2px rgba(0,0,0,.25);background:var(--ds-bg)}
html[data-theme=dark] .ds-game-card,
html[data-theme=dark] .ds-premium-card{background:var(--ds-bg)}
html[data-theme=dark] .ds-product-media{background:var(--ds-bg-subtle)}
@media (hover:hover) and (pointer:fine){
  html[data-theme=dark] .ds-product-card:hover{box-shadow:0 14px 26px -16px rgba(0,0,0,.8)}
}

/* Mobile (320-640px): tighter card paddings. */
@media (max-width:639px){
  .ds-section{margin-top:2.25rem}
  .ds-section-head{gap:.5rem}
  .ds-section-sub{font-size:.82rem}
  .ds-product-body{padding:10px 9px 9px}
  .ds-game-card{padding:5px}
  .ds-game-card .ds-product-body{padding:8px 2px 2px}
}

/* Norea-inspired storefront pass: deep navy canvas, quiet panels, compact Khmer-friendly rhythm. */
:root {
  --aj-norea-bg: #080D1B;
  --aj-norea-panel: #14182B;
  --aj-norea-panel-2: #1B2036;
  --aj-norea-border: rgba(148, 163, 184, .18);
  --aj-norea-muted: #99ACD4;
}
html[data-theme="dark"] {
  --ds-bg: var(--aj-norea-panel);
  --ds-bg-subtle: #0E1324;
  --ds-bg-elevated: #1B2036;
  --ds-border: var(--aj-norea-border);
  --ds-text: #F7FAFF;
  --ds-text-muted: var(--aj-norea-muted);
  --ds-primary: #2EA1FF;
  --ds-primary-hover: #57B3FF;
  --ds-primary-soft: rgba(46, 161, 255, .13);
  --ds-primary-border: rgba(46, 161, 255, .35);
  --ds-input-bg: #10162A;
  --ds-input-border: rgba(148, 163, 184, .28);
  --ds-focus: #57B3FF;
  --bg-page: var(--aj-norea-bg);
  --bg-nav: #080D1B;
  --bg-surface: var(--aj-norea-panel);
  --bg-card: var(--aj-norea-panel);
  --text-primary: #F7FAFF;
  --text-secondary: var(--aj-norea-muted);
  --text-muted: #7284A8;
}
html[data-theme="dark"], html[data-theme="dark"] body { background: var(--aj-norea-bg) !important; }
html[data-theme="dark"] body { font-family: Inter, "Noto Serif Khmer", "Kantumruy Pro", Battambang, system-ui, sans-serif; }
html[data-theme="dark"] .ds-section { margin-bottom: 34px; }
html[data-theme="dark"] .ds-section-head { margin-bottom: 13px; }
html[data-theme="dark"] .ds-section-title { font-weight: 750; letter-spacing: -.012em; }
html[data-theme="dark"] .ds-section-sub { color: var(--aj-norea-muted); }
html[data-theme="dark"] .ds-card,
html[data-theme="dark"] .ds-product-card,
html[data-theme="dark"] .ds-game-card,
html[data-theme="dark"] .ds-premium-card { background: var(--aj-norea-panel); border-color: var(--aj-norea-border); }
html[data-theme="dark"] .ds-game-card,
html[data-theme="dark"] .ds-premium-card { background: var(--aj-norea-panel); }
html[data-theme="dark"] .ds-game-card::before,
html[data-theme="dark"] .ds-premium-card::before,
html[data-theme="dark"] .ds-game-card .ds-product-media::after,
html[data-theme="dark"] .ds-premium-card .ds-product-media::after { display: none; }
html[data-theme="dark"] .ds-product-media { background: #0E1324; }
html[data-theme="dark"] .ds-product-body { background: var(--aj-norea-panel); }
html[data-theme="dark"] .ds-game-btn { background: rgba(46,161,255,.12); border-color: rgba(46,161,255,.34); color: #57B3FF; }
html[data-theme="dark"] a.ds-game-card:hover .ds-game-btn,
html[data-theme="dark"] a.ds-game-card:focus-visible .ds-game-btn { background: #2EA1FF; border-color: #2EA1FF; color: #06101E; }
html[data-theme="dark"] .ds-site-nav { background: #080D1B; border-bottom-color: rgba(148,163,184,.22); box-shadow: 0 8px 24px rgba(0,0,0,.22); }
html[data-theme="dark"] .aj-language-selector > button,
html[data-theme="dark"] .ajf { background: #0B1020; }
html[data-theme="dark"] .ajf-bottom { background: rgba(5, 9, 18, .78); }
/* The existing decorative skyline stays available, but the Norea-like page rhythm keeps it quiet. */
@media (max-width: 639px) {
  html[data-theme="dark"] .ds-container { padding-inline: 16px; }
  html[data-theme="dark"] .ds-section { margin-top: 2rem; margin-bottom: 28px; }
  html[data-theme="dark"] .ds-grid-games { gap: 9px; }
  html[data-theme="dark"] .ds-product-card { border-radius: 12px; }
  html[data-theme="dark"] .ds-product-body { padding: 10px 9px 9px; }
  html[data-theme="dark"] .ds-product-name { font-size: .875rem; }
}

/* Ensure the shared page canvas follows the Norea-inspired dark palette. */
html[data-theme="dark"] body.bg-bg-1,
html[data-theme="dark"] body#app-body,
html[data-theme="dark"] #app-body { background-color: #080D1B !important; }
html[data-theme="dark"] #main-content { background-color: transparent !important; }
html[data-theme="dark"] .khs-backdrop,
html[data-theme="dark"] .khs-rail { opacity: .35; }

/* ================= A. All-games catalog (consolidated) ================= */
/* Section head: icon tile off, live count via data-count, "View All" chip. */
#all-games .ds-section-head { align-items: center; }
#all-games .ds-section-title { gap: 8px; }
#all-games .ds-section-title .ds-icon-tile { display: none; }
#all-games .ds-section-sub { display: none; }
#all-games .ds-section-head::after { content: 'View All  ?'; display: inline-flex; align-items: center; min-height: 34px; padding: 0 12px; border: 1px solid var(--ds-border); border-radius: 8px; color: var(--ds-text); background: var(--ds-bg-subtle); font-size: .78rem; font-weight: 700; white-space: nowrap; }

#all-games .ds-grid-games { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
#all-games .ds-game-card {
  min-width: 0;
  padding: 5px;
  border: 2px solid #343944;
  border-radius: 12px;
  background: #17191f;
  box-shadow: 0 2px 0 rgba(0,0,0,.45);
}
#all-games .ds-game-card .ds-product-media { border-radius: 8px; border: 1px solid #101217; }
#all-games .ds-game-card .ds-product-body { padding: 7px 1px 1px; gap: 6px; }
#all-games .ds-game-card .ds-game-name {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .015em;
  line-height: 1.25;
  min-height: 2.5em;
}
#all-games ul#all-games-list li a.ds-product-card h3.ds-game-name {
  color: #f8f4e8 !important;
  opacity: 1 !important;
  visibility: visible !important;
  text-shadow: 0 1px 2px rgba(0,0,0,.8) !important;
}
#all-games .ds-game-btn {
  min-height: 32px;
  border-radius: 999px;
  background: #f3f0e6;
  border: 1px solid #d5d1c5;
  color: #292a2c;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: .72rem;
  font-weight: 700;
}
#all-games .ds-game-btn { color: #292a2c !important; background: #f3f0e6 !important; border-color: #d5d1c5 !important; }
#all-games a.ds-game-card:hover .ds-game-btn,
#all-games a.ds-game-card:focus-visible .ds-game-btn { background: #fffdf4; color: #111318; }
@media (min-width: 768px) {
  #all-games .ds-grid-games { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
  #all-games .ds-game-card .ds-game-name { font-size: .82rem; }
}
@media (min-width: 1280px) {
  #all-games .ds-grid-games { gap: 14px; }
}
@media (max-width: 399px) {
  #all-games .ds-grid-games { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
  #all-games .ds-game-card .ds-game-name { font-size: .64rem; }
  #all-games .ds-game-btn { font-size: .64rem; }
}

/* ================= A. Premium Accounts catalog (consolidated) =================
   Compact grid kept from the earlier pass; the stock badge chip is readable
   again (an older append hid it). Featured flag + plan meta stay hidden. */
#premium-accounts .ds-section-head { align-items: center; }
#premium-accounts .ds-section-title .ds-icon-tile { display: none; }
#premium-accounts .ds-section-sub { max-width: 42rem; }
#premium-accounts .ds-grid-games,
.aj-related .ds-grid-products { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
#premium-accounts .ds-premium-card,
.aj-related .ds-premium-card {
  min-width: 0;
  padding: 5px;
  border: 2px solid #343944;
  border-radius: 12px;
  background: #17191f;
  box-shadow: 0 2px 0 rgba(0,0,0,.45);
}
#premium-accounts .ds-premium-card .ds-product-media,
#premium-accounts .ds-premium-card .ds-product-media--contain,
.aj-related .ds-premium-card .ds-product-media {
  border-radius: 8px;
  background: #101217;
  border: 1px solid #0b0d11;
}
#premium-accounts .ds-premium-card .ds-product-media img,
.aj-related .ds-premium-card .ds-product-media img { object-fit: contain; padding: 12%; }
#premium-accounts .ds-premium-card .ds-product-body,
.aj-related .ds-premium-card .ds-product-body { align-items: center; padding: 7px 1px 1px; gap: 6px; }
#premium-accounts .ds-premium-card .ds-product-name,
.aj-related .ds-premium-card .ds-product-name {
  font-family: Georgia, 'Times New Roman', serif;
  text-align: center;
  text-transform: uppercase;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .015em;
  line-height: 1.25;
  min-height: 2.5em;
  width: 100%;
  color: #f8f4e8;
  text-shadow: 0 1px 2px rgba(0,0,0,.9);
}
/* Stock badge: consistent chip, readable in both themes. */
#premium-accounts .ds-premium-card .ds-badge { font-size: .68rem; padding: 2px 8px; }
/* Featured flag + plan meta stay hidden in the compact grid. */
#premium-accounts .ds-premium-card .ds-product-flag,
#premium-accounts .ds-premium-card .ds-product-meta,
.aj-related .ds-premium-card .ds-product-flag,
.aj-related .ds-premium-card .ds-product-meta { display: none; }
#premium-accounts .ds-premium-card .ds-product-foot,
.aj-related .ds-premium-card .ds-product-foot { width: 100%; padding-top: 0; gap: 0; }
#premium-accounts .ds-premium-card .ds-btn,
.aj-related .ds-premium-card .ds-btn {
  min-height: 32px;
  border-radius: 999px;
  background: #f3f0e6;
  border: 1px solid #d5d1c5;
  color: #292a2c;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: .72rem;
  font-weight: 700;
}
#premium-accounts a.ds-premium-card:hover .ds-btn,
#premium-accounts a.ds-premium-card:focus-visible .ds-btn { background: #fffdf4; color: #111318; }
@media (min-width: 768px) {
  #premium-accounts .ds-grid-games,
  .aj-related .ds-grid-products { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
  #premium-accounts .ds-premium-card .ds-product-name,
  .aj-related .ds-premium-card .ds-product-name { font-size: .82rem; }
}
@media (min-width: 1280px) {
  #premium-accounts .ds-grid-games,
  .aj-related .ds-grid-products { gap: 14px; }
}
@media (max-width: 399px) {
  #premium-accounts .ds-grid-games,
  .aj-related .ds-grid-products { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
}

/* Catalog cards follow the active theme. Dark chrome only in dark mode. */
html[data-theme="light"] #all-games .ds-game-card,
html:not([data-theme="dark"]) #all-games .ds-game-card,
html[data-theme="light"] #premium-accounts .ds-premium-card,
html:not([data-theme="dark"]) #premium-accounts .ds-premium-card,
html[data-theme="light"] .aj-related .ds-premium-card,
html:not([data-theme="dark"]) .aj-related .ds-premium-card {
  background: #ffffff !important;
  border-color: #d7dce5 !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .06) !important;
}
html[data-theme="light"] #all-games ul#all-games-list li a.ds-product-card h3.ds-game-name,
html:not([data-theme="dark"]) #all-games ul#all-games-list li a.ds-product-card h3.ds-game-name,
html[data-theme="light"] #premium-accounts .ds-premium-card .ds-product-name,
html:not([data-theme="dark"]) #premium-accounts .ds-premium-card .ds-product-name,
html[data-theme="light"] .aj-related .ds-product-name,
html:not([data-theme="dark"]) .aj-related .ds-product-name {
  color: #111827 !important;
  text-shadow: none !important;
}
html[data-theme="light"] #all-games .ds-game-btn,
html:not([data-theme="dark"]) #all-games .ds-game-btn,
html[data-theme="light"] #premium-accounts .ds-premium-card .ds-btn,
html:not([data-theme="dark"]) #premium-accounts .ds-premium-card .ds-btn,
html[data-theme="light"] .aj-related .ds-btn,
html:not([data-theme="dark"]) .aj-related .ds-btn {
  background: #f7f4ea !important;
  border-color: #e6e1d4 !important;
  color: #1a1c22 !important;
}
html[data-theme="light"] #premium-accounts .ds-premium-card .ds-product-media,
html[data-theme="light"] #premium-accounts .ds-premium-card .ds-product-media--contain,
html:not([data-theme="dark"]) #premium-accounts .ds-premium-card .ds-product-media,
html:not([data-theme="dark"]) #premium-accounts .ds-premium-card .ds-product-media--contain {
  background: #f3f5f8 !important;
  border-color: #e5e7eb !important;
}

/* ================= B. Checkout & payment (CSS-only) ================= */

/* Totals: steady digits while the price updates. */
#totalDisplay, #totalPriceMobile, .js-total, .ds-summary-total { font-variant-numeric: tabular-nums; }

/* Pay buttons: disabled/loading state. Both checkouts disable the button in
   JS while submitting (game-show.js isProcessingPayment, premium-checkout.js
   c.busy + inline spinner), so :disabled is the loading state. */
#buyNowBtn:disabled,
#buyNowBtnMobile:disabled,
button.js-buy:disabled {
  opacity: .75;
  cursor: progress;
  pointer-events: none;
  box-shadow: none;
  transform: none;
}

/* Game checkout: fixed mobile bar respects the iOS home indicator. */
#summaryBarMobile { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
#summaryBarDesktop { box-shadow: 0 -8px 24px -18px rgba(15,23,42,.35); }

/* Premium checkout: full-width pay button in the mobile summary bar. */
@media (max-width: 479px) {
  .ds-summary-bar .js-buy { flex: 1 1 auto; min-width: 0; }
}

/* Premium order page: product logo tile should contain, not crop. */
body[data-page="premium.orders.show"] .ds-card img.w-20.h-20 {
  object-fit: contain;
  background: var(--ds-bg-subtle);
  padding: 4px;
}

/* Status chips: token-driven borders in dark mode (design-system hardcodes
   pastel borders that are too bright on dark softs). */
.ds-badge-success { border-color: var(--ds-badge-success-border, #BBF7D0); }
.ds-badge-error { border-color: var(--ds-badge-error-border, #FECACA); }
.ds-badge-warning { border-color: var(--ds-badge-warning-border, #FDE68A); }
html[data-theme="dark"] .ds-notice-success { border-color: var(--ds-badge-success-border); }
html[data-theme="dark"] .ds-notice-error { border-color: var(--ds-badge-error-border); }
html[data-theme="dark"] .ds-notice-warning { border-color: var(--ds-badge-warning-border); }

/* Payment result card: tighter padding on small phones. */
@media (max-width: 380px) {
  body[data-page="payment.success"] .ds-card,
  body[data-page="payment.failed"] .ds-card { padding: 20px; }
}
