/*
 * TravelKon Popup
 *
 * Built on <dialog>, so the browser supplies the backdrop, the focus trap and
 * ESC-to-close. Clicking the backdrop lands on the <dialog> element itself,
 * which is what the script uses to detect an outside click -- no extra overlay
 * div, no scroll-lock bookkeeping.
 */

.tkpb {
    width: min(920px, calc(100vw - 2rem));
    max-width: 100%;
    max-height: 90dvh;
    display: flex;
    padding: 0;
    border: 0;
    border-radius: 14px;
    background: #fff;
    color: #1d1d1f;
    overflow: hidden;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
}

/* The custom flex display must not override dialog:not([open])'s hidden state. */
.tkpb:not([open]) { display: none; }
.tkpb[open] { display: flex; }

.tkpb::backdrop {
    background: rgba(12, 6, 22, .34);
    backdrop-filter: blur(2px);
}

/* dvh is recent-ish; vh keeps older mobile Safari from overflowing. */
@supports not (height: 1dvh) {
    .tkpb { max-height: 90vh; }
    .tkpb--image-only,
    .tkpb--image-only .tkpb__box { max-height: min(var(--tkpb-image-size, 60vw), 72vh); }
    .tkpb--image-only .tkpb__img { max-height: min(var(--tkpb-image-size, 60vw), 72vh); }
}

.tkpb[open] {
    animation: tkpb-in .18s ease-out;
}

@keyframes tkpb-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .tkpb[open] { animation: none; }
}

.tkpb__box {
    display: grid;
    grid-template-columns: 1fr;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Two columns only when there is room; below this the image stacks on top. */
@media (min-width: 720px) {
    .tkpb--media .tkpb__box {
        grid-template-columns: 5fr 6fr;
        align-items: stretch;
    }
}

/* Image-only campaigns should not reserve an empty text column. */
.tkpb--image-only {
    width: auto;
    width: fit-content;
    max-width: calc(100vw - 2rem);
    max-height: min(var(--tkpb-image-size, 60vw), 72dvh);
}

.tkpb--image-only .tkpb__box {
    display: block;
    flex: 0 0 auto;
    width: auto;
    width: fit-content;
    max-height: min(var(--tkpb-image-size, 60vw), 72dvh);
    overflow: hidden;
}

.tkpb--image-only .tkpb__body {
    display: none;
}

.tkpb--image-only .tkpb__media {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: auto;
    width: fit-content;
    border-radius: 14px;
    overflow: hidden;
}

.tkpb--image-only .tkpb__img {
    display: block;
    width: auto;
    max-width: min(var(--tkpb-image-size, 60vw), calc(100vw - 2rem));
    height: auto !important;
    max-height: min(var(--tkpb-image-size, 60vw), 72dvh);
    aspect-ratio: auto !important;
    object-fit: initial;
    background: transparent;
    border-radius: 14px;
}

.tkpb__img--loading { opacity: 0; }

/* ---------- close ---------- */

.tkpb__close {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #d63638;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
}

.tkpb__close svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    fill: none;
}

.tkpb__close:hover { background: #b42325; }

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

/* A quiet re-entry point remains after the modal is dismissed. */
.tkpb__tab {
    position: fixed;
    z-index: 2147483000;
    top: 42%;
    left: 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: min(190px, calc(100vw - 12px));
    padding: 11px 14px 11px 12px;
    border: 0;
    border-radius: 0 12px 12px 0;
    background: var(--tkpb-accent, #351559);
    color: var(--tkpb-accent-text, #fff);
    box-shadow: 0 7px 22px rgba(12, 6, 22, .2);
    font: inherit;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: .04em;
    text-align: left;
    text-transform: uppercase;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease;
}

.tkpb__tab:hover { transform: translateX(4px); box-shadow: 0 9px 26px rgba(12, 6, 22, .28); }
.tkpb__tab:focus-visible { outline: 3px solid #fff; outline-offset: -5px; }
.tkpb__tab[hidden] { display: none; }
.tkpb__tab-dot { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: #ffcc42; box-shadow: 0 0 0 3px rgba(255, 204, 66, .18); }
.tkpb__tab-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 719px) {
    .tkpb--image-only {
        width: auto;
        width: fit-content;
        max-width: calc(100vw - 24px);
        max-height: min(var(--tkpb-mobile-image-size, 70vw), 78dvh);
    }

    .tkpb--image-only .tkpb__box,
    .tkpb--image-only .tkpb__media {
        width: fit-content;
        max-height: min(var(--tkpb-mobile-image-size, 70vw), 78dvh);
    }

    .tkpb--image-only .tkpb__img {
        width: auto;
        max-width: min(var(--tkpb-mobile-image-size, 70vw), calc(100vw - 24px));
        max-height: min(var(--tkpb-mobile-image-size, 70vw), 78dvh);
        height: auto !important;
        object-fit: initial;
    }

    .tkpb__tab { top: 42%; right: auto; left: 0; bottom: auto; border-radius: 0 12px 12px 0; padding: 11px 12px; writing-mode: vertical-rl; text-orientation: mixed; }
    .tkpb__tab:hover { transform: translateX(4px); }
}

@media (prefers-reduced-motion: reduce) {
    .tkpb__tab { transition: none; }
}

/* ---------- media ---------- */

.tkpb__media {
    margin: 0;
    background: #f2f0f5;
}

.tkpb__img {
    display: block;
    width: 100%;
    height: 100%;
    max-height: 34dvh;
    object-fit: cover;
    aspect-ratio: 4 / 5;
}

@media (min-width: 720px) {
    .tkpb__img { max-height: none; }
}

/* ---------- body ---------- */

.tkpb__body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 26px 22px 24px;
}

@media (min-width: 720px) {
    .tkpb__body {
        justify-content: center;
        padding: 34px 32px;
    }
}

.tkpb__heading {
    margin: 0;
    font-size: clamp(1.25rem, 1.05rem + 1vw, 1.7rem);
    line-height: 1.2;
    font-weight: 700;
}

.tkpb__sub,
.tkpb__content { margin: 0; font-size: .95rem; line-height: 1.5; }

.tkpb__sub p,
.tkpb__content p { margin: 0 0 .5em; }

.tkpb__foot {
    font-size: .78rem;
    line-height: 1.45;
    opacity: .7;
}

/* ---------- form ---------- */

.tkpb__form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tkpb__field { display: block; }

.tkpb__form input[type="text"],
.tkpb__form input[type="email"] {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    border: 1px solid #d5d1dd;
    border-radius: 8px;
    background: #fff;
    /* 16px minimum stops iOS Safari zooming the viewport on focus. */
    font-size: 16px;
    line-height: 1.3;
    color: inherit;
}

.tkpb__form input:focus-visible {
    outline: 2px solid var(--tkpb-accent, #351559);
    outline-offset: 1px;
    border-color: transparent;
}

.tkpb__privacy {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: .82rem;
    line-height: 1.4;
}

.tkpb__privacy input {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    margin: 1px 0 0;
    accent-color: var(--tkpb-accent, #351559);
}

.tkpb__submit {
    padding: 13px 18px;
    border: 0;
    border-radius: 8px;
    background: var(--tkpb-accent, #351559);
    color: var(--tkpb-accent-text, #fff);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
}

.tkpb__submit:hover { filter: brightness(1.08); }

.tkpb__submit:focus-visible {
    outline: 2px solid var(--tkpb-accent, #351559);
    outline-offset: 2px;
}

/* ---------- countdown ---------- */

.tkpb-cd {
    display: inline-flex;
    flex-direction: column;
    gap: 2px;
    align-items: center;
    align-self: flex-start;
    padding: 8px 14px;
    border-radius: 10px;
    background: var(--tkpb-accent, #351559);
    color: var(--tkpb-accent-text, #fff);
    box-shadow: 0 2px 4px rgba(0, 0, 0, .12);
}

.tkpb-cd[hidden] { display: none; }

.tkpb-cd__heading[hidden] { display: none; }

.tkpb-cd__heading {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    opacity: .95;
}

.tkpb-cd__row[hidden] { display: none; }

.tkpb-cd__row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.tkpb-cd__unit { text-align: center; }

.tkpb-cd__num {
    display: block;
    /* Tabular figures plus a floor width: ticking digits never re-wrap the row. */
    min-width: 2ch;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}

.tkpb-cd__label {
    display: block;
    font-size: 10px;
    letter-spacing: .08em;
    text-transform: uppercase;
    opacity: .95;
}

.tkpb-cd__msg {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    text-align: center;
}

.tkpb-cd__msg[hidden] { display: none; }

/* Themes usually ship this, but the popup must not depend on that. */
.tkpb .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;
}
