:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --text: #1a2333;
  --muted: #62708a;
  --accent: #1769ff;
  --accent-hover: #0f55d6;
  --danger: #c33434;
  --border: #dce3ef;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #eef2fb 0%, #f8fbff 100%);
}

body.modal-open {
  overflow: hidden;
}

.container {
  width: min(1100px, 92vw);
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #ffffffd9;
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
}

.brand {
  font-weight: 700;
  text-decoration: none;
  color: var(--text);
}

.cart-button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 0.6rem 1rem;
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  cursor: pointer;
}

.cart-badge {
  min-width: 1.4rem;
  height: 1.4rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.3rem;
}

main {
  padding: 2rem 0 3rem;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
}

.product-link {
  text-decoration: none;
  color: inherit;
}

.product-image {
  width: 100%;
  border-radius: 10px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 1px solid var(--border);
}

.product-meta {
  margin: 0.2rem 0;
  color: var(--muted);
}

.product-price {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0.3rem 0 1rem;
}

.product-actions {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.add-button,
.details-link,
.checkout-button {
  border: none;
  border-radius: 8px;
  padding: 0.55rem 0.8rem;
  cursor: pointer;
  text-decoration: none;
  font-size: 0.95rem;
}

.add-button,
.checkout-button {
  background: var(--accent);
  color: #fff;
}

.add-button:hover,
.checkout-button:hover {
  background: var(--accent-hover);
}

.add-button.is-added {
  animation: addButtonPulse 0.35s ease-out;
}

.cart-badge.is-bumped {
  animation: badgeBump 0.4s ease-out;
}

.details-link {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.product-page {
  display: grid;
  gap: 1.4rem;
  grid-template-columns: 1fr 1fr;
  align-items: start;
}

.product-page-image {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--border);
}

.cart-modal[aria-hidden='true'] {
  display: none;
}

.cart-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
}

.cart-backdrop {
  position: absolute;
  inset: 0;
  background: #05102670;
}

.cart-panel {
  position: absolute;
  right: 0;
  top: 0;
  width: min(480px, 95vw);
  height: 100%;
  background: var(--surface);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.cart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.icon-button {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1.8rem;
  line-height: 1;
}

.cart-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  overflow: auto;
}

.cart-item {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem;
}

.cart-item img {
  width: 100%;
  border-radius: 8px;
}

.qty-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.qty-controls button {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  padding: 0.25rem 0.45rem;
  cursor: pointer;
}

.qty-controls .remove {
  color: var(--danger);
  border-color: #f0c9c9;
}

.cart-empty {
  color: var(--muted);
}

.cart-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  display: grid;
  gap: 0.8rem;
}

.checkout-fields {
  display: grid;
  gap: 0.6rem;
}

.checkout-fields label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.checkout-fields input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  font: inherit;
  color: var(--text);
}

.success {
  max-width: 600px;
  padding: 1.2rem;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 14px;
}

@keyframes addButtonPulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.08);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes badgeBump {
  0% {
    transform: translateY(0) scale(1);
  }

  45% {
    transform: translateY(-2px) scale(1.2);
  }

  100% {
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 900px) {
  .products-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .product-page {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .products-grid {
    grid-template-columns: 1fr;
  }
}
