/* VideosYa — mobile-first. Paleta: índigo-carbón + par cromático cian/rosa. */

:root {
  --bg: #14121f;
  --surface: #1e1b2e;
  --surface-2: #262238;
  --ink: #f5f3ff;
  --ink-dim: #a29cc0;
  --cyan: #2de2e6;
  --pink: #ff3d6e;
  --bg-glow: color-mix(in srgb, var(--surface-2) 88%, var(--pink) 12%);
  --radius: 16px;
  --tap: 48px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.55, 0, 1, 0.45);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --scroll-shift: 0px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

body {
  margin: 0;
  background-color: var(--bg);
  background-image: radial-gradient(
    125% 125% at 50% calc(10% + var(--scroll-shift)),
    var(--bg) 34%,
    var(--surface-2) 72%,
    var(--bg-glow) 100%
  );
  background-attachment: fixed;
  background-repeat: no-repeat;
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.55;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- Cabecera ---------- */

.topbar {
  padding: 0.9rem 1.25rem;
  max-width: 40rem;
}

.wordmark {
  display: inline-block;
  line-height: 0;
}

.wordmark-logo {
  display: block;
  width: auto;
  height: 54px;
  transform-origin: 35% 50%;
  animation: logo-glitch 5s steps(1, end) infinite;
  transition: transform 500ms var(--ease-out), filter 500ms var(--ease-out);
}

/* ---------- Herramienta (héroe) ---------- */

main {
  flex: 1;
  width: 100%;
  max-width: 40rem;
  margin: 0 auto;
  padding: 1rem 1.25rem 3rem;
}

.tool h1 {
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-weight: 800;
  font-size: clamp(1.7rem, 6.5vw, 2.6rem);
  line-height: 1.12;
  letter-spacing: -0.025em;
  margin: 1.2rem 0 0.5rem;
}

.tool h1 em {
  font-style: normal;
  color: var(--cyan);
  text-shadow: 1px 1px 0 rgba(255, 61, 110, 0.28);
}

.lede {
  color: var(--ink-dim);
  margin: 0 0 1.6rem;
}

.url-form { display: grid; gap: 0.75rem; perspective: 800px; }

.url-field {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 280ms var(--ease-out), box-shadow 280ms var(--ease-out),
    transform 350ms var(--ease-out), background-color 350ms var(--ease-out);
}

.url-field:focus-within {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(45, 226, 230, 0.25);
}

.url-field.has-error,
.url-field.has-error:focus-within {
  border-color: var(--pink);
  box-shadow: 0 0 0 3px rgba(255, 61, 110, 0.2);
}

#url-input {
  flex: 1;
  min-width: 0;
  min-height: var(--tap);
  padding: 0.75rem 1rem;
  background: transparent;
  border: 0;
  color: var(--ink);
  font-size: 1rem;
}

#url-input::placeholder { color: var(--ink-dim); opacity: 0.7; }
#url-input:focus { outline: none; }

.paste-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: var(--tap);
  padding: 0 1.1rem;
  border: 0;
  border-left: 1px solid var(--surface-2);
  background: var(--surface-2);
  color: var(--cyan);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 220ms var(--ease-out), background-color 220ms var(--ease-out),
    transform 220ms var(--ease-out);
}

.icon {
  width: 20px;
  height: 20px;
  flex: none;
}

.cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: var(--tap);
  padding: 0.75rem 1.2rem;
  border: 0;
  border-radius: var(--radius);
  background: linear-gradient(100deg, var(--pink), #ff5c86);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transform: perspective(700px) rotateX(var(--tilt-y, 0deg)) rotateY(var(--tilt-x, 0deg));
  transition: transform 420ms var(--ease-out), box-shadow 420ms var(--ease-out),
    filter 300ms var(--ease-out), opacity 220ms var(--ease-in);
  width: 100%;
}

.cta:active {
  transform: perspective(700px) rotateX(var(--tilt-y, 0deg)) rotateY(var(--tilt-x, 0deg)) scale(0.97);
  transition-duration: 100ms;
  transition-timing-function: var(--ease-in);
}

.cta-secondary {
  background: var(--surface-2);
  color: var(--cyan);
}

.cta[aria-disabled="true"],
.cta:disabled {
  opacity: 0.6;
  pointer-events: none;
}

/* Texto corto en móvil, completo desde el punto de quiebre de escritorio */
.btn-text-full { display: none; }
.btn-text-short { display: inline; }

button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 2px;
}

/* ---------- Estado y resultado ---------- */

.status {
  margin: 1rem 0 0;
  padding: 0.8rem 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-dim);
  animation: status-in 420ms var(--ease-out) both;
}

.status.error {
  background: rgba(255, 61, 110, 0.12);
  border: 1px solid rgba(255, 61, 110, 0.3);
  color: #ff8aa8;
}

.status-icon {
  display: none;
  width: 20px;
  height: 20px;
  flex: none;
  margin-top: 0.1rem;
}

.status.error .status-icon { display: block; }

.status.is-leaving {
  pointer-events: none;
  animation: status-out 220ms var(--ease-in) both;
}

.result {
  margin-top: 1.5rem;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: calc(var(--radius) + 4px);
  transform-style: preserve-3d;
  animation: result-in 650ms var(--ease-out) both;
  transition: border-color 350ms var(--ease-out), box-shadow 500ms var(--ease-out);
}

.result-head {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

/* Firma visual: la miniatura enmarcada como un teléfono 9:16 */
.phone-frame {
  flex: 0 0 96px;
  aspect-ratio: 9 / 16;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  border: 2px solid var(--surface-2);
  box-shadow: 2px 2px 0 rgba(255, 61, 110, 0.22), -2px -2px 0 rgba(45, 226, 230, 0.22);
  transform: perspective(700px) rotateX(var(--tilt-y, 0deg)) rotateY(var(--tilt-x, 0deg));
  transition: transform 500ms var(--ease-out), box-shadow 500ms var(--ease-out);
}

.phone-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

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

.result-meta h2 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.2rem;
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.result-author {
  color: var(--ink-dim);
  font-size: 0.9rem;
  margin: 0;
}

.downloads { display: grid; gap: 0.6rem; }
.downloads .cta { font-size: 0.98rem; }

/* ---------- Progreso de descarga ---------- */

.progress { margin-top: 0.9rem; }

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(100deg, var(--pink), var(--cyan));
  transition: width 240ms var(--ease-out);
}

.progress-fill.indeterminate {
  width: 35%;
  animation: progress-indeterminate 1.1s ease-in-out infinite;
}

@keyframes progress-indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(285%); }
}

.progress-label {
  margin: 0.45rem 0 0;
  font-size: 0.85rem;
  color: var(--ink-dim);
}

/* ---------- Cómo funciona ---------- */

.how { margin-top: 3rem; }

.how h2 {
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-weight: 800;
  font-size: 1.3rem;
  letter-spacing: -0.02em;
}

.steps {
  margin: 0;
  padding-left: 1.25rem;
  display: grid;
  gap: 0.7rem;
  color: var(--ink-dim);
}

.steps strong { color: var(--ink); }

/* ---------- Pie ---------- */

.footer {
  padding: 1.5rem 1.25rem 2rem;
  border-top: 1px solid var(--surface-2);
  color: var(--ink-dim);
  font-size: 0.85rem;
  text-align: center;
}

.footer a { color: var(--ink-dim); }

/* ---------- Movimiento y microinteracciones ---------- */

.reveal {
  opacity: 0;
  transform: translateY(24px) scale(0.985);
  filter: blur(5px);
  transition: opacity 620ms var(--ease-out), transform 720ms var(--ease-out),
    filter 620ms var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  filter: blur(0);
}

@keyframes result-in {
  from { opacity: 0; transform: translateY(18px) scale(0.975); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes status-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes status-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-5px); }
}

@keyframes logo-glitch {
  0%, 84%, 100% { transform: translate3d(0, 0, 0); filter: none; }
  86% { transform: translate3d(-2px, 1px, 0) skewX(-2deg); filter: drop-shadow(3px 0 var(--pink)); }
  89% { transform: translate3d(2px, -1px, 0) skewX(2deg); filter: drop-shadow(-3px 0 var(--cyan)); }
  92% { transform: translate3d(-1px, 0, 0); filter: drop-shadow(2px 0 var(--pink)) drop-shadow(-2px 0 var(--cyan)); }
  95% { transform: translate3d(0, 0, 0); filter: none; }
}

/* ---------- Desktop ---------- */

@media (min-width: 640px) {
  .topbar { padding: 1.2rem 2rem; }
  .wordmark-logo { height: 65px; }
  main { padding-top: 2.5rem; }
  .url-form { grid-template-columns: 1fr auto; }
  .phone-frame { flex-basis: 130px; }
  .cta { width: auto; }
  .btn-text-full { display: inline; }
  .btn-text-short { display: none; }
}

/* Cursor de marca: solo en dispositivos que realmente usan mouse. */
@media (hover: hover) and (pointer: fine) {
  body {
    cursor: url("/static/images/cursor.svg") 5 3, default;
  }

  a[href],
  button:not(:disabled),
  [role="button"],
  label[for] {
    cursor: url("/static/images/cursor-pointer.svg") 11 4, pointer;
  }

  input,
  textarea,
  [contenteditable="true"] {
    cursor: url("/static/images/cursor-text.svg") 16 16, text;
  }

  .wordmark:hover .wordmark-logo {
    animation: logo-glitch 700ms steps(1, end) 1;
    transform: rotate(-1.5deg) scale(1.035);
  }

  .url-field:hover {
    border-color: color-mix(in srgb, var(--cyan) 48%, var(--surface-2));
    background: color-mix(in srgb, var(--surface) 94%, var(--cyan));
  }

  .paste-btn:hover {
    color: var(--ink);
    background: color-mix(in srgb, var(--surface-2) 86%, var(--cyan));
  }

  .paste-btn:active { transform: scale(0.94); }

  .cta:hover {
    box-shadow: 0 7px 18px rgba(255, 61, 110, 0.11), 0 2px 6px rgba(0, 0, 0, 0.22);
    filter: saturate(1.08) brightness(1.06);
  }

  .cta-secondary:hover { box-shadow: 0 7px 18px rgba(45, 226, 230, 0.05); }

  .result:hover {
    border-color: color-mix(in srgb, var(--surface-2) 68%, var(--cyan));
    box-shadow: 0 14px 34px rgba(6, 4, 18, 0.16);
  }

  .phone-frame:hover {
    box-shadow: 3px 3px 0 rgba(255, 61, 110, 0.25), -3px -3px 0 rgba(45, 226, 230, 0.25);
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
  .reveal { opacity: 1; transform: none; filter: none; }
  .cta, .phone-frame { transform: none !important; }
}
