/* widgets.css — the floating widgets against the site's own fixed elements.
 *
 * Loaded site-wide from components/layout/default.blade.php. The Tawk.to
 * bubble is positioned through Tawk_API.customStyle in assets/js/widgets.js
 * (it lives in an iframe this sheet cannot reach); this file places the
 * site's own back-to-top arrow (.ul-totop, at the end) and the Cocoon
 * accessibility launcher (#cocoon-a11y-btn) and its panel.
 *
 * The widget appends its own <style> to <head> on DOMContentLoaded, i.e. AFTER
 * this sheet, with bare `#id` rules (0,1,0). Every rule here is written as
 * `body #id` (0,1,1) so it wins on specificity rather than on source order.
 * The launcher's `left`/`right` are inline styles set by the script and are
 * left alone — only `bottom` and `z-index` are adjusted.
 */

/* Under the navigation curtain and the page-transition curtain (9998), over
   the header (60) and the apply tab (50). The vendor default is ~2^31, which
   left the launcher floating over the open menu. Launcher above panel, as the
   vendor orders them. */
body #cocoon-a11y-btn {
    z-index: 9001;
}

body #cocoon-a11y-panel {
    z-index: 9000;
}

/* Under 1200px the apply tab becomes a pill in the bottom inline-end corner
   (apply-tab.css) — the LEFT in Arabic, which is where the launcher sits. Lift
   the launcher to the same height as the chat bubble on the other side
   (yOffset 90 in widgets.js) so the pill keeps the corner. English puts the
   pill on the right, away from the launcher, so nothing moves there. */
@media (max-width: 1199.98px) {
    [dir="rtl"] body #cocoon-a11y-btn {
        bottom: 90px;
    }

    [dir="rtl"] body #cocoon-a11y-panel {
        bottom: 160px;
        max-height: calc(100vh - 176px);
    }
}

/* The portal pages carry an apply dock across the bottom: bottom inline-end
   on a desktop, a full-width bar on a phone (international.css). The dock
   component puts `has-intl-dock` on <body>. Lift the launcher clear of it in
   both directions; the chat bubble gets the matching lift in widgets.js. */
body.has-intl-dock #cocoon-a11y-btn {
    bottom: 110px;
}

body.has-intl-dock #cocoon-a11y-panel {
    bottom: 180px;
    max-height: calc(100vh - 196px);
}

/* ---- Back to top -----------------------------------------------------------
 *
 * The old site's `.scroll-up-button`: a navy circle in the bottom-RIGHT with
 * an up arrow, gold on hover. Rendered by components/layout/widgets.blade.php,
 * revealed by assets/js/widgets.js with `is-in` after ~400px of scroll.
 *
 * PHYSICAL `right`, not inset-inline-end, on purpose. The accessibility
 * launcher is physically bottom-left in both locales (config/widgets.php), so
 * the arrow takes the opposite corner in both — a logical property would have
 * put the two on top of each other in Arabic.
 *
 * What else lives in the bottom-right, from the bottom up:
 *   - the apply pill under 1200px, in ENGLISH only (inline-end; apply-tab.css),
 *     16px up and ~42px tall;
 *   - the portal apply dock on `has-intl-dock` pages (international.css),
 *     22px up and ~70px tall, a full-width bar 12px up under 576px;
 *   - the chat bubble, both locales, 90px up (120px on dock pages), ~60px tall,
 *     only when widgets.js has put `has-chat` on <body>.
 * The arrow sits at 20px and is lifted only when one of those is under it.
 * Hidden is the resting state so a script that never runs leaves nothing
 * floating over the page.
 */
.ul-totop {
    position: fixed;
    right: 20px;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));

    /* Over the apply tab (50) and the header (60); under the chat bubble, the
       a11y launcher (9000+) and both curtains (9998). */
    z-index: 100;

    display: flex;
    align-items: center;
    justify-content: center;
    /* Same 60px disc as the a11y launcher (data-size 60) and the chat bubble. */
    width: 60px;
    height: 60px;
    padding: 0;

    border-radius: 50%;
    background: var(--ul-primary, #0b254e);
    color: #fff;
    /* Gold edge, as the apply tab has — the arrow is painted in the same navy
       as the heroes and the footer it floats over. */
    border: 1px solid var(--ul-c3, #febe35);
    box-shadow: 0 10px 30px -10px rgba(11, 37, 78, .55);
    cursor: pointer;
    font-size: 22px;
    line-height: 1;

    opacity: 0;
    transform: translateY(16px);
    pointer-events: none;

    transition: transform .45s cubic-bezier(.22, 1, .36, 1),
                opacity .3s ease,
                background .3s ease,
                color .3s ease,
                box-shadow .3s ease;
}

.ul-totop.is-in {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Same inversion as .ul-btn:hover and the apply tab: gold ground, navy glyph. */
.ul-totop:hover,
.ul-totop:focus-visible {
    background: var(--ul-c3, #febe35);
    color: var(--ul-primary, #0b254e);
    box-shadow: 0 14px 34px -10px rgba(11, 37, 78, .65);
}

.ul-totop:focus-visible {
    outline: 3px solid var(--ul-c3, #febe35);
    outline-offset: 3px;
}


/* ───────────────────────────────────────────── the chat launcher (ours)

   Tawk's bubble is hidden by widgets.js and this stands in its place —
   the same 60px navy disc with a gold edge as the back-to-top arrow, at
   the offset Tawk's own bubble used (90px, and 120px on the portal pages
   whose dock takes the corner), so nothing around it moves. */

.ul-chat {
    position: fixed;
    right: 20px;
    bottom: calc(90px + env(safe-area-inset-bottom, 0px));

    /* Above the arrow (100) and the apply tab (50); below both curtains. */
    z-index: 110;

    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    padding: 0;

    border-radius: 50%;
    background: var(--ul-primary, #0b254e);
    color: #fff;
    /* NO RING. The back-to-top arrow beside it carries the gold edge; the
       chat bubble is a plain navy disc, which is what it was before the
       dashboard's logo took its place. */
    border: 0;
    box-shadow: 0 10px 30px -10px rgba(11, 37, 78, .55);
    cursor: pointer;
    font-size: 22px;
    line-height: 1;

    transition: background .3s ease, color .3s ease, box-shadow .3s ease, transform .3s ease;
}

.ul-chat[hidden] {
    display: none;
}

/* Sized here rather than on the element, so one rule covers the disc at
   every breakpoint. The mark is drawn in currentColor and inverts with the
   disc on hover. */
.ul-chat-icon {
    width: 30px;
    height: 30px;
    display: block;
}

.ul-chat:focus-visible {
    outline: 3px solid var(--ul-c3, #febe35);
    outline-offset: 3px;
}

/* Unread messages, as Tawk's own bubble counted them. */
.ul-chat-badge {
    position: absolute;
    inset-block-start: -2px;
    inset-inline-end: -2px;

    min-width: 20px;
    height: 20px;
    padding: 0 5px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 999px;
    background: #e03131;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

.ul-chat-badge[hidden] {
    display: none;
}

/* The portal dock lifts the chat the same way it lifts the arrow. */
.has-intl-dock .ul-chat {
    bottom: calc(120px + env(safe-area-inset-bottom, 0px));
}

/* Under 1200px the English apply pill owns the corner; the arrow moves up to
   90px, so the chat moves above it. */
@media (max-width: 1199.98px) {
    [dir="ltr"] .ul-chat {
        bottom: calc(160px + env(safe-area-inset-bottom, 0px));
    }

    [dir="ltr"] .has-intl-dock .ul-chat {
        bottom: calc(190px + env(safe-area-inset-bottom, 0px));
    }
}

@media (max-width: 500px) {
    .ul-chat {
        right: 14px;
    }
}

.ul-curtain-open .ul-chat {
    opacity: 0;
    pointer-events: none;
}

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

/* The open navigation covers the page; nothing of the page should float over
   it. nav-curtain.js puts this class on <body>. Both selectors so the `.is-in`
   state (0,2,0) is beaten outright, not by source order. */
.ul-curtain-open .ul-totop,
.ul-curtain-open .ul-totop.is-in {
    opacity: 0;
    pointer-events: none;
}

/* Under 1200px the English apply pill takes the bottom-right corner. Lift the
   arrow over it to the bubble's own height, and when the bubble is there too,
   over the bubble (90px + ~60px + a gap). Arabic parks the pill bottom-LEFT,
   so the arrow keeps the corner there. */
@media (max-width: 1199.98px) {
    [dir="ltr"] .ul-totop {
        bottom: calc(90px + env(safe-area-inset-bottom, 0px));
    }

    [dir="ltr"] .has-chat .ul-totop {
        bottom: calc(160px + env(safe-area-inset-bottom, 0px));
    }
}

/* The portal apply dock takes the bottom-right in both locales (and hides the
   apply pill). Over the dock, and over the bubble when it is there, which on
   those pages is at 120px. After the media block so these win at every width
   when the two tie on specificity. */
.has-intl-dock .ul-totop {
    bottom: calc(110px + env(safe-area-inset-bottom, 0px));
}

.has-intl-dock.has-chat .ul-totop {
    bottom: calc(190px + env(safe-area-inset-bottom, 0px));
}

/* Phone: keep the 60px disc (the a11y launcher stays 60px here too) and sit
   14px from the edge, level with the launcher on the other side. */
@media (max-width: 500px) {
    .ul-totop {
        right: 14px;
    }
}

/* --------------------------------------------------------------------------
   Footer — an uploaded image standing in for a button's icon.
   App\Support\Footer lets an editor file a picture on an app-store or social
   post; it is drawn where the Font Awesome glyph would be, at the glyph's
   size, so a custom mark lines up with the icons beside it.
   -------------------------------------------------------------------------- */
.app-download-btn img,
.ul-footer-socials a img {
    width: 1.1em;
    height: 1.1em;
    object-fit: contain;
    flex: none;
}
