/* =====================================================================
   PRODUCT PAGES — gravel and ties: product cards and photo viewer
   (loaded only by those pages, after base.css)
   ===================================================================== */

/* ---------- PRODUCTS (gravel, ties) ---------- */
.products-section { padding: 40px var(--gutter) 100px; }

.products {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 30px;
    max-width: 1300px; margin: 0 auto;
}

/* Only one or two products: center them at a sensible width */
.products:has(> .product-card:only-child),
.products:has(> .product-card:nth-child(2):last-child) { grid-template-columns: repeat(auto-fit, minmax(0, 400px)); justify-content: center; }

.products:has(> .product-card:only-child) .product-card { height: 480px; }

.product-card {
    background: var(--card-bg); border-radius: var(--radius); overflow: hidden;
    box-shadow: var(--shadow); position: relative; border: 2px solid var(--primary); height: 420px;
}

.img-box { position: absolute; inset: 0; z-index: 1; cursor: pointer; background: #eaeaea; }

.img-box img { width: 100%; height: 100%; object-fit: cover; transition: 0.5s; display: block; }

.product-card:hover .img-box img { transform: scale(1.04); }

.img-box.no-image { display: flex; align-items: flex-start; justify-content: center; padding-top: 22%; color: #bbb; font-size: 3rem; }

.img-box.no-image img { display: none; }

.card-details {
    position: absolute; bottom: 0; left: 0; width: 100%; padding: 60px 20px 20px;
    display: flex; flex-direction: column; align-items: center; text-align: center;
    z-index: 2; pointer-events: none;
    background: linear-gradient(to top, #ffffff 0%, #ffffff 65%, transparent 100%);
}

.card-details * { pointer-events: auto; }

.card-details h4 { font-size: 1.15rem; font-weight: 600; color: var(--text-dark); margin-bottom: 6px; line-height: 1.3; }

.card-details h5 { font-size: 0.95rem; font-weight: 500; color: #666; margin-bottom: 10px; line-height: 1.35; }

.card-details h5:empty { display: none; }

.price-tag {
    font-size: 1.1rem; font-weight: 700; color: var(--primary);
    background: var(--primary-soft); padding: 6px 14px; border-radius: 6px; display: inline-flex; align-items: center; margin-top: auto;
}

.price { min-width: 25px; display: inline-block; outline: none; }

/* "Call for updated pricing" mode (Control Panel switch) */
.call-price {
    display: none; margin-top: auto; align-items: center; justify-content: center; gap: 6px; text-align: center; line-height: 1.25;
    font-size: 0.98rem; font-weight: 700; color: #fff; background: var(--primary); padding: 7px 14px; border-radius: 6px; text-decoration: none; transition: 0.3s;
}
.call-price:hover { background: var(--primary-dark); }
.call-price i { font-size: 1.1em; }
body.prices-hidden .price-tag { display: none; }
body.prices-hidden .call-price { display: inline-flex; }
.pricing-notice {
    display: none; align-items: center; justify-content: center; gap: 10px; max-width: 900px; margin: 0 auto 30px; padding: 14px 20px;
    border-radius: 12px; background: var(--primary-soft); color: var(--text-dark); font-size: 1.02rem; line-height: 1.5; text-align: center;
}
.pricing-notice i { color: var(--primary); font-size: 1.4rem; flex-shrink: 0; }
.pricing-notice a { color: var(--primary); font-weight: 700; text-decoration: none; white-space: nowrap; }
.pricing-notice .for-editors { display: none; }
body.prices-hidden .pricing-notice { display: flex; }
/* While editing, the real prices show so they can still be updated */
body.editing-active.prices-hidden .price-tag { display: inline-flex; }
body.editing-active.prices-hidden .call-price { display: none; }
body.editing-active .pricing-notice { background: #fff8ec; }
body.editing-active .pricing-notice .for-customers { display: none; }
body.editing-active .pricing-notice .for-editors { display: inline; }

.products-note { display: flex; flex-wrap: wrap; justify-content: center; gap: 15px; margin-top: 45px; }

body.editing-active .card-details h5:empty { display: block; min-width: 60%; }

.delete-card-btn {
    position: absolute; top: 10px; right: 10px; z-index: 4; width: 36px; height: 36px; border-radius: 50%;
    background: #fff; font-size: 19px; box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

body.editing-active .img-box::before {
    content: '📷 Click to change photo'; position: absolute; inset: 0; background: rgba(0,0,0,0.55);
    color: #fff; display: flex; align-items: center; justify-content: center; text-align: center; padding: 10px;
    font-weight: 600; opacity: 0; transition: 0.3s; z-index: 3;
}

body.editing-active .img-box:hover::before { opacity: 1; }

body.editing-active .img-box.no-image::before { opacity: 1; background: rgba(0,0,0,0.35); content: '📷 Click to add a photo'; }

/* ---------- LIGHTBOX ---------- */
.lightbox-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.9); z-index: 3000; align-items: center; justify-content: center; backdrop-filter: blur(5px); padding: 15px; }

.lightbox-overlay.open { display: flex; }

.lightbox-img-wrapper { position: relative; max-width: 90vw; max-height: 90vh; }

.lightbox-img-wrapper img { max-width: 100%; max-height: 85vh; object-fit: contain; border-radius: 12px; box-shadow: 0 15px 50px rgba(0,0,0,0.5); display: block; }

.lightbox-close { position: absolute; top: -44px; right: 0; color: #fff; font-size: 35px; cursor: pointer; transition: 0.3s; background: none; border: none; }

.lightbox-close:hover { color: #f3c9cb; transform: rotate(90deg); }

@media (max-width: 768px) {
    .products-section { padding: 30px var(--gutter) 80px; }
    /* Phones: 2 products per row */
    .products { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
    .products:has(> .product-card:only-child) { grid-template-columns: minmax(0, 420px); }
    .products:has(> .product-card:only-child) .product-card { height: 400px; }
    .product-card { height: 320px; border-radius: 12px; }
    .card-details { padding: 45px 12px 14px; }
    .card-details h4 { font-size: 1rem; margin-bottom: 5px; }
    .card-details h5 { font-size: 0.85rem; margin-bottom: 8px; }
    .price-tag { font-size: 0.95rem; padding: 5px 10px; }
    .call-price { font-size: 0.85rem; padding: 6px 10px; }
    .pricing-notice { font-size: 0.95rem; padding: 12px 14px; margin-bottom: 22px; }
}

@media (max-width: 480px) {
    .products { gap: 10px; }
    .product-card { height: 250px; border-width: 1.5px; border-radius: 10px; }
    .products:has(> .product-card:only-child) .product-card { height: 360px; }
    .card-details { padding: 35px 8px 10px; }
    .card-details h4 { font-size: 0.85rem; line-height: 1.25; margin-bottom: 4px; }
    .card-details h5 { font-size: 0.72rem; margin-bottom: 6px; line-height: 1.25; }
    .price-tag { font-size: 0.8rem; padding: 4px 8px; }
    .call-price { font-size: 0.74rem; padding: 5px 8px; gap: 4px; }
    .delete-card-btn { width: 30px; height: 30px; font-size: 16px; top: 6px; right: 6px; }
}

/* Hero photos (paths are relative to this css/ folder).
   main.jpg is the hero photo; if it's missing, the first product photo shows instead. */
body[data-page="gravel"] .hero { --hero-img: url('../images/gravel/main.jpg'), url('../images/gravel/1.png'); }
body[data-page="ties"] .hero { --hero-img: url('../images/ties_timbers/main.jpg'), url('../images/ties_timbers/1.jpg'); }
