/**
 * ST Product Grid - Frontend Styles
 * Uses CSS custom properties set inline on .stpg-grid for per-grid styling
 */

.stpg-grid {
    display: grid;
    gap: var(--stpg-gap, 24px);
    margin: 0 auto;
    max-width: 1400px;
}

.stpg-cols-2 { grid-template-columns: repeat(2, 1fr); }
.stpg-cols-3 { grid-template-columns: repeat(3, 1fr); }
.stpg-cols-4 { grid-template-columns: repeat(4, 1fr); }

/* Card */
.stpg-card {
    background: var(--stpg-bg, #ffffff);
    border-radius: var(--stpg-radius, 12px);
    overflow: hidden;
    box-shadow: var(--stpg-shadow, none);
    border: var(--stpg-border, none);
    transition: box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
}

.stpg-card:hover {
    box-shadow: var(--stpg-hover-shadow, none);
}

.stpg-card-link,
.stpg-card-link:link,
.stpg-card-link:visited,
.stpg-card-link:hover,
.stpg-card-link:active,
.stpg-card-link:focus {
    text-decoration: none !important;
    color: inherit !important;
    display: flex;
    flex-direction: column;
    flex: 1;
}
.stpg-card-link:hover .stpg-card-title { color: var(--stpg-btn-bg, #e94560) !important; }

/* Image */
.stpg-card-image {
    position: relative;
    overflow: hidden;
    background: #f5f5f5;
}

.stpg-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s ease;
}

.stpg-card:hover .stpg-card-image img {
    transform: scale(1.08);
}

/* Image ratios */
.stpg-ratio-square { aspect-ratio: 1 / 1; }
.stpg-ratio-landscape { aspect-ratio: 4 / 3; }
.stpg-ratio-portrait { aspect-ratio: 3 / 4; }

/* Body */
.stpg-card-body {
    padding: 16px 20px 12px;
    display: flex;
    flex-direction: column;
    flex: 1;
    text-align: var(--stpg-title-align, left);
}

.stpg-card-title {
    font-size: var(--stpg-title-size, 1.05rem);
    font-weight: 700;
    line-height: 1.3;
    margin: 0 0 6px 0;
    color: #1a1a2e;
    text-decoration: none !important;
    transition: color 0.2s ease;
}

.stpg-card-desc {
    font-size: 0.85rem;
    line-height: 1.5;
    color: #555;
    margin: 0 0 8px 0;
    text-decoration: none !important;
}

.stpg-card-price {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 4px;
}
.stpg-card-price strong {
    color: #1a1a2e;
    font-size: 1.1rem;
}
.stpg-card-price-note {
    display: block;
    font-size: 0.72rem;
    color: #888;
    font-weight: 400;
    line-height: 1.3;
    margin-top: 2px;
    letter-spacing: 0.2px;
}

/* Ribbon — purely visual, sits over the card top-left corner */
.stpg-card { position: relative; }
.stpg-ribbon {
    position: absolute;
    top: 10px;
    left: -6px;
    z-index: 5;
    padding: 5px 12px 5px 14px;
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    line-height: 1.3;
    border-radius: 0 3px 3px 0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
    pointer-events: none;
    max-width: 80%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.stpg-ribbon::before {
    content: "";
    position: absolute;
    bottom: -6px;
    left: 0;
    border-width: 0 6px 6px 0;
    border-style: solid;
    border-color: transparent rgba(0,0,0,0.25) transparent transparent;
}

/* Buttons */
.stpg-card-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 20px 20px;
    margin-top: auto;
}

.stpg-card-button {
    display: block;
    text-align: center;
    padding: 12px 20px;
    text-decoration: none !important;
    border-radius: var(--stpg-btn-radius, 50px);
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.2s ease;
    line-height: 1.4;
    letter-spacing: 0;
    white-space: normal;
}

/* Primary button — uses CSS vars set per-grid in the inline style block */
.stpg-btn-primary {
    background: var(--stpg-btn-bg, #0073aa);
    color: var(--stpg-btn-color, #ffffff) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.stpg-btn-primary:hover {
    background: var(--stpg-btn-hover, #005177);
    color: var(--stpg-btn-color, #ffffff) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
    text-decoration: none !important;
}

/* Secondary button kept for backward compat — not rendered by current PHP */
.stpg-btn-secondary {
    background: transparent;
    color: #1a1a2e !important;
    border: 2px solid #ddd;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.stpg-btn-secondary svg {
    flex-shrink: 0;
}

.stpg-btn-secondary:hover {
    border-color: var(--stpg-btn-bg, #0073aa);
    color: var(--stpg-btn-bg, #0073aa) !important;
    text-decoration: none !important;
}

/* Responsive */
@media (max-width: 1024px) { .stpg-cols-4 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 768px) {
    .stpg-cols-3, .stpg-cols-4 { grid-template-columns: repeat(2, 1fr); }
    .stpg-grid { gap: 16px; }
    .stpg-card-body { padding: 12px 14px 8px; }
    .stpg-card-title { font-size: 0.95rem; }
    .stpg-card-buttons { padding: 0 14px 14px; gap: 6px; }
    .stpg-card-button { padding: 8px 12px; font-size: 0.8rem; }
}
@media (max-width: 480px) { .stpg-cols-2, .stpg-cols-3, .stpg-cols-4 { grid-template-columns: 1fr; } }


/* Visually hidden but accessible to screen readers and search engines */
.stpg-card .screen-reader-text {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
