/*
 * assets/css/pages/category.css
 * Styles shared by the three product listing pages: /products (and its /flours and /gift-hampers
 * landings), /rice and /millets.
 *
 * Loaded by:  includes/category/view.php, a <link> placed where the former inline <style> blocks stood
 *             (inside <body>, after includes/header.php and includes/offtag.php), so these rules
 *             still follow site.css in the cascade.
 * Page hooks: main.ia-listing (rice and millets) and main.products-page (products). Rules that apply to
 *             both pages therefore carry both selectors in one selector list.
 * Variants:   category-listing.css (rice and millets only) and category-catalog.css (products only) hold the
 *             few rules that differ between the two page families. They are loaded right after this file.
 * Contents:   product card (quantity buttons, price, cart button, coming soon state, hover), notify modal,
 *             products grid, then the responsive layer (grid columns, phone chips and slider, reduced motion).
 */

/* Card qty buttons */
.card-qty-btn {
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 0.4rem;
    border: 1.5px solid #d1d5db;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    background: white;
    color: #374151;
    transition: all 0.15s;
    flex-shrink: 0;
}
.card-qty-btn:hover:not(:disabled) { border-color: #059669; color: #059669; }
.card-qty-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.card-qty-input {
    width: 2rem;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 700;
    border: none;
    outline: none;
    background: transparent;
}

/* Card price */
.card-price { font-size: 1rem; font-weight: 800; color: #111827; }
.card-price-unit { font-size: 0.7rem; color: #6b7280; }

/* Card action buttons */
.card-action-btn {
    flex: 1;
    padding: 0.45rem 0.5rem;
    border-radius: 0.6rem;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    white-space: nowrap;
}
.card-atc { background: #000; color: #fff; border: none; }
.card-atc:hover { background: #111; }
.card-buy { background: #000; color: #fff; border: none; }
.card-buy:hover { background: #111; }

/* Single cart button (add to cart / go to cart) */
.ia-cart-btn { width: 100%; border: none; text-decoration: none; }
/* .card-action-btn is display:flex, so [hidden] needs !important to win */
.ia-cart-btn[hidden] { display: none !important; }
.ia-add { background: #0f172a; color: #fff; }
.ia-go  { background: #059669; color: #fff; }
.ia-go:hover { background: #047857; }

/* Notify modal */
.notify-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}
.notify-modal.active { display: flex; }

/* Products grid */
#productsGrid::-webkit-scrollbar { display: none; }
#productsGrid {
    scrollbar-width: none;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Delivery badge */
.delivery-badge {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.68rem;
    color: #374151;
    margin-top: 0.25rem;
}
.delivery-badge .delivery-icon {
    color: #059669;
    font-size: 0.65rem;
    flex-shrink: 0;
}

/* Coming soon overlay */
.cs-front-badge {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.28);
    border-radius: inherit;
    z-index: 5;
}
.cs-front-badge__label {
    font-size: 0.75rem;
    font-weight: 900;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: #fff;
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
    white-space: nowrap;
    overflow: hidden;
    width: 0;
    text-align: center;
    animation: cs-typewriter 1.2s steps(12, end) 0.3s forwards;
}
.cs-coming-soon-btn {
    background: #f0fdf4;
    border: 1.5px solid #bbf7d0;
    color: #15803d;
    cursor: not-allowed;
    letter-spacing: 0.06em;
    font-weight: 700;
}

@keyframes cs-typewriter {
    from { width: 0;     opacity: 0.4; }
    to   { width: 140px; opacity: 1; }
}

/* Card image hover (pop-out) */
.card-img-wrap { background: #f3f4f6; }
.card-img-wrap img {
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    will-change: transform;
}
.product-card:hover .card-img-wrap img {
    transform: scale(1.12) translateY(-10px);
    filter: drop-shadow(0 20px 20px rgba(0, 0, 0, 0.18));
}

:root{
  --ia-cream:#f5ede0;--ia-off:#faf7f2;--ia-green:#2f6b3e;--ia-green-dk:#255632;
  --ia-line:rgba(201,168,124,.5);--ia-ease:cubic-bezier(.22,1,.36,1);
}

/* Helpers: hidden until the breakpoint that needs them */
.ia-pp-bar{display:none}
.ia-pp-soon{display:none}

/* Grid: one rule-set for every width (fixes the min-w-[260px] overflow between 768 and 1279 px) */
#productsGrid>.product-card{min-width:0!important}
#productsGrid>.ia-pp-soon{display:flex;order:2;grid-column:1/-1;align-items:center;gap:.75rem;margin:.5rem 0 .25rem;
  font-size:.8rem;font-weight:800;letter-spacing:.08em;text-transform:uppercase;color:#6b5a48}
#productsGrid>.ia-pp-soon::before,#productsGrid>.ia-pp-soon::after{content:"";flex:1;height:1px;background:var(--ia-line)}
/* buyable products first, out-of-stock next, coming-soon last */
#productsGrid>.product-card[data-stock="0"]{order:1}
#productsGrid>.product-card[data-coming-soon="1"]{order:3}

@media (min-width:768px) and (max-width:1023px){
  #productsGrid{grid-template-columns:repeat(3,minmax(0,1fr))!important;overflow:visible!important}
  #productsGrid>.product-card{width:auto!important}
}
@media (min-width:1024px){
  #productsGrid{grid-template-columns:repeat(4,minmax(0,1fr))!important}
  #productsGrid>.product-card{width:auto!important}
}

/* Hero: left text block + right promo no longer push the page wider than the screen (768-1279) */
.ia-listing,.products-page{overflow-x:clip}
@media (min-width:768px) and (max-width:1279px){
  .ia-listing>section:nth-of-type(1) .flex-shrink-0,.products-page>section:nth-of-type(1) .flex-shrink-0{flex-shrink:1!important;min-width:0}
  .ia-listing>section:nth-of-type(1) h2,.products-page>section:nth-of-type(1) h2{font-size:1.5rem!important}
}

/* Card internals: nothing can overflow the card, at any width */
.ia-qty{min-width:0}
.ia-qty .card-qty-input{min-width:0}
.ia-qty .card-qty-minus,.ia-qty .card-qty-plus{flex:0 0 auto;min-width:2rem;height:100%;font-size:1rem;display:flex;align-items:center;justify-content:center}
.ia-qty .card-qty-minus:disabled,.ia-qty .card-qty-plus:disabled{opacity:.35;cursor:not-allowed}
.product-card .pack-dropdown{min-width:0;text-overflow:ellipsis}
.product-card h2{overflow-wrap:anywhere}
.product-card .wishlist-btn{width:2.5rem;height:2.5rem}
.ia-price-row>div{min-width:0}
.ia-price-row .card-price{display:flex;flex-wrap:wrap;align-items:baseline;gap:.1rem .4rem}
.ia-price-row .card-price>.line-through{order:2}
.ia-price-row .card-price>.text-emerald-600{order:3;background:#ecfdf5;border-radius:999px;padding:.05rem .45rem;font-size:.65rem;line-height:1.5}
.ia-price-row .card-price-unit{display:block;flex-basis:100%;margin-top:.1rem}
.product-card{-webkit-tap-highlight-color:transparent}

/* Touch devices: 44px targets, no sticky hover */
@media (pointer:coarse){
  .product-card .card-action-btn,.product-card .notify-me-btn,.product-card .cs-coming-soon-btn{min-height:2.75rem}
  .product-card .ia-pack-row>*{height:2.5rem}
}
@media (hover:none){
  .product-card:hover .card-img-wrap img{transform:none;filter:none}
  .product-card:hover{transform:none;box-shadow:none}
}

/* Focus + press feedback */
.ia-listing a:focus-visible,.products-page a:focus-visible,.ia-listing button:focus-visible,.products-page button:focus-visible,.ia-listing select:focus-visible,.products-page select:focus-visible{outline:2px solid var(--ia-green);outline-offset:2px}
.product-card .card-action-btn{transition:transform .15s var(--ia-ease),background-color .2s ease,color .2s ease}
.product-card .card-action-btn:active:not(:disabled){transform:scale(.97)}

/* Motion: reveal (classes added by JS only, so no-JS = fully visible) */
@keyframes iaUp{from{opacity:0;transform:translateY(18px)}to{opacity:1;transform:none}}
.ia-rv:not(.in){opacity:0}
.ia-rv.in{animation:iaUp .6s var(--ia-ease) var(--ia-d,0s) backwards}
#productsGrid{transition:opacity .2s ease}
#productsGrid.ia-busy{opacity:.45;pointer-events:none}
@media (prefers-reduced-motion:reduce){
  .ia-rv:not(.in){opacity:1}
  .ia-rv.in{animation:none}
  #productsGrid{transition:none}
  .banner-slide{animation:none!important}
  .banner-slide:first-child{opacity:1}
}

/* Notify modal: never taller than the screen (landscape phones) */
#notifyModalInner{max-height:calc(100vh - 2rem);max-height:calc(100dvh - 2rem);overflow-y:auto}

/* Phones + small tablets  (<= 767px) */
@media (max-width:767px){
  .ia-listing,.products-page{background:var(--ia-off)}

  /* hero: short, title plus one line. Filters move into the chip bar below */
  .ia-listing>section:nth-of-type(1),.products-page>section:nth-of-type(1){min-height:0!important;padding-bottom:1.25rem!important}
  .ia-listing>section:nth-of-type(1) h1,.products-page>section:nth-of-type(1) h1{font-family:'Playfair Display',serif;font-weight:900;font-size:1.75rem!important;line-height:1.2;margin-bottom:.35rem!important}
  .ia-listing>section:nth-of-type(1) p,.products-page>section:nth-of-type(1) p{font-size:.875rem;margin-bottom:0!important}
  .ia-listing .custom-select-wrap,.products-page .custom-select-wrap,#activeFilters{display:none!important}

  .ia-listing>section:nth-of-type(2),.products-page>section:nth-of-type(2){padding:1rem .75rem 2rem!important}

  /* category chips + offer + count */
  .ia-pp-bar{display:block;margin-bottom:.75rem}
  .ia-pp-chips{display:flex;gap:.5rem;overflow-x:auto;scroll-snap-type:x proximity;scroll-padding:0 .75rem;margin:0 -.75rem;padding:.25rem .75rem;
    scrollbar-width:none;-webkit-overflow-scrolling:touch}
  .ia-pp-chips::-webkit-scrollbar{display:none}
  .ia-pp-chip{flex:0 0 auto;scroll-snap-align:start;display:inline-flex;align-items:center;justify-content:center;min-height:2.75rem;padding:0 1.1rem;
    border-radius:999px;border:1.5px solid var(--ia-line);background:#fff;color:#1a0a00;font-size:.875rem;font-weight:700;text-decoration:none;
    white-space:nowrap;transition:background-color .2s ease,color .2s ease,border-color .2s ease,transform .15s var(--ia-ease)}
  .ia-pp-chip:active{transform:scale(.97)}
  .ia-pp-chip.is-active{background:var(--ia-green);border-color:var(--ia-green);color:#fff}
  .ia-pp-offer{display:flex;align-items:center;justify-content:space-between;gap:.75rem;margin-top:.5rem;padding:.65rem .85rem;
    background:var(--ia-cream);border:1px solid var(--ia-line);border-radius:1rem}
  .ia-pp-offer-txt{font-size:.8rem;line-height:1.35;color:#3d1f0a;min-width:0}
  .ia-pp-offer-txt strong{color:var(--ia-green);font-weight:800}
  .ia-pp-offer-txt small{display:block;font-size:.72rem;color:#6b5a48}
  .ia-pp-code{flex:0 0 auto;display:inline-flex;align-items:center;gap:.4rem;min-height:2.5rem;padding:0 .8rem;border-radius:.75rem;
    border:1.5px dashed var(--ia-green);background:#fff;color:var(--ia-green);font-size:.8rem;font-weight:800;letter-spacing:.04em;cursor:pointer}
  .ia-pp-code.is-done{background:var(--ia-green);color:#fff;border-style:solid}
  .ia-pp-count{margin:.6rem .15rem 0;font-size:.78rem;color:#6b5a48}

  /* grid: no horizontal scroller on phones, everything is visible and tappable */
  #productsGrid{display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr));gap:.75rem;overflow:visible!important;
    padding:0!important;scroll-snap-type:none}
  #productsGrid>.product-card{width:auto!important;margin:0!important}
  .ia-listing .bg-gradient-to-l.pointer-events-none,.products-page .bg-gradient-to-l.pointer-events-none{display:none}

  /* card body */
  #productsGrid .product-card>div:nth-child(2){padding:.75rem!important;gap:.6rem!important}
  #productsGrid .product-card h2{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;
    font-size:.9rem;line-height:1.3;min-height:2.6em}
  #productsGrid .ia-pack-row{flex-direction:column;gap:.5rem;margin-top:0}
  #productsGrid .ia-pack-row>*{width:100%;flex:none;min-width:0;height:2.5rem}
  #productsGrid .pack-dropdown{font-size:16px}  /* iOS zooms the page on focus when < 16px */
  #productsGrid .ia-qty{padding:0 .25rem}
  #productsGrid .ia-qty .card-qty-minus,#productsGrid .ia-qty .card-qty-plus{flex:0 0 2.5rem;min-width:2.5rem;font-size:1.1rem}
  #productsGrid .ia-qty .card-qty-input{flex:1 1 auto;width:auto;font-size:.9rem}
  #productsGrid .ia-price-row{margin-top:0}
  #productsGrid .ia-price-row>div{width:100%}
  #productsGrid .card-price-unit{font-size:.7rem;line-height:1.3}
  /* buttons always sit at the bottom of the card, so Add / Buy Now line up across a row */
  #productsGrid .ia-btn-row{flex-direction:column;gap:.5rem;margin-top:auto}
  #productsGrid .card-action-btn{flex:none;width:100%;padding:.55rem .5rem;font-size:.8rem;min-height:2.75rem}
  #productsGrid .card-atc{background:#fff;color:#111;border:1.5px solid #111}
  #productsGrid .card-buy{background:var(--ia-green);color:#fff}
  #productsGrid .card-buy:active{background:var(--ia-green-dk)}
  #productsGrid .delivery-badge{font-size:.68rem;line-height:1.35;align-items:flex-start;margin-top:0;min-height:2.7em}
  #productsGrid .delivery-badge .delivery-icon{margin-top:.15rem}
  #productsGrid .notify-me-btn,#productsGrid .cs-coming-soon-btn{min-height:2.75rem;font-size:.8rem}

  /* disabled cards: do not show dead controls, only image, name and one clear state */
  #productsGrid .product-card[data-stock="0"] .ia-pack-row,
  #productsGrid .product-card[data-coming-soon="1"] .ia-pack-row,
  #productsGrid .product-card[data-coming-soon="1"] .ia-price-row{display:none}
  #productsGrid .product-card[data-stock="0"]>div:nth-child(2),
  #productsGrid .product-card[data-coming-soon="1"]>div:nth-child(2){gap:.5rem!important}
  #productsGrid .product-card h2{margin-bottom:0}
  /* "About these products" copy is hidden on phones */
  .ia-pp-about{display:none}
}
@media (max-width:639px){
  #productsGrid{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media (max-width:359px){
  #productsGrid{gap:.5rem}
  #productsGrid .ia-qty .card-qty-minus,#productsGrid .ia-qty .card-qty-plus{flex-basis:2.25rem;min-width:2.25rem}
  #productsGrid .product-card>div:nth-child(2){padding:.6rem!important}
  #productsGrid .product-card h2{font-size:.85rem}
}
@media (max-width:299px){
  #productsGrid{grid-template-columns:minmax(0,1fr)}
}
@media (min-width:768px){.ia-pp-bar{display:none!important}}
/* Phone product slider (up to 639px): one full-width card per screen, swipe for the next. Delete this block to fall back to the 2-column grid. */
.ia-sl-nav{display:none}
@media (max-width:639px){
  #productsGrid{display:flex!important;flex-wrap:nowrap!important;gap:.75rem!important;overflow-x:auto!important;overflow-y:hidden!important;
    scroll-snap-type:x mandatory!important;scroll-behavior:smooth;overscroll-behavior-x:contain;-webkit-overflow-scrolling:touch;
    scrollbar-width:none;-ms-overflow-style:none;padding:0!important;margin:0}
  #productsGrid::-webkit-scrollbar{display:none}
  #productsGrid>.product-card,#productsGrid>.product-card:nth-child(n+5){display:flex!important;flex:0 0 100%!important;width:100%!important;max-width:100%;
    min-width:0!important;margin:0!important;scroll-snap-align:start;scroll-snap-stop:always}
  #productsGrid>.ia-pp-soon{display:none!important}

  /* card: wide image (short enough that price + buttons stay on the first screen), controls side by side */
  #productsGrid .card-img-wrap{aspect-ratio:5/4!important}
  #productsGrid .product-card>div:nth-child(2){padding:1rem!important;gap:.75rem!important;min-height:0!important}
  #productsGrid .product-card h2{font-size:1.05rem;line-height:1.3;min-height:0;-webkit-line-clamp:2}
  #productsGrid .ia-pack-row{flex-direction:row!important;gap:.6rem;margin-top:0}
  #productsGrid .ia-pack-row>*{flex:1 1 0!important;width:auto!important;min-width:0;height:2.75rem}
  #productsGrid .ia-qty .card-qty-minus,#productsGrid .ia-qty .card-qty-plus{flex:0 0 2.5rem;min-width:2.5rem}
  #productsGrid .ia-price-row .card-price{font-size:1.4rem;line-height:1.2}
  #productsGrid .ia-price-row .card-price-unit{font-size:.78rem}
  #productsGrid .ia-btn-row{flex-direction:row!important;gap:.6rem;margin-top:auto}
  #productsGrid .card-action-btn{flex:1 1 0!important;width:auto!important;min-height:2.9rem;font-size:.9rem}
  #productsGrid .delivery-badge{min-height:0;font-size:.75rem}
  #productsGrid .product-card .wishlist-btn{top:.6rem;right:.6rem}

  /* slider controls */
  .ia-sl-nav{display:flex;align-items:center;justify-content:center;gap:.75rem;margin-top:.875rem}
  .ia-sl-nav.is-off{display:none}
  .ia-sl-btn{flex:0 0 auto;width:2.75rem;height:2.75rem;border-radius:999px;border:1.5px solid var(--ia-line,rgba(201,168,124,.5));background:#fff;color:#1a0a00;
    display:inline-flex;align-items:center;justify-content:center;font-size:.9rem;cursor:pointer;-webkit-tap-highlight-color:transparent;
    transition:transform .15s ease,opacity .2s ease,background-color .2s ease}
  .ia-sl-btn:active:not(:disabled){transform:scale(.92)}
  .ia-sl-btn:disabled{opacity:.35;cursor:default}
  .ia-sl-btn:focus-visible{outline:2px solid var(--ia-green,#2f6b3e);outline-offset:2px}
  .ia-sl-mid{flex:1 1 auto;max-width:11rem;text-align:center}
  .ia-sl-count{font-size:.85rem;font-weight:800;color:#3d1f0a;font-variant-numeric:tabular-nums}
  .ia-sl-bar{height:3px;margin-top:.4rem;border-radius:999px;background:var(--ia-line,rgba(201,168,124,.5));overflow:hidden}
  .ia-sl-bar>i{display:block;height:100%;width:0;border-radius:999px;background:var(--ia-green,#2f6b3e);transition:width .25s ease}
}
@media (prefers-reduced-motion:reduce){
  #productsGrid{scroll-behavior:auto}
  .ia-sl-bar>i,.ia-sl-btn{transition:none}
}
