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

/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg:        #F6F5F2;
  --surface:   #FFFFFF;
  --surface-2: #FAF9F7;
  --line:      #E3E0DA;
  --line-soft: #EDEAE4;
  --ink:       #17181D;
  --ink-soft:  #565A63;
  --ink-mute:  #8A8E97;
  --accent:    #E1552B;
  --accent-ink:#FFFFFF;
  --accent-soft:#FDEEE8;
  --ok:        #1F7A4D;
  --ok-soft:   #E6F4EC;
  --warn:      #9A6100;
  --warn-soft: #FDF1DC;
  --bad:       #B3261E;
  --bad-soft:  #FCE9E7;

  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --disp: "Space Grotesk", var(--sans);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --maxw: 1180px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow-sm: 0 1px 2px rgba(20, 22, 28, .06), 0 1px 3px rgba(20, 22, 28, .04);
  --shadow-md: 0 4px 14px rgba(20, 22, 28, .07), 0 1px 3px rgba(20, 22, 28, .05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #101116;
    --surface:   #191B21;
    --surface-2: #1F212A;
    --line:      #2C2F39;
    --line-soft: #24262F;
    --ink:       #F1F0EC;
    --ink-soft:  #A9ADB7;
    --ink-mute:  #7E838E;
    --accent:    #FF6B3D;
    --accent-ink:#1A0D07;
    --accent-soft:#2A1912;
    --ok:        #63C795;
    --ok-soft:   #14291F;
    --warn:      #E9B45C;
    --warn-soft: #2C2313;
    --bad:       #F08A80;
    --bad-soft:  #2E1815;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, .45);
  }
}

/* =============================================================
   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.6;
  color: var(--ink);
  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; }
input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
p { text-wrap: pretty; }
h1, h2, h3, h4 { text-wrap: balance; line-height: 1.12; letter-spacing: -0.02em; font-family: var(--disp); }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
fieldset { border: 0; padding: 0; min-width: 0; }
legend { padding: 0; }

/* =============================================================
   3. Utilidades
   ============================================================= */
.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
.is-hidden { display: none !important; }
.skip-link {
  position: fixed; top: -100px; left: 1rem; z-index: 999;
  padding: .6rem 1rem; background: var(--ink); color: var(--bg);
  border-radius: var(--r-sm); font-weight: 600;
}
.skip-link:focus { top: 1rem; }

/* =============================================================
   4. Tipografía de secciones
   ============================================================= */
h1 { font-size: clamp(1.85rem, 4.6vw, 3rem); font-weight: 700; }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); font-weight: 700; }
h3 { font-size: 1.06rem; font-weight: 700; }
.section { padding-block: clamp(2.5rem, 6vw, 4.5rem); }
.section > h2 { margin-bottom: 1.6rem; }

/* =============================================================
   5. Componentes
   ============================================================= */

/* -- Cabecera -- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; height: 60px; }
.brand { display: inline-flex; align-items: center; gap: .55rem; font-family: var(--disp); font-weight: 700; font-size: 1.2rem; letter-spacing: -.03em; }
.brand-mark { color: var(--accent); display: grid; place-items: center; }
.brand-accent { color: var(--accent); }
.header-nav { display: none; gap: 1.4rem; margin-left: auto; margin-right: 1.2rem; font-size: .9rem; color: var(--ink-soft); }
.header-nav a:hover { color: var(--ink); }

/* -- Selector de idioma -- */
.lang-switch {
  display: inline-flex; align-items: center; gap: 2px; flex: none;
  padding: 3px; border: 1px solid var(--line); border-radius: 99px;
  background: var(--surface-2);
}
.lang-switch a {
  padding: .22rem .6rem; border-radius: 99px;
  font-size: .76rem; font-weight: 700; letter-spacing: .04em;
  color: var(--ink-mute);
  transition: color .18s var(--ease-out), background-color .18s var(--ease-out);
}
.lang-switch a:hover { color: var(--ink); }
.lang-switch a.is-active { background: var(--accent); color: var(--accent-ink); }

/* -- Hero -- */
.hero { padding-block: clamp(1.6rem, 4vw, 2.8rem) 1.2rem; text-align: center; }
.hero-sub { max-width: 60ch; margin: .85rem auto 0; color: var(--ink-soft); font-size: clamp(.98rem, 1.5vw, 1.08rem); }
.hero-sub strong { color: var(--ink); }

/* -- Botones -- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  flex-direction: column;
  padding: .72rem 1.15rem; border-radius: var(--r-md);
  font-weight: 600; font-size: .93rem; line-height: 1.2;
  transition: transform .18s var(--ease-out), background-color .18s var(--ease-out), border-color .18s var(--ease-out);
  border: 1px solid transparent; text-align: center;
}
.btn small { display: block; font-weight: 400; font-size: .74rem; opacity: .8; letter-spacing: 0; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }
.btn-solid { background: var(--accent); color: var(--accent-ink); }
.btn-solid:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink-mute); }
.btn-sm { padding: .45rem .8rem; font-size: .84rem; border-radius: var(--r-sm); }
.btn-big { padding: .95rem 1.3rem; font-size: 1rem; }

/* -- Tarjeta de herramienta -- */
.tool-section { padding-bottom: .5rem; }
.tool-card {
  display: grid; gap: clamp(1.2rem, 3vw, 2rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: clamp(1rem, 3vw, 1.75rem);
  box-shadow: var(--shadow-md);
}
.panel { display: grid; gap: 1.5rem; align-content: start; min-width: 0; }
.group { display: grid; gap: .7rem; }
.group-title {
  display: flex; align-items: center; gap: .5rem;
  font-family: var(--disp); font-weight: 700; font-size: 1rem;
  margin-bottom: .1rem;
}
.step-dot {
  display: grid; place-items: center; width: 22px; height: 22px; flex: none;
  border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  font-size: .75rem; font-weight: 700;
}
.field { display: grid; gap: .35rem; min-width: 0; }
.field-label { font-size: .8rem; font-weight: 600; color: var(--ink-soft); letter-spacing: .01em; }
.field-label small { font-weight: 400; color: var(--ink-mute); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.field-narrow { max-width: 100%; }
input[type="text"], input[type="url"], select {
  width: 100%; padding: .62rem .75rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  transition: border-color .18s var(--ease-out);
}
input[type="text"]:focus, select:focus { border-color: var(--accent); outline: none; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-mute) 50%), linear-gradient(135deg, var(--ink-mute) 50%, transparent 50%); background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 2rem; }
.hint { font-size: .79rem; color: var(--ink-mute); line-height: 1.45; }

/* -- Pestañas -- */
.tabs { display: inline-flex; gap: .25rem; padding: .25rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); }
.tab { padding: .4rem .9rem; border-radius: var(--r-sm); font-size: .86rem; font-weight: 600; color: var(--ink-soft); }
.tab.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* -- Estilos de puntos -- */
.style-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
.style-opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.style-box {
  display: grid; gap: .3rem; justify-items: center; padding: .55rem .3rem;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface-2); cursor: pointer;
  font-size: .72rem; color: var(--ink-soft);
  transition: border-color .18s var(--ease-out), background-color .18s var(--ease-out);
}
.style-box svg { width: 26px; height: 26px; fill: var(--ink-soft); }
.style-opt input:checked + .style-box { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.style-opt input:checked + .style-box svg { fill: var(--accent); }
.style-opt input:focus-visible + .style-box { outline: 2px solid var(--accent); outline-offset: 2px; }

/* -- Colores -- */
.colors-row { gap: .7rem; }
.color-input { display: flex; align-items: center; gap: .5rem; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); padding: .28rem .5rem .28rem .28rem; }
input[type="color"] { width: 38px; height: 30px; padding: 0; border: 0; border-radius: 6px; background: none; cursor: pointer; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 1px solid var(--line); border-radius: 6px; }
.color-input output { font-size: .78rem; font-variant-numeric: tabular-nums; color: var(--ink-soft); text-transform: uppercase; }

/* -- Emojis -- */
.emoji-row { display: flex; flex-wrap: wrap; gap: .35rem; }
.emoji-btn {
  width: 38px; height: 38px; font-size: 1.15rem; line-height: 1;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2);
  transition: border-color .18s var(--ease-out), background-color .18s var(--ease-out);
}
.emoji-btn:hover { border-color: var(--ink-mute); }
.emoji-btn.is-active { border-color: var(--accent); background: var(--accent-soft); }
.center-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* -- Formatos 3D -- */
.fmt-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.fmt-opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.fmt-box {
  display: grid; gap: .15rem; justify-items: center; text-align: center;
  padding: .7rem .35rem; border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface-2); cursor: pointer;
  transition: border-color .18s var(--ease-out), background-color .18s var(--ease-out);
}
.fmt-box svg { width: 40px; height: 32px; fill: var(--ink-soft); }
.fmt-box strong { font-size: .82rem; }
.fmt-box em { font-style: normal; font-size: .7rem; color: var(--ink-mute); }
.fmt-opt input:checked + .fmt-box { border-color: var(--accent); background: var(--accent-soft); }
.fmt-opt input:checked + .fmt-box svg { fill: var(--accent); }
.fmt-opt input:focus-visible + .fmt-box { outline: 2px solid var(--accent); outline-offset: 2px; }

/* -- Rango -- */
input[type="range"] { width: 100%; accent-color: var(--accent); }

/* -- Avisos de impresión -- */
.warnings { display: grid; gap: .4rem; }
.warn-item {
  display: flex; gap: .5rem; align-items: flex-start;
  padding: .55rem .7rem; border-radius: var(--r-sm);
  font-size: .8rem; line-height: 1.4;
}
.warn-item b { font-weight: 600; }
.warn-ok  { background: var(--ok-soft);  color: var(--ok); }
.warn-mid { background: var(--warn-soft); color: var(--warn); }
.warn-bad { background: var(--bad-soft); color: var(--bad); }

/* -- Vistas previas -- */
.preview { display: grid; gap: 1.5rem; align-content: start; min-width: 0; }
.preview-block { display: grid; gap: .7rem; }
.preview-title { font-size: .95rem; display: flex; align-items: center; gap: .5rem; }
.tag { font-family: var(--sans); font-weight: 500; font-size: .7rem; color: var(--ink-mute); border: 1px solid var(--line); border-radius: 99px; padding: .1rem .5rem; }
.qr-holder {
  display: grid; place-items: center; padding: 1rem;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md);
  min-height: 220px;
}
.qr-holder canvas, .qr-holder svg { width: min(100%, 260px); height: auto; border-radius: 6px; }
.viewer {
  position: relative; display: grid; place-items: center;
  width: 100%; aspect-ratio: 4 / 3; min-height: 240px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md);
  overflow: hidden; touch-action: none;
}
.viewer canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
.viewer-msg {
  position: absolute; inset: auto; padding: 1rem 1.4rem; text-align: center;
  font-size: .84rem; color: var(--ink-mute); max-width: 32ch;
}
.dl-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; }
.dl-row .btn { flex: 1 1 auto; }
.dl-row .field { flex: 0 0 110px; }
.dl-row-3d .btn-big { flex: 1 1 100%; }
.status { font-size: .8rem; color: var(--ink-mute); min-height: 1.2em; }
.status.is-bad { color: var(--bad); }

/* -- Insignias bajo la herramienta -- */
.privacy-badge {
  margin-top: 1rem; padding: .8rem 1rem;
  background: var(--ok-soft); color: var(--ok);
  border-radius: var(--r-md); font-size: .86rem;
}
.privacy-badge strong { color: inherit; }
.limits { margin-top: .5rem; font-size: .79rem; color: var(--ink-mute); }

/* =============================================================
   6. Secciones de contenido
   ============================================================= */
.steps { list-style: none; padding: 0; display: grid; gap: 1rem; grid-template-columns: 1fr; counter-reset: none; }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.25rem; display: grid; gap: .4rem; align-content: start; }
.step-num { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-family: var(--disp); font-weight: 700; }
.step p { font-size: .9rem; color: var(--ink-soft); }

.cards { display: grid; gap: 1rem; grid-template-columns: 1fr; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.2rem; display: grid; gap: .35rem; align-content: start; }
.card-ico { font-size: 1.5rem; line-height: 1; }
.card p { font-size: .88rem; color: var(--ink-soft); }

.prose { max-width: 78ch; }
.prose h3 { margin-top: 1.7rem; margin-bottom: .4rem; font-size: 1.08rem; }
.prose p { margin-bottom: .8rem; color: var(--ink-soft); }
.prose strong { color: var(--ink); }

.faq { display: grid; gap: .5rem; }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.faq summary { padding: .9rem 1.1rem; cursor: pointer; font-weight: 600; font-size: .93rem; list-style: none; display: flex; justify-content: space-between; gap: 1rem; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--accent); font-weight: 700; flex: none; }
.faq details[open] summary::after { content: "–"; }
.faq details p { padding: 0 1.1rem 1rem; font-size: .89rem; color: var(--ink-soft); }

/* -- Pie -- */
.site-footer { border-top: 1px solid var(--line-soft); margin-top: 2rem; padding-block: 2rem; background: var(--surface-2); }
.footer-inner { display: grid; gap: .7rem; }
.footer-brand { font-family: var(--disp); font-weight: 700; }
.footer-nav { display: flex; flex-wrap: wrap; gap: 1.2rem; font-size: .88rem; color: var(--ink-soft); }
.footer-nav a:hover { color: var(--accent); }
.footer-note { font-size: .76rem; color: var(--ink-mute); max-width: 70ch; }

/* =============================================================
   7. Huecos de anuncios (placeholders — sin código de terceros)
   ============================================================= */
.ad-slot {
  position: relative; display: grid; place-items: center;
  border: 1px dashed color-mix(in srgb, var(--ink-mute) 55%, transparent);
  border-radius: var(--r-md);
  background: repeating-linear-gradient(45deg, transparent, transparent 10px, color-mix(in srgb, var(--ink-mute) 7%, transparent) 10px, color-mix(in srgb, var(--ink-mute) 7%, transparent) 20px);
}
.ad-label { font-size: .7rem; letter-spacing: .18em; font-weight: 600; color: var(--ink-mute); }
.ad-leaderboard { min-height: 100px; margin-block: 1.5rem; }
.ad-incontent { min-height: 250px; margin-block: 1rem 2rem; }
.ad-popup { width: 100%; min-height: 250px; }
.ad-corner { width: 100%; min-height: 92px; }

.ad-dialog {
  margin: auto;                       /* el reset global de margin lo descentra */
  border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 1.1rem; width: min(92vw, 340px);
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-md);
}
.ad-dialog::backdrop { background: rgba(10, 11, 15, .55); backdrop-filter: blur(2px); }
.ad-dialog-head { display: flex; align-items: start; justify-content: space-between; gap: .5rem; margin-bottom: .8rem; }
.ad-dialog-head p { font-weight: 600; font-size: .95rem; }
.ad-dialog .btn { width: 100%; margin-top: .8rem; }
.ad-close {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.3rem; line-height: 1;
  color: var(--ink-soft); background: var(--surface-2); border: 1px solid var(--line);
}
.ad-close:hover { color: var(--ink); }

.ad-toast {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 60;
  width: min(88vw, 320px);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: .55rem; box-shadow: var(--shadow-md);
}
.ad-toast .ad-close { position: absolute; top: -10px; right: -10px; background: var(--surface); }

/* =============================================================
   8. Responsive
   ============================================================= */
@media (min-width: 540px) {
  .cards, .steps { grid-template-columns: repeat(2, 1fr); }
  .dl-row-3d .btn-big { flex: 1 1 auto; }
}
@media (min-width: 720px) {
  .header-nav { display: flex; }
  .steps { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 960px) {
  /* Escritorio: controles a la izquierda (dos filas), vistas previas a la derecha.
     En movil el orden del HTML manda: contenido -> vista previa -> diseno. */
  .tool-card {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "a p" "b p";
    align-items: start;
  }
  .panel-a { grid-area: a; }
  .panel-b { grid-area: b; }
  .preview { grid-area: p; }
  .cards { grid-template-columns: repeat(3, 1fr); }
  .hero { padding-block: clamp(2rem, 5vw, 3.4rem) 1.6rem; }
}
@media (min-width: 1280px) {
  .tool-card { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
}

/* =============================================================
   9. Movimiento reducido — solo efectos intrusivos
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
