/* ==========================================================
   CATALOGO A GRIGLIA (retail, pubblico, grossisti)
   Card prodotto, bottoni e chip arrivano da main.css (r-*):
   qui solo l'impaginazione propria della pagina.
   ========================================================== */

.cg-page {
    padding-top: clamp(1rem, 2.5vw, 1.75rem);
}

.cg-crumbs {
    margin-bottom: clamp(1rem, 2.5vw, 1.5rem);
}

/* ---------- Intestazione della collezione (fascia scura) ---------- */
.cg-hero {
    position: relative;
    overflow: hidden;
    background: var(--ink);
    color: var(--paper);
    border-radius: clamp(22px, 3vw, 32px);
    padding: clamp(2rem, 5vw, 3.5rem) clamp(1.5rem, 5vw, 3.5rem);
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: center;
    gap: clamp(1.5rem, 4vw, 3rem);
    min-height: clamp(180px, 22vw, 260px);
}

.cg-hero--cover {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    padding-right: clamp(1.5rem, 3vw, 2rem);
}

.cg-hero__text {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 38rem;
}

/* Su fondo scuro l'oro pieno e' leggibile (contrasto > 6:1) */
.cg-hero__eyebrow {
    color: var(--gold);
}

.cg-hero h1 {
    color: #fff;
    font-size: clamp(2.1rem, 5vw, 3.5rem);
    font-weight: 400;
    line-height: 1.05;
}

.cg-hero p {
    color: #C9D2C6;
    font-size: clamp(1rem, 1.5vw, 1.1rem);
    line-height: 1.65;
}

.cg-hero__media {
    position: relative;
    z-index: 1;
    aspect-ratio: 16 / 10;
    border-radius: 20px;
}

/* Senza copertina: logo in filigrana a destra, solo decorativo */
.cg-hero__wm {
    position: absolute;
    right: clamp(-60px, -3vw, -20px);
    top: 50%;
    transform: translateY(-50%);
    width: clamp(180px, 26vw, 320px);
    height: auto;
    opacity: 0.05;
    pointer-events: none;
}

.cg-hero__thread {
    position: absolute;
    right: 0;
    bottom: 0.75rem;
    width: 55%;
    height: 90px;
    pointer-events: none;
}

.cg-hero__thread path {
    fill: none;
    stroke: var(--gold);
    stroke-width: 1.5;
    opacity: 0.55;
    vector-effect: non-scaling-stroke;
}

.cg-hero--cover .cg-hero__thread { display: none; }

/* ---------- Barra strumenti ---------- */
.cg-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem 1.5rem;
    padding: clamp(1.5rem, 3vw, 2rem) 0 0.75rem;
}

.cg-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    min-width: 0;
}

.cg-chips .r-chip { white-space: nowrap; }

.cg-tools {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
    flex-shrink: 0;
}

.cg-search {
    position: relative;
    display: flex;
    align-items: center;
}

.cg-search > .r-icon {
    position: absolute;
    left: 14px;
    width: 18px;
    height: 18px;
    color: var(--moss);
    pointer-events: none;
}

.cg-search input[type="search"] {
    width: clamp(200px, 22vw, 280px);
    height: 44px;
    padding: 0 3rem 0 2.6rem;
    border-radius: var(--radius-pill);
    font-size: 0.9rem;
}

.cg-search input[type="search"]::-webkit-search-cancel-button { display: none; }

.cg-search__go {
    position: absolute;
    right: 4px;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: var(--radius-pill);
    background: var(--ink);
    color: var(--paper);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.cg-search__go:hover { background: var(--forest); }
.cg-search__go .r-icon { width: 17px; height: 17px; }

.cg-sort {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cg-sort label {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--moss);
    white-space: nowrap;
}

.cg-sort select {
    -webkit-appearance: none;
    appearance: none;
    height: 44px;
    padding: 0 2.4rem 0 1rem;
    border-radius: var(--radius-pill);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    max-width: 220px;
}

.cg-sort > .r-icon {
    position: absolute;
    right: 12px;
    width: 18px;
    height: 18px;
    pointer-events: none;
}

.cg-results {
    font-size: 0.875rem;
    color: var(--moss);
    padding-bottom: clamp(1rem, 2vw, 1.5rem);
    border-bottom: 1px solid var(--line);
    margin-bottom: clamp(1.5rem, 3vw, 2rem);
}

.cg-results span + span { margin-left: 0.25rem; }

/* In main.css .r-pcard__media e' display:block e il logo segnaposto
   finisce in alto a sinistra: qui lo rimettiamo al centro. */
.cg-grid .r-pcard__media {
    display: flex;
}

/* ---------- Nessun risultato ---------- */
.cg-empty {
    margin-top: 1rem;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 0 var(--line);
    padding: clamp(2.5rem, 6vw, 4rem) 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.75rem;
}

.cg-empty__icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-pill);
    background: var(--sage);
    color: var(--forest);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.25rem;
}

.cg-empty h2 {
    font-size: clamp(1.5rem, 3vw, 1.9rem);
    font-weight: 400;
}

.cg-empty p {
    color: var(--moss);
    max-width: 40ch;
}

.cg-empty .r-btn { margin-top: 0.5rem; }

/* ---------- Nota per chi non ha fatto l'accesso ---------- */
.cg-note {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    margin-bottom: clamp(1.5rem, 3vw, 2rem);
    padding: 0.9rem 1rem 0.9rem 1.25rem;
    border-radius: var(--radius-md);
    background: var(--sage);
    color: var(--forest-dark);
    font-size: 0.95rem;
    font-weight: 600;
}

.cg-note > span {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}

.cg-note__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* ---------- Paginazione a pillole ---------- */
.cg-pager {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: clamp(2.5rem, 5vw, 3.5rem);
}

.cg-pager__nums {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.cg-pager__num,
.cg-pager__step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-width: 44px;
    height: 44px;
    padding: 0 0.9rem;
    border-radius: var(--radius-pill);
    background: var(--surface);
    box-shadow: inset 0 0 0 1px var(--line-strong);
    color: var(--ink);
    font-weight: 700;
    font-size: 0.9rem;
    text-decoration: none;
    font-variant-numeric: tabular-nums;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.cg-pager__num { padding: 0; }

.cg-pager a:hover { background: var(--sage); color: var(--ink); }

.cg-pager__num.is-active,
.cg-pager__num.is-active:hover {
    background: var(--ink);
    color: var(--paper);
    box-shadow: none;
}

.cg-pager__step .r-icon { width: 17px; height: 17px; }

.cg-pager__step.is-disabled {
    color: var(--moss);
    background: transparent;
    opacity: 0.6;
}

.cg-pager__gap {
    color: var(--moss);
    padding: 0 0.2rem;
}

/* ==========================================================
   CARD GROSSISTI: stessa card r-pcard, piu' condizioni e form
   ========================================================== */
.ws-card .r-pcard__body { gap: 0.4rem; }

.ws-card__price {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.2rem 0.5rem;
}

.ws-card__terms {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.ws-card__terms .r-pill { white-space: normal; }

.ws-card__form {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: auto;
    padding-top: 0.6rem;
    border-top: 1px solid var(--line);
}

.ws-card__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.total-price {
    font-size: 0.8125rem;
    color: var(--moss);
    text-align: right;
}

.total-price strong {
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

/* Selettore quantita' (bottoni + campo): stessa struttura letta da changeQty() */
.quantity-wrapper {
    display: inline-flex;
    align-items: center;
    height: 44px;
    border-radius: var(--radius-pill);
    background: var(--surface);
    box-shadow: inset 0 0 0 1px var(--line-strong);
    flex-shrink: 0;
}

.qty-btn {
    min-width: 40px;
    height: 44px;
    padding: 0 0.5rem;
    border: 0;
    background: transparent;
    color: var(--ink);
    font-weight: 700;
    font-size: 0.8125rem;
    border-radius: var(--radius-pill);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.qty-btn:hover { background: var(--sage); }
.qty-btn .r-icon { width: 16px; height: 16px; }

.quantity-wrapper input[type="number"] {
    width: 3.2rem;
    height: 36px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    text-align: center;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    -moz-appearance: textfield;
    appearance: textfield;
}

.quantity-wrapper input::-webkit-outer-spin-button,
.quantity-wrapper input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.ws-card .btn-add-cart { width: 100%; }

.btn-add-cart:disabled {
    background: var(--line-strong);
    color: var(--moss);
    cursor: not-allowed;
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .cg-toolbar { flex-direction: column; align-items: stretch; }
    .cg-tools { margin-left: 0; }
    .cg-search { flex: 1; }
    .cg-search input[type="search"] { width: 100%; }
}

@media (max-width: 760px) {
    .cg-hero--cover { grid-template-columns: 1fr; padding-right: clamp(1.5rem, 5vw, 3.5rem); }
    .cg-hero--cover .cg-hero__media { order: -1; }

    /* Categorie su una riga che scorre in orizzontale, a filo dei bordi */
    .cg-chips {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        margin: 0 calc(-1 * var(--site-gutter));
        padding: 2px var(--site-gutter);
        scroll-padding: 0 var(--site-gutter);
    }

    .cg-chips::-webkit-scrollbar { display: none; }

    .cg-tools { flex-wrap: wrap; gap: 0.6rem; }
    .cg-search { flex: 1 1 100%; }
    .cg-sort { flex: 1 1 100%; }
    .cg-sort select { flex: 1; min-width: 0; max-width: none; }
    .cg-sort label { white-space: normal; }

    .cg-pager__step span { display: none; }
    .cg-pager__step { padding: 0; min-width: 44px; }

    .ws-card__row { flex-direction: column; align-items: stretch; }
    .ws-card .quantity-wrapper { justify-content: space-between; }
    .total-price { text-align: left; }
    .ws-card .btn-add-cart { white-space: normal; padding: 0.4rem 0.75rem; text-align: center; }
    .ws-card .btn-add-cart .r-icon { display: none; }
    .ws-card .qty-btn { min-width: 34px; }
    .ws-card .quantity-wrapper input[type="number"] { width: 2.6rem; }
}
