/* =========================================================================
   views/portal-photos — the client portal's Photos tab for an uploaded
   website (portalWebsitePage paintPhotos, a live custom site): every
   picture the site serves (services/customLivePhotos), each once, in its
   group: Pages, each big list (Blog, Fridges…), the small lists put away
   under Other lists, Logos & icons, Share images; each a heading line and
   one row of tiles, Show all for the rest. A tile is its one action (Edit
   in CMS, Edit on page, Replace): the picture is the button, and a hover,
   keyboard focus or (on a touch screen) a caption says what and the action. The
   upload's pictures no page shows are put away under them; then the
   library and its drop row, and the Replace picker.
   Prefix: cph- (custom photos). The library under it is siteDetailsRows'
   (.sd-photos, sites.css); a list's own tab is collections.css (ccol-).
   ========================================================================= */
.cph { display: flex; flex-direction: column; gap: var(--space-3); }
.cph[hidden] { display: none; }
.cph + .cph { margin-top: var(--space-8); }
.cph-head { display: flex; align-items: baseline; gap: var(--space-2); }
.cph-head :is(h3, h4, h5) { margin: 0; font-size: var(--text-sm); font-weight: var(--fw-semibold); color: var(--text-strong); }
/* a section's heading (On your website, Photos you've added) a step above its groups' */
.cph-head--section :is(h3, h4) { font-size: var(--text-base); }
.cph-head--section .cph-count { font-size: var(--text-sm); }
/* a group's heading: its name and count (the count wraps under a long name), Open in CMS on the first line always */
.cph-head-text { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: var(--space-2); row-gap: var(--space-0-5); flex: 1 1 auto; min-width: 0; }
.cph-head .cph-head-link { display: inline-flex; align-items: center; min-height: var(--control-xs); margin-left: auto; font-size: var(--text-sm); white-space: nowrap; }
.cph-count { font-size: var(--text-xs); color: var(--text-soft); font-variant-numeric: tabular-nums; }
.cph-lede { margin: 0; font-size: var(--text-sm); color: var(--text-muted); line-height: var(--leading-snug); }

/* the groups: a heading line, one row of pictures, Show all for the rest */
.cph-groups { display: flex; flex-direction: column; gap: var(--space-6); }
.cph-group { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.cph-more {
  align-self: flex-start; min-height: var(--control-xs); margin-top: calc(var(--space-1) * -1); padding: 0; border: 0; border-radius: var(--radius-xs);
  background: none; font: inherit; font-size: var(--text-sm); color: var(--text-muted); cursor: pointer;
}
@media (hover: hover) and (pointer: fine) { .cph-more:hover { color: var(--text-strong); } }
.cph-more[hidden], .cph-tile[hidden] { display: none; }   /* (fitRows: one row of a group, as many across as fit) */

/* the small lists, put away together: their groups once it opens */
.cph-other-groups { display: flex; flex-direction: column; gap: var(--space-6); padding: var(--space-3) 0 var(--space-5); }

/* the pictures: a plain grid of tiles; a tile with an action is one button (.cph-hit) */
.cph-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: var(--space-5) var(--space-4); }
/* (120px tiles, 8 across on a wide screen; never fewer than 3 across, so a narrow window shows a row as a phone does) */
.cph-grid--sm { --cph-gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(min(120px, calc((100% - 2 * var(--cph-gap)) / 3)), 1fr)); gap: var(--space-3) var(--cph-gap); }
.cph-tile { position: relative; display: flex; flex-direction: column; gap: var(--space-1-5); min-width: 0; }
.cph-img { position: relative; display: block; aspect-ratio: 4 / 3; overflow: hidden; border-radius: var(--radius-md); background: var(--surface-sunk); box-shadow: inset 0 0 0 1px var(--border-faint); }
.cph-img img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cph-tile.is-graphic .cph-img img { object-fit: contain; padding: var(--space-4); }   /* a logo, or a see-through icon: whole, never cropped (a photo, an SVG one too, fills) */
.cph-tile[data-tone="light"] .cph-img { background: var(--logo-well-dark); box-shadow: none; }   /* a white logo on the dark well a logo strip gives it */
.cph-tile[data-tone="dark"] .cph-img { background: var(--logo-well); }   /* …and a dark one on the white well, in the dark theme too */
.cph-badge { position: absolute; top: var(--space-1-5); left: var(--space-1-5); }
.cph-tile.is-swapped .cph-img { box-shadow: inset 0 0 0 1px var(--border-strong); }
.cph-where { overflow: hidden; font-size: var(--text-xs); color: var(--text-muted); line-height: var(--leading-snug); white-space: nowrap; text-overflow: ellipsis; }
/* (a tile's caption on a touch screen: where, then what a tap does) */
.cph-where:has(.cph-where-act) { display: flex; flex-direction: column; }
.cph-where-what { overflow: hidden; text-overflow: ellipsis; }
.cph-where-act { color: var(--text-soft); }
/* a picture with nothing to show: a quiet picture mark */
.cph-ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-soft); }
.cph-ph svg { width: 20px; height: 20px; }
/* saving: the picture dimmed, the shared spinner over it */
.cph-tile.is-busy .cph-img img { opacity: .6; transition: opacity var(--dur) var(--ease); }
.cph-spin { position: absolute; inset: 0; display: grid; place-items: center; }
.cph-spin > .spinner { box-sizing: content-box; padding: var(--space-1-5); border-radius: var(--radius-full); background: var(--surface); box-shadow: var(--shadow-sm); background-clip: padding-box; }

/* the tile as its button: the picture, and over it on hover or keyboard focus what it is and what a click does */
.cph-hit { position: relative; display: block; width: 100%; padding: 0; border: 0; border-radius: var(--radius-md); background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.cph-hit:focus-visible { outline-offset: 2px; }
.cph-tip {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; gap: var(--space-0-5);
  padding: var(--space-2) var(--space-2-5); border-radius: inherit; pointer-events: none;
  background: linear-gradient(to top, var(--overlay-media-strong), transparent 72%); color: var(--text-invert);
  opacity: 0; transition: opacity var(--dur-fast) var(--ease);
}
.cph-tip-what { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; font-size: var(--text-xs); font-weight: var(--fw-medium); line-height: var(--leading-snug); overflow-wrap: anywhere; }
.cph-tip-act { font-size: var(--text-xs); line-height: var(--leading-snug); opacity: .8; }
.cph-hit:focus-visible .cph-tip { opacity: 1; }
/* a pointer: the caption goes, hover tells; a touch screen keeps the quiet caption line under each tile */
@media (hover: hover) and (pointer: fine) {
  .cph-hit:hover .cph-tip { opacity: 1; }
  .cph-tile.is-action .cph-where { display: none; }
}
.cph-hit:disabled { cursor: default; }
.cph-hit:disabled .cph-tip, .cph-tile.is-busy .cph-tip { opacity: 0; }
/* a replaced picture's way back, on its corner */
.cph-undo {
  position: absolute; top: var(--space-1-5); right: var(--space-1-5); height: var(--control-xs); padding: 0 var(--space-2);
  border: 0; border-radius: var(--radius-full); background: var(--overlay-media-strong); color: var(--text-invert);
  font: inherit; font-size: var(--text-xs); font-weight: var(--fw-medium); cursor: pointer;
}
@media (hover: hover) and (pointer: fine) { .cph-undo:hover { background: var(--overlay-image-hover); } }
.cph-undo:focus-visible { outline-offset: 2px; }
.cph-error { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.cph-error p { margin: 0; font-size: var(--text-sm); color: var(--text-muted); }

/* the upload's pictures no page shows: one row, open to see them */
.cph-gallery { border-bottom: 1px solid var(--border-faint); }
.cph-gallery:first-of-type { border-top: 1px solid var(--border-faint); }
.cph-gallery summary { display: flex; align-items: center; gap: var(--space-2); min-height: var(--control-lg); list-style: none; cursor: pointer; border-radius: var(--radius-sm); }
.cph-gallery summary:focus-visible { outline-offset: 2px; }
.cph-gallery summary::-webkit-details-marker { display: none; }
.cph-gallery summary svg { width: 16px; height: 16px; margin-left: auto; color: var(--text-soft); transition: transform var(--dur) var(--ease); }
.cph-gallery[open] summary svg { transform: rotate(180deg); }
.cph-unused > .cph-lede { padding-top: var(--space-1); }
.cph-gallery-name { margin: 0; font-size: var(--text-sm); font-weight: var(--fw-semibold); color: var(--text-strong); }   /* as a group's heading */
@media (hover: hover) and (pointer: fine) { .cph-gallery summary:hover svg { color: var(--text-strong); } }
@media (prefers-reduced-motion: reduce) { .cph-gallery summary svg, .cph-tile.is-busy .cph-img img, .cph-tip { transition: none; } }

/* a link in a line of words (the list that can take the photos no page shows; a list's Open in CMS) */
.cph-avail-link {
  display: inline; padding: 0; border: 0; border-radius: var(--radius-xs); background: none;
  font: inherit; color: var(--text-strong); text-decoration: underline; text-decoration-color: var(--border-strong);
  text-underline-offset: 2px; cursor: pointer;
}
@media (hover: hover) and (pointer: fine) { .cph-avail-link:hover { text-decoration-color: currentColor; } }

/* the photos they've added: the drop zone a slim row, not a tall box (the library's own note goes while it's empty) */
.cph--added .sb-drop { min-height: 0; justify-content: flex-start; padding: var(--space-2-5) var(--space-3); text-align: left; border-radius: var(--radius-lg); }
.cph--added .sb-drop-inner { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: var(--space-3); row-gap: 0; justify-items: start; }
.cph--added .sb-drop-ico { grid-row: span 2; width: var(--control-sm); height: var(--control-sm); margin: 0; }
.cph--added .sb-drop-ico .ic svg { width: 16px; height: 16px; }
.cph--added .sd-photos:has(.sb-thumbs:empty) .sd-note { display: none; }

/* Replace: one of their library photos, a picture that came with the website, or a new upload */
.cph-choose { display: flex; flex-direction: column; gap: var(--space-3); }
.cph-choose-seg { align-self: flex-start; max-width: 100%; overflow-x: auto; }
.cph-choose-grid[hidden] { display: none; }
.cph-choose-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: var(--space-2); max-height: 50vh; overflow-y: auto; padding: 2px; }
.cph-choose-opt { display: block; aspect-ratio: 4 / 3; padding: 0; border: 0; border-radius: var(--radius-md); overflow: hidden; background: var(--surface-sunk); cursor: pointer; box-shadow: inset 0 0 0 1px var(--border-faint); }
.cph-choose-opt img { display: block; width: 100%; height: 100%; object-fit: cover; }
@media (hover: hover) and (pointer: fine) { .cph-choose-opt:hover { box-shadow: 0 0 0 1px var(--text-strong); } }

@media (max-width: 640px) {
  .cph-grid:not(.cph-grid--sm) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4) var(--space-3); }
  .cph-grid--sm { --cph-gap: var(--space-2); }
}
