/*
 * components/product-detail.css
 *
 * What:  The rich single-product page (views/partials/product-detail.ejs):
 *        gallery (left) · details + option groups + note + related
 *        (center) · "Your order" summary for this item (right). Sticky
 *        Add bar on mobile. Fully responsive — 3 cols → 2 → 1.
 * Used:  Loaded globally via _layout; renders on the product view.
 */

.pd { max-width: 1320px; margin: 0 auto; padding: var(--space-4) var(--space-6) calc(var(--space-10) + 72px); }

/* Breadcrumb */
.pd-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--color-text-soft); margin-bottom: var(--space-4); }
.pd-crumbs a { color: var(--color-text-soft); text-decoration: none; }
.pd-crumbs a:hover { color: var(--color-primary); }
.pd-crumbs__current { color: var(--color-text); font-weight: 600; }

.pd__grid { display: grid; grid-template-columns: 420px minmax(0, 1fr) 340px; gap: var(--space-6); align-items: start; }

/* ── Gallery ───────────────────────────────────────────────────────── */
.pd__gallery { position: sticky; top: 88px; }
.pd-gallery__main {
    position: relative; aspect-ratio: 1 / 1; border-radius: var(--radius-lg);
    overflow: hidden; background: var(--color-bg-alt); display: grid; place-items: center; font-size: 3rem;
}
.pd-gallery__main img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pd-gallery__thumbs { list-style: none; margin: var(--space-3) 0 0; padding: 0; display: flex; gap: var(--space-2); }
.pd-gallery__thumb {
    width: 72px; height: 72px; border-radius: var(--radius-md); overflow: hidden;
    border: 2px solid transparent; background: var(--color-bg-alt); cursor: pointer; padding: 0;
}
.pd-gallery__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pd-gallery__thumb.is-active { border-color: var(--color-primary); }

/* ── Center: details ───────────────────────────────────────────────── */
.pd-veg { display: inline-block; width: 18px; height: 18px; border-radius: 4px; border: 2px solid; }
.pd-veg.is-veg { border-color: #16a34a; background: radial-gradient(circle, #16a34a 38%, transparent 40%); }
.pd-veg.is-nonveg { border-color: #c0392b; background: radial-gradient(circle, #c0392b 38%, transparent 40%); }
.pd__name { font-size: 1.9rem; font-weight: 800; margin: var(--space-2) 0 4px; }
.pd__rating { display: flex; align-items: center; gap: 6px; margin: 0 0 var(--space-2); font-weight: 700; }
.pd__stars { display: inline-flex; align-items: center; gap: 4px; color: #f59e0b; }
.pd__rating-count { color: var(--color-text-soft); font-weight: 500; }
.pd__price { font-size: 1.5rem; font-weight: 800; margin: 0 0 var(--space-2); }
.pd__price--na { font-size: 1rem; font-style: italic; color: var(--color-text-soft); }
.pd__desc { color: var(--color-text-soft); line-height: 1.5; margin: 0 0 var(--space-5); }

/* ── Option groups ─────────────────────────────────────────────────── */
.pd-group { border: 0; margin: 0 0 var(--space-5); padding: 0; }
.pd-group__legend { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); width: 100%; padding: 0 0 var(--space-3); }
.pd-group__name { font-size: 0.98rem; font-weight: 800; }
.pd-group__hint { font-size: 0.78rem; color: var(--color-text-soft); }
.pd-group__req { color: var(--color-primary); font-weight: 700; }
.pd-group__opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(172px, 1fr)); gap: var(--space-2); }

.pd-opt {
    display: flex; align-items: center; gap: 9px;
    padding: 9px 12px; border: 1px solid var(--color-border-soft);
    border-radius: var(--radius-md); cursor: pointer;
    transition: border-color 120ms ease, background 120ms ease;
}
.pd-opt:hover { border-color: var(--color-border); }
.pd-opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.pd-opt__mark { flex: 0 0 auto; width: 20px; height: 20px; border: 2px solid var(--color-border); display: inline-grid; place-items: center; }
.pd-opt input[type="radio"] + .pd-opt__mark { border-radius: 50%; }
.pd-opt input[type="checkbox"] + .pd-opt__mark { border-radius: 6px; }
.pd-opt__mark::after { content: ""; width: 10px; height: 10px; border-radius: inherit; background: #fff; transform: scale(0); transition: transform 120ms ease; }
.pd-opt input:checked + .pd-opt__mark { border-color: var(--color-primary); background: var(--color-primary); }
.pd-opt input:checked + .pd-opt__mark::after { transform: scale(1); }
.pd-opt input:focus-visible + .pd-opt__mark { box-shadow: 0 0 0 3px var(--color-primary-soft); }
.pd-opt:has(input:checked) { border-color: var(--color-primary); background: var(--color-primary-soft); }
.pd-opt__name { flex: 1 1 auto; font-weight: 600; font-size: 0.9rem; }
.pd-opt__price { color: var(--color-text-soft); font-weight: 700; font-size: 0.85rem; white-space: nowrap; }
.pd-opt__mark { width: 18px; height: 18px; }

/* Stock states */
.pd__oos { color: var(--color-primary); font-weight: 800; margin: 0 0 var(--space-2); }
.pd__stock { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; margin: 0 0 var(--space-2); }
.pd__stock svg { flex: 0 0 auto; }
.pd__stock--in { color: #16a34a; }
.pd__stock--out { color: var(--color-primary); }
.pd-add.is-disabled, .pd-add:disabled { background: var(--color-border); color: var(--color-text-soft); cursor: not-allowed; }
.pd-qty__btn.is-disabled, .pd-qty__btn:disabled { background: var(--color-bg-alt); color: var(--color-border); cursor: not-allowed; }
.pd-qty__btn.is-disabled:hover, .pd-qty__btn:disabled:hover { background: var(--color-bg-alt); color: var(--color-border); }
.pd-group.is-invalid .pd-group__legend { color: var(--color-primary); }
.pd-group.is-invalid .pd-opt { border-color: var(--color-primary); }

/* Linked sub-group — appears as its own section after the parent
   group's fieldset, only when the parent option is selected. A thin
   left accent + a slight indent reads as "this depends on what you
   picked above" without breaking the page rhythm. */
.pd-linked-section {
    margin: 0 0 var(--space-5);
    border-left: 3px solid var(--color-primary-soft);
    padding-left: var(--space-3);
}
.pd-linked-section[hidden] { display: none; }
.pd-linked-section .pd-group { margin-bottom: 0; }
.pd-linked-section .pd-group__legend { padding-top: 0; }

/* ── Customization note ────────────────────────────────────────────── */
.pd-note { display: block; position: relative; margin: 0 0 var(--space-6); }
.pd-note__label { display: block; font-weight: 800; margin-bottom: var(--space-2); }
.pd-note__input { width: 100%; border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 10px 12px; font: inherit; resize: vertical; background: var(--color-primary-soft); }
.pd-note__input:focus { outline: none; border-color: var(--color-primary); }
.pd-note__count { position: absolute; right: 10px; bottom: 8px; font-size: 0.75rem; color: var(--color-text-soft); }

/* ── You may also like ─────────────────────────────────────────────── */
.pd-related { margin-top: var(--space-4); }
.pd-related__title { font-size: 1.1rem; font-weight: 800; margin: 0 0 var(--space-3); }
.pd-related__list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--space-3); }
.pd-related__card { display: block; text-decoration: none; color: inherit; }
.pd-related__media { display: block; position: relative; aspect-ratio: 1 / 1; border-radius: var(--radius-md); overflow: hidden; background: var(--color-bg-alt); display: grid; place-items: center; font-size: 1.6rem; }
.pd-related__media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pd-related__name { display: block; font-weight: 700; font-size: 0.9rem; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pd-related__price { display: block; color: var(--color-text-soft); font-size: 0.85rem; }

/* ── Right: order summary ──────────────────────────────────────────── */
.pd__order { position: sticky; top: 88px; }
.pd-order__card { background: #fff; border: 1px solid var(--color-border-soft); border-radius: var(--radius-lg); padding: var(--space-4); }
.pd-order__title { font-size: 1.1rem; font-weight: 800; margin: 0 0 var(--space-3); }
.pd-order__item { display: flex; gap: var(--space-3); align-items: flex-start; padding-bottom: var(--space-3); border-bottom: 1px solid var(--color-border-soft); }
.pd-order__thumb { flex: 0 0 48px; width: 48px; height: 48px; border-radius: var(--radius-sm); overflow: hidden; background: var(--color-bg-alt); display: grid; place-items: center; position: relative; }
.pd-order__thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pd-order__info { flex: 1 1 auto; min-width: 0; }
.pd-order__name { font-weight: 700; margin: 0; }
.pd-order__opts { color: var(--color-text-soft); font-size: 0.82rem; margin: 2px 0 0; }
.pd-order__line { font-weight: 800; white-space: nowrap; }
.pd-order__totals { padding: var(--space-3) 0; }
.pd-order__row { display: flex; justify-content: space-between; font-weight: 600; }
.pd-add--panel { width: 100%; margin-top: var(--space-2); }

.pd-qty { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-top: var(--space-3); }
.pd-qty__label { font-weight: 700; }
.pd-qty__stepper { display: inline-flex; align-items: center; gap: var(--space-3); border: 1px solid var(--color-border); border-radius: 999px; padding: 4px; }
.pd-qty__btn { width: 32px; height: 32px; border: 0; border-radius: 50%; background: var(--color-bg-alt); color: var(--color-text); font-size: 1.2rem; font-weight: 700; cursor: pointer; display: grid; place-items: center; }
.pd-qty__btn:hover { background: var(--color-primary); color: #fff; }
.pd-qty__value { min-width: 22px; text-align: center; font-weight: 800; }

.pd-add { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); background: var(--color-primary); color: #fff; border: 0; border-radius: var(--radius-md); padding: 14px 20px; font-size: 1rem; font-weight: 800; cursor: pointer; }
.pd-add:hover { background: var(--color-primary-dark); }
.pd-add__total { font-variant-numeric: tabular-nums; }

/* Sticky add bar — mobile only. */
.pd-bar { display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: #fff; border-top: 1px solid var(--color-border-soft); padding: var(--space-3) var(--space-4); box-shadow: 0 -4px 18px rgba(0,0,0,0.06); }
.pd-bar .pd-add { width: 100%; }

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 1180px) {
    /* Drop the order rail to full-width below; keep gallery + details. */
    .pd__grid { grid-template-columns: 360px minmax(0, 1fr); }
    .pd__order { grid-column: 1 / -1; position: static; }
    .pd-order__card { max-width: 520px; }
}
@media (max-width: 820px) {
    .pd { padding: var(--space-3) var(--space-3) calc(var(--space-10) + 80px); }
    .pd__grid { grid-template-columns: 1fr; gap: var(--space-4); }
    .pd__gallery { position: static; }
    .pd-gallery__main { aspect-ratio: 16 / 10; }
    .pd__name { font-size: 1.4rem; }
    .pd-order__card { max-width: none; }
    /* On mobile the panel's own Add is hidden; the sticky bar carries it. */
    .pd-add--panel { display: none; }
    .pd-bar { display: flex; }
}
