/* wiggy.io/gallery, /gallery/<category> and /w/<slug>-<id>: the public gallery pages, rendered by the gallery Worker
   (gallery/pages.mjs). Builds on site.css (tokens, nav, buttons, footer). Design: design/web/gallery.html and widget.html;
   keep them in step. The widgets themselves are styled by RENDER_CSS in gallery/render.mjs. */

[hidden] { display: none !important; }

/* The gallery pages scroll under the nav from the start, so it always has its line. */
.nav { border-bottom-color: var(--line); }

/* ───── Page head ───── */
.g-head { padding-block: clamp(40px, 6vw, 72px) 28px; }
.g-head__inner { display: grid; gap: 18px; max-width: 760px; }
.g-head .h-hero { font-size: clamp(40px, 6vw, 68px); }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; font: 600 14px/20px var(--font-text); color: var(--ink-3); }
.crumbs a { color: var(--ink-2); text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.crumbs span[aria-hidden] { color: var(--line-strong); }

.g-search { display: flex; align-items: center; gap: 10px; width: min(100%, 560px); min-height: 56px; padding-inline: 20px 8px; border-radius: var(--r-pill);
  background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--line-strong); color: var(--ink-3); }
.g-search:focus-within { box-shadow: inset 0 0 0 2px var(--ink); }
.g-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font: 500 17px/1 var(--font-text); color: var(--ink); }
.g-search input::placeholder { color: var(--ink-3); }
.g-search .btn { min-height: 42px; }

/* Category links: real links, so each category is its own page */
.g-bar { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 69px); z-index: 10; background: color-mix(in srgb, var(--ground) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--line); }
.g-bar__row { display: flex; align-items: center; gap: 16px; padding-block: 12px; }
.g-cats { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); padding-inline-end: 28px; }
.g-cats::-webkit-scrollbar { display: none; }
.g-cat { flex: none; display: inline-flex; align-items: center; min-height: 38px; padding: 0 16px; border-radius: var(--r-pill); background: var(--surface-2);
  color: var(--ink-2); text-decoration: none; font: 600 15px/1 var(--font-text); white-space: nowrap; }
.g-cat:hover { color: var(--ink); background: var(--surface-3); }
.g-cat[aria-current="page"] { background: var(--ink); color: var(--ground); }
.g-cat--fan { box-shadow: inset 0 0 0 1.5px var(--line-strong); background: transparent; }
.g-sort { flex: none; display: inline-flex; padding: 3px; border-radius: var(--r-pill); background: var(--surface-2); }
.g-sort a { padding: 8px 14px; border-radius: var(--r-pill); color: var(--ink-2); text-decoration: none; font: 600 14px/1 var(--font-text); }
.g-sort a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgb(26 20 32 / .12); }

/* ───── Listing ───── */
.g-list { padding-block: 32px clamp(56px, 8vw, 96px); display: grid; gap: 28px; }
.g-list__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 24px; }
.g-list__head p { color: var(--ink-2); max-width: 60ch; }
.g-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 28px 24px; align-items: start; }

/* A card is one link: the widget on its stage, then the sentence that made it */
.gcard { display: grid; gap: 14px; color: inherit; text-decoration: none; border-radius: var(--r-card); }
.gcard__stage { position: relative; display: grid; place-items: center; height: 212px; border-radius: var(--r-card); overflow: hidden;
  background: var(--stage, linear-gradient(160deg, #5B5064, #2C2632)); transition: transform .35s var(--ease); }
.gcard__stage::before { content: ""; position: absolute; inset: 0; opacity: .5;
  background: radial-gradient(circle at 1px 1px, rgb(255 255 255 / .16) 1px, transparent 1.4px) 0 0 / 18px 18px; }
.gcard__stage > * { position: relative; }
/* Wide widgets shrink to fit narrow cards. */
.gcard__stage { container-type: inline-size; }
@container (max-width: 340px) { .gcard__stage .wr { zoom: .86; } }
@container (max-width: 290px) { .gcard__stage .wr { zoom: .74; } }
.gcard__fallback { display: grid; place-items: center; width: 132px; height: 132px; padding: 12px; border-radius: 22px; background: rgb(255 255 255 / .9);
  color: #1A1420; font: 700 15px/1.25 var(--font-display); text-align: center; }
.gcard__stage .pair { display: flex; gap: 14px; }
.gcard:hover .gcard__stage { transform: translateY(-3px); }
.gcard:hover .gcard__title { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.gcard__body { display: grid; gap: 6px; padding-inline: 4px; }
.gcard__title { font: 700 19px/1.25 var(--font-display); letter-spacing: -.005em; }
.gcard q { font: 500 15px/1.45 var(--font-text); color: var(--ink-2); quotes: "“" "”"; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gcard__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font: 500 13px/18px var(--font-text); color: var(--ink-3); }
.gcard__meta b { color: var(--ink-2); font-weight: 600; }
.src { display: inline-flex; align-items: center; gap: 6px; }
.src i { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--ink-3)); }
.tag { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: var(--r-pill); font: 700 12px/16px var(--font-text); background: var(--surface-2); color: var(--ink-2); }
.tag--fan { background: var(--pink-soft); color: var(--pink-ink); }
.gcard__stage .tag { position: absolute; top: 12px; inset-inline-start: 12px; background: rgb(0 0 0 / .45); color: #fff; }

.g-more { justify-self: center; }
.g-empty { display: grid; justify-items: center; gap: 14px; padding: 56px 20px; text-align: center; border-radius: var(--r-card); background: var(--surface-2); }
.g-empty p { color: var(--ink-2); max-width: 44ch; }
.g-note { font: 500 14px/20px var(--font-text); color: var(--ink-3); max-width: 70ch; }
.g-note a { color: inherit; }

/* ───── One widget ───── */
.w-page { padding-block: 24px clamp(56px, 8vw, 96px); }
.w-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: clamp(28px, 5vw, 64px); align-items: start; margin-top: 20px; }
.w-stage { position: sticky; top: 96px; display: grid; gap: 12px; }
.w-stage__screen { position: relative; display: grid; place-items: center; gap: 22px; min-height: clamp(320px, 38vw, 460px); padding: 40px 20px;
  border-radius: var(--r-lg); overflow: hidden; background: var(--stage); }
.w-stage__screen::before { content: ""; position: absolute; inset: 0; opacity: .5;
  background: radial-gradient(circle at 1px 1px, rgb(255 255 255 / .16) 1px, transparent 1.4px) 0 0 / 20px 20px; }
.w-stage__screen > * { position: relative; }
.w-stage__big { zoom: 1.45; display: none; }
.w-stage__sizes { display: flex; gap: 6px; }
.w-stage__sizes label { display: inline-flex; align-items: center; min-height: 34px; padding: 0 14px; border-radius: var(--r-pill); cursor: pointer; font: 700 13px/1 var(--font-text);
  background: rgb(255 255 255 / .18); color: #fff; }
/* The size switch is radio buttons and CSS: the pages run no script. Up to three sizes. */
.w-stage > input { position: absolute; opacity: 0; pointer-events: none; }
#size-0:checked ~ .w-stage__screen .w-stage__big[data-i="0"], #size-1:checked ~ .w-stage__screen .w-stage__big[data-i="1"],
#size-2:checked ~ .w-stage__screen .w-stage__big[data-i="2"] { display: block; }
#size-0:checked ~ .w-stage__screen label[for="size-0"], #size-1:checked ~ .w-stage__screen label[for="size-1"],
#size-2:checked ~ .w-stage__screen label[for="size-2"] { background: #fff; color: var(--on-yellow); }
#size-0:focus-visible ~ .w-stage__screen label[for="size-0"], #size-1:focus-visible ~ .w-stage__screen label[for="size-1"],
#size-2:focus-visible ~ .w-stage__screen label[for="size-2"] { outline: 3px solid var(--focus); outline-offset: 2px; }
.w-stage__cap { font: 500 13px/18px var(--font-text); color: var(--ink-3); }

.w-info { display: grid; gap: 22px; }
.w-info h1 { font: 800 clamp(34px, 4.4vw, 52px)/1.02 var(--font-display); letter-spacing: -.025em; text-wrap: balance; }
.w-maker { display: flex; align-items: center; gap: 10px; font: 600 15px/20px var(--font-text); color: var(--ink-2); }
.w-maker .av { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--yellow-soft); color: var(--on-yellow); font: 800 14px/1 var(--font-display); }
.w-said { display: grid; gap: 8px; padding: 18px 20px; border-radius: var(--r-md); background: var(--surface-2); }
.w-said .label { font: 700 12px/16px var(--font-text); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.w-said q { font: 600 clamp(18px, 1.8vw, 21px)/1.4 var(--font-text); color: var(--ink); quotes: "“" "”"; }
.w-cta { display: grid; gap: 10px; justify-items: start; }
.w-cta__row { display: flex; flex-wrap: wrap; gap: 10px; }
.w-cta .small { max-width: 48ch; }
.w-facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px 20px; margin: 0; padding-top: 20px; border-top: 1px solid var(--line); font: 500 15px/22px var(--font-text); }
.w-facts dt { color: var(--ink-3); }
.w-facts dd { margin: 0; color: var(--ink); }
.w-facts dd small { display: block; color: var(--ink-3); font-size: 13px; line-height: 18px; }
.w-counts { display: flex; gap: 24px; }
.w-counts div { display: grid; }
.w-counts b { font: 800 26px/1.1 var(--font-display); font-variant-numeric: tabular-nums; }
.w-counts span { font: 500 13px/18px var(--font-text); color: var(--ink-3); }
.w-steps { display: grid; gap: 14px; counter-reset: step; margin: 0; padding: 0; list-style: none; }
.w-steps li { display: grid; grid-template-columns: 32px 1fr; gap: 12px; align-items: start; counter-increment: step; }
.w-steps li::before { content: counter(step); width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--yellow); color: var(--on-yellow); font: 800 15px/1 var(--font-display); }
.w-steps b { display: block; font: 700 16px/22px var(--font-text); }
.w-steps span { font: 500 15px/22px var(--font-text); color: var(--ink-2); }
.w-fan { display: grid; gap: 4px; padding: 14px 16px; border-radius: var(--r-md); background: var(--pink-soft); color: var(--ink); font: 500 14px/20px var(--font-text); }
.w-fan b { font-weight: 700; }
.w-small-print { font: 500 13px/19px var(--font-text); color: var(--ink-3); }
.w-small-print a { color: inherit; }
.w-related { margin-top: clamp(56px, 8vw, 96px); display: grid; gap: 24px; }

@media (max-width: 900px) {
  .w-layout { grid-template-columns: minmax(0, 1fr); }
  .w-stage { position: static; }
  .w-stage__big { zoom: 1.2; }
}
@media (max-width: 640px) {
  .g-bar__row { flex-wrap: wrap; gap: 10px; }
  .g-cats { flex-basis: 100%; order: 2; }
  .g-sort { order: 1; }
  .gcard__stage { height: 188px; }
  .w-stage__big { zoom: 1; }
}
@media (prefers-reduced-motion: reduce) { .gcard__stage { transition: none; } }
