/* ==========================================================================
   QRelieve — generador de QR para imprimir en 3D
   ========================================================================== */

:root {
  --ink: #16181d;
  --ink-2: #3d424d;
  --muted: #6b7280;
  --line: #e4e4e0;
  --bg: #f7f6f2;
  --card: #ffffff;
  --accent: #f2622e;
  --accent-ink: #c94716;
  --ok: #157a42;
  --warn: #a15c00;
  --bad: #b42318;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(22, 24, 29, .05), 0 8px 24px rgba(22, 24, 29, .06);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Space Grotesk", var(--font);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  overflow-x: hidden;
}
img, svg, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-ink); }
[hidden] { display: none !important; }

.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 12px; border-radius: 8px; z-index: 50; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 13px; }

/* ---------- Header ---------- */
.site-header { background: var(--card); border-bottom: 1px solid var(--line); }
.header-row { display: flex; align-items: center; justify-content: space-between; height: 58px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-family: var(--display); font-weight: 700; font-size: 20px; letter-spacing: -.01em; }
.brand-mark { width: 30px; height: 30px; }
.header-nav { display: flex; gap: 22px; }
.header-nav a { color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: 15px; }
.header-nav a:hover { color: var(--accent-ink); }

/* ---------- Hero ---------- */
.hero { padding-top: 26px; padding-bottom: 18px; }
.hero h1 {
  font-family: var(--display);
  font-size: clamp(26px, 4.2vw, 44px);
  line-height: 1.08;
  letter-spacing: -.02em;
  margin: 0 0 10px;
  max-width: 22ch;
}
.lead { margin: 0; color: var(--ink-2); font-size: clamp(15px, 1.6vw, 18px); max-width: 70ch; }

/* ---------- Tool layout ---------- */
.tool {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:
    "content previews"
    "design  previews"
    "object  previews";
  align-items: start;
}
.p-content { grid-area: content; }
.p-design  { grid-area: design; }
.p-object  { grid-area: object; }
.previews  { grid-area: previews; position: sticky; top: 14px; display: grid; gap: 16px; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  min-width: 0;
}
.panel-title { display: flex; align-items: center; gap: 10px; font-size: 17px; margin: 0 0 14px; letter-spacing: -.01em; }
.panel-title.small { font-size: 15px; margin: 0; }
.step { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 14px; flex: none; }
.label { margin: 14px 0 8px; font-size: 14px; font-weight: 600; color: var(--ink-2); }

/* Chips de contenido */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  border: 1px solid var(--line); background: var(--bg); border-radius: 999px;
  padding: 7px 12px; font-size: 14px; font-weight: 500; cursor: pointer; transition: border-color .15s, background .15s;
}
.chip:hover { border-color: #c9c9c2; }
.chip.is-on { background: var(--ink); color: #fff; border-color: var(--ink); }

input[type="text"], textarea, select {
  width: 100%; border: 1.5px solid var(--line); background: #fff; border-radius: 12px;
  padding: 12px 14px; font-size: 16px; outline: none; transition: border-color .15s, box-shadow .15s;
}
input[type="text"]:focus, textarea:focus, select:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(242, 98, 46, .18); }
#in-url { font-size: 17px; padding: 14px 16px; }
textarea { resize: vertical; }
.hint { margin: 8px 0 0; font-size: 13.5px; color: var(--muted); }
.wifi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.wifi-grid label { font-size: 13.5px; font-weight: 600; color: var(--ink-2); display: grid; gap: 5px; }
.wifi-grid .check { display: flex; align-items: center; gap: 8px; align-self: end; padding-bottom: 12px; font-weight: 500; }

/* Vista previa 2D */
.qr-stage {
  position: relative; display: grid; place-items: center;
  background: repeating-conic-gradient(#f1f0ea 0% 25%, #fbfaf6 0% 50%) 50% / 18px 18px;
  border-radius: 12px; padding: 14px; min-height: 200px;
}
.qr-canvas { width: min(100%, 260px); aspect-ratio: 1; }
.qr-canvas canvas, .qr-canvas svg { width: 100% !important; height: 100% !important; border-radius: 6px; box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.badge-demo { position: absolute; top: 10px; left: 10px; background: var(--ink); color: #fff; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.dl-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.dl-error { color: var(--bad); font-size: 14px; font-weight: 500; margin: 10px 0 0; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1.5px solid transparent; border-radius: 12px; padding: 11px 16px;
  font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none;
  transition: transform .08s, background .15s, border-color .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: #2a2e37; }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-ink); }
.btn-sm { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.btn-big { width: 100%; padding: 14px 18px; font-size: 17px; text-align: left; }
.btn-big svg { width: 24px; height: 24px; flex: none; }
.btn-big span { display: grid; line-height: 1.2; }
.btn-big small { font-weight: 500; font-size: 13px; opacity: .9; }
.link-btn { background: none; border: 0; padding: 8px 0 0; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; font-size: 14px; cursor: pointer; text-align: center; width: 100%; }
.link-btn:hover { color: var(--accent-ink); }
.busy { margin: 8px 0 0; font-size: 14px; color: var(--muted); text-align: center; }

/* Vista previa 3D */
.viewer-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.viewer-tip { font-size: 12.5px; color: var(--muted); }
.viewer {
  position: relative; width: 100%; aspect-ratio: 4 / 3; border-radius: 12px; overflow: hidden;
  background: radial-gradient(120% 90% at 50% 20%, #ffffff 0%, #ecebe5 70%, #e2e1da 100%);
  touch-action: none; cursor: grab;
}
.viewer:active { cursor: grabbing; }
.viewer canvas { width: 100% !important; height: 100% !important; }
.viewer-msg { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px; color: var(--muted); font-size: 14.5px; }
.viewer[data-state="ready"] .viewer-msg { display: none; }
.dims { margin: 8px 0 12px; font-size: 13.5px; color: var(--ink-2); text-align: center; font-variant-numeric: tabular-nums; }

/* Diseño */
.styles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.style-btn {
  display: grid; justify-items: center; gap: 4px; padding: 8px 4px; border-radius: 12px;
  border: 1.5px solid var(--line); background: #fff; cursor: pointer; font-size: 12px; font-weight: 500;
}
.style-btn svg { width: 30px; height: 30px; fill: var(--ink); }
.style-btn.is-on, .fmt-btn.is-on { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(242, 98, 46, .16); }
.color-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.color { display: flex; align-items: center; gap: 10px; border: 1.5px solid var(--line); border-radius: 12px; padding: 6px 10px; font-size: 14px; font-weight: 500; cursor: pointer; }
.color input { width: 34px; height: 34px; border: 0; padding: 0; background: none; cursor: pointer; flex: none; }
.warn-line { margin: 10px 0 0; font-size: 13.5px; color: var(--warn); }

.emoji-grid { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 6px; }
.emoji-mini { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.emoji-btn {
  aspect-ratio: 1; display: grid; place-items: center; font-size: 21px; line-height: 1;
  border: 1.5px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; padding: 0;
}
.emoji-mini .emoji-btn { width: 36px; font-size: 18px; }
.emoji-btn.is-on { border-color: var(--accent); background: #fff3ed; }
.emoji-btn.none { font-size: 12px; color: var(--muted); font-weight: 600; }
.logo-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }

/* Objeto 3D */
.formats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.fmt-btn {
  display: grid; justify-items: center; text-align: center; gap: 2px; padding: 12px 6px; border-radius: 14px;
  border: 1.5px solid var(--line); background: #fff; cursor: pointer; color: var(--ink);
}
.fmt-btn svg { width: 48px; height: 36px; color: var(--accent-ink); margin-bottom: 4px; }
.fmt-btn strong { font-size: 14px; }
.fmt-btn span { font-size: 12px; color: var(--muted); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.field-label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(--ink-2); align-content: start; }
.filaments { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.sw {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; cursor: pointer; padding: 0;
  box-shadow: 0 0 0 1px rgba(0,0,0,.18);
}
.sw.is-on { box-shadow: 0 0 0 2.5px var(--accent); }
.sw-custom { position: relative; overflow: hidden; background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); }
.sw-custom input { position: absolute; inset: -6px; width: 44px; height: 44px; opacity: 0; cursor: pointer; }
.sliders { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.slider { display: grid; gap: 4px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.slider output { font-weight: 700; color: var(--ink); float: right; font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--accent); }

.checks { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 6px; }
.checks li { font-size: 13.5px; padding: 8px 10px 8px 34px; border-radius: 10px; position: relative; line-height: 1.4; }
.checks li::before { position: absolute; left: 10px; top: 7px; font-weight: 700; }
.checks .ok { background: #eaf6ef; color: var(--ok); }
.checks .ok::before { content: "✓"; }
.checks .warn { background: #fff5e5; color: var(--warn); }
.checks .warn::before { content: "!"; }
.checks .bad { background: #fdecea; color: var(--bad); }
.checks .bad::before { content: "✕"; }

.privacy { margin: 16px 0 0; font-size: 14px; color: var(--ink-2); text-align: center; }
.nojs { background: #fff5e5; border: 1px solid #f3d9a8; padding: 14px; border-radius: 12px; }

/* ---------- Huecos de anuncio (placeholders) ---------- */
.ad-slot {
  display: grid; place-items: center; text-align: center;
  border: 2px dashed #c9c8bf; border-radius: 12px; background: repeating-linear-gradient(-45deg, #f2f1ec 0 10px, #f7f6f2 10px 20px);
  color: #8d8b80; font-weight: 700; letter-spacing: .18em; font-size: 13px;
}
/* Huecos ocultos hasta activar anuncios (lib/manifest.js → ads: true) */
html:not(.ads-on) .ad-leaderboard, html:not(.ads-on) .ad-incontent { display: none; }
.ad-leaderboard { min-height: 90px; max-width: 970px; margin: 28px auto 0; }
.ad-incontent { min-height: 250px; max-width: 728px; margin: 8px auto 0; }
.ad-rect { width: 300px; max-width: 100%; height: 250px; margin: 0 auto; }
.ad-mini { width: 100%; height: 100px; }

.ad-modal {
  border: 0; border-radius: 18px; padding: 26px 22px 18px; width: min(360px, calc(100vw - 32px));
  box-shadow: 0 20px 60px rgba(0,0,0,.3); text-align: center; position: fixed;
}
.ad-modal::backdrop { background: rgba(22, 24, 29, .55); }
.ad-modal-title { margin: 0 0 14px; font-weight: 700; }
.ad-modal .btn { margin-top: 14px; }
.ad-close, .ad-toast-close {
  position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border-radius: 50%;
  border: 0; background: #f0efe9; font-size: 20px; line-height: 1; cursor: pointer; color: var(--ink);
}
.ad-close:hover, .ad-toast-close:hover { background: #e2e1da; }
.ad-toast {
  position: fixed; left: 16px; bottom: 16px; width: 260px; z-index: 40;
  background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 34px rgba(0,0,0,.18);
  padding: 34px 10px 10px; animation: toastIn .35s ease-out;
}
.ad-toast-close { width: 26px; height: 26px; font-size: 17px; top: 5px; right: 5px; }
@keyframes toastIn { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Secciones de contenido ---------- */
.section { padding-top: 56px; }
.section h2 { font-family: var(--display); font-size: clamp(23px, 3vw, 32px); letter-spacing: -.02em; line-height: 1.15; margin: 0 0 22px; }
.steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.steps li, .idea { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.steps-n { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 800; font-size: 18px; }
.steps h3, .idea h3 { margin: 12px 0 6px; font-size: 18px; }
.steps p, .idea p { margin: 0; color: var(--ink-2); font-size: 15px; }
.ideas { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.idea-ico { font-size: 30px; }
.prose { max-width: 820px; }
.prose p { color: var(--ink-2); margin: 0 0 14px; }
.prose strong { color: var(--ink); }
.faq { display: grid; gap: 10px; max-width: 860px; }
.faq details { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 0 18px; }
.faq summary { cursor: pointer; font-weight: 600; padding: 16px 0; list-style: none; position: relative; padding-right: 28px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; position: absolute; right: 0; top: 13px; font-size: 22px; font-weight: 400; color: var(--muted); }
.faq details[open] summary::after { content: "−"; }
.faq p { margin: 0 0 16px; color: var(--ink-2); }

.site-footer { margin-top: 64px; padding: 26px 0 90px; border-top: 1px solid var(--line); background: var(--card); font-size: 14px; color: var(--ink-2); }
.footer-row { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.footer-row p { margin: 0; }
.footer-row a { color: var(--ink-2); }

/* ---------- Páginas legales ---------- */
.legal { max-width: 760px; padding-top: 30px; }
.legal h1 { font-family: var(--display); font-size: 32px; }
.legal p, .legal li { color: var(--ink-2); }
.todo { background: #fff5e5; padding: 1px 5px; border-radius: 4px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .tool {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "content" "preview2d" "design" "object" "preview3d";
  }
  .previews { display: contents; }
  .p-preview2d { grid-area: preview2d; }
  .p-preview3d { grid-area: preview3d; }
  .steps, .ideas { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 620px) {
  .wrap { padding: 0 14px; }
  .header-nav { display: none; }
  .hero { padding-top: 16px; padding-bottom: 12px; }
  .lead { font-size: 15px; }
  .panel { padding: 14px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -14px 12px; padding: 0 14px 2px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { white-space: nowrap; }
  .styles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .emoji-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .two-col, .filaments, .sliders, .wifi-grid { grid-template-columns: 1fr; }
  .fmt-btn span { display: none; }
  .fmt-btn strong { font-size: 13px; }
  .steps, .ideas { grid-template-columns: 1fr; }
  .qr-canvas { width: min(100%, 220px); }
  .ad-toast { right: 10px; left: auto; bottom: 10px; width: 220px; }
  .ad-incontent { min-height: 200px; }
}

@media (prefers-reduced-motion: reduce) {
  .ad-toast { animation: none; }
  html { scroll-behavior: auto; }
}

/* Tarjetas «Más formas de usar tu QR» */
.idea-link { display: block; text-decoration: none; color: inherit; transition: border-color .15s, transform .15s; }
.idea-link:hover { border-color: var(--accent); transform: translateY(-2px); }
.idea-link h3 { color: var(--ink); }
.prose code { background: #efeee8; padding: 1px 5px; border-radius: 5px; font-size: .92em; }
