/* =========================================================
   CATÁLOGO — hoja de estilos base
   Paleta y tipografía pensadas como un catálogo impreso
   digitalizado: papel, tinta, hairlines, sin sombras genéricas.
   ========================================================= */

:root {
  --paper: #f5f4f0;
  --paper-raised: #fbfaf7;
  --ink: #1d2b33;
  --ink-muted: #5b6b72;
  --line: #d9d4c7;
  --accent: #b7862c;
  --accent-ink: #1d2b33;
  --danger: #8a3b2f;

  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", "Courier New", monospace;

  --max-width: 1200px;
  --radius: 3px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
}

button {
  font-family: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Encabezado ---------- */

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--paper-raised);
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 0;
}

.brand {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.brand span {
  color: var(--accent);
}

.search-field {
  flex: 1;
  max-width: 420px;
  position: relative;
}

.search-field input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  font-size: 0.95rem;
}

.search-field input::placeholder {
  color: var(--ink-muted);
}

.search-field svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  stroke: var(--ink-muted);
  pointer-events: none;
}

.result-count {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--ink-muted);
  white-space: nowrap;
}

/* ---------- Navegación de categorías ---------- */

.category-nav {
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  overflow-x: auto;
}

.category-nav__inner {
  display: flex;
  gap: 4px;
  padding: 4px 24px;
}

.category-nav button {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  padding: 12px 14px;
  font-size: 0.92rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.category-nav button:hover {
  color: var(--ink);
}

.category-nav button[aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ---------- Intro de sección ---------- */

.catalog-intro {
  padding: 40px 0 8px;
}

.catalog-intro h1 {
  font-family: var(--serif);
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  font-weight: 500;
  margin: 0 0 8px;
  max-width: 46ch;
}

.catalog-intro p {
  color: var(--ink-muted);
  max-width: 60ch;
  margin: 0;
}

/* ---------- Grid de productos ---------- */

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  margin: 32px 0 64px;
}

.product-card {
  background: var(--paper-raised);
  display: flex;
  flex-direction: column;
  text-align: left;
  border: none;
  padding: 0;
  cursor: pointer;
  color: inherit;
  position: relative;
}

.product-card__media {
  aspect-ratio: 1 / 1;
  overflow: hidden;
  position: relative;
  background: var(--line);
}

.product-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.25s ease;
}

.product-card:hover .product-card__media img {
  transform: scale(1.03);
}

.product-card__badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: var(--radius);
  font-weight: 600;
}

.product-card__badge--agotado {
  background: var(--ink);
  color: var(--paper-raised);
}

.product-card__body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.product-card__sku {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.product-card__name {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.3;
  margin: 2px 0 0;
}

.product-card__category {
  font-size: 0.82rem;
  color: var(--ink-muted);
}

.product-card__price {
  margin-top: auto;
  padding-top: 10px;
  font-family: var(--mono);
  font-size: 0.98rem;
  font-weight: 600;
}

/* ---------- Estado vacío ---------- */

.empty-state {
  padding: 80px 24px;
  text-align: center;
  color: var(--ink-muted);
}

.empty-state h2 {
  font-family: var(--serif);
  color: var(--ink);
  font-weight: 500;
  margin-bottom: 8px;
}

.empty-state button {
  margin-top: 16px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  padding: 10px 18px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
}

.empty-state button:hover {
  background: var(--ink);
  color: var(--paper-raised);
}

/* ---------- Modal de producto ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(29, 43, 51, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  background: var(--paper-raised);
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.modal__media {
  background: var(--line);
  aspect-ratio: 1 / 1;
}

.modal__body {
  padding: 28px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--ink-muted);
  font-size: 1.3rem;
  line-height: 1;
  padding: 4px;
}

.modal__close:hover {
  color: var(--ink);
}

.modal__sku {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.modal__name {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 500;
  margin: 4px 0 0;
}

.modal__category {
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.modal__desc {
  margin: 6px 0 4px;
  color: var(--ink);
}

.modal__price {
  font-family: var(--mono);
  font-size: 1.3rem;
  font-weight: 600;
  margin-top: 6px;
}

.modal__stock {
  font-size: 0.85rem;
}

.modal__stock--ok {
  color: #2f5233;
}

.modal__stock--no {
  color: var(--danger);
}

.modal__cta {
  margin-top: 12px;
  align-self: flex-start;
  background: var(--ink);
  color: var(--paper-raised);
  border: none;
  padding: 12px 22px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.92rem;
}

.modal__cta:hover {
  background: var(--accent);
  color: var(--accent-ink);
}

.modal__cta:disabled {
  background: var(--line);
  color: var(--ink-muted);
  cursor: not-allowed;
}

@media (max-width: 640px) {
  .modal {
    grid-template-columns: 1fr;
  }
  .site-header__inner {
    flex-wrap: wrap;
  }
  .search-field {
    order: 3;
    max-width: none;
    width: 100%;
  }
}

/* ---------- Pie de página ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  padding: 28px 0;
  color: var(--ink-muted);
  font-size: 0.85rem;
}
