/* Functional baseline — visual design pass comes later. */

* { box-sizing: border-box; }

/* Keep the hidden attribute authoritative over any display rule below. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #fafafa;
  color: #1a1a1a;
}

body.no-scroll { overflow: hidden; }

/* ---------------------------------------------------------------- login */

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
}

.login form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(300px, 80vw);
  text-align: center;
}

.login h1 { font-size: 1.1rem; font-weight: 500; letter-spacing: .08em; }

.login input,
.login button {
  font: inherit;
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid #ddd;
}

.login button {
  background: #1a1a1a;
  color: #fff;
  border-color: #1a1a1a;
  cursor: pointer;
}

.login-error { color: #b3261e; font-size: .85rem; min-height: 1.2em; margin: 0; }

/* ----------------------------------------------------------------- grid */

.gallery-header { padding: 24px 16px 8px; }
.gallery-header h1 { font-size: 1rem; font-weight: 500; letter-spacing: .08em; margin: 0; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 4px;
  padding: 16px;
}

@media (max-width: 600px) {
  .grid { grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 8px; }
}

.cell {
  padding: 0;
  border: 0;
  background: #eee;
  aspect-ratio: 1;
  overflow: hidden;
  cursor: pointer;
}

.cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity .3s ease;
}

.cell.ready img { opacity: 1; }

/* ------------------------------------------------------------- lightbox */

.lightbox {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 10;
}

.lightbox-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}

.lb-track {
  position: absolute;
  inset: 0;
  will-change: transform;
}

.lb-slide {
  position: absolute;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.lb-zoomer {
  width: 100%;
  height: 100%;
  position: relative;
  will-change: transform;
}

.lb-blur,
.lb-medium {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-select: none;
}

.lb-blur {
  filter: blur(24px);
  transform: scale(1.05);
  transition: opacity .3s ease;
}

.lb-medium {
  opacity: 0;
  transition: opacity .3s ease;
}

.lb-slide.loaded .lb-medium { opacity: 1; }
.lb-slide.loaded .lb-blur { opacity: 0; }

/* Lightbox chrome */

.lb-btn {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .35);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  text-decoration: none;
  transition: background .2s ease;
}

.lb-btn:hover { background: rgba(0, 0, 0, .6); }
.lb-btn:disabled { opacity: .3; cursor: default; }

.lb-close { top: max(12px, env(safe-area-inset-top)); right: 12px; }
.lb-download { top: max(12px, env(safe-area-inset-top)); left: 12px; }

.lb-nav {
  top: 50%;
  transform: translateY(-50%);
  font-size: 28px;
}
.lb-prev { left: 12px; }
.lb-next { right: 12px; }

/* Arrows are redundant on touch screens — swiping is the gesture. */
@media (pointer: coarse) {
  .lb-nav { display: none; }
}

.lb-counter {
  position: absolute;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, .75);
  font-size: .8rem;
  letter-spacing: .05em;
  z-index: 2;
}
