/**
 * Project Bakery Hero Carousel — frontend стилове.
 * Всички селектори са scoped с префикс .pbhc-, за да не чупят темата.
 * Цветовете и размерите се управляват през CSS variables (виж :root по-долу
 * и inline променливите, генерирани от настройките).
 */

.pbhc-carousel {
    /* Fallback стойности — реалните идват inline от настройките. */
    --pbhc-height-desktop: 100dvh;
    --pbhc-height-mobile: 80dvh;
    --pbhc-accent-bg: #111111;
    --pbhc-accent-text: #ffffff;
    --pbhc-shop-bg: #ffffff;
    --pbhc-shop-text: #111111;
    --pbhc-speed: 800ms;
    --pbhc-overlay: 0.25;
    --pbhc-slide-text: #ffffff;

    --pbhc-radius: 999px;
    --pbhc-content-max: 1280px;
    --pbhc-gutter: clamp(1.25rem, 5vw, 5rem);

    position: relative;
    box-sizing: border-box;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #0a0a0a;
    isolation: isolate;
    font-family: inherit;
}

.pbhc-carousel *,
.pbhc-carousel *::before,
.pbhc-carousel *::after {
    box-sizing: border-box;
}

/* ---------- Viewport / Track ---------- */

.pbhc-viewport {
    position: relative;
    width: 100%;
    height: var(--pbhc-height-desktop);
    min-height: 420px;
    overflow: hidden;
}

.pbhc-track {
    list-style: none;
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    position: relative;
}

.pbhc-slide {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
}

/* ---------- Media ---------- */

/* display:contents премахва <picture> от лейаута — снимката се оразмерява
   директно спрямо .pbhc-slide (който има ясни размери по двете оси).
   Така избягваме бъговете с процентни размери през <picture> тага. */
.pbhc-media {
    display: contents;
}

.pbhc-media img {
    position: absolute;
    top: 0;
    left: 0;
    /* !important + max-width:none побеждават теми, които налагат
       img { height:auto; max-width:100% }. Абсолютното позициониране
       гарантира, че снимката пълни слайда независимо от <picture> тага. */
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    margin: 0;
    object-fit: cover;
    object-position: center;
    display: block;
    /* Лек ken-burns при активен слайд се добавя по-долу. */
}

.pbhc-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, calc(var(--pbhc-overlay) + 0.25)) 0%,
        rgba(0, 0, 0, var(--pbhc-overlay)) 45%,
        rgba(0, 0, 0, calc(var(--pbhc-overlay) * 0.4)) 100%
    );
    pointer-events: none;
}

/* ---------- Content ---------- */

.pbhc-content {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    padding: var(--pbhc-gutter);
    padding-bottom: clamp(5rem, 12vh, 9rem); /* място за shop CTA */
    z-index: 2;
    pointer-events: none;
}

.pbhc-content-inner {
    max-width: min(var(--pbhc-content-max), 100%);
    width: 100%;
    color: var(--pbhc-slide-text);
    pointer-events: auto;
    transform: translateY(24px);
    opacity: 0;
    transition: transform 700ms cubic-bezier(0.22, 1, 0.36, 1),
                opacity 700ms cubic-bezier(0.22, 1, 0.36, 1);
    transition-delay: 200ms;
}

.pbhc-slide.is-active .pbhc-content-inner {
    transform: translateY(0);
    opacity: 1;
}

.pbhc-title {
    margin: 0 0 0.5rem;
    font-size: clamp(2rem, 5.5vw, 4.5rem);
    line-height: 1.05;
    font-weight: 700;
    letter-spacing: -0.02em;
    text-shadow: 0 2px 24px rgba(0, 0, 0, 0.35);
    color: inherit;
}

.pbhc-subtitle {
    margin: 0 0 1.5rem;
    font-size: clamp(1rem, 1.8vw, 1.35rem);
    line-height: 1.4;
    max-width: 46ch;
    opacity: 0.95;
    text-shadow: 0 1px 12px rgba(0, 0, 0, 0.35);
    color: inherit;
}

.pbhc-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

/* ---------- Buttons ---------- */

.pbhc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.95rem 1.9rem;
    font-size: clamp(0.95rem, 1.3vw, 1.1rem);
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    border: none;
    border-radius: var(--pbhc-radius);
    cursor: pointer;
    transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease, color 180ms ease;
    white-space: nowrap;
}

.pbhc-btn:focus-visible {
    outline: 3px solid var(--pbhc-slide-text);
    outline-offset: 3px;
}

/* Бутон с цената — силен контраст. */
.pbhc-btn-price {
    background: var(--pbhc-accent-bg);
    color: var(--pbhc-accent-text);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.pbhc-btn-price:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.pbhc-btn-price .pbhc-price,
.pbhc-btn-price .pbhc-price * {
    color: inherit !important;
    font-weight: 800;
    text-decoration: none;
}

/* WooCommerce слага <del>/<ins> при промоция — стилизираме ги четимо. */
.pbhc-btn-price .pbhc-price del {
    opacity: 0.6;
    font-weight: 500;
    margin-right: 0.35em;
}

.pbhc-btn-price .pbhc-price ins {
    text-decoration: none;
}

/* Sold out състояние. */
.pbhc-btn-price.is-sold-out {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: 1.5px solid rgba(255, 255, 255, 0.6);
    cursor: not-allowed;
    letter-spacing: 0.08em;
    box-shadow: none;
}

/* ---------- Shop CTA (винаги видим) ---------- */

.pbhc-shop-cta {
    position: absolute;
    left: 0;
    right: 0;
    bottom: clamp(1.25rem, 3vh, 2.25rem);
    display: flex;
    justify-content: center;
    z-index: 5;
    pointer-events: none;
    padding: 0 1rem;
}

.pbhc-btn-shop {
    background: var(--pbhc-shop-bg);
    color: var(--pbhc-shop-text);
    pointer-events: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    letter-spacing: 0.01em;
}

.pbhc-btn-shop svg {
    width: 1.1em;
    height: 1.1em;
    transition: transform 200ms ease;
}

.pbhc-btn-shop:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 38px rgba(0, 0, 0, 0.3);
}

.pbhc-btn-shop:hover svg {
    transform: translateX(4px);
}

/* ---------- Navigation arrows ---------- */

.pbhc-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 4;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    color: #111;
    cursor: pointer;
    transition: background 180ms ease, transform 180ms ease, opacity 180ms ease;
    padding: 0;
}

.pbhc-nav svg {
    width: 24px;
    height: 24px;
}

.pbhc-nav:hover {
    background: #fff;
}

.pbhc-nav:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 2px;
}

.pbhc-prev { left: clamp(0.75rem, 2vw, 1.75rem); }
.pbhc-next { right: clamp(0.75rem, 2vw, 1.75rem); }

/* ---------- Dots ---------- */

.pbhc-dots {
    position: absolute;
    top: clamp(1rem, 3vh, 2rem);
    right: clamp(1rem, 3vw, 2rem);
    display: flex;
    gap: 0.5rem;
    z-index: 4;
}

.pbhc-dot {
    width: 10px;
    height: 10px;
    padding: 0;
    border: 2px solid rgba(255, 255, 255, 0.85);
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    transition: background 200ms ease, transform 200ms ease;
}

.pbhc-dot.is-active {
    background: #fff;
    transform: scale(1.2);
}

.pbhc-dot:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* ================= PRODUCT TAGS (H&M стил) ================= */

.pbhc-tag {
    position: absolute;
    transform: translate(-50%, -50%);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.85rem 0.35rem 0.35rem;
    background: rgba(255, 255, 255, 0.96);
    color: #111;
    border-radius: 999px;
    text-decoration: none;
    font-size: clamp(0.8rem, 1.1vw, 0.95rem);
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
    z-index: 3;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.pbhc-tag:hover,
.pbhc-tag:focus-visible {
    transform: translate(-50%, -50%) scale(1.06);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
    outline: none;
}

.pbhc-tag-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.7em;
    height: 1.7em;
    flex: none;
    border-radius: 50%;
    background: #111;
    color: #fff;
    font-weight: 700;
    font-size: 0.95em;
}

.pbhc-tag-info {
    display: flex;
    flex-direction: column;
    gap: 0.1em;
    line-height: 1.15;
    text-align: left;
}

.pbhc-tag-name {
    font-size: 0.82em;
    font-weight: 600;
    max-width: 22ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pbhc-tag-price {
    color: inherit;
    font-weight: 800;
}

.pbhc-tag-price del {
    opacity: 0.55;
    font-weight: 500;
    margin-right: 0.35em;
}

.pbhc-tag-price ins {
    text-decoration: none;
}

/* Пулсираща анимация, за да се забелязват таговете. */
.pbhc-tag::before {
    content: "";
    position: absolute;
    left: 0.35rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.7em;
    height: 1.7em;
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7);
    animation: pbhc-pulse 2.4s infinite;
    pointer-events: none;
}

@keyframes pbhc-pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.6); }
    70% { box-shadow: 0 0 0 12px rgba(255, 255, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

/* Sold out таг. */
.pbhc-tag.is-sold-out {
    background: rgba(17, 17, 17, 0.82);
    color: #fff;
    cursor: not-allowed;
    letter-spacing: 0.04em;
}

.pbhc-tag.is-sold-out .pbhc-tag-icon {
    background: #fff;
    color: #111;
}

.pbhc-tag.is-sold-out::before {
    display: none;
}

/* Малък етикет долу вляво (заглавие/подзаглавие на слайда). */
.pbhc-slide-label {
    position: absolute;
    left: clamp(1rem, 4vw, 3.5rem);
    bottom: clamp(1.25rem, 5vh, 3rem);
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    color: var(--pbhc-slide-text);
    text-shadow: 0 2px 16px rgba(0, 0, 0, 0.4);
    pointer-events: none;
}

.pbhc-slide-title {
    font-size: clamp(1.25rem, 2.6vw, 2.25rem);
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.1;
}

.pbhc-slide-sub {
    font-size: clamp(0.9rem, 1.4vw, 1.1rem);
    font-weight: 400;
    opacity: 0.92;
}

@media (prefers-reduced-motion: reduce) {
    .pbhc-tag::before { animation: none; }
}

/* ================= EFFECTS ================= */

/* Fade ефект. */
.pbhc-effect-fade .pbhc-slide {
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--pbhc-speed) ease, visibility var(--pbhc-speed) ease;
    z-index: 1;
}

.pbhc-effect-fade .pbhc-slide.is-active {
    opacity: 1;
    visibility: visible;
    z-index: 2;
}

/* Slide ефект — track flex, slide-овете една до друга. */
.pbhc-effect-slide .pbhc-track {
    display: flex;
    transition: transform var(--pbhc-speed) cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
}

.pbhc-effect-slide .pbhc-slide {
    position: relative;
    inset: auto;
    flex: 0 0 100%;
}

/* Лек ken-burns zoom на активния слайд (fade режим). */
@media (prefers-reduced-motion: no-preference) {
    .pbhc-effect-fade .pbhc-slide.is-active .pbhc-media img {
        animation: pbhc-kenburns 8s ease-out forwards;
    }
}

@keyframes pbhc-kenburns {
    from { transform: scale(1); }
    to { transform: scale(1.06); }
}

/* ================= RESPONSIVE ================= */

@media (max-width: 768px) {
    .pbhc-viewport {
        height: var(--pbhc-height-mobile);
        min-height: 480px;
    }

    .pbhc-content {
        padding: 1.25rem;
        padding-bottom: 6.5rem;
        align-items: flex-end;
        text-align: left;
    }

    .pbhc-title {
        font-size: clamp(1.75rem, 8vw, 2.75rem);
    }

    .pbhc-subtitle {
        font-size: 1rem;
        margin-bottom: 1.1rem;
    }

    .pbhc-actions {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    .pbhc-btn-price {
        width: 100%;
        padding: 1rem 1.5rem;
    }

    /* На мобилно крием страничните стрелки — жестове/точки са достатъчни. */
    .pbhc-nav {
        display: none;
    }

    .pbhc-shop-cta {
        bottom: 1rem;
    }

    .pbhc-btn-shop {
        width: calc(100% - 2rem);
        max-width: 420px;
    }
}

/* Тагове на мобилно — малко по-компактни. */
@media (max-width: 768px) {
    .pbhc-tag {
        padding: 0.3rem 0.7rem 0.3rem 0.3rem;
        gap: 0.4rem;
        font-size: 0.8rem;
    }

    .pbhc-slide-label {
        left: 1rem;
        bottom: 1.25rem;
    }
}

/* ================= ACCESSIBILITY ================= */

@media (prefers-reduced-motion: reduce) {
    .pbhc-content-inner,
    .pbhc-effect-fade .pbhc-slide,
    .pbhc-effect-slide .pbhc-track,
    .pbhc-btn,
    .pbhc-nav {
        transition: none !important;
        animation: none !important;
    }
}

/* Админ съобщение при празен карусел. */
.pbhc-empty-notice {
    padding: 2rem;
    text-align: center;
    background: #f6f7f7;
    border: 1px dashed #c3c4c7;
    color: #50575e;
    border-radius: 8px;
}

/* ================= ELEMENTOR СЪВМЕСТИМОСТ =================
 * В Elementor shortcode widget-ът е flex елемент. Тъй като цялото
 * съдържание на карусела е абсолютно позиционирано, widget-ът се свива
 * до 0 широчина и каруселът изчезва. Тук насила разпъваме widget-а и
 * контейнера му на пълна широчина — само когато съдържат нашия карусел.
 * :has() е поддържан от всички модерни браузъри.
 */
.elementor-widget-shortcode:has(.pbhc-carousel),
.elementor-widget:has(> .elementor-widget-container > .pbhc-carousel) {
    width: 100% !important;
    max-width: 100% !important;
    flex: 1 0 100% !important;
    align-self: stretch !important;
}

.elementor-widget-shortcode:has(.pbhc-carousel) > .elementor-widget-container {
    width: 100% !important;
    max-width: 100% !important;
}

/* Ако Elementor контейнерът, който директно държи карусела, е с ограничена
 * широчина — също го разпъваме. */
.e-con:has(> .e-con-inner > .elementor-widget-shortcode .pbhc-carousel) .e-con-inner {
    width: 100% !important;
    max-width: 100% !important;
}
