/* ============================================================
   public/css/components.css
   Estilos de los componentes Blade de la tienda.

   Este archivo es la ÚNICA fuente de verdad para product-card,
   product-grid y section-heading. Antes estaban duplicados en
   home/index, catalog/category y catalog/show.

   Enlazar en web.blade.php ANTES del <style> del layout:
       <link rel="stylesheet" href="{{ asset('css/components.css') }}">

   Usa las variables --pink, --gray-*, etc. definidas en el layout.
   ============================================================ */


/* ─────────────────────────────────────────────
   Grilla de productos
   ───────────────────────────────────────────── */
.pgrid {
    display: grid;
    gap: 24px;
}
.pgrid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pgrid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pgrid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* Con 1 o 2 productos, centrar en vez de dejar columnas vacías.
   Con 3 se mantiene la grilla: alinear a la izquierda se ve mejor
   que centrar tres cards sueltas. */
.pgrid--4:has(> :last-child:nth-child(-n+2)),
.pgrid--3:has(> :last-child:nth-child(-n+2)) {
    grid-template-columns: repeat(auto-fit, minmax(220px, 260px));
    justify-content: center;
}

.pgrid__empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 24px;
    color: var(--gray-400);
}
.pgrid__empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.pgrid__empty h3 {
    font-family: var(--serif);
    font-size: 1.2rem;
    color: var(--gray-700);
    margin-bottom: 6px;
}
.pgrid__empty p { font-size: .85rem; }


/* ─────────────────────────────────────────────
   Card de producto
   ───────────────────────────────────────────── */
.pc {
    background: #fff;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
    transition: transform .2s ease, box-shadow .2s ease;
}
.pc:hover {
    transform: translateY(-4px);
    box-shadow: 0 14px 34px rgba(0, 0, 0, .14);
}

/* Media — la foto se ve COMPLETA, sin recortar.
   Critico para arreglos verticales: con object-fit:cover se cortaba
   la parte superior del arreglo. */
.pc__media {
    aspect-ratio: 1;
    overflow: hidden;
    background: #fff;
    position: relative;
    padding: 10px;
}
.pc--sm .pc__media { padding: 6px; }

.pc__media img {
    width: 100%;
    height: 100%;
    object-fit: contain;      /* <- muestra el arreglo entero */
    display: block;
    /* Zoom mas notorio que antes (1.03 casi no se veia) y con una
       curva que desacelera al final, para que se sienta suave. */
    transition: transform .55s cubic-bezier(.2, .8, .3, 1);
}
.pc:hover .pc__media img { transform: scale(1.09); }

.pc__placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.5rem;
    background: var(--pink-pale);
}

/* Badge de estado */
.pc__badge {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .02em;
    color: #fff;
    z-index: 2;
}
.pc__badge.is-promo    { background: #dc2626; }
.pc__badge.is-featured { background: var(--pink); }

/* Wishlist */
.pc__wish {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,.12);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s, transform .2s;
    backdrop-filter: blur(4px);
    z-index: 2;
}
.pc__wish:hover { background: #fff; transform: scale(1.1); }
.pc__wish svg   { width: 17px; height: 17px; color: var(--gray-400); }
.pc__wish:hover svg { color: #ef4444; }

/* Barra "Vista rápida" */
.pc__quick {
    position: absolute;
    bottom: -40px;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, .82);
    color: #fff;
    text-align: center;
    padding: 10px;
    font-size: .75rem;
    font-weight: 600;
    transition: bottom .2s ease;
}
.pc:hover .pc__quick { bottom: 0; }

/* Cuerpo — centrado, como el sitio actual */
.pc__body {
    padding: 14px 12px 18px;
    text-align: center;
    border-top: 1px solid var(--gray-100);
}

.pc__name {
    font-size: .84rem;
    font-weight: 400;
    color: var(--gray-500);
    line-height: 1.4;
    margin: 0 0 8px;
    /* Una linea con puntos suspensivos, como el sitio actual */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pc__name a { color: inherit; text-decoration: none; }
.pc__name a:hover { color: var(--pink); }

.pc__foot {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.pc__price {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--gray-900);
    display: flex;
    align-items: baseline;
    gap: 6px;
}
.pc__price-old {
    font-size: .75rem;
    font-weight: 400;
    color: var(--gray-400);
}

.pc__cart {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    background: var(--gray-100);
    border: none;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--gray-700);
    transition: background .2s, color .2s;
}
.pc__cart svg { width: 15px; height: 15px; }
.pc__cart:hover { background: var(--pink); color: #fff; }


/* ─────────────────────────────────────────────
   Encabezado de sección
   ───────────────────────────────────────────── */
.shead { margin-bottom: 24px; }

.shead--center { text-align: center; }
.shead--left {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    text-align: left;
}

.shead__eyebrow {
    font-size: .67rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--pink);
    margin: 0 0 4px;
}

.shead__title {
    font-family: var(--sans);
    font-size: clamp(1.15rem, 2.2vw, 1.5rem);
    font-weight: 400;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--gray-900);
    line-height: 1.3;
    margin: 0;
}

.shead__sub {
    font-size: .85rem;
    color: var(--gray-400);
    margin: 4px 0 0;
}

.shead__rule {
    display: block;
    width: 48px;
    height: 3px;
    background: var(--pink);
    border-radius: 3px;
    margin: 14px auto 0;
}
.shead--left .shead__rule { margin-left: 0; }

.shead__action { flex-shrink: 0; }


/* ─────────────────────────────────────────────
   Entrada escalonada de las cards
   ───────────────────────────────────────────── */
@keyframes pcFadeUp {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}
.pgrid > * { animation: pcFadeUp .45s ease both; }
.pgrid > *:nth-child(1) { animation-delay: .02s }
.pgrid > *:nth-child(2) { animation-delay: .06s }
.pgrid > *:nth-child(3) { animation-delay: .10s }
.pgrid > *:nth-child(4) { animation-delay: .14s }
.pgrid > *:nth-child(5) { animation-delay: .18s }
.pgrid > *:nth-child(6) { animation-delay: .22s }
.pgrid > *:nth-child(7) { animation-delay: .26s }
.pgrid > *:nth-child(8) { animation-delay: .30s }


/* ─────────────────────────────────────────────
   Responsive
   ───────────────────────────────────────────── */
/* Mantener 4 columnas mientras haya espacio real.
   Antes bajaba a 3 en 1024px, que es demasiado pronto en escritorio. */
@media (max-width: 900px) {
    .pgrid--4 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .pgrid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .pgrid { gap: 16px; }
}

@media (max-width: 640px) {
    .pgrid--4,
    .pgrid--3,
    .pgrid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

    .shead--left { flex-direction: column; align-items: flex-start; gap: 10px; }
    .pc__body { padding: 8px 10px 12px; }
    .pc__name { font-size: .78rem; }
    .pc__price { font-size: .88rem; }
}

@media (max-width: 380px) {
    .pgrid--4,
    .pgrid--3,
    .pgrid--2 { grid-template-columns: 1fr; }
}


/* Respeta a quien prefiere menos movimiento */
@media (prefers-reduced-motion: reduce) {
    .pgrid > * { animation: none; }
    .pc, .pc__media img, .pc__wish { transition: none; }
}
