/* =============================================================
   QR3D — hoja de estilo unica
   1. Tokens  2. Reset  3. Utilidades  4. Tipografia  5. Componentes
   6. Herramienta  7. Secciones  8. Anuncios  9. Responsive  10. Motion
   ============================================================= */

/* 1. Tokens ================================================== */
:root {
  --bg:        #f6f6f4;
  --bg-2:      #eeeeea;
  --surface:   #ffffff;
  --ink:       #14161a;
  --ink-2:     #3d434f;
  --muted:     #6b7280;
  --line:      #e2e2dd;
  --line-2:    #d3d3cc;
  --accent:    #ff5a1f;
  --accent-ink:#ffffff;
  --accent-sf: #fff1eb;
  --blue:      #1f63d6;
  --blue-sf:   #eaf1fd;
  --ok:        #12805c;
  --warn:      #a35a00;
  --warn-sf:   #fff6e6;
  --danger:    #c0341d;
  --danger-sf: #fdeeea;

  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Space Grotesk", var(--sans);
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, monospace;

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

  --shadow-sm: 0 1px 2px rgba(20,22,26,.06), 0 1px 3px rgba(20,22,26,.05);
  --shadow:    0 2px 4px rgba(20,22,26,.05), 0 8px 24px rgba(20,22,26,.07);
  --shadow-lg: 0 4px 8px rgba(20,22,26,.05), 0 24px 60px rgba(20,22,26,.11);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --maxw: 1180px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #101114;
    --bg-2:      #17181c;
    --surface:   #1a1c21;
    --ink:       #f2f3f5;
    --ink-2:     #c6c9d0;
    --muted:     #969ba7;
    --line:      #2a2d34;
    --line-2:    #3a3e47;
    --accent:    #ff6d38;
    --accent-ink:#1a0e08;
    --accent-sf: #2a1710;
    --blue:      #6ea3ff;
    --blue-sf:   #14203a;
    --ok:        #3fc79a;
    --warn:      #efb45a;
    --warn-sf:   #2c2312;
    --danger:    #ff8163;
    --danger-sf: #331813;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow:    0 2px 4px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
    --shadow-lg: 0 4px 8px rgba(0,0,0,.3), 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; }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
img, svg, canvas, video { display: block; max-width: 100%; }
img { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
p { text-wrap: pretty; }
/* El atributo `hidden` del navegador es una regla debil: cualquier `display`
   nuestro la pisa y el elemento se sigue viendo. Esto lo hace mandar siempre. */
[hidden] { display: none !important; }
h1, h2, h3, h4 { text-wrap: balance; line-height: 1.1; letter-spacing: -0.02em; font-family: var(--display); font-weight: 600; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* 3. Utilidades ============================================== */
.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; top: -100px; left: 1rem; z-index: 9999;
  padding: .6rem 1rem; background: var(--ink); color: var(--bg);
  border-radius: var(--r-sm); font-weight: 600;
}
.skip-link:focus { top: 1rem; }
.hide { display: none !important; }

/* 4. Tipografia ============================================== */
h1 { font-size: clamp(1.9rem, 1.2rem + 2.6vw, 3rem); }
h2 { font-size: clamp(1.5rem, 1.1rem + 1.5vw, 2.1rem); }
h3 { font-size: clamp(1.05rem, .98rem + .35vw, 1.25rem); }
.lead { font-size: clamp(1rem, .96rem + .3vw, 1.16rem); color: var(--ink-2); }
.small { font-size: .875rem; }
.muted { color: var(--muted); }

/* 5. Componentes ============================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  padding: .78rem 1.15rem; border-radius: var(--r);
  font-weight: 600; font-size: .95rem; line-height: 1.2;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  transition: transform .18s var(--ease-out), box-shadow .18s var(--ease-out),
              background-color .18s var(--ease-out), border-color .18s var(--ease-out);
  text-align: center;
}
.btn:hover { border-color: var(--ink-2); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn--primary {
  background: var(--accent); color: var(--accent-ink); border-color: transparent;
  box-shadow: 0 6px 18px -6px color-mix(in srgb, var(--accent) 70%, transparent);
}
.btn--primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); border-color: transparent; }
.btn--big { padding: 1rem 1.35rem; font-size: 1.02rem; border-radius: var(--r-lg); width: 100%; }
.btn--ghost { background: transparent; border-color: var(--line-2); }
.btn--sm { padding: .5rem .8rem; font-size: .84rem; border-radius: var(--r-sm); }

.chip {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .3rem .65rem; border-radius: 999px;
  font-size: .78rem; font-weight: 600; letter-spacing: .01em;
  background: var(--accent-sf); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}
.chip--blue { background: var(--blue-sf); color: var(--blue); border-color: color-mix(in srgb, var(--blue) 25%, transparent); }

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

.field { display: grid; gap: .4rem; }
.field > label, .lbl {
  font-size: .82rem; font-weight: 600; color: var(--ink-2);
  letter-spacing: .01em;
}
.input, select.input, textarea.input {
  width: 100%; padding: .72rem .85rem;
  border: 1px solid var(--line-2); border-radius: var(--r);
  background: var(--bg); color: var(--ink);
  transition: border-color .16s var(--ease-out), box-shadow .16s var(--ease-out);
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.input::placeholder { color: var(--muted); }

/* 6. Herramienta ============================================= */
.site-header {
  position: sticky; top: 0; z-index: 50;
  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; min-height: 62px; }
.logo { display: inline-flex; align-items: center; gap: .55rem; font-family: var(--display); font-weight: 700; font-size: 1.12rem; letter-spacing: -.02em; }
.logo svg { width: 26px; height: 26px; }
.site-nav { display: flex; gap: 1.35rem; font-size: .9rem; font-weight: 500; color: var(--ink-2); }
.site-nav a:hover { color: var(--accent); }

.hero { padding: clamp(1.6rem, 4vw, 2.8rem) 0 .5rem; text-align: center; }
.hero .chip { margin-bottom: .9rem; }
.hero h1 { margin-bottom: .6rem; }
.hero .lead { max-width: 62ch; margin-inline: auto; }

.tool { padding-bottom: 1.4rem; }
.tool-card {
  display: grid; gap: clamp(1rem, 2.2vw, 1.6rem);
  padding: clamp(1rem, 2.4vw, 1.6rem);
  border-radius: var(--r-xl);
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
}
@media (min-width: 960px) {
  .tool-card { grid-template-columns: minmax(0, 1fr) minmax(0, 1.02fr); align-items: start; }
}

.panel { display: grid; gap: 1.1rem; align-content: start; }
.block { display: grid; gap: .7rem; }
.block__head { display: flex; align-items: center; gap: .55rem; }
.block__num {
  flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: .72rem; font-weight: 700;
  background: var(--ink); color: var(--bg);
}
.block__title { font-size: .95rem; font-weight: 650; font-family: var(--display); letter-spacing: -.01em; }

.seg { display: flex; gap: .35rem; padding: .28rem; background: var(--bg-2); border-radius: var(--r); border: 1px solid var(--line); }
.seg button {
  flex: 1 1 0; padding: .5rem .55rem; border-radius: 9px;
  font-size: .86rem; font-weight: 600; color: var(--muted);
  transition: background-color .16s var(--ease-out), color .16s var(--ease-out);
}
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: .45rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .45rem; }

.opt {
  display: grid; gap: .3rem; place-items: center;
  padding: .6rem .3rem; border-radius: var(--r);
  border: 1.5px solid var(--line); background: var(--bg);
  font-size: .76rem; font-weight: 600; color: var(--ink-2);
  transition: border-color .16s var(--ease-out), background-color .16s var(--ease-out), color .16s var(--ease-out);
}
.opt:hover { border-color: var(--line-2); }
.opt[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-sf); color: var(--accent); }
.opt svg { width: 30px; height: 30px; }
.opt--fmt { grid-template-columns: 1fr; text-align: center; padding: .7rem .4rem; gap: .25rem; }
.opt--fmt small { font-weight: 500; font-size: .69rem; color: var(--muted); line-height: 1.25; display: block; }
.opt--fmt[aria-pressed="true"] small { color: color-mix(in srgb, var(--accent) 80%, var(--ink)); }

.color-row { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.color-pick {
  display: flex; align-items: center; gap: .6rem;
  padding: .45rem .55rem; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--bg);
}
.color-pick input[type="color"] {
  flex: 0 0 auto; width: 38px; height: 38px; padding: 0; border: 1px solid var(--line-2);
  border-radius: 9px; background: none; cursor: pointer;
}
.color-pick span { font-size: .78rem; font-weight: 600; color: var(--ink-2); line-height: 1.2; }
.color-pick small { display: block; font-weight: 500; color: var(--muted); font-size: .7rem; font-family: var(--mono); text-transform: uppercase; }
.swap-btn { display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; font-weight: 600; color: var(--blue); }
.swap-btn:hover { text-decoration: underline; }

.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: .28rem; }
.emoji-grid button {
  aspect-ratio: 1; display: grid; place-items: center;
  font-size: 1.05rem; border-radius: 9px; border: 1.5px solid transparent; background: var(--bg);
  transition: border-color .14s var(--ease-out), transform .14s var(--ease-out);
  line-height: 1;
}
.emoji-grid button:hover { transform: scale(1.12); }
.emoji-grid button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-sf); }

.center-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.center-prev {
  width: 42px; height: 42px; border-radius: 10px; border: 1px dashed var(--line-2);
  display: grid; place-items: center; font-size: 1.3rem; background: var(--bg); overflow: hidden; flex: 0 0 auto;
}
.center-prev img { width: 100%; height: 100%; object-fit: contain; }

.range-row { display: flex; align-items: center; gap: .7rem; }
.range-row input[type="range"] { flex: 1 1 auto; accent-color: var(--accent); min-width: 0; }
.range-val { font-family: var(--mono); font-size: .8rem; font-weight: 600; color: var(--ink-2); min-width: 5.4ch; text-align: right; }

/* Vistas previas */
.previews { display: grid; gap: 1rem; align-content: start; }
.prev-box { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--bg-2); overflow: hidden; }
.prev-head {
  display: flex; align-items: center; justify-content: space-between; gap: .6rem;
  padding: .6rem .85rem; border-bottom: 1px solid var(--line); background: var(--surface);
}
.prev-head h3 { font-size: .85rem; font-weight: 650; }
.prev-body { padding: .9rem; display: grid; gap: .8rem; }

#qr-canvas-holder {
  display: grid; place-items: center; min-height: 190px; padding: .8rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
#qr-canvas-holder canvas, #qr-canvas-holder svg { border-radius: 6px; box-shadow: var(--shadow-sm); max-width: 100%; height: auto; }

#viewer3d {
  position: relative; width: 100%; aspect-ratio: 4 / 3; min-height: 230px;
  border-radius: var(--r); overflow: hidden; cursor: grab;
  background: radial-gradient(120% 110% at 50% 0%, var(--surface) 0%, var(--bg-2) 70%);
  touch-action: none;
}
#viewer3d:active { cursor: grabbing; }
#viewer3d canvas { width: 100% !important; height: 100% !important; display: block; }
.viewer-msg {
  position: absolute; inset: 0; display: grid; place-items: center; align-content: center; text-align: center;
  padding: 1.2rem; font-size: .86rem; color: var(--muted); gap: .5rem;
}
.viewer-hint {
  position: absolute; left: 50%; bottom: .55rem; transform: translateX(-50%);
  font-size: .72rem; color: var(--muted); background: color-mix(in srgb, var(--surface) 85%, transparent);
  padding: .18rem .6rem; border-radius: 999px; pointer-events: none; white-space: nowrap;
}
.spinner {
  width: 26px; height: 26px; border-radius: 50%; margin-inline: auto;
  border: 2.5px solid var(--line-2); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.dl-row { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.dl-note { font-size: .76rem; color: var(--muted); text-align: center; }

/* Avisos de impresion */
.notes { display: grid; gap: .4rem; }
.note {
  display: flex; gap: .5rem; align-items: flex-start;
  padding: .55rem .7rem; border-radius: var(--r-sm); font-size: .8rem; line-height: 1.45;
  border: 1px solid transparent;
}
.note b { font-weight: 650; }
.note--ok     { background: color-mix(in srgb, var(--ok) 9%, transparent); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 22%, transparent); }
.note--warn   { background: var(--warn-sf); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 28%, transparent); }
.note--danger { background: var(--danger-sf); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 28%, transparent); }
.note svg { flex: 0 0 auto; width: 15px; height: 15px; margin-top: .18rem; }

.privacy {
  display: flex; align-items: center; justify-content: center; gap: .5rem; flex-wrap: wrap;
  margin-top: 1rem; font-size: .84rem; color: var(--muted); text-align: center;
}
.privacy svg { width: 15px; height: 15px; }

.nojs { padding: 1rem; border-radius: var(--r); background: var(--warn-sf); color: var(--warn); font-size: .9rem; }

/* 7. Secciones =============================================== */
section { scroll-margin-top: 80px; }
.sec { padding: clamp(2.4rem, 6vw, 4.2rem) 0; }
.sec--alt { background: var(--bg-2); border-block: 1px solid var(--line); }
.sec__head { max-width: 62ch; margin-bottom: clamp(1.4rem, 3vw, 2.2rem); }
.sec__head h2 { margin-bottom: .5rem; }

.steps { display: grid; gap: 1rem; }
@media (min-width: 720px) { .steps { grid-template-columns: repeat(3, 1fr); } }
.step { padding: 1.3rem; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); }
.step__n {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: var(--accent-sf); color: var(--accent); font-family: var(--display);
  font-weight: 700; font-size: 1rem; margin-bottom: .8rem;
}
.step h3 { margin-bottom: .35rem; }
.step p { font-size: .9rem; color: var(--ink-2); }

.ideas { display: grid; gap: .9rem; }
@media (min-width: 640px) { .ideas { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .ideas { grid-template-columns: repeat(3, 1fr); } }
.idea { padding: 1.2rem; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); transition: transform .2s var(--ease-out), box-shadow .2s var(--ease-out); }
.idea:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.idea svg { width: 26px; height: 26px; color: var(--accent); margin-bottom: .7rem; }
.idea h3 { margin-bottom: .3rem; }
.idea p { font-size: .875rem; color: var(--ink-2); }

.prose { max-width: 72ch; }
.prose h3 { margin: 1.6rem 0 .5rem; }
.prose p { margin-bottom: .85rem; color: var(--ink-2); }
.prose ul { margin: 0 0 .9rem 1.1rem; color: var(--ink-2); }
.prose li { margin-bottom: .35rem; }
.prose strong { color: var(--ink); font-weight: 650; }

.faq { max-width: 76ch; display: grid; gap: .5rem; }
.faq details { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); overflow: hidden; }
.faq summary {
  cursor: pointer; list-style: none; padding: .95rem 1.1rem;
  font-weight: 600; font-size: .96rem; display: flex; gap: .8rem; align-items: flex-start; justify-content: space-between;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+"; flex: 0 0 auto; font-family: var(--mono); font-size: 1.2rem; line-height: 1; color: var(--accent);
  transition: transform .2s var(--ease-out);
}
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details > div { padding: 0 1.1rem 1.05rem; font-size: .9rem; color: var(--ink-2); }

.site-footer { padding: 2.4rem 0; border-top: 1px solid var(--line); background: var(--bg-2); font-size: .86rem; color: var(--muted); }
.site-footer .wrap { display: grid; gap: 1rem; }
.foot-links { display: flex; flex-wrap: wrap; gap: 1.1rem; }
.foot-links a:hover { color: var(--accent); }

/* 8. Anuncios (SOLO huecos - el propietario pega su codigo) === */
.ad-slot {
  display: grid; place-items: center; align-content: center; gap: .2rem; text-align: center;
  border: 1.5px dashed var(--line-2); border-radius: var(--r);
  background: repeating-linear-gradient(135deg, transparent 0 9px, color-mix(in srgb, var(--line) 45%, transparent) 9px 10px);
  color: var(--muted);
}
.ad-slot__label { font-size: .68rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.ad-slot__size { font-size: .66rem; font-family: var(--mono); opacity: .7; }
.ad-slot--leaderboard { min-height: 100px; width: 100%; max-width: 970px; margin: 1.6rem auto 0; }
.ad-slot--incontent { min-height: 260px; width: 100%; max-width: 336px; margin: 2rem auto; }
.ad-slot--dialog { min-height: 250px; width: 100%; margin-block: .9rem; }
.ad-slot--corner { min-height: 92px; width: 100%; }

dialog.ad-dialog {
  border: 1px solid var(--line); border-radius: var(--r-xl); padding: 0;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg);
  width: min(92vw, 400px);
}
dialog.ad-dialog::backdrop { background: rgba(10,11,13,.55); backdrop-filter: blur(3px); }
.ad-dialog__in { padding: 1.1rem 1.2rem 1.2rem; }
.ad-dialog__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: .2rem; }
.ad-dialog__head h3 { font-size: 1.05rem; }
.ad-dialog__close {
  flex: 0 0 auto; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bg-2); color: var(--ink-2); font-size: 1.15rem; line-height: 1;
}
.ad-dialog__close:hover { background: var(--line); }

.ad-toast {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 80;
  width: min(88vw, 288px); padding: .75rem;
  border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  transform: translateY(150%); opacity: 0; pointer-events: none;
  transition: transform .45s var(--ease-out), opacity .45s var(--ease-out);
}
.ad-toast[data-open="true"] { transform: translateY(0); opacity: 1; pointer-events: auto; }
.ad-toast__head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .4rem; }
.ad-toast__head span { font-size: .66rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.ad-toast__close { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); font-size: 1rem; line-height: 1; }
.ad-toast__close:hover { background: var(--bg-2); color: var(--ink); }

/* 9. Responsive ============================================== */
@media (max-width: 719px) {
  .site-nav { display: none; }
  .dl-row { grid-template-columns: 1fr; }
  .emoji-grid { grid-template-columns: repeat(6, 1fr); }
  .ad-toast { left: 1rem; right: 1rem; width: auto; }
}
/* Movil y tablet: los envoltorios desaparecen y las piezas se intercalan,
   para que la imagen del codigo salga justo debajo del campo del enlace. */
@media (max-width: 959px) {
  .panel, .previews { display: contents; }
  .block--contenido { order: 1; }
  .prev-box--2d     { order: 2; }
  .block--diseno    { order: 3; }
  .block--objeto    { order: 4; }
  .prev-box--3d     { order: 5; }
}

/* 10. Reduced motion - solo lo intrusivo ===================== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .spinner { animation-duration: 1.8s; }
  .ad-toast { transition-duration: .18s; }
  .idea:hover { transform: none; }
}
