/* The gallery index (site/gallery.js): a picture per case, a column slider, compact filters, five layouts.
   One DOM for all five; main.gallery[data-layout] picks the CSS. --cols comes from the slider (clamped to what fits). */
.gallery { --cols: 5; --gap: 14px; --aspect: 16 / 10; max-width: 1560px; }
.gallery-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin: 0 0 10px; }
.gallery-head h1 { font-size: 24px; margin: 0; }
.gallery-head .lede { font-size: 13.5px; margin: 0; max-width: none; }

/* filters: two single-line chip rows that scroll sideways rather than wrap */
.gallery .filters { gap: 6px; margin: 0 0 6px; min-width: 0; }
.gallery .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; gap: 4px; padding-bottom: 2px; min-width: 0; }
.gallery .chips-label { width: 36px; font-size: 12px; }
.gallery .chip { font-size: 12px; padding: 2px 9px; white-space: nowrap; flex: 0 0 auto; }
.gallery .panel-head { display: none; }
/* one row for the filters and the column bar (every layout but Rail, which gives the filters their own panel) */
.gallery-body { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 20px; align-items: start; }
.gallery:not([data-layout="rail"]) .g-main { display: contents; }
.gallery:not([data-layout="rail"]) .g-rail { grid-column: 1; grid-row: 1; min-width: 0; }
.gallery:not([data-layout="rail"]) .g-bar { grid-column: 2; grid-row: 1; flex-direction: column; align-items: flex-end; gap: 6px; }
.gallery:not([data-layout="rail"]) .g-groups, .gallery:not([data-layout="rail"]) .empty-note { grid-column: 1 / -1; }

/* the bar: how many, and the column slider; it stays in reach while scrolling */
.g-bar { position: sticky; top: 49px; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; margin: 0 0 8px; background: color-mix(in srgb, var(--background) 94%, transparent); backdrop-filter: blur(6px); }
.gallery .filter-count { margin: 0; }
.cols { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted-foreground); }
.cols label { display: flex; align-items: center; gap: 6px; }
.cols-range { width: 140px; accent-color: var(--foreground); touch-action: pan-y; }
.cols-step { font: inherit; width: 26px; height: 26px; border: 1px solid var(--border); background: var(--background); color: var(--foreground); border-radius: 6px; cursor: pointer; line-height: 1; }
.cols-step:hover { background: var(--accent); }
.cols-out { min-width: 3.2em; font-variant-numeric: tabular-nums; color: var(--foreground); }

/* the grid */
.gallery .cards { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: var(--gap); }
.gallery .app-group { margin: 0 0 22px; }
.gallery .app-group h2 { font-size: 15px; margin: 0 0 8px; }
.gallery .app-group[hidden], .gallery .card[hidden] { display: none !important; }
.g-groups { touch-action: pan-x pan-y; }

/* a card: the picture, then the caption */
.gallery .card { display: flex; flex-direction: column; gap: 6px; padding: 0; border: 0; border-radius: 0; background: none; min-width: 0; position: relative; }
.gallery .card:hover { border-color: transparent; }
.card-link { display: flex; flex-direction: column; gap: 7px; text-decoration: none; min-width: 0; border-radius: 10px; }
.card-link:focus-visible { outline: 2px solid var(--ring); outline-offset: 3px; }
.shot { position: relative; aspect-ratio: var(--aspect); overflow: hidden; border: 1px solid var(--border); border-radius: 9px; background: var(--muted); }
.card-link:hover .shot { border-color: var(--ring); }
.shot img.t { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: left top; display: block; }
/* the picture in the page's theme: a lazy image that is display:none is never fetched */
.shot img.t-dark, .insp-views img.t-dark { display: none; }
:root[data-theme="dark"] .shot img.t-light, :root[data-theme="dark"] .insp-views img.t-light { display: none; }
:root[data-theme="dark"] .shot img.t-dark, :root[data-theme="dark"] .insp-views img.t-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .shot img.t-light, :root:not([data-theme="light"]) .insp-views img.t-light { display: none; }
  :root:not([data-theme="light"]) .shot img.t-dark, :root:not([data-theme="light"]) .insp-views img.t-dark { display: block; }
}
.shot-live { position: absolute; inset: 0; overflow: hidden; background: var(--background); pointer-events: none; }
.shot-live data-views { position: absolute; top: 0; left: 0; width: 200%; --data-height: 200%; height: 200%; transform: scale(.5); transform-origin: 0 0; border: 0; }
.shot-live data-views .dv-status { display: none; }
/* hover flips through the case's views: one segment per view, YouTube's storyboard / Dribbble's multi-shot */
.scrub { position: absolute; left: 8px; right: 8px; bottom: 6px; display: flex; gap: 3px; opacity: 0; transition: opacity .12s; pointer-events: none; }
.scrub i { flex: 1; height: 3px; border-radius: 2px; background: rgba(127, 127, 127, .45); }
.scrub i.on { background: var(--foreground); }
.shot-view { position: absolute; left: 6px; top: 6px; max-width: calc(100% - 12px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: color-mix(in srgb, var(--background) 88%, transparent); border: 1px solid var(--border); opacity: 0; transition: opacity .12s; pointer-events: none; }
.card-link:hover .scrub, .card-link:hover .shot-view { opacity: 1; }
.shot[data-n="1"] .scrub { display: none; }
.cap { min-width: 0; }
.cap h3 { font-size: 13.5px; margin: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cap .line { margin: 2px 0 0; color: var(--muted-foreground); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gallery .card .meta { display: none; margin: 0; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted-foreground); }
.gallery .card .tabs { display: none; }
.g-inspector { display: none; }

/* 1. Index — Observable's and D3's galleries: app headings, uniform small pictures, a title and one line */
.gallery[data-layout="index"] { --gap: 16px; }

/* 2. Shots — Dribbble: one flat grid, bigger 4:3 pictures, a caption row with the app; the summary over the picture on hover */
.gallery[data-layout="shots"] { --gap: 22px; --aspect: 4 / 3; }
.gallery[data-layout="shots"] .g-groups { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: var(--gap); }
.gallery[data-layout="shots"] .app-group, .gallery[data-layout="shots"] .app-group .cards { display: contents; }
.gallery[data-layout="shots"] .app-group h2 { display: none; }
.gallery[data-layout="shots"] .shot { border-radius: 12px; }
.gallery[data-layout="shots"] .card .meta { display: flex; }
.gallery[data-layout="shots"] .meta .pill:not(.pill-app) { display: none; }
.gallery[data-layout="shots"] .cap .line { position: absolute; left: 0; right: 0; top: 0; aspect-ratio: var(--aspect); display: flex; align-items: flex-end; padding: 14px 14px 18px; margin: 0; white-space: normal; color: #fff; font-size: 12.5px; background: linear-gradient(to top, rgba(0, 0, 0, .78), rgba(0, 0, 0, 0) 60%); border-radius: 12px; opacity: 0; transition: opacity .15s; pointer-events: none; }
.gallery[data-layout="shots"] .card-link:hover .cap .line, .gallery[data-layout="shots"] .card-link:focus-visible .cap .line { opacity: 1; }
.gallery[data-layout="shots"] .scrub { bottom: auto; top: 8px; left: auto; width: 40%; right: 10px; }
.gallery[data-layout="shots"] .shot-view { top: auto; bottom: 8px; display: none; }

/* 3. Photos — Apple Photos: edge to edge, hairline gaps, the app as a header across the grid, captions only on hover */
.gallery[data-layout="photos"] { --gap: 3px; --aspect: 4 / 3; }
.gallery[data-layout="photos"] .g-groups { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: var(--gap); }
.gallery[data-layout="photos"] .app-group, .gallery[data-layout="photos"] .app-group .cards { display: contents; }
.gallery[data-layout="photos"] .app-group h2 { grid-column: 1 / -1; margin: 14px 0 4px; font-size: 14px; }
.gallery[data-layout="photos"] .app-group:first-child h2 { margin-top: 0; }
.gallery[data-layout="photos"] .card-link { gap: 0; border-radius: 3px; }
.gallery[data-layout="photos"] .shot { border-radius: 3px; border: 0; }
.gallery[data-layout="photos"] .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 8px 6px; background: linear-gradient(to top, rgba(0, 0, 0, .75), rgba(0, 0, 0, 0)); border-radius: 0 0 3px 3px; opacity: 0; transition: opacity .12s; pointer-events: none; }
.gallery[data-layout="photos"] .cap h3 { color: #fff; font-size: 12px; }
.gallery[data-layout="photos"] .cap .line { display: none; }
.gallery[data-layout="photos"] .card-link:hover .cap, .gallery[data-layout="photos"] .card-link:focus-visible .cap { opacity: 1; }
.gallery[data-layout="photos"] .scrub { top: 6px; bottom: auto; }
.gallery[data-layout="photos"] .shot-view { display: none; }

/* 4. Blocks — shadcn/ui blocks: few, large previews; each case's views as tabs that swap the preview */
.gallery[data-layout="blocks"] { --gap: 18px; }
.gallery[data-layout="blocks"] .card { border: 1px solid var(--border); border-radius: 12px; padding: 12px 12px 10px; background: var(--card); }
.gallery[data-layout="blocks"] .card-link { flex-direction: column-reverse; }
.gallery[data-layout="blocks"] .cap h3 { font-size: 15px; }
.gallery[data-layout="blocks"] .cap .line { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.gallery[data-layout="blocks"] .card .meta { display: flex; }
.gallery[data-layout="blocks"] .card .tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: thin; padding: 3px; background: var(--muted); border-radius: 8px; }
.gallery[data-layout="blocks"] .tabs button { font: inherit; font-size: 12px; border: 0; background: none; color: var(--muted-foreground); padding: 3px 9px; border-radius: 6px; cursor: pointer; white-space: nowrap; flex: 0 0 auto; }
.gallery[data-layout="blocks"] .tabs button:hover { color: var(--foreground); }
.gallery[data-layout="blocks"] .tabs button[aria-selected="true"] { background: var(--background); color: var(--foreground); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.gallery[data-layout="blocks"] .scrub, .gallery[data-layout="blocks"] .shot-view { display: none; }

/* 5. Rail — Streamlit's gallery (a category rail) + Storybook (a details panel): three columns, both panels dragged */
.gallery[data-layout="rail"] { max-width: none; }
.gallery[data-layout="rail"] .gallery-body { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 18px; align-items: start; }
.gallery[data-layout="rail"] .g-rail, .gallery[data-layout="rail"] .g-inspector { position: sticky; top: 60px; max-height: calc(100vh - 72px); overflow: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--card); }
.gallery[data-layout="rail"] .g-rail { width: var(--data-panel-width, 220px); padding: 0 10px 10px; }
.gallery[data-layout="rail"] .g-inspector { display: block; width: var(--data-panel-width, 330px); }
.gallery[data-layout="rail"] .panel-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; font-size: 12px; color: var(--muted-foreground); position: sticky; top: 0; background: var(--card); z-index: 1; }
.gallery[data-layout="rail"] .g-inspector .panel-head { padding: 8px 12px; }
.fold { font: inherit; border: 1px solid var(--border); background: var(--background); color: var(--muted-foreground); border-radius: 6px; width: 24px; height: 22px; cursor: pointer; line-height: 1; }
.fold:hover { color: var(--foreground); background: var(--accent); }
.gallery[data-layout="rail"] .filters { gap: 14px; }
.gallery[data-layout="rail"] .chips { flex-direction: column; align-items: stretch; overflow: visible; }
.gallery[data-layout="rail"] .chips-label { width: auto; font-weight: 600; color: var(--foreground); margin: 0 0 2px; }
.gallery[data-layout="rail"] .chip { text-align: left; border-color: transparent; border-radius: 6px; display: flex; justify-content: space-between; }
.gallery[data-layout="rail"] .chip[aria-pressed="true"] { background: var(--muted); color: var(--foreground); border-color: transparent; font-weight: 600; }
.gallery[data-layout="rail"].fold-rail .g-rail, .gallery[data-layout="rail"].fold-inspector .g-inspector { width: 38px; padding: 0 6px; overflow: hidden; }
.gallery[data-layout="rail"].fold-rail .g-rail > :not(.panel-head), .gallery[data-layout="rail"].fold-inspector .g-inspector > :not(.panel-head) { display: none; }
.gallery[data-layout="rail"].fold-rail .g-rail .panel-head span, .gallery[data-layout="rail"].fold-inspector .g-inspector .panel-head span { display: none; }
.gallery[data-layout="rail"].fold-rail .fold, .gallery[data-layout="rail"].fold-inspector .g-inspector .fold { transform: scaleX(-1); }
.gallery[data-layout="rail"].fold-inspector .g-inspector .panel-head { padding: 8px 0; }
.insp-body { padding: 0 14px 14px; }
.insp-body h2 { font-size: 17px; margin: 4px 0 8px; }
.insp-body h3 { font-size: 12.5px; margin: 14px 0 6px; color: var(--muted-foreground); font-weight: 600; }
.insp-app { margin: 0; font-size: 12px; color: var(--muted-foreground); }
.insp-summary { margin: 0; font-size: 13px; color: var(--muted-foreground); }
.insp-views { list-style: none; margin: 0 0 14px; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.insp-views a { display: flex; flex-direction: column; gap: 3px; text-decoration: none; font-size: 11.5px; position: relative; }
.insp-views img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; object-position: left top; border: 1px solid var(--border); border-radius: 6px; background: var(--muted); }
.insp-views code { font-size: 10px; }

/* the temporary switcher between the five proposals (bottom right; remembered; never a URL flag) */
.layout-switch { position: fixed; right: 14px; bottom: 14px; z-index: 50; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 6px 8px; box-shadow: 0 6px 24px rgba(0, 0, 0, .18); font-size: 12px; max-width: calc(100vw - 28px); }
.layout-switch label { display: flex; align-items: center; gap: 6px; color: var(--muted-foreground); }
.layout-switch select { font: inherit; color: var(--foreground); background: var(--background); border: 1px solid var(--border); border-radius: 6px; padding: 3px 6px; max-width: 100%; min-width: 0; }

@media (max-width: 760px) {
  .gallery-body { grid-template-columns: minmax(0, 1fr); }
  .gallery:not([data-layout="rail"]) .g-bar { grid-column: 1; grid-row: 2; flex-direction: row; align-items: center; }
  .gallery:not([data-layout="rail"]) .g-groups { grid-row: 3; }
  .g-bar { top: 0; position: static; flex-wrap: wrap; }
  .cols-range { width: 110px; }
  .gallery[data-layout="rail"] .gallery-body { grid-template-columns: minmax(0, 1fr); }
  .gallery[data-layout="rail"] .g-rail { position: static; width: auto; max-height: none; }
  .gallery[data-layout="rail"] .chips { flex-direction: row; flex-wrap: nowrap; overflow-x: auto; }
  .gallery[data-layout="rail"] .g-inspector { display: none; }
  .layout-switch span { display: none; }
  .gallery .cap h3 { font-size: 12.5px; }
}
