/* =========================================
   DROP PHOTOS — style.css
   Collaborative album UI. Same DNA as usedrop.live.
   Two screens: Home + Album.
   ========================================= */

/* =========================================
   DESIGN TOKENS
   ========================================= */
:root {
  --accent:        #F25C30;
  --accent-hover:  #FF7A54;
  --accent-glow:   rgba(242, 92, 48, 0.12);
  --success:       #22C583;
  --success-glow:  rgba(34, 197, 131, 0.10);
  --error:         #F4425F;
  --radius:        10px;
  --radius-lg:     14px;
  --font:          'Outfit', system-ui, sans-serif;
  --mono:          'JetBrains Mono', ui-monospace, monospace;
  --ease:          cubic-bezier(.4, 0, .2, 1);
  --container:     640px;

  /* Dark (default) */
  --bg:            #0A0A0E;
  --bg-elevated:   #131318;
  --bg-hover:      #1A1A22;
  --text:          #F1F0EE;
  --text-dim:      #65656E;
  --border:        #222230;
  --border-focus:  #38384A;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:            #FAFAF9;
    --bg-elevated:   #FFFFFF;
    --bg-hover:      #F0EFED;
    --text:          #1A1A1E;
    --text-dim:      #7A7A82;
    --border:        #E0E0E4;
    --border-focus:  #C8C8D0;
    --accent-glow:   rgba(242, 92, 48, 0.08);
    --success-glow:  rgba(34, 197, 131, 0.08);
  }
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

input, button, select { font-family: inherit; }
button { cursor: pointer; border: none; background: none; color: inherit; }

/* =========================================
   LAYOUT
   ========================================= */
#app {
  width: 100%;
  max-width: var(--container);
  padding: 0 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.home-screen,
.album-screen {
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* =========================================
   BRAND (home screen heading)
   ========================================= */
.brand {
  text-align: center;
  padding-top: 64px;
  padding-bottom: 32px;
  cursor: default;
}

.brand-name {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 3.2rem;
  letter-spacing: 0.22em;
  color: var(--text);
  line-height: 1;
}

.brand-sub {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.92rem;
  letter-spacing: 0.4em;
  color: var(--accent);
  margin-top: 4px;
}

.brand-tagline {
  margin-top: 14px;
  font-weight: 300;
  font-size: 1.05rem;
  color: var(--text-dim);
  letter-spacing: 0.01em;
}

/* =========================================
   HOME ACTION (create album button)
   ========================================= */
.home-action {
  width: 100%;
  max-width: 340px;
}

/* =========================================
   HOME DIVIDER
   ========================================= */
.home-divider {
  width: 100%;
  max-width: 340px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 28px 0;
  color: var(--text-dim);
  font-size: 0.82rem;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.home-divider::before,
.home-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* =========================================
   CODE INPUT (join album)
   ========================================= */
.code-input-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 340px;
}

.code-input-pair {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.code-word-input {
  width: 140px;
  max-width: 40%;
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 600;
  text-align: center;
  color: var(--text);
  background: var(--accent-glow);
  border: 2px solid rgba(242, 92, 48, 0.3);
  border-radius: var(--radius);
  padding: 14px 10px;
  outline: none;
  caret-color: var(--accent);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), background 0.2s var(--ease);
}

.code-word-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: var(--bg-hover);
}

.code-word-input::placeholder {
  font-weight: 400;
  font-size: 0.88rem;
  color: var(--text-dim);
  opacity: 0.5;
}

.code-pair-dash {
  font-family: var(--mono);
  font-size: 1.5rem;
  color: var(--text-dim);
  flex-shrink: 0;
}

.code-input-or {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 2px;
}

.code-numeric-input {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  width: 140px;
  outline: none;
  caret-color: var(--accent);
  transition: border-color 0.2s var(--ease);
}

.code-numeric-input:focus {
  border-color: var(--accent);
}

.code-numeric-input::placeholder {
  font-weight: 400;
  color: var(--text-dim);
  opacity: 0.5;
}

.code-input-hint {
  font-size: 0.78rem;
  color: var(--text-dim);
  min-height: 1.2em;
  text-align: center;
}

.code-input-hint.error {
  color: var(--error);
}

/* =========================================
   ALBUM CREATED (shown after POST /collect)
   ========================================= */
.album-created {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  animation: slideUp 0.4s var(--ease) forwards;
}

.created-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.word-code-display {
  font-family: var(--mono);
  font-size: 2.6rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.04em;
  text-align: center;
  line-height: 1.1;
  opacity: 0;
  transform: translateY(16px) scale(0.9);
  animation: wordReveal 0.5s var(--ease) 0.1s forwards;
}

.word-code-dash {
  color: var(--text-dim);
  margin: 0 4px;
}

.numeric-code-fallback {
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--text-dim);
  letter-spacing: 0.15em;
  opacity: 0;
  animation: fadeIn 0.4s var(--ease) 0.5s forwards;
}

.created-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.created-expiry {
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* =========================================
   SUCCESS RING
   ========================================= */
.success-ring {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--success-glow);
  border: 2px solid var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: scaleIn 0.4s var(--ease) forwards;
}

.success-check {
  font-size: 1.6rem;
  color: var(--success);
  line-height: 1;
}

/* =========================================
   NAV BAR (album screen)
   ========================================= */
.nav-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 20px 0 12px;
}

.nav-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--text-dim);
  flex-shrink: 0;
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
}

.nav-back:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.nav-title {
  font-family: var(--mono);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
  flex: 1;
  text-align: center;
  padding-right: 36px; /* balance the back button */
}

/* =========================================
   ALBUM STATS
   ========================================= */
.album-share {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
}

.album-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 20px;
}

.stat-dot {
  opacity: 0.5;
}

/* =========================================
   GALLERY GRID
   ========================================= */
.gallery-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  min-height: 0;
}

.gallery-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.gallery-item:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

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

.gallery-item img.loading {
  opacity: 0.3;
}

/* Overlay on hover */
.gallery-item-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.65) 0%, transparent 50%);
  opacity: 0;
  transition: opacity 0.2s var(--ease);
  display: flex;
  align-items: flex-end;
  padding: 10px;
}

.gallery-item:hover .gallery-item-overlay {
  opacity: 1;
}

.gallery-item-info {
  flex: 1;
  min-width: 0;
}

.gallery-item-name {
  font-size: 0.68rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gallery-item-size {
  font-size: 0.6rem;
  font-family: var(--mono);
  color: rgba(255,255,255,0.7);
}

.gallery-item-dl {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  transition: background 0.2s var(--ease);
}

.gallery-item-dl:hover {
  background: var(--accent);
}

/* Video badge */
.gallery-video-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 0.58rem;
  font-family: var(--mono);
  padding: 2px 6px;
  border-radius: 4px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* Placeholder for files without thumbnails */
.gallery-item-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
}

/* =========================================
   GALLERY EMPTY STATE
   ========================================= */
.gallery-empty {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 48px 0 24px;
  text-align: center;
}

.empty-icon {
  color: var(--accent);
  opacity: 0.5;
}

.empty-title {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text);
}

.empty-sub {
  font-size: 0.88rem;
  color: var(--text-dim);
}

/* =========================================
   ALBUM ACTIONS (add photos + download all)
   ========================================= */
.album-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
  max-width: 360px;
  align-self: center;
}

/* =========================================
   UPLOAD PROGRESS
   ========================================= */
.upload-progress {
  width: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  max-width: 360px;
  align-self: center;
}

.upload-status {
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--text);
}

/* =========================================
   DOWNLOAD PROGRESS
   ========================================= */
.download-progress {
  width: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  max-width: 360px;
  align-self: center;
}

.download-status {
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--text);
}

/* =========================================
   PROGRESS BAR (shared)
   ========================================= */
.progress-track {
  width: 100%;
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.35s var(--ease);
  box-shadow: 0 0 14px var(--accent-glow);
}

.progress-label {
  font-size: 0.82rem;
  color: var(--text-dim);
  font-family: var(--mono);
}

/* =========================================
   REFRESH INDICATOR
   ========================================= */
.refresh-indicator {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-align: center;
  margin-top: 20px;
  padding-bottom: 12px;
  opacity: 0.6;
}

/* =========================================
   LIGHTBOX (full-screen photo viewer)
   ========================================= */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 20px;
  gap: 16px;
}

.lightbox.active {
  display: flex;
  animation: fadeIn 0.25s var(--ease) forwards;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s var(--ease);
  z-index: 1;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.lightbox-content {
  max-width: 90vw;
  max-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-content img,
.lightbox-content video {
  max-width: 90vw;
  max-height: 70vh;
  object-fit: contain;
  border-radius: var(--radius);
}

.lightbox-meta {
  text-align: center;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.6);
  font-family: var(--mono);
}

.lightbox-dl {
  transition: background 0.2s var(--ease);
}

.lightbox-dl:hover {
  background: var(--accent-hover);
}

/* =========================================
   BUTTONS
   ========================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 500;
  font-size: 0.88rem;
  padding: 10px 22px;
  border-radius: 100px;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), box-shadow 0.2s var(--ease), opacity 0.2s var(--ease);
  position: relative;
  overflow: hidden;
}

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

.btn-accent:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 20px var(--accent-glow);
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border-focus);
  background: var(--bg-hover);
}

.btn-sm {
  font-size: 0.78rem;
  padding: 7px 16px;
}

.btn-full {
  width: 100%;
  padding: 14px;
  font-size: 0.95rem;
  justify-content: center;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Copy button text swap */
.btn .btn-done { display: none; }
.btn.copied .btn-text { display: none; }
.btn.copied .btn-done { display: inline; }

/* =========================================
   TOAST
   ========================================= */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 10px 24px;
  font-size: 0.85rem;
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
  z-index: 300;
  max-width: 90vw;
  text-align: center;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.toast.error {
  border-color: var(--error);
}

/* =========================================
   FOOTER
   ========================================= */
.site-footer {
  width: 100%;
  text-align: center;
  padding: 32px 24px 24px;
  font-size: 0.72rem;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

.footer-brand {
  margin-top: 6px;
}

.footer-brand a {
  color: var(--accent);
  text-decoration: none;
}

.footer-brand a:hover {
  text-decoration: underline;
}

/* =========================================
   ANIMATIONS
   ========================================= */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes wordReveal {
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.5); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes galleryItemIn {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}

/* =========================================
   STATE VISIBILITY
   Screen toggling via #app class.
   ========================================= */

/* Default: album screen hidden */
.album-screen   { display: none; }
.album-created  { display: none; }

/* Home state */
.state-home .home-screen  { display: flex; }
.state-home .album-screen { display: none; }

/* Created state: show created result on home, hide create/join */
.state-created .home-screen        { display: flex; }
.state-created .album-screen       { display: none; }
.state-created .home-action        { display: none; }
.state-created .home-divider       { display: none; }
.state-created .code-input-wrap    { display: none; }
.state-created .album-created      { display: flex; }
.state-created .brand              { padding-top: 48px; padding-bottom: 20px; }

/* Album state */
.state-album .home-screen      { display: none; }
.state-album .album-screen     { display: flex; }

/* Within album: empty vs populated */
.state-album .gallery-empty     { display: none; }
.state-album.is-empty .gallery-empty  { display: flex; }
.state-album.is-empty .gallery-grid   { display: none; }
.state-album.is-empty .album-stats    { display: none; }
.state-album.is-empty #downloadAllBtn { display: none; }

/* Upload progress visible */
.state-album .upload-progress   { display: none; }
.state-album.is-uploading .upload-progress { display: flex; }
.state-album.is-uploading #addPhotosBtn   { display: none; }

/* Download progress visible */
.state-album .download-progress   { display: none; }
.state-album.is-downloading .download-progress { display: flex; }
.state-album.is-downloading #downloadAllBtn    { display: none; }

/* Loading state while fetching album */
.state-loading .home-screen  { display: none; }
.state-loading .album-screen { display: flex; }

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

/* Tablets and small desktops */
@media (max-width: 640px) {
  .gallery-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
}

/* Phones */
@media (max-width: 480px) {
  .brand-name { font-size: 2.4rem; }
  .brand { padding-top: 48px; padding-bottom: 24px; }
  .word-code-display { font-size: 2rem; }

  .gallery-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
  }

  .gallery-item {
    border-radius: 6px;
  }

  .nav-title {
    font-size: 0.95rem;
  }
}

/* Very small phones */
@media (max-width: 360px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
  }

  .brand-name { font-size: 2rem; }
  .word-code-display { font-size: 1.6rem; }
}
