/* ==========================================================================
   D'LUXURY Store: stylesheet (shared by the shop and the admin)

   1. Design tokens      colours, fonts, spacing, radii
   2. Base               reset and element defaults
   3. Site header, hero, categories, footer
   4. Product grid and cards
   5. Components         button, filter, stepper, field
   6. Product detail and gallery
   7. Cart
   8. Motion
   ========================================================================== */


/* ==========================================================================
   1. Design tokens
   Black and gold. Gold is only ever a FILL with black text on it, or text on
   black: gold text on white does not pass contrast, so it is never used there.
   ========================================================================== */

:root {
  color-scheme: light;

  /* Colour */
  --color-ink:           #111111;   /* header, footer, primary buttons */
  --color-gold:          #C9A227;   /* key buttons, badges, accents */
  --color-bg:            #FAF9F6;   /* warm white page */
  --color-surface:       #FFFFFF;   /* product cards, panels */
  --color-text:          #222222;
  --color-muted:         #6B6B6B;   /* a touch darker than #777 so small text passes 4.5:1 */
  --color-border:        #E6E2D8;
  --color-brand:         var(--color-ink);
  --color-on-brand:      #FAF9F6;
  --color-accent:        var(--color-gold);
  --color-on-accent:     #111111;
  --color-whatsapp:      #128c4a;
  --color-on-whatsapp:   #ffffff;
  --color-overlay:       rgb(17 17 17 / 60%);
  --color-danger:        #b42318;

  /* Typography */
  --font-display: "Marcellus", "Times New Roman", serif;
  --font-body:    "Jost", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Spacing scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.75rem;

  /* Radii: small and quiet, in keeping with a luxury look */
  --radius-sm:   4px;
  --radius-md:   6px;
  --radius-lg:   8px;
  --radius-pill: 999px;

  /* Shadow */
  --shadow-card: 0 1px 2px rgb(17 17 17 / 6%), 0 4px 14px rgb(17 17 17 / 5%);

  /* Layout */
  --container-width: 1200px;
  --page-gutter:     var(--space-3);
  --cart-width:      440px;

  /* Safe areas (phone notches and home bars; zero on desktop) */
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (min-width: 720px) { :root { --page-gutter: var(--space-5); } }


/* ==========================================================================
   2. Base
   ========================================================================== */

*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { scroll-padding-top: calc(var(--safe-top) + 120px); scroll-behavior: smooth; }

body {
  margin: 0;
  padding-bottom: var(--safe-bottom);
  background: var(--color-bg);
  color: var(--color-text);
  font: 400 1rem/1.5 var(--font-body);
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { margin: 0; font-family: var(--font-display); font-weight: 400; line-height: 1.15; }

button { font: inherit; color: inherit; cursor: pointer; }

img, video { max-width: 100%; }

:focus-visible { outline: 3px solid var(--color-ink); outline-offset: 2px; }
.on-dark :focus-visible { outline-color: var(--color-gold); }

.container { max-width: var(--container-width); margin-inline: auto; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

.skip-link {
  position: absolute; left: var(--space-2); top: -60px; z-index: 30;
  padding: var(--space-2) var(--space-4); border-radius: var(--radius-sm);
  background: var(--color-gold); color: var(--color-ink); font-weight: 600;
}
.skip-link:focus { top: calc(var(--safe-top) + var(--space-2)); }


/* ==========================================================================
   3. Site header, hero, categories, footer
   ========================================================================== */

.site-header {
  position: sticky; top: 0; z-index: 10;
  padding: var(--safe-top) var(--page-gutter) 0;
  background: var(--color-ink); color: var(--color-on-brand);
  border-bottom: 1px solid rgb(201 162 39 / 45%);
}

.site-header__inner {
  display: grid; align-items: center; gap: 10px 12px;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "brand cart" "search search";
  padding: 10px 0 12px;
}

.brand {
  grid-area: brand; justify-self: start;
  color: var(--color-gold); text-decoration: none;
  font: 400 1.5rem/1 var(--font-display); letter-spacing: 0.14em;
}

.search { grid-area: search; position: relative; width: 100%; }
.search__icon {
  position: absolute; left: 12px; top: 50%; width: 18px; height: 18px;
  transform: translateY(-50%); color: #555; pointer-events: none;
}
.search .field {
  min-height: 44px; padding-left: 40px;
  border-color: transparent; border-radius: var(--radius-sm);
  background: var(--color-bg); color: var(--color-ink);
}
.search .field::placeholder { color: #666; }

.cart-button {
  position: relative; grid-area: cart; display: grid; place-items: center;
  width: 44px; height: 44px; padding: 0;
  border: 1px solid rgb(250 249 246 / 28%); border-radius: var(--radius-sm);
  background: transparent; color: var(--color-on-brand);
}
.cart-button:hover { border-color: var(--color-gold); }
.cart-button svg { width: 22px; height: 22px; }
.cart-badge {
  position: absolute; top: -8px; right: -8px;
  min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: var(--radius-pill); background: var(--color-gold); color: var(--color-ink);
  font: 600 0.75rem/20px var(--font-body); text-align: center;
}

@media (min-width: 720px) {
  .site-header__inner {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "brand search cart";
    gap: 28px; padding-block: 14px;
  }
  .brand { font-size: 1.75rem; }
  .search { max-width: 560px; justify-self: center; }
}

/* Hero: compact, so the catalogue starts almost immediately */
.hero { padding: 18px var(--page-gutter) 22px; background: var(--color-ink); color: var(--color-on-brand); }
.hero__inner { display: grid; gap: var(--space-3); }
.hero__title { max-width: 16ch; font-size: clamp(1.65rem, 6vw, 3.1rem); letter-spacing: 0.01em; }
.hero__text { max-width: 46ch; margin: 0; color: rgb(250 249 246 / 78%); font-size: 0.95rem; }
.hero__text:empty { display: none; }
.hero .button { justify-self: start; }

@media (min-width: 900px) {
  .hero { padding-block: 40px 44px; }
  .hero__inner { grid-template-columns: 1.2fr 1fr; align-items: end; column-gap: 56px; }
  .hero__text, .hero .button { grid-column: 2; }
  .hero__title { grid-row: 1 / span 2; }
  .hero__text { align-self: end; }
}

/* Categories: one scrolling row, easy to swipe on a phone */
.categories { padding: 0 var(--page-gutter); border-bottom: 1px solid var(--color-border); background: var(--color-bg); }
.filters {
  display: flex; gap: var(--space-2);
  padding: var(--space-3) 0;
  overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity;
  max-width: var(--container-width); margin-inline: auto;
}
.filters::-webkit-scrollbar { display: none; }
.filter {
  flex: none; scroll-snap-align: start;
  min-height: 40px; padding: 0 var(--space-4);
  border: 1px solid var(--color-border); border-radius: var(--radius-pill);
  background: var(--color-surface); color: var(--color-text);
  font-weight: 500; white-space: nowrap;
}
.filter:hover { border-color: var(--color-ink); }
.filter[aria-pressed="true"] {
  border-color: var(--color-ink); background: var(--color-ink);
  color: var(--color-gold); font-weight: 600;
}

.catalog { padding: var(--space-4) var(--page-gutter) 0; scroll-margin-top: 120px; }
.catalog__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin: var(--space-2) 0 var(--space-3); }
.catalog__title { font-size: 1.45rem; }
.catalog__count { color: var(--color-muted); font-size: 0.9rem; }
.catalog__loading, .catalog__empty { grid-column: 1 / -1; margin: 0; padding: var(--space-6) 0; color: var(--color-muted); text-align: center; }

.site-footer {
  margin-top: 56px; padding: 32px var(--page-gutter) calc(28px + var(--safe-bottom));
  background: var(--color-ink); color: rgb(250 249 246 / 78%);
  border-top: 1px solid rgb(201 162 39 / 45%);
}
.site-footer__inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-4); }
.site-footer .brand { font-size: 1.35rem; }
.site-footer p { margin: 0; font-size: 0.9rem; }
.site-footer a:not(.brand) {
  display: inline-flex; align-items: center; min-height: 44px;
  color: var(--color-gold); font-weight: 500;
}


/* ==========================================================================
   4. Product grid and cards
   Two per row on phones, three on tablets, four on desktop.
   ========================================================================== */

.product-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 700px)  { .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; } }
@media (min-width: 1024px) { .product-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; } }

.product-card {
  display: flex; flex-direction: column; min-width: 0; overflow: hidden;
  border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  background: var(--color-surface); box-shadow: var(--shadow-card);
}

/* Fixed 4:5 box, so nothing jumps while photos load */
.product-card__media {
  position: relative; display: grid; place-items: center; width: 100%;
  aspect-ratio: 4 / 5; padding: 0; overflow: hidden; border: 0;
  background: #EFEBE1; color: var(--color-gold);
  font: 400 2.6rem var(--font-display);
}
.product-card__media:has(img, video) > .tile-letter { visibility: hidden; }
.product-card__media img,
.product-card__media video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.product-card__media video { pointer-events: none; background: var(--color-ink); }
.product-card--soldout .product-card__media img,
.product-card--soldout .product-card__media video { opacity: 0.55; }

.tags { position: absolute; top: var(--space-2); left: var(--space-2); z-index: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.tag {
  padding: 2px 8px; border-radius: 2px;
  font: 600 0.75rem/1.5 var(--font-body); letter-spacing: 0.03em;
}
.tag--sale { background: var(--color-gold); color: var(--color-ink); }
.tag--new  { background: var(--color-ink); color: var(--color-gold); }
.tag--out  { background: var(--color-surface); color: var(--color-ink); border: 1px solid var(--color-ink); }

.media-chip {
  position: absolute; left: var(--space-2); bottom: var(--space-2); z-index: 1;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px 3px 7px; border-radius: var(--radius-pill);
  background: rgb(17 17 17 / 78%); color: var(--color-on-brand);
  font: 500 0.75rem/1.5 var(--font-body);
}
.media-chip svg { width: 11px; height: 11px; color: var(--color-gold); }

.product-card__body { display: flex; flex: 1; flex-direction: column; gap: 2px; padding: 10px 10px 12px; }
.product-card__name { font: 500 0.95rem/1.3 var(--font-body); min-height: 2.6em; }
.product-card__name .link-button {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.product-card__desc {
  display: block; overflow: hidden; color: var(--color-muted); font-size: 0.82rem;
  text-overflow: ellipsis; white-space: nowrap;
}

.price { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; margin-top: auto; padding-top: var(--space-2); }
.price__now { font-weight: 600; font-size: 1.05rem; color: var(--color-ink); }
.price__was { color: var(--color-muted); font-size: 0.85rem; text-decoration: line-through; }
.price__off {
  padding: 0 6px; border-radius: 2px; background: #F4E9C4; color: var(--color-ink);
  font-size: 0.75rem; font-weight: 600; line-height: 1.6;
}
.product-card__action { margin-top: var(--space-2); width: 100%; }
@media (max-width: 767px) { .price { align-content: flex-start; min-height: 3.4rem; } }

/* Placeholder cards while the catalogue loads (same size as real cards) */
.product-card--skeleton { box-shadow: none; }
.product-card--skeleton .product-card__media { font-size: 0; }
.skeleton { display: block; height: 14px; margin-top: 8px; border-radius: 2px; background: #EFEBE1; }
.skeleton--short { width: 55%; }


/* ==========================================================================
   5. Components
   ========================================================================== */

.button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 var(--space-5);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font-weight: 600; letter-spacing: 0.01em; text-align: center; text-decoration: none; white-space: nowrap;
}
.button--accent { background: var(--color-gold); color: var(--color-ink); }
.button--accent:hover { background: #D6B13A; }
.button--dark { border-color: var(--color-ink); background: var(--color-ink); color: var(--color-on-brand); }
.button--dark:hover { background: #2b2b2b; }
.button--outline { border-color: var(--color-ink); background: transparent; color: var(--color-ink); }
.button--outline:hover { background: var(--color-ink); color: var(--color-on-brand); }
.button--whatsapp { display: flex; margin-top: var(--space-2); min-height: 52px; background: var(--color-whatsapp); color: var(--color-on-whatsapp); }
.button:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.button[aria-disabled="true"] { opacity: 0.4; pointer-events: none; }

.icon-button { width: 44px; height: 44px; border: 0; background: none; font-size: 1.6rem; }

.link-button { padding: 0; border: 0; background: none; font: inherit; text-align: left; }
.link-button:hover { text-decoration: underline; }

.stepper {
  display: flex; align-items: center; justify-content: space-between;
  border: 1px solid var(--color-ink); border-radius: var(--radius-sm); background: var(--color-surface);
}
.stepper__button { width: 44px; height: 42px; border: 0; background: none; color: var(--color-ink); font-size: 1.25rem; }
.stepper__value { font-weight: 600; }
.stepper--compact .stepper__button { width: 36px; height: 34px; }

.field {
  width: 100%; padding: var(--space-3) 0.75rem;
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  background: var(--color-surface); color: var(--color-text); font: inherit;
}
.field:focus-visible { border-color: var(--color-ink); outline-offset: 1px; }


/* ==========================================================================
   6. Product detail and gallery
   ========================================================================== */

.detail {
  width: min(940px, calc(100% - 1rem)); max-height: calc(100% - 1rem);
  padding: 0; border: 0; border-radius: var(--radius-lg);
  background: var(--color-surface); color: var(--color-text);
}
.detail::backdrop { background: var(--color-overlay); }
.detail__panel { position: relative; padding: var(--space-4); }
.detail__close {
  position: absolute; top: var(--space-2); right: var(--space-2); z-index: 3;
  border-radius: 50%; background: var(--color-surface); box-shadow: var(--shadow-card);
}
#detail-body { display: grid; gap: var(--space-5); }
@media (min-width: 720px) { #detail-body { grid-template-columns: 1.15fr 1fr; gap: var(--space-6); } .detail__panel { padding: var(--space-5); } }

.gallery__main {
  position: relative; display: grid; place-items: center; aspect-ratio: 4 / 5;
  overflow: hidden; border-radius: var(--radius-md);
  background: #EFEBE1; color: var(--color-gold); font: 400 4rem var(--font-display);
}
.gallery__main img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: var(--color-bg); }
.gallery__main video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.gallery__error {
  position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: var(--space-4);
  background: var(--color-surface); color: var(--color-text); font: 500 1rem var(--font-body); text-align: center;
}
.gallery__nav {
  position: absolute; top: 50%; z-index: 1; width: 40px; height: 40px; transform: translateY(-50%);
  border: 0; border-radius: 50%; background: rgb(17 17 17 / 70%); color: var(--color-on-brand); font-size: 1.6rem; line-height: 1;
}
.gallery__nav--prev { left: var(--space-2); }
.gallery__nav--next { right: var(--space-2); }
.gallery__thumbs { display: flex; gap: var(--space-2); margin-top: var(--space-2); overflow-x: auto; padding: 2px; }
.gallery__thumb {
  flex: none; width: 64px; height: 64px; padding: 0; overflow: hidden;
  border: 2px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-bg);
}
.gallery__thumb[aria-pressed="true"] { border-color: var(--color-gold); outline: 1px solid var(--color-ink); }
.gallery__thumb img { width: 100%; height: 100%; object-fit: cover; }
.gallery__thumb--video { display: grid; place-items: center; background: var(--color-ink); color: var(--color-gold); }
.gallery__thumb--video svg { width: 22px; height: 22px; }

.detail__info { display: flex; flex-direction: column; gap: var(--space-2); padding-top: var(--space-2); }
.detail__category { color: var(--color-muted); font-size: 0.9rem; }
.detail__name { font-size: 1.75rem; }
.detail__price { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-top: 2px; }
.detail__price .price__now { font-size: 1.45rem; }
.detail__price .price__was { font-size: 1rem; }
.detail__desc, .detail__more { margin: 0; }
.detail__more { color: var(--color-muted); white-space: pre-line; }
.detail__action { margin-top: var(--space-3); }
.detail__action .button { width: 100%; }


/* ==========================================================================
   7. Cart (slide-in panel)
   ========================================================================== */

.cart { width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: transparent; }
.cart::backdrop { background: var(--color-overlay); }
.cart__panel {
  position: fixed; inset: 0 0 0 auto; display: flex; flex-direction: column;
  width: min(var(--cart-width), 100%); padding: var(--space-5);
  padding-top: calc(var(--space-5) + var(--safe-top)); padding-bottom: calc(var(--space-5) + var(--safe-bottom));
  background: var(--color-surface); color: var(--color-text); animation: slide-in 0.22s ease-out;
}
.cart__header { display: flex; align-items: center; justify-content: space-between; padding-bottom: var(--space-3); }
.cart__title { font-size: 1.5rem; }
.cart__header-actions { display: flex; align-items: center; gap: var(--space-2); }
.cart__clear { color: var(--color-muted); font-size: 0.9rem; text-decoration: underline; }
.cart__lines { flex: 1; overflow: auto; border-top: 1px solid var(--color-border); }
.cart__empty { padding: 2.5rem 0; color: var(--color-muted); text-align: center; }
.cart__notice {
  margin: 0 0 var(--space-2); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm);
  background: #F4E9C4; font-size: 0.875rem;
}
.cart__form { display: grid; gap: var(--space-2); padding-top: var(--space-3); }
.cart__total { display: flex; justify-content: space-between; padding: var(--space-3) 0 var(--space-1); font-size: 1.15rem; font-weight: 600; }
.cart__hint { margin: 6px 0 0; color: var(--color-muted); font-size: 0.85rem; }
.cart__keep { margin-top: var(--space-2); width: 100%; }

.cart-line { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--color-border); }
.cart-line__thumb {
  position: relative; display: grid; flex: none; place-items: center; width: 64px; height: 64px;
  overflow: hidden; border-radius: var(--radius-sm); color: var(--color-gold); font: 400 1.4rem var(--font-display);
}
.cart-line__thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cart-line__info { flex: 1; min-width: 0; }
.cart-line__top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-2); }
.cart-line__name { font-weight: 600; }
.cart-line__price { display: block; color: var(--color-muted); font-size: 0.875rem; }
.cart-line__remove { padding: 0; border: 0; background: none; color: var(--color-muted); font-size: 0.85rem; text-decoration: underline; }
.cart-line__remove:hover { color: var(--color-danger); }
.cart-line__bottom { display: flex; align-items: center; justify-content: space-between; margin-top: var(--space-2); }
.cart-line__bottom .stepper { min-width: 112px; }

.toast {
  position: absolute; right: var(--space-5); bottom: calc(var(--space-5) + var(--safe-bottom)); left: var(--space-5);
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-md);
  background: var(--color-ink); color: var(--color-on-brand); box-shadow: 0 8px 24px rgb(0 0 0 / 25%);
  animation: slide-in 0.2s ease-out;
}
.toast__undo { border: 0; background: none; color: var(--color-gold); font-weight: 700; }


/* ==========================================================================
   8. Motion
   ========================================================================== */

@keyframes slide-in { from { opacity: 0; transform: translateX(40px); } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .cart__panel, .toast { animation: none; }
}
