/* ============================================================================
   SADER — s-publications
   Louis-Vuitton-style editorial product showcase for the legal library.
   A masked, scroll-snapped horizontal shelf of book covers framed on a
   parchment mat, with serif titles + faint captions and a brass caption rule
   that draws in on hover. Light (ivory) world; reuses semantic tokens only.
   Loaded AFTER components.css. Logical properties only — RTL flips for free.
   ============================================================================ */

.s-publications {
  position: relative;            /* anchor for the rotated .rail-label        */
  background-color: var(--bg-alt);
  overflow: hidden;              /* contain the full-bleed shelf + mask        */
}

/* Intro and foot stay on the reading measure; the shelf goes full-bleed. */
.s-publications__intro {
  position: relative;
  z-index: var(--z-base);
}

/* Let this section's header use the FULL container width, so the CTA can sit
   at the true right edge while the heading + lead keep a readable measure. */
.s-publications__intro .section-head { max-inline-size: none; }
.s-publications__intro .eyebrow,
.s-publications__intro .section-head__title { max-inline-size: 46rem; }

/* CTA sits BESIDE the intro lead on one row (wraps under it on phones). */
.s-publications__lead-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: clamp(var(--space-5), 3vw, var(--space-8));
  margin-block-start: var(--space-5);
}
.s-publications__lead-row .section-head__lead {
  /* Hold the lead on a readable measure (don't grow) so the free space in the
     full-width row lets the CTA's auto-margin push it to the far inline-end. */
  flex: 0 1 46rem;
  max-inline-size: 46rem;
  margin-block: 0;
}
.s-publications__cta {
  flex: 0 0 auto;
  /* Shove the button to the far inline-end of the row (right in LTR, left in
     RTL), opposite the lead rather than hugging right beside it. */
  margin-inline-start: auto;
  margin-block-start: 0;
  white-space: nowrap;
}

/* ----------------------------------------------------------------------------
   THE SHELF — full-bleed horizontal scroller with masked edges.
   The leading/trailing scroll padding equals the page gutter so the first and
   last covers line up with the section head above them.
   -------------------------------------------------------------------------- */
.s-publications__shelf-wrap {
  position: relative;
  /* Align the shelf with the rest of the page: same max width + gutters as
     .container, instead of running full-bleed to the viewport edges. */
  inline-size: 100%;
  max-inline-size: var(--container);
  margin-inline: auto;
  margin-block-start: clamp(var(--space-7), 4vw, var(--space-9));
  /* Soft fade on both inline edges — mirrors the .marquee mask treatment. */
  -webkit-mask-image: linear-gradient(to right,
            transparent 0,
            #000 clamp(1.5rem, 5vw, 5rem),
            #000 calc(100% - clamp(1.5rem, 5vw, 5rem)),
            transparent 100%);
          mask-image: linear-gradient(to right,
            transparent 0,
            #000 clamp(1.5rem, 5vw, 5rem),
            #000 calc(100% - clamp(1.5rem, 5vw, 5rem)),
            transparent 100%);
}

.s-publications__shelf {
  /* How many covers are "faced" (fully visible) at once; the rest scroll in.
     More columns = smaller covers. */
  --shelf-cols: 4;
  --shelf-gap: clamp(var(--space-5), 2.4vw, var(--space-7));
  display: flex;
  justify-content: flex-start;
  gap: var(--shelf-gap);
  list-style: none;
  margin: 0;
  padding-block: var(--space-4) var(--space-6);
  padding-inline: var(--gutter);
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;                     /* glide when paging the shelf */
  scroll-snap-type: x mandatory;
  scroll-padding-inline-start: var(--gutter);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;                       /* Firefox: hide scrollbar     */
}
.s-publications__shelf::-webkit-scrollbar { display: none; }  /* WebKit       */

.s-publications__item {
  flex: 0 0 auto;
  /* Exactly --shelf-cols covers fill the visible width; every extra book spills
     past the edge and is reached by scrolling/snapping (mask fades the seam). */
  inline-size: calc(
    (100% - (var(--shelf-cols) - 1) * var(--shelf-gap)) / var(--shelf-cols)
  );
  scroll-snap-align: start;
}

/* Fewer faced covers as the viewport narrows, so books never get too thin. */
@media (max-width: 900px) { .s-publications__shelf { --shelf-cols: 4; } }
@media (max-width: 600px) { .s-publications__shelf { --shelf-cols: 2; } }

/* Honour reduced-motion: don't animate the horizontal paging. */
@media (prefers-reduced-motion: reduce) {
  .s-publications__shelf { scroll-behavior: auto; }
}

/* ----------------------------------------------------------------------------
   THE BOOK — link wrapping a framed cover + caption block.
   -------------------------------------------------------------------------- */
.s-publications__book {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  color: var(--text);
  block-size: 100%;
}

/* No mat, no shadow. Every cover is rendered at the SAME fixed height; the
   width follows the cover's own ratio (never distorted, never cropped), so the
   row reads as a tidy, even shelf regardless of each book's true proportions. */
/* UNIFORM BOX — identical width AND height for every book, so the row is a
   perfectly even grid. Each cover fills its box (object-fit: cover). The box is
   7:10, matching the ~0.7 portrait covers (which fill with NO crop); the few
   square covers are centred and trimmed slightly on the sides to match — the
   title/centre is always preserved, and nothing is ever distorted. */
.s-publications__media {
  inline-size: 100%;
  aspect-ratio: 7 / 10;
  overflow: hidden;             /* clip the fill + the hover zoom */
  background: none;
  border: 0;
}

/* Higher specificity than the .card__media component (which forces 100%/100%). */
.s-publications__book .s-publications__media img {
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
  object-position: center;
  border-radius: 1px;
  transition: transform var(--dur-slow) var(--ease);
}

/* Hover/focus: a gentle, shadowless zoom (the frame itself doesn't move). */
@media (prefers-reduced-motion: no-preference) {
  .s-publications__book:hover .s-publications__media img,
  .s-publications__book:focus-visible .s-publications__media img {
    transform: scale(1.04);
  }
}

/* ----------------------------------------------------------------------------
   CAPTION — kicker (discipline) + serif title + faint meta + growing rule.
   -------------------------------------------------------------------------- */
.s-publications__caption {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-inline-end: var(--space-3);
}

.s-publications__title {
  font-family: var(--font-display);
  font-size: var(--fs-h4);
  font-weight: var(--fw-semi);
  line-height: var(--lh-snug);
  letter-spacing: var(--tracking-tight);
  color: var(--text);
  /* Keep the shelf rhythm even when titles differ in length. */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color var(--dur-fast) var(--ease);
}
.s-publications__book:hover .s-publications__title,
.s-publications__book:focus-visible .s-publications__title {
  color: var(--accent-deep);
}

.s-publications__meta {
  font-family: var(--font-body);
  font-size: var(--fs-caption);
  line-height: var(--lh-snug);
  color: var(--text-faint);
}

/* The brass caption underline — grows from the inline-start on hover. */
.s-publications__rule {
  margin-block-start: var(--space-1);
  inline-size: clamp(28px, 3vw, 40px);
  block-size: 2px;
  background-color: var(--accent);
  transition: inline-size var(--dur-base) var(--ease);
}
@media (prefers-reduced-motion: no-preference) {
  .s-publications__book:hover .s-publications__rule,
  .s-publications__book:focus-visible .s-publications__rule {
    inline-size: 100%;
  }
}

/* ----------------------------------------------------------------------------
   FOOT — running count + the single brass CTA.
   -------------------------------------------------------------------------- */
.s-publications__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-5) var(--space-7);
  margin-block-start: clamp(var(--space-8), 5vw, var(--space-10));
  padding-block-start: var(--space-7);
  border-block-start: 1px solid var(--line);
}
.s-publications__count {
  font-family: var(--font-display);
  font-size: var(--fs-h3);
  font-weight: var(--fw-regular);
  line-height: var(--lh-snug);
  color: var(--text-muted);
  max-inline-size: 30ch;
}
.s-publications__numeral {
  font-size: 1.15em;
  font-weight: var(--fw-light);
  padding-inline: 0.08em;
}

/* ----------------------------------------------------------------------------
   RESPONSIVE — slightly smaller covers on phones; the shelf already scrolls.
   -------------------------------------------------------------------------- */
@media (max-width: 600px) {
  .s-publications__item { inline-size: 68vw; }
  .s-publications__shelf { gap: var(--space-6); }
}


/* ── Mouse navigation — prev/next arrows (injected by publications-shelf.js) ──
   The shelf scrollbar is hidden by design, so a plain mouse can't move it.
   These arrows give mouse + keyboard users a way to browse the covers. They
   are mounted on the section (outside the wrap's edge-mask) and hidden on
   touch devices, which can already swipe. ───────────────────────────────── */
.s-publications { position: relative; }
.s-publications__arrow {
  position: absolute;
  z-index: 4;
  transform: translateY(-50%);
  inline-size: clamp(2.75rem, 3vw, 3.25rem);
  block-size: clamp(2.75rem, 3vw, 3.25rem);
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--text);
  background-color: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06), 0 12px 28px rgba(0,0,0,0.12);
  transition: background-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              opacity var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease);
}
.s-publications__arrow--prev { inset-inline-start: clamp(var(--space-3), 2vw, var(--space-6)); }
.s-publications__arrow--next { inset-inline-end:  clamp(var(--space-3), 2vw, var(--space-6)); }
.s-publications__arrow:hover { background-color: var(--text); color: var(--bg); border-color: var(--text); }
.s-publications__arrow:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.s-publications__arrow:disabled { opacity: 0; pointer-events: none; }
.s-publications__arrow svg {
  inline-size: 1.35rem; block-size: 1.35rem;
  fill: none; stroke: currentColor;
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}
[dir="rtl"] .s-publications__arrow svg { transform: scaleX(-1); }   /* point chevrons inward for RTL */

@media (hover: none) {                 /* touch devices can swipe — no arrows needed */
  .s-publications__arrow { display: none; }
}
