/* ============================================================
   HBD Library — Simple Clean Theme
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg:      #111111;
  --surface: #1c1c1c;
  --border:  #2e2e2e;
  --text:    #ffffff;
  --muted:   #888888;
  --font:    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
}

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ============================================================
   AUTH SCREEN
   ============================================================ */

#auth-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 2rem 1.5rem 3rem;
  gap: 1.5rem;
  transition: opacity 0.4s ease;
}

#auth-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

/* ---- Camera ---- */
#video {
  width: min(70vw, 280px);
  height: min(70vw, 280px);
  border-radius: 50%;
  object-fit: cover;
  display: block;
  background: var(--surface);
}

/* ---- Hint text ---- */
#hint {
  font-size: 1.3rem;
  font-weight: 500;
  text-align: center;
  letter-spacing: -0.01em;
  color: var(--text);
  min-height: 2rem;
}

/* ---- Fingerprint / Verify button ---- */
.btn {
  background: #ffffff;
  color: #111111;
  border: none;
  border-radius: 100px;
  padding: 0.8rem 2.2rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font);
  letter-spacing: -0.01em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.btn:active {
  transform: scale(0.95);
  opacity: 0.85;
}

/* ============================================================
   GALLERY SCREEN
   ============================================================ */

#gallery-screen {
  width: 100%;
  min-height: 100dvh;
  opacity: 0;
  transition: opacity 0.5s ease;
}

#gallery-screen.visible {
  opacity: 1;
}

.gallery-header {
  text-align: center;
  padding: 3.5rem 1rem 1.5rem;
}

.gallery-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.gallery-header p {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 0.3rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Gallery loading state */
#gallery-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 4rem 1rem;
  color: var(--muted);
  font-size: 0.88rem;
}

#gallery-loading.hidden {
  display: none;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 2.5px solid #2a2a2a;
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

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

#gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
}

#gallery a {
  position: relative;
  display: block;
  aspect-ratio: 1;
  overflow: hidden;
  /* shimmer skeleton while image loads */
  background: var(--surface);
  background-image: linear-gradient(
    90deg,
    var(--surface) 0%,
    #2a2a2a 40%,
    var(--surface) 80%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s ease infinite;
}

/* stop shimmer once any child image has loaded */
#gallery a.loaded {
  background-image: none;
  animation: none;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

#gallery img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.35s ease, transform 0.2s ease;
}

#gallery img.loaded {
  opacity: 1;
}

#gallery a:hover img.loaded {
  transform: scale(1.06);
}

/* Video elements */
#gallery video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.35s ease, transform 0.2s ease;
}

#gallery video.loaded {
  opacity: 1;
}

#gallery a:hover video.loaded {
  transform: scale(1.06);
}

/* Video play icon overlay */
.video-play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0.9;
  transition: opacity 0.2s ease, transform 0.2s ease;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.5));
}

#gallery a:hover .video-play-icon {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.1);
}

#gallery a {
  position: relative;
}

.gallery-error,
.gallery-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* ============================================================
   REGISTER PAGE
   ============================================================ */

.register-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 2rem 1.5rem 4rem;
  gap: 1.25rem;
  max-width: 400px;
  margin: 0 auto;
  text-align: center;
}

.register-page h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.register-page p {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

/* Code input */
.code-input {
  width: 100%;
  max-width: 280px;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 1.1rem;
  font-family: 'Courier New', Courier, monospace;
  text-align: center;
  letter-spacing: 0.12em;
  outline: none;
  transition: border-color 0.2s;
}

.code-input::placeholder {
  color: #444;
  letter-spacing: 0.1em;
}

.code-input:focus {
  border-color: #555;
}

/* Register section (shown after correct code) */
#reg-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
}

/* Status text */
.register-status {
  font-size: 0.85rem;
  min-height: 1.2rem;
  color: var(--muted);
  transition: color 0.2s;
}
.register-status.error   { color: #ff6b6b; }
.register-status.success { color: #69f0ae; }

/* Success card */
.success-card {
  width: 100%;
  max-width: 300px;
  background: var(--surface);
  border: 1px solid #2e4a38;
  border-radius: 16px;
  padding: 1.5rem 1.25rem;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  text-align: center;
}
.success-card.visible { display: flex; }

.success-card h3 {
  color: #69f0ae;
  font-size: 1rem;
  font-weight: 600;
}

.success-card p {
  color: var(--muted);
  font-size: 0.82rem;
}

.redirect-countdown {
  font-size: 0.82rem;
  color: #888;
  margin-top: 0.25rem;
}

/* ============================================================
   UTILITIES
   ============================================================ */

.hidden {
  display: none !important;
}

/* ============================================================
   PHOTOSWIPE VIDEO SUPPORT
   ============================================================ */

.pswp__video-container {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.pswp__video-container video {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 380px) {
  #video {
    width: 76vw;
    height: 76vw;
  }
  #hint {
    font-size: 1.1rem;
  }
  #gallery {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 600px) {
  #video {
    width: 300px;
    height: 300px;
  }
  #gallery {
    max-width: 960px;
    margin: 0 auto;
    grid-template-columns: repeat(4, 1fr);
    padding: 0 1rem 3rem;
    gap: 3px;
  }
}
