/* colleges-deck.css — the homepage colleges section.
 *
 * Page-scoped on purpose: pushed via @push('styles') from
 * components/uowa/index/services.blade.php, so one file serves both locales and
 * none of this has to be mirrored into style.css AND en.css.
 *
 * Layout is a filtered deck — field tabs above, four tiles below. It replaced a
 * 12-tile wall that was also rendered a second time as a mobile Swiper, so the
 * twelve colleges appeared twice in the DOM. There is one copy now, responsive.
 *
 * Direction is handled with logical properties throughout, with two deliberate
 * exceptions marked below where a physical value is the correct answer.
 */

.ul-cdeck {
    /* The three field grounds.
     *
     * `science` uses var(--ul-primary) so it keeps tracking the per-locale brand
     * navy (#0b254e ar / #041C33 en). The other two are literals because no token
     * exists for them — they were picked to sit at the same depth as the navy and
     * differ only in hue, so the trio reads as one family rather than a rainbow.
     * White measures 12.05:1, 15.12:1 and 14.15:1 on them respectively. */
    --ulcd-health: #0e3b4a;
    --ulcd-science: var(--ul-primary);
    --ulcd-human: #2e2450;
    --ulcd-other: #33404d;

    --ulcd-ease: cubic-bezier(.22, 1, .36, 1);
    --ulcd-radius: 16px;

    /* How much of the photograph shows through when the card is at rest.
       Raised from .45 so the pictures actually read. The colour still leads,
       because the wash on top of them was lightened by more than this was
       raised — see the measurement note on .ul-cdeck-card::before. */
    --ulcd-photo-rest: .70;
}

/* ─────────────────────────────────────────────────────────── tabs */

.ul-cdeck-tabs-wrap {
    position: relative;
    margin-bottom: clamp(22px, 2.6vw, 34px);
}

.ul-cdeck-tabs {
    position: relative;
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.ul-cdeck-tab {
    position: relative;
    z-index: 2;
    appearance: none;
    cursor: pointer;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, .09);
    background: #fff;
    color: var(--ul-primary);
    transition: color .3s ease, border-color .3s ease,
                background-color .3s ease, transform .3s ease;
}

.ul-cdeck-tab-count {
    font-size: 11.5px;
    font-weight: 700;
    line-height: 1;
    padding: 3px 7px;
    border-radius: 999px;
    background: var(--ul-gray);
    color: var(--ul-primary);
    font-variant-numeric: tabular-nums;
    transition: background-color .28s var(--ulcd-ease), color .28s var(--ulcd-ease);
}

/* Hover matches the gallery page's filter buttons (.ul-gallery-filter-btn in
   style.css / en.css): fill with the primary colour and lift 2px.
 *
 * The selected tab is excluded on purpose — its background is the pill, which
 * is a separate absolutely-positioned element. Lifting the tab would slide the
 * label 2px off the pill sitting behind it. */
.ul-cdeck-tab:not([aria-selected="true"]):hover {
    background: var(--ul-primary);
    border-color: var(--ul-primary);
    color: #fff;
    transform: translateY(-2px);
}

.ul-cdeck-tab:not([aria-selected="true"]):hover .ul-cdeck-tab-count {
    background: var(--ul-c3);
    color: var(--ul-primary);
}

/* Solid by default so the selected tab is legible before the script runs, and
   still legible if it never does. */
.ul-cdeck-tab[aria-selected="true"] {
    color: #fff;
    background: var(--ul-primary);
    border-color: transparent;
}

/* Only once JS has actually positioned the pill does the tab hand its
   background over. The tab sits at z-index 2 and the pill at z-index 1, so
   leaving the tab's own background opaque would paint over the pill and render
   white text on white — the label vanishes entirely. */
.ul-cdeck-tabs.is-pill-ready .ul-cdeck-tab[aria-selected="true"] {
    background: transparent;
}

.ul-cdeck-tab[aria-selected="true"] .ul-cdeck-tab-count {
    background: var(--ul-c3);
    color: var(--ul-primary);
}

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

/* The sliding pill that sits behind the selected tab. Physical `left` and
   `transform: translateX()` on purpose: JS drives it from offsetLeft, which is
   measured from the container's left edge in BOTH directions, so a logical
   property here would fight the measurement rather than help it. */
.ul-cdeck-pill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: var(--ulcd-pill-w, 0);
    border-radius: 999px;
    background: var(--ul-primary);
    transform: translateX(var(--ulcd-pill-x, 0));
    transition: transform .5s var(--ulcd-ease), width .5s var(--ulcd-ease);
    pointer-events: none;
    z-index: 1;
    opacity: 0;
}

.ul-cdeck-pill.is-ready {
    opacity: 1;
}

/* Wrapping tabs would leave the pill stranded on the wrong row. The selected
   tab's own background (above) takes over — nothing extra needed here. */
.ul-cdeck-tabs.is-wrapped .ul-cdeck-pill {
    display: none;
}

/* ─────────────────────────────────────────────────────────── grid */

.ul-cdeck-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: clamp(12px, 1.2vw, 16px);
}

/* Compact at rest so twelve of them read as a tight block rather than a wall,
   then grown on hover — see the transform below. */
.ul-cdeck-card {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    min-height: 170px;
    padding: 18px;
    border-radius: var(--ulcd-radius);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    text-decoration: none;
    background: var(--ul-primary);
    transition: transform .38s var(--ulcd-ease), box-shadow .38s var(--ulcd-ease);
}

.ul-cdeck-card[data-field="health"] { background: var(--ulcd-health); }
.ul-cdeck-card[data-field="science"] { background: var(--ulcd-science); }
.ul-cdeck-card[data-field="human"] { background: var(--ulcd-human); }
.ul-cdeck-card[data-field="other"] { background: var(--ulcd-other); }

.ul-cdeck-card.is-hidden {
    display: none;
}

/* The photograph is always on the card, held back rather than hidden.
 *
 * It used to sit at opacity 0 and only arrive on hover, because twelve
 * photographs competing at full strength turned the grid into noise. Holding
 * them at --ulcd-photo-rest solves the same problem without emptying the card:
 * the brand colour still governs, the photo reads as texture underneath it, and
 * hover brings the picture the rest of the way up.
 *
 * It sits UNDER the colour wash (::before, z-index 1), which is what keeps the
 * name legible over an unknown photograph — see the contrast note there. */
.ul-cdeck-photo {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    opacity: var(--ulcd-photo-rest);
    transition: opacity .45s var(--ulcd-ease);
}

.ul-cdeck-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    /* Rests at its natural framing and zooms IN slightly on hover. The old
       1.14 → 1 ran the other way, which made sense only while the photo was
       arriving from nothing; on a photo that is already there it reads as the
       card pulling away from you. */
    transform: scale(1);
    transition: transform .75s var(--ulcd-ease);
}

.ul-cdeck-card:hover .ul-cdeck-photo,
.ul-cdeck-card:focus-visible .ul-cdeck-photo {
    opacity: 1;
}

.ul-cdeck-card:hover .ul-cdeck-photo img,
.ul-cdeck-card:focus-visible .ul-cdeck-photo img {
    transform: scale(1.06);
}

@media (hover: none) {
    /* Nothing to reveal and nothing to zoom, so the resting state is the whole
       state — the photo is already visible without a hover to earn it. */
    .ul-cdeck-photo img {
        transform: none;
    }

    /* Touch fires :hover on tap and then leaves it stuck until you tap
       elsewhere, so a tapped card would sit grown and shadowed over its
       neighbours while the next page loads. Nothing grows on touch. */
    .ul-cdeck-card:hover {
        transform: none;
        z-index: auto;
        box-shadow: none;
    }

    .ul-cdeck-card:hover .ul-cdeck-photo {
        opacity: var(--ulcd-photo-rest);
    }
}

/* The wash, tinted to the field so the photograph reads as part of the card
   rather than a picture behind a label.
 *
 * Lightened from .45→.92 so the pictures show. These alphas are measured, not
 * chosen — re-measure before changing them.
 *
 * The name is 15.5px/600 white, so WCAG AA asks 4.5:1, and it sits at 77.2%
 * down the card, where this ramp is at alpha .597. The worst backdrop across
 * the twelve live photographs is a blown-out rgb(254,254,254) patch in
 * 729df0ba, and the lightest of the four field colours is #33404d. Composited
 * — photo at --ulcd-photo-rest over that colour, then this wash over both —
 * white lands at 6.46:1 there. Raising the photo to .75 and dropping the wash
 * to .16→.70 still passes at 5.77:1; the pair below is the more conservative
 * of the two. */
.ul-cdeck-card::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(180deg, rgba(4, 28, 51, .18), rgba(4, 28, 51, .72));
    transition: opacity .36s var(--ulcd-ease);
}

.ul-cdeck-card[data-field="health"]::before {
    background: linear-gradient(180deg, rgba(14, 59, 74, .18), rgba(14, 59, 74, .72));
}

.ul-cdeck-card[data-field="science"]::before {
    background: linear-gradient(180deg, rgba(11, 37, 78, .18), rgba(11, 37, 78, .72));
}

.ul-cdeck-card[data-field="human"]::before {
    background: linear-gradient(180deg, rgba(46, 36, 80, .18), rgba(46, 36, 80, .72));
}

/* The wash deliberately does NOT lighten on hover. Hover is when the photograph
   comes up to full strength, which is precisely when the wash is carrying the
   most weight — dropping it to .88 multiplied into the gradient and took white
   text over a bright sky from 9.5:1 down to about 7.4:1.

   At rest the photo is held at --ulcd-photo-rest over the card's flat brand
   colour, so the pixel under the wash is a blend of photo and that colour and
   is therefore always darker than the photo alone. Hover is the worst case for
   contrast, and it is the case that was measured. */

/* The gold rule that sweeps across the foot of the card on hover. */
.ul-cdeck-card::after {
    content: "";
    position: absolute;
    inset-block-end: 0;
    inset-inline-start: 0;
    z-index: 3;
    height: 3px;
    width: 0;
    background: var(--ul-c3);
    transition: width .5s var(--ulcd-ease);
}

/* Grows out of the grid on hover. Scaled rather than resized: changing the
   card's real dimensions would reflow the whole row and shove its neighbours
   around, whereas a transform is composited and touches nothing else.
 *
 * 1.06 is the ceiling. At the desktop card width that adds ~7px per side, which
 * is what the grid gap is — any more and the card collides with its neighbour
 * instead of filling the space between them. z-index lifts it above the cards
 * that come after it in the DOM, or they would paint over its grown edge. */
.ul-cdeck-card:hover,
.ul-cdeck-card:focus-visible {
    transform: translateY(-4px) scale(1.06);
    z-index: 5;
    box-shadow: 0 26px 44px -22px rgba(4, 28, 51, .8);
}

.ul-cdeck-card:hover::after,
.ul-cdeck-card:focus-visible::after {
    width: 100%;
}

.ul-cdeck-card:focus-visible {
    outline: 2px solid var(--ul-c3);
    outline-offset: 3px;
}

.ul-cdeck-icon {
    position: absolute;
    z-index: 3;
    inset-block-start: 18px;
    inset-inline-start: 20px;
    width: 34px;
    height: 34px;
    color: #fff;
    opacity: .92;
    transition: transform .42s var(--ulcd-ease);
}

.ul-cdeck-icon img,
.ul-cdeck-icon svg {
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* CMS icons are black-on-transparent SVGs; this makes them white without
       needing a second asset per college. */
    filter: brightness(0) invert(1);
}

.ul-cdeck-card:hover .ul-cdeck-icon {
    transform: scale(1.1);
}

/* There is deliberately no field/type label on the card. The tab above already
   says which field you are looking at, so printing it on all four tiles was
   pure repetition — the card carries the college name and nothing else. */
.ul-cdeck-name {
    position: relative;
    z-index: 3;
    margin: 0;
    color: #fff;
    /* card role */
    font-size: var(--t-card);
    font-weight: 700;
    line-height: var(--lh-heading);
    text-wrap: balance;
}

.ul-cdeck-go {
    position: absolute;
    z-index: 3;
    inset-block-end: 18px;
    inset-inline-end: 18px;
    font-size: 15px;
    line-height: 1;
    color: var(--ul-c3);
    opacity: 0;
    transform: translateX(-6px);
    transition: opacity .34s var(--ulcd-ease), transform .34s var(--ulcd-ease);
}

/* The glyph itself already points the right way — icon_forward() returns
   fa-chevron-left in Arabic and fa-chevron-right in English. So do NOT mirror it
   here; only the direction it slides in from has to invert. */
[dir="rtl"] .ul-cdeck-go {
    transform: translateX(6px);
}

.ul-cdeck-card:hover .ul-cdeck-go,
.ul-cdeck-card:focus-visible .ul-cdeck-go {
    opacity: 1;
    transform: translateX(0);
}

/* ─────────────────────────────────────────────────── entrance motion */

/* The card entrance is NOT declared here — it is driven from colleges-deck.js
   with element.animate().
 *
 * It used to be a CSS @keyframes gated behind @media (prefers-reduced-motion),
 * and it never played: Windows turns that setting on via its ordinary
 * "animation effects" toggle, so a large share of normal visitors matched the
 * media query and got no motion at all. The Web Animations API is not subject to
 * the media query, so the script decides — and it decides to play a gentler
 * fade rather than nothing. Do not reintroduce a CSS animation here.
 *
 * The base state is the resting state, so a card with no animation is simply
 * visible; nothing depends on an animation running or finishing. */

/* ─────────────────────────────────────────────────────── responsive */

@media (max-width: 991px) {
    .ul-cdeck-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 575px) {
    .ul-cdeck-grid {
        grid-template-columns: 1fr;
    }

    .ul-cdeck-card {
        min-height: 150px;
    }

    /* Tabs become a single scrolling row rather than wrapping to three lines. */
    .ul-cdeck-tabs {
        flex-wrap: nowrap;
        justify-content: flex-start;
        overflow-x: auto;
        scrollbar-width: none;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
    }

    .ul-cdeck-tabs::-webkit-scrollbar {
        display: none;
    }

    .ul-cdeck-tab {
        flex: none;
        font-size: 13px;
        padding: 9px 14px;
    }
}

/* Deliberately NO blanket transition kill under prefers-reduced-motion.
 *
 * Hover lift, the gold rule, the arrow and the pill are feedback for something
 * the visitor just did — switching those off makes the section feel broken
 * rather than calm, and this codebase already takes that position in
 * awards-slider.js. What reduced motion is actually for is unrequested,
 * large-travel or looping movement; the only such motion here is the card
 * entrance, and the script already softens that to an opacity-only fade.
 *
 * The one thing worth trimming is the distance the pill travels, since that is
 * the largest sustained movement on the section. */
