
/* =======================
   NEW GRGY TIMES — Base CSS
   Cleaned & consolidated
   ======================= */

/* --- CSS Variables --- */
:root {
  --color-background: #ffffff;
  --color-border: #e5e5e5;
  --color-text: #111111;
  --color-text-muted: #4d4d4d;
  --color-footer-border: #dddddd;
  --font-base: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

/* --- Reset / Base --- */
*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-base);
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-text);
  background-color: var(--color-background);
}
body.modal-open { overflow: hidden; }

a { color: inherit; text-decoration: none; }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
}

/* --- Header --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--color-background);
  border-bottom: 1px solid var(--color-border);
}

.header-inner {
  display: grid;
  align-items: center;
  justify-items: center;
  gap: 16px;
  position: relative;
  min-height: 60px;
}

.brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: center;
}

.brand-logo {
  display: block;
  width: 120px;
  height: auto;
  max-height: 48px;
}

.brand-text { display: none; }

.cart-icon {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
}
.cart-icon:focus {
  outline: 2px solid var(--color-text);
  outline-offset: 2px;
}
.cart-icon-img { width: 28px; height: 28px; object-fit: contain; }

.cart-count {
  position: absolute;
  top: -6px;
  right: -10px;
  background: #000;
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  line-height: 1;
  padding: 3px 6px;
  min-width: 18px;
  text-align: center;
}
.cart-count.hidden { display: none; }

/* --- Product grid --- */
.product-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, 1fr);
  padding-top: 32px;
  padding-bottom: 64px;
}
@media (min-width: 768px) { .product-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1280px) {
  .product-grid { grid-template-columns: repeat(5, 1fr); gap: 24px; }
}

.product-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
}
.card-img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 360px;
  object-fit: contain;
  image-rendering: auto;
}

[data-item-id].soldout {
  position: relative;
}
[data-item-id].soldout .card-img {
  filter: grayscale(1) brightness(.75);
}
.product-title { margin: 0; font-size: 16px; font-weight: 600; }
.product-sku    { margin: 0; color: var(--color-text-muted); font-size: 14px; }
.product-price  { margin: 0; color: var(--color-text-muted); font-size: 15px; }
.product-price--soldout { color: rgba(17, 17, 17, 0.45); }

/* --- Cart popup --- */
.cart-popup.hidden { display: none; }
.cart-popup {
  position: absolute;
  top: 60px;
  right: 16px;
  background: #fff;
  border: 1px solid #ddd;
  padding: 16px;
  font-size: 14px;
  min-width: 200px;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
}
.cart-popup.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.cart-items {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 50vh;
  overflow: auto;
}

/* --- Cart item (2 rows on the right: total above, remove below) --- */
.cart-item {
  display: grid;
  grid-template-columns: 32px 1fr auto; /* image | body | right column */
  grid-auto-rows: auto;
  gap: 8px;
  align-items: center;
}
.cart-item > img { width: 32px; height: 32px; object-fit: cover; grid-row: 1 / span 2; }

.cart-item-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  grid-column: 2;
  grid-row: 1 / span 2;
}
.cart-item .title { font-size: 14px; margin: 0; }
.cart-item .price { margin: 0; font-size: 13px; color: var(--color-text-muted); }

.cart-item .controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.cart-item .controls button {
  width: 28px;
  height: 28px;
  border: 1px solid #ddd;
  background: #fff;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.cart-item .controls input {
  width: 40px;
  text-align: center;
  border: 1px solid #ddd;
  padding: 4px;
}

.cart-item-total {
  grid-column: 3;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  font-size: 14px;
}
.cart-item-total .line-total { font-weight: 600; }

.remove-btn {
  grid-column: 3;
  grid-row: 2;
  justify-self: end;
  background: none;
  border: none;
  padding: 4px 8px;
  cursor: pointer;
  text-decoration: underline;
  color: #333;
}
.remove-btn:hover { opacity: .8; }

/* --- Cart summary & actions --- */
.cart-summary {
  border-top: 1px solid #eee;
  margin-top: 8px;
  padding-top: 8px;
  display: flex;
  justify-content: space-between;
  font-size: 14px;
}

.cart-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.cart-actions button {
  flex: 1;
  padding: 8px;
  border: 1px solid #000;
  background: #000;
  color: #fff;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 13px;
}
.cart-actions button[disabled] { opacity: .5; cursor: not-allowed; }
.cart-actions button.secondary { background: #fff; color: #000; }

/* --- Qty controls in modal --- */
.qty-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.qty-btn {
  width: 32px;
  height: 32px;
  border: 1px solid #000;
  background: #fff;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.qty-input {
  width: 56px;
  text-align: center;
  border: 1px solid #ddd;
  padding: 6px 4px;
  font-size: 16px;
}

/* --- Cart form --- */
.cart-form { display: grid; gap: 8px; margin-top: 8px; }
.cart-form .row { display: grid; gap: 6px; }
.cart-form label { font-size: 12px; color: #555; }
.cart-form input[type="text"],
.cart-form input[type="tel"],
.cart-form input[type="email"],
.cart-form textarea {
  border: 1px solid #ddd;
  padding: 8px;
  font-size: 14px;
  width: 100%;
}
.cart-form input::placeholder,
.cart-form textarea::placeholder { color: #999; }
.cart-form textarea { resize: vertical; }

.delivery-info {
  font-size: 12px;
  color: #555;
  background: #f7f7f7;
  border: 1px solid #eee;
  padding: 8px;
  margin-top: 8px;
}

.consent-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 13px;
  cursor: pointer;
}
.consent-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-width: 16px;
  appearance: auto;
  -webkit-appearance: checkbox;
  accent-color: #000;
  cursor: pointer;
}
.consent-row label { line-height: 1.3; user-select: none; }
.consent-row a { color: #000; text-decoration: underline; }

.input-error { border-color: #e63946 !important; }

/* --- Toast --- */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.95);
  color: #000;
  padding: 16px 28px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease-in-out;
}
.toast.show { opacity: 1; pointer-events: auto; }


/* --- Page content --- */
.page-content { padding: 32px 16px; min-height: 60vh; }
.page-content h1 {
  font-size: 24px;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.page-content p { line-height: 1.6; font-size: 15px; }
.page-content a { color: #000; text-decoration: underline; }

.section-block { padding: 24px 16px; }
.section-block h2 {
  font-size: 18px;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* --- Footer --- */
.site-footer {
  border-top: 1px solid var(--color-footer-border);
  background-color: var(--color-background);
  padding: 0;
  margin-top: 32px;
  text-align: center;
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 0;
  border-top: 1px solid #eee;
  justify-content: center;
  border-bottom: 1px solid #eee;
}
.footer-links a { font-size: 13px; color: var(--color-text-muted); }
.footer-links a:hover,
.footer-links a:focus { color: var(--color-text); }

.copyright {
  padding: 12px 0;
  color: #666;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
}

/* --- Modal --- */
.modal.hidden { display: none; }
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}
.modal-content {
  background: #fff;
  padding: 24px;
  max-width: 400px;
  width: 90%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-image {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 80vh;
  object-fit: contain;
  margin: 0 auto;
}
.modal-title { margin: 0; font-size: 20px; }
.modal-description { margin: 0; color: var(--color-text-muted); font-size: 15px; }
.modal-price { margin: 0; font-weight: 600; font-size: 16px; }
.modal-content button {
  margin-top: 16px;
  width: 100%;
  padding: 8px;
  background: #000;
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.modal-image-wrapper {
  /* Place arrows left/right of the image without overlay */
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  column-gap: 12px;
  width: 100%;
}
/* Ensure the image stays centered in the middle column */
.modal-image-wrapper .modal-image {
  grid-column: 2;
  justify-self: center;
}
.modal-slide-btn {
  /* Static placement so buttons don’t overlay the image */
  position: static;
  transform: none;
  width: 36px;
  height: 36px;
  border: 1px solid #ddd;
  border-radius: 50%;
  background: #fff; /* white background as requested */
  color: #000;
  font-size: 0; /* hide any inner text; use pseudo elements for arrows */
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background-color .2s ease, border-color .2s ease, color .2s ease;
}
.modal-slide-btn:hover { background: #f7f7f7; border-color: #ccc; }
.modal-slide-btn.prev { grid-column: 1; }
.modal-slide-btn.next { grid-column: 3; }
.modal-close { background: transparent; color: var(--color-text); border: 1px solid var(--color-border); }

/* --- Inventory Spinner --- */
body.inventory-busy { cursor: progress; }

#inventory-spinner {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.25);
  backdrop-filter: blur(2px);
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s ease;
  z-index: 9999;
}
body.inventory-busy #inventory-spinner {
  opacity: 1;
  pointer-events: auto;
}
#inventory-spinner .box {
  padding: 18px 26px;
  border-radius: 12px;
  background: rgba(0,0,0,.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
}
#inventory-spinner .spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  animation: ngt-spin 1s linear infinite;
}
#inventory-spinner .label {
  color: #fff;
  font-size: 14px;
  line-height: 1.4;
  text-align: center;
}

@keyframes ngt-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* --- Fix: Standard image navigation arrows --- */
.modal-image-wrapper {
  display: inline-block; /* shrink to image width */
  width: auto;           /* override earlier width:100% */
  position: relative;    /* anchor for absolute buttons */
  overflow: visible;
}
.modal-image-wrapper .modal-image { display: block; }

/* Override generic .modal-content button styles for arrow buttons */
.modal-content .modal-slide-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid #ddd;
  background: #fff;
  color: #000;
  aspect-ratio: 1 / 1; /* keep perfect circle */
}

/* Position arrows centered inside the image area */
.modal-image-wrapper .modal-slide-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
}
.modal-image-wrapper .modal-slide-btn.prev { left: 8px; }
.modal-image-wrapper .modal-slide-btn.next { right: 8px; }
