/* ── Custom Properties ──────────────────────────────── */
:root {
  --bg: #ffffff;
  --text: #1a1a1a;
  --text-secondary: #666666;
  --accent: #ff3b5c;
  --grid-gap: 2px;
  --header-height: 72px;
  --bar-height: 56px;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* ── Reset ─────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overscroll-behavior: none;
  touch-action: manipulation;
}

button {
  font: inherit;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

input {
  font: inherit;
  border: none;
  background: none;
  color: inherit;
  outline: none;
}

.hidden {
  display: none !important;
}

/* ── Password Gate ─────────────────────────────────── */
.gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
  background: #ffffff;
}

.gate-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  width: 100%;
  max-width: 300px;
}

.gate-logo {
  width: 220px;
  height: auto;
}

.gate-input {
  width: 100%;
  padding: 14px 16px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 10px;
  font-size: 16px;
  color: #1a1a1a;
  text-align: center;
  transition: background 0.2s var(--ease);
}

.gate-input::placeholder {
  color: rgba(0, 0, 0, 0.35);
}

.gate-input:focus {
  background: rgba(0, 0, 0, 0.08);
}

.gate-input.shake {
  animation: shake 0.4s var(--ease);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

.gate-button {
  width: 100%;
  padding: 14px;
  background: #1a1a1a;
  color: #ffffff;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  transition: opacity 0.2s var(--ease);
}

.gate-button:active {
  opacity: 0.8;
}

.gate-error {
  font-size: 14px;
  color: #e53e3e;
  min-height: 20px;
}

/* ── Gallery ───────────────────────────────────────── */
.gallery {
  min-height: 100dvh;
  padding-bottom: calc(var(--bar-height) + env(safe-area-inset-bottom, 0px) + 8px);
}

/* ── Header ────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.8) 70%, transparent 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0 16px;
  padding-top: env(safe-area-inset-top, 0px);
  transition: transform 0.3s var(--ease);
}

.header.header-hidden {
  transform: translateY(-100%);
}

.header-logo {
  width: 40px;
  height: auto;
  flex-shrink: 0;
  margin-right: 12px;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
}

.header-text {
  min-width: 0;
}

.header-band {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-shoot {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-btn {
  flex-shrink: 0;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  border-radius: 8px;
  transition: background 0.2s var(--ease);
}

.header-btn:active {
  background: rgba(255, 59, 92, 0.1);
}

/* ── Photo Grid ────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--grid-gap);
  padding-top: var(--grid-gap);
}

@media (orientation: landscape) and (max-width: 767px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 768px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 768px) and (orientation: landscape) {
  .grid { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 1200px) {
  .grid { grid-template-columns: repeat(5, 1fr); }
}

/* ── Photo Cell ────────────────────────────────────── */
.photo-cell {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: #f0f0f0;
}

.photo-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}

.photo-cell img.loaded {
  opacity: 1;
}

/* Heart overlay */
.photo-heart {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.photo-heart::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(0,0,0,0.5) 0%, transparent 70%);
  pointer-events: none;
}

.photo-heart svg {
  width: 20px;
  height: 20px;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
  transition: transform 0.2s var(--ease);
}

.photo-heart:active svg {
  transform: scale(0.85);
}

.photo-heart .icon-heart-filled {
  display: none;
}

.photo-cell.favorited .photo-heart .icon-heart-outline {
  display: none;
}

.photo-cell.favorited .photo-heart .icon-heart-filled {
  display: block;
}

/* Select mode checkbox */
.photo-check {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.9);
  background: rgba(0,0,0,0.25);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}

.photo-check svg {
  width: 16px;
  height: 16px;
  opacity: 0;
  transition: opacity 0.15s var(--ease);
}

.select-mode .photo-check {
  display: flex;
}

.photo-cell.selected .photo-check {
  background: var(--accent);
  border-color: var(--accent);
}

.photo-cell.selected .photo-check svg {
  opacity: 1;
}

/* Dim unselected in picks view */
.grid.picks-view .photo-cell:not(.favorited) {
  display: none;
}

/* ── Bottom Bar ────────────────────────────────────── */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  transform: translateY(100%);
  transition: transform 0.3s var(--ease);
}

.bottom-bar.visible {
  transform: translateY(0);
}

.bottom-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--bar-height);
  padding: 0 16px;
}

.bar-left {
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bar-btn {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  transition: background 0.2s var(--ease), opacity 0.2s var(--ease);
}

.bar-btn-primary {
  background: #1a1a1a;
  color: #ffffff;
}

.bar-btn-primary:active {
  opacity: 0.8;
}

.bar-btn-secondary {
  color: var(--text-secondary);
}

.bar-btn-secondary:active {
  background: rgba(0, 0, 0, 0.06);
}

.bar-btn-accent {
  background: var(--accent);
  color: #ffffff;
}

.bar-btn-accent:active {
  opacity: 0.8;
}

/* ── Lightbox ──────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.97);
}

.lightbox-controls-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  z-index: 10;
  background: linear-gradient(to bottom, rgba(255,255,255,0.9), transparent);
}

.lightbox-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lightbox-counter {
  font-size: 14px;
  color: #666666;
  font-variant-numeric: tabular-nums;
}

.lightbox-top-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.lightbox-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1a1a1a;
  border-radius: 50%;
  transition: background 0.2s var(--ease);
}

.lightbox-btn:active {
  background: rgba(0, 0, 0, 0.06);
}

.lightbox-btn-label {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  color: #1a1a1a;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  transition: background 0.2s var(--ease);
}

.lightbox-btn-label:active {
  background: rgba(0, 0, 0, 0.06);
}

.lightbox-btn .icon-heart-filled {
  display: none;
}

.lightbox-btn.favorited .icon-heart-outline {
  display: none;
}

.lightbox-btn.favorited .icon-heart-filled {
  display: block;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.lightbox-prev-btn {
  left: 8px;
}

.lightbox-next-btn {
  right: 8px;
}

.lightbox-nav:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #1a1a1a;
}

/* Hide nav arrows on mobile — swipe instead */
@media (max-width: 767px) {
  .lightbox-nav { display: none; }
}

.lightbox-img-wrap {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  padding: 16px;
}

.lightbox-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.1s linear;
}

/* ── Download Modal ────────────────────────────────── */
.download-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.download-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.download-modal-content {
  position: relative;
  width: 100%;
  max-width: 500px;
  max-height: 70dvh;
  background: #ffffff;
  border-radius: 16px 16px 0 0;
  padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
}

.download-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.download-modal-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.download-modal-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.download-modal-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 10px;
}

.download-modal-item span {
  font-size: 14px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}

.download-modal-item a {
  flex-shrink: 0;
  margin-left: 12px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--accent);
  border-radius: 8px;
  text-decoration: none;
  transition: opacity 0.2s var(--ease);
}

.download-modal-item a:active {
  opacity: 0.8;
}

/* ── Loading spinner ───────────────────────────────── */
.loading-spinner {
  display: flex;
  justify-content: center;
  padding: 40px;
}

.loading-spinner::after {
  content: '';
  width: 24px;
  height: 24px;
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Not found page ────────────────────────────────── */
.not-found {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  gap: 8px;
  padding: 24px;
}

.not-found h1 {
  font-size: 18px;
  font-weight: 600;
}

.not-found p {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ── Heart pop animation (double-tap / swipe-down) ─── */
.lightbox-heart-pop {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  z-index: 20;
  pointer-events: none;
  opacity: 0;
}

.lightbox-heart-pop.animate {
  animation: heart-pop 0.8s ease forwards;
}

@keyframes heart-pop {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 0.8; }
  15% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
  30% { transform: translate(-50%, -50%) scale(1.0); opacity: 1; }
  70% { transform: translate(-50%, -50%) scale(1.0); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.0); opacity: 0; }
}

/* ── Pull-down indicator ──────────────────────────── */
.lightbox-pull-indicator {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) scale(0.5);
  z-index: 20;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.lightbox-pull-indicator.active {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* ── Lightbox hint ────────────────────────────────── */
.lightbox-hint {
  position: absolute;
  top: calc(56px + env(safe-area-inset-top, 0px));
  left: 0;
  right: 0;
  text-align: center;
  z-index: 10;
  font-size: 13px;
  color: rgba(0, 0, 0, 0.4);
  pointer-events: none;
  transition: opacity 1s ease;
}

.lightbox-hint.fade-out {
  opacity: 0;
}

/* ── Lightbox bottom bar ──────────────────────────── */
.lightbox-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 14px 20px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, rgba(255,255,255,0.9), transparent);
  pointer-events: none;
}

.lightbox-bar-count {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a1a;
}

.lightbox-download-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--accent);
  color: #ffffff;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  pointer-events: auto;
  transition: opacity 0.2s var(--ease);
}

.lightbox-download-all:active {
  opacity: 0.8;
}

/* ── Smooth swipe transition on the img wrap ──────── */
.lightbox-img-wrap.animating {
  transition: transform 0.3s ease;
}
