/**
 * Elementor Popup Cards – front-end styles.
 *
 * All colours, sizing, typography & spacing can be overridden from the Elementor
 * Style tab. These defaults replicate the original BlockPopup component.
 */

.tw-popup {
    position: relative;
    padding-block: 50px;
    box-sizing: border-box;
}

.tw-popup *,
.tw-popup *::before,
.tw-popup *::after {
    box-sizing: border-box;
}

/* Section title */
.tw-popup__title-container {
    text-align: center;
    width: 100%;
}

.tw-popup__section-title {
    font-size: 2rem;
    margin: 0 0 28px;
    line-height: 1.2;
}

/* Grid */
.tw-popup__grid-wrapper {
    width: 100%;
}

.tw-popup__grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 24px;
    width: 100%;
}

/* Card (button) */
.tw-popup__card {
    position: relative;
    display: block;
    width: 100%;
    min-width: 0;
    aspect-ratio: 328 / 465;
    padding: 0;
    margin: 0;
    background: #fff;
    border: 0;
    overflow: hidden;
    cursor: pointer;
    text-align: left;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    font: inherit;
    color: inherit;
}

.tw-popup__card:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.tw-popup__card-image {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.tw-popup__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    display: block;
}

.tw-popup__card:hover .tw-popup__image {
    transform: scale(1.05);
}

/* Card overlay */
.tw-popup__overlay {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 2rem 1.5rem 1.5rem;
    color: #fff;
    background: linear-gradient(
        to top,
        var(--tw-popup-overlay-start, rgba(0, 0, 0, 0.8)) 0%,
        var(--tw-popup-overlay-mid, rgba(0, 0, 0, 0.4)) 50%,
        var(--tw-popup-overlay-end, rgba(0, 0, 0, 0)) 100%
    );
}

.tw-popup__overlay-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.tw-popup__card-title {
    margin: 0;
    line-height: 1.3;
    text-align: left;
    font-size: 1.4rem;
    color: #fff;
}

.tw-popup__read-more {
    display: inline-block;
    align-self: flex-start;
    color: #fff;
    font-size: 18px;
    font-weight: 400;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.3s ease, text-decoration-thickness 0.3s ease;
}

.tw-popup__card:hover .tw-popup__read-more {
    text-decoration-thickness: 2px;
}

/* Mobile slider */
.tw-popup__slider {
    display: none;
    width: 100%;
}

.tw-popup__slider-wrapper {
    overflow: visible;
    max-width: 100%;
}

.tw-popup__slider-track {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    max-width: 100%;
    overflow: hidden;
}

.tw-popup__slide {
    flex: 0 0 auto;
    display: none;
    justify-content: center;
    opacity: 0.5;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.tw-popup__slide[data-position="prev"],
.tw-popup__slide[data-position="current"],
.tw-popup__slide[data-position="next"] {
    display: flex;
}

.tw-popup__slide[data-position="current"] {
    opacity: 0.9;
    transform: scale(1);
}

.tw-popup__slide .tw-popup__card {
    width: 280px;
    height: 400px;
    aspect-ratio: auto;
    margin: 0 auto;
}

/* Nav */
.tw-popup__nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    margin-top: 20px;
    width: 100%;
}

.tw-popup__nav-btn {
    width: 48px;
    height: 48px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    color: #FF673E;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease, transform 0.2s ease;
}

.tw-popup__nav-btn:hover {
    transform: scale(1.05);
}

.tw-popup__nav-btn svg {
    width: 40px;
    height: 40px;
    stroke: currentColor;
}

/* Popup modal */
.tw-popup__modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

.tw-popup__modal-overlay[hidden] {
    display: none;
}

.tw-popup__modal-overlay.is-open {
    animation: tw-popup-overlay-fade 0.2s ease-out;
}

@keyframes tw-popup-overlay-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.tw-popup__modal-content {
    position: relative;
    background: #fff;
    border-radius: 16px;
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    margin: auto;
    flex-shrink: 0;
    animation: tw-popup-modal-in 0.3s ease-out;
}

@keyframes tw-popup-modal-in {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to   { opacity: 1; transform: scale(1)   translateY(0); }
}

.tw-popup__close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: #333;
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease, transform 0.3s ease;
    z-index: 10;
    padding: 0;
}

.tw-popup__close:hover {
    background: #FF673E;
    transform: scale(1.1);
}

.tw-popup__modal-header {
    padding: 2rem 2rem 1rem;
    border-bottom: 1px solid #e9ecef;
}

.tw-popup__modal-title {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.3;
}

.tw-popup__modal-body {
    padding: 1.5rem 2rem 2rem;
}

.tw-popup__modal-image-wrap {
    margin-bottom: 1.5rem;
}

.tw-popup__modal-image-wrap:empty {
    display: none;
}

.tw-popup__modal-image-wrap img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: cover;
    border-radius: 8px;
}

.tw-popup__modal-text {
    line-height: 1.6;
    font-size: 1rem;
}

.tw-popup__modal-text p { margin: 0 0 1rem; }
.tw-popup__modal-text p:last-child { margin-bottom: 0; }
.tw-popup__modal-text img { max-width: 100%; height: auto; }

/* Marker class while a popup is open.
 * Scroll locking is handled in JS via `overflow:hidden` on <html> + <body>
 * (with scrollbar-width compensation). We intentionally do NOT use
 * `position: fixed` here because it causes a visible scroll jump when the
 * popup closes. This class is kept so themes can hook into the open state
 * (e.g. hide a sticky header while a popup is visible). */
body.tw-popup-lock {
    /* no layout rules – JS handles overflow on html/body */
}

/* Responsive */
@media (max-width: 1024px) {
    .tw-popup__card-title { font-size: 1.5rem; }
}

@media (max-width: 768px) {
    .tw-popup__section-title { font-size: 2rem; }

    /* When slider enabled it is shown via widget-specific inline media rules.
       The grid is hidden in that same rule. These fallbacks cover cases where
       the slider is disabled. */
    .tw-popup__slider { display: block; max-width: 100%; }
    .tw-popup__slide .tw-popup__card { width: 260px; height: 370px; }
    .tw-popup__slide .tw-popup__card-title { font-size: 1.25rem; }
    .tw-popup__slide .tw-popup__overlay { padding: 1.5rem 1rem 1rem; }

    .tw-popup__modal-overlay {
        padding: 0.5rem;
        align-items: flex-start;
        padding-top: 1rem;
        padding-bottom: 1rem;
    }
    .tw-popup__modal-content {
        max-height: calc(100vh - 2rem);
        border-radius: 12px;
        width: calc(100% - 1rem);
        max-width: none;
    }
    .tw-popup__modal-header { padding: 1.5rem 1.5rem 1rem; }
    .tw-popup__modal-title  { font-size: 1.5rem; }
    .tw-popup__modal-body   { padding: 1rem 1.5rem 1.5rem; }
    .tw-popup__close {
        top: 0.75rem;
        right: 0.75rem;
        width: 36px;
        height: 36px;
        font-size: 1.25rem;
    }
}

@media (max-width: 480px) {
    .tw-popup__slide .tw-popup__card { width: 240px; height: 340px; }
    .tw-popup__slide .tw-popup__card-title { font-size: 1.125rem; }
    .tw-popup__slide .tw-popup__read-more  { font-size: 1.125rem; }
    .tw-popup__slide .tw-popup__overlay    { padding: 1rem 0.75rem 0.75rem; }

    .tw-popup__modal-overlay {
        padding: 0.25rem;
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
    .tw-popup__modal-content {
        width: calc(100% - 0.5rem);
        max-height: calc(100vh - 1rem);
        border-radius: 8px;
    }
    .tw-popup__modal-header { padding: 1rem; }
    .tw-popup__modal-title  { font-size: 1.25rem; }
    .tw-popup__modal-body   { padding: 1rem; }
    .tw-popup__modal-text   { font-size: 0.9rem; }
    .tw-popup__modal-image-wrap img { max-height: 250px; }
}
