/* ============================================================
   Casa Corvera — Catálogo interactivo v2 (mobile-first)
   Sin backdrop-filter en ningún ancestro de elementos fixed.
   ============================================================ */
:root {
  --gold: #c9a86a;
  --gold-l: #e6c98d;
  --gold-d: #8a6f3f;
  --ink: #0d0c0a;
  --ink-2: #14110d;
  --cream: #f5f1ea;
  --muted: #a89f8e;
  --line: rgba(201, 168, 106, 0.25);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--ink); color: var(--cream);
  font-family: 'Jost', sans-serif; -webkit-text-size-adjust: 100%;
}
img { max-width: 100%; height: auto; }
h1, h2, p { margin: 0; }
a { color: var(--gold); text-decoration: none; }
::selection { background: var(--gold); color: var(--ink); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
body.modal-open { overflow: hidden; }

/* ---------- Barra superior ---------- */
.cbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
}
.cbar-logo img { height: 42px; width: auto; display: block; }
.cbar-back { font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); padding: 10px 0; }
.cbar-back:hover { color: var(--gold-l); }

/* ---------- Encabezado compacto ---------- */
.chero { padding: 24px 16px 16px; max-width: 1240px; margin: 0 auto; }
.kicker { font-size: 12px; letter-spacing: 4px; text-transform: uppercase; color: var(--gold); margin-bottom: 6px; }
.chero-title { font-family: 'Marcellus', serif; font-weight: 400; font-size: clamp(27px, 7vw, 44px); margin-bottom: 8px; }
.chero-sub { font-size: 15px; font-weight: 300; line-height: 1.55; color: var(--muted); max-width: 560px; margin-bottom: 14px; }

.btn-gold {
  display: inline-block; padding: 14px 26px; background: var(--gold); color: var(--ink);
  font-size: 14px; letter-spacing: 2px; text-transform: uppercase; font-weight: 500;
  border: none; cursor: pointer; text-align: center;
}
.btn-gold:hover { background: var(--gold-l); color: var(--ink); }
.btn-ghost {
  display: inline-block; padding: 11px 18px; border: 1px solid var(--gold);
  background: none; color: var(--gold-l); font-family: 'Jost', sans-serif;
  font-size: 12px; letter-spacing: 2px; text-transform: uppercase; cursor: pointer; text-align: center;
}
.btn-ghost:hover { background: var(--gold); color: var(--ink); }

/* ---------- Búsqueda y orden (flujo normal, no sticky) ---------- */
.filters { max-width: 1240px; margin: 0 auto; padding: 0 16px 10px; }
.tool-row { display: flex; gap: 8px; }
.search, .sort {
  min-height: 42px; padding: 8px 12px; font-size: 16px; font-family: 'Jost', sans-serif;
  background: var(--ink-2); color: var(--cream); border: 1px solid rgba(201, 168, 106, 0.35);
  border-radius: 0; outline: none;
}
.search { flex: 1 1 auto; min-width: 0; }
.sort { flex: 0 1 150px; min-width: 118px; }
.search:focus, .sort:focus { border-color: var(--gold); }
.search::placeholder { color: #6f6656; }

/* ---------- Barra de línea (lo único sticky: ~56 px) ---------- */
.seg-bar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(13, 12, 10, 0.97);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 8px 16px;
}
.seg-inner { max-width: 1240px; margin: 0 auto; display: flex; align-items: center; gap: 14px; }
.seg {
  display: flex; gap: 6px; flex: 1; min-width: 0;
  overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg-btn {
  flex: 0 0 auto; min-height: 40px; padding: 8px 14px;
  background: none; border: 1px solid rgba(201, 168, 106, 0.35); color: var(--muted);
  font-family: 'Jost', sans-serif; font-size: 12px; letter-spacing: 0.5px; text-transform: uppercase;
  white-space: nowrap; cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.seg-btn[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: var(--ink); font-weight: 500; }
.seg-btn:not([aria-pressed="true"]):hover { border-color: var(--gold); color: var(--gold-l); }
.count { display: none; font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: #6f6656; white-space: nowrap; }

/* ---------- Grid de productos (2 → 3 → 4 → 5 columnas) ---------- */
main { max-width: 1240px; margin: 0 auto; padding: 14px 16px calc(90px + env(safe-area-inset-bottom, 0px)); }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

.card {
  min-width: 0;
  display: flex; flex-direction: column; background: var(--ink-2);
  border: 1px solid rgba(201, 168, 106, 0.18); color: var(--cream);
  content-visibility: auto; contain-intrinsic-size: 300px;
  transition: border-color 0.25s ease, transform 0.25s ease;
}
.card:hover { border-color: var(--gold); color: var(--cream); }
.card-media { display: block; aspect-ratio: 4 / 5; overflow: hidden; background: #1c1813; }
.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.5s ease; }
.card-body { display: flex; flex-direction: column; flex: 1; padding: 9px 10px 11px; }
.card-name {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-family: 'Marcellus', serif; font-size: 15px; line-height: 1.3;
}
.card-meta {
  display: block; margin-top: 3px; font-size: 10.5px; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-price { display: block; margin-top: auto; padding-top: 8px; font-size: 14px; font-weight: 500; color: var(--gold-l); }

.empty { padding: 40px 10px; text-align: center; color: var(--muted); font-weight: 300; line-height: 1.6; }

/* ---------- Modal de producto (hoja inferior en móvil) ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.72); }
.modal-sheet {
  position: relative; width: 100%; max-height: 94%;
  background: var(--ink-2); border-top: 1px solid var(--gold-d);
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}
.m-close {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 46px; height: 46px; display: flex; align-items: center; justify-content: center;
  background: rgba(13, 12, 10, 0.85); border: 1px solid var(--line); color: var(--gold-l); cursor: pointer;
}
.m-close:hover { color: var(--ink); background: var(--gold); }
.m-media { aspect-ratio: 16 / 10; max-height: 42vh; background: #1c1813; }
.m-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.m-body { padding: 16px; }
.m-head { display: flex; align-items: center; gap: 14px; }
.m-head img { width: 44px; height: 78px; object-fit: cover; border: 1px solid var(--line); flex: none; }
.m-nombre { font-family: 'Marcellus', serif; font-weight: 400; font-size: 23px; line-height: 1.2; }
.m-meta { margin-top: 4px; font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); }
.m-precio { margin-top: 13px; font-size: 25px; color: var(--gold-l); font-weight: 500; }
.m-iva { font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); font-weight: 300; }
.m-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 15px; }

/* ---------- Toast y FAB ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(90px + env(safe-area-inset-bottom, 0px)); z-index: 70;
  background: var(--gold); color: var(--ink); padding: 10px 18px;
  font-size: 14px; letter-spacing: 1px;
}
.wa-fab {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 50;
  width: 56px; height: 56px; border-radius: 50%; background: #25D366;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
.wa-fab:hover { background: #1ebe5b; }

/* ============================================================
   Pantallas medianas y grandes
   ============================================================ */
@media (min-width: 640px) {
  .card-media { aspect-ratio: 3 / 4; }
  .cbar { padding: 12px 28px; }
  .cbar-logo img { height: 46px; }
  .chero { padding: 40px 28px 20px; }
  .chero-sub { font-size: 16px; }
  .filters { padding: 0 28px 12px; }
  .tool-row { max-width: 620px; }
  .seg-bar { padding: 10px 28px; }
  .seg { flex: 1 1 auto; min-width: 0; }
  .seg-btn { flex: 0 0 auto; padding: 8px 18px; font-size: 13px; letter-spacing: 1px; }
  .count { display: block; margin-left: auto; flex: none; }
  main { padding-left: 28px; padding-right: 28px; }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .card-body { padding: 10px 12px 12px; }
  .card-meta { font-size: 11px; }
  .card-price { font-size: 15px; }
}

@media (min-width: 900px) {
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .card-name { font-size: 17px; }
  .modal { align-items: center; padding: 24px; }
  .modal-sheet { max-width: 880px; max-height: 100%; border: 1px solid var(--line); display: grid; grid-template-columns: 1.15fr 1fr; padding-bottom: 0; }
  .m-media { aspect-ratio: auto; max-height: none; height: 100%; min-height: 420px; }
  .m-body { padding: 26px 26px 26px 22px; align-self: center; }
  .m-nombre { font-size: 26px; }
  .m-precio { font-size: 27px; }
  .m-actions { flex-direction: row; }
  .m-actions .btn-gold { flex: 1; }
}

@media (min-width: 1200px) {
  .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

@media (hover: hover) {
  .card:hover .card-media img { transform: scale(1.05); }
  .card:hover { transform: translateY(-3px); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- SKU en tarjeta ---------- */
.card-sku {
  display: block; margin-top: 4px;
  font-size: 10px; letter-spacing: 1.5px; color: #6f6656;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- Datos técnicos en la ficha ---------- */
.m-specs {
  margin: 16px 0 0; padding: 14px 0 0;
  border-top: 1px solid var(--line);
  display: grid; gap: 10px;
}
.m-spec { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; }
.m-spec dt {
  margin: 0; font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted);
  white-space: nowrap;
}
.m-spec dd {
  margin: 0; font-size: 15px; color: var(--cream); text-align: right; min-width: 0;
}
