/*
 * Digital Merch — Theme System
 * CSS-переменные для трёх пресетов: light, dark, glass
 * Вдохновлено thema1 (dark), thema2 (glass), thema3 (light)
 */

/* ─── Reset & Base ───────────────────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  transition: background 0.4s ease, color 0.4s ease;
}

/* ─── Theme Variables (defaults = dark) ──────────────────────────────── */

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --text: #f0f0f0;
  --muted: #888888;
  --accent: #6366f1;
  --shadow: 0 4px 24px rgba(0,0,0,0.6);
  --radius: 16px;
  --radius-sm: 8px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Profile Container ─────────────────────────────────────────────── */

.profile-page {
  min-height: 100vh;
  padding: 24px 16px 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.profile-container {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ─── Card Component ─────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  transition: transform var(--transition), box-shadow var(--transition);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.card:hover::before {
  opacity: 1;
}

/* Glass card variant */
.card-glass {
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.card-glass:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
}

/* ─── Avatar ─────────────────────────────────────────────────────────── */

.avatar-container {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}

.avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--accent);
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
  transition: transform var(--transition), box-shadow var(--transition);
}

.avatar:hover {
  transform: scale(1.05);
  box-shadow: 0 0 30px rgba(99, 102, 241, 0.5);
}

/* ─── Typography ─────────────────────────────────────────────────────── */

.profile-name {
  font-size: 1.75rem;
  font-weight: 700;
  text-align: center;
  color: var(--text);
  letter-spacing: -0.02em;
}

.profile-subtitle {
  font-size: 0.95rem;
  color: var(--muted);
  text-align: center;
  margin-top: 4px;
}

.section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 12px;
}

/* ─── Link Buttons ───────────────────────────────────────────────────── */

.link-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: all var(--transition);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.link-btn::after {
  content: '→';
  opacity: 0;
  transform: translateX(-8px);
  transition: all var(--transition);
  position: absolute;
  right: 16px;
}

.link-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
}

.link-btn:hover::after {
  opacity: 1;
  transform: translateX(0);
}

/* ─── Photo Gallery ──────────────────────────────────────────────────── */

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}

.gallery-item {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--transition);
}

.gallery-item:hover {
  transform: scale(1.03);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition);
}

.gallery-item:hover img {
  transform: scale(1.1);
}

/* Single photo — full width */
.gallery-single {
  grid-template-columns: 1fr;
}

.gallery-single .gallery-item {
  aspect-ratio: 16/10;
}

/* ─── Embed Block ────────────────────────────────────────────────────── */

.embed-container {
  border-radius: var(--radius);
  overflow: hidden;
  background: rgba(0, 0, 0, 0.2);
}

.embed-container iframe {
  display: block;
  border: none;
}

/* ─── Spacer Block ───────────────────────────────────────────────────── */

.spacer {
  height: 24px;
}

.spacer-lg {
  height: 48px;
}

/* ─── Reactions (Guestbook) ──────────────────────────────────────────── */

.reactions-bar {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.reaction-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 50px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}

.reaction-btn:hover {
  transform: scale(1.1);
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--accent);
}

.reaction-btn:active {
  transform: scale(0.95);
}

.reaction-btn .count {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}

/* ─── Animate on appear ──────────────────────────────────────────────── */

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-in {
  animation: fadeInUp 0.5s ease forwards;
  opacity: 0;
}

.animate-in:nth-child(1) { animation-delay: 0.05s; }
.animate-in:nth-child(2) { animation-delay: 0.1s; }
.animate-in:nth-child(3) { animation-delay: 0.15s; }
.animate-in:nth-child(4) { animation-delay: 0.2s; }
.animate-in:nth-child(5) { animation-delay: 0.25s; }
.animate-in:nth-child(6) { animation-delay: 0.3s; }
.animate-in:nth-child(7) { animation-delay: 0.35s; }
.animate-in:nth-child(8) { animation-delay: 0.4s; }

/* ─── Pulse glow for accent ──────────────────────────────────────────── */

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 8px rgba(99, 102, 241, 0.3); }
  50% { box-shadow: 0 0 20px rgba(99, 102, 241, 0.6); }
}

.glow {
  animation: pulse-glow 2s ease-in-out infinite;
}

/* ─── Edit Dashboard ─────────────────────────────────────────────────── */

.edit-page {
  min-height: 100vh;
  background: #0a0a0a;
  color: #f0f0f0;
  padding: 0;
}

.edit-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 24px 16px 120px;
}

.edit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  margin-bottom: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.edit-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
}

.edit-section {
  background: #141414;
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.edit-section h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: #f0f0f0;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── Form Elements ──────────────────────────────────────────────────── */

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #888;
  margin-bottom: 6px;
  font-weight: 600;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #f0f0f0;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color var(--transition), background var(--transition);
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.08);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: #555;
}

/* Color picker */
.color-picker-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.color-picker {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  padding: 0;
  background: none;
}

.color-picker::-webkit-color-swatch {
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.15);
}

.color-preview {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ─── Buttons ────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: #f0f0f0;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.8rem;
}

/* ─── Theme Selector ─────────────────────────────────────────────────── */

.theme-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.theme-option {
  padding: 16px 12px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
  text-align: center;
  transition: all var(--transition);
  background: rgba(255, 255, 255, 0.02);
}

.theme-option:hover {
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
}

.theme-option.active {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.1);
}

.theme-option .preview {
  width: 100%;
  height: 40px;
  border-radius: 8px;
  margin-bottom: 8px;
}

.theme-option .name {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ─── Photo Upload ───────────────────────────────────────────────────── */

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.photo-thumb {
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-thumb .delete-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.85);
  color: #fff;
  border: none;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition);
}

.photo-thumb:hover .delete-btn {
  opacity: 1;
}

.upload-zone {
  border: 2px dashed rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--muted);
}

.upload-zone:hover {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.05);
  color: var(--accent);
}

/* ─── Stats ──────────────────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.stat-card {
  text-align: center;
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-top: 4px;
}

/* ─── Block Editor ───────────────────────────────────────────────────── */

.block-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.block-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.block-item .drag-handle {
  cursor: grab;
  color: var(--muted);
  font-size: 1.2rem;
}

.block-item .block-content {
  flex: 1;
  min-width: 0;
}

.block-type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent);
}

/* ─── Link Editor ────────────────────────────────────────────────────── */

.link-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  margin-bottom: 8px;
}

.link-item input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
}

/* ─── Toast notification ─────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 24px;
  border-radius: 12px;
  background: #1e1e1e;
  color: #f0f0f0;
  font-size: 0.9rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  z-index: 1000;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
  border: 1px solid rgba(255,255,255,0.1);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success {
  border-left: 3px solid #22c55e;
}

.toast.error {
  border-left: 3px solid #ef4444;
}

/* ─── Auth Pages ─────────────────────────────────────────────────────── */

.auth-page {
  min-height: 100vh;
  background: #0a0a0a;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: #141414;
  border-radius: 20px;
  padding: 40px 32px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.auth-card h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #f0f0f0;
  margin-bottom: 8px;
  text-align: center;
}

.auth-card .subtitle {
  font-size: 0.9rem;
  color: #888;
  text-align: center;
  margin-bottom: 32px;
}

.auth-card .logo {
  font-size: 2rem;
  text-align: center;
  margin-bottom: 24px;
}

/* ─── Responsive ─────────────────────────────────────────────────────── */

@media (min-width: 768px) {
  .profile-container {
    max-width: 520px;
  }

  .edit-container {
    padding: 40px 24px 120px;
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .theme-options {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .theme-option {
    padding: 12px 8px;
  }
}

/* ─── Avatar (Public) ──────────────────────────────────────────────── */

.avatar-container {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--accent);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.avatar:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.4);
}

/* ─── Avatar (Edit Page) ───────────────────────────────────────────── */

.edit-avatar-wrapper {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--accent);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
}

.edit-avatar-wrapper:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 28px color-mix(in srgb, var(--accent) 30%, transparent);
}

.edit-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.edit-avatar-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

/* ─── Avatar Picker Thumbnails ─────────────────────────────────────── */

.avatar-pick-thumb {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.25s ease;
  position: relative;
  flex-shrink: 0;
}

.avatar-pick-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-pick-thumb:hover {
  border-color: var(--accent);
  transform: scale(1.1);
}

.avatar-pick-active {
  border-color: var(--accent);
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 40%, transparent);
}

.avatar-pick-check {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 1.2rem;
  font-weight: 700;
}

/* ─── Lightbox (shared) ────────────────────────────────────────────── */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 16px;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
}
