/* ─────────────────────────────────────────────────────────────────────────────
   style.css — DownX · Dark Glassmorphism Design System
   ───────────────────────────────────────────────────────────────────────────── */

/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Brand palette */
  --clr-primary:      #818cf8;   /* indigo-400   */
  --clr-primary-deep: #6366f1;   /* indigo-500   */
  --clr-accent:       #c084fc;   /* purple-400   */
  --clr-pink:         #f472b6;   /* pink-400     */
  --clr-success:      #34d399;   /* emerald-400  */
  --clr-danger:       #f87171;   /* red-400      */

  /* Surfaces */
  --surface-0:  #050507;
  --surface-1:  #0d0d14;
  --surface-2:  #121220;
  --surface-3:  #1a1a2e;
  --glass-bg:   rgba(255,255,255,0.04);
  --glass-bd:   rgba(255,255,255,0.08);
  --glass-hover:rgba(255,255,255,0.07);

  /* Text */
  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #475569;

  /* Sizing */
  --radius-sm:  8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;

  /* Transitions */
  --ease-spring: cubic-bezier(.34,1.56,.64,1);
  --ease-out: cubic-bezier(.22,1,.36,1);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--surface-0);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Animated blobs ── */
.bg-blobs {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.18;
  animation: drift 20s ease-in-out infinite alternate;
}

.blob-1 {
  width: 700px; height: 700px;
  background: radial-gradient(circle, #6366f1, transparent 70%);
  top: -200px; left: -200px;
  animation-duration: 22s;
}

.blob-2 {
  width: 600px; height: 600px;
  background: radial-gradient(circle, #c084fc, transparent 70%);
  bottom: -100px; right: -100px;
  animation-duration: 18s;
  animation-delay: -8s;
}

.blob-3 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, #f472b6, transparent 70%);
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  animation-duration: 25s;
  animation-delay: -12s;
  opacity: 0.10;
}

@keyframes drift {
  0%   { transform: translate(0, 0) scale(1); }
  33%  { transform: translate(60px, -40px) scale(1.05); }
  66%  { transform: translate(-30px, 60px) scale(0.97); }
  100% { transform: translate(40px, 30px) scale(1.02); }
}

.blob-3 { animation-name: drift3; }
@keyframes drift3 {
  0%   { transform: translate(-50%,-50%) scale(1); }
  50%  { transform: translate(-50%,-50%) scale(1.15); }
  100% { transform: translate(-50%,-50%) scale(0.95); }
}

/* ── Noise overlay ── */
.noise {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  opacity: 0.4;
}

/* ── Layout ── */
.layout {
  position: relative;
  z-index: 2;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  max-width: 760px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

/* ── Header ── */
.header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 52px 0 40px;
  text-align: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px; height: 48px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-bd);
  border-radius: var(--radius-md);
  backdrop-filter: blur(20px);
  box-shadow: 0 0 32px rgba(99,102,241,0.2);
}

.logo-text {
  font-size: 2.25rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #e0e7ff 30%, var(--clr-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-x {
  background: linear-gradient(135deg, var(--clr-primary), var(--clr-pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-tagline {
  font-size: 0.9rem;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

/* ── Main ── */
.main {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding-bottom: 32px;
}

/* ── Cards ── */
.card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-bd);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(32px) saturate(160%);
  -webkit-backdrop-filter: blur(32px) saturate(160%);
  overflow: hidden;
  transition: box-shadow 0.4s var(--ease-out), border-color 0.3s;
}

.card:hover {
  box-shadow: 0 8px 48px rgba(99,102,241,0.12);
  border-color: rgba(255,255,255,0.12);
}

.card-inner {
  padding: 36px 36px 28px;
}

.card-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.card-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.card-subtitle code {
  background: rgba(255,255,255,0.08);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8em;
  color: var(--clr-primary);
}

/* ── URL Form ── */
.url-form { display: flex; flex-direction: column; gap: 14px; }

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 16px;
  color: var(--text-muted);
  display: flex;
  pointer-events: none;
  transition: color 0.2s;
}

.url-input {
  width: 100%;
  padding: 16px 105px 16px 48px;
  background: rgba(255,255,255,0.05);
  border: 1.5px solid rgba(255,255,255,0.10);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 16px; /* Prevents auto-zoom on iOS Safari */
  outline: none;
  transition: border-color 0.25s, background 0.25s, box-shadow 0.25s;
}

.url-input::placeholder { color: var(--text-muted); }

.url-input:focus {
  border-color: var(--clr-primary);
  background: rgba(99,102,241,0.08);
  box-shadow: 0 0 0 4px rgba(99,102,241,0.15);
}

.url-input:focus + .input-icon,
.input-wrapper:focus-within .input-icon { color: var(--clr-primary); }

.paste-btn {
  position: absolute;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: rgba(129, 140, 248, 0.15);
  border: 1px solid rgba(129, 140, 248, 0.35);
  border-radius: var(--radius-sm);
  color: #c7d2fe;
  font-family: inherit;
  font-size: 0.825rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s var(--ease-spring), box-shadow 0.2s;
  touch-action: manipulation;
  z-index: 3;
}
.paste-btn:hover {
  background: rgba(129, 140, 248, 0.28);
  border-color: var(--clr-primary);
  color: #fff;
  box-shadow: 0 0 12px rgba(99,102,241,0.25);
  transform: translateY(-1px);
}
.paste-btn:active {
  transform: scale(0.95);
}

.clear-btn {
  position: absolute;
  right: 6px;
  width: 44px;
  height: 44px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
  touch-action: manipulation;
  z-index: 3;
}
.clear-btn:hover { color: var(--text-primary); background: rgba(255,255,255,0.08); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  padding: 16px 28px;
  border-radius: var(--radius-md);
  transition: transform 0.2s var(--ease-spring), box-shadow 0.25s, opacity 0.2s, background 0.2s;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  transition: background 0.2s;
}
.btn:hover::after { background: rgba(255,255,255,0.07); }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--clr-primary-deep), var(--clr-accent));
  color: #fff;
  box-shadow: 0 4px 24px rgba(99,102,241,0.35);
}
.btn-primary:hover {
  box-shadow: 0 8px 36px rgba(99,102,241,0.5);
  transform: translateY(-1px);
}
.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn-download {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff;
  box-shadow: 0 4px 24px rgba(16,185,129,0.3);
  flex: 1;
}
.btn-download:hover:not(:disabled) {
  box-shadow: 0 8px 36px rgba(16,185,129,0.5);
  transform: translateY(-1px);
}
.btn-download:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-ghost {
  background: rgba(255,255,255,0.06);
  color: var(--text-secondary);
  border: 1px solid rgba(255,255,255,0.10);
}
.btn-ghost:hover { background: rgba(255,255,255,0.10); color: var(--text-primary); }

.btn-arrow { flex-shrink: 0; transition: transform 0.2s; }
.btn:hover .btn-arrow { transform: translateX(3px); }

/* ── Spinner ── */
.btn-spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Error message ── */
.error-msg {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 6px;
  padding: 12px 16px;
  background: rgba(248,113,113,0.10);
  border: 1px solid rgba(248,113,113,0.25);
  border-radius: var(--radius-sm);
  color: var(--clr-danger);
  font-size: 0.875rem;
  animation: slideDown 0.2s var(--ease-out);
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Platform hints ── */
.platform-hints {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 36px;
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-wrap: wrap;
}

.hint-label { font-size: 0.8rem; color: var(--text-muted); }

.hint-badge {
  font-size: 0.75rem;
  font-weight: 500;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 100px;
  padding: 3px 10px;
  color: var(--text-secondary);
}

/* ── Result card ── */
.result-card {
  animation: cardIn 0.5s var(--ease-out);
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.result-header {
  display: flex;
  gap: 20px;
  padding: 28px 28px 24px;
  align-items: flex-start;
}

.thumbnail-wrapper {
  position: relative;
  width: 160px;
  height: 90px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-3);
}

.thumbnail {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

.thumbnail-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.4);
  color: #fff;
  opacity: 0;
  transition: opacity 0.2s;
}
.thumbnail-wrapper:hover .thumbnail-play { opacity: 1; }

.result-meta { flex: 1; min-width: 0; }

.result-author {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--clr-primary);
  letter-spacing: 0.03em;
  margin-bottom: 6px;
}

.result-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 8px;
}

.result-duration {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Formats grid ── */
.formats-section {
  padding: 0 28px 20px;
}

.formats-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 12px;
}

.formats-grid {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Format pill (radio) */
.format-pill {
  position: relative;
  cursor: pointer;
  flex: 1 1 calc(50% - 10px);
  min-width: 110px;
}

.format-pill input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
}

.format-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 12px 14px;
  min-height: 52px;
  background: rgba(255,255,255,0.05);
  border: 1.5px solid rgba(255,255,255,0.10);
  border-radius: var(--radius-sm);
  transition: border-color 0.2s, background 0.2s, transform 0.15s var(--ease-spring), box-shadow 0.2s;
  user-select: none;
  touch-action: manipulation;
}

.format-quality {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.format-size {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.format-pill input:checked + .format-label {
  background: rgba(99,102,241,0.15);
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 1px rgba(99,102,241,0.3), 0 4px 16px rgba(99,102,241,0.2);
  transform: translateY(-1px);
}

.format-pill:hover .format-label {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.2);
}

/* ── Download actions ── */
.download-actions {
  display: flex;
  gap: 12px;
  padding: 0 28px 24px;
}

/* ── Progress bar ── */
.progress-wrapper {
  margin: 0 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-bar {
  height: 4px;
  background: linear-gradient(90deg, var(--clr-primary), var(--clr-accent));
  border-radius: 100px;
  width: 0%;
  transition: width 0.3s var(--ease-out);
  animation: progressPulse 2s ease-in-out infinite;
}

@keyframes progressPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.7; }
}

.progress-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

/* ── Footer ── */
.footer {
  text-align: center;
  padding: 28px 0 36px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer a {
  color: var(--clr-primary);
  text-decoration: none;
  transition: color 0.2s;
}
.footer a:hover { color: var(--clr-accent); }

.heart { color: var(--clr-pink); }

/* ── Utility ── */
[hidden] { display: none !important; }

/* ── Responsive & Breakpoints (Mobile-First approach) ── */
@media (min-width: 540px) {
  .format-pill {
    flex: 0 0 auto;
    min-width: 90px;
  }
}

@media (max-width: 539px) {
  .header { padding: 36px 0 24px; }
  .logo-text { font-size: 1.75rem; }
  .card-inner { padding: 24px 18px 20px; }
  .result-header { flex-direction: column; gap: 16px; padding: 20px 18px 18px; }
  .thumbnail-wrapper { width: 100%; height: 200px; }
  .download-actions { flex-direction: column; gap: 10px; padding: 0 18px 20px; }
  .download-actions .btn { width: 100%; }
  .platform-hints { padding: 12px 18px; }
  .formats-section { padding: 0 18px 16px; }
  .progress-wrapper { margin: 0 18px 18px; }
}
