/* Base reset */
html {
  font-size: 16px;
}

/* Interactive defaults — every <button> shows a pointer on hover; disabled
 * buttons get the native "not-allowed" cursor. Individual templates that
 * wanted this added inline forgot to on a few (hamburger, product back
 * button), so we cover it globally once. */
button {
  cursor: pointer;
}
/* Children of buttons (icons, SVGs, spans wrapping them) should never
 * override the button's cursor — so hover shows a pointer anywhere inside
 * the button hit area, not just on padding. */
button * {
  cursor: inherit;
}
button:disabled,
button[aria-disabled="true"] {
  cursor: not-allowed;
}

html,
body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

body {
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: var(--line-height);
  font-size: var(--text-base);
  font-weight: var(--font-normal);
}

/*
 * Storefront layout — mobile render everywhere, clamped to a phone-width
 * column on desktop (LinkedIn/Instagram style). The wrapper is emitted by
 * `pageWrapperSchema` and sits between <body> and the page-specific
 * template, so every page inherits the column automatically.
 */
.page-wrapper {
  width: 100%;
  min-height: 100vh;
  background: var(--bg-page);
  margin-inline: auto;
}

@media (min-width: 768px) {
  body {
    background: #f3f4f6;
  }
  .page-wrapper {
    max-width: 520px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05), 0 10px 40px rgba(0, 0, 0, 0.06);
  }
  /* Marketplace storefronts are dense — Daraz / Flipkart / Amazon scale
     to the viewport. Drop the phone-width clamp and ditch the side
     shadow so the layout uses the full window. The inner page templates
     keep their own desktop max-widths (e.g. 1280-1440px) so we don't go
     edge-to-edge on ultrawide. */
  .page-wrapper--wide {
    max-width: none;
    box-shadow: none;
    background: var(--bg-page);
  }
  /* Wide-wrapper pages with feed-column content (checkout, cart, orders,
     profile) — without anchor, the 640px column floats unframed in the
     middle of the wide page background. Give it a soft surface so it
     reads as a card rather than a void. Scoped to wide wrapper so it
     doesn't touch the existing column-clamped variants. */
  .page-wrapper--wide .feed-column-anchor,
  .page-wrapper--wide #checkout-page,
  .page-wrapper--wide #cart-page {
    background: var(--bg-surface, #ffffff);
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.04);
  }
}

/* Typography */
h1,
h2,
h3 {
  color: var(--text-heading);
  font-weight: var(--font-bold);
}

h1 {
  margin: 0;
}

small,
.caption {
  color: var(--text-muted);
  font-size: var(--text-xs);
}

/* Input base */
input {
  height: var(--h-10);
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  width: 100%;
  margin: 0;
  box-sizing: border-box;
  /* Bind the input surface + text to theme tokens. Previously unset, so the
     browser used its own white box while text inherited the (light, on dark
     presets) body colour — i.e. white-on-white. Now both follow the active
     theme/style and keep their guaranteed contrast pairing. */
  color: var(--text-main);
  background: var(--bg-surface);
  font-family: var(--font-sans);
}

/* Textarea — mirror the input surface/text binding so multi-line fields theme
   identically (templates historically styled textareas only inline). */
textarea {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  width: 100%;
  margin: 0;
  box-sizing: border-box;
  color: var(--text-main);
  background: var(--bg-surface);
  font-family: var(--font-sans);
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

input::placeholder,
textarea::placeholder {
  letter-spacing: normal;
  font-size: var(--text-sm) !important;
  color: var(--text-muted);
}

/* Checkbox */
input[type="checkbox"] {
  padding: 0.7rem 0.6rem;
  width: auto;
  height: auto;
  appearance: none;
  border: 2px solid var(--color-primary);
  border-radius: 0;
  background: var(--bg-surface);
  cursor: pointer;
  position: relative;
  vertical-align: middle;
}

input[type="checkbox"]:checked::after {
  content: "";
  display: block;
  position: absolute;
  left: 5px;
  top: 2px;
  width: 6px;
  height: 12px;
  border: solid var(--button-text);
  border-width: 0 3px 3px 0;
  transform: rotate(45deg);
}

/* Radio */
input[type="radio"] {
  width: 20px;
  height: 20px;
  padding: 0;
  appearance: none;
  border: 2px solid var(--color-primary);
  border-radius: 50%;
  background: var(--bg-surface);
  cursor: pointer;
  position: relative;
  vertical-align: middle;
  box-sizing: border-box;
  display: inline-block;
}

input[type="radio"]:checked::after {
  content: "";
  display: block;
  position: absolute;
  left: 3px;
  top: 3px;
  width: 8px;
  height: 8px;
  background: var(--color-primary);
  border-radius: 50%;
}

/* Select */
select {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--bg-surface);
  cursor: pointer;
  font-size: var(--text-xs);
  color: var(--text-main);
  appearance: none;
  /* Mid-grey arrow (#888) reads on both light and dark theme surfaces — a data
     URI can't reference a CSS var, so #333 went invisible on dark presets. */
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20fill%3D%22%23888888%22%20d%3D%22M7.41%208.59L12%2013.17l4.59-4.58L18%2010l-6%206-6-6z%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
}

/* Links */
a {
  text-decoration: none;
  color: var(--text-main);
}

/* Error styles */
.input-error {
  color: var(--text-error);
  font-size: var(--text-xs);
}

.form-error {
  color: var(--text-error);
  font-size: var(--text-lg);
}

.text-error {
  color: var(--text-error);
  font-size: var(--text-base);
}

/* Navigation */
.nav a {
  color: var(--text-on-dark);
  text-decoration: none;
  margin-right: var(--space-md);
}

.nav a:hover {
  color: var(--color-secondary);
}

/* Outline button */
.outline-btn:hover,
.outline-btn:focus,
.outline-btn.active {
  background: var(--bg-surface);
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

.outline-btn.selected {
  border-color: var(--color-primary) !important;
  box-shadow: var(--shadow-sm) !important;
}

/* Circular button */
.circular-btn {
  border-radius: var(--radius-full);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
}

.light-circular-btn {
  background-color: var(--text-on-dark);
}

.light-circular-btn:hover,
.light-circular-btn:focus,
.light-circular-btn.selected,
.light-circular-btn.active {
  border-color: var(--color-primary);
  background-color: var(--color-primary);
  color: var(--button-text) !important;
}

/* Chip button — bound to theme tokens (was pinned to --color-white/black, so
   chips never followed a style change). */
.chip-button {
  background-color: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.chip-button.active {
  background-color: var(--color-primary);
  color: var(--button-text);
  border-color: var(--color-primary);
}

/* Search modal */
.search-modal {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  display: none;
  z-index: var(--z-modal);
}

/* Utility */
.divider {
  height: 1px;
  background-color: var(--border-color);
  width: 100%;
  margin: 4px 0;
}

/* Responsive */
@media (max-width: 767px) {
  .responsive-container {
    width: 100%;
    min-width: unset;
    border-radius: 0;
  }
}

@media (min-width: 768px) {
  body {
    margin-left: auto;
    margin-right: auto;
  }
}

/* Add to cart animation */
.flying-image {
  position: fixed;
  z-index: 1000;
  width: var(--product-image-width);
  height: var(--product-image-height);
  transition:
    transform 1s ease-in,
    opacity 1s ease-in;
  pointer-events: none;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25%,
  75% {
    transform: translateX(-5px);
  }
  50% {
    transform: translateX(5px);
  }
}

#add-to-cart-btn.shake {
  animation: shake 0.5s;
}
