/* Rewind Web App — layout & components */

/* --- Typography --- */
.display-font {
  font-family: 'Anybody', system-ui, sans-serif;
  font-stretch: semi-condensed;
}
.mono {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'JetBrains Mono', ui-monospace, monospace;
}

/* --- App shell --- */
.app-shell {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 var(--lg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Header --- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--lg) 0;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--xl);
}
.app-header .wordmark {
  font-family: 'Anybody', system-ui, sans-serif;
  font-stretch: semi-condensed;
  font-weight: 800;
  font-size: 24px;
  color: var(--amber);
  letter-spacing: -0.5px;
}
.app-header .user-menu {
  display: flex;
  align-items: center;
  gap: var(--sm);
}
.app-header .user-email {
  color: var(--text-secondary);
  font-size: 13px;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sm);
  padding: var(--sm) var(--lg);
  border-radius: var(--pill-radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s ease-out, border-color 0.15s ease-out;
}
.btn-primary {
  background: var(--blue);
  color: #fff;
}
.btn-primary:hover { background: var(--blue-light); }
.btn-secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text-primary);
}
.btn-secondary:hover {
  border-color: var(--blue);
  background: rgba(59, 143, 202, 0.08);
}
.btn-danger {
  background: transparent;
  color: var(--no-red);
  border-color: rgba(214, 80, 96, 0.3);
}
.btn-danger:hover {
  background: rgba(214, 80, 96, 0.1);
}
.btn-sm { padding: var(--xs) var(--md); font-size: 13px; }
.btn-google {
  background: #fff;
  color: #333;
  font-weight: 500;
  padding: var(--md) var(--xl);
  font-size: 15px;
  border-radius: var(--pill-radius);
}
.btn-google:hover { background: #f0f0f0; }
.btn-google img {
  width: 20px;
  height: 20px;
}

/* --- Cards --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: var(--lg);
}
.card-hover:hover {
  border-color: var(--blue);
  background: var(--surface-light);
  cursor: pointer;
}

/* --- Form controls --- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--xs);
  margin-bottom: var(--lg);
}
.form-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}
.form-input, .form-select, .form-textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--pill-radius);
  padding: var(--md) var(--lg);
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  transition: border-color 0.15s ease-out;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--blue);
  outline: none;
}
.form-input::placeholder { color: var(--text-tertiary); }
.form-textarea {
  resize: vertical;
  min-height: 80px;
}
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23908DA9'%3E%3Cpath d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* --- Badge --- */
.badge {
  display: inline-flex;
  align-items: center;
  font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--badge-radius);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-owned {
  color: var(--mint);
  border: 1px solid rgba(64, 168, 104, 0.4);
  background: rgba(64, 168, 104, 0.12);
}
.badge-wanted {
  color: var(--amber);
  border: 1px solid rgba(212, 160, 64, 0.4);
  background: rgba(212, 160, 64, 0.12);
}
.badge-grail {
  color: var(--hot-pink);
  border: 1px solid rgba(204, 68, 136, 0.4);
  background: rgba(204, 68, 136, 0.12);
}

/* --- Search bar --- */
.search-bar {
  position: relative;
  margin-bottom: var(--lg);
}
.search-bar input {
  width: 100%;
  padding: var(--md) var(--lg) var(--md) 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--capsule);
  color: var(--text-primary);
  font-size: 14px;
}
.search-bar input:focus {
  border-color: var(--blue);
  outline: none;
}
.search-bar input::placeholder { color: var(--text-tertiary); }
.search-bar .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  font-size: 16px;
  pointer-events: none;
}

/* --- Filter tabs --- */
.filter-tabs {
  display: flex;
  gap: var(--sm);
  margin-bottom: var(--xl);
}
.filter-tab {
  padding: var(--sm) var(--lg);
  border-radius: var(--capsule);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  transition: all 0.15s ease-out;
}
.filter-tab:hover {
  border-color: var(--blue);
  color: var(--text-primary);
}
.filter-tab.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

/* --- Collection list --- */
.collection-list {
  display: flex;
  flex-direction: column;
  gap: var(--md);
  flex: 1;
}
.collection-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--md) var(--lg);
  gap: var(--md);
}
.collection-item .item-info {
  flex: 1;
  min-width: 0;
}
.collection-item .item-title {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.collection-item .item-meta {
  display: flex;
  gap: var(--sm);
  align-items: center;
  color: var(--text-tertiary);
  font-size: 13px;
  margin-top: 2px;
}

/* --- Empty state --- */
.empty-state {
  text-align: center;
  padding: var(--xxxl) var(--xl);
  color: var(--text-secondary);
}
.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: var(--lg);
  opacity: 0.4;
}
.empty-state h3 {
  font-size: 18px;
  margin-bottom: var(--sm);
  color: var(--text-primary);
}

/* --- Login page --- */
.login-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  text-align: center;
  gap: var(--xxl);
}
.login-page .logo {
  font-family: 'Anybody', system-ui, sans-serif;
  font-stretch: semi-condensed;
  font-weight: 800;
  font-size: 48px;
  color: var(--amber);
}
.login-page .tagline {
  color: var(--text-secondary);
  font-size: 16px;
  margin-top: calc(-1 * var(--xl));
}
.login-methods {
  display: flex;
  flex-direction: column;
  gap: var(--lg);
  width: 100%;
  max-width: 320px;
}
.login-divider {
  display: flex;
  align-items: center;
  gap: var(--lg);
  color: var(--text-tertiary);
  font-size: 13px;
}
.login-divider::before, .login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.magic-link-form {
  display: flex;
  flex-direction: column;
  gap: var(--md);
}

/* --- Detail page --- */
.detail-header {
  display: flex;
  align-items: center;
  gap: var(--md);
  margin-bottom: var(--xl);
}
.detail-header .back-btn {
  background: none;
  border: none;
  color: var(--blue);
  font-size: 20px;
  cursor: pointer;
  padding: var(--xs);
}
.detail-header h2 {
  font-family: 'Anybody', system-ui, sans-serif;
  font-stretch: semi-condensed;
  font-weight: 800;
  font-size: 22px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.detail-actions {
  display: flex;
  gap: var(--md);
  margin-top: var(--xl);
}
.detail-field {
  padding: var(--md) 0;
  border-bottom: 1px solid var(--border-subtle);
}
.detail-field .field-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
  margin-bottom: 2px;
}
.detail-field .field-value {
  font-size: 15px;
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: var(--xl);
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--pill-radius);
  padding: var(--md) var(--xl);
  font-size: 14px;
  z-index: 10000;
  opacity: 0;
  transition: transform 0.25s ease-out, opacity 0.25s ease-out;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.toast.error { border-color: rgba(214, 80, 96, 0.4); color: var(--no-red); }
.toast.success { border-color: rgba(64, 168, 104, 0.4); color: var(--mint); }

/* --- Loading spinner --- */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center {
  display: flex;
  justify-content: center;
  padding: var(--xxxl);
}

/* --- Confirm dialog --- */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
}
.dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: var(--xl);
  max-width: 360px;
  width: 90%;
  text-align: center;
}
.dialog h3 { margin-bottom: var(--md); }
.dialog p { color: var(--text-secondary); margin-bottom: var(--xl); font-size: 14px; }
.dialog-actions {
  display: flex;
  gap: var(--md);
  justify-content: center;
}

/* --- Title search (combobox) --- */
.title-search-group {
  position: relative;
}
.title-input-wrap {
  position: relative;
}
.title-input-wrap .form-input {
  padding-left: 38px;
}
.title-input-wrap.has-match .form-input {
  padding-right: 80px;
}
.title-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  font-size: 15px;
  pointer-events: none;
}
.title-match-badge {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--mint);
  border: 1px solid rgba(64, 168, 104, 0.4);
  background: rgba(64, 168, 104, 0.12);
  padding: 2px 6px;
  border-radius: var(--badge-radius);
  pointer-events: none;
}
.title-search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  max-height: 320px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--pill-radius);
  margin-top: var(--xs);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.title-search-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--md) var(--lg);
  cursor: pointer;
  transition: background 0.1s ease-out;
}
.title-search-item:hover,
.title-search-item.active {
  background: var(--surface-light);
}
.title-search-name {
  font-size: 14px;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.title-search-year {
  font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
  font-size: 12px;
  color: var(--text-tertiary);
  margin-left: var(--md);
  flex-shrink: 0;
}
.title-search-loading,
.title-search-empty {
  padding: var(--lg);
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sm);
}

/* --- Responsive --- */
@media (max-width: 480px) {
  .app-shell { padding: 0 var(--md); }
  .filter-tabs { overflow-x: auto; flex-wrap: nowrap; }
  .filter-tab { white-space: nowrap; }
}
