/* ============================================================
   NANAI NANAI · components.css
   Biblioteca de componentes reutilizables del Design System.
   Convención: .bloque, .bloque__elemento, .bloque--modificador
   ============================================================ */

/* ============================================================
   1. ÁTOMOS · BOTONES
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.01em;
  line-height: 1;
  padding: 0.85em 1.6em;
  border-radius: var(--radius-button);
  border: 1px solid transparent;
  transition: var(--transition-smooth);
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: translateY(1px); }

/* Primario · dorado de marca */
.btn--primary {
  background: var(--color-brand-primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn--primary:hover {
  background: var(--color-brand-primary-dark);
  box-shadow: var(--shadow-md);
}

/* Primario oscuro · para CTA de máxima jerarquía */
.btn--dark {
  background: var(--color-text-dark);
  color: var(--color-bg-main);
}
.btn--dark:hover { background: #000; box-shadow: var(--shadow-md); }

/* Secundario · píldora fantasma con borde 1px */
.btn--secondary {
  background: transparent;
  color: var(--color-text-dark);
  border-color: var(--color-line-strong);
}
.btn--secondary:hover {
  border-color: var(--color-text-dark);
  background: rgba(38, 33, 30, 0.03);
}

/* Enlace-botón discreto */
.btn--ghost {
  padding-inline: 0.4em;
  background: transparent;
  color: var(--color-text-dark);
}
.btn--ghost:hover { color: var(--color-brand-primary); }

.btn--block { width: 100%; }
.btn--lg { font-size: var(--fs-md); padding: 1.05em 2em; }

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* Ícono dentro de botón */
.btn .icon { width: 1.1em; height: 1.1em; }

/* ============================================================
   2. ÁTOMOS · FORMULARIOS
   ============================================================ */
.field { display: flex; flex-direction: column; gap: var(--space-2); }

.label {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--color-text-dark);
}
.label .req { color: var(--color-danger); }
.field__hint { font-size: var(--fs-xs); color: var(--color-text-muted); }

.input,
.textarea,
.select {
  width: 100%;
  font-size: var(--fs-md);
  color: var(--color-text-dark);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-sm);
  padding: 0.8em 1em;
  transition: var(--transition-fast);
}
.input::placeholder,
.textarea::placeholder { color: var(--color-text-soft); }

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--color-brand-primary);
  box-shadow: 0 0 0 3px var(--color-brand-primary-soft);
}

.textarea { min-height: 120px; resize: vertical; line-height: var(--lh-body); }

/* Variante minimalista con borde inferior */
.input--underline {
  border: 0;
  border-bottom: 1px solid var(--color-line-strong);
  border-radius: 0;
  padding-inline: 0;
  background: transparent;
}
.input--underline:focus { box-shadow: none; border-bottom-color: var(--color-brand-primary); }

/* Select con caret propio */
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%236b635d' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1em center;
  padding-right: 2.6em;
  cursor: pointer;
}

/* Contador de caracteres */
.char-counter {
  align-self: flex-end;
  font-size: var(--fs-xs);
  color: var(--color-text-soft);
  font-variant-numeric: tabular-nums;
}
.char-counter.is-limit { color: var(--color-danger); }

/* ============================================================
   3. ÁTOMOS · PÍLDORAS Y TAGS
   ============================================================ */

/* Píldora seleccionable (adicionales, opciones) */
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--color-text-dark);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-pill);
  padding: 0.55em 1.1em;
  transition: var(--transition-fast);
}
.pill:hover { border-color: var(--color-text-muted); }
.pill.is-selected,
.pill[aria-pressed="true"] {
  background: var(--color-text-dark);
  border-color: var(--color-text-dark);
  color: #fff;
}
.pill__price { font-size: var(--fs-xs); opacity: 0.7; }

/* Tag de territorio · modificadores cromáticos */
.tag {
  display: inline-flex;
  align-items: center;
  align-self: flex-start; /* evita estirarse en contenedores flex-column */
  width: fit-content;
  gap: 0.4em;
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  padding: 0.35em 0.75em;
  border-radius: var(--radius-pill);
  background: var(--color-line);
  color: var(--color-text-dark);
}
.tag::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; opacity: 0.85;
}
.tag--contencion { background: var(--color-territorio-contencion); color: var(--color-territorio-contencion-ink); }
.tag--memoria    { background: var(--color-territorio-memoria);    color: var(--color-territorio-memoria-ink); }
.tag--renacer    { background: var(--color-territorio-renacer);    color: var(--color-territorio-renacer-ink); }

/* Badge numérico (carrito) */
.badge-count {
  position: absolute;
  top: -6px; right: -8px;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: var(--fw-bold);
  color: #fff; background: var(--color-brand-primary);
  border-radius: var(--radius-pill);
  line-height: 1;
}

/* Rating estrellas */
.rating { display: inline-flex; align-items: center; gap: var(--space-2); }
.rating__stars { display: inline-flex; color: var(--color-star); letter-spacing: 1px; }
.rating__count { font-size: var(--fs-sm); color: var(--color-text-muted); }
.rating__count a { text-decoration: underline; text-underline-offset: 2px; }

/* Precio */
.price { font-family: var(--font-body); font-weight: var(--fw-semibold); font-size: var(--fs-xl); color: var(--color-text-dark); font-variant-numeric: tabular-nums; }
.price small { font-family: var(--font-body); font-weight: var(--fw-regular, 400); font-size: var(--fs-sm); color: var(--color-text-muted); }

/* ============================================================
   4. LAYOUT · NAVBAR
   ============================================================ */
.navbar {
  position: sticky; top: 0; z-index: var(--z-navbar);
  background: color-mix(in srgb, var(--color-bg-main) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--color-line);
}
.navbar__inner {
  min-height: var(--navbar-h);
  display: flex; align-items: center; gap: var(--space-6);
}
.navbar__brand { flex-shrink: 0; }
.navbar__brand img { height: 34px; width: auto; }

.navbar__links {
  display: flex; align-items: center; gap: var(--space-6);
  margin-right: auto;
}
.navbar__link {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--color-text-muted);
  position: relative;
  padding-block: var(--space-2);
}
.navbar__link:hover,
.navbar__link.is-active { color: var(--color-text-dark); }
.navbar__link.is-active::after {
  content: ""; position: absolute; left: 0; bottom: 0;
  width: 100%; height: 2px; background: var(--color-brand-primary);
  border-radius: var(--radius-pill);
}

.navbar__actions { display: flex; align-items: center; gap: var(--space-4); }

/* Búsqueda sutil */
.search {
  display: flex; align-items: center; gap: var(--space-2);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-pill);
  padding: 0.5em 0.9em;
  min-width: 210px;
  transition: var(--transition-fast);
}
.search:focus-within { border-color: var(--color-brand-primary); }
.search .icon { color: var(--color-text-soft); flex-shrink: 0; }
.search input {
  border: 0; background: transparent; outline: none;
  font-size: var(--fs-sm); width: 100%;
}

.icon-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 50%;
  color: var(--color-text-dark);
  transition: var(--transition-fast);
}
.icon-btn:hover { background: var(--color-bg-sunken); }

.navbar__burger { display: none; }
.navbar__close {
  display: none;
  position: absolute; top: var(--space-4); right: var(--space-4);
}

/* ============================================================
   5. LAYOUT · FOOTER
   ============================================================ */
.footer {
  background: var(--color-text-dark);
  color: color-mix(in srgb, var(--color-bg-main) 72%, transparent);
  padding-block: var(--space-9) var(--space-6);
  margin-top: var(--space-10);
}
.footer a { color: inherit; opacity: 0.8; }
.footer a:hover { opacity: 1; color: var(--color-brand-primary); }

.footer__grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: var(--space-7);
  padding-bottom: var(--space-7);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.footer__brand img { height: 40px; width: auto; margin-bottom: var(--space-4); }
.footer__brand p { font-size: var(--fs-sm); opacity: 0.7; max-width: 34ch; }

.footer__col h4 {
  font-family: var(--font-body);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--color-brand-primary);
  margin-bottom: var(--space-4);
}
.footer__col li + li { margin-top: var(--space-3); }
.footer__col a { font-size: var(--fs-sm); }

.footer__bottom {
  display: flex; flex-wrap: wrap; align-items: center;
  justify-content: space-between; gap: var(--space-4);
  padding-top: var(--space-5);
  font-size: var(--fs-xs);
}
.footer__bottom > span { opacity: 0.6; }

.footer__social { display: flex; gap: var(--space-3); }
.footer__social a {
  width: 38px; height: 38px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid rgba(255,255,255,0.22);
  color: rgba(255,255,255,0.9); opacity: 1;
  transition: var(--transition-smooth, all 0.2s ease);
}
.footer__social a:hover {
  background: var(--color-brand-primary);
  border-color: var(--color-brand-primary);
  color: var(--color-text-dark); opacity: 1;
  transform: translateY(-2px);
}
.footer__social svg { display: block; }

/* ============================================================
   6. ORGANISMO · TARJETA DE PRODUCTO
   ============================================================ */
.product-card {
  display: flex; flex-direction: column;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-premium);
  overflow: hidden;
  transition: var(--transition-smooth);
}
.product-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-line-strong);
}
.product-card__media {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--color-bg-sunken);
}
.product-card__media img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform 0.6s ease;
}
.product-card:hover .product-card__media img { transform: scale(1.05); }

.product-card__tag { position: absolute; top: var(--space-3); left: var(--space-3); }

.product-card__badge {
  position: absolute; top: var(--space-3); right: var(--space-3);
  background: var(--color-bg-elevated); color: var(--color-text-dark);
  font-size: var(--fs-2xs); font-weight: 600;
  letter-spacing: var(--tracking-wide);
  padding: 3px 9px; border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
}

.product-card__stock {
  font-size: var(--fs-xs); font-weight: 600;
  color: #b06a3d; letter-spacing: var(--tracking-wide);
}

.product-card__body {
  display: flex; flex-direction: column; gap: var(--space-2);
  padding: var(--space-4) var(--space-5) var(--space-5);
  flex: 1;
}
.product-card__title {
  font-family: var(--font-titles);
  font-size: var(--fs-lg);
  color: var(--color-text-dark);
}
.product-card__title a { color: inherit; text-decoration: none; }
.product-card__title a:hover { text-decoration: underline; text-underline-offset: 3px; }
.product-card__desc { font-size: var(--fs-sm); color: var(--color-text-muted); }
.product-card__foot {
  display: flex; align-items: baseline; gap: var(--space-2);
  margin-top: auto; padding-top: var(--space-3);
}
.product-card__price {
  font-family: var(--font-body);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-xl);
  color: var(--color-text-dark);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

/* Botón "Agregar al carro" · visible al hover (desktop), siempre en táctil */
.product-card__add { width: 100%; margin-top: var(--space-3); }
@media (hover: hover) {
  .product-card__add {
    opacity: 0; max-height: 0; margin-top: 0; overflow: hidden;
    pointer-events: none;
    transition: opacity 0.18s ease, max-height 0.28s ease, margin-top 0.28s ease;
  }
  .product-card:hover .product-card__add,
  .product-card:focus-within .product-card__add {
    opacity: 1; max-height: 60px; margin-top: var(--space-3); pointer-events: auto;
  }
}

/* Variante compacta (home) */
.product-card--mini .product-card__body { padding: var(--space-3) var(--space-4) var(--space-4); gap: var(--space-1); }
.product-card--mini .product-card__title { font-size: var(--fs-md); line-height: var(--lh-tight, 1.25); }
.product-card--mini .product-card__price { font-size: var(--fs-lg); }

/* Estado agotado */
.product-card--soldout .product-card__media::after {
  content: "Agotado";
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-titles); font-size: var(--fs-lg);
  letter-spacing: var(--tracking-wide);
  color: #fff; background: var(--color-overlay);
}
.product-card--soldout .product-card__media img { filter: grayscale(0.4); }

/* ============================================================
   7. ORGANISMO · DRAWER (Carrito lateral)
   ============================================================ */
.overlay {
  position: fixed; inset: 0; z-index: var(--z-overlay);
  background: var(--color-overlay);
  opacity: 0; visibility: hidden; transition: var(--transition-smooth);
}
.overlay.is-open { opacity: 1; visibility: visible; }

.drawer {
  position: fixed; top: 0; right: 0; z-index: var(--z-drawer);
  width: min(420px, 92vw); height: 100%;
  background: var(--color-bg-main);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.drawer.is-open { transform: translateX(0); }
.drawer__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-5); border-bottom: 1px solid var(--color-line);
}
.drawer__title { font-size: var(--fs-xl); }
.drawer__body { flex: 1; overflow-y: auto; padding: var(--space-5); }
.drawer__foot { padding: var(--space-5); border-top: 1px solid var(--color-line); background: var(--color-bg-elevated); }

/* Línea de ítem en carrito / drawer */
.cart-line { display: flex; gap: var(--space-4); padding-block: var(--space-4); }
.cart-line + .cart-line { border-top: 1px solid var(--color-line); }
.cart-line__media {
  width: 84px; height: 84px; flex-shrink: 0;
  border-radius: var(--radius-sm); overflow: hidden; background: var(--color-bg-sunken);
}
.cart-line__media img { width: 100%; height: 100%; object-fit: cover; }
.cart-line__info { flex: 1; display: flex; flex-direction: column; gap: var(--space-1); }
.cart-line__title { font-family: var(--font-titles); font-size: var(--fs-md); }
.cart-line__meta { font-size: var(--fs-xs); color: var(--color-text-muted); }
.cart-line__price { font-weight: var(--fw-semibold); }

/* Stepper de cantidad */
.qty {
  display: inline-flex; align-items: center;
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.qty button { width: 30px; height: 30px; font-size: var(--fs-md); color: var(--color-text-muted); }
.qty button:hover { color: var(--color-text-dark); background: var(--color-bg-sunken); }
.qty output { min-width: 28px; text-align: center; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }

/* ============================================================
   8. MOLÉCULA · ACORDEÓN / TABS DE DETALLE
   ============================================================ */
.accordion { border-top: 1px solid var(--color-line); }
.accordion__item { border-bottom: 1px solid var(--color-line); }
.accordion__trigger {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-5) 0;
  font-family: var(--font-titles); font-size: var(--fs-lg); text-align: left;
}
.accordion__trigger .chev { transition: transform 0.3s ease; color: var(--color-text-muted); }
.accordion__trigger[aria-expanded="true"] .chev { transform: rotate(180deg); }
.accordion__panel {
  display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows 0.3s ease;
}
.accordion__panel[data-open="true"] { grid-template-rows: 1fr; }
.accordion__panel > div { overflow: hidden; }
.accordion__panel-inner { padding-bottom: var(--space-5); color: var(--color-text-muted); }

/* Lista de contenido de caja */
.content-list { display: grid; gap: var(--space-3); }
.content-list li {
  display: flex; gap: var(--space-3); align-items: flex-start;
  font-size: var(--fs-sm); color: var(--color-text-dark);
}
.content-list li::before {
  content: ""; flex-shrink: 0; margin-top: 0.55em;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--color-brand-primary);
}

/* Nota / aviso de despacho */
.note {
  background: var(--color-brand-primary-soft);
  border-left: 3px solid var(--color-brand-primary);
  border-radius: var(--radius-sm);
  padding: var(--space-4) var(--space-5);
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
}
.note strong { color: var(--color-text-dark); }
.note ul { list-style: none; display: grid; gap: var(--space-2); margin-top: var(--space-2); }
.note li { padding-left: var(--space-4); position: relative; }
.note li::before { content: "·"; position: absolute; left: var(--space-1); color: var(--color-brand-primary); font-weight: 700; }

/* ============================================================
   9. RESPONSIVE de componentes
   ============================================================ */
@media (max-width: 860px) {
  .search { display: none; }
  .navbar__burger { display: inline-flex; }
  .navbar__actions { margin-left: auto; }   /* carrito + menú alineados a la derecha */
  .footer__grid { grid-template-columns: 1fr 1fr; }

  /* Sin backdrop-filter en mobile: evita que el panel fixed se ancle al navbar
     (backdrop-filter crea un bloque contenedor para hijos position:fixed). */
  .navbar { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--color-bg-main); }

  /* Menú móvil: panel lateral que entra desde la derecha, igual que el drawer del carrito */
  .navbar__links {
    display: flex;
    position: fixed; top: 0; right: 0; z-index: var(--z-drawer);
    width: min(300px, 82vw); height: 100%;
    flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 0;
    margin: 0;
    background: var(--color-bg-main);
    box-shadow: var(--shadow-lg);
    padding: calc(var(--navbar-h) + var(--space-2)) var(--space-5) var(--space-6);
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .navbar__links.is-open { transform: translateX(0); }
  .navbar__link {
    width: 100%; padding: var(--space-4) 0;
    border-bottom: 1px solid var(--color-line);
    font-size: var(--fs-md); color: var(--color-text-dark);
  }
  .navbar__link.is-active::after { display: none; }
  .navbar__close { display: inline-flex; }
}
@media (max-width: 560px) {
  .footer__grid { grid-template-columns: 1fr; }
}
