/* shop-table-grid.css: the shop's shelf on a phone (Change 33; the owner's choice «הצעה א׳» of 2026-11-15, after Hali's note that the shop is hard to use on a phone).
   Below 1088px the table of books (a label column and three columns side by side, which on a phone becomes sideways scrollers with one book in view) gives way to a grid of tiles:
   two across on a phone, three from 600px, four from 900px. The books stand on a board in their own colour with the age tag on the board, as on the table's shelf; the table's two text rows
   open in a quick view (shop-table-quickview.js). The table itself is untouched from 1088px up (display: none below, in the page for the finder and for search engines).

   The tile is the same for every book at every width: stage (cover on its board, the age tag ON the board), title, the pre-order note when the book has one, the price, ONE button. The note stands above the price and the buy
   block is pinned to the foot of the tile, so the price and the button sit at the same height in the tiles of one row whatever the title's length or the note. Nothing overlaps: the tag lives inside the board's own box.
   No stripe or line on any side of a tile (the owner's rule): colour is the tile's ground. */

.mg { display: none; }

@media (max-width: 1087px) {
  .tt .shelf-table, .tt .sep, .tt .hint { display: none !important; }
  .tt .mg {
    --mg-cols: 2; --mg-gap: 14px; --mg-cover-h: 164px; --mg-cover-w: 112px; --mg-board-h: 42px;
    display: grid; grid-template-columns: repeat(var(--mg-cols), minmax(0, 1fr)); gap: var(--mg-gap);
    margin-block: 16px 32px;
  }
  /* the colouring box's pictures rise out of it (56px to 64px above it): the box starts far enough below the last tile or the page links that the picture has at least 32px of air above it, not 12px */
  .tt .colouring-box { margin-block-start: 96px; }
}
@media (min-width: 600px) and (max-width: 1087px) {
  .tt .mg { --mg-cols: 3; --mg-gap: 16px; --mg-cover-h: 184px; --mg-cover-w: 128px; }
}
@media (min-width: 900px) and (max-width: 1087px) {
  .tt .mg { --mg-cols: 4; --mg-cover-h: 200px; --mg-cover-w: 140px; }
}

/* ---------- 7 or more products on a phone: the finder keeps the ages and the count in view while the tiles scroll ----------
   (from 900px the table's own one-row bar does it: shop-table.css.) The question above the ages scrolls away: the bar sticks with its top
   LIFTED by that much (--finder-lift, measured by shop-table.js, never guessed: her question text may wrap), so the bar's size never changes when
   it sticks and nothing jumps. Its paper shows once it is stuck, with a soft shadow and no line. */
@media (max-width: 899px) {
  .finder[data-sticky] { position: sticky; inset-block-start: calc(-1 * var(--finder-lift, 0px)); z-index: 15; padding-block: 6px 8px; }
  .finder[data-sticky]::before {
    content: ""; position: absolute; inset-block: 0; inset-inline: calc(50% - 50vw); z-index: -1;
    background: var(--paper); box-shadow: 0 8px 14px -12px rgba(40, 32, 20, .45);
    opacity: 0; transition: opacity var(--dur-state) var(--ease-standard);
  }
  .finder[data-sticky].is-stuck::before { opacity: 1; }
  @supports selector(:has(a)) {
    html:has(.finder[data-sticky]) { scroll-padding-top: 96px; }   /* a control reached with Tab is never left under the bar */
  }
}
@media (max-width: 599px) {   /* the question is a block above the ages: 8px between them, and the same 8px above the ages once the question has scrolled away */
  .finder[data-sticky] .finder-q { margin-block-end: 8px; }
}

/* ---------- the tile ---------- */
.mg-tile {
  display: flex; flex-direction: column; min-inline-size: 0;
  padding: 14px;   /* the air inside a tile is at least the air between tiles (14px on a phone, 16px from 600px) */
  background: var(--book-ground, var(--paper-light));
}
.mg-tile[hidden] { display: none; }
.mg-link { display: flex; flex-direction: column; color: inherit; text-decoration: none; border-radius: 2px; }
.mg-link:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

/* the stage: the cover stands on the board. Row one is a slot of the cover's greatest height, every cover rests on its floor, so the boards of two tiles side by side are level
   whatever the covers' shapes; row two is the board at its own height (a tag that needs two lines makes only its own board taller, never moves a cover or another tile's board). */
.mg-stage {
  display: grid; grid-template-rows: var(--mg-cover-h) auto; justify-items: center; align-items: end;
}
.mg-cover { position: relative; z-index: 1; display: block; margin-block-end: -2px; }   /* 2px sunk into the board: it stands on it */
.mg-cover img {
  display: block; inline-size: auto; block-size: auto; max-inline-size: var(--mg-cover-w); max-block-size: var(--mg-cover-h);
  background: #fff; box-shadow: 3px 4px 9px rgba(40, 32, 20, .32);
}
/* a cover is never wider than its board less 10px of board on each side, at any width (the tile is the container: 100cqw is the board's own width) */
.mg-tile { container-type: inline-size; }
@supports (width: 1cqw) {
  .mg-cover img { max-inline-size: min(var(--mg-cover-w), calc(100cqw - 20px)); }
}
.mg-board {
  display: flex; align-items: center; justify-content: center; box-sizing: border-box;
  inline-size: 100%; min-block-size: var(--mg-board-h); padding: 9px 6px;   /* the board's two ends are the button's two ends: one edge down the whole tile; the tag has 9px above and below it */
  background: linear-gradient(var(--ledge-top) 0 3px, var(--ledge) 3px);
  box-shadow: 0 4px 7px -4px rgba(40, 32, 20, .4);
}
/* the age tag is IN the board here (static), not laid over it as on the table's shelf; a long label wraps inside the board instead of crossing its ends */
.mg-board .age-tag {
  position: static; inset: auto; transform: none; z-index: auto;
  inline-size: auto; max-inline-size: 100%; min-block-size: 22px; margin: 0; padding: 2px 8px;
  white-space: normal; text-align: center;
}
.mg-board .age-tag .age-n { font: 700 16px/1 var(--font-display); }
.mg-board .age-tag .age-words { font: 400 14px/1 var(--font-body); }
.mg-board .age-tag[data-empty-age] { font: 700 16px/1 var(--font-display); }

.mg-title {
  margin: 18px 0 0;
  font: 700 18px/22px var(--font-heading); color: var(--ink); text-align: center; text-wrap: balance; overflow-wrap: anywhere;
}
@media (min-width: 600px) { .mg-title { margin-block-start: 20px; } }
@media (hover: hover) and (pointer: fine) {
  .mg-link:hover .mg-title { text-decoration: underline 1px; text-underline-offset: 4px; }
}

/* a cover-less product: the cloth binding of the table, drawn at the tile's size */
.mg-cover--plate { --k: .5; --bw: 236; --bh: 328; inline-size: calc(var(--bw) * var(--k) * 1px); block-size: calc(var(--bh) * var(--k) * 1px); }
.mg-cover--plate .plate { box-shadow: 3px 4px 9px rgba(40, 32, 20, .32); }

/* ---------- the buy block, pinned to the foot ---------- */
.mg-buy { margin-block-start: auto; padding-block-start: 14px; align-items: stretch; gap: 8px; }
.mg-buy .stock-note { margin: 0; text-align: center; font: 700 14px/1.3 var(--font-body); color: var(--ink); }
.mg-buy .price-line { justify-content: center; align-items: baseline; gap: 2px 8px; }
.mg-buy .price { font-size: 24px; }
.mg-buy .price-was { font-size: 16px; }
.mg-buy .price-note { margin: 0; text-align: center; font: 600 15px/1.35 var(--font-body); color: var(--muted); }
.mg-buy .btn-buy, .mg-buy .page-link {
  display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; inline-size: 100%;
  min-block-size: 44px; margin: 0; padding: 0 8px; border: 0; border-radius: 3px;
  font: 700 15px/1.15 var(--font-body); text-align: center; text-decoration: none; white-space: normal;
}
.mg-buy .page-link { background: var(--paper-light); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }
.mg-buy .page-link:hover, .mg-buy .page-link:focus-visible { background: #DCE6E3; box-shadow: inset 0 0 0 2.5px var(--ink); }
.mg-buy .btn-buy:focus-visible, .mg-buy .page-link:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

/* ---------- a book to come: an unpainted book, no link, no buy block ---------- */
.mg-soon { background: var(--paper-light); }
.mg-soon .mg-title { color: var(--muted); }
.mg-cover--blank { --k: .5; --bw: 196; --bh: 272; }
@media (max-width: 379px) {   /* a narrow phone: the cloth binding and the unpainted book stay inside the board with air on both sides, as the covers do */
  .mg-cover--plate { --k: .4; }
  .mg-cover--blank { --k: .42; }
}
@media (max-width: 339px) { .mg-cover--plate { --k: .37; } }
/* the teaser takes the place of the price and the button in the foot: as tall as the button, in the same place, so the tile ends level with the tiles beside it */
.mg-teaser { margin-block-start: auto; padding-block-start: 14px; min-block-size: 58px; box-sizing: border-box; display: flex; flex-direction: column; justify-content: center; text-align: center; font: 400 15px/1.5 var(--font-body); color: var(--muted); }
.mg-teaser p { margin: 0; }
.mg-teaser p + p { margin-block-start: 4px; }
.mg-teaser a { color: var(--link); }

/* ---------- the quick view: a sheet from the foot of a phone, a centred dialog on a wider screen ---------- */
.mg-modal-open { overflow: hidden; }
.mg-qv {
  inline-size: 100%; max-inline-size: 100%; max-block-size: calc(100dvh - 32px); margin: auto 0 0; padding: 0;
  border: 0; border-radius: 10px 10px 0 0; background: var(--book-ground, var(--paper-light)); color: var(--text);
  box-shadow: 0 -14px 34px -12px rgba(0, 0, 0, .5);
  overflow: auto; overscroll-behavior: contain;
}
.mg-qv::backdrop { background: rgba(24, 22, 16, .58); }
.mg-qv[open] { animation: mg-qv-in 220ms var(--ease-decelerate, ease-out); }
.mg-qv[open]::backdrop { animation: mg-qv-fade 180ms ease-out; }
@keyframes mg-qv-in { from { opacity: 0; transform: translateY(28px); } to { opacity: 1; transform: none; } }
@keyframes mg-qv-fade { from { opacity: 0; } to { opacity: 1; } }
@media (min-width: 600px) {
  .mg-qv { inline-size: min(520px, 100% - 32px); max-inline-size: none; margin: auto; border-radius: 3px; box-shadow: 0 24px 60px -12px rgba(0, 0, 0, .55); }
}
/* the bar stays at the top and the buttons at the foot while a long text scrolls between them: close and buy are always in reach, whatever the phone's height.
   The bar's padding + the button's 12px put the close icon on the same start edge as the text below (16px). */
.mg-qv__bar {
  position: sticky; inset-block-start: 0; z-index: 3;
  display: flex; align-items: center; min-block-size: 56px; padding-inline: 4px;
  background: var(--book-ground, var(--paper-light));
}
.mg-qv__close {
  display: inline-flex; align-items: center; gap: 8px; min-block-size: 44px; padding: 0 12px; border: 0; border-radius: 3px;
  background: transparent; color: var(--ink); font: 600 16px/1 var(--font-body); cursor: pointer;
}
.mg-qv__close svg { inline-size: 18px; block-size: 18px; flex: none; }
.mg-qv__close:hover { background: rgba(30, 28, 22, .07); }
.mg-qv__close:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.mg-qv__inner { padding: 0 16px; }
.mg-qv__top { display: grid; grid-template-columns: 116px minmax(0, 1fr); column-gap: 16px; align-items: stretch; }
.mg-qv__stage { display: flex; flex-direction: column; align-items: center; }   /* the cover's top is the block's top: the title starts on the same line, the price stands level with the board */
.mg-qv__cover { position: relative; z-index: 1; display: block; margin-block-end: -2px; }
.mg-qv__cover img { display: block; inline-size: auto; block-size: auto; max-inline-size: 100px; max-block-size: 140px; background: #fff; box-shadow: 3px 4px 9px rgba(40, 32, 20, .32); }
.mg-qv__cover.mg-cover--plate { --k: .42; }
.mg-qv .mg-board { --mg-board-h: 42px; }
.mg-qv__info { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-inline-size: 0; }
.mg-qv__title { margin: 0; font: 700 24px/27px var(--font-heading); color: var(--ink); text-wrap: balance; overflow-wrap: anywhere; }
.mg-qv__facts { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-inline-size: 0; margin-block-start: auto; }
.mg-qv .stock-note { margin: 0; font: 700 14px/1.3 var(--font-body); color: var(--ink); }
.mg-qv .price-line { gap: 2px 10px; }
.mg-qv .price { font-size: 30px; }
.mg-qv .price-was { font-size: 18px; }
.mg-qv__rows { margin-block-start: 16px; }
.mg-qv__row { margin-block-start: 12px; padding-block-start: 12px; border-block-start: 1px solid rgba(91, 86, 76, .3); }
.mg-qv__row:first-child { margin-block-start: 0; }
.mg-qv__row h3 { margin: 0 0 4px; font: 700 15px/1.3 var(--font-heading); color: var(--plum); }
.mg-qv__row p { margin: 0; font: 400 15px/1.55 var(--font-body); color: var(--text); }
.mg-qv__acts {
  position: sticky; inset-block-end: 0; z-index: 2;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px;
  margin: 18px -16px 0; padding: 14px 16px max(20px, calc(env(safe-area-inset-bottom) + 12px));
  background: var(--book-ground, var(--paper-light));
}
.mg-qv__acts::before {   /* the text fades out under the buttons instead of being cut: invisible when nothing is behind it */
  content: ""; position: absolute; inset-inline: 0; inset-block-end: 100%; block-size: 22px; pointer-events: none;
  background: linear-gradient(to bottom, transparent, var(--book-ground, var(--paper-light)));
}
.mg-qv__acts > * { min-inline-size: 0; }
.mg-qv__acts .btn-buy, .mg-qv__acts .page-link {
  display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; inline-size: 100%;
  min-block-size: 48px; margin: 0; padding: 0 8px; border: 0; border-radius: 3px;
  font: 700 15px/1.15 var(--font-body); text-align: center; text-decoration: none; white-space: normal;
}
.mg-qv__acts .page-link { background: var(--paper-light); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }
.mg-qv__acts .page-link:hover, .mg-qv__acts .page-link:focus-visible { background: #DCE6E3; box-shadow: inset 0 0 0 2.5px var(--ink); }
.mg-qv__acts .btn-buy:focus-visible, .mg-qv__acts .page-link:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.mg-qv__acts .price-note { grid-column: 1 / -1; margin: 0; }
@media (min-width: 600px) and (min-height: 700px) {   /* a tablet, or a large phone held wide: a bigger cover (a phone on its side keeps the small one: its sheet is short) */
  .mg-qv__top { grid-template-columns: 148px minmax(0, 1fr); column-gap: 20px; }
  .mg-qv__cover img { max-inline-size: 132px; max-block-size: 192px; }
  .mg-qv__cover.mg-cover--plate { --k: .54; }
  .mg-qv__title { font-size: 28px; line-height: 31px; }
}
@media (max-width: 359px) {
  .mg-qv__top { grid-template-columns: 104px minmax(0, 1fr); column-gap: 12px; }
  .mg-qv__title { font-size: 21px; line-height: 24px; }
}
/* a name WITH niqqud (the class pil-points, added by inc/typography.php, and the title is set in Alef): Alef's points reach far above and below the letters, so the lines of a long name need more room than the plain
   name's 1.125. 27px at 24px let two lines of ink touch (0.5px, measured by c35-ink-qa.js on a four-line name); these give 4px or more. */
.mg-qv__title.pil-points { line-height: 31px; }
@media (min-width: 600px) and (min-height: 700px) { .mg-qv__title.pil-points { line-height: 36px; } }
@media (max-width: 359px) { .mg-qv__title.pil-points { line-height: 27px; } }
@media (prefers-reduced-motion: reduce) {
  .mg-qv[open], .mg-qv[open]::backdrop { animation: none; }
}
@media (forced-colors: active) {
  .mg-tile { border: 1px solid CanvasText; }
  .mg-qv { border: 1px solid CanvasText; }
  .mg-buy .btn-buy, .mg-qv__acts .btn-buy { border: 1px solid ButtonText; }
}
