/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #f6f6fb;
  --surface: #ffffff;
  --surface-2: #f0f0f8;
  --ink: #15151f;
  --muted: #5c5c6e;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --accent-soft: #eceafc;
  --accent-2: #0d9488;
  --border: #e2e2ee;
  --danger: #c0361f;
  --danger-bg: #fbe9e5;
  --warn: #a4650c;
  --warn-bg: #fbf0dc;
  --ok: #157a4a;
  --ok-bg: #e4f5ec;
  --radius: 14px;
  --radius-sm: 9px;
  --sans: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow-card: 0 1px 2px rgba(20,20,35,.04), 0 8px 24px -12px rgba(20,20,35,.12);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101018;
    --surface: #181822;
    --surface-2: #1f1f2b;
    --ink: #f1f1f7;
    --muted: #a3a3b5;
    --accent: #8b83f7;
    --accent-ink: #14141f;
    --accent-soft: #262244;
    --accent-2: #35c9b6;
    --border: #2b2b3a;
    --danger: #ff8a75;
    --danger-bg: #3a1e18;
    --warn: #f0b757;
    --warn-bg: #3a2c11;
    --ok: #6bd6a3;
    --ok-bg: #113627;
    --shadow-card: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.5);
  }
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  overscroll-behavior-y: none;
}
img, svg, video { 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.15; letter-spacing: -0.01em; font-weight: 800; }
::selection { background: var(--accent); color: var(--accent-ink); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

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

/* =============================================================
   3. Utilities
   ============================================================= */
.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 1.25rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .8rem 1.3rem; border-radius: var(--radius-sm); font-weight: 700; font-size: .95rem;
  transition: transform .15s var(--ease-out), background .15s var(--ease-out), box-shadow .15s var(--ease-out);
  white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { box-shadow: 0 6px 20px -8px var(--accent); }
.btn-secondary { background: var(--surface-2); color: var(--ink); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--accent-soft); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-link { background: none; color: var(--muted); text-decoration: underline; font-weight: 600; padding: .4rem .2rem; }
.btn-small { padding: .55rem .9rem; font-size: .85rem; }
.file-btn { cursor: pointer; }

/* =============================================================
   4. Header / footer
   ============================================================= */
.site-header { border-bottom: 1px solid var(--border); padding: 1rem 0; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: .5rem; font-weight: 800; font-size: 1.1rem; color: var(--ink); }
.logo svg { color: var(--accent); }
.header-tag { font-size: .82rem; color: var(--muted); font-weight: 600; }

.site-footer { border-top: 1px solid var(--border); margin-top: 3rem; padding: 1.5rem 0 2.5rem; color: var(--muted); font-size: .9rem; }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.footer-links { display: flex; gap: 1.25rem; }
.footer-links a:hover { color: var(--accent); }

/* =============================================================
   5. Hero
   ============================================================= */
.hero { padding: 2rem 0 1.5rem; text-align: center; }
.hero h1 { font-size: clamp(1.6rem, 4.5vw, 2.5rem); max-width: 46rem; margin: 0 auto .8rem; }
.hero-sub { color: var(--muted); font-size: clamp(.95rem, 2vw, 1.1rem); max-width: 42rem; margin: 0 auto; }

.section-heading { text-align: center; max-width: 42rem; margin: 0 auto 1.5rem; }
.section-heading h2 { font-size: clamp(1.3rem, 3vw, 1.7rem); margin-bottom: .5rem; }
.section-heading p { color: var(--muted); }

.section-block { padding: 2.5rem 0; }
.section-block > h2 { font-size: clamp(1.3rem, 3vw, 1.7rem); margin-bottom: 1.25rem; text-align: center; }

/* =============================================================
   6. Tool card
   ============================================================= */
.tool-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-card); padding: 1.25rem;
  margin: 1.25rem 0;
}
.js-needed { padding: 1rem; background: var(--warn-bg); color: var(--warn); border-radius: var(--radius-sm); font-weight: 600; }

.tool-grid { display: grid; gap: 1.5rem; grid-template-columns: 1fr; }
.tool-controls { display: flex; flex-direction: column; gap: 1.1rem; }
/* Mobile-first: on the primary 2D tool, show the live result + download
   buttons BEFORE the customization controls, so the tool is usable
   (see a QR, download it) above the fold on a 375x812 phone without
   scrolling. Desktop's two-column layout (>=720px) resets this — at that
   width both halves are already visible side by side. */
#qr-tool .tool-preview { order: -1; }
.field-group { display: flex; flex-direction: column; gap: .45rem; }
.field-group label { font-size: .82rem; font-weight: 700; color: var(--muted); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; align-items: end; }
.checkbox-inline { display: flex; align-items: center; gap: .4rem; font-size: .85rem; font-weight: 600; color: var(--muted); }

input[type="text"], input[type="password"], textarea, select {
  width: 100%; padding: .7rem .85rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font: inherit; font-size: .95rem;
  transition: border-color .15s var(--ease-out);
}
input[type="text"]:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 3.2rem; }
input[type="color"] {
  width: 100%; height: 2.7rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .2rem; background: var(--surface); cursor: pointer;
}

.mode-tabs { display: inline-flex; background: var(--surface-2); border-radius: var(--radius-sm); padding: .25rem; gap: .25rem; }
.mode-tab { padding: .55rem 1rem; border-radius: 7px; font-weight: 700; font-size: .88rem; color: var(--muted); transition: background .15s var(--ease-out), color .15s var(--ease-out); }
.mode-tab.is-active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.style-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; }
.style-btn {
  display: flex; align-items: center; gap: .55rem; padding: .6rem .7rem; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-weight: 600; font-size: .85rem; color: var(--ink);
  transition: border-color .15s var(--ease-out), background .15s var(--ease-out);
}
.style-btn.is-active { border-color: var(--accent); background: var(--accent-soft); }
.style-swatch { width: 20px; height: 20px; border-radius: 4px; background: var(--ink); flex: none; }
.style-swatch--clasico { border-radius: 3px; }
.style-swatch--redondeado { border-radius: 7px; }
.style-swatch--puntos { border-radius: 50%; }
.style-swatch--elegante { border-radius: 40% 10% 40% 10%; }

.center-image-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.emoji-picker { display: flex; flex-wrap: wrap; gap: .25rem; }
.emoji-btn {
  width: 2.1rem; height: 2.1rem; border-radius: var(--radius-sm); font-size: 1.05rem;
  border: 1px solid var(--border); display: flex; align-items: center; justify-content: center;
  transition: border-color .15s var(--ease-out), background .15s var(--ease-out);
}
.emoji-btn.is-active { border-color: var(--accent); background: var(--accent-soft); }
.center-hint { font-size: .8rem; color: var(--muted); }

.tool-preview { display: flex; flex-direction: column; gap: .9rem; align-items: center; }
.qr-preview-frame {
  width: 100%; max-width: 300px; aspect-ratio: 1 / 1; background: var(--surface-2);
  border-radius: var(--radius); display: flex; align-items: center; justify-content: center; overflow: hidden;
  border: 1px solid var(--border);
}
#qr-preview { display: flex; align-items: center; justify-content: center; }
#qr-preview canvas, #qr-preview img, #qr-preview svg { max-width: 100%; max-height: 100%; }

.download-row { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: center; width: 100%; }
.download-row--secondary { justify-content: center; }
.download-row .btn { flex: 1 1 auto; min-width: 9rem; }

.privacy-badge { font-size: .88rem; color: var(--ok); font-weight: 600; margin-top: .5rem; }
.limits-text { font-size: .82rem; color: var(--muted); margin-top: .3rem; }

/* --- 3D format selector --- */
.format-grid { display: grid; grid-template-columns: 1fr; gap: .6rem; }
.format-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: .15rem; padding: .7rem .85rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm); text-align: left;
  transition: border-color .15s var(--ease-out), background .15s var(--ease-out);
}
.format-btn.is-active { border-color: var(--accent-2); background: color-mix(in srgb, var(--accent-2) 12%, transparent); }
.format-label { font-weight: 700; font-size: .92rem; }
.format-hint { font-size: .78rem; color: var(--muted); }

.print-warnings { display: flex; flex-direction: column; gap: .5rem; }
.warning-item { padding: .6rem .8rem; border-radius: var(--radius-sm); font-size: .84rem; font-weight: 600; display: flex; gap: .5rem; align-items: flex-start; }
.warning-item--danger { background: var(--danger-bg); color: var(--danger); }
.warning-item--warn { background: var(--warn-bg); color: var(--warn); }
.warning-item--ok { background: var(--ok-bg); color: var(--ok); }
.warning-item--info { background: var(--surface-2); color: var(--muted); }

.viewer3d-frame {
  width: 100%; max-width: 320px; aspect-ratio: 1 / 1; background: var(--surface-2);
  border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); position: relative;
}
#viewer3d { width: 100%; height: 100%; position: relative; }
#viewer3d canvas { width: 100% !important; height: 100% !important; display: block; }
.viewer3d-status {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 1rem; font-size: .85rem; color: var(--muted); font-weight: 600;
}
#viewer3d[data-state="ready"] .viewer3d-status { display: none; }

/* =============================================================
   7. Ad slots
   ============================================================= */
.ad-slot {
  border: 2px dashed var(--border); border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-weight: 700; letter-spacing: .08em; font-size: .78rem;
  background: var(--surface-2);
}
.ad-slot--banner { min-height: 90px; margin: 1.5rem 0; }
.ad-slot--incontent { min-height: 250px; margin: 1.5rem 0; }
.ad-slot--popup { min-height: 200px; width: 100%; margin-bottom: .8rem; }
.ad-slot--corner { min-height: 100px; width: 100%; }

/* =============================================================
   8. Steps / use-cases / FAQ
   ============================================================= */
.steps-grid { display: grid; gap: 1.1rem; grid-template-columns: 1fr; }
.step-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.4rem; }
.step-icon { width: 34px; height: 34px; color: var(--accent); margin-bottom: .8rem; }
.step-card h3 { font-size: 1.02rem; margin-bottom: .4rem; }
.step-card p { color: var(--muted); font-size: .9rem; }

.usecase-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
.usecase-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1.1rem; }
.usecase-card h3 { font-size: .95rem; margin-bottom: .35rem; color: var(--accent); }
.usecase-card p { font-size: .87rem; color: var(--muted); }

.faq-list { display: flex; flex-direction: column; gap: .6rem; max-width: 46rem; margin: 0 auto; }
.faq-list details {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .9rem 1.1rem;
}
.faq-list summary { font-weight: 700; cursor: pointer; font-size: .95rem; }
.faq-list p { margin-top: .6rem; color: var(--muted); font-size: .9rem; }

/* =============================================================
   9. Ad popup dialog + corner toast
   ============================================================= */
dialog#ad-popup {
  border: none; border-radius: var(--radius); padding: 1.2rem; max-width: 360px; width: calc(100% - 2rem);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-card); position: relative;
}
dialog#ad-popup::backdrop { background: rgba(10,10,20,.5); }
.dialog-close {
  position: absolute; top: .6rem; right: .6rem; width: 1.8rem; height: 1.8rem; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 1.2rem; color: var(--muted);
  background: var(--surface-2);
}

.corner-toast {
  position: fixed; bottom: 1rem; right: 1rem; z-index: 500; width: min(260px, calc(100vw - 2rem));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-card); padding: .9rem; animation: toastIn .4s var(--ease-out);
}
.corner-toast-close {
  position: absolute; top: .35rem; right: .5rem; font-size: 1.05rem; color: var(--muted); width: 1.6rem; height: 1.6rem;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* =============================================================
   10. Responsive
   ============================================================= */
@media (min-width: 720px) {
  .tool-grid { grid-template-columns: 1.15fr 1fr; align-items: start; }
  #qr-tool .tool-preview { order: 0; } /* side-by-side now, restore source order */
  .format-grid { grid-template-columns: repeat(3, 1fr); }
  .steps-grid { grid-template-columns: repeat(3, 1fr); }
  .usecase-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 960px) {
  .usecase-grid { grid-template-columns: repeat(3, 1fr); }
}

/* =============================================================
   11. Reduced motion (only intrusive effects)
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  .corner-toast { animation: none; }
}

/* =============================================================
   12. Legal skeleton pages
   ============================================================= */
.legal-page { max-width: 46rem; margin: 0 auto; padding: 2.5rem 1.25rem 4rem; }
.legal-page h1 { font-size: 1.7rem; margin-bottom: 1.2rem; }
.legal-page h2 { font-size: 1.1rem; margin: 1.6rem 0 .5rem; }
.legal-page p { color: var(--muted); margin-bottom: .8rem; }
.legal-page .todo { background: var(--warn-bg); color: var(--warn); padding: .8rem 1rem; border-radius: var(--radius-sm); font-size: .85rem; font-weight: 600; }
