/* =============================================================================
   Grazing Products Grid — gp-grid.css
   ============================================================================= */

/* ── CSS Custom Properties ──────────────────────────────────────────────────── */
:root {
  --gp-accent:        #2d7a4f;      /* teal-green for prices / accents        */
  --gp-btn-bg:        #1e5c3a;      /* dark green CTA button                  */
  --gp-btn-hover:     #174d30;
  --gp-card-bg:       #ffffff;
  --gp-card-radius:   14px;
  --gp-card-shadow:   0 2px 12px rgba(0, 0, 0, .08);
  --gp-card-gap:      20px;
  --gp-modal-radius:  16px;
  --gp-overlay-bg:    rgba(0, 0, 0, .55);
  --gp-font-base:     inherit;
  --gp-transition:    .25s ease;
}

/* ── Wrapper ────────────────────────────────────────────────────────────────── */
.gp-wrapper {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  box-sizing: border-box;
}

/* ── Category Section ───────────────────────────────────────────────────────── */
.gp-category-section {
  margin-bottom: 48px;
}

.gp-category-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0 0 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid #f0f0f0;
}

/* ── Grid ───────────────────────────────────────────────────────────────────── */
.gp-grid {
  display: grid;
  gap: var(--gp-card-gap);
}

/* Column variants */
.gp-cols-1 { grid-template-columns: 1fr; }
.gp-cols-2 { grid-template-columns: repeat(2, 1fr); }
.gp-cols-3 { grid-template-columns: repeat(3, 1fr); }
.gp-cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px) {
  .gp-cols-3,
  .gp-cols-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .gp-cols-2,
  .gp-cols-3,
  .gp-cols-4 { grid-template-columns: 1fr; }
}

/* ── Card ───────────────────────────────────────────────────────────────────── */
.gp-card {
  background: var(--gp-card-bg);
  border-radius: var(--gp-card-radius);
  box-shadow: var(--gp-card-shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0px 0px 0px 20px;
  cursor: pointer;
  transition: box-shadow var(--gp-transition), transform var(--gp-transition);
  outline: none;
  border: 1px solid #f0f0f0;
  gap: 12px;
}

.gp-card:hover,
.gp-card:focus-visible {
  box-shadow: 0 6px 24px rgba(0, 0, 0, .13);
  transform: translateY(-2px);
}

.gp-card:focus-visible {
  outline: 3px solid var(--gp-accent);
  outline-offset: 2px;
}

/* Left side — text */
.gp-card__info {
  flex: 1;
  min-width: 0;
}

.gp-card__name {
  font-size: .95rem;
  font-weight: 600;
  color: #1a1a1a;
  margin: 0 0 10px;
  line-height: 1.35;
  word-break: break-word;
}

.gp-card__price {
  font-size: .95rem;
  font-weight: 600;
  color: var(--gp-accent);
  margin: 0;
}

/* Right side — image + plus button */
.gp-card__image-wrap {
  position: relative;
  flex-shrink: 0;
  width: 110px;
  height: 90px;
  border-radius: 0px 10px 10px 0px;
  overflow: hidden;
  background: #f5f5f5;
}

.gp-card__image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gp-card__no-image {
  width: 100%;
  height: 100%;
  background: #e8e8e8;
}

/* + button — bottom-right corner of image */
.gp-card__plus {
  position: absolute;
  bottom: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #ffffff;
  border: 1.5px solid #e0e0e0;
  color: #555;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--gp-transition), color var(--gp-transition);
  box-shadow: 0 1px 4px rgba(0,0,0,.12);
}

.gp-card__plus:hover {
  background: var(--gp-accent);
  color: #fff;
  border-color: var(--gp-accent);
}

/* ── No-results message ─────────────────────────────────────────────────────── */
.gp-no-results {
  text-align: center;
  color: #888;
  padding: 32px 0;
}

/* ── Prevent body scroll when modal is open ─────────────────────────────────── */
body.gp-modal-open {
  overflow: hidden;
}

/* ── Modal ──────────────────────────────────────────────────────────────────── */
.gp-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  /* hidden state */
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--gp-transition);
}

/* hidden attribute → keep display:flex but invisible */
.gp-modal[hidden] {
  display: flex !important;   /* override browser default for [hidden] */
  opacity: 0;
  pointer-events: none;
}

.gp-modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

.gp-modal.is-closing {
  opacity: 0;
  pointer-events: none;
}

/* Overlay */
.gp-modal__overlay {
  position: absolute;
  inset: 0;
  background: var(--gp-overlay-bg);
  cursor: pointer;
}

/* Box — flex column so footer sticks to bottom */
.gp-modal__box {
  position: relative;
  background: #ffffff;
  border-radius: var(--gp-modal-radius);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow: hidden;            /* clip children, scroll handled by inner div */
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 48px rgba(0, 0, 0, .25);
  transform: translateY(20px) scale(.97);
  transition: transform var(--gp-transition);
  z-index: 1;
}

/* Scrollable inner area */
.gp-modal__scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #ccc transparent;
}

.gp-modal.is-open .gp-modal__box {
  transform: translateY(0) scale(1);
}

.gp-modal.is-closing .gp-modal__box {
  transform: translateY(20px) scale(.97);
}

/* Close × button */
.gp-modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f0f0f0;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: #444;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--gp-transition), color var(--gp-transition);
  z-index: 2;
  line-height: 1;
}

.gp-modal__close:hover {
  background: #e0e0e0;
  color: #111;
}

.gp-modal__close:focus-visible {
  outline: 3px solid var(--gp-accent);
  outline-offset: 2px;
}

/* Hero image */
.gp-modal__image {
  width: 100%;
  border-radius: var(--gp-modal-radius) var(--gp-modal-radius) 0 0;
  overflow: hidden;
  background: #f5f5f5;
}

.gp-modal__image img {
  width: 100%;
  height: 260px;
  object-fit: cover;
  display: block;
}

/* Body content */
.gp-modal__body {
  padding: 22px 24px 22px;
}

.gp-modal__title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0 0 6px;
  line-height: 1.3;
  padding-right: 36px; /* space for close button if no image */
}

.gp-modal__price {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0 0 16px;
}

/* Meta rows */
.gp-modal__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin-bottom: 10px;
  font-size: .875rem;
  color: #444;
  line-height: 1.5;
}

.gp-modal__meta-label {
  font-weight: 700;
  color: #1a1a1a;
  text-transform: uppercase;
  font-size: .78rem;
  letter-spacing: .04em;
  display: block;
  margin-bottom: 2px;
}

.gp-modal__meta .gp-modal__meta-label {
  display: inline;
  margin-bottom: 0;
}

.gp-modal__meta-value {
  color: #555;
}

/* Ingredients block */
.gp-modal__ingredients {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #f0f0f0;
  font-size: .875rem;
  color: #444;
  line-height: 1.6;
}

.gp-modal__ingredients .gp-modal__meta-label {
  margin-bottom: 6px;
}

.gp-modal__ingredients-content p {
  margin: 0 0 6px;
}

/* Footer — fixed sticky bar at bottom of modal box */
.gp-modal__footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: #ffffff;
  border-top: 1px solid #f0f0f0;
  border-radius: 0 0 var(--gp-modal-radius) var(--gp-modal-radius);
}

.gp-modal__btn {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  background: var(--gp-btn-bg);
  color: #ffffff !important;
  font-size: 1rem;
  font-weight: 600;
  padding: 14px 24px;
  border-radius: 50px;
  text-decoration: none;
  transition: background var(--gp-transition);
  flex: 1;
  width: 100%;
}

.gp-modal__btn:hover,
.gp-modal__btn:focus-visible {
  background: var(--gp-btn-hover);
  color: #ffffff !important;
  text-decoration: none;
}

.gp-modal__btn:focus-visible {
  outline: 3px solid var(--gp-accent);
  outline-offset: 2px;
}

.gp-modal__btn-price {
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
}

/* ── Scrollbar styling (webkit) ─────────────────────────────────────────────── */
.gp-modal__scroll::-webkit-scrollbar {
  width: 6px;
}
.gp-modal__scroll::-webkit-scrollbar-track {
  background: transparent;
}
.gp-modal__scroll::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

/* ── Accessibility: reduced-motion ──────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .gp-card,
  .gp-modal,
  .gp-modal__box,
  .gp-modal__close,
  .gp-card__plus,
  .gp-modal__btn {
    transition: none !important;
    transform: none !important;
  }
}
