/* ============================================================================
   SADER — SECTION: PUBLICATIONS HUB  (.pubhub)
   Merges the two catalogue experiences — the LIST ("The Scholars' Catalogue",
   .s-library) and the 3D ANIMATION ("The Reading Room", .s-press) — into one
   page with a single "Publications" title and a List / Gallery toggle.

   The hub itself OWNS the page background so it can fade smoothly from the white
   (list) world to the black (gallery) world: the inner sections are made
   transparent, and only .pubhub paints `background-color: var(--bg)` with a
   transition. JS flips `data-theme="dark"` on .pubhub for the gallery view, so
   the token-driven colour recomputes from white to #0E0E0E and the transition
   animates the change. Logical properties throughout; reduced-motion aware.
   ============================================================================ */

.pubhub {
  position: relative;
  min-block-size: 100vh;
  background-color: var(--bg);
  color: var(--text);
  transition: background-color 700ms var(--ease), color 700ms var(--ease);
}

/* The inner experiences must NOT paint their own ground — the hub does, so the
   white→black fade is a single transitioning surface behind both views. */
.pubhub .section,
.pubhub .s-library,
.pubhub .s-press {
  background: transparent;
}

/* --------------------------------------------------------------------------
   HEAD — single title + the view toggle (visible in both worlds)
   -------------------------------------------------------------------------- */
.pubhub__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5) var(--space-7);
  padding-block: clamp(var(--space-9), 8vw, var(--space-11)) var(--space-6);
}

.pubhub__title {
  font-family: var(--font-display);
  font-size: var(--fs-display-2);
  font-weight: var(--fw-semi);
  line-height: var(--lh-display);
  letter-spacing: var(--tracking-display);
  color: var(--text);
  margin: 0;
  transition: color 700ms var(--ease);
}

/* Segmented pill toggle — adapts to the active theme via tokens. */
.pubhub__toggle {
  display: inline-flex;
  gap: 2px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--text) 5%, transparent);
  transition: border-color 700ms var(--ease), background 700ms var(--ease);
}

.pubhub__toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  font-family: var(--font-body);
  font-size: var(--fs-caption);
  font-weight: var(--fw-medium);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-muted);
  background: transparent;
  border: 0;
  border-radius: var(--radius-pill);
  padding-block: 0.6em;
  padding-inline: 1.15em;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--dur-base) var(--ease),
              background-color var(--dur-base) var(--ease);
}
.pubhub__toggle-btn svg {
  inline-size: 1.05em;
  block-size: 1.05em;
  flex: 0 0 auto;
}
.pubhub__toggle-btn:hover { color: var(--text); }
.pubhub__toggle-btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
.pubhub__toggle-btn[aria-pressed="true"] {
  color: var(--on-accent);
  background-color: var(--accent);
}
.pubhub__toggle-btn[aria-pressed="true"]:hover { color: var(--on-accent); }

/* --------------------------------------------------------------------------
   VIEWS — only one is shown; the incoming one fades up.
   -------------------------------------------------------------------------- */
.pubhub__view[hidden] { display: none; }

/* The list section carries its own top padding via .section; trim it because
   the hub head already supplies the breathing room above. */
.pubhub__view .s-library { padding-block-start: var(--space-2); }
.pubhub__view .s-press   { padding-block-start: var(--space-2); }

@media (prefers-reduced-motion: no-preference) {
  .pubhub__view.is-entering { animation: pubhub-fade 520ms var(--ease) both; }
}
@keyframes pubhub-fade {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* On narrow screens stack the title over a full-width toggle. */
@media (max-width: 560px) {
  .pubhub__head { gap: var(--space-4); }
  .pubhub__toggle { inline-size: 100%; }
  .pubhub__toggle-btn { flex: 1 1 0; justify-content: center; }
}
