/* ============================================================
   THE ORIGINALS ART GALLERY — /reading-nook/gallery

   A separate sheet rather than more of styles.css. The gallery is one
   page with one job, and styles.css is already four design eras deep;
   nook.css proved that a page-scoped sheet stays legible where the
   shared one drifts. Tokens come from styles.css, so this file adds
   layout and nothing else — no new colours, no new type scale.

   Every rule here is scoped under .gallery-* so it cannot reach the
   rest of the site.
   ============================================================ */

.gallery-main {
  width: min(calc(100% - 32px), 1180px);
  margin: 0 auto;
  padding: clamp(20px, 4vw, 44px) 0 64px;
}

/* The skip link and the in-page headings have to clear the sticky
   header, the same reason styles.css carries a scroll-margin-top for
   its own anchors. */
.gallery-main,
.gallery-book {
  scroll-margin-top: calc(var(--header-height) + 16px);
}

.gallery-intro {
  max-width: 62ch;
  margin-bottom: clamp(24px, 4vw, 40px);
}

.gallery-intro h1 {
  margin: 6px 0 12px;
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 5vw, 2.75rem);
  line-height: 1.1;
  color: var(--ink-strong);
}

.gallery-intro__lede {
  margin: 0 0 18px;
  font-size: clamp(1rem, 2.4vw, 1.1rem);
  line-height: 1.6;
  color: var(--ink);
}

.gallery-intro__links {
  margin: 0;
}

.gallery-book {
  margin: 0 0 clamp(32px, 5vw, 52px);
}

.gallery-book__title {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 3vw, 1.5rem);
  line-height: 1.2;
}

.gallery-book__title a {
  color: var(--ink-strong);
  text-decoration: none;
}

.gallery-book__title a:hover {
  text-decoration: underline;
}

.gallery-book__meta {
  margin: 0 0 14px;
  font-size: 0.9rem;
  color: var(--muted);
}

/* Two columns on a phone, not three. The kid shelf on the homepage
   shipped three at every width below 900px and left ~48px of label; the
   same arithmetic applies to any tile grid on a 320px screen, so this
   one starts at two and earns more room as it gets it. */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(8px, 2vw, 16px);
}

@media (min-width: 640px) {
  .gallery-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 980px) {
  .gallery-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.gallery-tile {
  margin: 0;
  border: 2px solid var(--ink-line);
  border-radius: var(--radius-md, 14px);
  overflow: hidden;
  background: var(--surface-warm, #fff);
  box-shadow: var(--pop-sm);
}

.gallery-tile img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--surface-warm, #fff);
}

.gallery-tile figcaption {
  padding: 8px 10px 10px;
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--muted);
}

.gallery-tile--cover {
  border-color: var(--ink-strong);
}

.gallery-tile a {
  display: block;
}

/* The transparent outline is not decoration. Windows High Contrast
   drops box-shadow and repaints a transparent outline, so pairing the
   two is what keeps the ring visible in forced-colors — the same
   contract the consolidated focus block in styles.css documents. */
.gallery-tile a:focus-visible,
.gallery-book__title a:focus-visible {
  outline: 3px solid transparent;
  outline-offset: 3px;
  box-shadow: var(--shadow-focus);
  border-radius: var(--radius-sm, 8px);
}

@media (prefers-reduced-motion: no-preference) {
  .gallery-tile {
    transition: transform var(--dur-base, 180ms) var(--ease-out, ease-out);
  }

  .gallery-tile:hover {
    transform: translateY(-2px);
  }
}

html[data-dark="on"] .gallery-tile {
  background: #281a3c;
  border-color: rgba(255, 246, 230, 0.24);
}

html[data-dark="on"] .gallery-tile img {
  background: #281a3c;
}
