/*
    Favorites (docs/Favorites/Favorites-Design.md).

    Three pieces of chrome:

    1. The Favorites entry and its flyout panel, the LAST item in the Workspace
       section of the rail. The panel is positioned the same way as the Recent
       History panel — position:fixed, offset from the rail by --kv-side-w, with
       `top` set by favorites.js on open so it aligns with the row that opened it
       and stays inside the viewport. It cannot reuse .kv-recent-panel itself:
       that panel hangs off a Bootstrap li.dropdown inside the user menu and
       borrows that dropdown's open/close state, whereas this one hangs off a
       plain nav and drives its own.

    2. The star in the top bar, beside the breadcrumb. flex: 0 0 auto is not
       cosmetic — .kv-top is `justify-content: space-between` and also holds
       SuperSearch and the Help button, so a growable star shifts SuperSearch's
       right alignment when SuperSearch is disabled. Same trap tour.css:153
       documents for .kv-help.

    3. The callout the star's replies appear in, anchored under the star and
       appended to <body> by favorites.js.

    Loaded only when FavoritesEnabled is on (the markup and favorites.js are
    omitted otherwise), so nothing here can affect a site with the flag off.
*/

/* ===== rail entry ===== */

body.kv .kv-fav {
    position: relative;
}

/* the entry itself reuses .kv-quick-link for its metrics; this only adds the
   caret alignment and the open state */
body.kv a.kv-fav-toggle {
    cursor: pointer;
}

body.kv a.kv-fav-toggle .kv-fav-caret {
    width: 13px;
    height: 13px;
    margin-left: auto;
    flex-shrink: 0;
    transition: transform .12s ease;
}

body.kv .kv-fav.is-open a.kv-fav-toggle .kv-fav-caret {
    transform: rotate(90deg);
}

body.kv .kv-fav.is-open a.kv-fav-toggle {
    background: var(--kv-field);
    color: var(--kv-ink) !important;
}

/* ===== flyout panel ===== */

body.kv .kv-fav-panel {
    position: fixed;
    left: calc(var(--kv-side-w) + 8px);
    /* top is set by favorites.js on open: aligned with the Favorites row and
       clamped into the viewport, exactly as recentNav.js does for its panel */
    top: 100px;
    z-index: 1100; /* above the rail (1040) and the narrow-screen drawer (1090) */
    /* sized for a full-length caption ("Cost Allocation Crosswalk") plus the
       row padding, without the panel becoming a second column of the page */
    width: 264px;
    max-width: calc(100vw - var(--kv-side-w) - 24px);
    background: var(--kv-card);
    border: 1px solid var(--kv-border);
    border-radius: var(--kv-r-panel);
    box-shadow: var(--kv-shadow-pop);
    overflow: hidden;
}

/* The panel header carries .kv-flyout-head (quartz.css:560) so its font, size,
   weight, letter-spacing, colour and icon treatment are IDENTICAL to the
   mega-menu flyout headings — "Workforce Management" and the rest. Matching by
   reuse rather than by copying values: this header originally copied the Recent
   History head (mono, uppercase, .68rem, muted), which is precisely how it ended
   up looking like a different feature.

   Only the box metrics are overridden. The mega flyout's own container supplies
   the padding around its header; this panel is full-bleed, so the header has to
   provide its own, aligned with the list rows below it (.9rem). */
body.kv .kv-fav-panel .kv-flyout-head {
    /* .95rem side padding lines the heading text up with the row text below it
       (row margin .4rem + row padding .55rem). */
    padding: .7rem .95rem .6rem;
    margin-bottom: 0;
}

body.kv ul.kv-fav-list {
    list-style: none;
    margin: 0;
    padding: .3rem 0;
    /* ten items is the cap, but a short monitor still has to cope — the panel
       scrolls its list rather than running off the bottom of the screen */
    max-height: calc(100vh - 220px);
    overflow-y: auto;
}

body.kv ul.kv-fav-list > li {
    list-style: none;
}

/* Rows match the mega-menu page links (.ltm-MegaMenuColumnRealLinkHref,
   quartz.css:674-694) exactly: .84rem at weight 500 in --kv-ink-soft, a 7px
   radius, the same .1s transition, and the same hover pill — --kv-tint behind
   --kv-primary text.

   The horizontal margin is what makes the pill read as a pill: the mega-menu
   links get their inset from the flyout column's own padding, whereas this panel
   is full-bleed, so the row has to inset itself or the highlight runs edge to
   edge. margin .4rem + padding .55rem puts the text .95rem from the panel edge,
   which is what the header padding below is aligned to. */
body.kv a.kv-fav-link {
    display: block;
    margin: 0 .4rem;
    padding: .4rem .55rem;
    border-radius: 7px;
    color: var(--kv-ink-soft) !important;
    text-decoration: none !important;
    font-size: .84rem;
    font-weight: 500;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background .1s, color .1s;
}

body.kv a.kv-fav-link:hover,
body.kv a.kv-fav-link:focus-visible {
    background: var(--kv-tint) !important;
    color: var(--kv-primary) !important;
}

body.kv .kv-fav-empty {
    padding: .55rem .95rem;
    color: var(--kv-muted);
    font-size: .75rem;
    line-height: 1.4;
}

body.kv .kv-fav-foot {
    border-top: 1px solid var(--kv-border);
    padding: .3rem 0;
}

/* Same pill as the favorite rows above, so the footer is not a different idiom
   from the list it closes. */
body.kv a.kv-fav-manage {
    display: block;
    margin: 0 .4rem;
    padding: .4rem .55rem;
    border-radius: 7px;
    color: var(--kv-ink-soft) !important;
    text-decoration: none !important;
    font-size: .84rem;
    font-weight: 500;
    line-height: 1.35;
    transition: background .1s, color .1s;
}

body.kv a.kv-fav-manage:hover,
body.kv a.kv-fav-manage:focus-visible {
    background: var(--kv-tint) !important;
    color: var(--kv-primary) !important;
}

/* Collapsed rail: the caption span is hidden by quartz.css's mini-rail rules
   (it targets a.kv-quick-link > span, which this entry is), so only the star
   icon shows. The caret would crowd it, and the panel has to clear the wider
   flyout lane — mirrors the .kv-recent-panel rule at quartz.css:353. */
@media (min-width: 1101px) {
    body.kv.kv-side-collapsed.kv-has-side .kv-fav-caret {
        display: none !important;
    }

    body.kv.kv-side-collapsed.kv-has-side .kv-fav-panel {
        left: calc(var(--kv-side-w) + 8px);
        max-width: calc(100vw - var(--kv-side-w) - 24px);
    }
}

/* ===== the star in the top bar ===== */

body.kv .kv-fav-star {
    flex: 0 0 auto; /* see the file header — do not make this growable */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin-left: .5rem;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--kv-muted);
    cursor: pointer;
    transition: color .12s ease, background .12s ease;
}

body.kv .kv-fav-star svg {
    width: 17px;
    height: 17px;
}

body.kv .kv-fav-star:hover {
    background: var(--kv-field);
    color: var(--kv-ink);
}

/* saved: the star fills. aria-pressed is the source of truth, so the visual
   state cannot drift from what assistive technology reports. */
body.kv .kv-fav-star[aria-pressed="true"] {
    color: #d99a0b;
}

body.kv .kv-fav-star[aria-pressed="true"] svg {
    fill: currentColor;
}

body.kv .kv-fav-star:disabled {
    opacity: .5;
    cursor: default;
}

/* ===== the star's callout ===== */

/* The star's replies — the ten-favorite cap and the two failure messages —
   appear here, under the star, rather than in the layout's Kendo notification
   widget pinned to the bottom-right corner of the window (axod 21638).

   favorites.js creates the element, appends it to <body> so .kv-top's flex row
   can neither reflow around it nor clip it, and sets `top`/`left` from the
   star's rect on every show, scroll and resize. Only the box is styled here. */
body.kv .kv-fav-note {
    position: fixed;
    top: 0;
    left: 0; /* both replaced by favorites.js before the callout is visible */
    z-index: 1200; /* above the favorites panel (1100), which it may overlap */
    max-width: min(340px, calc(100vw - 24px));
    padding: .55rem .75rem;
    background: var(--kv-card);
    border: 1px solid var(--kv-border);
    border-radius: var(--kv-r-panel);
    box-shadow: var(--kv-shadow-pop);
    color: var(--kv-ink-soft);
    font-size: .8125rem;
    line-height: 1.4;
}

/* Caret pointing up at the star, drawn as a bordered triangle over a filled one.
   --kv-fav-note-caret is the star's centre measured from the callout's left
   edge, set by favorites.js: the callout is clamped into the viewport, so it is
   not always centred on the star even though the caret must still find it. */
body.kv .kv-fav-note::before,
body.kv .kv-fav-note::after {
    content: "";
    position: absolute;
    left: var(--kv-fav-note-caret, 20px);
    margin-left: -7px;
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
}

body.kv .kv-fav-note::before {
    top: -8px;
    border-bottom: 8px solid var(--kv-border);
}

body.kv .kv-fav-note::after {
    top: -7px;
    border-bottom: 8px solid var(--kv-card);
}

/* ===== Manage Favorites page ===== */

.kv-favmg {
    max-width: 620px;
    padding: 1rem 0;
}

.kv-favmg-hint,
.kv-favmg-empty {
    color: var(--kv-muted);
    font-size: .8125rem;
    line-height: 1.5;
    margin: 0 0 .9rem;
}

ul.kv-favmg-list {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
    border: 1px solid var(--kv-border);
    border-radius: var(--kv-r-panel);
    overflow: hidden;
}

li.kv-favmg-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .5rem .75rem;
    background: var(--kv-card);
}

li.kv-favmg-row + li.kv-favmg-row {
    border-top: 1px solid var(--kv-border);
}

.kv-favmg-name {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: .875rem;
}

.kv-favmg-actions {
    flex: 0 0 auto;
    display: inline-flex;
    gap: .25rem;
}

/* the arrows and the remove button are square and quiet — they are controls on a
   list, not page actions, so they must not outweigh Save */
.kv-favmg-actions .k-button {
    min-width: 30px;
    padding: .15rem .35rem;
    line-height: 1.2;
}

.kv-favmg-foot {
    display: flex;
    gap: .5rem;
    align-items: center;
}
