/*
 * Resources: filter chips, a grid of cards (thumbnail, tags, title, text, button), notes for
 * "none yet" / "none match", and the video pop-up. Markup: view.php; behaviour: script.js.
 */

/* (On the card too, so it looks the same in other blocks, e.g. Resource cards) */
.blk--resources,
.resources__card {
    --res-line: var(--neutral-200);
    --res-tint: var(--neutral-100);
}

.resources__intro + * {
    margin-top: var(--step-8);
}

.blk--resources [hidden] {
    display: none !important;
}

/* ---------- Filter bar: topic (and type) pills, the search box on the right ----------
   Like the blog's topic pills (blocks/blog-categories), over a hairline. */

.resources__filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--step-4) var(--step-8);
    padding-bottom: var(--step-7);
    border-bottom: 1px solid var(--res-line);
}

.resources__filter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--step-2) var(--step-6);
}

.resources__filter-label {
    color: var(--black);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.56;
}

.resources__chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--step-2);
    margin: 0;
    padding: 0;
    list-style: none;
}

.resources__chips > li,
.resources__chips > li + li {
    margin: 0;
}

.resources__chip {
    display: inline-flex;
    align-items: center;
    padding: 9px 18px;
    border: 1px solid var(--res-line);
    border-radius: var(--pill);
    background: var(--white);
    color: var(--black);
    font-size: 14px;
    line-height: 1.3;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color .2s ease, border-color .2s ease, color .2s ease;
}

.resources__chip:hover {
    border-color: var(--color-action-hover);
    color: var(--color-action);
}

/* The chosen option: the action colour, as buttons */
.resources__chip.is-on {
    border-color: var(--color-action);
    background: var(--color-action);
    color: var(--white);
}

/* First line: the type toggle on the left, the search box on the right */
.resources__tools {
    display: flex;
    flex: 1 1 100%;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--step-3);
}

.resources__tools > .resources__search:only-child {
    margin-left: auto;
}

/* Then the topic pills, across the full width */
.resources__filters > .resources__filter {
    flex: 1 1 100%;
}

.resources__segments {
    position: relative;
    display: inline-flex;
    flex-wrap: nowrap;
    gap: 0;
    padding: 4px;
    border: 1px solid var(--res-line);
    border-radius: var(--pill);
    background: var(--res-tint);
}

.resources__segments-thumb {
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 0;
    width: var(--seg-w, 0);
    border-radius: var(--pill);
    background: var(--color-action);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .15);
    transform: translateX(var(--seg-x, 0));
}

.resources__segments.is-ready .resources__segments-thumb {
    transition: transform .35s cubic-bezier(.2, .7, .2, 1), width .35s cubic-bezier(.2, .7, .2, 1);
}

.resources__chip.resources__segment {
    position: relative;
    z-index: 1;
    gap: 6px;
    padding: 7px 16px;
    border: 0;
    background: none;
    color: var(--neutral-800);
    transition: color .25s ease;
}

.resources__chip.resources__segment:hover {
    color: var(--black);
}

.resources__chip.resources__segment.is-on {
    background: none;
    color: var(--white);
}

.resources__segment svg {
    flex: none;
}

.resources__search {
    position: relative;
    display: block;
    flex: 0 1 280px;
    min-width: 200px;
}

.resources__search svg {
    position: absolute;
    top: 50%;
    left: 16px;
    color: var(--neutral-700);
    transform: translateY(-50%);
    pointer-events: none;
}

.resources__search input {
    width: 100%;
    padding: 11px 16px 11px 44px;
    border: 1px solid var(--neutral-300);
    border-radius: var(--pill);
    background: var(--white);
    color: var(--black);
    font-size: 16px; /* (no zoom on phones) */
    -webkit-text-fill-color: currentColor;
}

.resources__search input:focus-visible {
    outline: 2px solid var(--color-action);
    outline-offset: 1px;
}

.resources__count {
    margin: var(--step-5) 0 var(--step-6);
    color: var(--neutral-700);
    font-size: 14px;
}

/* ---------- Cards ---------- */

.resources__grid {
    display: grid;
    /* Cards across (the block's settings): --cards-per-d / -t / -m */
    grid-template-columns: repeat(var(--cards-per-d, 4), minmax(0, 1fr));
    gap: var(--step-7);
    margin: 0;
    padding: 0;
    list-style: none;
}

.resources__card {
    display: flex;
    flex-direction: column;
    margin: 0;
    overflow: hidden;
    border: 1px solid var(--res-line);
    border-radius: 14px;
    background: var(--white);
}

.resources__media {
    position: relative;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: var(--res-tint);
}

.resources__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .6s cubic-bezier(.2, .7, .2, 1);
}

/* Hover: the image zooms gently (as article cards) and a label shows in the middle; the
   image opens the same as the card's button (resource-dialogs.js). */
.resources__media {
    cursor: pointer;
}

.resources__media > svg {
    transition: transform .6s cubic-bezier(.2, .7, .2, 1);
}

.resources__card:hover .resources__media img,
.resources__card:hover .resources__media > svg {
    transform: scale(1.04);
}

.resources__view {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: color-mix(in srgb, var(--black) 35%, transparent);
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s ease;
}

.resources__view > span {
    padding: 8px 18px;
    border-radius: var(--pill);
    background: var(--white);
    color: var(--neutral-900);
    font-size: 14px;
    font-weight: 500;
    transform: translateY(6px);
    transition: transform .3s ease;
}

.resources__media:hover .resources__view {
    opacity: 1;
}

.resources__media:hover .resources__view > span {
    transform: none;
}

@media (prefers-reduced-motion: reduce) {
    .resources__card:hover .resources__media img,
    .resources__card:hover .resources__media > svg,
    .resources__media:hover .resources__view > span {
        transform: none;
    }
}

.resources__media--blank {
    display: grid;
    place-items: center;
    color: var(--tertiary-600);
}

.resources__badge {
    position: absolute;
    top: var(--step-3);
    left: var(--step-3);
    padding: var(--step-1) 10px;
    border-radius: var(--pill);
    background: rgba(0, 0, 0, .72);
    color: var(--white);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .04em;
}

.resources__play {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--white);
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, .5));
    pointer-events: none;
}

.resources__play svg {
    width: 56px;
    height: 56px;
}

.resources__body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: var(--step-2);
    padding: var(--step-5);
}

.resources__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.resources__tags li {
    margin: 0;
    padding: 3px 10px;
    border-radius: var(--pill);
    background: var(--res-tint);
    color: var(--neutral-800);
    font-size: 12px;
}

.resources__title {
    margin: 0;
    color: var(--black);
    font-size: 19px;
    font-style: normal;
    font-weight: 500;
    line-height: 1.3;
    letter-spacing: .01em;
}

.resources__text {
    margin: 0;
    font-size: 15px;
    line-height: 1.55;
}

.resources__action {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--step-2) var(--step-3);
    margin-top: auto;
    padding-top: var(--step-2);
}

.resources__size {
    color: var(--neutral-700);
    font-size: 13px;
}

/* ---------- None yet / none match ---------- */

.resources__note {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--step-4);
    padding: var(--step-8) var(--step-6);
    border: 1px dashed var(--neutral-300);
    border-radius: 14px;
    font-size: 17px;
    text-align: center;
}

.resources__note p {
    margin: 0;
}

/* ---------- Video pop-up ---------- */

.resources__dialog {
    width: min(1000px, calc(100vw - 32px));
    max-width: none;
    margin: auto;
    padding: 0;
    border: 0;
    border-radius: 14px;
    background: var(--black);
    overflow: visible;
}

.resources__dialog::backdrop {
    background: rgba(0, 0, 0, .75);
}

.resources__dialog-box {
    position: relative;
}

.resources__player {
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: 14px;
}

.resources__player :is(iframe, video) {
    width: 100%;
    height: 100%;
    border: 0;
    background: var(--black);
}

.resources__close {
    position: absolute;
    top: -52px;
    right: 0;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--white);
    color: var(--black);
}

@media (max-width: 900px) {
    .resources__tools {
        justify-content: flex-start;
    }

    .resources__search {
        flex: 1 1 260px;
    }
}

@media (max-width: 600px) {
    .resources__tools {
        flex-wrap: wrap;
    }

    .resources__segments,
    .resources__search {
        flex: 1 1 100%;
    }

    .resources__chip.resources__segment {
        flex: 1;
        justify-content: center;
    }
}

/* ---------- Entrance (script.js → reveal.js) ----------
   The heading as in other blocks; the filter bar (the type toggle and search box fade in,
   then, as the blog's topic pills, the label and the pills one after another); then the cards rise
   one after another. */

.blk--resources.rv :is(.resources__intro, .resources__filter-label, .resources__chips > li, .resources__segments, .resources__search, .resources__count, .resources__card, .resources__note--none) {
    opacity: 0;
}

.blk--resources.rv.rv-from-left .resources__intro {
    transform: translateX(calc(var(--reveal-shift) * -1));
}

.blk--resources.rv.rv-from-below .resources__intro {
    transform: translateY(var(--reveal-rise));
}

.blk--resources.rv .resources__chips > li {
    transform: translateY(12px) scale(.96);
}

.blk--resources.rv :is(.resources__card, .resources__note--none) {
    translate: 0 calc(var(--reveal-rise) * .6);
}

.blk--resources.rv-armed .resources__intro {
    transition: opacity var(--reveal-text) ease, transform var(--reveal-text) var(--reveal-ease);
}

.blk--resources.rv-armed .resources__filter-label {
    transition: opacity var(--reveal-text) ease calc(var(--rv-start, 0s) + .15s);
}

.blk--resources.rv-armed .resources__count {
    transition: opacity var(--reveal-text) ease calc(var(--rv-start, 0s) + .3s);
}

.blk--resources.rv-armed .resources__chips > li {
    transition:
        opacity .5s ease calc(var(--rv-start, 0s) + .3s + var(--rv-i, 0) * .05s),
        transform .6s var(--reveal-ease) calc(var(--rv-start, 0s) + .3s + var(--rv-i, 0) * .05s);
}

.blk--resources.rv-armed :is(.resources__segments, .resources__search) {
    transition: opacity var(--reveal-text) ease var(--rv-start, 0s);
}

.blk--resources.rv-armed :is(.resources__card, .resources__note--none) {
    transition:
        opacity var(--reveal-text) ease calc(var(--rv-start, 0s) + var(--rv-i, 0) * var(--reveal-stagger)),
        translate var(--reveal-text) var(--reveal-ease) calc(var(--rv-start, 0s) + var(--rv-i, 0) * var(--reveal-stagger));
}

.blk--resources.rv.rv-heading-in .resources__intro,
.blk--resources.rv.rv-filters-in :is(.resources__filter-label, .resources__chips > li, .resources__segments, .resources__search, .resources__count),
.blk--resources.rv.rv-items-in :is(.resources__card, .resources__note--none) {
    opacity: 1;
    transform: none;
    translate: none;
}

/* ---------- Download link beside "View PDF" ---------- */

.resources__download {
    color: var(--color-action);
    font-size: 13px;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.resources__download .resources__size {
    display: inline-block; /* keeps the link's underline off the size */
    margin-left: 4px;
    color: var(--neutral-700);
}

/* ---------- PDF viewer (script.js) ---------- */

.resources__viewer {
    width: min(960px, calc(100vw - 32px));
    height: calc(100vh - 48px);
    max-width: none;
    max-height: none;
    margin: auto;
    padding: 0;
    border: 0;
    border-radius: 14px;
    background: var(--neutral-100);
    overflow: hidden;
}

.resources__viewer::backdrop {
    background: rgba(0, 0, 0, .7);
}

.resources__viewer-box {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.resources__viewer-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 16px 12px 24px;
    border-bottom: 1px solid var(--neutral-200);
    background: var(--white);
}

.resources__viewer-heading {
    min-width: 0;
}

.resources__viewer-title {
    margin: 0;
    overflow: hidden;
    color: var(--neutral-800);
    font-size: 16px;
    font-weight: 500;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.resources__viewer-pages {
    margin: 2px 0 0;
    color: var(--neutral-700);
    font-size: 13px;
}

.resources__viewer-actions {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 12px;
}

.resources__viewer-link {
    color: var(--color-action);
    font-size: 13px;
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* The close button sits in the bar here (in the video pop-up it floats above) */
.resources__viewer .resources__viewer-close {
    position: static;
    width: 36px;
    height: 36px;
    background: var(--neutral-100);
}

.resources__viewer-pages-area {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 24px;
    overflow: auto;
    overscroll-behavior: contain;
}

.resources__viewer-pages-area:focus-visible {
    outline: 2px solid var(--color-action);
    outline-offset: -2px;
}

.resources__viewer-page {
    flex-shrink: 0;
    width: 100%;
    max-width: 820px;
    background: var(--white);
    box-shadow: 0 2px 12px rgba(0, 0, 0, .12);
}

.resources__viewer-page canvas {
    display: block;
    width: 100%;
    height: auto;
}

.resources__viewer-error {
    margin: auto;
    max-width: 420px;
    color: var(--neutral-700);
    text-align: center;
}

/* Phones: full screen */
@media (max-width: 600px) {
    .resources__viewer {
        width: 100vw;
        height: 100dvh;
        border-radius: 0;
    }

    .resources__viewer-bar {
        flex-wrap: wrap;
        padding: 10px 12px 10px 16px;
    }

    .resources__viewer-heading {
        flex: 1;
    }

    .resources__viewer-title {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        white-space: normal;
    }

    /* (On a phone, opening the file is much the same as Download) */
    .resources__viewer-link {
        display: none;
    }

    .resources__viewer-pages-area {
        gap: 12px;
        padding: 12px;
    }
}

@media (max-width: 1024px) {
    .resources__grid {
        grid-template-columns: repeat(var(--cards-per-t, 2), minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    .resources__grid {
        grid-template-columns: repeat(var(--cards-per-m, 1), minmax(0, 1fr));
    }
}
