/*
 * Shared base for every design: reset, accessibility, and the components the engine renders
 * (cart drawer, cart bar, toast, add controls, carousel track, marquee, design switcher).
 * Designs restyle these through the --ps-* tokens they set on html[data-design="N"].
 */
:root {
  --ps-bg: #fff;
  --ps-surface: #fff;
  --ps-surface-2: #f4f4f4;
  --ps-ink: #1d1d1d;
  --ps-muted: #5c5c5c;
  --ps-line: rgba(0, 0, 0, .14);
  --ps-accent: var(--brand, #333);
  --ps-on-accent: #fff;
  --ps-focus: var(--ps-accent);
  --ps-radius: 14px;
  --ps-radius-sm: 10px;
  --ps-font-body: system-ui, "Segoe UI", Tahoma, sans-serif;
  --ps-font-display: var(--ps-font-body);
  --ps-shadow: 0 18px 50px -20px rgba(0, 0, 0, .35);
  --ps-switcher-h: 52px;
  --ps-header-h: 72px;
  --ps-gutter: clamp(16px, 4vw, 40px);
  --ps-ease: cubic-bezier(.2, .7, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: var(--ps-header-h); }
html.ps-locked { overflow: hidden; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--ps-bg);
  color: var(--ps-ink);
  font-family: var(--ps-font-body);
  font-size: 1rem;
  line-height: 1.6;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s ease, color .3s ease;
}
html:not(.ps-ready) body { visibility: hidden; }
img, svg { display: block; max-width: 100%; }
img { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3, h4, p, ul, ol, figure, blockquote { margin: 0; }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ps-focus); outline-offset: 3px; }
::selection { background: color-mix(in srgb, var(--ps-accent) 30%, transparent); }
[id] { scroll-margin-top: var(--ps-header-h); }

.ps-sr {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.ps-skip {
  position: fixed; inset-inline-start: 12px; top: -60px; z-index: 100;
  background: var(--ps-ink); color: var(--ps-bg); padding: 10px 16px; border-radius: 8px;
  text-decoration: none; transition: top .2s ease;
}
.ps-skip:focus { top: 12px; }

.ps-ico { width: 1.25em; height: 1.25em; flex: none; }
[dir="rtl"] .ps-flip { transform: scaleX(-1); }

/* Logo mask: colored by currentColor, sized by height */
.ps-logo {
  display: inline-block;
  height: 44px;
  aspect-ratio: var(--ratio);
  background-color: currentColor;
  -webkit-mask: var(--mask) center / contain no-repeat;
  mask: var(--mask) center / contain no-repeat;
  flex: none;
}

/* Theme toggle shows the icon for the mode you would switch to */
.ps-ctl-theme .i-sun { display: none; }
[data-theme="dark"] .ps-ctl-theme .i-sun { display: block; }
[data-theme="dark"] .ps-ctl-theme .i-moon { display: none; }
.ps-ctl {
  position: relative;
  display: inline-grid; place-items: center;
  min-width: 44px; height: 44px; padding: 0 10px;
  border: 0; background: none; border-radius: 999px;
}
.ps-ctl-lang span { font-weight: 700; font-size: .95rem; line-height: 1; }
.ps-count {
  position: absolute; top: 2px; inset-inline-end: 0;
  min-width: 20px; height: 20px; padding: 0 5px;
  display: grid; place-items: center;
  border-radius: 999px;
  background: var(--ps-accent); color: var(--ps-on-accent);
  font: 700 .72rem/1 var(--ps-font-body);
  font-variant-numeric: tabular-nums;
}
.ps-count[data-n="0"] { display: none; }
.ps-count.is-bump { animation: ps-bump .45s var(--ps-ease); }
@keyframes ps-bump { 30% { transform: scale(1.35); } }

/* Add controls (designs restyle freely) */
.ps-add { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.ps-add.is-added { animation: ps-pop .5s var(--ps-ease); }
@keyframes ps-pop { 35% { transform: scale(.92); } 70% { transform: scale(1.06); } }
.ps-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ps-chip { display: inline-flex; flex-direction: column; align-items: center; gap: 0; line-height: 1.25; min-height: 44px; justify-content: center; }
.ps-chip.is-added { animation: ps-pop .5s var(--ps-ease); }
.ps-buy { position: relative; display: flex; gap: 8px; align-items: stretch; min-width: 0; }
.ps-opt { min-width: 0; flex: 1; min-height: 44px; }
.ps-step { display: inline-flex; }
.ps-step .ps-step-ctl { display: none; align-items: center; gap: 4px; }
.ps-step:not([data-qty="0"]) .ps-step-add { display: none; }
.ps-step:not([data-qty="0"]) .ps-step-ctl { display: inline-flex; }
.ps-step-btn { display: grid; place-items: center; width: 40px; height: 40px; }
.ps-step-q { min-width: 2ch; text-align: center; font-variant-numeric: tabular-nums; font-weight: 700; }

/* Carousel track */
.ps-track {
  position: relative;
  display: flex;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  transition: opacity .28s ease;
}
.ps-track > * { scroll-snap-align: start; flex: none; }

/* Scrollbars take the active design's colours: accent thumb on a faint track */
html {
  --ps-sb-thumb: color-mix(in srgb, var(--ps-accent) 70%, var(--ps-bg));
  --ps-sb-hover: var(--ps-accent);
  --ps-sb-track: color-mix(in srgb, var(--ps-ink) 6%, var(--ps-bg));
  scrollbar-color: var(--ps-sb-thumb) var(--ps-sb-track);
}
html *, .ps-drawer-body { scrollbar-width: thin; scrollbar-color: var(--ps-sb-thumb) transparent; }
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--ps-sb-track); }
::-webkit-scrollbar-thumb {
  background: var(--ps-sb-thumb);
  border-radius: 99px;
  border: 3px solid var(--ps-sb-track);
}
::-webkit-scrollbar-thumb:hover { background: var(--ps-sb-hover); }
::-webkit-scrollbar-corner { background: transparent; }
html * ::-webkit-scrollbar-track, html *::-webkit-scrollbar-track { background: transparent; }
html *::-webkit-scrollbar { width: 8px; height: 8px; }
html *::-webkit-scrollbar-thumb { border: 2px solid transparent; background-clip: padding-box; }
.ps-track { padding-bottom: 14px; }
/* Gliding carousels run edge to edge and loop, so no inset padding and no snapping */
html .ps-track.ps-glide {
  scroll-snap-type: none;
  padding-inline: 0 !important;
  scroll-padding-inline: 0 !important;
  scrollbar-width: none;
  -webkit-mask-image: none;
  mask-image: none;
}
html .ps-track.ps-glide::-webkit-scrollbar { display: none; }
html .ps-track.ps-glide > * { scroll-snap-align: none; }
.ps-track.ps-fading { opacity: 0; }

/* Marquee */
.ps-marquee { overflow: hidden; }
.ps-marquee [data-marquee] { display: flex; width: max-content; animation: ps-marq var(--ps-marquee, 40s) linear infinite; }
.ps-marquee:hover [data-marquee] { animation-play-state: paused; }
[dir="rtl"] .ps-marquee [data-marquee] { animation-name: ps-marq-rtl; }
@keyframes ps-marq { to { transform: translateX(-50%); } }
@keyframes ps-marq-rtl { to { transform: translateX(50%); } }

/* Buttons used by the drawer (designs may reuse .ps-btn) */
.ps-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px;
  border: 0; border-radius: var(--ps-radius-sm);
  background: var(--ps-accent); color: var(--ps-on-accent);
  font-weight: 700; text-decoration: none;
  transition: transform .15s ease, filter .15s ease;
}
.ps-btn:hover { filter: brightness(1.06); }
.ps-btn:active { transform: translateY(1px); }
.ps-btn-ghost { background: transparent; color: var(--ps-ink); box-shadow: inset 0 0 0 1.5px var(--ps-line); }
.ps-btn-block { width: 100%; }
.ps-link { border: 0; background: none; padding: 10px; text-decoration: underline; text-underline-offset: 3px; color: var(--ps-muted); min-height: 44px; }
.ps-iconbtn { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 999px; background: transparent; }
.ps-iconbtn:hover { background: color-mix(in srgb, var(--ps-ink) 8%, transparent); }

/* ---------- Cart drawer ---------- */
.ps-scrim {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(10, 6, 4, .45);
  opacity: 0; transition: opacity .25s ease;
}
.ps-scrim.is-open { opacity: 1; }
.ps-drawer {
  position: fixed; z-index: 61; top: 0; bottom: 0; inset-inline-end: 0;
  width: min(440px, 100%);
  display: flex; flex-direction: column;
  background: var(--ps-surface); color: var(--ps-ink);
  font-family: var(--ps-font-body);
  box-shadow: var(--ps-shadow);
  transform: translateX(100%);
  transition: transform .28s var(--ps-ease);
}
[dir="rtl"] .ps-drawer { transform: translateX(-100%); }
.ps-drawer.is-open { transform: none; }
.ps-drawer-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 14px 14px 20px;
  border-bottom: 1px solid var(--ps-line);
}
[dir="rtl"] .ps-drawer-head { padding: 14px 20px 14px 14px; }
.ps-drawer-head h2 { font: 700 1.35rem/1.2 var(--ps-font-display); }
.ps-drawer-n { color: var(--ps-muted); font-size: .9rem; margin-inline-end: auto; }
.ps-drawer-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 8px 20px; }
.ps-lines { list-style: none; margin: 0; padding: 0; }
.ps-line {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  grid-template-areas: "img main rm" "img qty sum";
  gap: 6px 12px; align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--ps-line);
}
.ps-line-img {
  grid-area: img; width: 56px; height: 56px; border-radius: var(--ps-radius-sm); overflow: hidden;
  background: var(--ps-surface-2); display: grid; place-items: center;
  font: 700 1.3rem var(--ps-font-display); color: var(--ps-accent);
}
.ps-line-img img { width: 100%; height: 100%; object-fit: cover; }
.ps-line-main { grid-area: main; display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.ps-line-main b { font-weight: 700; }
.ps-line-opt { font-size: .88rem; }
.ps-line-each { color: var(--ps-muted); font-size: .82rem; }
.ps-line-qty { grid-area: qty; display: inline-flex; align-items: center; gap: 2px; justify-self: start; border: 1px solid var(--ps-line); border-radius: 999px; }
.ps-line-qty button { width: 40px; height: 40px; border: 0; background: none; display: grid; place-items: center; border-radius: 999px; }
.ps-line-qty output { min-width: 2ch; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.ps-line-sum { grid-area: sum; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ps-line-rm { grid-area: rm; justify-self: end; width: 40px; height: 40px; border: 0; background: none; color: var(--ps-muted); display: grid; place-items: center; border-radius: 999px; }
.ps-line-rm:hover { color: var(--ps-ink); background: color-mix(in srgb, var(--ps-ink) 8%, transparent); }
.ps-drawer-foot { padding: 16px 20px calc(16px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--ps-line); display: grid; gap: 8px; }
.ps-total { display: flex; justify-content: space-between; align-items: baseline; font-size: 1.05rem; }
.ps-total b { font: 700 1.35rem var(--ps-font-display); font-variant-numeric: tabular-nums; }
.ps-empty, .ps-soon { display: grid; justify-items: center; text-align: center; gap: 10px; padding: 48px 8px; }
.ps-empty > .ps-ico { width: 48px; height: 48px; color: var(--ps-muted); }
.ps-empty p { color: var(--ps-muted); max-width: 30ch; }
.ps-empty p b { color: var(--ps-ink); font-size: 1.15rem; }
.ps-soon { justify-items: stretch; text-align: start; }
.ps-soon h3 { font: 700 1.4rem/1.25 var(--ps-font-display); outline: none; }
.ps-soon p { color: var(--ps-muted); margin-bottom: 8px; }

/* ---------- Floating cart bar ---------- */
.ps-cartbar {
  position: fixed; z-index: 50;
  inset-inline: 12px; bottom: calc(var(--ps-switcher-h) + 18px + env(safe-area-inset-bottom, 0px));
  margin-inline: auto; width: min(440px, calc(100% - 24px));
  display: flex; align-items: center; gap: 12px;
  min-height: 52px; padding: 8px 18px 8px 10px;
  border: 0; border-radius: 999px;
  background: var(--ps-accent); color: var(--ps-on-accent);
  box-shadow: var(--ps-shadow);
  font-family: var(--ps-font-body);
  animation: ps-rise .35s var(--ps-ease);
}
[dir="rtl"] .ps-cartbar { padding: 8px 10px 8px 18px; }
.ps-cartbar-ico { position: relative; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 999px; background: color-mix(in srgb, var(--ps-on-accent) 18%, transparent); }
.ps-cartbar .ps-count { top: -6px; inset-inline-end: -6px; background: var(--ps-on-accent); color: var(--ps-accent); }
.ps-cartbar-txt { font-weight: 700; }
.ps-cartbar-sum { margin-inline-start: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
@keyframes ps-rise { from { transform: translateY(16px); opacity: 0; } }

/* ---------- Toast ---------- */
.ps-toast {
  position: fixed; z-index: 70;
  top: 14px; inset-inline: 12px; margin-inline: auto;
  width: max-content; max-width: min(520px, calc(100% - 24px));
  display: flex; align-items: center; gap: 12px;
  padding: 10px 10px 10px 16px;
  border-radius: 14px;
  background: var(--ps-ink); color: var(--ps-bg);
  box-shadow: var(--ps-shadow);
  font-family: var(--ps-font-body); font-size: .95rem;
  opacity: 0; transform: translateY(-12px); pointer-events: none;
  transition: opacity .2s ease, transform .2s var(--ps-ease);
}
[dir="rtl"] .ps-toast { padding: 10px 16px 10px 10px; }
.ps-toast.is-on { opacity: 1; transform: none; pointer-events: auto; }
.ps-toast-msg { display: flex; align-items: center; gap: 8px; }
.ps-toast-act { border: 0; border-radius: 10px; padding: 8px 12px; min-height: 40px; background: color-mix(in srgb, var(--ps-bg) 16%, transparent); color: inherit; font-weight: 700; white-space: nowrap; }

/* ---------- Design switcher (same look in every design so it reads as a tool) ---------- */
.ps-switcher {
  position: fixed; z-index: 55;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px)); inset-inline: 10px;
  margin-inline: auto; width: max-content; max-width: calc(100% - 20px);
  display: flex; align-items: center; gap: 10px;
  height: var(--ps-switcher-h); padding: 6px 6px 6px 16px;
  border-radius: 999px;
  background: rgba(24, 22, 20, .86); color: #fff;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .5), inset 0 0 0 1px rgba(255, 255, 255, .12);
  font: 500 .85rem/1.2 system-ui, "Segoe UI", Tahoma, sans-serif;
}
[dir="rtl"] .ps-switcher { padding: 6px 16px 6px 6px; }
.ps-sw-label { display: grid; line-height: 1.15; }
.ps-sw-label span { font-size: .7rem; opacity: .7; }
.ps-sw-label b { font-weight: 700; white-space: nowrap; }
.ps-sw-picks { display: flex; gap: 2px; }
.ps-sw-picks button {
  width: 40px; height: 40px; border: 0; border-radius: 999px;
  background: transparent; color: #fff; font-weight: 700;
  transition: background-color .15s ease;
}
.ps-sw-picks button:hover { background: rgba(255, 255, 255, .14); }
.ps-sw-picks button[aria-pressed="true"] { background: #fff; color: #1a1816; }
.ps-switcher :focus-visible { outline-color: #fff; }
@media (max-width: 420px) {
  .ps-switcher { gap: 6px; padding-inline-start: 12px; }
  [dir="rtl"] .ps-switcher { padding: 6px 12px 6px 6px; }
  .ps-sw-picks button { width: 36px; }
  .ps-sw-label b { max-width: 84px; overflow: hidden; text-overflow: ellipsis; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .ps-marquee { overflow-x: auto; }
  .ps-marquee [data-marquee] { animation: none !important; }
  .ps-marquee [data-marquee] > [aria-hidden="true"] { display: none; }
}

/* Space for the fixed design bar, placed at the end of the site footer (see app.js) */
.ps-endspace {
  display: block; flex: none; width: 100%; grid-column: 1 / -1;
  height: calc(var(--ps-switcher-h) + 20px + env(safe-area-inset-bottom, 0px));
  margin: 0; padding: 0; border: 0; background: none;
}
