/* Styles for gallery.html only ("Top designs on the web"). Shared tokens and components live in css/styles.css. */

.section.gal { padding-top: var(--s6); }

/* Source note: when and where the numbers came from */
.gal-source {
  max-width: 72ch;
  margin: 0 0 var(--s6);
  padding-left: var(--s4);
  border-left: 2px solid var(--line);
  color: var(--muted);
  font-size: var(--t-sm);
  line-height: 1.55;
}

/* Toolbar: site chips on the left, sort and toggle on the right */
.gal-toolbar {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4) var(--s6);
  padding-bottom: var(--s4);
  border-bottom: 1px solid var(--line);
}
.gal-sites { display: flex; gap: var(--s2); flex-wrap: wrap; min-width: 0; }
/* Hold space for the chips and cards that gallery.js adds, so the page below doesn't jump. */
.gal-sites:empty { min-height: 36px; }
.gal-grid[aria-busy="true"]:empty { min-height: 100vh; }
@media (pointer: coarse), (max-width: 767px) { .gal-sites:empty { min-height: 48px; } }
.gal-sites .chip { display: inline-flex; align-items: center; gap: var(--s2); white-space: nowrap; }
.gal-chip-n { color: var(--muted); font-variant-numeric: tabular-nums; font-size: var(--t-xs); }
.gal-sites .chip.is-active .gal-chip-n { color: inherit; opacity: .75; }

.gal-controls { display: flex; align-items: center; gap: var(--s5); flex-wrap: wrap; }
.gal-sort { white-space: nowrap; display: inline-flex; align-items: center; gap: var(--s2); font-size: var(--t-sm); color: var(--muted); }
.gal-sort select {
  font: 500 var(--t-sm) / 1.2 var(--font-body);
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--field-border);
  border-radius: var(--radius-btn);
  padding: 8px 32px 8px 12px;
  min-height: 40px;
  cursor: pointer;
}
.gal-sort select:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* "Sellable only" switch: a real checkbox, visually a track */
.gal-switch { position: relative; display: inline-flex; align-items: center; gap: var(--s2); font-size: var(--t-sm); font-weight: 500; color: var(--ink); cursor: pointer; min-height: 40px; user-select: none; }
.gal-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.gal-switch-track { position: relative; width: 36px; height: 20px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); transition: background-color .15s ease, border-color .15s ease; flex: none; }
.gal-switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--bg); box-shadow: 0 1px 2px rgb(0 0 0 / .25); transition: transform .15s ease; }
.gal-switch input:checked + .gal-switch-track { background: var(--accent); border-color: var(--accent); }
.gal-switch input:checked + .gal-switch-track::after { transform: translateX(16px); }
.gal-switch input:focus-visible + .gal-switch-track { outline: 2px solid var(--focus); outline-offset: 2px; }

.gal-count { margin: var(--s4) 0 var(--s5); color: var(--muted); font-size: var(--t-sm); min-height: 1.4em; }

/* Grid */
.gal-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s6) var(--s5); }
@media (max-width: 1199px) { .gal-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 767px) { .gal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s5) var(--s3); } }

/* Card: photo first, then rank/site/license, title, creator, counts, action */
.gal-card { display: flex; flex-direction: column; min-width: 0; }
.gal-media {
  position: relative;
  display: block;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.gal-media img { width: 100%; height: 100%; object-fit: cover; display: block; transition: opacity .2s ease; }
.gal-card:hover .gal-media img { opacity: .92; }
.gal-ph { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: var(--s2); color: var(--muted); font-size: var(--t-xs); background: var(--surface); }
.gal-ph .icon, .gal-ph svg { width: 28px; height: 28px; opacity: .6; }

.gal-body { display: flex; flex-direction: column; gap: var(--s2); padding-top: var(--s3); flex: 1; min-width: 0; }

.gal-meta { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s1) var(--s2); font-size: var(--t-xs); color: var(--muted); }
.gal-rank { font-family: var(--font-display, inherit); font-weight: 700; font-size: var(--t-sm); color: var(--ink); font-variant-numeric: tabular-nums; }
.gal-site { color: var(--ink-2); font-weight: 500; }
.gal-meta .license-badge { margin-left: auto; }

.gal-title { margin: 0; font-size: var(--t-md); font-weight: 500; line-height: 1.35; letter-spacing: 0; }
.gal-title a { color: var(--ink); text-decoration: none; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gal-card:hover .gal-title a, .gal-title a:hover { color: var(--accent); }
.gal-title a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }

.gal-by { display: flex; align-items: center; gap: var(--s2); margin: 0; font-size: var(--t-sm); color: var(--ink-2); min-width: 0; }
.gal-by span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gal-by .avatar { width: 22px; height: 22px; }

.gal-stats { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); margin: 0; font-size: var(--t-xs); color: var(--muted); }
.gal-stats span { display: inline-flex; align-items: center; gap: 4px; }
.gal-stats b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.gal-stats .icon, .gal-stats svg { width: 14px; height: 14px; }

/* Action: buy for designs in our shop, view-on-site for the rest */
.gal-action { margin-top: auto; padding-top: var(--s2); display: flex; flex-direction: column; gap: var(--s2); }
.gal-action .btn { width: 100%; justify-content: center; }
.gal-action .btn .icon, .gal-view .icon, .gal-action svg { width: 14px; height: 14px; flex: none; }
.gal-out { gap: 6px; }
.gal-view { display: inline-flex; align-items: center; justify-content: center; gap: 4px; font-size: var(--t-sm); color: var(--ink-2); text-decoration: none; padding: 4px 0; }
.gal-view:hover { color: var(--accent); }
.gal-note { margin: 0; font-size: var(--t-xs); line-height: 1.45; color: var(--muted); }
.gal-note a { color: var(--ink-2); text-decoration: underline; text-underline-offset: 2px; }
.gal-note a:hover { color: var(--accent); }

/* Placeholder for the buy button while shop prices load */
.gal-skel-btn { display: block; height: 44px; border-radius: var(--radius-btn); }

/* Empty state spans the grid */
.gal-empty { grid-column: 1 / -1; }
.gal-empty-actions { display: flex; flex-wrap: wrap; gap: var(--s3); justify-content: center; }

/* Closing explainer */
.gal-why {
  margin-top: var(--s8);
  padding: var(--s6);
  border-radius: var(--radius);
  background: var(--surface);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--s3) var(--s6);
  align-items: center;
}
.gal-why h2 { margin: 0; font-size: var(--t-xl); grid-column: 1; }
.gal-why p { margin: 0; color: var(--ink-2); max-width: 68ch; grid-column: 1; }
.gal-why .btn { grid-column: 2; grid-row: 1 / span 2; }

@media (max-width: 767px) {
  .section.gal { padding-top: var(--s5); }
  .gal-toolbar { flex-direction: column; align-items: stretch; flex-wrap: nowrap; }
  .gal-toolbar > * { min-width: 0; max-width: 100%; }
  .gal-sites { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px; max-width: none; width: calc(100% + 32px); }
  .gal-sites::-webkit-scrollbar { display: none; }
  .gal-controls { justify-content: space-between; gap: var(--s3); flex-wrap: nowrap; }
  .gal-sort > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .gal-sort select { max-width: 60vw; }
  .gal-meta .license-badge { margin-left: 0; }
  .gal-title { font-size: var(--t-sm); }
  .gal-action .btn { font-size: var(--t-xs); padding-left: 8px; padding-right: 8px; }
  .gal-why { grid-template-columns: 1fr; padding: var(--s5); }
  .gal-why .btn { grid-column: 1; grid-row: auto; justify-self: start; }
}

/* 16px sort box up to tablet width so iPad/iPhone Safari don't zoom in on focus. */
@media (max-width: 899px) { .gal-sort select { font-size: var(--t-md); } }

/* Phone polish: 44px controls, and below 600px a one-column list card (photo left, details right)
   so the text can stay at 14px instead of squeezing into two 170px columns. */
@media (max-width: 767px) {
  .gal-sites .chip { min-height: 44px; }
  .gal-sort select { min-height: 44px; }
  .gal-switch { min-height: 44px; }
  .gal-chip-n { font-size: var(--t-sm); }
  .gal-source { font-size: var(--t-sm); margin-bottom: var(--s5); }
}
@media (max-width: 599px) {
  .gal-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .gal-card { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: var(--s4); align-items: start; padding: var(--s4) 0; border-bottom: 1px solid var(--line); }
  .gal-card:first-child { padding-top: 0; }
  .gal-media { aspect-ratio: 1; }
  .gal-body { padding-top: 0; gap: 6px; }
  .gal-meta { font-size: var(--t-sm); }
  .gal-meta .license-badge { margin-left: 0; }
  .gal-title { font-size: var(--t-md); }
  .gal-title a { padding-block: 2px; }
  .gal-by, .gal-stats { font-size: var(--t-sm); }
  .gal-stats { gap: 2px var(--s3); }
  .gal-action { padding-top: var(--s2); }
  .gal-action .btn { font-size: var(--t-sm); padding-left: 12px; padding-right: 12px; min-height: 44px; }
  .gal-view { min-height: 44px; font-size: var(--t-sm); }
  .gal-note { font-size: var(--t-sm); line-height: 1.5; }
  .gal-note a { display: inline-block; padding-block: 10px; margin-block: -10px; }
}
@media (max-width: 359px) {
  .gal-card { grid-template-columns: 88px minmax(0, 1fr); gap: var(--s3); }
}

@media (prefers-reduced-motion: reduce) {
  .gal-media img, .gal-switch-track, .gal-switch-track::after { transition: none; }
}
