/* CFS Gallery — responsive, mobile-first. Uses the per-site --cfs-* palette
   variables when present, with sensible fallbacks. */

.cfs-gallery { --gal-accent: var(--cfs-accent, #b8005c); --gal-ink: var(--cfs-text, #1a1a1a);
  --gal-muted: #6b7280; --gal-card: #fff; --gal-line: #e5e7eb; }
.cfs-gallery * { box-sizing: border-box; }
.cfs-gal-section { margin: 0 0 2.2rem; }
.cfs-gal-section > h2 { font-size: 1.25rem; margin: 0 0 .8rem; display: flex; align-items: baseline; gap: .6rem; }
.cfs-gal-seeall { font-size: .8rem; font-weight: 400; color: var(--gal-accent); text-decoration: none; }
.cfs-gal-empty { color: var(--gal-muted); }

/* Image grid */
.cfs-gal-grid { display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
@media (min-width: 720px) { .cfs-gal-grid { gap: 14px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); } }

.cfs-gal-card { position: relative; margin: 0; background: var(--gal-card);
  border-radius: 10px; overflow: hidden; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.08);
  transition: transform .12s ease, box-shadow .12s ease; }
.cfs-gal-card:hover, .cfs-gal-card:focus { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.16); outline: none; }
.cfs-gal-card .cfs-gal-thumb { display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: cover; }
.cfs-gal-meta { display: flex; justify-content: space-between; align-items: center;
  gap: 6px; padding: 7px 9px; font-size: .74rem; color: var(--gal-muted); }
.cfs-gal-by { font-weight: 600; color: var(--gal-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cfs-gal-stats { display: flex; gap: 8px; flex-shrink: 0; }

/* Album cards */
.cfs-gal-album-grid { display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
@media (min-width: 720px) { .cfs-gal-album-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); } }
.cfs-gal-album-card { display: block; text-decoration: none; color: var(--gal-ink);
  background: var(--gal-card); border-radius: 10px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.cfs-gal-album-thumb { aspect-ratio: 4 / 3; background: #f3f4f6; display: flex; align-items: center; justify-content: center; }
.cfs-gal-album-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cfs-gal-noimg { font-size: 2rem; opacity: .4; }
.cfs-gal-album-title { font-weight: 600; padding: 8px 10px 2px; font-size: .95rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cfs-gal-album-count { padding: 0 10px 10px; font-size: .78rem; color: var(--gal-muted); }

.cfs-gal-album-owner { color: var(--gal-muted); font-size: .9rem; margin: 0 0 .6rem; }

/* Buttons + upload bar */
.cfs-gal-btn { background: var(--gal-accent); color: #fff; border: 0; border-radius: 8px;
  padding: .6rem 1rem; font-size: .95rem; font-weight: 600; cursor: pointer; }
.cfs-gal-btn:hover { filter: brightness(1.06); }
.cfs-gal-upload-bar { margin: 0 0 1.4rem; }
.cfs-gal-login { color: var(--gal-muted); }
.cfs-gal-login a { color: var(--gal-accent); }

/* Modal (upload) */
.cfs-gal-modal { position: fixed; inset: 0; z-index: 100000; display: flex; align-items: center;
  justify-content: center; padding: 16px; background: rgba(0,0,0,.55); }
.cfs-gal-modal[hidden] { display: none; }
.cfs-gal-modal-box { background: #fff; border-radius: 14px; width: 100%; max-width: 440px;
  padding: 20px 20px 18px; position: relative; max-height: 92vh; overflow: auto; }
.cfs-gal-modal-box h3 { margin: 0 0 .9rem; }
.cfs-gal-modal-close, .cfs-gal-lb-close { position: absolute; top: 8px; right: 10px; background: none;
  border: 0; font-size: 1.7rem; line-height: 1; cursor: pointer; color: #999; }
.cfs-gal-field { display: block; margin: 0 0 .85rem; }
.cfs-gal-field > span { display: block; font-size: .8rem; font-weight: 600; margin: 0 0 .3rem; color: var(--gal-ink); }
.cfs-gal-field input[type=text], .cfs-gal-field select, .cfs-gal-field input[type=file] {
  width: 100%; padding: .55rem .6rem; border: 1px solid var(--gal-line); border-radius: 8px; font-size: .95rem; }
.cfs-gal-modal-actions { margin-top: .4rem; }
.cfs-gal-upload-status { font-size: .85rem; margin: .3rem 0; min-height: 1.1em; }
.cfs-gal-upload-status.err { color: #c0392b; }
.cfs-gal-upload-status.ok { color: #187a3e; }

/* Lightbox */
.cfs-gal-lightbox { position: fixed; inset: 0; z-index: 100001; }
.cfs-gal-lightbox[hidden] { display: none; }
.cfs-gal-lb-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.85); }
.cfs-gal-lb-content { position: absolute; inset: 0; display: flex; flex-direction: column; }
@media (min-width: 900px) { .cfs-gal-lb-content { flex-direction: row; } }
.cfs-gal-lb-stage { flex: 1 1 auto; display: flex; align-items: center; justify-content: center;
  min-height: 40vh; padding: 12px; }
.cfs-gal-lb-img { max-width: 100%; max-height: 78vh; object-fit: contain; border-radius: 6px; }
.cfs-gal-lb-panel { background: #fff; flex: 0 0 auto; max-height: 42vh; overflow: auto; padding: 16px; }
@media (min-width: 900px) { .cfs-gal-lb-panel { width: 340px; max-height: none; height: 100%; } }
.cfs-gal-lb-close { color: #fff; z-index: 3; font-size: 2.1rem; top: 6px; right: 12px; }
.cfs-gal-lb-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 3;
  background: rgba(0,0,0,.4); color: #fff; border: 0; font-size: 2.2rem; width: 46px; height: 64px;
  cursor: pointer; border-radius: 8px; }
.cfs-gal-lb-prev { left: 8px; } .cfs-gal-lb-next { right: 8px; }
@media (min-width: 900px) { .cfs-gal-lb-next { right: 356px; } }
.cfs-gal-lb-by { font-weight: 700; }
.cfs-gal-lb-date { color: var(--cfs-muted, #6b7280); font-size: .82rem; margin-bottom: .6rem; }
.cfs-gal-lb-caption { margin: 0 0 1rem; line-height: 1.4; }
.cfs-gal-lb-like { display: inline-flex; align-items: center; gap: .4rem; cursor: pointer;
  border: 1px solid var(--gal-line, #e5e7eb); background: #fff; border-radius: 20px; padding: .35rem .8rem;
  font-size: .95rem; margin-bottom: 1rem; }
.cfs-gal-lb-like.liked { color: #b8005c; border-color: #f4c3d8; background: #fff0f6; }
.cfs-gal-lb-like .heart { font-size: 1.1rem; }

/* Comments */
.cfs-gal-comments-list { list-style: none; margin: 0 0 1rem; padding: 0; }
.cfs-gal-comment { position: relative; padding: .55rem 0; border-top: 1px solid #f0f0f0; }
.cfs-gal-c-author { font-weight: 600; margin-right: .5rem; }
.cfs-gal-c-date { color: #9ca3af; font-size: .78rem; }
.cfs-gal-c-body { margin-top: .2rem; }
.cfs-gal-c-body p { margin: .2rem 0; }
.cfs-gal-c-del { position: absolute; top: .5rem; right: 0; border: 0; background: none; color: #bbb;
  font-size: 1.1rem; cursor: pointer; }
.cfs-gal-comment-form textarea { width: 100%; border: 1px solid var(--gal-line, #e5e7eb); border-radius: 8px;
  padding: .5rem; font-size: .92rem; min-height: 3.2em; resize: vertical; }
.cfs-gal-comment-form .cfs-gal-btn { margin-top: .5rem; padding: .45rem .9rem; font-size: .88rem; }
.cfs-gal-c-login { color: #6b7280; font-size: .88rem; }
.cfs-gal-c-login a { color: var(--gal-accent); }

/* dark palette hook */
body.cfs-dark .cfs-gallery { --gal-card: #1e2024; --gal-ink: #f3f4f6; --gal-line: #33363b; }
