/* Vacancy feed feature */

#feed-screen {
    --feed-bg: var(--surface-0, var(--bg, #111315));
    --feed-surface: var(--surface-2, var(--card, #1b1e22));
    --feed-surface-raised: var(--surface-3, var(--card-hover, #22262b));
    --feed-line: var(--line, var(--border, #34393f));
    --feed-line-strong: var(--line-strong, var(--border-strong, #4a5159));
    --feed-ink: var(--ink, var(--text, #f4f5f6));
    --feed-ink-soft: var(--ink-soft, var(--text-soft, #c2c7cc));
    --feed-muted: var(--muted, #8a929a);
    --feed-accent: var(--accent, #7c8cff);
    --feed-success: var(--success, #5868cc);
    --feed-danger: var(--danger, #ef6b73);
}

#feed-screen .screen-content {
    width: min(100%, 760px);
    margin-inline: auto;
    gap: 12px;
}

/* Filters stay horizontally scrollable on phones, without pill-heavy styling. */
#feed-screen .tg-vac-cats-row {
    min-width: 0;
}

#feed-screen .tg-vac-cats {
    gap: 8px;
    padding: 0 0 4px;
    scroll-padding-inline: 4px;
}

#feed-screen .tg-vac-chip {
    min-height: 44px;
    padding: 9px 13px;
    border-color: var(--feed-line);
    border-radius: 8px;
    background: transparent;
    color: var(--feed-ink-soft);
    font-size: 12px;
    font-weight: 600;
    box-shadow: none;
}

#feed-screen .tg-vac-chip:not(.active):hover {
    border-color: var(--feed-line-strong);
    background: var(--feed-surface);
    color: var(--feed-ink);
}

#feed-screen .tg-vac-chip.active {
    border-color: var(--feed-accent);
    background: var(--feed-surface-raised);
    color: var(--feed-ink);
}

#feed-status {
    min-height: 0;
    margin: 0;
    color: var(--feed-muted);
}

.feed-deck-progress {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 24px;
    color: var(--feed-muted);
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.feed-deck-progress[hidden] {
    display: none;
}

#feed-deck-source {
    color: var(--feed-ink-soft);
}

/* Base item is also used briefly while the list is being assembled. */
.feed-item {
    position: relative;
    box-sizing: border-box;
    margin-bottom: 10px;
    padding: 16px 52px 16px 16px;
    overflow: hidden;
    border: 1px solid var(--feed-line);
    border-radius: 10px;
    background: var(--feed-surface);
    color: var(--feed-ink);
    cursor: pointer;
}

.feed-item:hover {
    border-color: var(--feed-line-strong);
}

.feed-item .fav-star {
    top: 8px;
    right: 8px;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    color: var(--feed-muted);
}

.feed-item .fav-star:hover,
.feed-item .fav-star:focus-visible {
    background: var(--feed-surface-raised);
    color: var(--feed-ink);
}

.feed-item .fav-star.active {
    color: #e9b949;
}

.feed-item .fav-star.active .app-icon {
    fill: currentColor;
}

#feed-list .tg-vac-title {
    display: -webkit-box;
    overflow: hidden;
    color: var(--feed-ink);
    font-size: 17px;
    font-weight: 700;
    line-height: 1.3;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

#feed-list .tg-vac-company {
    display: -webkit-box;
    overflow: hidden;
    margin-top: 6px;
    color: var(--feed-muted);
    font-size: 13px;
    line-height: 1.35;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

#feed-list .tg-vac-salary {
    margin-top: 10px;
    color: var(--feed-success);
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
}

.feed-snippet {
    display: -webkit-box;
    overflow: hidden;
    margin-top: 10px;
    color: var(--feed-ink-soft);
    font-size: 13px;
    line-height: 1.45;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.feed-snippet.is-expanded {
    display: block;
    overflow: visible;
    max-height: none;
    user-select: text;
    -webkit-user-select: text;
}

.feed-snippet-toggle {
    min-width: 44px;
    min-height: 44px;
    margin: 0;
    padding: 8px 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--feed-accent);
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
}

.feed-snippet-toggle:hover,
.feed-snippet-toggle:focus-visible {
    color: var(--feed-ink);
}

.feed-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    /* Two complete compact rows; never clip a badge border mid-row. */
    max-height: 58px;
    margin-top: 8px;
    overflow: hidden;
}

.feed-badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 8px;
    border: 1px solid var(--feed-line);
    border-radius: 6px;
    background: transparent;
    color: var(--feed-ink-soft);
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
}

.feed-badge--tg {
    gap: 5px;
    border-color: color-mix(in srgb, #2aabee 44%, var(--feed-line));
    background: transparent;
    color: var(--feed-ink-soft);
}

.feed-actions {
    margin-top: 12px;
}

.feed-apply-btn {
    width: 100%;
    min-height: 44px;
    padding: 10px 14px;
    border: 1px solid var(--feed-line-strong);
    border-radius: 8px;
    background: var(--feed-surface-raised);
    color: var(--feed-ink);
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.feed-apply-btn:hover:not(:disabled),
.feed-apply-btn:focus-visible {
    border-color: var(--feed-accent);
}

.feed-apply-btn:disabled {
    opacity: 0.52;
    cursor: default;
}

.feed-applied-mark {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    color: var(--feed-success);
    font-size: 12px;
    font-weight: 700;
}

/* Stable Tinder deck: every vacancy occupies the same visual frame. */
#feed-list.feed-deck {
    position: relative;
    width: 100%;
    min-height: 374px;
    isolation: isolate;
}

#feed-list.feed-deck .feed-item {
    position: absolute;
    inset: 0 0 auto;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 356px;
    min-height: 356px;
    margin: 0;
    padding: 18px 58px 18px 18px;
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
    transform-origin: 50% 92%;
    transition: transform 180ms ease, opacity 160ms ease, border-color 160ms ease;
}

/* Expanded details grow the deck and use the screen's native vertical scroll. */
#feed-list.feed-deck .feed-item.feed-item--expanded {
    height: auto;
    max-height: none;
    overflow: visible;
}

/* The dedicated action rail duplicates swipe actions, so avoid a button inside a button-like card. */
#feed-list.feed-deck .feed-apply-btn {
    display: none;
}

#feed-list.feed-deck .feed-actions {
    display: none;
}

#feed-list.feed-deck .feed-item:nth-child(1).feed-item--applied::after {
    content: "✓ Отклик отправлен";
    position: absolute;
    right: 16px;
    bottom: 14px;
    left: 16px;
    color: var(--feed-success);
    font-size: 12px;
    font-weight: 700;
}

#feed-list.feed-deck .feed-item:nth-child(1) {
    z-index: 4;
    opacity: 1;
    pointer-events: auto;
}

#feed-list.feed-deck .feed-item:nth-child(2) {
    z-index: 3;
    inset-inline: 9px;
    width: calc(100% - 18px);
    opacity: 0.68;
    pointer-events: none;
    transform: translateY(8px);
}

#feed-list.feed-deck .feed-item:nth-child(3) {
    z-index: 2;
    inset-inline: 18px;
    width: calc(100% - 36px);
    opacity: 0.38;
    pointer-events: none;
    transform: translateY(15px);
}

#feed-list.feed-deck .feed-item:nth-child(n + 4) {
    z-index: 1;
    opacity: 0;
    pointer-events: none;
    transform: translateY(15px);
}

#feed-list.feed-deck .feed-item:nth-child(n + 2) > * {
    visibility: hidden;
}

#feed-list.feed-deck .feed-item--dragging {
    cursor: grabbing;
    transition: none;
}

#feed-list.feed-deck .feed-item--snapping {
    transition: transform 190ms cubic-bezier(.2, .8, .2, 1), opacity 160ms ease;
}

#feed-list.feed-deck .feed-item--leaving {
    pointer-events: none;
    transition: transform 240ms cubic-bezier(.35, .1, .7, .3), opacity 200ms ease;
}

#feed-list.feed-deck .feed-item--pending {
    border-color: var(--feed-accent);
    pointer-events: none;
}

.feed-swipe-stamp {
    position: absolute;
    top: 66px;
    z-index: 3;
    padding: 8px 10px;
    border: 1px solid currentColor;
    border-radius: 6px;
    opacity: 0;
    background: var(--feed-bg);
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0;
    text-transform: none;
    pointer-events: none;
}

.feed-swipe-stamp--skip {
    right: 18px;
    color: var(--feed-ink-soft);
    transform: none;
}

.feed-swipe-stamp--apply {
    left: 18px;
    color: var(--feed-success);
    transform: none;
}

.feed-swipe-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 56px;
}

.feed-swipe-actions[hidden] {
    display: none;
}

.feed-swipe-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    width: auto;
    min-width: 104px;
    height: 48px;
    padding: 0 13px;
    border: 1px solid var(--feed-line-strong);
    border-radius: 9px;
    background: var(--feed-surface);
    color: var(--feed-ink-soft);
    box-shadow: none;
    font: inherit;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease, transform 120ms ease, opacity 120ms ease;
}

.feed-swipe-action svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.feed-swipe-action--skip {
    border-color: var(--feed-line-strong);
    color: var(--feed-ink-soft);
}

.feed-swipe-action--skip::after {
    content: "Убрать";
}

.feed-swipe-action--open {
    width: 48px;
    min-width: 48px;
    padding: 0;
}

.feed-swipe-action--apply {
    min-width: 112px;
    border-color: color-mix(in srgb, var(--feed-success) 55%, var(--feed-line));
    color: var(--feed-success);
}

.feed-swipe-action--apply::after {
    content: "Откликнуться";
}

.feed-swipe-action:hover:not(:disabled),
.feed-swipe-action:focus-visible {
    border-color: currentColor;
    background: var(--feed-surface-raised);
}

.feed-swipe-action:active:not(:disabled) {
    transform: translateY(1px);
}

.feed-swipe-action:disabled,
.feed-swipe-action--apply.is-unavailable {
    opacity: 0.42;
    cursor: default;
}

.feed-item--applied {
    opacity: 0.68;
}

.feed-item--applied .tg-vac-title {
    color: var(--feed-ink-soft);
}

.feed-undo-region {
    position: fixed;
    right: max(12px, env(safe-area-inset-right));
    bottom: calc(14px + env(safe-area-inset-bottom));
    left: max(12px, env(safe-area-inset-left));
    z-index: 1200;
    display: grid;
    gap: 8px;
    width: min(520px, calc(100% - 24px));
    max-height: min(42vh, 320px);
    margin-inline: auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    pointer-events: auto;
}

.feed-undo {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    min-height: 52px;
    overflow: hidden;
    border: 1px solid var(--feed-line-strong, var(--line-strong));
    border-radius: 8px;
    background: var(--feed-surface-raised, var(--surface-3));
    color: var(--feed-ink, var(--ink));
    box-shadow: 0 10px 28px rgba(18, 20, 35, 0.2);
    pointer-events: auto;
}

.feed-undo__message {
    min-width: 0;
    padding: 12px 10px 13px 14px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
}

.feed-undo__button {
    align-self: stretch;
    min-width: 88px;
    min-height: 48px;
    padding: 0 14px;
    border: 0;
    background: transparent;
    color: var(--feed-accent, var(--accent));
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.feed-undo__button:hover,
.feed-undo__button:focus-visible {
    background: color-mix(in srgb, var(--feed-accent, var(--accent)) 10%, transparent);
}

.feed-undo__timer {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--feed-accent, var(--accent));
    transform-origin: left;
    animation: feedUndoCountdown var(--feed-undo-duration, 7000ms) linear forwards;
    pointer-events: none;
}

@keyframes feedUndoCountdown {
    to { transform: scaleX(0); }
}

#feed-screen .empty-state {
    min-height: 280px;
    border: 1px solid var(--feed-line);
    border-radius: 10px;
    background: var(--feed-surface);
    box-shadow: none;
}

#feed-more {
    min-height: 44px;
    border-radius: 8px;
}

#feed-screen :is(button, [role="button"]):focus-visible {
    outline: 2px solid var(--feed-accent);
    outline-offset: 2px;
}

@media (max-width: 520px) {
    #feed-screen .screen-content {
        gap: 10px;
    }

    #feed-list.feed-deck {
        min-height: 354px;
    }

    #feed-list.feed-deck .feed-item {
        height: 336px;
        min-height: 336px;
        padding: 16px 54px 16px 16px;
    }

    #feed-list .tg-vac-title {
        font-size: 16px;
    }

    .feed-snippet {
        -webkit-line-clamp: 2;
    }

    .feed-swipe-actions {
        gap: 8px;
    }

    .feed-swipe-action {
        min-width: 96px;
        padding-inline: 10px;
    }

    .feed-swipe-action--open {
        min-width: 48px;
        padding: 0;
    }

    .feed-swipe-action--apply {
        min-width: 108px;
    }
}

@media (max-width: 350px) {
    .feed-swipe-action {
        min-width: 48px;
        padding: 0;
    }

    .feed-swipe-action::after {
        content: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    #feed-list.feed-deck .feed-item,
    .feed-swipe-action,
    .feed-undo__timer {
        transition-duration: 0.01ms !important;
    }

    .feed-undo__timer {
        animation: none;
    }
}
