/* ---------------------------------------------------------------------------
   Screenshot gallery - /gallery/ and its chapters, and nowhere else.

   A separate file on purpose: site.css is on every page of the site, and a
   gallery rule there would be paid for by all of them. Everything here reads
   the variables site.css defines (--brand, --line, --r, --sh ...), so a
   change of palette reaches the gallery without touching this file.

   Written by tools/build-gallery.py's pages; the markup it relies on:
     .gal-nav     chapter tabs under the hero
     .gal-jump    "On this page" chips inside the hero
     .gal-cover   the chapter's picture beside the heading
     .ggrid       uniform grid of .gshot cards (16:10 thumbnails)
     .gcats       the five chapter cards on the overview
     .gal-pager   previous / next chapter
     .glb         the viewer (built by gallery.js)
--------------------------------------------------------------------------- */

/* ---- chapter tabs -------------------------------------------------------- */

.gal-nav { background: #fff; border-bottom: 1px solid var(--line); }
.gal-nav ul {
  display: flex; gap: 4px; list-style: none; margin: 0; padding: 9px 0;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.gal-nav ul::-webkit-scrollbar { display: none; }
.gal-nav a {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  padding: 7px 14px; border-radius: 100px;
  font-size: .93rem; font-weight: 600; color: var(--text); text-decoration: none;
  transition: background .15s, color .15s;
}
.gal-nav a:hover { background: var(--brand-wash); color: var(--brand-dark); }
.gal-nav a[aria-current="page"] { background: var(--brand); color: #fff; }
/* Six tabs need about 1090px. Below 1200 they tighten, and where they still
   do not fit the row scrolls sideways; the fade at the right edge says so,
   and gallery.js scrolls the current tab into view on arrival. */
@media (max-width: 1200px) {
  .gal-nav a { padding: 7px 10px; font-size: .9rem; }
  .gal-nav ul { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
                mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); padding-right: 28px; }
}

/* The count chip, used in the tabs, the jump chips and the chapter cards. */
.gal-n {
  display: inline-block; min-width: 1.9em; padding: 1px 7px; border-radius: 100px;
  background: var(--brand-wash); color: var(--brand);
  font-size: .74rem; font-weight: 700; line-height: 1.5; text-align: center;
}
.gal-nav a[aria-current="page"] .gal-n { background: rgba(255,255,255,.22); color: #fff; }

/* Sticky under the site header on a desktop, where the header is one row of
   68px + its 1px rule. Below 961px the header turns into the mobile menu and
   its height is no longer a fixed number, so the tabs simply scroll away. */
@media (min-width: 961px) {
  .gal-nav {
    position: sticky; top: 69px; z-index: 60;
    background: rgba(255,255,255,.94); backdrop-filter: saturate(1.6) blur(8px);
  }
  /* an anchor jumped to must clear the header AND the tabs */
  .gal-page [id] { scroll-margin-top: 136px; }
}

/* ---- hero ---------------------------------------------------------------- */

/* Only above site.css's own 1000px break: written unconditionally, this rule
   out-ranks the one that stacks the hero on a phone, and the heading ends up
   squeezed into half of a 390px screen. */
@media (min-width: 1001px) {
  .gal-hero .hero-split { grid-template-columns: 1fr 1.02fr; gap: 40px; }
}
.gal-jump {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px;
}
.gal-jump-h {
  margin-right: 4px; font-size: .78rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}
.gal-jump a {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 7px 5px 13px;
  background: #fff; border: 1px solid var(--line); border-radius: 100px;
  font-size: .88rem; font-weight: 600; color: var(--ink); text-decoration: none;
  transition: border-color .15s, box-shadow .15s;
}
.gal-jump a:hover { border-color: var(--brand-soft); box-shadow: var(--sh); color: var(--brand-dark); }

/* The chapter's picture: a slightly tilted-back card with a second one
   peeking out behind it, so it reads as "a collection" rather than "a
   screenshot". Both layers are decoration; the picture itself is flat. */
.gal-cover {
  position: relative; display: block; border-radius: calc(var(--r) + 2px);
  margin: 10px 10px 18px 0;
}
.gal-cover::before {
  content: ""; position: absolute; inset: 14px -12px -14px 12px; z-index: 0;
  background: #fff; border: 1px solid var(--line); border-radius: calc(var(--r) + 2px);
  box-shadow: var(--sh);
}
.gal-cover img {
  position: relative; z-index: 1; width: 100%; height: auto;
  border: 1px solid var(--line); border-radius: calc(var(--r) + 2px);
  box-shadow: var(--sh-lg); background: #fff;
}
.gal-cover .gshot-zoom { z-index: 2; }
@media (max-width: 1000px) {
  .gal-cover { max-width: 620px; }
}

/* ---- the grid of screenshots --------------------------------------------- */

.ggrid {
  display: grid; gap: 24px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
@media (max-width: 940px) { .ggrid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; } }
@media (max-width: 600px) { .ggrid { grid-template-columns: 1fr; } }

.gshot {
  margin: 0; display: flex; flex-direction: column;
  background: #fff; border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--sh); overflow: hidden;
  transition: transform .16s, box-shadow .16s, border-color .16s;
}
.gshot:hover { transform: translateY(-2px); box-shadow: var(--sh-lg); border-color: var(--brand-soft); }

.gshot-a {
  position: relative; display: block; aspect-ratio: 16 / 10; overflow: hidden;
  background: var(--brand-wash); border-bottom: 1px solid var(--line);
}
.gshot-a img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform .45s cubic-bezier(.22,1,.36,1);
}
.gshot:hover .gshot-a img { transform: scale(1.025); }
.gshot-a:focus-visible { outline-offset: -3px; }

/* "Full size" badge. Always there on a touch screen, where there is no hover
   to reveal it; on a mouse it appears with the hover so the grid stays calm. */
.gshot-zoom {
  position: absolute; right: 10px; bottom: 10px;
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: rgba(15,34,49,.74); color: #fff; box-shadow: 0 4px 12px rgba(15,34,49,.25);
  transition: opacity .18s, transform .18s;
}
.gshot-zoom svg { width: 17px; height: 17px; }
@media (hover: hover) {
  .gshot-zoom { opacity: 0; transform: translateY(4px); }
  .gshot:hover .gshot-zoom, .gshot-a:focus-visible .gshot-zoom,
  .gal-cover:hover .gshot-zoom, .gal-cover:focus-visible .gshot-zoom { opacity: 1; transform: none; }
}

.gshot figcaption {
  padding: 14px 18px 17px; font-size: .92rem; line-height: 1.55; color: var(--muted);
}
/* The title on a line of its own: run into the sentence after it, a bold
   phrase with no full stop read as a typo ("A turn From week, to week"). */
.gshot-t { display: block; margin-bottom: 3px; font-size: 1rem; color: var(--ink); font-weight: 700; line-height: 1.4; }
.gshot-k {
  display: block; margin-bottom: 5px;
  font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--brand);
}

/* ---- overview: the five chapters ----------------------------------------- */

/* Two wide cards, then three: the chapters that are new come first and get
   the room. Six tracks so both rows share one grid and line up. */
.gcats { display: grid; gap: 24px; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.gcat { grid-column: span 2; }
.gcat:nth-child(-n+2) { grid-column: span 3; }
@media (max-width: 940px) {
  .gcats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
  .gcat, .gcat:nth-child(-n+2) { grid-column: span 1; }
  .gcat:first-child { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  .gcats { grid-template-columns: 1fr; }
  .gcat:first-child { grid-column: auto; }
}

.gcat {
  display: flex; flex-direction: column; text-decoration: none; color: inherit;
  background: #fff; border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--sh); overflow: hidden;
  transition: transform .16s, box-shadow .16s, border-color .16s;
}
.gcat:hover { transform: translateY(-3px); box-shadow: var(--sh-lg); border-color: var(--brand-soft); color: inherit; }
.gcat-img {
  display: block; aspect-ratio: 16 / 10; overflow: hidden;
  background: var(--brand-wash); border-bottom: 1px solid var(--line);
}
.gcat-img img { width: 100%; height: 100%; object-fit: cover; transition: transform .45s cubic-bezier(.22,1,.36,1); }
.gcat:hover .gcat-img img { transform: scale(1.025); }
.gcat-b { display: flex; flex-direction: column; gap: 7px; padding: 17px 20px 20px; flex: 1; }
.gcat-h { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.gcat-t { font-size: 1.14rem; font-weight: 700; color: var(--ink); letter-spacing: -.01em; }
.gcat:hover .gcat-t { color: var(--accent); }
.gcat-p { font-size: .95rem; color: var(--muted); line-height: 1.55; }
.gcat-go {
  display: inline-flex; align-items: center; gap: 6px; margin-top: auto; padding-top: 6px;
  font-size: .92rem; font-weight: 600; color: var(--brand);
}
.gcat-go svg { width: 16px; height: 16px; transition: transform .16s; }
.gcat:hover .gcat-go svg { transform: translateX(3px); }

/* ---- previous / next ----------------------------------------------------- */

.gal-pager { border-top: 1px solid var(--line); }
.gal-pager-in { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.gal-pager a {
  display: flex; flex-direction: column; gap: 2px; padding: 16px 20px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--r);
  text-decoration: none; transition: border-color .15s, box-shadow .15s;
}
.gal-pager a:hover { border-color: var(--brand-soft); box-shadow: var(--sh); }
.gal-next { text-align: right; }
.gal-pager-k { font-size: .76rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.gal-pager-t { font-size: 1.05rem; font-weight: 700; color: var(--ink); }
.gal-prev .gal-pager-t::before { content: "\2190\00a0"; color: var(--brand); }
.gal-next .gal-pager-t::after { content: "\00a0\2192"; color: var(--brand); }
@media (max-width: 600px) { .gal-pager-in { grid-template-columns: 1fr; } .gal-next { text-align: left; } }

/* ---- the viewer ---------------------------------------------------------- */

/* A <dialog> opened with showModal(): the browser gives it the top layer,
   traps focus inside it, closes it on Escape and returns focus to the link
   that opened it. None of that is re-implemented in gallery.js. */
.glb {
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; overflow: hidden;
  /* Nearly opaque: at .94 the page's own headings showed through behind the
     caption, which on a phone - where they are large - read as clutter. */
  background: rgba(9,18,28,.985); color: #d5e0ea;
}
.glb::backdrop { background: rgba(9,18,28,.5); }
.glb[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }

.glb-top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 16px 8px 20px; font-size: .9rem;
}
.glb-count { font-variant-numeric: tabular-nums; color: #9fb3c6; }
.glb-tools { display: flex; gap: 8px; }

.glb-stage {
  position: relative; display: flex; align-items: center; justify-content: center;
  min-height: 0; padding: 4px 76px; touch-action: pan-y;
}
.glb-img {
  display: block; max-width: 100%; max-height: 100%; width: auto; height: auto;
  object-fit: contain; border-radius: 6px; background: #fff;
  box-shadow: 0 24px 70px rgba(0,0,0,.55);
  transition: opacity .18s;
}
.glb-img.is-loading { opacity: .35; }

.glb-cap {
  max-width: 82ch; margin: 0 auto; padding: 12px 24px 20px; text-align: center;
  font-size: .95rem; line-height: 1.55; color: #b9c9d8;
}
.glb-cap .gshot-t { color: #fff; }
.glb-cap .gshot-k { color: #8fb4d6; }

.glb-btn {
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0;
  border: 1px solid rgba(255,255,255,.22); border-radius: 50%;
  background: rgba(255,255,255,.08); color: #fff; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.glb-btn:hover { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.45); }
.glb-btn:focus-visible { outline: 3px solid #8fb4d6; outline-offset: 2px; }
.glb-btn svg { width: 20px; height: 20px; }
a.glb-btn { text-decoration: none; }
.glb-prev, .glb-next { position: absolute; top: 50%; transform: translateY(-50%); }
.glb-prev { left: 16px; }
.glb-next { right: 16px; }

@media (max-width: 700px) {
  .glb-stage { padding: 4px 10px; }
  /* on a phone the arrows move under the picture, beside each other, where a
     thumb reaches them - and a swipe does the same job */
  .glb-prev, .glb-next { top: auto; bottom: -52px; transform: none; }
  .glb-prev { left: calc(50% - 54px); }
  .glb-next { right: calc(50% - 54px); }
  .glb-cap { padding-top: 64px; font-size: .9rem; }
}

/* the page behind does not scroll while the viewer is open */
html.glb-lock, html.glb-lock body { overflow: hidden; }

@media print {
  .gal-nav, .gal-jump, .gal-pager, .gshot-zoom { display: none !important; }
  .ggrid { grid-template-columns: repeat(2, 1fr); }
  .gshot { break-inside: avoid; box-shadow: none; }
}
