/* =========================================================
   5OCHO · Catálogo — hoja de estilos
   Dirección: "banco de pruebas". Azul noche + placa perforada,
   cian de marca solo para acción y estado.
   Cumple la CSP de _headers: sin estilos en línea ni fuentes externas.
   ========================================================= */

/* ---------- 1. Tokens ---------- */
:root {
  /* Marca */
  --brand: #24d8ff;
  --brand-strong: #08b5ef;
  --on-brand: #04202a;
  --accent: #24d8ff;          /* cian usado como texto */
  --focus: #24d8ff;

  /* Superficies (oscuro por defecto) */
  --bg: #0a1017;
  --surface: #111a24;
  --surface-2: #16222e;
  --line: #233140;
  --line-strong: #364b5f;
  --text: #e9f0f6;
  --muted: #98a7b6;
  --plate: #e9eef2;           /* placa clara donde se apoya la foto del producto */
  --backdrop: rgba(4, 9, 14, .74);
  --shadow: 0 18px 44px rgba(0, 0, 0, .38);

  /* Estado */
  --ok: #5dd39e;
  --warn: #f2b84b;
  --bad: #ff8a8a;

  /* Tipografía: solo fuentes del sistema (la CSP no permite fuentes externas) */
  /* Inter se declara primero como preferencia visual; no se carga como web font
     porque la CSP no permite fuentes externas. El navegador usará el siguiente
     fallback disponible (Segoe UI en Windows, system-ui en Mac/Linux). */
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;

  /* Radios con jerarquía: controles < tarjetas < diálogos */
  --r-control: 8px;
  --r-card: 12px;
  --r-dialog: 16px;

  color-scheme: dark;
}

:root[data-theme="light"] {
  --accent: #0a7f98;
  --focus: #0a7f98;
  --bg: #f2f5f8;
  --surface: #ffffff;
  --surface-2: #f6f8fa;
  --line: #dbe3ea;
  --line-strong: #c1cdd8;
  --text: #14202b;
  --muted: #566677;
  --plate: #f1f4f7;
  --backdrop: rgba(10, 20, 30, .55);
  --shadow: 0 14px 34px rgba(16, 24, 32, .12);
  --ok: #1d7a4d;
  --warn: #8f5d06;
  --bad: #b3261e;
  color-scheme: light;
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.skip-link { position: absolute; top: -100px; left: 16px; z-index: 100; padding: 10px 16px; background: var(--brand); color: var(--on-brand); font-weight: 700; border-radius: var(--r-control); text-decoration: none; transition: top .15s ease-out; }
.skip-link:focus-visible { top: 14px; }
main:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.noscript-message { margin: 16px; padding: 14px; border: 1px solid var(--line-strong); border-radius: var(--r-control); color: var(--text); background: var(--surface); }

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

.wrap {
  width: 100%;
  max-width: 1320px;
  margin-inline: auto;
  padding-inline: clamp(16px, 3vw, 40px);
}

/* ---------- 3. Encabezado ---------- */
.top { background: var(--bg); border-bottom: 1px solid var(--line); }
.nav { min-height: 68px; display: flex; align-items: center; gap: 20px; }

.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.logo-img { display: block; width: auto; height: 44px; object-fit: contain; mix-blend-mode: screen; }
:root[data-theme="light"] .logo-img { mix-blend-mode: normal; background: #101820; border-radius: 8px; }
.brand-copy { display: flex; flex-direction: column; font-size: 15px; font-weight: 700; letter-spacing: -.01em; line-height: 1.2; }
.brand small { font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0; }

.nav-note { order: 2; margin-right: auto; color: var(--muted); font-size: 13px; }
.social-links { order: 3; display: flex; align-items: center; gap: 8px; margin-left: auto; }

.social-link {
  height: 40px; display: inline-flex; align-items: center; gap: 8px;
  padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: var(--r-control);
  background: transparent; color: var(--text);
  font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap;
  transition: border-color .15s, background .15s;
}
.social-link:hover { border-color: var(--accent); background: var(--surface); }
.social-link img { width: 22px; height: 22px; object-fit: contain; }
.social-link.instagram img { border-radius: 5px; }
:root[data-theme="light"] .social-link img,
:root[data-theme="light"] .cart-icon { background: #101820; border-radius: 50%; padding: 3px; }
:root[data-theme="light"] .social-link.instagram img { border-radius: 6px; }

/* ---------- 4. Hero: titular grande sobre placa perforada ---------- */
.hero { position: relative; overflow: hidden; padding: 34px 0 30px; border-bottom: 1px solid var(--line); }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 460px); gap: 56px; align-items: center; }
.hero h1 { margin: 0 0 14px; font-size: clamp(36px, 5.4vw, 60px); line-height: 1.02; font-weight: 800; letter-spacing: -.045em; }
.hero h1 br { display: none; }
.hero p { margin: 0; max-width: 46ch; color: var(--muted); font-size: 16px; }
.hero-stat { max-width: 300px; margin-top: 24px; padding-left: 18px; border-left: 2px solid var(--brand); }

/* Vitrina: tres productos reales sobre placa clara (decorativa; la compra ocurre en las tarjetas) */
.hero-shelf { display: grid; grid-template-columns: 1.5fr 1fr; grid-template-rows: 1fr 1fr; gap: 12px; height: 252px; }
.shelf-item { display: grid; place-items: center; min-width: 0; padding: 10px; background: var(--plate); border-radius: var(--r-card); overflow: hidden; }
.shelf-item:first-child { grid-row: 1 / 3; padding: 16px; }
.shelf-item img { display: block; width: 100%; height: 100%; object-fit: contain; mix-blend-mode: multiply; }
.hero-stat strong { display: block; font-size: 18px; letter-spacing: -.02em; }
.hero-stat span { display: block; margin-top: 4px; color: var(--muted); font-size: 14px; }

/* ---------- 5. Barra de herramientas ---------- */
.toolbar {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.toolbar-sentinel { height: 1px; margin-bottom: -1px; }
.tools { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.search { position: relative; flex: 1 1 320px; max-width: 480px; min-width: 0; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input,
.sort {
  height: 44px; width: 100%;
  border: 1px solid var(--line-strong); border-radius: var(--r-control);
  background-color: var(--surface); color: var(--text);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.search input { padding: 0 14px 0 42px; }
.search input::placeholder { color: var(--muted); }
.search input:focus, .sort:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
.sort { flex: 0 1 230px; width: auto; padding: 0 38px 0 14px; }

.tools-right { display: flex; align-items: center; justify-content: flex-end; gap: 14px; margin-left: auto; }
.count { color: var(--muted); font-size: 13px; white-space: nowrap; }

.cart-trigger {
  height: 44px; display: inline-flex; align-items: center; gap: 8px;
  padding: 0 12px 0 8px;
  border: 1px solid var(--line-strong); border-radius: var(--r-control);
  background: var(--surface); color: var(--text);
  font-weight: 700; white-space: nowrap;
  transition: border-color .15s;
}
.cart-trigger:hover { border-color: var(--brand); }
.cart-icon { width: 30px; height: 30px; display: block; object-fit: contain; flex: 0 0 auto; }
.cart-trigger span#cartCount {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 999px; background: var(--brand); color: var(--on-brand);
  font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums;
}

.filters {
  position: relative; display: flex; gap: 8px; padding: 0 0 12px;
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none; overscroll-behavior-x: contain;
}
.filters::-webkit-scrollbar { display: none; }
.filter-indicator { display: none; }
.filters.has-indicator .filter-indicator {
  display: block; position: absolute; z-index: 0; top: 0; left: 0;
  width: var(--filter-indicator-width, 0px); height: 36px;
  border-radius: var(--r-control); background: var(--brand);
  transform: translateX(var(--filter-indicator-x, 0px)); pointer-events: none;
}
.filter {
  flex: 0 0 auto; height: 36px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--r-control);
  background: transparent; color: var(--muted);
  font-size: 13px; font-weight: 600; white-space: nowrap;
  transition: border-color .15s, color .15s;
}
.filters.has-indicator .filter { position: relative; z-index: 1; }
.filters.has-indicator .filter.active { background: transparent; border-color: transparent; color: var(--on-brand); }
.filter:hover { border-color: var(--line-strong); color: var(--text); }
.filter.active { background: var(--brand); border-color: var(--brand); color: var(--on-brand); font-weight: 700; }

/* ---------- 6. Listado ---------- */
main { padding: 26px 0 72px; }
.section-head { margin: 0 0 18px; }
.section-head h2 { margin: 0; font-size: 22px; letter-spacing: -.03em; }
.section-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.stock-disclaimer { font-size: 13px !important; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 16px; align-items: stretch; }
/* Reserva altura antes de que app.js dibuje las tarjetas: evita que el pie de página salte (CLS). */
.grid:empty { min-height: 100vh; }

/* Tarjeta: foto a sangre arriba, marca/categoría en una línea, precio como protagonista */
.card {
  min-width: 0; overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto auto auto 1fr auto;
  grid-template-areas:
    "img img"
    "maker cat"
    "title title"
    "desc desc"
    "meta meta"
    "bottom bottom";
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-card);
  transition: border-color .15s;
}
.card:hover { border-color: var(--line-strong); }

.product-image {
  grid-area: img; position: relative;
  display: grid; place-items: center;
  width: 100%; aspect-ratio: 3 / 2; padding: 14px;
  border: 0; border-radius: 0; background: var(--plate);
  overflow: hidden; cursor: pointer;
}
.product-image img { display: block; width: 100%; height: 100%; object-fit: contain; mix-blend-mode: multiply; }
.view-product {
  position: absolute; right: 10px; bottom: 10px;
  padding: 6px 10px; border-radius: 6px;
  background: rgba(10, 16, 23, .88); color: #fff;
  font-size: 12px; font-weight: 600;
  opacity: 0; transition: opacity .15s;
}
.product-open:hover .view-product,
.product-open:focus-visible .view-product { opacity: 1; }

.maker { grid-area: maker; padding: 14px 0 0 16px; font-size: 13px; font-weight: 700; color: var(--text); min-width: 0; }
.card-top { grid-area: cat; display: flex; flex-direction: row-reverse; align-items: center; gap: 6px; padding: 14px 16px 0 8px; min-width: 0; }
.category { color: var(--muted); font-size: 12px; font-weight: 500; white-space: nowrap; }
.glyph { display: grid; place-items: center; width: 18px; height: 18px; color: var(--accent); }
.glyph svg { display: block; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.card h3 { grid-area: title; margin: 4px 0 0; padding: 0 16px; font-size: 16px; line-height: 1.25; font-weight: 650; letter-spacing: -.015em; overflow-wrap: anywhere; }
.product-title-link { max-width: 100%; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; letter-spacing: inherit; }
.product-title-link:hover { color: var(--accent); }

.desc {
  grid-area: desc; margin: 0; padding: 6px 16px 0;
  color: var(--muted); font-size: 13px; line-height: 1.5; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.product-meta { grid-area: meta; margin: 0; padding: 8px 16px 0; color: var(--muted); font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.product-meta span { color: var(--text); font-weight: 650; }

.card-bottom {
  grid-area: bottom; margin: 14px 16px 16px; padding-top: 12px;
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px 10px; align-items: end;
}
.product-purchase-row { display: contents; }

.price { grid-column: 1; grid-row: 1; min-width: 0; font-size: 24px; line-height: 1.1; font-weight: 800; letter-spacing: -.035em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.price small { display: block; margin-bottom: 3px; color: var(--muted); font-size: 11px; font-weight: 500; letter-spacing: 0; }

.quantity-control {
  grid-column: 2; grid-row: 1;
  display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 4px 8px;
  color: var(--muted); font-size: 12px; font-weight: 500;
}
.qty-input, .modal-qty input {
  width: 56px; height: 34px; padding: 0 6px;
  border: 1px solid var(--line-strong); border-radius: var(--r-control);
  background: var(--bg); color: var(--text);
  text-align: center; font-variant-numeric: tabular-nums;
  -moz-appearance: textfield; appearance: textfield;
}
.qty-input::-webkit-inner-spin-button, .qty-input::-webkit-outer-spin-button,
.modal-qty input::-webkit-inner-spin-button, .modal-qty input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.qty-input:disabled { opacity: .5; }

.stock-availability, .modal-stock {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--ok); font-size: 12px; font-weight: 650; white-space: nowrap;
}
.stock-availability { flex-basis: 100%; justify-content: flex-end; margin: 0; }
.stock-availability::before, .modal-stock::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: 0 0 7px; }
.stock-availability.last, .modal-stock.last { color: var(--warn); }
.stock-availability.out, .modal-stock.out { color: var(--bad); }

.card-actions { grid-column: 1 / -1; grid-row: 2; display: grid; grid-template-columns: 1.35fr 1fr; gap: 8px; min-width: 0; }
.card-actions button, .modal-actions button {
  min-width: 0; min-height: 42px; padding: 8px 10px;
  border-radius: var(--r-control);
  font-size: 13px; font-weight: 700; line-height: 1.2; text-align: center;
  transition: background .15s, border-color .15s, color .15s;
}
.ask { display: inline-grid; place-items: center; border: 1px solid var(--brand); background: var(--brand); color: var(--on-brand); }
.ask-label, .ask-added { grid-area: 1 / 1; white-space: nowrap; }
.ask-added { opacity: 0; }
.ask.is-added .ask-label { opacity: 0; }
.ask.is-added .ask-added { opacity: 1; }
.ask:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.consult { border: 1px solid var(--line-strong); background: transparent; color: var(--text); }
.consult:hover { border-color: var(--accent); color: var(--accent); }
.ask:disabled { background: var(--surface-2); border-color: var(--line); color: var(--muted); cursor: not-allowed; opacity: .7; }

.empty { grid-column: 1 / -1; padding: 56px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--r-card); }
.empty strong { display: block; margin-bottom: 6px; color: var(--text); font-size: 18px; }

.footer { background: var(--bg); border-top: 1px solid var(--line); padding: 30px 0; }
.footer-content { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 1.2fr) auto; gap: 24px; align-items: start; }
.footer-brand p { margin: 0 0 6px; color: var(--muted); font-size: 13px; }
.footer-brand strong { color: var(--text); font-size: 14px; }
.footer-brand .usd { color: var(--accent); font-weight: 600; }
.company-details h2 { margin: 0 0 8px; font-size: 14px; }
.company-details address { display: grid; gap: 4px; color: var(--muted); font-size: 13px; font-style: normal; }
.company-details a, .footer-links a { color: var(--accent); text-underline-offset: 2px; }
.footer-links { display: grid; gap: 8px; font-size: 13px; }
.legal-top { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.legal-home-link, .legal-footer-links a { color: var(--text); font-size: 14px; font-weight: 650; text-underline-offset: 3px; }
.legal-home-link:hover, .legal-footer-links a:hover { color: var(--accent); }
.legal-footer-links { display: flex; flex-wrap: wrap; gap: 18px; }
.order-confirmation-notice { margin: 0 0 14px; padding: 10px 12px; border: 1px solid var(--line-strong); border-left: 3px solid var(--accent); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 13px; font-weight: 650; }
.order-consent-links { display: block; margin-top: 5px; font-size: 13px; }
.order-consent-links a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.shipping-confirmation-notice { margin-bottom: 14px; }
.legal-content { padding-top: 32px; padding-bottom: 60px; max-width: 960px; }
.legal-content h1 { margin: 0 0 12px; font-size: clamp(28px, 5vw, 42px); letter-spacing: -.03em; }
.legal-content h2 { margin: 28px 0 8px; font-size: 20px; }
.legal-content p, .legal-content li { color: var(--muted); line-height: 1.65; }
.legal-content a { color: var(--accent); text-underline-offset: 2px; }
.legal-notice { padding: 12px 14px; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 8px; background: var(--surface); }
.faq-list { display: grid; gap: 12px; margin-top: 24px; }
.faq-item { padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); }
.faq-item h2 { margin: 0 0 6px; font-size: 17px; }
.faq-item p { margin: 0; }


/* ---------- 7. Formularios ---------- */
.field-group { display: grid; gap: 5px; }
.field-group label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field-group input, .field-group select {
  width: 100%; max-width: 100%; height: 42px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: var(--r-control);
  background-color: var(--bg); color: var(--text);
  font-size: 14px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field-group input::placeholder { color: var(--muted); opacity: .8; }
.field-group input:focus, .field-group select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
.field-group input:disabled, .field-group select:disabled { opacity: .55; cursor: not-allowed; }

/* Estado de error: se marca el campo que falta o está mal, no solo el aviso del navegador.
   .was-validated lo agrega app.js cuando un intento de envío falla. */
.was-validated .field-group :is(input, select):invalid { border-color: var(--bad); }
.was-validated .field-group :is(input, select):invalid:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 25%, transparent); }
.split-field { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 10px; min-width: 0; }
.split-field > select, .split-field > input { min-width: 0; }
.split-field > select { text-align: center; padding: 0 24px 0 8px; }

/* Flecha de los select dibujada con degradados: sigue al tema sin SVG por tema */
.sort, .field-group select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 19px) 52%, calc(100% - 14px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  text-overflow: ellipsis;
}
.field-group select { padding-right: 34px; }
select option { background: var(--surface); color: var(--text); }

.agency-help { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.agency-notice {
  padding: 9px 12px; border: 1px dashed var(--line-strong); border-radius: var(--r-control);
  color: var(--muted); font-size: 12px; line-height: 1.45;
}
.agency-notice a { color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }

.delivery-fields, .shipping-dialog fieldset { display: grid; gap: 10px; min-width: 0; margin: 0; padding: 0; border: 0; }
.delivery-form { display: grid; gap: 10px; }
.delivery-form.hidden { display: none; }

/* ---------- 8. Carrito (diálogo centrado) ---------- */
.cart-layer {
  position: fixed; inset: 0; z-index: 20;
  width: 100vw; height: 100dvh; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0;
  background: transparent; color: inherit;
  display: none; align-items: center; justify-content: center;
}
.cart-layer[open], .cart-layer.open { display: flex; }
.cart-layer::backdrop { background: var(--backdrop); }

.cart-panel {
  width: min(980px, calc(100vw - 40px)); height: min(780px, calc(100dvh - 48px));
  display: flex; flex-direction: column; overflow-x: hidden; overflow-y: auto;
  overscroll-behavior: contain; scroll-padding: 72px 0 220px;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-dialog);
  box-shadow: var(--shadow); outline: none;
}
.cart-head {
  position: sticky; top: 0; z-index: 5; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.cart-head h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.cart-head-copy { min-width: 0; }
.cart-intro { margin: 3px 0 0; color: var(--muted); font-size: 13px; line-height: 1.35; }
.cart-content { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); align-items: start; }
.cart-order-step, .cart-delivery-step { min-width: 0; }
.cart-order-step { border-right: 1px solid var(--line); }
.cart-list { display: grid; align-content: start; gap: 10px; padding: 18px 20px 24px; }
.cart-item-motion { display: grid; grid-template-rows: 1fr; min-width: 0; }
.cart-item-motion-inner { min-height: 0; overflow: hidden; }
.cart-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.cart-item-product { display: grid; grid-template-columns: 48px minmax(0, 1fr); align-items: center; gap: 10px; min-width: 0; }
.cart-item-image { display: block; width: 48px; height: 48px; padding: 3px; border-radius: 6px; background: var(--plate); object-fit: contain; }
.cart-item-copy { min-width: 0; }
.cart-item strong { font-size: 14px; line-height: 1.3; }
.cart-item small { display: block; margin-top: 4px; color: var(--muted); font-variant-numeric: tabular-nums; }
.qty { display: flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.qty button { width: 34px; height: 34px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line-strong); border-radius: var(--r-control); background: var(--surface-2); color: var(--text); font-size: 18px; line-height: 1; }
.qty button:disabled { opacity: .4; cursor: not-allowed; }
.cart-empty { display: grid; justify-items: center; gap: 12px; padding: 28px 16px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line-strong); border-radius: 10px; }
.cart-empty p { margin: 0; }
.cart-empty-continue { min-height: 44px; padding: 9px 16px; border: 1px solid var(--line-strong); border-radius: var(--r-control); background: var(--surface-2); color: var(--text); font-weight: 700; }
.cart-panel.is-empty .cart-delivery-step,
.cart-panel.is-empty .cart-summary { display: none; }
.cart-panel.is-empty .cart-order-step { border: 0; }

.delivery-section { min-width: 0; margin: 0; padding: 18px 20px 24px; }
.delivery-title { margin: 0 0 10px; font-size: 14px; font-weight: 700; }
.delivery-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 14px; padding: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.delivery-tab { height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: var(--r-control); background: transparent; color: var(--muted); font-size: 13px; font-weight: 650; transition: background .15s, color .15s; }
.delivery-icon { width: 16px; height: 16px; flex: 0 0 16px; }
.delivery-tab.active { background: var(--brand); color: var(--on-brand); font-weight: 750; }

.cart-summary {
  position: sticky; bottom: 0; z-index: 4; flex: 0 0 auto; margin-top: 0;
  padding: 16px 20px calc(16px + env(safe-area-inset-bottom, 0px));
  background: var(--surface); border-top: 1px solid var(--line);
}
.cart-total-value { font-variant-numeric: tabular-nums; }
.cart-unified-summary { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 300px); gap: 10px 24px; align-items: center; }
.cart-unified-summary .cart-total { grid-column: 1; margin: 0; }
.cart-unified-summary .checkout { grid-column: 2; }
.cart-total { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0; font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.order-consent { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 10px; align-items: start; margin: 18px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.order-consent input { width: 20px; height: 20px; margin: 0; accent-color: var(--brand); cursor: pointer; }
.order-consent .order-consent-text { display: block; margin-top: 3px; }
.order-consent label { color: var(--text); cursor: pointer; }
.order-consent a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.was-validated .order-consent input:invalid,
.order-consent.has-error input { outline: 2px solid var(--bad); outline-offset: 2px; }
.checkout { width: 100%; min-height: 48px; padding: 12px; border: 0; border-radius: 10px; background: var(--brand); color: var(--on-brand); font-size: 15px; font-weight: 800; transition: background .15s; }
.checkout:hover { background: var(--brand-strong); }
.checkout[aria-disabled="true"] {
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--muted);
  cursor: not-allowed;
}
.checkout[aria-disabled="true"]:hover { background: var(--surface-2); }
.checkout[aria-disabled="false"] { cursor: pointer; }

.cart-close, .modal-close {
  display: grid; place-items: center; width: 38px; height: 38px; padding: 0;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font-size: 22px; line-height: 1;
}
.cart-close:hover, .modal-close:hover { border-color: var(--accent); color: var(--accent); }
.close-icon { display: block; width: 14px; height: 14px; }

/* ---------- 9. Formulario de envío independiente ---------- */
.shipping-dialog {
  width: min(560px, calc(100% - 24px)); max-height: min(90vh, 820px); overflow: auto;
  padding: 22px; border: 1px solid var(--line); border-radius: var(--r-dialog);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.shipping-dialog::backdrop { background: var(--backdrop); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.shipping-dialog-head { position: relative; margin-bottom: 18px; padding-right: 48px; }
.shipping-dialog-head h2 { margin: 2px 0 6px; font-size: 22px; letter-spacing: -.025em; }
.shipping-dialog-head p { margin: 0; color: var(--muted); font-size: 14px; }
.shipping-dialog .modal-close { position: absolute; top: 0; right: 0; }
.shipping-dialog form { display: grid; gap: 12px; }
.shipping-dialog .shipping-submit { margin-top: 4px; }

/* ---------- 10. Detalle de producto (modal) ---------- */
.product-modal {
  width: 100vw; height: 100dvh; max-width: none; max-height: none;
  margin: 0; padding: 20px; border: 0;
  background: transparent; color: inherit;
}
.product-modal[open] { display: flex; align-items: center; justify-content: center; }
.product-modal::backdrop { background: var(--backdrop); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.product-dialog {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .95fr);
  width: min(960px, 100%); max-height: min(88vh, 780px); overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-dialog);
  box-shadow: var(--shadow);
}
.modal-close { position: absolute; z-index: 2; top: 14px; right: 14px; }
.modal-photo { display: grid; place-items: center; min-height: 460px; padding: 32px; background: var(--plate); }
.modal-photo img { display: block; width: 100%; height: 100%; max-height: 520px; object-fit: contain; mix-blend-mode: multiply; }
.modal-info { padding: 36px 32px 32px; }
.modal-category { color: var(--accent); font-size: 13px; font-weight: 600; }
.modal-brand { margin: 14px 0 4px; color: var(--muted); font-size: 13px; font-weight: 600; }
.modal-info h2 { margin: 0; font-size: clamp(24px, 3vw, 34px); line-height: 1.1; letter-spacing: -.035em; }
.modal-price { margin: 16px 0 6px; font-size: 32px; font-weight: 800; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.modal-info h3 { margin: 22px 0 8px; font-size: 14px; }
.modal-features li::first-letter { text-transform: uppercase; }
.modal-features { margin: 0; padding-left: 18px; color: var(--muted); font-size: 14px; line-height: 1.7; }
.modal-buy { margin-top: 22px; padding: 16px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
.modal-qty { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; color: var(--muted); font-size: 13px; font-weight: 600; }
.modal-actions { display: grid; grid-template-columns: 1.35fr 1fr; gap: 8px; }

/* ---------- 11. Aviso (toast) y estados globales ---------- */
.notice-toast {
  position: fixed; left: 50%; bottom: 20px; z-index: 60;
  max-width: min(92vw, 520px); padding: 12px 16px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: var(--shadow);
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  transition: opacity .18s, transform .18s;
}
.notice-toast.visible { opacity: 1; transform: translate(-50%, 0); }
.has-open-dialog { position: fixed; top: var(--locked-scroll-top, 0); left: 0; right: 0; width: 100%; overflow: hidden; }

/* Tablet vertical: prioriza el ancho útil para productos y formulario. */
@media (max-width: 900px) {
  .cart-content { grid-template-columns: minmax(0, 1fr); }
  .cart-order-step { border-right: 0; border-bottom: 1px solid var(--line); }
}

/* Ventanas bajas, incluido el teléfono en horizontal: todo el panel desplaza. */
@media (max-height: 520px) and (min-width: 601px) {
  .cart-panel { width: 100vw; height: 100%; max-height: 100%; border-radius: 0; }
  .cart-head { padding: 8px 14px; }
  .cart-head h2 { font-size: 18px; }
  .cart-summary { position: static; }
}

/* ---------- 12. Tablet ---------- */
@media (max-width: 850px) {
  .nav-note { display: none; }
  .hero-grid { grid-template-columns: 1fr; }
  .hero-shelf { display: none; }
  .hero-stat { max-width: none; }
  .tools { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .search { grid-column: 1 / -1; max-width: none; }
  .sort { grid-column: 1; width: 100%; flex: none; }
  .tools-right { grid-column: 2; }
  .product-dialog { grid-template-columns: 1fr; }
  .modal-photo { min-height: 0; height: 36vh; padding: 20px; }
}

/* ---------- 13. Móvil ---------- */
@media (max-width: 600px) {
  .wrap { padding-inline: 14px; }

  .cart-layer {
    top: var(--cart-visual-top, 0px); bottom: auto;
    height: var(--cart-visual-height, 100dvh);
  }

  /* Encabezado: iconos de 40 px, nombre accesible conservado */
  .nav { flex-wrap: nowrap; gap: 10px; min-height: 60px; }
  .logo-img { height: 34px; }
  .brand { gap: 8px; min-width: 0; }
  .brand small { display: none; }
  .social-links { gap: 6px; }
  .social-link { width: 40px; height: 44px; padding: 0; justify-content: center; }
  .social-link span {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }

  .hero { padding: 28px 0 24px; }
  .hero h1 { font-size: 36px; margin-bottom: 10px; }
  .hero h1 br { display: inline; }
  .hero p { font-size: 15px; }
  .hero-stat { padding-left: 14px; }
  .hero-stat strong { font-size: 16px; }
  .hero-stat span { font-size: 13px; }

  /* La barra deja de ser fija (ocupaba ~25 % de la pantalla); el carrito pasa a botón flotante */
  .toolbar { position: static; -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--bg); }
  .tools { gap: 8px; padding: 12px 0 10px; }
  .search input, .sort { height: 46px; font-size: 16px; } /* 16 px evita el zoom de iOS al enfocar */
  .tools-right { gap: 0; }
  .count { font-size: 13px; }
  .filters { margin-inline: -14px; padding: 0 14px 12px; }
  .filter { position: relative; height: 44px; }
  .filters.has-indicator .filter-indicator { height: 44px; }
  .card h3 { position: relative; }
  .product-title-link::after {
    content: ""; position: absolute; left: 0; right: 0; top: 50%;
    height: 44px; transform: translateY(-50%);
  }

  .cart-trigger {
    position: fixed; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); z-index: 15;
    height: 54px; padding: 0 14px 0 10px; border-radius: 14px;
    border-color: color-mix(in srgb, var(--brand) 55%, var(--line-strong));
    box-shadow: var(--shadow);
  }
  .cart-label { display: none; }
  .cart-icon { width: 32px; height: 32px; }

  main { padding: 16px 0 96px; }
  .section-head { margin-bottom: 12px; }
  .grid { grid-template-columns: 1fr; gap: 12px; }

  /* Tarjeta horizontal: foto a la izquierda, datos a la derecha, compra debajo */
  .card {
    grid-template-columns: 116px minmax(0, 1fr) auto;
    grid-template-rows: auto auto 1fr auto auto;
    grid-template-areas:
      "img maker cat"
      "img title title"
      "img desc desc"
      "img meta meta"
      "bottom bottom bottom";
  }
  .product-image { aspect-ratio: auto; height: 100%; min-height: 116px; padding: 8px; }
  .view-product { display: none; }
  .maker { padding: 12px 0 0 12px; font-size: 12.5px; }
  .card-top { padding: 12px 12px 0 8px; }
  .glyph { display: none; }
  .card h3 { padding: 0 12px; font-size: 15px; }
  .desc { padding: 4px 12px 0; font-size: 12.5px; -webkit-line-clamp: 2; }
  .card-bottom { margin: 12px; padding-top: 12px; }
  .price { font-size: 22px; }
  .card-actions button { min-height: 44px; font-size: 14px; }
  .qty-input { width: 52px; height: 36px; font-size: 16px; }

  /* Campos a 16 px: sin zoom involuntario en iOS */
  .field-group input, .field-group select { height: 46px; font-size: 16px; }

  /* El panel completo se desplaza; el cierre y la compra permanecen a la vista. */
  .cart-panel {
    width: 100%; height: 100%; max-height: 100%; border: 0; border-radius: 0;
    overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    scroll-padding: 64px 0 calc(var(--cart-summary-height, 92px) + 16px);
  }
  .cart-head { position: sticky; top: 0; z-index: 4; }
  .cart-content { grid-template-columns: minmax(0, 1fr); }
  .cart-order-step { border-right: 0; border-bottom: 1px solid var(--line); }
  .cart-list { padding: 14px 16px 18px; }
  .delivery-section { padding: 16px; }
  .cart-summary { padding: 5px 12px max(5px, env(safe-area-inset-bottom, 0px)); }
  .cart-unified-summary { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .cart-unified-summary .cart-total,
  .cart-unified-summary .checkout { grid-column: 1; }
  .cart-total { font-size: 16px; line-height: 1.2; }
  .checkout { min-height: 44px; padding: 9px 10px; }
  .cart-panel.is-empty .cart-content { grid-template-columns: minmax(0, 1fr); }
  .shipping-dialog { padding: 18px; border-radius: 14px; }
  .shipping-dialog-head h2 { font-size: 20px; }

  .product-modal { padding: 10px; }
  .product-dialog { max-height: 94vh; border-radius: 14px; }
  .modal-photo { height: 32vh; }
  .modal-info { padding: 20px; }
  .modal-price { font-size: 28px; }
  .modal-qty input { font-size: 16px; }

  .cart-layer .notice-toast { bottom: calc(var(--cart-summary-height, 92px) + 10px); }
  .notice-toast { bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
  .footer-content { grid-template-columns: 1fr; gap: 18px; }
  .footer-links { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .product-meta { padding: 4px 12px 0; font-size: 12px; }
}

@media (pointer: coarse) {
  .cart-close { width: 44px; height: 44px; }
  .qty button { width: 44px; height: 44px; }
}

@media (max-width: 380px) {
  .brand-copy { display: none; }
  /* En pantallas estrechas (360 px) la miniatura de 80 px no deja ver el producto:
     la foto pasa arriba, a todo el ancho, como en escritorio. */
  .card {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto auto auto 1fr auto;
    grid-template-areas:
      "img img"
      "maker cat"
      "title title"
      "desc desc"
      "meta meta"
      "bottom bottom";
  }
  .product-image { aspect-ratio: 3 / 2; height: auto; min-height: 0; padding: 12px; }
}

/* ---------- 14. Movimiento reducido ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* =========================================================
   15. Movimiento
   Solo responde a acciones (filtrar, agregar, abrir) más una
   entrada de hero al cargar. Todo queda desactivado si la
   persona pidió reducir el movimiento.
   ========================================================= */
@keyframes rise     { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes fade     { from { opacity: 0; } to { opacity: 1; } }
@keyframes cardIn   { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes slideIn  { from { transform: translateX(32px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes popIn    { from { opacity: 0; transform: scale(.97) translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes cartPulse{ 0% { transform: scale(1); } 35% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes countPop { 0% { transform: scale(1); } 35% { transform: scale(1.45); } 100% { transform: scale(1); } }

@media (prefers-reduced-motion: no-preference) {
  /* Entrada del hero: una sola vez, escalonada */
  .hero h1        { animation: rise .6s cubic-bezier(.2, .7, .2, 1) both; }
  .hero p         { animation: rise .6s cubic-bezier(.2, .7, .2, 1) .08s both; }
  .hero-stat      { animation: rise .6s cubic-bezier(.2, .7, .2, 1) .16s both; }
  .shelf-item     { animation: rise .7s cubic-bezier(.2, .7, .2, 1) .12s both; }
  .shelf-item:nth-child(2) { animation-delay: .22s; }
  .shelf-item:nth-child(3) { animation-delay: .32s; }

  /* Lista: al filtrar, buscar u ordenar (app.js activa .is-animating solo entonces) */
  .grid.is-animating .card { animation: cardIn .28s cubic-bezier(.2, .7, .2, 1) both; }
  .grid.is-animating .card:nth-child(2) { animation-delay: 35ms; }
  .grid.is-animating .card:nth-child(3) { animation-delay: 70ms; }
  .grid.is-animating .card:nth-child(4) { animation-delay: 105ms; }
  .grid.is-animating .card:nth-child(5) { animation-delay: 140ms; }
  .grid.is-animating .card:nth-child(6) { animation-delay: 175ms; }
  .grid.is-animating .card:nth-child(7) { animation-delay: 210ms; }
  .grid.is-animating .card:nth-child(n+8) { animation-delay: 245ms; }

  /* Feedback al agregar, filas del carrito y carga de imágenes */
  .ask-label, .ask-added { transition: opacity .18s cubic-bezier(.2, .7, .2, 1); }
  .cart-item-motion { transition: grid-template-rows .18s cubic-bezier(.2, .7, .2, 1), opacity .18s cubic-bezier(.2, .7, .2, 1), transform .18s cubic-bezier(.2, .7, .2, 1); }
  .cart-item-motion.is-entering { opacity: 0; transform: translateY(7px); }
  .cart-item-motion.is-removing { grid-template-rows: 0fr; opacity: 0; transform: translateY(-4px); }
  .cart-item { transition: background .2s ease, border-color .2s ease; }
  .cart-item.is-highlighted { background: color-mix(in srgb, var(--brand) 12%, var(--surface)); border-color: var(--brand); }
  .image-fade-pending { opacity: 0; }
  .image-fade-pending.image-fade-loaded, .image-fade-pending.image-fade-error { opacity: 1; transition: opacity .18s cubic-bezier(.2, .7, .2, 1); }

  /* Sombras y píldora de filtros */
  @media (min-width: 601px) {
    .toolbar { transition: box-shadow .2s cubic-bezier(.2, .7, .2, 1); }
    .toolbar.is-stuck { box-shadow: 0 8px 18px rgba(0, 0, 0, .18); }
  }
  .filters.has-indicator .filter-indicator { transition: transform .24s cubic-bezier(.2, .7, .2, 1), width .24s cubic-bezier(.2, .7, .2, 1); }

  /* La foto de la tarjeta y la del detalle comparten una sola transición */
  ::view-transition-group(product-shared-image) { animation-duration: .28s; animation-timing-function: cubic-bezier(.2, .7, .2, 1); }
  ::view-transition-old(product-shared-image),
  ::view-transition-new(product-shared-image) { height: 100%; object-fit: contain; }

  /* Agregar al carrito: pulso del botón y rebote del contador */
  .cart-trigger.is-bumping { animation: cartPulse .45s cubic-bezier(.2, .7, .2, 1); }
  .cart-trigger.is-bumping #cartCount { animation: countPop .45s cubic-bezier(.2, .7, .2, 1); }

  /* Paneles y modales: solo entrada (la salida es inmediata para no afectar foco ni cierre) */
  .cart-layer[open] .cart-panel,
  .cart-layer.open .cart-panel { animation: popIn .22s cubic-bezier(.2, .8, .2, 1); }
  .cart-layer[open]::backdrop,
  .product-modal[open]::backdrop,
  .shipping-dialog[open]::backdrop { animation: fade .2s ease-out; }
  .product-modal[open] .product-dialog,
  .shipping-dialog[open] { animation: popIn .22s cubic-bezier(.2, .8, .2, 1); }

  /* Microinteracciones */
  .delivery-form:not([hidden]) { animation: fade .22s ease-out; }
  .ask, .consult, .checkout, .filter, .delivery-tab, .cart-trigger, .qty button { transition-property: background, border-color, color, transform; }
  .ask:active:not(:disabled), .consult:active, .checkout:active, .filter:active,
  .delivery-tab:active, .qty button:active:not(:disabled) { transform: scale(.97); }
  .cart-trigger:active { transform: scale(.97); }
}
