:root {
  --rdvbiz-brand-25: 230 230 242;
  --rdvbiz-brand-50: 194 194 235;
  --rdvbiz-brand-100: 153 204 204;
  --rdvbiz-brand-200: 133 133 214;
  --rdvbiz-brand-300: 106 106 205;
  --rdvbiz-brand-400: 79 79 196;
  --rdvbiz-brand-500: 60 60 180;
  --rdvbiz-brand-600: 51 51 153;
  --rdvbiz-brand-700: 37 37 111;
  --rdvbiz-brand-800: 23 23 69;
  --rdvbiz-brand-900: 9 9 27;
}

rdvbiz-widget a,
nexcalia-widget a {
    text-decoration: none;
    color: rgb(0, 103, 172);
}

rdvbiz-widget a:not(.rdvbiz-widget-btn):hover,
nexcalia-widget a:not(.rdvbiz-widget-btn):hover {
    text-decoration: underline;
}

rdvbiz-widget a.rdvbiz-widget-btn,
nexcalia-widget a.rdvbiz-widget-btn {
    display: inline-flex;
    align-items: center;
    padding: 2px 5px;
    border: 1px solid #93c5fd;
    border-radius: 0.375rem;
    box-shadow: 0 1px 2px 0 rgba(99, 102, 241, 0.05), 0 1px 3px 1px rgba(99, 102, 241, 0.1);
    background-color: #ffffff;
}

rdvbiz-widget a.rdvbiz-widget-btn:hover,
nexcalia-widget a.rdvbiz-widget-btn:hover {
    background-color: #93c5fd;
}

rdvbiz-widget a.rdvbiz-widget-btn:focus,
nexcalia-widget a.rdvbiz-widget-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px #93c5fd;
}

rdvbiz-widget a.rdvbiz-widget-btn.rdvbiz-widget-fab,
nexcalia-widget a.rdvbiz-widget-btn.rdvbiz-widget-fab {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    z-index: 10;
}

/* The dialog keeps the browser's fixed, centered position; its body scrolls, not the host page */
dialog.rdvbd {
    box-sizing: border-box;
    /* The widget content (58rem with its margins) centred with 2.5rem of air on each side */
    width: min(94vw, 63rem);
    max-width: 94vw;
    max-height: 90vh;
    /* Anchored near the top, so a step of another height does not move it */
    margin: 5vh auto auto;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: #ffffff;
    color: #111111;
    overflow: hidden;
}
dialog.rdvbd[open] {
    display: flex;
    flex-direction: column;
    animation: 0.3s rdvbFadeIn;
}
/* Opacity only: a transform would make the dialog the box of its fixed children (reading guides, panel) */
@keyframes rdvbFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}
dialog.rdvbd::backdrop {
    background: rgba(0, 0, 0, 0.5);
    animation: 0.3s rdvbBackdropIn;
}
@keyframes rdvbBackdropIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}
.rdvbd-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    /* No inset: the widget centres its content, and its footer reaches the edges like the close button */
    padding: 0;
}
.rdvbd-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: none;
    border-radius: 9999px;
    /* Opaque: the dialog body scrolls under it */
    background: #ffffff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.16);
    color: inherit;
    cursor: pointer;
    font: inherit;
}
.rdvbd-close:hover {
    background: #f2f2f2;
}
.rdvbd-close:focus-visible {
    outline: 2px solid rgb(var(--rdvbiz-brand-600) / 1);
    outline-offset: 2px;
}
.rdvbd-close svg {
    width: 1.125rem;
    height: 1.125rem;
}

iframe.rdvbf {
    display: block;
    border: none;
    width: 100%;
    max-width: 100%;
    padding: 0;
}

/* Phone buttons: drawn only when the widget asks for them, and only below 833px */
.button-wrapper {
    display: none;
}
.button-wrapper[hidden] {
    display: none !important;
}
.button-next-prev {
    font-size: 1rem;
    line-height: 1.5rem;
    padding: .5rem 1rem;
    background-color: rgb(var(--rdvbiz-brand-600) / 1);
    border-radius: .5rem;
    color: white;
    display: inline-flex;
    width: 100%;
}
.button-next-prev.button-next-prev-disabled {
    background-color: rgb(var(--rdvbiz-brand-25) / 1);
    color: rgb(255 255 255 / 1);
    cursor: not-allowed;
}
/* The host page may not reset buttons, and has none of the Tailwind classes the buttons carry */
:where(.button-wrapper) button {
    border: none;
    cursor: pointer;
    font-family: inherit;
}
.button-wrapper svg {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
}
/* The page stays put behind an open dialog; CSS lets go by itself when the dialog closes or leaves the page */
html:has(dialog.rdvbd[open]) {
    overflow: hidden;
}
/*
 * Full screen up to 900px: the widget then has the whole width, so it switches to its phone layout (below 833px)
 * exactly when the page does, and the Next/Back buttons always show on one side or the other
 */
@media (max-width: 900px) {
    dialog.rdvbd {
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-height: 100vh;
        max-height: 100dvh;
        margin: 0;
        inset: 0;
        border-radius: 0;
    }
}
@media (max-width: 832px) {
    /* Frosted glass bar, as on iOS: the page stays readable behind the buttons */
    .button-wrapper {
        display: flex;
        flex-direction: row-reverse;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: auto;
        z-index: 999998;
        padding: .75rem 5% calc(.75rem + env(safe-area-inset-bottom, 0px));
        background-color: rgb(255 255 255 / .5);
        border-top: 1px solid rgb(0 0 0 / .08);
        -webkit-backdrop-filter: saturate(180%) blur(10px);
        backdrop-filter: saturate(180%) blur(10px);
    }
    @supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
        .button-wrapper {
            background-color: rgb(255 255 255 / .95);
        }
    }
    /* In a dialog the bar is its footer, below the scrolling body */
    dialog.rdvbd .button-wrapper {
        position: static;
        flex: none;
    }
    .button-next {
        font-size: 1rem;
        line-height: 1.5rem;
        padding: .5rem 1rem;
        background-color: rgb(var(--rdvbiz-brand-600) / 1);
        border-radius: .5rem;
        color: white;
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .button-prev {
        font-size: 1rem;
        line-height: 1.5rem;
        padding: .5rem 1rem;
        background-color: white;
        border-radius: .5rem;
        color: rgb(var(--rdvbiz-brand-600) / 1);
        border: 0.1rem solid rgb(var(--rdvbiz-brand-600) / 1);
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-right: 1rem;
    }
    .button-next.button-next-prev-disabled {
        background-color: rgb(var(--rdvbiz-brand-25) / 1);
        color: rgb(255 255 255 / 1);
        cursor: not-allowed;
    }
}

/* Optional brand navigation glyphs; other brands keep their native SVG paths. */
.button-wrapper :is(.button-next, .button-prev) svg {
    background-color: var(--rdvbiz-brand-navigation-icon-fill, transparent);
    -webkit-mask: var(--rdvbiz-navigation-mask, none) center / auto 1rem no-repeat;
    mask: var(--rdvbiz-navigation-mask, none) center / auto 1rem no-repeat;
}
.button-wrapper .button-next svg { --rdvbiz-navigation-mask: var(--rdvbiz-brand-navigation-next-mask, none); }
.button-wrapper .button-prev svg { --rdvbiz-navigation-mask: var(--rdvbiz-brand-navigation-prev-mask, none); }
.button-wrapper :is(.button-next, .button-prev) svg path {
    opacity: var(--rdvbiz-brand-navigation-path-opacity, 1);
}
