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

/* ============ 1. Tokens ============ */
:root {
  --bg:        #f5f6fb;
  --bg-alt:    #eceef7;
  --panel:     #ffffff;
  --panel-2:   #fafbff;
  --ink:       #12141c;
  --muted:     #5c6273;
  --line:      #e2e6f0;
  --line-2:    #d3d9e8;
  --accent:    #4f46e5;
  --accent-2:  #6d64f0;
  --accent-ink:#ffffff;
  --accent-soft:#eeecfe;
  --warn:      #92500e;
  --warn-bg:   #fff5e6;
  --warn-line: #f0c78a;
  --danger:    #a41c1c;
  --danger-bg: #fdeeee;
  --danger-line:#f0b4b4;
  --ok:        #16663f;
  --ok-bg:     #e9f7ef;

  --radius:    16px;
  --radius-sm: 10px;
  --shadow:    0 1px 2px rgba(18,20,28,.05), 0 8px 28px rgba(18,20,28,.06);
  --shadow-lg: 0 24px 60px rgba(18,20,28,.14);
  --gutter:    clamp(1rem, 3vw, 1.75rem);
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #0e1016;
    --bg-alt:    #131722;
    --panel:     #171b25;
    --panel-2:   #1c2130;
    --ink:       #e9ecf6;
    --muted:     #9aa2b8;
    --line:      #272d3c;
    --line-2:    #333a4d;
    --accent:    #7b73f7;
    --accent-2:  #8f88ff;
    --accent-soft:#232144;
    --warn:      #f0b96b;
    --warn-bg:   #2c2415;
    --warn-line: #5a4720;
    --danger:    #f19b9b;
    --danger-bg: #2e1a1a;
    --danger-line:#5c2c2c;
    --ok:        #7bd6a4;
    --ok-bg:     #16281f;
    --shadow:    0 1px 2px rgba(0,0,0,.3), 0 8px 28px rgba(0,0,0,.35);
    --shadow-lg: 0 24px 60px rgba(0,0,0,.5);
  }
}

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

/* ============ 3. Utilidades ============ */
.container { width: 100%; max-width: 1160px; margin-inline: auto; padding-inline: var(--gutter); }
.skip-link {
  position: fixed; top: -100px; left: 1rem; z-index: 999;
  padding: .6rem 1rem; background: var(--accent); color: #fff; border-radius: 8px; font-weight: 600;
}
.skip-link:focus { top: 1rem; }

/* ============ 4. Tipografía base ============ */
h1 { font-size: clamp(1.75rem, 4.4vw, 2.85rem); }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
h3 { font-size: 1.06rem; }

/* ============ 5. Componentes ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .68rem 1.05rem; border-radius: var(--radius-sm);
  font-weight: 600; font-size: .93rem; line-height: 1.25;
  border: 1px solid transparent; text-align: center;
  transition: transform .18s var(--ease-out), background-color .18s var(--ease-out),
              border-color .18s var(--ease-out), box-shadow .18s var(--ease-out);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 18px rgba(79,70,229,.28); }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { background: var(--panel); border-color: var(--line-2); color: var(--ink); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: .45rem .8rem; font-size: .85rem; }
.btn-big { width: 100%; flex-direction: column; gap: .1rem; padding: .95rem 1rem; font-size: 1.02rem; }
.btn-big small { font-weight: 500; font-size: .78rem; opacity: .85; }
.btn-link {
  background: none; color: var(--muted); font-weight: 500; font-size: .85rem;
  text-decoration: underline; text-underline-offset: 3px; padding: .35rem 0; width: 100%;
}
.btn-link:hover { color: var(--accent); }
.btn[disabled] { opacity: .5; pointer-events: none; }

.field { display: block; margin-bottom: .9rem; }
.field-label { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: .35rem; letter-spacing: .01em; }
.hint { display: block; font-size: .78rem; color: var(--muted); margin-top: .3rem; }
input[type="text"], select {
  width: 100%; padding: .62rem .75rem; font: inherit; font-size: .95rem;
  color: var(--ink); background: var(--panel-2);
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  transition: border-color .18s var(--ease-out), box-shadow .18s var(--ease-out);
}
input[type="text"]:focus, select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type="range"] { width: 100%; accent-color: var(--accent); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.check { display: flex; align-items: center; gap: .5rem; font-size: .88rem; color: var(--muted); margin-bottom: .8rem; cursor: pointer; }
.check input { accent-color: var(--accent); width: 1rem; height: 1rem; }
.color-row { display: flex; align-items: center; gap: .55rem; }
input[type="color"] {
  inline-size: 3rem; block-size: 2.35rem; padding: 2px; cursor: pointer;
  border: 1px solid var(--line-2); border-radius: 8px; background: var(--panel-2);
}
output { font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
fieldset.fs { border: 0; padding: 0; margin: 0 0 .9rem; }
fieldset.fs legend { padding: 0; }

.seg { display: inline-flex; background: var(--bg-alt); border-radius: 12px; padding: 3px; margin-bottom: .9rem; gap: 2px; }
.seg-btn { padding: .45rem .95rem; border-radius: 9px; font-size: .88rem; font-weight: 600; color: var(--muted); }
.seg-btn.is-active { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  padding: .35rem .7rem; border-radius: 999px; font-size: .8rem; font-weight: 500;
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--muted);
  transition: border-color .18s var(--ease-out), color .18s var(--ease-out);
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

/* selectores visuales (estilo / formato) */
.styles { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
.formats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.style-opt input, .fmt-opt input { position: absolute; opacity: 0; pointer-events: none; }
.style-box, .fmt-box {
  display: flex; flex-direction: column; align-items: center; gap: .3rem; text-align: center;
  padding: .6rem .35rem; border: 1.5px solid var(--line-2); border-radius: 12px;
  background: var(--panel-2); font-size: .76rem; font-weight: 500; color: var(--muted);
  cursor: pointer; height: 100%;
  transition: border-color .18s var(--ease-out), background-color .18s var(--ease-out), color .18s var(--ease-out);
}
.style-box svg { width: 26px; height: 26px; fill: currentColor; }
.fmt-box svg { width: 40px; height: 32px; fill: currentColor; }
.fmt-box b { font-size: .82rem; font-weight: 600; color: var(--ink); }
.fmt-box small { font-size: .72rem; line-height: 1.3; }
.style-opt:hover .style-box, .fmt-opt:hover .fmt-box { border-color: var(--accent); }
.style-opt input:checked + .style-box, .fmt-opt input:checked + .fmt-box {
  border-color: var(--accent); background: var(--accent-soft); color: var(--accent);
}
.fmt-opt input:checked + .fmt-box b { color: var(--accent); }
.style-opt input:focus-visible + .style-box, .fmt-opt input:focus-visible + .fmt-box { outline: 2px solid var(--accent); outline-offset: 2px; }

.emojis { display: grid; grid-template-columns: repeat(6, 1fr); gap: .35rem; margin-bottom: .6rem; }
.emoji {
  aspect-ratio: 1; display: grid; place-items: center; font-size: 1.2rem;
  border: 1.5px solid var(--line-2); border-radius: 10px; background: var(--panel-2);
  transition: border-color .18s var(--ease-out), transform .18s var(--ease-out);
}
.emoji:hover { border-color: var(--accent); transform: translateY(-1px); }
.emoji.is-active { border-color: var(--accent); background: var(--accent-soft); }
.center-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
.center-state { font-size: .8rem; color: var(--muted); }

/* ============ 6. La herramienta ============ */
.hero { padding: clamp(1.25rem, 3vw, 2rem) 0 1.5rem; }
.hero h1 { margin-bottom: .5rem; }
.hero-sub { font-size: clamp(.95rem, 1.4vw, 1.04rem); color: var(--muted); max-width: 68ch; margin-bottom: clamp(1rem, 2vw, 1.4rem); }
.hero-sub strong { color: var(--ink); font-weight: 600; }

.tool { display: grid; gap: 1rem; align-items: start; }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(1rem, 2.2vw, 1.35rem); box-shadow: var(--shadow);
}
.panel-title { font-size: 1rem; display: flex; align-items: center; gap: .5rem; margin-bottom: .9rem; }
.step-num {
  display: grid; place-items: center; width: 1.5rem; height: 1.5rem; flex: none;
  border-radius: 999px; background: var(--accent); color: #fff; font-size: .78rem; font-weight: 700;
}
.panel-preview { position: sticky; top: 1rem; }

.preview-2d { display: grid; place-items: center; margin-bottom: .9rem; }
.qr-holder {
  --checker: #e9ecf5;
  width: 100%; max-width: 300px; aspect-ratio: 1;
  display: grid; place-items: center; padding: .5rem;
  border: 1px solid var(--line); border-radius: 12px;
  background-color: var(--panel-2);
  background-image:
    linear-gradient(45deg, var(--checker) 25%, transparent 25%, transparent 75%, var(--checker) 75%),
    linear-gradient(45deg, var(--checker) 25%, transparent 25%, transparent 75%, var(--checker) 75%);
  background-size: 16px 16px; background-position: 0 0, 8px 8px;
}
.qr-holder canvas, .qr-holder svg { width: 100% !important; height: auto !important; border-radius: 4px; }
.nojs { font-size: .85rem; color: var(--danger); text-align: center; }

.dl-group { margin-bottom: .9rem; }
.dl-label { display: block; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: .4rem; }
.dl-row { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.dl-main { margin-bottom: .75rem; }

.viewer-wrap { margin-bottom: .9rem; }
.viewer-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.viewer-hint { font-size: .75rem; color: var(--muted); }
.viewer {
  position: relative; width: 100%; aspect-ratio: 4 / 3; min-height: 210px;
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  background: linear-gradient(180deg, var(--panel-2), var(--bg-alt));
  touch-action: none;
}
.viewer canvas { width: 100%; height: 100%; display: block; }
.viewer-msg {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  padding: 1rem; font-size: .85rem; color: var(--muted); line-height: 1.5;
}
.viewer-msg[hidden] { display: none; }
.viewer-legend { display: flex; align-items: center; gap: .4rem; font-size: .76rem; color: var(--muted); margin-top: .4rem; }
.swatch { width: .85rem; height: .85rem; border-radius: 4px; border: 1px solid var(--line-2); display: inline-block; }
.swatch + .swatch, .viewer-legend .swatch:nth-of-type(2) { margin-left: .5rem; }

.privacy-badge {
  font-size: .8rem; color: var(--muted); line-height: 1.5;
  background: var(--ok-bg); color: var(--ok); border-radius: var(--radius-sm); padding: .6rem .75rem;
}
.privacy-badge strong { font-weight: 700; }

.specs { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin: 0 0 .8rem; }
.specs div { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .5rem .6rem; }
.specs dt { font-size: .72rem; color: var(--muted); font-weight: 500; }
.specs dd { font-size: .92rem; font-weight: 700; margin: 0; font-variant-numeric: tabular-nums; }
.specs dd.is-bad { color: var(--danger); }

.warnings:empty { display: none; }
.warn-item {
  display: flex; gap: .5rem; font-size: .83rem; line-height: 1.45;
  padding: .55rem .7rem; border-radius: var(--radius-sm); margin-bottom: .45rem;
  background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-line);
}
.warn-item.is-error { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-line); }
.warn-item.is-ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }

.limits { font-size: .82rem; color: var(--muted); margin-top: 1rem; max-width: 78ch; }

/* ============ 7. Secciones ============ */
.site-header { position: sticky; top: 0; z-index: 40; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; height: 3.75rem; }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; letter-spacing: -.02em; }
.brand-mark { width: 1.4rem; height: 1.4rem; fill: var(--accent); }
.brand-name { font-size: 1.12rem; }
.brand-name em { font-style: normal; color: var(--accent); }
.site-nav { display: flex; gap: 1.15rem; font-size: .88rem; color: var(--muted); font-weight: 500; }
.site-nav a:hover { color: var(--accent); }

.section { padding: clamp(2.25rem, 6vw, 3.75rem) 0; }
.section-alt { background: var(--bg-alt); }
.section h2 { margin-bottom: .5rem; }
.section-sub { color: var(--muted); margin-bottom: 1.5rem; max-width: 60ch; }

.steps { list-style: none; padding: 0; display: grid; gap: 1rem; margin-top: 1.5rem; grid-template-columns: repeat(3, 1fr); }
.steps li { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.step-badge { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 700; margin-bottom: .7rem; }
.steps h3 { margin-bottom: .35rem; }
.steps p { font-size: .9rem; color: var(--muted); }

.ideas { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.idea { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.15rem; }
.idea-ico { font-size: 1.5rem; display: block; margin-bottom: .5rem; }
.idea h3 { margin-bottom: .3rem; }
.idea p { font-size: .88rem; color: var(--muted); }

.prose { max-width: 74ch; }
.prose h2 { margin-bottom: .9rem; }
.prose h3 { font-size: 1.1rem; margin: 1.6rem 0 .5rem; }
.prose p { margin-bottom: .9rem; color: var(--muted); }
.prose strong { color: var(--ink); font-weight: 600; }

.faq { display: grid; gap: .5rem; max-width: 74ch; }
.faq details { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .85rem 1rem; }
.faq summary { font-weight: 600; cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 1.25rem; color: var(--accent); line-height: 1; }
.faq details[open] summary::after { content: "–"; }
.faq p { font-size: .92rem; color: var(--muted); margin-top: .6rem; }

.site-footer { background: var(--panel); border-top: 1px solid var(--line); padding: 2rem 0; }
.footer-inner { display: grid; gap: .5rem; }
.footer-brand { font-size: .92rem; }
.footer-nav { display: flex; gap: 1rem; font-size: .88rem; color: var(--muted); }
.footer-nav a:hover { color: var(--accent); text-decoration: underline; }
.footer-note { font-size: .8rem; color: var(--muted); }

/* ============ 8. Publicidad (solo huecos marcados) ============ */
.ad-slot {
  position: relative; display: grid; place-items: center;
  border: 1.5px dashed var(--line-2); border-radius: var(--radius);
  background: var(--panel-2); color: var(--muted);
  margin: clamp(1.25rem, 3vw, 2rem) 0;
}
.ad-leaderboard { min-height: 100px; }
.ad-incontent { min-height: 250px; max-width: 336px; margin-inline: auto; }
.ad-tag { font-size: .7rem; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; opacity: .65; }

.ad-corner {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 60;
  width: 168px; min-height: 130px; display: grid; place-items: center;
  border: 1.5px dashed var(--line-2); border-radius: 14px;
  background: var(--panel); box-shadow: var(--shadow-lg);
}
.ad-corner[hidden] { display: none; }
.ad-corner-close {
  position: absolute; top: -.55rem; right: -.55rem; width: 1.6rem; height: 1.6rem;
  display: grid; place-items: center; border-radius: 999px;
  background: var(--ink); color: var(--bg); font-size: 1rem; line-height: 1;
}

.ad-modal {
  border: 0; border-radius: var(--radius); padding: 1.25rem;
  background: var(--panel); color: var(--ink); box-shadow: var(--shadow-lg);
  max-width: min(92vw, 360px); width: 100%;
}
.ad-modal::backdrop { background: rgba(10,12,20,.5); }
.ad-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.ad-modal-head p { font-weight: 600; font-size: .95rem; }
.ad-modal-x { width: 2rem; height: 2rem; display: grid; place-items: center; border-radius: 999px; font-size: 1.3rem; line-height: 1; color: var(--muted); }
.ad-modal-x:hover { background: var(--bg-alt); color: var(--ink); }
.ad-modal-slot { min-height: 250px; margin: 0 0 .9rem; }
.ad-modal .btn { width: 100%; }

/* ============ 9. Responsive ============ */
@media (max-width: 539px) {
  /* en móvil la herramienta tiene que caer lo más arriba posible */
  .hero { padding-top: .9rem; }
  .hero-sub { font-size: .92rem; margin-bottom: 1rem; }
  .panel { padding: .9rem; }
  .panel-title { margin-bottom: .7rem; }
  .qr-holder { max-width: 236px; }
  .styles { grid-template-columns: repeat(2, 1fr); }
  .formats { grid-template-columns: 1fr; }
  .fmt-box { flex-direction: row; align-items: center; text-align: left; gap: .7rem; padding: .7rem; }
  .fmt-box svg { flex: none; }
  .site-nav { display: none; }
  .ad-corner { width: 132px; min-height: 104px; right: .6rem; bottom: .6rem; }
}
@media (min-width: 720px) {
  .footer-inner { grid-template-columns: 1fr auto; align-items: center; }
  .footer-note { grid-column: 1 / -1; }
}
@media (max-width: 719px) {
  .steps, .ideas { grid-template-columns: 1fr; }
}
@media (min-width: 720px) and (max-width: 959px) {
  .ideas { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 960px) {
  .tool {
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.92fr);
    grid-template-areas:
      "contenido preview"
      "diseno    preview"
      "obj3d     preview";
    gap: 1rem 1.15rem;
  }
  .panel-contenido { grid-area: contenido; }
  .panel-preview   { grid-area: preview; }
  .panel-diseno    { grid-area: diseno; }
  .panel-3d        { grid-area: obj3d; }

  /* imagen y objeto 3D uno al lado del otro: así las descargas caben en pantalla */
  .panel-preview {
    display: grid; align-content: start;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .7rem .9rem;
    grid-template-areas:
      "head  head"
      "qr    viewer"
      "dlimg dl3d"
      "priv  priv";
  }
  .panel-preview > .panel-title { grid-area: head; margin-bottom: 0; }
  .preview-2d  { grid-area: qr; margin: 0; display: block; }
  .preview-2d .qr-holder { margin-inline: auto; }
  .viewer-wrap { grid-area: viewer; margin: 0; }
  .dl-img      { grid-area: dlimg; margin: 0; align-self: end; }
  .dl-main     { grid-area: dl3d; margin: 0; align-self: end; }
  .privacy-badge { grid-area: priv; }
  .qr-holder { max-width: 100%; }
  .dl-row { grid-template-columns: 1fr; gap: .4rem; }
}

/* ============ 10. Movimiento (solo lo intrusivo se desactiva) ============ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
