/* =============================================================
   QuitaFondo — hoja de estilos única
   1. Tokens · 2. Reset · 3. Utilidades · 4. Tipografía
   5. Componentes · 6. Secciones · 7. Herramienta · 8. Responsive
   ============================================================= */

/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg:        #f7f8fb;
  --bg-soft:   #eef0f7;
  --card:      #ffffff;
  --ink:       #0e1220;
  --ink-2:     #313a52;
  --muted:     #626c85;
  --line:      #e4e7f0;
  --line-2:    #d3d8e6;
  --accent:    #5b4bdb;
  --accent-ink:#4b3cc4;
  --accent-sf: #efedff;
  --teal:      #0aa992;
  --teal-sf:   #e4f7f3;
  --danger:    #c0392b;
  --danger-sf: #fdeceb;
  --white:     #ffffff;

  --shadow-sm: 0 1px 2px rgba(14, 18, 32, .05), 0 1px 3px rgba(14, 18, 32, .04);
  --shadow-md: 0 4px 6px -1px rgba(14, 18, 32, .06), 0 12px 24px -8px rgba(14, 18, 32, .10);
  --shadow-lg: 0 8px 16px -4px rgba(14, 18, 32, .07), 0 28px 56px -16px rgba(14, 18, 32, .16);

  --r-sm: 8px;
  --r:    12px;
  --r-lg: 18px;
  --r-xl: 24px;

  --sans:    "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --display: "Manrope", var(--sans);

  --ease-out:  cubic-bezier(0.16, 1, 0.3, 1);
  --ease-soft: cubic-bezier(0.25, 0.46, 0.45, 0.94);

  --gutter: clamp(1rem, 4vw, 2rem);
  --maxw: 1120px;

  /* damero de transparencia */
  --checker-a: #ffffff;
  --checker-b: #e9ecf4;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #0d1017;
    --bg-soft:   #141926;
    --card:      #161b28;
    --ink:       #f2f4f9;
    --ink-2:     #d3d9e6;
    --muted:     #99a3ba;
    --line:      #252c3d;
    --line-2:    #333c52;
    --accent:    #8b7dfb;
    --accent-ink:#a396ff;
    --accent-sf: #1e1c3a;
    --teal:      #2fd4b6;
    --teal-sf:   #102c29;
    --danger:    #ff8a7a;
    --danger-sf: #33191a;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.4), 0 12px 24px -8px rgba(0,0,0,.5);
    --shadow-lg: 0 8px 16px -4px rgba(0,0,0,.45), 0 28px 56px -16px rgba(0,0,0,.6);
    --checker-a: #1d2331;
    --checker-b: #262e40;
  }
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink-2);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
p { text-wrap: pretty; }
h1, h2, h3, h4 { text-wrap: balance; line-height: 1.12; letter-spacing: -0.022em; color: var(--ink); font-family: var(--display); font-weight: 800; }
::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

.skip-link {
  position: fixed; top: -100px; left: 1rem; z-index: 9999;
  padding: .6rem 1rem; background: var(--accent); color: #fff;
  border-radius: var(--r-sm); font-weight: 600;
}
.skip-link:focus { top: 1rem; }

/* =============================================================
   3. Utilidades
   ============================================================= */
.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
.wrap-narrow { max-width: 760px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.center { text-align: center; }

/* =============================================================
   4. Tipografía
   ============================================================= */
h1 { font-size: clamp(1.85rem, 1.25rem + 2.6vw, 3.05rem); }
h2 { font-size: clamp(1.45rem, 1.15rem + 1.3vw, 2.1rem); }
h3 { font-size: clamp(1.08rem, 1rem + .4vw, 1.28rem); }
.lede {
  font-size: clamp(1rem, .96rem + .3vw, 1.15rem);
  color: var(--muted);
  max-width: 62ch;
  margin-inline: auto;
}
.prose p { margin-block: 0 1.05em; }
.prose h2 { margin-block: 2.4rem .8rem; }
.prose h3 { margin-block: 1.8rem .5rem; }
.prose ul { margin: 0 0 1.05em 1.1em; padding: 0; }
.prose li { margin-bottom: .35em; }
.prose a { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; }
.prose strong { color: var(--ink); font-weight: 650; }

/* =============================================================
   5. Componentes
   ============================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  padding: .8rem 1.4rem; border-radius: var(--r);
  font-weight: 650; font-size: .96rem; letter-spacing: -.01em;
  background: var(--accent); color: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform .18s var(--ease-out), box-shadow .18s var(--ease-out), background .18s var(--ease-out);
  text-align: center;
}
.btn:hover { background: var(--accent-ink); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-ghost {
  background: transparent; color: var(--ink-2);
  border: 1px solid var(--line-2); box-shadow: none;
}
.btn-ghost:hover { background: var(--bg-soft); color: var(--ink); box-shadow: none; }
.btn-lg { padding: 1.05rem 1.9rem; font-size: 1.06rem; border-radius: var(--r-lg); width: 100%; }

.tag {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .32rem .7rem; border-radius: 999px;
  font-size: .78rem; font-weight: 600; letter-spacing: .01em;
  background: var(--accent-sf); color: var(--accent-ink);
}

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

/* ---- cabecera ---- */
.site-header {
  position: sticky; top: 0; z-index: 60;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  height: 62px;
}
.logo { display: inline-flex; align-items: center; gap: .55rem; font-family: var(--display); font-weight: 800; font-size: 1.06rem; color: var(--ink); letter-spacing: -.03em; }
.logo svg { width: 26px; height: 26px; flex: none; }
.header-nav { display: flex; align-items: center; gap: .35rem; font-size: .9rem; }
.header-nav a { padding: .45rem .7rem; border-radius: var(--r-sm); color: var(--muted); font-weight: 550; }
.header-nav a:hover { color: var(--ink); background: var(--bg-soft); }
.lang-switch { border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: .38rem .7rem !important; }
/* En movil solo cabe el selector de idioma: las secciones se alcanzan
   desplazandose y desde el pie. Sin esto la cabecera desborda a 375 px. */
.header-nav .nav-section { display: none; }

/* ---- pie ---- */
.site-footer {
  margin-top: 4rem; padding-block: 2.5rem 2rem;
  border-top: 1px solid var(--line); background: var(--bg-soft);
  font-size: .88rem; color: var(--muted);
}
.footer-grid { display: flex; flex-wrap: wrap; gap: 1.25rem 2.5rem; justify-content: space-between; align-items: flex-start; }
.footer-links { display: flex; flex-wrap: wrap; gap: .35rem 1.25rem; }
.footer-links a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.footer-note { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); font-size: .82rem; }

/* ---- huecos de publicidad (vacíos a propósito) ---- */
.ad-slot {
  min-height: 100px; margin: 2.25rem auto; max-width: 970px;
  display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--line-2); border-radius: var(--r);
  color: var(--muted); font-size: .74rem; letter-spacing: .16em; text-transform: uppercase;
  background: color-mix(in srgb, var(--card) 55%, transparent);
}
.ad-slot--tall { min-height: 250px; }

/* =============================================================
   6. Secciones
   ============================================================= */
.hero { padding-block: clamp(1.75rem, 1rem + 3vw, 3.25rem) 1rem; }
.hero-head { text-align: center; margin-bottom: 1.5rem; }
.hero-head .tag { margin-bottom: .9rem; }
.hero-head h1 { margin-bottom: .7rem; }

.section { padding-block: clamp(2.25rem, 1.5rem + 3vw, 4rem); }
.section-head { text-align: center; max-width: 62ch; margin: 0 auto clamp(1.5rem, 1rem + 2vw, 2.5rem); }
.section-head h2 { margin-bottom: .6rem; }
.section-head p { color: var(--muted); }

/* pasos */
.steps { display: grid; gap: 1rem; grid-template-columns: 1fr; counter-reset: step; }
.step { position: relative; padding: 1.6rem 1.5rem 1.5rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 11px; margin-bottom: .9rem;
  background: var(--accent-sf); color: var(--accent-ink);
  font-family: var(--display); font-weight: 800; font-size: 1.05rem;
}
.step h3 { margin-bottom: .35rem; }
.step p { color: var(--muted); font-size: .95rem; }

/* ideas de uso */
.uses { display: grid; gap: .9rem; grid-template-columns: 1fr; }
.use {
  display: flex; gap: .9rem; align-items: flex-start;
  padding: 1.15rem 1.2rem; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  transition: transform .2s var(--ease-out), box-shadow .2s var(--ease-out);
}
.use:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.use-icon {
  flex: none; width: 40px; height: 40px; border-radius: 11px;
  display: grid; place-items: center; background: var(--teal-sf); color: var(--teal);
}
.use-icon svg { width: 21px; height: 21px; }
.use h3 { font-size: 1rem; margin-bottom: .2rem; }
.use p { font-size: .9rem; color: var(--muted); line-height: 1.55; }

/* tabla de formatos */
.formats-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--card); box-shadow: var(--shadow-sm); }
table.formats { width: 100%; border-collapse: collapse; font-size: .92rem; min-width: 620px; }
table.formats th, table.formats td { padding: .9rem 1.1rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
table.formats thead th { font-family: var(--display); font-weight: 700; color: var(--ink); font-size: .84rem; text-transform: uppercase; letter-spacing: .06em; background: var(--bg-soft); }
table.formats tbody tr:last-child td { border-bottom: 0; }
table.formats td:first-child { font-weight: 700; color: var(--ink); white-space: nowrap; }

/* FAQ */
.faq { display: grid; gap: .7rem; }
.faq details {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow-sm); overflow: hidden;
}
.faq summary {
  list-style: none; cursor: pointer; padding: 1.05rem 3rem 1.05rem 1.25rem;
  font-weight: 650; color: var(--ink); font-family: var(--display);
  position: relative; font-size: 1rem; line-height: 1.4;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: ""; position: absolute; right: 1.25rem; top: 50%;
  width: 10px; height: 10px; margin-top: -6px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg); transition: transform .25s var(--ease-out);
}
.faq details[open] summary::after { transform: rotate(-135deg); margin-top: -2px; }
.faq summary:hover { background: var(--bg-soft); }
.faq .faq-body { padding: 0 1.25rem 1.15rem; color: var(--muted); font-size: .95rem; }
.faq .faq-body p + p { margin-top: .7rem; }

/* =============================================================
   7. La herramienta
   ============================================================= */
.tool-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  padding: clamp(1rem, .6rem + 1.4vw, 1.6rem);
  max-width: 880px; margin-inline: auto;
}
.tool-stage { display: none; }
.tool-card[data-state="idle"]    .stage-idle,
.tool-card[data-state="engine"]  .stage-busy,
.tool-card[data-state="working"] .stage-busy,
.tool-card[data-state="done"]    .stage-result,
.tool-card[data-state="error"]   .stage-error { display: block; }

/* zona de subida */
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .55rem; text-align: center; cursor: pointer;
  padding: clamp(1.75rem, 1rem + 4vw, 3rem) 1.25rem;
  border: 2px dashed var(--line-2); border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--bg-soft) 60%, transparent);
  transition: border-color .2s var(--ease-out), background .2s var(--ease-out), transform .2s var(--ease-out);
}
.drop:hover, .drop:focus-within { border-color: var(--accent); background: var(--accent-sf); }
.drop.is-dragover { border-color: var(--accent); background: var(--accent-sf); transform: scale(1.008); }
.drop-icon { width: 52px; height: 52px; color: var(--accent); margin-bottom: .2rem; }
.drop-title { font-family: var(--display); font-weight: 750; font-size: 1.1rem; color: var(--ink); }
.drop-sub { font-size: .88rem; color: var(--muted); }
.drop .btn { margin-top: .65rem; pointer-events: none; }
.drop-formats { font-size: .78rem; color: var(--muted); margin-top: .15rem; }

/* estado ocupado */
.stage-busy { padding: clamp(1.75rem, 1rem + 4vw, 3rem) 1rem; text-align: center; }
.busy-title { font-family: var(--display); font-weight: 750; font-size: 1.08rem; color: var(--ink); margin-bottom: .35rem; }
.busy-sub { font-size: .88rem; color: var(--muted); min-height: 1.4em; }
.progress {
  position: relative; height: 8px; border-radius: 999px; overflow: hidden;
  background: var(--bg-soft); max-width: 420px; margin: 1.1rem auto .8rem;
}
.progress-bar {
  position: absolute; inset: 0 auto 0 0; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--teal));
  border-radius: 999px; transition: width .35s var(--ease-soft);
}
.progress.is-indeterminate .progress-bar {
  width: 40%; animation: slide 1.25s var(--ease-soft) infinite;
}
@keyframes slide { 0% { left: -40%; } 100% { left: 100%; } }

/* resultado */
.result-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem 1rem; margin-bottom: .9rem; }
.result-head h2 { font-size: 1.15rem; }
.result-meta { font-size: .84rem; color: var(--muted); }

.compare {
  position: relative; border-radius: var(--r-lg); overflow: hidden;
  border: 1px solid var(--line);
  background-color: var(--checker-a);
  background-image:
    linear-gradient(45deg, var(--checker-b) 25%, transparent 25%),
    linear-gradient(-45deg, var(--checker-b) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--checker-b) 75%),
    linear-gradient(-45deg, transparent 75%, var(--checker-b) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  display: grid; place-items: center;
  min-height: 180px;
  touch-action: pan-y;
}
.compare.has-bg { background-image: none; }
.compare-canvas { max-height: min(52vh, 440px); width: auto; max-width: 100%; }
.compare-original {
  position: absolute; inset: 0; margin: auto;
  max-height: min(52vh, 440px); width: auto; max-width: 100%;
  clip-path: inset(0 calc(100% - var(--split, 50%)) 0 0);
  pointer-events: none;
}
.compare.no-split .compare-original { display: none; }
canvas.compare-original { background: transparent; }
.compare-divider {
  position: absolute; top: 0; bottom: 0; left: var(--split, 50%);
  width: 2px; background: rgba(255,255,255,.9); box-shadow: 0 0 0 1px rgba(14,18,32,.22);
  pointer-events: none; transform: translateX(-1px);
}
.compare-divider::after {
  content: ""; position: absolute; top: 50%; left: 50%;
  width: 34px; height: 34px; margin: -17px 0 0 -17px;
  border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(14,18,32,.3);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23313a52' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 6l-6 6 6 6M9 6l6 6-6 6'/%3E%3C/svg%3E");
  background-size: 18px; background-repeat: no-repeat; background-position: center;
}
.compare-range {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: ew-resize; margin: 0; -webkit-appearance: none; appearance: none; background: none;
}
.compare-range::-webkit-slider-thumb { -webkit-appearance: none; width: 44px; height: 100%; cursor: ew-resize; }
.compare-range::-moz-range-thumb { width: 44px; height: 999px; border: 0; background: transparent; cursor: ew-resize; }
.compare-hint { font-size: .8rem; color: var(--muted); text-align: center; margin-top: .55rem; }

/* controles */
.controls { margin-top: 1.15rem; display: grid; gap: 1.1rem; }
.control-label { display: block; font-size: .8rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin-bottom: .5rem; }
.swatches { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.swatch {
  width: 40px; height: 40px; border-radius: var(--r-sm);
  border: 2px solid var(--line-2); position: relative; overflow: hidden;
  transition: border-color .18s var(--ease-out), transform .18s var(--ease-out);
}
.swatch:hover { transform: translateY(-1px); }
.swatch[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-sf); }
.swatch-transparent {
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #d9dde8 25%, transparent 25%),
    linear-gradient(-45deg, #d9dde8 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d9dde8 75%),
    linear-gradient(-45deg, transparent 75%, #d9dde8 75%);
  background-size: 14px 14px;
  background-position: 0 0, 0 7px, 7px -7px, -7px 0;
}
.swatch-custom { padding: 0; border-style: solid; }
.swatch-custom input[type="color"] {
  width: 200%; height: 200%; margin: -25%; border: 0; padding: 0; background: none; cursor: pointer;
}

.segmented { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; background: var(--bg-soft); padding: .35rem; border-radius: var(--r); }
.segmented button {
  padding: .6rem .35rem; border-radius: var(--r-sm); font-weight: 650; font-size: .88rem;
  color: var(--muted); transition: background .18s var(--ease-out), color .18s var(--ease-out);
}
.segmented button:hover { color: var(--ink); }
.segmented button[aria-pressed="true"] { background: var(--card); color: var(--accent-ink); box-shadow: var(--shadow-sm); }
.segmented button[disabled] { opacity: .4; cursor: not-allowed; }

.download-row { display: grid; gap: .6rem; }
.format-note { font-size: .84rem; color: var(--muted); text-align: center; min-height: 1.3em; }
.result-actions { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center; }
.result-actions .btn-ghost { flex: 1 1 180px; }

/* error */
.stage-error { padding: 2rem 1.25rem; text-align: center; }
.error-icon { width: 48px; height: 48px; margin: 0 auto .8rem; color: var(--danger); }
.stage-error h2 { font-size: 1.1rem; margin-bottom: .4rem; }
.error-msg { color: var(--muted); font-size: .93rem; max-width: 46ch; margin: 0 auto 1.2rem; }

/* aviso de privacidad + límites */
.tool-foot {
  max-width: 880px; margin: 1rem auto 0;
  display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; justify-content: center;
  font-size: .84rem; color: var(--muted); text-align: center;
}
.tool-foot span { display: inline-flex; align-items: center; gap: .4rem; }
.tool-foot svg { width: 15px; height: 15px; flex: none; color: var(--teal); }

.nojs {
  display: none; margin-top: 1rem; padding: .9rem 1.1rem;
  border-radius: var(--r); background: var(--danger-sf); color: var(--danger);
  font-size: .9rem; text-align: center;
}
html.no-js .nojs { display: block; }
html.no-js .tool-card { display: none; }

/* =============================================================
   8. Responsive
   ============================================================= */
@media (min-width: 540px) {
  .download-row { grid-template-columns: 1fr; }
}
@media (min-width: 720px) {
  .header-nav .nav-section { display: inline-block; }
  .steps { grid-template-columns: repeat(3, 1fr); }
  .uses  { grid-template-columns: repeat(2, 1fr); }
  .controls { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); align-items: start; }
  .controls .control-download { grid-column: 1 / -1; }
}
@media (min-width: 960px) {
  .uses { grid-template-columns: repeat(3, 1fr); }
}

/* =============================================================
   9. Movimiento reducido — solo efectos intrusivos
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .progress.is-indeterminate .progress-bar { animation: none; width: 100%; opacity: .5; }
}
