/* 84_photos.css - the Photos area in a machine record and the large photo view (84_photos.js).
   Tokens only (01_tokens.css, and the 3D view's --kp3d-bg). Buttons are the app's .tool-btn; the large view reuses the
   Higher resolution close-up's dialog and top bar (83_hires.css: .hr-view, .hr-bar, .hr-back) and the 3D view's square
   buttons (.kp3d-nb), so it reads as the same app in light and dark. */

.ph { margin: var(--sp-5) 0; }
.ph[hidden], .ph [hidden] { display: none !important; }
.ph.is-drop { outline: 2px dashed var(--brand); outline-offset: 8px; border-radius: var(--r-sm); }

.ph-note { display: flex; align-items: flex-start; gap: 6px; margin: 0 0 var(--sp-3); font-size: 14px; line-height: 1.45; color: var(--ink-soft); text-wrap: pretty; }
.ph-note-i { flex: none; display: inline-flex; margin-top: 2px; }
.ph-note-i svg, .ph-state svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---- thumbnails: square, as many as fit; collapsed to two full rows by the script. Nothing sits on top of a photo:
   the line above the grid says in words where the photos are kept ---- */
.ph-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: var(--sp-2); list-style: none; margin: 0 0 var(--sp-3); padding: 0; }
.ph-grid li { min-width: 0; }
.ph-thumb { position: relative; display: block; box-sizing: border-box; width: 100%; aspect-ratio: 1 / 1; padding: 0; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-alt); color: var(--ink); font: inherit; overflow: hidden; cursor: pointer; }
.ph-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ph-thumb:hover { border-color: var(--brand); }
.ph-thumb:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.ph-more { display: grid; place-items: center; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--navy); }
[data-theme="dark"] .ph-more { color: var(--ink); }
.ph-less { display: block; width: 100%; margin: 0 0 var(--sp-3); }

/* ---- shrinking: what is happening, how far, and a way out ---- */
.ph-work { margin: 0 0 var(--sp-3); padding: var(--sp-3); border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-alt); }
.ph-work-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.ph-work-t { margin: 0; min-width: 0; font-size: 15px; font-weight: 600; line-height: 1.35; color: var(--ink); font-variant-numeric: tabular-nums; }
.ph-stop { flex: none; }
.ph-prog { height: 6px; margin-top: var(--sp-3); border-radius: 3px; background: var(--line); overflow: hidden; }
.ph-bar { width: 0; height: 100%; border-radius: 3px; background: var(--brand-solid); }
@media (prefers-reduced-motion: no-preference) { .ph-bar { transition: width var(--dur) var(--ease); } }

/* ---- done, and what went wrong ---- */
.ph-done, .ph-err { display: flex; align-items: flex-start; gap: var(--sp-2); margin: 0 0 var(--sp-3); padding: 10px var(--sp-3); border-radius: var(--r-sm); font-size: 15px; line-height: 1.4; }
.ph-done { background: var(--success-bg); color: var(--success-fg); font-weight: 600; font-variant-numeric: tabular-nums; }
.ph-done svg, .ph-err-i svg { flex: none; width: 20px; height: 20px; margin-top: 1px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.ph-nb { white-space: nowrap; } /* the size of the saved photo stays together: in a narrow record it moves to its own line whole */
/* the colour carries the signal (the card, the sign, the heading); the words to read are in the app's ink */
.ph-err { background: var(--danger-bg); color: var(--danger-fg); }
.ph-err.is-info { background: var(--info-bg); color: var(--info); }
.ph-err-i { flex: none; display: inline-flex; }
.ph-err-text { flex: 1 1 auto; min-width: 0; }
.ph-err-t { margin: 0; font-weight: 700; }
.ph-err-m { margin: 2px 0 0; color: var(--ink); text-wrap: pretty; }
.ph-err-l { margin: 4px 0 0; padding-left: 18px; color: var(--ink); overflow-wrap: anywhere; }
.ph-err-ok { margin-top: var(--sp-3); min-width: 88px; }

/* ---- add: one button with a mouse, two side by side on a touch screen ---- */
.ph-actions { display: grid; grid-template-columns: 1fr; gap: var(--sp-2); }
.ph-actions.is-two { grid-template-columns: 1fr 1fr; }
.ph-btn { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; min-height: 48px; padding: 0 10px; font-size: 15px; font-weight: 600; color: var(--navy); }
[data-theme="dark"] .ph-btn { color: var(--ink); }
.ph-btn svg { flex: none; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ph-hint { margin: var(--sp-2) 0 0; font-size: 13px; line-height: 1.45; color: var(--ink-soft); text-wrap: pretty; }

/* ---- one photo, large. The previous and next buttons never sit on the photo: on a wide screen they stand in their
   own columns beside it, on a phone they are a row of two worded buttons under it ---- */
.ph-mid { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: minmax(0, 1fr); align-items: center; background: var(--kp3d-bg); }
.ph-stage { grid-column: 2; grid-row: 1; align-self: stretch; min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center; box-sizing: border-box; padding: var(--sp-3); overflow: hidden; background: var(--kp3d-bg); touch-action: pan-y; }
.ph-big { display: block; min-width: 0; min-height: 0; max-width: 100%; max-height: 100%; object-fit: contain; border-radius: var(--r-sm); background: var(--surface); box-shadow: var(--shadow); -webkit-user-select: none; user-select: none; }
.ph-miss { margin: 0; padding: var(--sp-4); border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font-weight: 600; }
.ph-nav { grid-row: 1; flex: none; margin: 0; font: inherit; font-size: 15px; font-weight: 600; }
.ph-nav span { display: none; }
.ph-prev { grid-column: 1; margin-left: max(var(--sp-3), env(safe-area-inset-left)); }
.ph-next { grid-column: 3; margin-right: max(var(--sp-3), env(safe-area-inset-right)); }
.ph-nav[aria-disabled="true"] { opacity: .35; cursor: default; }
.ph-foot { flex: none; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-3); box-sizing: border-box; padding: var(--sp-3) max(var(--sp-4), env(safe-area-inset-right)) max(var(--sp-3), env(safe-area-inset-bottom)) max(var(--sp-4), env(safe-area-inset-left)); border-top: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.ph-foot-text { flex: 1 1 240px; min-width: 0; }
.ph-facts { display: flex; flex-wrap: wrap; gap: 2px var(--sp-4); margin: 0; font-size: 15px; font-weight: 600; line-height: 1.4; font-variant-numeric: tabular-nums; }
.ph-state { display: flex; align-items: center; gap: 6px; margin: 4px 0 0; font-size: 14px; line-height: 1.4; color: var(--ink-soft); }
.ph-state svg { flex: none; }
.ph-ask { margin: var(--sp-2) 0 0; font-size: 15px; font-weight: 600; line-height: 1.4; color: var(--ink); text-wrap: pretty; }
.ph-foot-b { flex: none; display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.ph-foot-b .tool-btn { min-width: 96px; min-height: 48px; font-weight: 600; }
.ph-danger, .ph-danger:hover, .ph-danger:active { background: var(--danger-solid); border-color: var(--danger-solid); color: var(--on-brand); }
/* dark: --on-brand turns to dark ink there, which is only 3.9:1 on the red. The light ink reads at 4.6:1 */
[data-theme="dark"] .ph-danger, [data-theme="dark"] .ph-danger:hover, [data-theme="dark"] .ph-danger:active { color: var(--ink-deep); }

@media screen and (max-width: 560px) {
  .ph-mid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; column-gap: var(--sp-2); background: var(--surface); }
  .ph-stage { grid-column: 1 / -1; border-bottom: 1px solid var(--line); }
  .ph-nav { grid-row: 2; width: auto; gap: 6px; margin: var(--sp-3) 0 0; box-shadow: none; }
  .ph-nav span { display: inline; }
  .ph-prev { grid-column: 1; margin-left: max(var(--sp-4), env(safe-area-inset-left)); }
  .ph-next { grid-column: 2; margin-right: max(var(--sp-4), env(safe-area-inset-right)); }
  .ph-foot { border-top: 0; }
  .ph-foot-b { flex: 1 1 100%; }
  .ph-foot-b .tool-btn { flex: 1 1 0; }
}
@media print { .ph-actions, .ph-hint, .ph-work, .ph-done, .ph-err, .ph-less, .ph-view { display: none !important; } }
