/**
 * Sticky Product Header — front styles
 *
 * @package StickyProductHeader
 */

/* Reset attribute hidden once JS is ready */
.sph-root[hidden] { display: none; }

.sph-root {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: auto !important;
    margin: 0 !important;
    z-index: 99999;
    background: var(--sph-bg, #1a2332);
    color: var(--sph-text, #ffffff);
    box-shadow: var(--sph-shadow, 0 2px 12px rgba(0, 0, 0, 0.15));
    transform: translateY(-100%);
    transition: transform 240ms ease-out;
    will-change: transform;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    box-sizing: border-box;
}

/* Admin bar offset */
body.admin-bar .sph-root { top: 32px; }

/* States */
.sph-root.sph-show { transform: translateY(0); }
.sph-root.sph-dismissed {
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
    transition: transform 240ms ease-out, opacity 200ms ease-out;
}

/* Container */
.sph-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 64px;
    height: auto;
    box-sizing: border-box;
}

/* Product info block */
.sph-product-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0; /* enable text truncation */
}

.sph-image {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    display: block;
}

.sph-text {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    min-width: 0;
    gap: 14px;
    flex: 1;
}

.sph-title {
    font-weight: 600;
    color: var(--sph-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 0 1 auto;
    font-size: 15px;
}

.sph-emoji {
    margin-right: 4px;
    display: inline-block;
}

/* Price */
.sph-price {
    font-size: 13px;
    display: flex;
    gap: 8px;
    align-items: baseline;
}

.sph-price del,
.sph-price .woocommerce-Price-amount.amount del,
.sph-price > del * {
    color: var(--sph-price-old);
    text-decoration: line-through;
    font-weight: 400;
}

.sph-price ins,
.sph-price .woocommerce-Price-amount.amount ins,
.sph-price > ins * {
    color: var(--sph-price-new);
    text-decoration: none;
    font-weight: 700;
}

/* When there's only a single price (no sale) */
.sph-price .woocommerce-Price-amount:only-child {
    color: var(--sph-price-new);
    font-weight: 700;
}

/* CTA */
.sph-cta {
    display: inline-block;
    padding: 12px 28px;
    background: var(--sph-cta-bg);
    color: var(--sph-cta-text);
    text-decoration: none;
    font-weight: 700;
    font-size: 14px;
    border-radius: 6px;
    transition: filter 150ms ease-out, transform 150ms ease-out;
    white-space: nowrap;
    flex-shrink: 0;
}

.sph-cta:hover,
.sph-cta:focus {
    filter: brightness(1.1);
    color: var(--sph-cta-text);
    text-decoration: none;
}

.sph-cta:active {
    transform: translateY(1px);
}

.sph-cta--uppercase {
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Close button */
.sph-close {
    background: transparent;
    border: 0;
    cursor: pointer;
    color: var(--sph-text);
    opacity: 0.6;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: opacity 150ms ease-out, background 150ms ease-out;
    flex-shrink: 0;
}

.sph-close:hover,
.sph-close:focus {
    opacity: 1;
    background: rgba(255, 255, 255, 0.08);
}

.sph-close svg {
    display: block;
}

/* ============================
   Mobile admin bar offset
   ============================ */
@media (max-width: 782px) {
    body.admin-bar .sph-root { top: 46px; }
}

/* ============================
   Mobile layout (≤ 768px)
   ============================ */
@media (max-width: 768px) {
    .sph-container {
        min-height: 52px;
        padding: 8px 12px;
        gap: 10px;
    }

    .sph-image {
        display: none; /* saves space on mobile */
    }

    .sph-title {
        font-size: 13px;
    }

    .sph-price {
        font-size: 12px;
    }

    .sph-cta {
        padding: 10px 14px;
        font-size: 13px;
    }

    .sph-close {
        padding: 6px;
    }
}

/* ============================
   Very small screens (≤ 380px)
   ============================ */
@media (max-width: 380px) {
    .sph-container { gap: 8px; padding: 8px 10px; }
    .sph-title { font-size: 12px; }
    .sph-cta { padding: 9px 10px; font-size: 12px; }
}

/* ============================
   Reduced motion preference
   ============================ */
@media (prefers-reduced-motion: reduce) {
    .sph-root {
        transition: none;
    }
}

/* ============================
   Focus outlines (keyboard a11y)
   ============================ */
.sph-cta:focus-visible,
.sph-close:focus-visible {
    outline: 3px solid var(--sph-cta-bg);
    outline-offset: 2px;
}
