/* store.css -- the store's own parts: /store/ (catalogue) and
   /store/edition.php (one edition). Loaded after /assets/site.css, which
   supplies the top bar, footer, colours, fonts, form controls, buttons and
   keyboard-focus outline -- none of that is repeated here.
   Hand-written, no build step, phone-first like site.css. */

/* ---- Catalogue: filter form ---------------------------------------------- */
/* As many columns as fit; on a 320px phone that is one. */
.store-filters {
  display: grid; gap: .75rem; align-items: end;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr));
  margin-block: 1.5rem 1rem;
}
.store-filters p { margin: 0; min-width: 0; }
.store-filters .sf-q { grid-column: 1 / -1; }
.sf-check { display: flex; align-items: center; gap: .5rem; min-height: 2.75rem; }
.sf-check input { width: 1.15rem; height: 1.15rem; margin: 0; flex: none; }
.sf-check label { margin: 0; font-size: .9rem; font-weight: 500; text-transform: none; letter-spacing: 0; }
.sf-go button { width: 100%; }
.store-note { color: var(--muted); font-size: .9rem; }

/* ---- Catalogue: the cards ------------------------------------------------- */
.store-grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 10rem), 1fr));   /* two across on most phones, one at 320px */
}
.card {
  display: flex; flex-direction: column; min-width: 0; overflow: hidden;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  transition: box-shadow .15s;
}
.card:hover { box-shadow: 0 6px 18px rgba(0,0,0,.1); }
.card-link { display: flex; flex-direction: column; flex: 1; color: inherit; text-decoration: none; }
.card-link:hover { color: inherit; }
.card-link:hover .card-title { text-decoration: underline; }
.card-link:focus-visible { outline-offset: -3px; border-radius: 8px; }   /* the card clips anything outside it */
.card-img {
  display: flex; align-items: center; justify-content: center;
  min-height: 9.5rem; padding: 1rem; text-align: center;
  background: var(--soft); border-block-end: 1px solid var(--line);
}
.card-img img { max-height: 10rem; max-width: 100%; object-fit: contain; }
.no-cover { color: var(--muted); font-size: .85rem; font-style: italic; padding: 1rem; }
.card-info { display: flex; flex-direction: column; flex: 1; padding: 1rem 1rem .3rem; overflow-wrap: anywhere; }
.card-title { font-size: 1rem; line-height: 1.3; margin-block: 0 .3rem; }
.card-family { font-size: .82rem; color: var(--muted); margin-block: 0 .6rem; }
.card-specs { font-size: .8rem; color: var(--muted); line-height: 1.5; margin-block: 0 .6rem; }
.card-isbn { font-size: .75rem; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; margin-block: 0 .8rem; }
.card-links { display: flex; flex-direction: column; gap: .4rem; margin-block-start: auto; padding: 0 1rem 1rem; }
.no-offers { font-size: .8rem; color: var(--muted); }

/* ---- Shared by the cards and the edition page ----------------------------- */
.badges { display: flex; flex-wrap: wrap; gap: .3rem; margin-block-end: .7rem; }
.badge {
  padding: .18rem .5rem; border-radius: 4px;
  font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
}
.badge-extent  { background: #dcfce7; color: #166534; }
.badge-print   { background: #fef3c7; color: #92400e; }
.badge-binding { background: #dbeafe; color: #1e40af; }

/* A link out to a retailer (navy) or a free download (green). */
.btn-buy {
  display: block; padding: .5rem .7rem; border-radius: 6px;
  background: var(--navy); color: #fff; font-size: .85rem; font-weight: 600; text-decoration: none;
  transition: background .15s;
}
.btn-buy:hover { background: var(--navy-dark); color: #fff; }
.btn-buy.out-of-stock { background: #6b6b6b; pointer-events: none; }
.btn-buy.btn-download { background: #1a7a4c; text-align: center; }
.btn-buy.btn-download:hover { background: #145c3a; }
.kindle-note { display: block; text-align: center; font-size: .78rem; color: var(--muted); text-decoration: none; }
.kindle-note:hover { color: var(--navy); text-decoration: underline; }

/* Nothing matches the filters. */
.store-empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }

/* ---- Edition page: cover on top, details under it ------------------------- */
.detail-wrap { display: grid; gap: 1.5rem; }
.detail-img {
  align-self: start; padding: 1rem; text-align: center;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
}
.detail-img img { max-width: 100%; max-height: 30rem; object-fit: contain; }
.detail-img .no-cover { display: block; padding: 3rem 1rem; }
.detail-body { min-width: 0; overflow-wrap: anywhere; }
.detail-body h1 { font-size: clamp(1.4rem, 3vw, 1.7rem); margin-block-end: .4rem; }
.detail-family { color: var(--muted); }
.detail-body .badges { margin-block-end: 1.3rem; }
.detail-body .badge { font-size: .74rem; padding: .22rem .6rem; }
.spec-table { width: 100%; border-collapse: collapse; margin-block-end: 1.5rem; font-size: .92rem; }
.spec-table tr { border-block-end: 1px solid var(--line); }
.spec-table th, .spec-table td { padding: .5rem .2rem; text-align: start; vertical-align: top; }
.spec-table th { width: 40%; color: var(--muted); font-weight: 600; }
.spec-table .mm { font-size: .85rem; }
.mm { color: var(--muted); }
.detail-notes {
  padding: 1rem 1.2rem; margin-block-end: 1.5rem; font-size: .9rem;
  border: 1px solid var(--line); border-radius: 8px;
}
.detail-notes h2, .buy-section h2 { font-size: 1.05rem; margin-block: 0 .6rem; }
.detail-notes p { margin: 0; }
.buy-list { display: flex; flex-direction: column; gap: .6rem; max-width: 26rem; }
.buy-list .btn-buy { padding: .7rem 1rem; font-size: .92rem; }
.buy-list .kindle-note { font-size: .82rem; }

/* ---- Wider screens --------------------------------------------------------- */
@media (min-width: 48em) {
  .store-grid { gap: 1.4rem; grid-template-columns: repeat(auto-fill, minmax(14.5rem, 1fr)); }
  .detail-wrap { grid-template-columns: minmax(15rem, 22.5rem) 1fr; gap: 2.4rem; }
  .detail-img { padding: 1.5rem; }
}

/* ---- Paper ----------------------------------------------------------------- */
@media print {
  .store-filters, .store-note { display: none; }
  .card { break-inside: avoid; }
  .btn-buy { background: none; color: #000; padding: 0; }
  .card-links a::after, .buy-list a::after { content: " <" attr(href) ">"; font-weight: 400; word-break: break-all; }
}
