/* ==========================================================================
   Gassi Store — product catalogue, product modal, cart drawer
   Uses the shared design tokens from style.css (Literata + Onest, flat gold,
   3px radii, no gradients, no pill buttons).
   ========================================================================== */

.visually-hidden {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Header cart button ---------- */
.cart-btn {
    position: relative;
    display: inline-flex; align-items: center; justify-content: center;
    width: 42px; height: 42px;
    border: 1px solid var(--border-strong);
    border-radius: 3px;
    color: var(--text);
    background: transparent;
    transition: border-color .18s, color .18s;
}
.cart-btn:hover { border-color: var(--gold); color: var(--gold-light); }
.cart-count {
    position: absolute; top: -6px; right: -6px;
    min-width: 19px; height: 19px; padding: 0 5px;
    display: grid; place-items: center;
    background: var(--gold-fill); color: var(--on-gold);
    border-radius: 3px;
    font-size: .72rem; font-weight: 700; line-height: 1;
}
/* `display: grid` above would otherwise beat the UA [hidden] rule and show a "0" badge. */
.cart-count[hidden] { display: none; }

/* ---------- Shop hero ---------- */
.shop-hero { padding: 132px 0 24px; }
.shop-hero-row {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 32px; flex-wrap: wrap;
    padding-bottom: 26px;
    border-bottom: 1px solid var(--border);
}
.shop-title {
    font-family: var(--font-heading);
    font-size: clamp(1.9rem, 4.4vw, 3rem);
    font-weight: 700; line-height: 1.12; letter-spacing: -.015em;
    margin: 10px 0 12px;
}
.shop-sub { color: var(--text-muted); font-size: 1rem; max-width: 56ch; font-weight: 300; }
.shop-hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Toolbar ---------- */
.shop-catalog { padding: 28px 0 12px; }
.shop-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; flex-wrap: wrap; margin-bottom: 22px;
}
.filter-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
    padding: 9px 16px;
    border: 1px solid var(--border-strong);
    border-radius: 3px;
    background: transparent; color: var(--text-muted);
    font-size: .86rem; font-weight: 500;
    transition: color .18s, border-color .18s, background .18s;
}
.chip:hover { color: var(--text); border-color: var(--gold); }
.chip.is-active { background: var(--gold-fill); border-color: var(--gold-fill); color: var(--on-gold); font-weight: 600; }

.toolbar-right { display: flex; align-items: center; gap: 14px; }
.result-count { color: var(--text-faint); font-size: .84rem; }
.sort-select {
    padding: 9px 12px;
    border: 1px solid var(--border-strong); border-radius: 3px;
    background: var(--bg-alt); color: var(--text); font-size: .86rem;
    transition: border-color .18s, color .18s;
}
.sort-select:hover { border-color: var(--gold); color: var(--gold-light); }
.sort-select option { background: var(--bg-alt); }

/* ---------- Product grid ---------- */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 18px;
}
.product-card {
    display: flex; flex-direction: column;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--bg-card);
    overflow: hidden;
    transition: border-color .2s;
}
.product-card:hover { border-color: var(--gold-border-strong); }

.pc-media {
    position: relative;
    display: block; width: 100%;
    padding: 0; border: 0; background: var(--media-bg);
    aspect-ratio: 3 / 4;
    overflow: hidden; cursor: pointer;
}
.pc-media img {
    width: 100%; height: 100%;
    object-fit: cover; display: block;
    transition: transform .45s cubic-bezier(.22,1,.36,1);
}
.product-card:hover .pc-media img { transform: scale(1.035); }
.pc-badge {
    position: absolute; top: 8px; right: 8px;
    padding: 4px 8px;
    background: var(--overlay-badge); color: var(--badge-text);
    border-radius: 3px;
    font-size: .75rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
}
.pc-badge.out { background: var(--overlay-badge); color: var(--badge-danger); }

.pc-body { padding: 13px 14px 15px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.pc-name {
    font-family: var(--font-body);
    font-size: .95rem; font-weight: 600; line-height: 1.3;
    color: var(--text);
    margin: 0;
    overflow-wrap: break-word;
    hyphens: auto;
}
.pc-fabric { font-size: .78rem; color: var(--text-faint); overflow-wrap: break-word; }
.pc-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 8px; flex-wrap: wrap; }
.pc-price { font-size: 1.02rem; font-weight: 700; color: var(--gold-light); white-space: nowrap; }
.pc-price small { font-size: .7rem; font-weight: 500; color: var(--text-faint); }
.pc-add {
    padding: 8px 13px;
    border: 1px solid var(--border-strong); border-radius: 3px;
    background: transparent; color: var(--text);
    font-size: .8rem; font-weight: 600;
    transition: background .18s, border-color .18s, color .18s;
}
.pc-add:hover { background: var(--gold-fill); border-color: var(--gold-fill); color: var(--on-gold); }

.shop-empty { text-align: center; color: var(--text-faint); padding: 48px 0; }

/* ---------- Catalogue states (loading / error) ---------- */
.shop-state {
    text-align: center; padding: 56px 20px;
    border: 1px solid var(--border); border-radius: 3px;
    background: var(--bg-card);
}
.shop-state h2 { font-size: 1.05rem; margin: 0 0 8px; color: var(--text); }
.shop-state p { color: var(--text-muted); font-size: .92rem; margin: 0 auto 18px; max-width: 44ch; }
.shop-state .btn { margin: 0 auto; }
.shop-loading { text-align: center; color: var(--text-faint); padding: 48px 0; }

/* ---------- How it works ---------- */
.shop-how { background: var(--bg-alt); }
.how-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; list-style: none; margin: 0; padding: 0; }
.how-steps li { display: flex; gap: 14px; align-items: flex-start; }
.how-num {
    flex-shrink: 0;
    width: 30px; height: 30px;
    display: grid; place-items: center;
    border: 1px solid var(--gold); border-radius: 3px;
    color: var(--gold-light); font-weight: 700; font-size: .9rem;
}
.how-steps h3 { font-family: var(--font-body); font-size: .96rem; font-weight: 600; margin: 4px 0 5px; }
.how-steps p { color: var(--text-muted); font-size: .88rem; font-weight: 300; margin: 0; }

/* ---------- Visit ---------- */
.visit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: start; }
.visit-facts { display: grid; gap: 14px; margin: 0; }
.visit-facts div { display: grid; grid-template-columns: 150px 1fr; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.visit-facts dt { color: var(--text-faint); font-size: .82rem; }
.visit-facts dd { margin: 0; font-size: .92rem; }
.visit-facts a { color: var(--gold-light); }

/* ---------- Product modal ---------- */
.modal, .cart-drawer { position: fixed; inset: 0; z-index: 200; }
.modal[hidden], .cart-drawer[hidden] { display: none; }
.modal-backdrop, .cart-backdrop {
    position: absolute; inset: 0;
    background: var(--overlay-scrim);
    backdrop-filter: blur(3px);
}
.modal-panel {
    position: relative;
    max-width: 940px; margin: 4vh auto; padding: 0;
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    max-height: 92vh; overflow: auto;
}
.modal-close {
    position: absolute; top: 8px; right: 8px; z-index: 3;
    width: 36px; height: 36px;
    display: grid; place-items: center;
    background: var(--overlay-control); color: var(--text);
    border: 1px solid var(--border-strong); border-radius: 3px;
    font-size: 1.2rem; line-height: 1;
}
.modal-close:hover { color: var(--gold-light); border-color: var(--gold); }

.pm-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: 0; }
.pm-gallery { background: var(--media-bg); padding: 16px; }
.pm-main { aspect-ratio: 3 / 4; background: #fff; border-radius: 2px; overflow: hidden; }
.pm-main img { width: 100%; height: 100%; object-fit: contain; display: block; }
.pm-thumbs { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; padding-bottom: 2px; }
.pm-thumbs button {
    flex: 0 0 auto; width: 58px; height: 76px; padding: 0;
    border: 1px solid #d5d8de; border-radius: 2px; overflow: hidden; background: #fff;
}
.pm-thumbs button.is-active { border-color: var(--gold); border-width: 2px; }
.pm-thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }

.pm-info { padding: 24px 24px 26px; display: flex; flex-direction: column; gap: 14px; }
.pm-cat { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--gold); font-weight: 600; }
.pm-info h2 { font-family: var(--font-heading); font-size: clamp(1.3rem, 2.6vw, 1.7rem); font-weight: 700; line-height: 1.2; margin: 0; }
.pm-fabric { color: var(--text-muted); font-size: .88rem; margin: 0; font-weight: 300; }
.pm-price { font-size: 1.5rem; font-weight: 700; color: var(--gold-light); }
.pm-price small { font-size: .78rem; font-weight: 500; color: var(--text-faint); }
.pm-field { display: flex; flex-direction: column; gap: 7px; }
.pm-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); font-weight: 600; }
.pm-note { font-size: .78rem; color: var(--text-faint); margin: 0; line-height: 1.5; }

.size-chips { display: flex; gap: 7px; flex-wrap: wrap; }
.size-chips button {
    min-width: 46px; padding: 9px 10px;
    border: 1px solid var(--border-strong); border-radius: 3px;
    background: transparent; color: var(--text-muted);
    font-size: .86rem; font-weight: 500;
}
.size-chips button:hover { border-color: var(--gold); color: var(--text); }
.size-chips button.is-active { background: var(--gold-fill); border-color: var(--gold-fill); color: var(--on-gold); font-weight: 700; }

.qty-stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--border-strong); border-radius: 3px; width: fit-content; }
.qty-stepper button {
    width: 38px; background: transparent; color: var(--text);
    border: 0; font-size: 1.1rem; line-height: 1;
}
.qty-stepper button:hover { color: var(--gold-light); }
.qty-stepper input {
    width: 52px; padding: 9px 0; text-align: center;
    background: transparent; border: 0; border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    color: var(--text); font-size: .92rem; font-weight: 600;
    -moz-appearance: textfield;
    appearance: textfield;
    min-width: 0;
}
.qty-stepper input::-webkit-outer-spin-button,
.qty-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* The panel can take focus itself when it holds no focusable children. */
.modal-panel:focus, .cart-panel:focus { outline: none; }
.modal-panel:focus-visible, .cart-panel:focus-visible { outline: 2px solid var(--gold-light); outline-offset: -2px; }
.btn.is-busy { opacity: .6; }

.btn-block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* ---------- Cart drawer ---------- */
.cart-panel {
    position: absolute; top: 0; right: 0; bottom: 0;
    width: min(420px, 100%);
    display: flex; flex-direction: column;
    background: var(--bg);
    border-left: 1px solid var(--border-strong);
    animation: cartIn .22s cubic-bezier(.22,1,.36,1);
}
@keyframes cartIn { from { transform: translateX(12px); opacity: .72; } to { transform: none; opacity: 1; } }
.cart-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.cart-head h2 { font-family: var(--font-heading); font-size: 1.15rem; font-weight: 700; margin: 0; }
.cart-head .modal-close { position: static; }
.cart-body { flex: 1; overflow-y: auto; padding: 6px 18px; }
.cart-empty { color: var(--text-faint); text-align: center; padding: 40px 0; font-size: .9rem; }

.cart-item { display: grid; grid-template-columns: 62px 1fr auto; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.cart-item img { width: 62px; height: 82px; object-fit: cover; border-radius: 2px; background: var(--media-bg); }
.cart-item > div { min-width: 0; }
.ci-name { font-size: .88rem; font-weight: 600; line-height: 1.3; overflow-wrap: break-word; }
.ci-meta { font-size: .76rem; color: var(--text-faint); margin-top: 3px; }
.ci-price { white-space: nowrap; overflow-wrap: break-word; }
.ci-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.ci-qty { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: 3px; }
.ci-qty button { width: 26px; height: 26px; background: transparent; border: 0; color: var(--text); font-size: 1rem; line-height: 1; }
.ci-qty button:hover { color: var(--gold-light); }
.ci-qty span { min-width: 26px; text-align: center; font-size: .82rem; font-weight: 600; }
.ci-remove { background: none; border: 0; color: var(--text-faint); font-size: .76rem; text-decoration: underline; }
.ci-remove:hover { color: var(--danger); }
.ci-price { font-size: .88rem; font-weight: 700; color: var(--gold-light); white-space: nowrap; }

.cart-foot { padding: 16px 18px 20px; border-top: 1px solid var(--border); }
.cart-total-row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.cart-total-row span { color: var(--text-muted); font-size: .86rem; }
.cart-total-row strong { font-size: 1.2rem; color: var(--gold-light); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .how-steps { grid-template-columns: 1fr; gap: 18px; }
    .visit-grid { grid-template-columns: 1fr; gap: 24px; }
    .pm-grid { grid-template-columns: 1fr; }
    .pm-gallery { padding: 12px; }
    .pm-info { padding: 20px 18px 22px; }
}
@media (max-width: 640px) {
    .shop-hero { padding: 112px 0 18px; }
    .shop-hero-row { gap: 18px; }
    .shop-hero-actions { width: 100%; }
    .shop-hero-actions .btn { flex: 1; justify-content: center; }
    .product-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .pc-body { padding: 10px 11px 12px; }
    .pc-name { font-size: .87rem; }
    .pc-fabric { display: none; }
    .pc-foot { flex-direction: column; align-items: stretch; gap: 7px; }
    .pc-add { width: 100%; text-align: center; }
    .shop-toolbar { gap: 12px; }
    .toolbar-right { width: 100%; justify-content: space-between; }
    .visit-facts div { grid-template-columns: 1fr; gap: 2px; }
    .modal-panel { margin: 0; max-height: 100vh; height: 100%; border-radius: 0; border: 0; }
    .pm-thumbs button { width: 50px; height: 66px; }
}
/* Only the very narrowest phones go single-column; 360–414 keep two. */
@media (max-width: 340px) {
    .product-grid { grid-template-columns: 1fr; }
}
@media (max-width: 400px) {
    .chip { padding: 8px 12px; font-size: .8rem; }
    .sort-select { font-size: .8rem; padding: 8px 10px; }
    .result-count { font-size: .78rem; }
}

/* ---------- Compact header for small phones ---------- */
@media (max-width: 480px) {
    /* Header compaction lives in style.css (shared with the homepage). */
    .cart-btn { width: 38px; height: 38px; }
    .shop-hero { padding: 96px 0 14px; }
    .shop-catalog { padding: 20px 0 8px; }
}

/* ---------- Press feedback ---------- */
.chip:active,
.pc-add:active,
.cart-btn:active,
.modal-close:active,
.size-chips button:active,
.ci-qty button:active,
.ci-remove:active { transform: translateY(1px); }

@media (prefers-reduced-motion: reduce) {
    .chip:active,
    .pc-add:active,
    .cart-btn:active,
    .modal-close:active,
    .size-chips button:active,
    .ci-qty button:active,
    .ci-remove:active { transform: none; filter: brightness(0.92); }
}
