/* events/css/photos.css
   Photo surfaces: inline gallery viewer, lightbox, photo finder, My Photos.
   Load after events.css. Consumes tokens.css. No backdrop-filter here (iOS + Chrome paint bugs). */

/* ========== INLINE GALLERY VIEWER (.mac-gallery) ========== */
.mac-gallery { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); overflow: hidden; }
.mac-gallery-stage { position: relative; background: var(--color-bg); overflow: hidden; touch-action: pan-y; }
.gallery-blur-bg { position: absolute; inset: -40px; background-size: cover; background-position: center; filter: blur(30px) brightness(0.55); opacity: 0; transition: opacity var(--dur); pointer-events: none; }
.gallery-blur-bg.visible { opacity: 1; }
.mac-gallery-featured {
  position: relative; display: flex; align-items: center; justify-content: center;
  min-height: 240px; max-height: min(72vh, 720px); aspect-ratio: 3 / 2; cursor: zoom-in;
  background: var(--ph, none) center / cover no-repeat;
}
.mac-gallery-featured img { max-width: 100%; max-height: min(72vh, 720px); width: auto; height: auto; object-fit: contain; display: block; user-select: none; -webkit-user-drag: none; opacity: 0; transition: opacity 320ms var(--ease-out); }
.mac-gallery-featured img.is-loaded { opacity: 1; }
.mac-gallery-featured iframe { width: 100%; aspect-ratio: 16 / 9; height: auto; max-height: min(72vh, 720px); border: 0; }
.mac-gallery-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 3;
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--color-border-strong);
  background: rgba(10, 9, 8, 0.72); color: var(--color-text); display: inline-flex; align-items: center; justify-content: center;
  transition: background var(--dur-fast), transform var(--dur-fast);
}
.mac-gallery-nav:hover { background: rgba(10, 9, 8, 0.9); }
.mac-gallery-nav:active { transform: translateY(-50%) scale(0.95); }
.mac-gallery-nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.mac-gallery-nav.prev { left: 12px; } .mac-gallery-nav.next { right: 12px; }
.mac-gallery-counter { position: absolute; bottom: 12px; right: 12px; z-index: 3; padding: 4px 10px; border-radius: var(--radius-pill); background: rgba(10, 9, 8, 0.72); color: var(--color-text); font-size: var(--text-xs); font-weight: 700; font-variant-numeric: tabular-nums; }
.mac-gallery-strip-wrap { border-top: 1px solid var(--color-border); background: var(--color-surface); }
.mac-gallery-strip { display: flex; gap: 6px; overflow-x: auto; padding: 10px var(--space-4); scroll-snap-type: x proximity; scrollbar-width: thin; scrollbar-color: var(--color-border-strong) transparent; -webkit-overflow-scrolling: touch; }
.mac-gallery-thumb { flex: 0 0 auto; height: 72px; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; padding: 0; border: 2px solid transparent; background: var(--color-surface-2); cursor: pointer; scroll-snap-align: center; position: relative; opacity: 0.6; transition: opacity var(--dur-fast), border-color var(--dur-fast); }
.mac-gallery-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mac-gallery-thumb:hover { opacity: 0.9; }
.mac-gallery-thumb.active, .mac-gallery-thumb[aria-current="true"] { opacity: 1; border-color: var(--brand-orange); }
.mac-gallery-thumb .thumb-play { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,0.35); }
.mac-gallery-thumb .thumb-play svg { width: 20px; height: 20px; fill: #fff; }
@media (min-width: 768px) { .mac-gallery-thumb { height: 88px; } .mac-gallery-strip { padding: 12px var(--space-5); } }

/* ========== LIGHTBOX (<dialog class="lb">) ========== */
.lb { --lb-bar: 56px; --lb-thumbs: 0px;
  position: fixed; inset: 0; width: 100vw; width: 100dvw; height: 100vh; height: 100dvh; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; background: rgba(6, 5, 4, 0.96); color: var(--color-text);
  display: none; grid-template-rows: var(--lb-bar) 1fr var(--lb-thumbs); overflow: hidden;
}
.lb[open] { display: grid; }
.lb::backdrop { background: rgba(6, 5, 4, 0.85); }
.lb__bar { display: flex; align-items: center; justify-content: space-between; padding: env(safe-area-inset-top, 0px) var(--space-3) 0 var(--space-4); }
.lb__counter { font-size: var(--text-sm); font-weight: 700; color: var(--color-text-muted); }
.lb__btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--color-border-strong); background: rgba(250, 246, 241, 0.06); color: var(--color-text); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.lb__btn:hover { background: rgba(250, 246, 241, 0.14); }
.lb__btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.lb__stage { position: relative; display: grid; grid-template-columns: 1fr; align-items: center; justify-items: center; min-height: 0; overflow: hidden; }
.lb__figure { margin: 0; width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 0; }
.lb__media { position: relative; display: flex; align-items: center; justify-content: center; width: 100%; flex: 1 1 auto; min-height: 0; }
.lb__media::before { content: ''; position: absolute; inset: 0; background: var(--ph, none) center / contain no-repeat; filter: blur(18px); opacity: 0.8; transition: opacity 300ms; pointer-events: none; }
.lb__media.is-loaded::before { opacity: 0; }
.lb__media img { position: relative; max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; display: block; user-select: none; -webkit-user-drag: none; will-change: transform; }
.lb__media iframe { width: min(100%, 1100px); aspect-ratio: 16 / 9; border: 0; }
.lb__media.is-error::after { content: 'This photo could not be loaded.'; position: absolute; color: var(--color-text-muted); }
.lb__caption { margin: var(--space-2) var(--space-4) 0; color: var(--color-text-muted); font-size: var(--text-sm); text-align: center; max-width: 60ch; }
.lb__caption[hidden] { display: none; }
.lb__nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; display: none; }
.lb__prev { left: var(--space-3); } .lb__next { right: var(--space-3); }
.lb__thumbs { display: none; gap: 6px; overflow-x: auto; padding: 8px var(--space-4) calc(8px + env(safe-area-inset-bottom, 0px)); scrollbar-width: none; }
.lb__thumbs::-webkit-scrollbar { display: none; }
.lb__thumb { flex: 0 0 auto; width: 64px; height: 64px; padding: 0; border: 2px solid transparent; border-radius: var(--radius-sm); overflow: hidden; background: var(--color-surface-2); opacity: 0.55; cursor: pointer; transition: opacity var(--dur-fast), border-color var(--dur-fast); }
.lb__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lb__thumb[aria-current="true"] { opacity: 1; border-color: var(--brand-orange); }
.lb--zoomed .lb__nav, .lb--zoomed .lb__thumbs { visibility: hidden; }
@media (min-width: 768px) {
  .lb { --lb-thumbs: 88px; }
  .lb__nav { display: inline-flex; }
  .lb__thumbs { display: flex; }
  .lb__stage { padding: 0 var(--space-9); }
}
@media (prefers-reduced-motion: reduce) { .lb__media img, .lb__media::before, .mac-gallery-featured img { transition: none !important; } }

/* ========== PHOTO FINDER (shared: hub card + event panel) ========== */
.fmp-hub-section { padding: var(--space-5) 0 var(--space-7); }
.pf-card { position: relative; display: grid; gap: var(--space-5); padding: var(--space-5); border-radius: var(--radius-lg); background: var(--color-surface); border: 1px solid var(--color-border); overflow: hidden; }
.pf-card::before { content: ''; position: absolute; inset: -40% auto auto -20%; width: 60%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, rgba(255, 92, 0, 0.18), transparent 65%); pointer-events: none; }
.pf-card > * { position: relative; min-width: 0; }
.pf-head { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: var(--space-4); align-items: center; }
.pf-head > div { min-width: 0; }
.pf-avatar { width: 72px; height: 72px; border-radius: 50%; overflow: hidden; background: var(--color-surface-2); border: 2px solid var(--color-border-strong); display: grid; place-items: center; color: var(--color-text-muted); position: relative; }
.pf-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pf-avatar svg { width: 40px; height: 40px; }
.pf-card[data-state="scanning"] .pf-avatar::after { content: ''; position: absolute; inset: -2px; border-radius: 50%; border: 2px solid transparent; border-top-color: var(--brand-orange); animation: pf-spin 1s linear infinite; }
@keyframes pf-spin { to { transform: rotate(360deg); } }
.pf-title { margin: 0 0 4px; font-family: var(--font-display); font-size: var(--text-h3); font-weight: 800; text-transform: uppercase; line-height: 1.1; }
.pf-sub { margin: 0; color: var(--color-text-muted); font-size: var(--text-sm); text-wrap: pretty; }
.pf-actions { display: grid; grid-template-columns: 1fr; gap: var(--space-3); }
.pf-actions .btn { width: 100%; white-space: normal; }
@media (min-width: 480px) { .pf-actions { grid-template-columns: 1fr 1fr; } }
.pf-status { min-height: 1.4em; font-size: var(--text-sm); color: var(--color-text-muted); }
.pf-status[data-tone="error"] { color: var(--color-error); }
.pf-status[data-tone="ok"] { color: var(--color-success); }
.pf-card[data-state="scanning"] .pf-actions { opacity: 0.5; pointer-events: none; }
.pf-drop { outline: 2px dashed var(--brand-orange); outline-offset: -6px; }
.pf-privacy { font-size: var(--text-xs); color: var(--color-text-faint); margin: 0; }

/* Results */
.pf-results { display: grid; gap: var(--space-6); margin-top: var(--space-6); }
.pf-results[hidden] { display: none; }
.pf-result-head h3 { font-family: var(--font-display); font-size: var(--text-h2); text-transform: uppercase; margin: 0 0 4px; color: var(--brand-orange); }
.pf-result-head p { margin: 0; color: var(--color-text-muted); }
.pf-group { display: grid; gap: var(--space-3); }
.pf-group-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); }
.pf-group-head h4 { margin: 0; font-size: var(--text-lg); }
.pf-group-head span { color: var(--color-text-muted); font-size: var(--text-sm); white-space: nowrap; }
.pf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; }
.pf-thumb { position: relative; padding: 0; border: 0; border-radius: var(--radius-sm); overflow: hidden; aspect-ratio: 1; background: var(--ph, var(--color-surface-2)) center / cover; cursor: zoom-in; animation: pf-rise 360ms var(--ease-out) both; animation-delay: calc(min(var(--i, 0), 7) * 60ms); }
.pf-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform var(--dur) var(--ease-out); }
.pf-thumb:hover img { transform: scale(1.04); }
@keyframes pf-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.pf-empty { display: grid; gap: var(--space-3); padding: var(--space-5); border-radius: var(--radius-md); background: var(--color-surface-2); border: 1px solid var(--color-border); }
.pf-empty p { margin: 0; }
.pf-empty .cluster { margin-top: var(--space-2); }
.pf-save { display: grid; gap: var(--space-3); padding: var(--space-5); border-radius: var(--radius-md); background: var(--color-surface-2); border: 1px solid var(--color-border); }
.pf-save h4 { margin: 0; } .pf-save p { margin: 0; color: var(--color-text-muted); font-size: var(--text-sm); }
.pf-save-form { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.pf-save-form input { flex: 1 1 220px; min-height: 48px; padding: 0 var(--space-4); border-radius: var(--radius-pill); border: 1px solid var(--color-border-strong); background: var(--color-bg); color: var(--color-text); }
.pf-save-form input:focus-visible { outline: 2px solid var(--brand-mint); outline-offset: 2px; }
.pf-save[data-done="true"] { border-color: rgba(95, 252, 192, 0.4); }
@media (min-width: 768px) {
  .pf-card { grid-template-columns: 1fr auto; align-items: center; padding: var(--space-6); }
  .pf-head { grid-template-columns: 112px minmax(0, 1fr); }
  .pf-avatar { width: 112px; height: 112px; }
  .pf-actions { grid-template-columns: auto auto; }
  .pf-status, .pf-privacy, .pf-results { grid-column: 1 / -1; }
  .pf-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
}
/* Event-page variant: lives under the gallery header */
.pf-panel { margin: 0 0 var(--space-6); }
.pf-panel[hidden] { display: none; }
.pf-toggle .badge { margin-left: 6px; }

/* ========== MY PHOTOS PAGE ========== */
.my-photos-hero { padding: var(--space-6) 0 var(--space-5); }
.my-photos-hero h1 { margin: var(--space-3) 0 var(--space-1); }
.my-photos-hero .muted { margin: 0 0 var(--space-4); }
.my-photos-grid { padding-bottom: var(--space-10); }
.my-photos-event { padding: var(--space-4); margin-bottom: var(--space-5); }
.my-photos-event-header { display: flex; align-items: center; gap: var(--space-3); color: inherit; text-decoration: none; margin-bottom: var(--space-3); }
.my-photos-event-header .event-thumb { width: 56px; height: 56px; border-radius: var(--radius-sm); background-size: cover; background-position: 50% 15%; flex: none; background-color: var(--color-surface-2); }
.my-photos-event-header h3 { margin: 0; font-size: var(--text-lg); }
.my-photos-event-header p { margin: 0; color: var(--color-text-muted); font-size: var(--text-xs); }
.my-photos-event-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; }
.my-photo-item { aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; padding: 0; border: 0; background: var(--color-surface-2); cursor: zoom-in; }
.my-photo-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.my-photos-empty { padding: var(--space-6); text-align: center; }
@media (min-width: 768px) { .my-photos-event-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; } }

/* ========== STICKY REGISTER BAR: never leaks on past events ========== */
.sticky-bar { visibility: hidden; pointer-events: none; }
.sticky-bar.visible { visibility: visible; pointer-events: auto; }

/* ========== GALLERY HEADER: wraps cleanly on phones ========== */
.gallery-header { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); margin-bottom: var(--space-5); }
.gallery-header .section-label { margin-bottom: 0; }
.gallery-header .gallery-count { color: var(--color-text-muted); font-size: var(--text-sm); white-space: nowrap; }
.gallery-header .pf-toggle { margin-left: auto; }
@media (max-width: 479px) { .gallery-header .pf-toggle { margin-left: 0; width: 100%; justify-content: center; } }
