/* ───── Page layout ───── */

.printify-store {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.store-header { text-align: center; margin-bottom: 3rem; }

.store-title {
  font-size: 3.2rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
}
.dark-mode .store-title { color: var(--white-color); }

.store-description {
  font-size: 1.7rem;
  color: var(--secondary-text-color);
  max-width: 660px;
  margin: 0 auto;
  line-height: 1.6;
}
.dark-mode .store-description,
.dark-mode .store-loading { color: var(--dark-mode-secondary-text-color); }

/* ───── Product grid ───── */

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 2rem;
}

.product-card {
  cursor: pointer;
  transition: transform 0.2s var(--animation-base);
  border-bottom: 1px solid var(--mid-gray-color);
  padding-bottom: 1.5rem;
}
.dark-mode .product-card { border-color: var(--dark-mode-border-color); }

.product-card:hover { transform: translateY(-3px); }

.product-image {
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  margin-bottom: 1rem;
}
.product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.product-title {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 400;
  margin: 0 0 0.6rem;
  line-height: 1.35;
  color: var(--primary-text-color);
}
.dark-mode .product-title { color: var(--dark-mode-primary-text-color); }

.product-footer { display: flex; align-items: center; justify-content: space-between; }

.product-price {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--primary-text-color);
}
.dark-mode .product-price { color: var(--dark-mode-primary-text-color); }

/* ───── Loading / empty / error ───── */

.store-loading {
  text-align: center;
  padding: 6rem 1rem;
  font-size: 1.7rem;
  color: var(--secondary-text-color);
}

.spinner {
  width: 2.4rem;
  height: 2.4rem;
  border: 3px solid var(--mid-gray-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin: 0 auto 1rem;
}
.dark-mode .spinner { border-color: var(--dark-mode-border-color); border-top-color: var(--primary-color); }

@keyframes spin { to { transform: rotate(360deg); } }

.store-empty, .store-error { text-align: center; padding: 6rem 1rem; font-size: 1.7rem; color: var(--secondary-text-color); }
.store-error { color: var(--red-color); }

/* ───── Product modal (pm) ───── */

.pm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  backdrop-filter: blur(6px);
}

.pm-content {
  background: var(--white-color);
  max-width: 1100px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}
.dark-mode .pm-content { background: var(--dark-mode-bg-color); }

.pm-close {
  position: absolute;
  top: 1.2rem; right: 1.2rem;
  width: 3.2rem; height: 3.2rem;
  border-radius: 50%;
  border: none;
  background: var(--light-gray-color);
  color: var(--primary-text-color);
  font-size: 2rem;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.2s var(--animation-base);
}
.dark-mode .pm-close { background: var(--dark-mode-darker-bg-color); color: var(--dark-mode-primary-text-color); }
.pm-close:hover { background: var(--mid-gray-color); }
.dark-mode .pm-close:hover { background: var(--dark-mode-border-color); }

.pm-layout { display: grid; grid-template-columns: 1fr 1fr; min-height: 0; }

/* Gallery */

.pm-gallery {
  padding: 2rem;
  background: var(--light-gray-color);
}
.dark-mode .pm-gallery { background: var(--dark-mode-darker-bg-color); }

.pm-gallery-main {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  background: rgba(0,0,0,0.04);
}
.dark-mode .pm-gallery-main { background: rgba(0,0,0,0.2); }

.pm-gallery-main img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transition: opacity 0.3s var(--animation-base);
}

.pm-gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 3rem; height: 3rem;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.45);
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s var(--animation-base), background 0.2s var(--animation-base);
}
.pm-gallery-main:hover .pm-gallery-nav { opacity: 1; }
.pm-gallery-nav:hover { background: rgba(0,0,0,0.7); }
.pm-gallery-prev { left: 0.75rem; }
.pm-gallery-next { right: 0.75rem; }

.pm-gallery-thumbs {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.8rem;
  overflow-x: auto;
}

.pm-thumb {
  width: 5rem; height: 5rem;
  object-fit: cover;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s var(--animation-base);
  flex-shrink: 0;
}
.pm-thumb:hover { opacity: 0.8; }
.pm-thumb.active { opacity: 1; outline: 2px solid var(--primary-color); outline-offset: -2px; }

/* Details panel */

.pm-details {
  padding: 2.4rem 2.4rem 2.4rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.pm-title {
  font-family: var(--font-serif);
  font-size: 2.4rem;
  font-weight: 400;
  margin: 0;
  line-height: 1.3;
  color: var(--primary-text-color);
}
.dark-mode .pm-title { color: var(--dark-mode-primary-text-color); }

.pm-price {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-color);
}

.pm-description {
  font-size: 1.5rem;
  line-height: 1.65;
  color: var(--secondary-text-color) !important;
  flex: 1;
}
.dark-mode .pm-description { color: var(--dark-mode-primary-text-color) !important; }

.pm-description p,
.pm-description ul,
.pm-description ol { margin: 0 0 1em; }
.pm-description ul, .pm-description ol { padding-left: 2rem; }
.pm-description li { margin-bottom: 0.3em; }
.pm-description strong { font-weight: 600; }
.pm-description em { font-style: italic; }

/* Variant selectors */

.variant-group { display: flex; flex-direction: column; gap: 0.6rem; }

.variant-label {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--primary-text-color);
}
.dark-mode .variant-label { color: var(--dark-mode-primary-text-color); }

.variant-options { display: flex; flex-wrap: wrap; gap: 0.6rem; }

.variant-pill {
  padding: 0.5rem 1.2rem;
  font-size: 1.3rem;
  font-weight: 500;
  border: 1px solid var(--mid-gray-color);
  background: transparent;
  color: var(--primary-text-color);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all 0.15s var(--animation-base);
}
.dark-mode .variant-pill { border-color: var(--dark-mode-border-color); color: var(--dark-mode-primary-text-color); }
.variant-pill:hover { border-color: var(--primary-text-color); }
.dark-mode .variant-pill:hover { border-color: var(--dark-mode-primary-text-color); }
.variant-pill.active { border-color: var(--primary-color); background: var(--primary-color); color: var(--white-color); }

.variant-swatch {
  width: 3.2rem; height: 3.2rem;
  border-radius: 50%;
  border: 2px solid var(--mid-gray-color);
  cursor: pointer;
  padding: 0;
  background: var(--swatch, var(--light-gray-color));
  transition: all 0.15s var(--animation-base);
}
.dark-mode .variant-swatch { border-color: var(--dark-mode-border-color); background: var(--swatch, var(--dark-mode-darker-bg-color)); }
.variant-swatch:hover { border-color: var(--primary-text-color); }
.dark-mode .variant-swatch:hover { border-color: var(--dark-mode-primary-text-color); }
.variant-swatch.active {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px var(--white-color), 0 0 0 4px var(--primary-color);
}
.dark-mode .variant-swatch.active {
  box-shadow: 0 0 0 2px var(--dark-mode-bg-color), 0 0 0 4px var(--primary-color);
}

/* Quantity selector */

.pm-qty { display: flex; flex-direction: column; gap: 0.4rem; }

.pm-qty-label {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--primary-text-color);
}
.dark-mode .pm-qty-label { color: var(--dark-mode-primary-text-color); }

.pm-qty-controls {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--mid-gray-color);
  width: fit-content;
}
.dark-mode .pm-qty-controls { border-color: var(--dark-mode-border-color); }

.pm-qty-btn {
  width: 3.2rem;
  height: 3.2rem;
  border: none;
  background: transparent;
  color: var(--primary-text-color);
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dark-mode .pm-qty-btn { color: var(--dark-mode-primary-text-color); }
.pm-qty-btn:hover { background: var(--light-gray-color); }
.dark-mode .pm-qty-btn:hover { background: var(--dark-mode-darker-bg-color); }

.pm-qty-value {
  width: 3rem;
  text-align: center;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--primary-text-color);
}
.dark-mode .pm-qty-value { color: var(--dark-mode-primary-text-color); }

/* Add to cart button */

.pm-atc {
  width: 100%;
  padding: 1.2rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--white-color);
  background: var(--primary-color);
  border: none;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: opacity 0.2s var(--animation-base);
}
.pm-atc:hover { opacity: 0.88; }
.pm-atc:disabled { opacity: 0.35; cursor: not-allowed; }

/* ───── Cart badge (inline in store header) ───── */

.store-header { position: relative; }

#cart-badge {
  position: absolute;
  top: 0;
  right: 0;
  display: none;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  color: var(--primary-text-color);
  font-size: 1.4rem;
  padding: 0.5rem 0.8rem;
  z-index: 100;
  transition: opacity 0.2s var(--animation-base);
}
.dark-mode #cart-badge { color: var(--dark-mode-primary-text-color); }
#cart-badge:hover { opacity: 0.7; }

.cart-badge-count {
  font-weight: 700;
  font-size: 1.3rem;
  background: var(--primary-color);
  color: var(--white-color);
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
}

.cart-badge-icon { font-size: 1.8rem; line-height: 1; }

#cart-badge.flash { animation: badgeFlash 0.4s var(--animation-base); }
@keyframes badgeFlash {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* ───── Cart drawer ───── */

#cart-drawer {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
}
#cart-drawer.open { display: block; }

.cart-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
}

.cart-drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 42rem;
  max-width: 100vw;
  height: 100%;
  background: var(--white-color);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s var(--animation-base);
}
#cart-drawer.open .cart-drawer-panel { transform: translateX(0); }
.dark-mode .cart-drawer-panel { background: var(--dark-mode-bg-color); }

.cart-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.6rem;
  border-bottom: 1px solid var(--mid-gray-color);
}
.dark-mode .cart-drawer-header { border-color: var(--dark-mode-border-color); }

.cart-drawer-title {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 400;
  margin: 0;
  color: var(--primary-text-color);
}
.dark-mode .cart-drawer-title { color: var(--dark-mode-primary-text-color); }

.cart-drawer-close {
  width: 3rem; height: 3rem;
  border: none;
  background: transparent;
  font-size: 2.4rem;
  cursor: pointer;
  color: var(--primary-text-color);
  display: flex;
  align-items: center;
  justify-content: center;
}
.dark-mode .cart-drawer-close { color: var(--dark-mode-primary-text-color); }

.cart-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.6rem;
}

.cart-empty {
  text-align: center;
  font-size: 1.5rem;
  color: var(--secondary-text-color);
  padding: 4rem 0;
}

/* Cart item */

.cart-item {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 1rem 0;
  border-bottom: 1px solid var(--light-gray-color);
}
.dark-mode .cart-item { border-color: var(--dark-mode-darker-bg-color); }

.cart-item-img {
  width: 6rem;
  height: 6rem;
  object-fit: cover;
  flex-shrink: 0;
}

.cart-item-info { flex: 1; min-width: 0; }

.cart-item-title {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--primary-text-color);
  line-height: 1.3;
}
.dark-mode .cart-item-title { color: var(--dark-mode-primary-text-color); }

.cart-item-variant {
  font-size: 1.2rem;
  color: var(--secondary-text-color);
  margin-top: 0.2rem;
}
.dark-mode .cart-item-variant { color: var(--dark-mode-secondary-text-color); }

.cart-item-price {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-top: 0.3rem;
}

.cart-item-qty {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--mid-gray-color);
  flex-shrink: 0;
}
.dark-mode .cart-item-qty { border-color: var(--dark-mode-border-color); }

.cart-qty-btn {
  width: 2.6rem; height: 2.6rem;
  border: none;
  background: transparent;
  color: var(--primary-text-color);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dark-mode .cart-qty-btn { color: var(--dark-mode-primary-text-color); }
.cart-qty-btn:hover { background: var(--light-gray-color); }
.dark-mode .cart-qty-btn:hover { background: var(--dark-mode-darker-bg-color); }

.cart-qty-value {
  width: 2.4rem;
  text-align: center;
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--primary-text-color);
}
.dark-mode .cart-qty-value { color: var(--dark-mode-primary-text-color); }

.cart-item-remove {
  width: 2.4rem; height: 2.4rem;
  border: none;
  background: transparent;
  color: var(--secondary-text-color);
  font-size: 1.6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.cart-item-remove:hover { color: var(--red-color); }

/* Cart footer */

.cart-drawer-footer {
  padding: 1.6rem;
  border-top: 1px solid var(--mid-gray-color);
}
.dark-mode .cart-drawer-footer { border-color: var(--dark-mode-border-color); }

.cart-subtotal {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary-text-color);
  margin-bottom: 1rem;
  text-align: right;
}
.dark-mode .cart-subtotal { color: var(--dark-mode-primary-text-color); }

.cart-checkout-btn {
  width: 100%;
  padding: 1.2rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--white-color);
  background: var(--primary-color);
  border: none;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: opacity 0.2s var(--animation-base);
}
.cart-checkout-btn:hover { opacity: 0.88; }

/* ───── Checkout modal (co) ───── */

.co-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 10001;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  backdrop-filter: blur(6px);
}
.co-modal.open { display: flex; }

.co-content {
  background: var(--white-color);
  max-width: 56rem;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 3rem;
  position: relative;
}
.dark-mode .co-content { background: var(--dark-mode-bg-color); }

.co-close {
  position: absolute;
  top: 0.8rem; right: 0.8rem;
  width: 2.8rem; height: 2.8rem;
  border: none;
  background: transparent;
  font-size: 2.2rem;
  cursor: pointer;
  color: var(--primary-text-color);
  display: flex;
  align-items: center;
  justify-content: center;
}
.dark-mode .co-close { color: var(--dark-mode-primary-text-color); }

.co-title {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  font-weight: 400;
  margin: 0 0 2rem;
  color: var(--primary-text-color);
}
.dark-mode .co-title { color: var(--dark-mode-primary-text-color); }

/* Form */

.co-form { display: flex; flex-direction: column; gap: 1.2rem; }

.co-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.co-row-3 { grid-template-columns: 1fr 1fr 1fr; }

.co-field { display: flex; flex-direction: column; gap: 0.3rem; }

.co-field label {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--primary-text-color);
}
.dark-mode .co-field label { color: var(--dark-mode-primary-text-color); }

.co-field input,
.co-field select {
  padding: 0.8rem 1rem;
  font-size: 1.4rem;
  border: 1px solid var(--mid-gray-color);
  background: var(--white-color);
  color: var(--primary-text-color);
  font-family: var(--font-sans);
  border-radius: 0;
  width: 100%;
  box-sizing: border-box;
}
.dark-mode .co-field input,
.dark-mode .co-field select {
  background: var(--dark-mode-darker-bg-color);
  border-color: var(--dark-mode-border-color);
  color: var(--dark-mode-primary-text-color);
}

.co-field input:focus,
.co-field select:focus {
  outline: none;
  border-color: var(--primary-color);
}

.co-submit {
  width: 100%;
  padding: 1.2rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--white-color);
  background: var(--primary-color);
  border: none;
  cursor: pointer;
  font-family: var(--font-sans);
  margin-top: 0.8rem;
  transition: opacity 0.2s var(--animation-base);
}
.co-submit:hover { opacity: 0.88; }

/* Loading */

.co-loading { text-align: center; padding: 3rem 0; }
.co-loading .spinner { margin-bottom: 1.5rem; }
.co-loading p { font-size: 1.5rem; color: var(--secondary-text-color); }
.dark-mode .co-loading p { color: var(--dark-mode-secondary-text-color); }

/* Shipping rates */

.co-rates { display: flex; flex-direction: column; gap: 0.8rem; margin-bottom: 1.6rem; }

.co-rate {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.2rem;
  border: 1px solid var(--mid-gray-color);
  cursor: pointer;
  transition: border-color 0.2s var(--animation-base);
}
.dark-mode .co-rate { border-color: var(--dark-mode-border-color); }
.co-rate:hover { border-color: var(--primary-color); }
.co-rate.active { border-color: var(--primary-color); }

.co-rate input[type="radio"] { accent-color: var(--primary-color); }

.co-rate-name { flex: 1; font-size: 1.4rem; font-weight: 600; color: var(--primary-text-color); }
.dark-mode .co-rate-name { color: var(--dark-mode-primary-text-color); }

.co-rate-price { font-size: 1.4rem; font-weight: 700; color: var(--primary-color); }

/* Totals */

.co-totals { border-top: 1px solid var(--mid-gray-color); padding-top: 1.2rem; margin-bottom: 0.8rem; }
.dark-mode .co-totals { border-color: var(--dark-mode-border-color); }

.co-total-row {
  display: flex;
  justify-content: space-between;
  font-size: 1.4rem;
  color: var(--primary-text-color);
  padding: 0.4rem 0;
}
.dark-mode .co-total-row { color: var(--dark-mode-primary-text-color); }

.co-total-final {
  font-size: 1.6rem;
  font-weight: 700;
  border-top: 1px solid var(--mid-gray-color);
  padding-top: 0.8rem;
  margin-top: 0.4rem;
}
.dark-mode .co-total-final { border-color: var(--dark-mode-border-color); }

/* ───── Responsive ───── */

@media (max-width: 768px) {
  .pm-layout { grid-template-columns: 1fr; }
  .pm-gallery { padding: 1.2rem; }
  .pm-details { padding: 1.6rem; }
  .pm-overlay { padding: 1rem; }
  .pm-title { font-size: 2rem; }
  .pm-description { font-size: 1.4rem; }

  .products-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1.2rem; }
  .store-title { font-size: 2.4rem; }
  .product-title { font-size: 1.5rem; }
  .product-price { font-size: 1.4rem; }

  .cart-drawer-panel { width: 100vw; }
  .co-content { padding: 1.6rem; }
  .co-row { grid-template-columns: 1fr; }
  .co-row-3 { grid-template-columns: 1fr; }

  #cart-badge { top: 0; right: 0; }
}

.kg-width-wide {
  max-width: 1040px;
  margin-left: auto;
  margin-right: auto;
}

.kg-width-full {
  max-width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
}
