/* =========================================================
   ytdownloader — glass + aurora
   Paleta: tinta casi negra + glass con tinte frío, acentos
   teal / violeta / rosa. Tipografía: Space Grotesk + Inter
   + JetBrains Mono. Sin frameworks.
   ========================================================= */

:root {
  --bg:           #07060d;
  --bg-deep:      #050409;
  --ink:          #f5f5f8;
  --ink-soft:     rgba(245, 245, 248, 0.72);
  --muted:        rgba(245, 245, 248, 0.50);
  --line:         rgba(255, 255, 255, 0.08);
  --line-strong:  rgba(255, 255, 255, 0.16);

  --glass:        rgba(255, 255, 255, 0.045);
  --glass-hi:     rgba(255, 255, 255, 0.075);
  --glass-border: rgba(255, 255, 255, 0.10);

  --teal:         #5eead4;
  --violet:       #a78bfa;
  --pink:         #f472b6;
  --amber:        #fbbf24;
  --red:          #fb7185;

  --grad-aurora:  linear-gradient(135deg, var(--teal) 0%, var(--violet) 55%, var(--pink) 100%);
  --grad-cta:     linear-gradient(135deg, #5eead4 0%, #a78bfa 50%, #f472b6 100%);

  --shadow-card:  0 1px 0 rgba(255, 255, 255, 0.06) inset,
                  0 -1px 0 rgba(0, 0, 0, 0.4) inset,
                  0 30px 60px -20px rgba(0, 0, 0, 0.55),
                  0 12px 30px -10px rgba(0, 0, 0, 0.45);

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 22px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg-deep);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
  position: relative;
}

/* ---------- Aurora background ---------- */

.aurora {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% 0%, #110a22 0%, transparent 60%),
    var(--bg-deep);
}

/* Slow conic "sky" sweep that drifts the whole gradient around. */
.aurora::before {
  content: "";
  position: absolute;
  inset: -25%;
  background: conic-gradient(
    from 0deg at 50% 50%,
    rgba(94, 234, 212, 0.06) 0deg,
    rgba(167, 139, 250, 0.05) 90deg,
    rgba(244, 114, 182, 0.06) 180deg,
    rgba(94, 234, 212, 0.05) 270deg,
    rgba(94, 234, 212, 0.06) 360deg
  );
  filter: blur(80px);
  animation: spin 90s linear infinite;
  will-change: transform;
  pointer-events: none;
}

.aurora .blob {
  position: absolute;
  width: 60vmax;
  height: 60vmax;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.55;
  mix-blend-mode: screen;
  will-change: transform, opacity;
  pointer-events: none;
  animation-timing-function: cubic-bezier(0.45, 0, 0.55, 1);
  animation-iteration-count: infinite;
  animation-direction: alternate;
}

.aurora .blob-1 {
  background: radial-gradient(circle at 30% 30%, var(--teal) 0%, transparent 60%);
  top: -25vmax; left: -20vmax;
  animation-name: drift1, breathe1;
  animation-duration: 38s, 14s;
}
.aurora .blob-2 {
  background: radial-gradient(circle at 50% 50%, var(--violet) 0%, transparent 60%);
  top: 10vmax; right: -25vmax;
  animation-name: drift2, breathe2;
  animation-duration: 53s, 19s;
}
.aurora .blob-3 {
  background: radial-gradient(circle at 50% 50%, var(--pink) 0%, transparent 60%);
  bottom: -30vmax; left: 20vmax;
  animation-name: drift3, breathe3;
  animation-duration: 71s, 23s;
}

.aurora .grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 30%, #000 30%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 30%, #000 30%, transparent 80%);
  opacity: 0.6;
}

/* Position drifts — small, slow, sine-eased for ambient feel. */
@keyframes drift1 {
  0%   { transform: translate3d(0, 0, 0)            scale(1)    rotate(0deg); }
  50%  { transform: translate3d(3vmax, 2vmax, 0)   scale(1.06) rotate(18deg); }
  100% { transform: translate3d(5vmax, -1vmax, 0)  scale(0.97) rotate(28deg); }
}
@keyframes drift2 {
  0%   { transform: translate3d(0, 0, 0)             scale(1)    rotate(0deg); }
  50%  { transform: translate3d(-4vmax, 3vmax, 0)   scale(0.95) rotate(-14deg); }
  100% { transform: translate3d(-6vmax, -2vmax, 0)  scale(1.04) rotate(-22deg); }
}
@keyframes drift3 {
  0%   { transform: translate3d(0, 0, 0)            scale(1)    rotate(0deg); }
  50%  { transform: translate3d(2vmax, -3vmax, 0)  scale(1.08) rotate(12deg); }
  100% { transform: translate3d(4vmax, -5vmax, 0)  scale(0.94) rotate(18deg); }
}

/* Opacity breathing — independent periods, very low amplitude. */
@keyframes breathe1 { 0%, 100% { opacity: 0.52; } 50% { opacity: 0.62; } }
@keyframes breathe2 { 0%, 100% { opacity: 0.48; } 50% { opacity: 0.60; } }
@keyframes breathe3 { 0%, 100% { opacity: 0.50; } 50% { opacity: 0.58; } }

/* Slow conic spin for the shimmer layer. */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .aurora .blob,
  .aurora::before { animation: none; }
}

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 880px;
  margin: 0 auto;
  padding: 1.1rem 1.25rem 0.5rem;
  position: relative;
  z-index: 1;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-size: 0.98rem;
  color: var(--ink);
}

.logo {
  width: 26px; height: 26px;
  border-radius: 8px;
  background: var(--grad-aurora);
  position: relative;
  display: inline-grid; place-items: center;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.12) inset,
    0 8px 20px -8px rgba(167, 139, 250, 0.6);
}
.logo::after {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--bg-deep);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85);
}

.brand-name { font-size: 1rem; }

.badges { display: inline-flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 0.32rem 0.6rem;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--ink-soft);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
}
.badge.ghost { color: var(--muted); }

.dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 0 rgba(94, 234, 212, 0);
}
.dot.live {
  background: var(--teal);
  animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(94, 234, 212, 0.6); }
  70%  { box-shadow: 0 0 0 8px rgba(94, 234, 212, 0); }
  100% { box-shadow: 0 0 0 0 rgba(94, 234, 212, 0); }
}

/* ---------- Layout ---------- */

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
  position: relative;
  z-index: 1;
}

.hero {
  padding: 1.5rem 0.25rem 1.75rem;
  text-align: left;
}

.lede {
  margin: 0;
  color: var(--ink-soft);
  font-size: 1.02rem;
  max-width: 56ch;
}

.hero h1 {
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-weight: 700;
  font-size: clamp(2rem, 6vw, 3rem);
  line-height: 1.05;
  letter-spacing: -0.025em;
  margin: 0 0 0.85rem;
  color: var(--ink);
}
.hero h1 em {
  font-style: normal;
  background: var(--grad-aurora);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- Glass card ---------- */

.card {
  position: relative;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  padding: 1.5rem;
  margin-bottom: 1.1rem;
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 30%);
  pointer-events: none;
}

.card.hidden { display: none; }

.field-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.65rem;
}

/* ---------- URL input stage ---------- */

.url-stage {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.4rem 0.4rem 0.95rem;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.url-stage:focus-within {
  border-color: rgba(167, 139, 250, 0.6);
  box-shadow:
    0 0 0 4px rgba(167, 139, 250, 0.12),
    0 0 40px -10px rgba(94, 234, 212, 0.25);
}

.url-icon { color: var(--muted); display: inline-flex; }

.url-stage input {
  flex: 1 1 auto;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--ink);
  font: 500 0.98rem/1.4 "Inter", sans-serif;
  padding: 0.75rem 0.25rem;
  letter-spacing: -0.005em;
}
.url-stage input::placeholder { color: var(--muted); }

/* ---------- Primary button (Analizar) ---------- */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font: 600 0.95rem/1 "Inter", sans-serif;
  border-radius: 10px;
  border: 0;
  cursor: pointer;
  padding: 0.85rem 1.15rem;
  color: var(--bg-deep);
  background: var(--grad-aurora);
  overflow: hidden;
  isolation: isolate;
  transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.18) inset,
    0 10px 30px -10px rgba(167, 139, 250, 0.5);
}
.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.25) inset,
    0 16px 40px -12px rgba(244, 114, 182, 0.55);
}
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.is-loading .btn-label { opacity: 0.7; }

.btn-shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, 0.55) 50%, transparent 65%);
  transform: translateX(-120%);
  transition: transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
  pointer-events: none;
  z-index: -1;
}
.btn:hover .btn-shine { transform: translateX(120%); }

/* ---------- Limits row ---------- */

.limits {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-top: 1rem;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: var(--muted);
}
.limits b { color: var(--ink); font-weight: 600; }
.limits .sep {
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--line-strong);
}

/* ---------- Info card ---------- */

.info-head {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1.2rem;
  align-items: start;
  margin-bottom: 1.4rem;
}

.thumb-wrap {
  position: relative;
  border-radius: var(--r-md);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--line);
}
#thumb {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.thumb-glow {
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: var(--grad-aurora);
  opacity: 0.18;
  filter: blur(20px);
  z-index: -1;
}

.meta h2 {
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-weight: 600;
  font-size: 1.2rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin: 0 0 0.4rem;
  color: var(--ink);
}
.meta .muted {
  margin: 0 0 0.6rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
}
.chip-time {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0;
  padding: 0.28rem 0.55rem;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.78rem;
  color: var(--teal);
  background: rgba(94, 234, 212, 0.08);
  border: 1px solid rgba(94, 234, 212, 0.22);
  border-radius: 8px;
}

/* ---------- Section label ---------- */

.section-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.75rem;
}
.section-rule {
  flex: 1; height: 1px;
  background: linear-gradient(90deg, var(--line-strong), transparent);
}

/* ---------- Format grid (custom radio cards) ---------- */

.format-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
  margin-bottom: 1.4rem;
}

.fmt-card {
  position: relative;
  display: grid;
  grid-template-columns: 36px 1fr auto 18px;
  align-items: center;
  gap: 0.7rem;
  padding: 0.85rem 0.95rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  overflow: hidden;
}
.fmt-card input { position: absolute; opacity: 0; pointer-events: none; }

.fmt-card:hover {
  background: rgba(255, 255, 255, 0.055);
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.fmt-card:has(input:checked) {
  background:
    linear-gradient(135deg, rgba(94, 234, 212, 0.10), rgba(167, 139, 250, 0.10));
  border-color: rgba(167, 139, 250, 0.55);
  box-shadow:
    0 0 0 1px rgba(167, 139, 250, 0.35) inset,
    0 10px 30px -12px rgba(167, 139, 250, 0.45);
}
.fmt-card:has(input:checked)::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: var(--grad-aurora);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.fmt-icon {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink-soft);
  border: 1px solid var(--line);
  transition: color 0.2s, background 0.2s;
}
.fmt-icon svg { width: 18px; height: 18px; }
.fmt-card:has(input:checked) .fmt-icon {
  background: var(--grad-aurora);
  color: var(--bg-deep);
  border-color: transparent;
}

.fmt-text { display: flex; flex-direction: column; min-width: 0; }
.fmt-label {
  font: 600 0.95rem/1.2 "Space Grotesk", "Inter", sans-serif;
  letter-spacing: -0.005em;
  color: var(--ink);
}
.fmt-sub {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.15rem;
  line-height: 1.3;
}

.fmt-size {
  font: 500 0.72rem/1 "JetBrains Mono", ui-monospace, monospace;
  color: var(--muted);
  padding: 0.25rem 0.45rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  white-space: nowrap;
  align-self: center;
  letter-spacing: 0.01em;
}
.fmt-card:has(input:checked) .fmt-size {
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--line-strong);
}
.fmt-card.over-limit .fmt-size {
  color: var(--red);
  background: rgba(251, 113, 133, 0.10);
  border-color: rgba(251, 113, 133, 0.3);
}
.fmt-card.over-limit .fmt-label { color: var(--muted); }
.fmt-card.over-limit .fmt-sub { color: rgba(245, 245, 248, 0.35); }

.fmt-tick {
  width: 18px; height: 18px;
  border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--line-strong);
  color: transparent;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
  flex-shrink: 0;
}
.fmt-tick svg { width: 12px; height: 12px; }
.fmt-card:has(input:checked) .fmt-tick {
  background: var(--grad-aurora);
  border-color: transparent;
  color: var(--bg-deep);
}

/* ---------- CTA ---------- */

.cta {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  padding: 1rem 1.2rem;
  font: 600 1.02rem/1 "Inter", sans-serif;
  letter-spacing: -0.005em;
  border: 0;
  border-radius: 14px;
  color: var(--bg-deep);
  background: var(--grad-cta);
  cursor: pointer;
  overflow: hidden;
  isolation: isolate;
  transition: transform 0.15s ease, box-shadow 0.25s ease, filter 0.2s;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.25) inset,
    0 18px 50px -16px rgba(244, 114, 182, 0.55),
    0 8px 24px -10px rgba(94, 234, 212, 0.45);
}
.cta:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.06);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.35) inset,
    0 24px 60px -16px rgba(244, 114, 182, 0.65),
    0 10px 30px -10px rgba(94, 234, 212, 0.55);
}
.cta:active:not(:disabled) { transform: translateY(0); }
.cta:disabled { opacity: 0.5; cursor: not-allowed; }

.cta-shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.55) 50%, transparent 70%);
  transform: translateX(-120%);
  transition: transform 0.9s cubic-bezier(0.2, 0.8, 0.2, 1);
  pointer-events: none;
  z-index: -1;
}
.cta:hover .cta-shine,
.cta.is-firing .cta-shine { transform: translateX(120%); }

.cta-arrow { color: var(--bg-deep); }

/* ---------- Error card ---------- */

.card-error {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  border-color: rgba(251, 113, 133, 0.35);
  background: linear-gradient(135deg, rgba(251, 113, 133, 0.08), rgba(251, 113, 133, 0.02));
}
.error-icon {
  flex-shrink: 0;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  color: var(--red);
  background: rgba(251, 113, 133, 0.12);
  border: 1px solid rgba(251, 113, 133, 0.3);
}
.error { margin: 0; color: var(--ink); font-size: 0.95rem; }

/* ---------- Focus visibility (a11y) ---------- */

:focus-visible {
  outline: 2px solid var(--violet);
  outline-offset: 3px;
  border-radius: 6px;
}
.btn:focus-visible,
.cta:focus-visible,
.fmt-card:focus-within {
  outline-color: var(--teal);
}

/* ---------- Responsive ---------- */

@media (max-width: 560px) {
  .topbar { padding: 0.9rem 1rem 0.4rem; }
  main    { padding: 0 1rem 2.5rem; }
  .card   { padding: 1.15rem; border-radius: 18px; }

  .info-head {
    grid-template-columns: 1fr;
    gap: 0.9rem;
  }
  .thumb-wrap { aspect-ratio: 16 / 9; }

  .format-grid { grid-template-columns: 1fr; }

  .hero h1 { font-size: clamp(1.7rem, 8vw, 2.2rem); }
}
