/*
 * Article sources block ("מקורות") — end-of-article citations card.
 *
 * Markup is generated by includes/sources-block.php from a plain
 * <h2>מקורות</h2><ol>…</ol> in the post body, so authors never touch this.
 * Palette mirrors preferred-source-btn.css (the theme has no design tokens):
 * card #ffffff on #f7f9fc, border #e2e7ee, ink #182230, muted #6b7280,
 * brand lime #a5df29 / #7aad18.
 *
 * The block carries no <p>, so the ads plugin's paragraph merger (priority 25)
 * cannot rewrite it.
 */

.shifke-sources {
    box-sizing: border-box;
    width: 100%;
    margin: 40px 0 32px;
    padding: 26px 24px 22px;
    border: 1px solid #e2e7ee;
    border-radius: 18px;
    background: linear-gradient(180deg, #fbfcfe 0%, #f7f9fc 100%);
    box-shadow: 0 2px 8px rgba(16, 24, 40, 0.04);
    direction: rtl;
    text-align: right;
    position: relative;
    overflow: hidden;
}

.shifke-sources::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, #7aad18 0%, #a5df29 55%, #d5e7a8 100%);
}

.shifke-sources *,
.shifke-sources *::before,
.shifke-sources *::after {
    box-sizing: border-box;
}

/* ---- Header ---------------------------------------------------------- */

.shifke-sources__head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
}

.shifke-sources__icon {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: #eef7d9;
    color: #5f8a10;
}

.shifke-sources__icon::before {
    content: "";
    width: 22px;
    height: 22px;
    display: block;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'><path d='M4 5.5A2.5 2.5 0 0 1 6.5 3H19a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H6.5A2.5 2.5 0 0 0 4 21.5z'/><path d='M4 19a2.5 2.5 0 0 1 2.5-2.5H20'/><path d='M9 8h7M9 11.5h5'/></svg>") center / contain no-repeat;
    mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'><path d='M4 5.5A2.5 2.5 0 0 1 6.5 3H19a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H6.5A2.5 2.5 0 0 0 4 21.5z'/><path d='M4 19a2.5 2.5 0 0 1 2.5-2.5H20'/><path d='M9 8h7M9 11.5h5'/></svg>") center / contain no-repeat;
}

.shifke-sources__titles {
    flex: 1 1 auto;
    min-width: 0;
}

.shifke-sources__title,
.shifke-sources h2.shifke-sources__title {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 20px;
    line-height: 1.25;
    font-weight: 700;
    color: #182230;
}

.shifke-sources__sub {
    display: block;
    margin-top: 4px;
    font-size: 14px;
    line-height: 1.45;
    color: #6b7280;
}

.shifke-sources__count {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    height: 30px;
    padding: 0 12px;
    border-radius: 9999px;
    border: 1px solid #d5dde6;
    background: #ffffff;
    font-size: 13px;
    font-weight: 600;
    color: #182230;
    white-space: nowrap;
}

/* ---- List ------------------------------------------------------------ */

.shifke-sources__list,
.shifke-sources ol.shifke-sources__list {
    list-style: none;
    margin: 0;
    padding: 0;
    counter-reset: shifke-source;
    display: grid;
    gap: 8px;
    direction: ltr;
    text-align: left;
}

.shifke-sources__item,
.shifke-sources ol.shifke-sources__list > li {
    counter-increment: shifke-source;
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) auto;
    align-items: start;
    gap: 12px;
    margin: 0;
    padding: 12px 14px;
    border: 1px solid #eef1f4;
    border-radius: 12px;
    background: #ffffff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.shifke-sources__item:hover {
    border-color: #d5e7a8;
    box-shadow: 0 4px 12px rgba(16, 24, 40, 0.06);
    transform: translateY(-1px);
}

.shifke-sources__item::before {
    content: counter(shifke-source);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 9999px;
    background: #f1f5f9;
    color: #475569;
    font-size: 12px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    margin-top: 1px;
}

.shifke-sources__cite {
    font-size: 14.5px;
    line-height: 1.55;
    color: #334155;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.shifke-sources__cite em {
    font-style: italic;
    color: #6b7280;
}

.shifke-sources__link,
.shifke-sources a.shifke-sources__link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 30px;
    padding: 0 11px;
    border-radius: 9999px;
    border: 1px solid #d5dde6;
    background: #f4f7fb;
    color: #182230;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
    box-shadow: none;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.shifke-sources__link::after {
    content: "";
    width: 11px;
    height: 11px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M7 17L17 7M9 7h8v8'/></svg>") center / contain no-repeat;
    mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M7 17L17 7M9 7h8v8'/></svg>") center / contain no-repeat;
}

.shifke-sources__link:hover,
.shifke-sources a.shifke-sources__link:hover {
    background: #eef7d9;
    border-color: #a5df29;
    color: #3f5f08;
    text-decoration: none;
}

.shifke-sources__link:focus-visible {
    outline: 2px solid #7aad18;
    outline-offset: 2px;
}

/* Jump target from an inline citation: land below the sticky header and
   flash the row so the reader sees which source they were sent to. */
.shifke-sources__item {
    scroll-margin-top: 96px;
}

/* Selected source. :target covers the no-JS path; --active is set by
   js/sources.js and stays until another citation is followed. The row gets a
   lime spine on its leading (left, the list is LTR) edge, a tinted ground, a
   lift, and the number badge fills in — the same accent, in every layer, so
   the eye lands on one row and nothing else competes. */
.shifke-sources__item:target,
.shifke-sources__item--active {
    position: relative;
    border-color: #c9e380;
    background: linear-gradient(90deg, #f3f9e6 0%, #fbfdf5 100%);
    box-shadow: 0 6px 18px rgba(122, 173, 24, 0.14), 0 1px 2px rgba(16, 24, 40, 0.04);
    transform: translateY(-1px);
}

.shifke-sources__item:target::after,
.shifke-sources__item--active::after {
    content: "";
    position: absolute;
    top: 8px;
    bottom: 8px;
    left: -1px;
    width: 4px;
    border-radius: 0 4px 4px 0;
    background: linear-gradient(180deg, #a5df29 0%, #7aad18 100%);
}

.shifke-sources__item:target::before,
.shifke-sources__item--active::before {
    background: #a5df29;
    color: #182230;
    box-shadow: 0 0 0 3px #eef7d9;
}

.shifke-sources__item:target .shifke-sources__cite,
.shifke-sources__item--active .shifke-sources__cite {
    color: #182230;
}

.shifke-sources__item:target .shifke-sources__link,
.shifke-sources__item--active .shifke-sources__link {
    border-color: #a5df29;
    background: #ffffff;
}

/* Arrival cue on top of the selected state: one soft ring that breathes out. */
.shifke-sources__item--flash {
    animation: shifke-sources-flash 1.4s cubic-bezier(0.2, 0.7, 0.2, 1) 1;
}

@keyframes shifke-sources-flash {
    0%   { box-shadow: 0 0 0 0 rgba(165, 223, 41, 0.75), 0 6px 18px rgba(122, 173, 24, 0.14); }
    60%  { box-shadow: 0 0 0 10px rgba(165, 223, 41, 0), 0 6px 18px rgba(122, 173, 24, 0.14); }
    100% { box-shadow: 0 0 0 0 rgba(165, 223, 41, 0), 0 6px 18px rgba(122, 173, 24, 0.14); }
}

/* The body chip that was followed mirrors the selected row. */
.shifke-cite a.is-current,
.entry-content sup.shifke-cite a.is-current {
    background: #a5df29;
    border-color: #7aad18;
    color: #182230;
}

/* ---- Collapse ("accordion") ------------------------------------------
 *
 * EVERY rule in this section is gated on html.shifke-js, which a small inline
 * script in <head> sets (includes/sources-block.php). The consequences are
 * deliberate:
 *
 *  - No JS: the class never appears, so the card renders exactly as it did
 *    before this feature — all items, no toggle in the accessibility tree.
 *    Crawlers see every source.
 *  - JS: the collapsed layout is already correct at first paint, so there is
 *    no flash of the full list and no layout shift.
 *  - A page still in LiteSpeed's cache from before this change has neither
 *    .shifke-sources--collapsible nor .is-collapsed, and both are required
 *    here, so stale HTML + new CSS renders the old, fully expanded card.
 *
 * The chevron is a mask, like every other icon in this file: the block must
 * not contain a <path (see the header of includes/sources-block.php).
 */

.shifke-sources--collapsible {
    scroll-margin-top: 96px;
}

/* Hidden rows are removed from layout, not clipped — a clipped row keeps its
   outbound link focusable and announced while the toggle says "collapsed". */
.shifke-js .shifke-sources--collapsible.is-collapsed .shifke-sources__item--extra {
    display: none;
}

.shifke-js .shifke-sources--collapsible.is-collapsed .shifke-sources__list {
    position: relative;
    padding-bottom: 10px;
}

/* Fade over the bottom of the last visible row: "there is more below". */
.shifke-js .shifke-sources--collapsible.is-collapsed .shifke-sources__list::after {
    content: "";
    position: absolute;
    inset-inline: 0;
    bottom: 0;
    height: 54px;
    pointer-events: none;
    background: linear-gradient(
        to top,
        #f8fafd 14%,
        rgba(248, 250, 253, 0.72) 55%,
        rgba(248, 250, 253, 0)
    );
}

.shifke-sources__toggle {
    display: none;
}

.shifke-js .shifke-sources__toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 16px auto 0;
    height: 38px;
    padding: 0 18px;
    border: 1px solid #d5dde6;
    border-radius: 9999px;
    background: #ffffff;
    color: #182230;
    font: inherit;
    font-size: 13.5px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.shifke-js .shifke-sources__toggle:hover {
    background: #eef7d9;
    border-color: #a5df29;
    color: #3f5f08;
}

.shifke-js .shifke-sources__toggle:focus-visible {
    outline: 2px solid #7aad18;
    outline-offset: 2px;
}

.shifke-sources__toggle::after {
    content: "";
    flex: 0 0 12px;
    width: 12px;
    height: 12px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>") center / contain no-repeat;
    mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>") center / contain no-repeat;
    transition: transform 0.25s ease;
}

.shifke-js .shifke-sources--collapsible:not(.is-collapsed) .shifke-sources__toggle::after {
    transform: rotate(180deg);
}

/* ---- Inline citation marks (in the article body) ---------------------
 *
 * A baseline chip, not a superscript. Hebrew running text in Assistant sits
 * high on the line, so a true superscript floats away from its word and
 * inflates the line box. The <sup> element is kept for semantics (screen
 * readers announce "מקור 4" from the aria-label) but is laid out as a small
 * pill that hugs the word it follows, ~2px above the baseline, with a zero
 * line-height so paragraphs keep their rhythm. Selectors include the theme's
 * .entry-content and a bare `sup` so the theme's own sup/a rules lose.
 */

sup.shifke-cite,
.entry-content sup.shifke-cite {
    position: static;
    top: auto;
    display: inline-block;
    font-size: 11px;
    line-height: 0;
    vertical-align: 0.18em;
    margin: 0 3px;
    padding: 0;
}

.shifke-cite a,
.entry-content sup.shifke-cite a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 17px;
    min-width: 17px;
    padding: 0 5px;
    margin: 0;
    border: 1px solid #d5e7a8;
    border-radius: 9999px;
    background: #f3f9e6;
    color: #4d720c;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.01em;
    font-variant-numeric: tabular-nums;
    text-decoration: none;
    box-shadow: none;
    vertical-align: middle;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.shifke-cite a:hover,
.entry-content sup.shifke-cite a:hover {
    background: #a5df29;
    border-color: #a5df29;
    color: #182230;
    text-decoration: none;
}

.shifke-cite a:focus-visible {
    outline: 2px solid #7aad18;
    outline-offset: 1px;
}

/* ---- Footer note ----------------------------------------------------- */

.shifke-sources__note {
    display: block;
    margin-top: 14px;
    font-size: 12.5px;
    line-height: 1.5;
    color: #6b7280;
}

/* ---- Responsive ------------------------------------------------------ */

@media (max-width: 600px) {
    .shifke-sources {
        margin: 32px 0 24px;
        padding: 20px 16px 18px;
        border-radius: 14px;
    }

    .shifke-sources__head {
        flex-wrap: wrap;
        gap: 10px 12px;
    }

    .shifke-sources__icon {
        flex-basis: 38px;
        width: 38px;
        height: 38px;
    }

    .shifke-sources__title,
    .shifke-sources h2.shifke-sources__title {
        font-size: 18px;
    }

    .shifke-sources__count {
        order: 3;
    }

    .shifke-sources__item,
    .shifke-sources ol.shifke-sources__list > li {
        grid-template-columns: 24px minmax(0, 1fr);
        padding: 11px 12px;
        gap: 8px 10px;
    }

    .shifke-sources__item::before {
        width: 24px;
        height: 24px;
        font-size: 11px;
    }

    .shifke-sources__cite {
        font-size: 14px;
    }

    .shifke-sources__link,
    .shifke-sources a.shifke-sources__link {
        grid-column: 2;
        justify-self: start;
    }

    /* Full-width tap target on a phone, where the toggle is the one control
       in the card. */
    .shifke-js .shifke-sources__toggle {
        display: flex;
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .shifke-sources__item,
    .shifke-sources__link,
    .shifke-cite a,
    .shifke-sources__toggle,
    .shifke-sources__toggle::after {
        transition: none;
    }

    .shifke-sources__item:hover {
        transform: none;
    }

    .shifke-sources__item--flash {
        animation: none;
    }

    .shifke-sources__item:target,
    .shifke-sources__item--active {
        transform: none;
    }
}

@media print {
    .shifke-sources {
        box-shadow: none;
        background: #ffffff;
    }

    .shifke-sources__link::after {
        display: none;
    }

    /* Paper has no toggle: print every source. */
    .shifke-js .shifke-sources--collapsible.is-collapsed .shifke-sources__item--extra {
        display: grid;
    }

    .shifke-js .shifke-sources--collapsible.is-collapsed .shifke-sources__list::after {
        content: none;
    }

    .shifke-js .shifke-sources--collapsible.is-collapsed .shifke-sources__list {
        padding-bottom: 0;
    }

    .shifke-js .shifke-sources__toggle {
        display: none;
    }
}
