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

.cfs-gallery { --gal-accent: var(--cfs-accent, var(--cfs-cb8005c)); --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; }

/* Back-up-a-level link at the top of album / sub-gallery views. */
.cfs-gal-back { display: inline-flex; align-items: center; gap: .35rem; margin: 0 0 1rem;
  font-size: .9rem; font-weight: 600; text-decoration: none; color: var(--gal-accent);
  border: 1px solid var(--gal-line); border-radius: 8px; padding: .4rem .8rem; background: var(--gal-card); }
.cfs-gal-back:hover { filter: brightness(.98); border-color: var(--gal-accent); }

/* 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: var(--cfs-accent2); }
.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; }
/* Right-hand info/comments panel — a cohesive dark panel that matches the
   maroon lightbox (was a stark floating white box). */
.cfs-gal-lb-panel { background: var(--cfs-c170709); color: var(--cfs-cf3dde6); flex: 0 0 auto; max-height: 44vh;
  overflow: auto; padding: 20px 20px 24px; border-top: 1px solid var(--cfs-c3a1520); }
@media (min-width: 900px) { .cfs-gal-lb-panel { width: 360px; max-height: none; height: 100%;
  border-top: 0; border-left: 1px solid var(--cfs-c3a1520); } }
.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-nav:hover { background: rgba(0,0,0,.65); }
.cfs-gal-lb-prev { left: 8px; } .cfs-gal-lb-next { right: 8px; }
@media (min-width: 900px) { .cfs-gal-lb-next { right: 376px; } }

.cfs-gal-lb-by { font-weight: 700; color: var(--cfs-panel-bg-soft); font-size: 1.05rem; }
.cfs-gal-lb-date { color: var(--cfs-cb07a8a); font-size: .8rem; margin-bottom: .8rem; }
.cfs-gal-lb-caption { margin: 0 0 1rem; line-height: 1.5; color: var(--cfs-ce6c8d2); }

.cfs-gal-lb-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 1.1rem; }
.cfs-gal-lb-like { display: inline-flex; align-items: center; gap: .45rem; cursor: pointer;
  border: 1px solid var(--cfs-c5a2535); background: var(--cfs-c2a0f18); color: var(--cfs-panel-bg-soft); border-radius: 20px; padding: .4rem .9rem;
  font-size: .95rem; }
.cfs-gal-lb-like:hover:not(:disabled) { background: var(--cfs-c3a1520); }
.cfs-gal-lb-like.liked { color: var(--cfs-cff6fa0); border-color: var(--cfs-accent-mid); background: var(--cfs-c3a1520); }
.cfs-gal-lb-like:disabled { opacity: .5; cursor: default; }
.cfs-gal-lb-like .heart { font-size: 1.15rem; }
.cfs-gal-lb-del { display: inline-flex; align-items: center; gap: .35rem; cursor: pointer;
  border: 1px solid #b14a4a; background: rgba(177,74,74,.16); color: #ffb0b0; border-radius: 20px;
  padding: .4rem .85rem; font-size: .88rem; font-weight: 600; }
.cfs-gal-lb-del:hover { background: #9a2c2c; color: #fff; border-color: #c85a5a; }

/* Comments (dark) */
.cfs-gal-comments-list { list-style: none; margin: 0 0 1rem; padding: 0; }
.cfs-gal-comment { position: relative; padding: .6rem 0; border-top: 1px solid var(--cfs-c3a1520); }
.cfs-gal-c-author { font-weight: 600; color: var(--cfs-panel-bg-soft); margin-right: .5rem; }
.cfs-gal-c-date { color: var(--cfs-c9a6a78); font-size: .78rem; }
.cfs-gal-c-body { margin-top: .25rem; color: var(--cfs-ce6c8d2); }
.cfs-gal-c-body p { margin: .2rem 0; }
.cfs-gal-c-del { position: absolute; top: .55rem; right: 0; border: 0; background: none; color: var(--cfs-c8a5a68);
  font-size: 1.15rem; cursor: pointer; line-height: 1; }
.cfs-gal-c-del:hover { color: #ff9a9a; }
.cfs-gal-comment-form textarea { width: 100%; background: var(--cfs-c1a0a10); border: 1px solid var(--cfs-c4a1525); border-radius: 8px;
  padding: .55rem; font-size: .92rem; min-height: 3.2em; resize: vertical; color: var(--cfs-cf0d0d8); box-sizing: border-box; }
.cfs-gal-comment-form textarea::placeholder { color: var(--cfs-c9a6a78); }
.cfs-gal-comment-form .cfs-gal-btn { margin-top: .5rem; padding: .45rem .9rem; font-size: .88rem; }
.cfs-gal-c-login { color: var(--cfs-cb07a8a); font-size: .88rem; }
.cfs-gal-c-login a { color: var(--cfs-cff8fa3); }

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