/* ═══════════════════════════════════════════════════════════════════════════
   The store shelves — the stage the 3D racks sit in.

   Two experiences share this sheet: the course rack (/store/courses) and the
   bookshelf (/store/books). Both are drawn in WebGL (assets/js/shelf/) with
   every readable word kept as real DOM on top, styled here with the site's own
   tokens so they read as MeducateED navy/gold rather than the reference's
   cream-and-walnut.

   Mo: "a whole width section instead of a boxed player" — so the band is
   FULL-BLEED. It is a direct child of the page, not of a .container, and
   carries the site's own full-bleed chrome (var(--ink-grad) + border-block),
   the same pattern as the ECG bands in home.css. The readable panel inside is
   still held to the site grid by a normal .container, so the words line up
   with every other section on the page.
   ═══════════════════════════════════════════════════════════════════════════ */

.shelf-band {
    position: relative;
    width: 100%;
    overflow: hidden;
    background: var(--ink-grad);
    border-block: 1px solid var(--border-dark);
    display: grid;
    align-items: center;
    /* Tall enough to read the sleeve, short enough that the catalogue below is
       visibly next — a full-viewport stage hides the thing people came for. */
    min-height: clamp(380px, 56vh, 620px);
}

/* Volumes stand ~2.2 units tall where a sleeve is 1.0, so the bookshelf needs
   real vertical room or the camera has to retreat until the spines stop being
   readable. */
.shelf-band-books {
    min-height: clamp(460px, 72vh, 760px);
}

.shelf-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    /* The canvas takes the drag, so the page must not pan under the finger —
       but vertical scrolling has to survive, or the phone traps the reader. */
    touch-action: pan-y;
    cursor: grab;
}
.shelf-canvas.is-dragging { cursor: grabbing; }
.shelf-canvas:active { cursor: grabbing; }
.shelf-canvas:focus-visible { outline: 2px solid var(--gold-live); outline-offset: -4px; }

/* ── the readout ────────────────────────────────────────────────────────── */
.shelf-band-grid {
    position: relative;              /* above the canvas, on the site grid */
    z-index: 2;
    display: grid;
    grid-template-columns: 1.12fr .88fr;
    align-items: center;
    padding-block: var(--s-8);
    /* ⚠ The canvas underneath owns the drag. Without this, the invisible left
       column would swallow every pointer-down and the shelf would not turn. */
    pointer-events: none;
}

.shelf-readout {
    grid-column: 2;
    min-width: 0;
    position: relative;
    padding-block: var(--s-6);
    /* A real gutter before the first letter. Without it the text starts
       exactly where the pool does and the panel reads as chopped. */
    padding-inline-start: clamp(var(--s-5), 2.4vw, var(--s-8));
}

/* A pool of the ground so the words hold over whatever is behind them.
   ⚠ It lives on a pseudo-element that BLEEDS past the container gutter: the
      band is full width, so a background painted on the element itself stops
      at the grid edge and the seam reads as a box floating over the shelf. */
.shelf-readout::before {
    content: "";
    position: absolute;
    z-index: -1;
    inset-block: -40%;
    left: -26%;
    right: calc(-1 * max(var(--s-6), (100vw - var(--maxw)) / 2 + var(--s-6)));
    background: radial-gradient(closest-side at 62% 50%,
        rgba(2, 15, 36, .93) 0%, rgba(2, 15, 36, .74) 52%, rgba(2, 15, 36, 0) 100%);
}
/* Only the things you actually click take the pointer back from the canvas. */
.shelf-readout a,
.shelf-readout button { pointer-events: auto; }

.shelf-uni {
    font-size: .6rem;
    letter-spacing: .26em;
    color: var(--gold-lt);
    margin-bottom: var(--s-3);
    min-height: 1em;            /* no jump when an item has no university */
}

.shelf-title {
    font-family: var(--font-body);
    font-weight: 800;
    font-size: clamp(1.3rem, 2.6vw, 2rem);
    line-height: 1.15;
    color: var(--paper);
    margin: 0;
    text-wrap: balance;
}

.shelf-blurb {
    margin-top: var(--s-4);
    color: var(--peach);
    font-size: .98rem;
    max-width: 42ch;
    /* Blurbs vary; clamp so the panel never reflows as you browse. */
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.shelf-actions {
    margin-top: var(--s-6);
    display: flex;
    align-items: center;
    gap: var(--s-5);
    flex-wrap: wrap;
}
.shelf-price {
    color: var(--gold-live);
    font-size: .9rem;
    letter-spacing: .1em;
}
/* The alternate action sits beside the gold button, so it must not inherit
   the block spacing a lone .btn-link gets. */
.shelf-actions .btn-link { margin: 0; }

.shelf-hint {
    position: absolute;
    /* Held to the same gutter as the container above it, at every width. */
    left: max(var(--s-6), calc((100vw - var(--maxw)) / 2 + var(--s-6)));
    bottom: var(--s-4);
    z-index: 2;
    font-size: .56rem;
    letter-spacing: .22em;
    color: var(--gold-lt);
    opacity: .65;
    pointer-events: none;
}

/* ── narrow: the readout drops below the rack ───────────────────────────── */
@media (max-width: 860px) {
    .shelf-band {
        grid-template-rows: minmax(260px, 40vh) auto;
        align-items: stretch;
        min-height: 0;
    }
    .shelf-band-books { grid-template-rows: minmax(320px, 48vh) auto; min-height: 0; }
    /* Back into the flow, so it takes row 1 rather than covering both. */
    .shelf-canvas { position: relative; grid-row: 1; height: 100%; }
    .shelf-band-grid {
        grid-row: 2;
        grid-template-columns: 1fr;
        padding-block: var(--s-5);
    }
    .shelf-readout {
        grid-column: 1;
        padding-block: 0;
        padding-inline-start: 0;
    }
    /* Stacked below the canvas, there is nothing behind the words to pool. */
    .shelf-readout::before { display: none; }
    .shelf-blurb { max-width: none; -webkit-line-clamp: 3; }
    .shelf-hint { display: none; }
}

/* When a shelf is live the catalogue below it is a reference list, so it gets
   a quieter entrance rather than competing with the rack for attention. */
.has-shelf #courseList,
.has-shelf #bookList { padding-top: var(--s-8); }

@media (prefers-reduced-motion: reduce) {
    /* The engines refuse to mount at all under reduced motion, so the band
       stays hidden and this is belt-and-braces. */
    .shelf-band { display: none; }
}
