/* Styles for the Gallery page only (public/gallery.html). */
.gal-wrap { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.gal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.gal-sort select {
  appearance: none; -webkit-appearance: none; font: inherit; font-size: 14px; font-weight: 600; color: #1a1a1a;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%234db8ff' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") no-repeat right 8px center / 22px;
  border: 1px solid rgba(0,0,0,.14); border-radius: 999px; padding: 9px 36px 9px 16px; cursor: pointer;
}
.gal-sort select:focus-visible { outline: 2px solid rgba(77,184,255,.7); outline-offset: 1px; }

.gal-filter { display: flex; align-items: center; gap: 8px; margin: 4px 18px 0; padding: 8px 8px 8px 14px; width: fit-content; max-width: calc(100% - 36px); background: #eaf6ff; color: #0b6aa8; border-radius: 999px; font-size: 13px; }
.gal-filter b { color: #0b4d7a; }
.gal-filter button { flex: none; width: 26px; height: 26px; border: 0; border-radius: 50%; background: #fff; color: #0b6aa8; font-size: 18px; line-height: 1; cursor: pointer; }
.gal-filter[hidden] { display: none; }

/* ---------- the grid: columns filled shortest-first, every picture in its own shape ---------- */
.gal-grid { display: flex; gap: 10px; padding: 12px 14px 0; align-items: flex-start; }
.gal-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.gal-tile { position: relative; display: block; width: 100%; border-radius: 14px; overflow: hidden; background: #e9e9ed; cursor: pointer; padding: 0; border: 0; }
.gal-tile img { display: block; width: 100%; height: 100%; object-fit: cover; }
.gal-tile:focus-visible { outline: 2px solid #1f8fdc; outline-offset: 2px; }
.gal-empty { text-align: center; color: #6b6b73; font-size: 14px; padding: 40px 24px; margin: 0; }
.gal-empty[hidden] { display: none; }
.gal-sentinel { height: 1px; }

/* the re-use button: a small rounded square with two arrows chasing each other in a circle, top right, shown while hovering */
.gal-reuse {
  position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; padding: 0; display: grid; place-items: center;
  border: 0; border-radius: 9px; background: rgba(20,20,24,.62); color: #fff; cursor: pointer;
  opacity: 0; transform: translateY(-2px); transition: opacity .15s ease, transform .15s ease, background .15s ease;
}
.gal-reuse svg { width: 20px; height: 20px; fill: currentColor; }
.gal-tile:hover .gal-reuse, .gal-tile:focus-within .gal-reuse { opacity: 1; transform: none; }
.gal-reuse:hover { background: rgba(31,143,220,.92); }
.gal-reuse::after {   /* the words that appear when the pointer is on the button */
  content: attr(data-tip); position: absolute; right: 0; top: calc(100% + 6px); padding: 4px 9px; border-radius: 7px;
  background: #16161a; color: #fff; font-size: 12px; font-weight: 600; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .12s ease;
}
.gal-reuse:hover::after, .gal-reuse:focus-visible::after { opacity: 1; }
@media (hover: none) { .gal-reuse { opacity: .9; transform: none; } .gal-reuse::after { display: none; } }

/* ---------- the post window ---------- */
.gal-overlay { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: rgba(10,10,14,.5); }
.gal-overlay[hidden] { display: none; }
.gal-win {
  position: relative; width: calc(90vw / var(--ui-z, 1)); height: calc(90vh / var(--ui-z, 1)); height: calc(90dvh / var(--ui-z, 1)); display: grid; grid-template-columns: minmax(0, 1fr) 340px;
  background: #fff; border-radius: 18px; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
.gal-close {
  position: absolute; top: 10px; right: 10px; z-index: 3; width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: rgba(255,255,255,.92); color: #1a1a1a; font-size: 24px; line-height: 1; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.gal-stage { min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center; background: #f0f0f3; padding: 12px; }
.gal-stage img { display: block; width: 100%; height: 100%; object-fit: contain; border-radius: 8px; }   /* the full-size file, as large as the window allows */
.gal-side { min-height: 0; overflow-y: auto; padding: 56px 20px 20px; border-left: 1px solid rgba(0,0,0,.07); display: flex; flex-direction: column; gap: 18px; }
.gal-side h3 { margin: 0 0 8px; font-family: 'Poppins', sans-serif; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #8a8a93; }

.gal-author { display: flex; align-items: center; gap: 10px; }
.gal-avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; overflow: hidden; background: #e4e4e7; color: #71717a; display: grid; place-items: center; font-weight: 700; }
.gal-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gal-author b { display: block; font-size: 15px; color: #1a1a1a; word-break: break-word; }
.gal-author small { display: block; margin-top: 1px; font-size: 12.5px; color: #8a8a93; }

.gal-likes { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; color: #1a1a1a; }
.gal-likes small { font-weight: 500; color: #8a8a93; font-size: 13px; }
.gal-heart { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid rgba(0,0,0,.12); border-radius: 50%; background: #fff; color: #1a1a1a; cursor: pointer; transition: transform .12s ease; }
.gal-heart svg { width: 24px; height: 24px; }
.gal-heart:active { transform: scale(.9); }
.gal-heart[aria-pressed="true"] { color: #e5484d; border-color: rgba(229,72,77,.35); background: #fff1f1; }
.gal-heart[aria-pressed="true"] svg path { fill: currentColor; }

.gal-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.gal-tag { border: 0; border-radius: 999px; padding: 6px 12px; background: #eef0f4; color: #34343c; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.gal-tag:hover { background: #dff0fd; color: #0b6aa8; }
.gal-none { margin: 0; font-size: 13px; color: #8a8a93; }

.gal-sec-head { display: flex; align-items: center; justify-content: space-between; }
.gal-sec-head h3 { margin-bottom: 8px; }
.gal-copy { width: 30px; height: 30px; margin-top: -8px; display: grid; place-items: center; border: 0; border-radius: 8px; background: none; color: #6b6b73; cursor: pointer; }
.gal-copy:hover { background: #eef0f4; color: #1a1a1a; }
.gal-copy svg { width: 18px; height: 18px; }
.gal-prompt { margin: 0; padding: 12px; border-radius: 12px; background: #f6f6f8; color: #2b2b31; font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow-y: auto; }

.gal-actions { display: flex; flex-direction: column; gap: 8px; margin-top: auto; }
.gal-btn { font: inherit; font-size: 15px; font-weight: 700; padding: 13px 16px; border-radius: 999px; border: 1.5px solid rgba(0,0,0,.18); background: #fff; color: #1a1a1a; cursor: pointer; }
.gal-btn:hover { background: #f3f3f6; }
.gal-primary { border-color: transparent; background: linear-gradient(135deg, #4db8ff, #8fd3ff); color: #0b3a5c; }
.gal-primary:hover { filter: brightness(1.05); background: linear-gradient(135deg, #4db8ff, #8fd3ff); }
.gal-remove { align-self: center; border: 0; background: none; color: #b3261e; font: inherit; font-size: 13px; cursor: pointer; text-decoration: underline; }
.gal-remove[hidden] { display: none; }

@media (max-width: 760px) {
  .gal-win { grid-template-columns: 1fr; grid-template-rows: minmax(0, 46%) minmax(0, 1fr); }
  .gal-side { border-left: 0; border-top: 1px solid rgba(0,0,0,.07); padding-top: 16px; }
  .gal-grid { padding-left: 10px; padding-right: 10px; gap: 8px; }
  .gal-col { gap: 8px; }
}

/* ---------- "Saved images" on the profile page ---------- */
.gal-saved { max-width: 900px; margin: 18px auto 0; padding: 0 18px; }
.gal-saved[hidden] { display: none; }
.gal-saved h2 { font-family: 'Poppins', sans-serif; font-size: 16px; font-weight: 700; margin: 0 0 10px; color: #1a1a1a; }
.gal-saved-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; align-items: start; }
.gal-saved-grid a { display: block; border-radius: 12px; overflow: hidden; background: #e9e9ed; }
.gal-saved-grid img { display: block; width: 100%; height: 100%; object-fit: cover; }
.gal-saved .gal-empty { padding: 14px 0; text-align: left; }
.gal-saved .gal-empty a { color: #1f8fdc; font-weight: 700; }
