/* apply-tab.css — the fixed "apply now" tab.
 *
 * Loaded site-wide from components/layout/default.blade.php, so it is one file
 * for both locales rather than the same edit landing twice in style.css (ar)
 * and en.css (en).
 */

.ul-apply-tab {
    /* Single source of truth for the slide's length. */
    --at-dur: .55s;

    position: fixed;
    top: 50%;
    inset-inline-end: 0;

    /* Two jobs in one transform: translateY centres the tab (`top: 50%` only
       puts its TOP edge at the middle of the viewport), and translateX parks it
       off the edge until apply-tab.js adds `is-in`.

       Every state writes the WHOLE transform out. An earlier version kept the X
       offset in a custom property and wrote `translateX(var(--at-off))` once —
       the variable updated correctly but the transform did not follow it, so
       the tab rendered a full state behind: the class said visible while it sat
       off-screen. A var() inside a transitioned transform cannot be relied on.

       Hidden is the resting state on purpose — if the script never runs the tab
       stays away rather than appearing stuck over the hero. */
    transform: translateY(-50%) translateX(115%);
    opacity: 0;
    pointer-events: none;

    /* Under the header (60) and well under the curtain, so neither is ever
       obscured by it. */
    z-index: 50;

    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 172px;

    background: var(--ul-primary);
    color: #fff;
    text-decoration: none;

    /* Logical, so the rounded corners stay on the side facing the page and the
       flat edge stays against the viewport edge in both directions. */
    border-start-start-radius: 14px;
    border-end-start-radius: 14px;

    /* Gold edge, in every state rather than only over the open panel. The tab
       is painted in the same navy as the heroes it sits on for most of the
       site, so with no edge it dissolves into whatever is behind it.

       Bare on the inline-end side on purpose. That edge is flush with the
       viewport (`inset-inline-end: 0` above) and it is the side the scrollbar
       runs down — the left in Arabic — so a line there reads as a seam against
       the screen edge rather than as part of the control. It is the same edge
       the radii above deliberately leave square, for the same reason. */
    border: 1px solid var(--ul-c3, #febe35);
    border-inline-end: 0;

    box-shadow: 0 10px 30px -10px rgba(11, 37, 78, .55);

    /* ONE transition declaration, and the `.is-in` rule below must never
       restate it.

       It used to be declared twice, because `visibility` needs a delay leaving
       and none arriving, which a single shorthand cannot express. That cost was
       invisible until tested: a second shorthand on a more specific selector
       silently won over the base one, and the tab animated IN at full length
       but snapped OUT instantly. Keyboard focus is handled by `inert` in
       apply-tab.js instead, which needs no timing at all. */
    transition: transform var(--at-dur) cubic-bezier(.22, 1, .36, 1),
                opacity calc(var(--at-dur) * .7) ease,
                background .3s ease,
                width .35s cubic-bezier(.22, 1, .36, 1),
                box-shadow .35s ease;
}

/* Arabic parks it off the left edge instead of the right. */
[dir="rtl"] .ul-apply-tab {
    transform: translateY(-50%) translateX(-115%);
}

/* Both directions spelled out so this beats the [dir] rule above on
   specificity rather than on source order — a later edit that moves these
   blocks around must not be able to strand the tab off-screen. */
[dir="ltr"] .ul-apply-tab.is-in,
[dir="rtl"] .ul-apply-tab.is-in {
    transform: translateY(-50%) translateX(0);
    opacity: 1;
    pointer-events: auto;
}

/* The label is rotated with a transform, NOT `writing-mode: vertical-rl`.
   A vertical writing mode rotates each glyph independently, which breaks the
   cursive joins Arabic depends on — قدّم الآن comes apart into loose letters.
   Rotating the whole line keeps the text shaped and simply turns it on its
   side.
   It is positioned absolutely and centred because a rotation is visual only:
   the element still occupies its unrotated width in layout, which would push
   the 46px strip open if it were a normal flex child. */
.ul-apply-tab-in {
    position: absolute;
    top: 50%;
    /* Physical `left`, deliberately. `inset-inline-start` resolves to `right`
       in Arabic, which then fights the -50% translate and threw the label clean
       off the side of the strip. The strip is symmetric, so centring inside it
       has no direction to respect — only the rotation below does. */
    left: 50%;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    white-space: nowrap;
    font-size: var(--t-label);
    font-weight: 700;
    line-height: var(--lh-ui);
}

/* Reading direction differs by side. On the right edge (English) the label
   reads downwards; on the left edge (Arabic) it reads upwards. Both are the
   conventional way round for a tab on that side. */
[dir="ltr"] .ul-apply-tab-in {
    transform: translate(-50%, -50%) rotate(90deg);
}

[dir="rtl"] .ul-apply-tab-in {
    transform: translate(-50%, -50%) rotate(-90deg);
}

/* The icon is counter-rotated so it stays upright while the words turn. */
[dir="ltr"] .ul-apply-tab-in i {
    transform: rotate(-90deg);
}

[dir="rtl"] .ul-apply-tab-in i {
    transform: rotate(90deg);
}

.ul-apply-tab-in i {
    font-size: 15px;
}

.ul-apply-tab:hover,
.ul-apply-tab:focus-visible {
    background: var(--ul-c3);
    color: var(--ul-primary);
    width: 54px;
    box-shadow: 0 14px 34px -10px rgba(11, 37, 78, .65);
}

.ul-apply-tab:focus-visible {
    outline: 3px solid var(--ul-c3);
    outline-offset: 3px;
}

/* The full-screen navigation covers the page; a tab floating over it would be
   the only thing not dimmed. nav-curtain.js puts this class on <body>.
   It deliberately does NOT set `transform` — doing so would discard both the
   centring and the slide offset. Fading alone is enough here.

   ALL FOUR SELECTORS ARE THE FIX, not verbosity. This was written as the bare
   `.ul-curtain-open .ul-apply-tab`, which is (0,2,0) — and the state it has to
   overrule, `[dir="rtl"] .ul-apply-tab.is-in`, is (0,3,0). It lost. The tab
   only *looked* hidden because it is parked off-screen near the top of a page,
   which is where the menu is usually opened from; scroll far enough for the
   tab to slide in, then open the menu, and it stayed there over the panel.

   The `.is-in` pair is (0,4,0), which clears (0,3,0) outright rather than
   tying with it and leaning on source order. */
[dir="ltr"] .ul-curtain-open .ul-apply-tab,
[dir="rtl"] .ul-curtain-open .ul-apply-tab,
[dir="ltr"] .ul-curtain-open .ul-apply-tab.is-in,
[dir="rtl"] .ul-curtain-open .ul-apply-tab.is-in {
    opacity: 0;
    pointer-events: none;
}

/* Under 1200px the page container has only 15px of side padding, so a strip
   on the viewport edge sat over the end of every line of text. The tab becomes
   a pill in the bottom corner instead: nothing to rotate, nothing to centre,
   and it sizes itself from its label. The `.is-in` slide is kept — it now
   comes in from the bottom. */
@media (max-width: 1199.98px) {
    .ul-apply-tab {
        top: auto;
        inset-inline-end: 16px;
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        width: auto;
        height: auto;
        padding: 10px 18px;
        border-radius: 999px;
        border-inline-end: 1px solid var(--ul-c3, #febe35);
        transform: translateY(24px);
    }

    [dir="rtl"] .ul-apply-tab {
        transform: translateY(24px);
    }

    [dir="ltr"] .ul-apply-tab.is-in,
    [dir="rtl"] .ul-apply-tab.is-in {
        transform: translateY(0);
    }

    .ul-apply-tab:hover,
    .ul-apply-tab:focus-visible {
        width: auto;
    }

    .ul-apply-tab-in {
        position: static;
        gap: 8px;
    }

    [dir="ltr"] .ul-apply-tab-in,
    [dir="rtl"] .ul-apply-tab-in,
    [dir="ltr"] .ul-apply-tab-in i,
    [dir="rtl"] .ul-apply-tab-in i {
        transform: none;
    }

    /* The portal pages carry their own apply dock in the same corner. */
    .has-intl-dock .ul-apply-tab {
        display: none;
    }
}


