/* ========================================
   Sacha Belma — Street Photography
   iOS Photos-inspired layout
   ======================================== */

:root {
  --bg: #ffffff;
  --bg-secondary: #f2f2f7;
  --text: #000000;
  --text-secondary: rgba(0, 0, 0, 0.45);
  --accent: #007aff;
  --gap: 2px;
  --header-height: 56px;
  --transition-speed: 0.4s;
  --radius: 0;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body {
  min-height: 100dvh;
  background: var(--bg);
  overscroll-behavior: none;
}

/* ---- Header ---- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  height: var(--header-height);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.08);
}

.header-title h1 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
  line-height: 1.2;
}

.header-subtitle {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.view-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}

.view-toggle:hover {
  background: rgba(0, 0, 0, 0.12);
}

.view-toggle:active {
  transform: scale(0.92);
}

/* Show grid icon in single view, single icon in grid view */
.icon-single { display: none; }
.icon-grid { display: block; }

body.grid-view .icon-single { display: block; }
body.grid-view .icon-grid { display: none; }


/* ---- Gallery ---- */
.gallery {
  padding: 0;
  transition: padding var(--transition-speed) cubic-bezier(0.25, 1, 0.5, 1);
}

/* Single photo view (default) */
.gallery .photo-item {
  display: block;
  width: 100%;
  margin-bottom: 2px;
  position: relative;
  overflow: hidden;
  opacity: 1;
  transform: scale(1);
  transition:
    opacity var(--transition-speed) cubic-bezier(0.25, 1, 0.5, 1),
    transform var(--transition-speed) cubic-bezier(0.25, 1, 0.5, 1),
    margin var(--transition-speed) cubic-bezier(0.25, 1, 0.5, 1),
    border-radius var(--transition-speed) cubic-bezier(0.25, 1, 0.5, 1);
}

.gallery .photo-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  transition: transform var(--transition-speed) cubic-bezier(0.25, 1, 0.5, 1);
}

/* Lazy loading fade in */
.gallery .photo-item.loading img {
  opacity: 0;
}

.gallery .photo-item.loaded img {
  opacity: 1;
  transition: opacity 0.4s ease;
}

/* ---- Grid View ---- */
body.grid-view .gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap);
  padding: var(--gap);
}

body.grid-view .gallery .photo-item {
  aspect-ratio: 1;
  margin-bottom: 0;
  border-radius: 0;
  cursor: pointer;
}

body.grid-view .gallery .photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Animate the switch */
body.transitioning .gallery .photo-item {
  transition:
    all var(--transition-speed) cubic-bezier(0.25, 1, 0.5, 1);
}


/* ---- Pinch Hint ---- */
.pinch-hint {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.pinch-hint.visible {
  opacity: 1;
}

.pinch-hint.hiding {
  opacity: 0;
}

.pinch-hint-content {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.06);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(0, 0, 0, 0.6);
  white-space: nowrap;
}

.pinch-hint-content svg {
  stroke: rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
}


/* ---- Fullscreen Overlay ---- */
.fullscreen-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.fullscreen-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.fullscreen-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 510;
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  color: #000;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.fullscreen-close:hover {
  background: rgba(255, 255, 255, 0.9);
}

.fullscreen-image-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.fullscreen-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 2px;
}

.fullscreen-counter {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}


/* ---- Loading placeholder ---- */
.photo-item .placeholder {
  position: absolute;
  inset: 0;
  background: var(--bg-secondary);
  z-index: 1;
  transition: opacity 0.4s ease;
}

.photo-item.loaded .placeholder {
  opacity: 0;
  pointer-events: none;
}


/* ---- Scrollbar (desktop) ---- */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}


/* ---- Desktop/Laptop: always grid, no toggle ---- */
@media (min-width: 768px) {
  .header {
    padding: 14px 24px;
    height: 60px;
  }

  .header-title h1 {
    font-size: 19px;
  }

  .view-toggle {
    display: none;
  }

  .pinch-hint {
    display: none;
  }

  /* Force grid view on desktop regardless of body class */
  .gallery {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 3px !important;
    padding: 3px !important;
    max-width: 1200px;
    margin: 0 auto;
  }

  .gallery .photo-item {
    aspect-ratio: 1 !important;
    margin-bottom: 0 !important;
    border-radius: 0 !important;
    cursor: pointer !important;
  }

  .gallery .photo-item img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
  }
}

@media (min-width: 1200px) {
  .gallery {
    max-width: 1400px;
    gap: 4px !important;
    padding: 4px !important;
  }
}

/* ---- No photos state ---- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  color: var(--text-secondary);
  text-align: center;
  padding: 40px 20px;
}

.empty-state svg {
  margin-bottom: 16px;
  stroke: rgba(0, 0, 0, 0.15);
}

.empty-state p {
  font-size: 15px;
  font-weight: 400;
  line-height: 1.5;
}

.empty-state .hint {
  font-size: 12px;
  margin-top: 8px;
  color: rgba(0, 0, 0, 0.25);
}
