/* Taxonomy Bookshelf: terms down the left, the chosen term's books standing on a shelf on the right */
.ktb { --ktb-list: 260px; display: grid; grid-template-columns: var(--ktb-list) minmax(0, 1fr); column-gap: 60px; align-items: flex-start; }

.ktb__terms { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.ktb__item { margin: 0; padding: 0; }
.ktb .ktb__term { display: inline-block; width: auto; min-height: 0; margin: 0; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; color: inherit; cursor: pointer; font: inherit; letter-spacing: inherit; text-align: left; text-decoration: none; text-transform: none; transition: color .2s; }
.ktb .ktb__term:hover, .ktb .ktb__term:focus, .ktb .ktb__term:active { background: none; box-shadow: none; }
.ktb .ktb__term.is-active { text-decoration: underline; text-decoration-thickness: 1px; text-decoration-color: var(--e-global-color-secondary); text-underline-offset: 5px; }
.ktb .ktb__term:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }

.ktb__stage { display: flex; flex-direction: column; justify-content: space-between; align-self: stretch; min-width: 0; }
/* The books and the shelf stand in the middle of the space between the header and the footer */
.ktb__middle { display: flex; flex-direction: column; justify-content: center; min-width: 0; }
/* The books and the shelf are in one track. It is as wide as the stage, or as wide as all the books if there are more than fit, so the shelf runs on to the last book. The stage scrolls the track sideways. */
.ktb__scroller { overflow: hidden; cursor: grab; touch-action: pan-y; -webkit-user-select: none; user-select: none; margin-top: -16px; margin-bottom: -40px; padding: 16px 0 40px; }
.ktb__track { width: max-content; min-width: calc(100% - 40px); margin: 0 20px; }
.ktb__books { display: flex; align-items: flex-end; justify-content: center; gap: 4px; min-height: 100px; padding: 0 0 calc(var(--ktb-shelf-top, 22px) / 2); }
.ktb__books > :first-child { margin-left: var(--ktb-shelf-inset, 60px); }
.ktb__books > :last-child { margin-right: var(--ktb-shelf-inset, 60px); }
/* Fade the spines, not the row: an opacity on the row makes it a layer of its own that the shelf then paints over */
.ktb.is-loading .ktb__spine { opacity: .35; }

/* A spine: the title runs down it, in the colour the script worked out from the cover */
.ktb .ktb__spine {
    display: flex; flex: 0 0 auto; align-items: center; justify-content: center; box-sizing: border-box;
    width: 38px; height: 320px; padding: 43px 15px; overflow: hidden;
    background-color: var(--spine, #d9d4cb); color: var(--spine-text, #000); text-decoration: none;
    /* Shading from each side edge, fading out towards the middle of the spine */
    background-image:
        linear-gradient(to right, color-mix(in srgb, var(--ktb-edge, #000000) calc(var(--ktb-edge-opacity, .3) * 100%), transparent) 0%, transparent var(--ktb-edge-spread, 80%)),
        linear-gradient(to left, color-mix(in srgb, var(--ktb-edge, #000000) calc(var(--ktb-edge-opacity, .3) * 100%), transparent) 0%, transparent var(--ktb-edge-spread, 80%));
    /* the soft inner edges, and a tiny shadow the book casts on the shelf under it */
    box-shadow: inset -3px 0 6px rgba(0, 0, 0, .08), inset 2px 0 3px rgba(255, 255, 255, .25), 0 3px 4px -1px rgba(0, 0, 0, .28);
    border-radius: 2px; transition: transform .2s ease, box-shadow .2s ease, opacity .18s ease; position: relative; z-index: 1; transform-origin: 50% 100%;
}
/* A short line near the top and the bottom of each spine, in the same colour as its text */
.ktb .ktb__spine::before, .ktb .ktb__spine::after { content: ""; position: absolute; left: 50%; width: 50%; height: 1px; background: var(--spine-text, #000); opacity: .75; transform: translateX(-50%); pointer-events: none; }
.ktb .ktb__spine::before { top: 12px; }
.ktb .ktb__spine::after { bottom: 12px; }
.ktb .ktb__spine:hover, .ktb .ktb__spine:focus-visible {
    z-index: 3; transform: translateY(var(--ktb-lift, 8px)) scale(var(--ktb-pull, 1.04));
    box-shadow: inset -3px 0 6px rgba(0, 0, 0, .08), inset 2px 0 3px rgba(255, 255, 255, .25), 0 8px 14px rgba(0, 0, 0, .25);
}
.ktb__spine-title { display: block; max-height: 100%; overflow: hidden; font-size: 13px; letter-spacing: .04em; line-height: 1; text-overflow: ellipsis; white-space: nowrap; writing-mode: vertical-rl; }

.ktb__shelf {
    position: relative; height: 14px; border-radius: 0 0 4px 4px;
    background: linear-gradient(180deg, #f6f4f0 0, #ece8e2 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9), 0 8px 14px -6px rgba(0, 0, 0, .18);
}
/* The flat top of the shelf the books stand on, seen from slightly above: it runs back behind the books */
.ktb__shelf::before {
    content: ""; position: absolute; right: 0; bottom: 100%; left: 0; z-index: 0; height: var(--ktb-shelf-top, 22px);
    background: linear-gradient(180deg, #dcd9d3 0, #e6e3de 100%);
    /* the same slant however many books there are: 2% of a typical shelf width (about 950px) */
    clip-path: polygon(19px 0, calc(100% - 19px) 0, 100% 100%, 0 100%);
}

@media (max-width: 767px) {
    .ktb { grid-template-columns: minmax(0, 1fr); row-gap: 24px; }
    .ktb__terms { flex-direction: row; gap: 18px; overflow-x: auto; padding-bottom: 14px; }
    .ktb__item { flex: 0 0 auto; }
}
@media (prefers-reduced-motion: reduce) { .ktb .ktb__spine, .ktb__books, .ktb .ktb__term { transition: none; } }

/* The books are dragged sideways (see the script), they do not scroll; the term row on phones still swipes */
.ktb__terms::-webkit-scrollbar { display: none; }
.ktb__scroller.is-dragging { cursor: grabbing; }
.ktb__scroller.is-dragging .ktb__spine { transition: none; }
.ktb__terms { scrollbar-width: none; }
/* Header: title, number of titles, lowest price */
.ktb [hidden] { display: none !important; }
.ktb__head { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 24px; row-gap: 4px; }
.ktb__title { margin: 0 auto 0 0; }
.ktb__meta { white-space: nowrap; }
.ktb__from-price .woocommerce-Price-amount { color: inherit; font: inherit; }

/* Buttons use Elementor's own button markup, so they take the theme's / kit's button styling */
.ktb__side-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.ktb__footer .elementor-widget-button, .ktb__side-footer .elementor-widget-button { width: auto; margin: 0; }
.ktb__footer .elementor-button-wrapper, .ktb__side-footer .elementor-button-wrapper { margin: 0; }
.ktb__footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.ktb__footer .ktb__from { margin-right: auto; }
.ktb__side { display: flex; flex-direction: column; gap: 40px; min-width: 0; }

/* After the base .ktb__side rule above, so it wins on small screens */
@media (max-width: 767px) {
    .ktb__side { gap: 10px; }
}
