/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #ffffff;
  --bg-light: #f7f6f3;
  --surface: #ffffff;
  --surface-border: #e8e6e1;
  --text: #1a1a1a;
  --text-muted: #6b6b6b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #eff6ff;
  --danger: #dc2626;
  --warning: #d97706;
  --success: #16a34a;
  --sans: 'Inter', system-ui, sans-serif;
  --serif: 'Fraunces', Georgia, serif;
  --radius: 12px;
  --radius-sm: 8px;
  --gutter: clamp(1rem, 4vw, 2rem);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  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.1; letter-spacing: -0.02em; }
input, select, textarea {
  font: inherit;
  color: var(--text);
  border: 1.5px solid var(--surface-border);
  border-radius: var(--radius-sm);
  padding: .6rem .85rem;
  width: 100%;
  background: var(--bg);
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}
textarea { resize: vertical; }
details { border-radius: var(--radius-sm); overflow: hidden; }
summary { cursor: pointer; }
::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* =============================================================
   3. Utilities
   ============================================================= */
.container {
  width: min(100%, 1280px);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.skip-link {
  position: fixed; top: -100px; left: 1rem;
  padding: .6rem 1rem; background: var(--accent); color: #fff;
  z-index: 9999; border-radius: 8px; font-weight: 500; font-size: .9rem;
}
.skip-link:focus { top: 1rem; }
.bg-light { background: var(--bg-light); }

/* =============================================================
   4. Header
   ============================================================= */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--surface-border);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: .85rem;
  gap: 1rem;
}
.logo {
  display: flex; align-items: center; gap: .55rem;
  font-size: 1.3rem; font-weight: 700; white-space: nowrap;
  color: #14327A; text-decoration: none; letter-spacing: -.02em;
}
.logo-bolt { flex-shrink: 0; }
.logo-text { color: #14327A; }
.site-header nav {
  display: flex; align-items: center; gap: 1.5rem;
  font-size: .9rem; font-weight: 500; color: var(--text-muted);
}
.site-header nav a:hover { color: var(--text); }

/* =============================================================
   5. Hero
   ============================================================= */
.hero-section {
  padding: 2.5rem 0 1.5rem;
  text-align: center;
}
.hero-section h1 {
  font-family: var(--serif);
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 600;
  margin-bottom: .75rem;
}
.subtitle {
  font-size: clamp(1rem, 2vw, 1.15rem);
  color: var(--text-muted);
  max-width: 56ch;
  margin-inline: auto;
}

/* =============================================================
   6. Tool section layout
   ============================================================= */
.tool-section { padding-bottom: 2rem; }
.tool-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

/* =============================================================
   7. Controls
   ============================================================= */
.tool-controls { display: flex; flex-direction: column; gap: 1.25rem; }

.control-group {
  background: var(--surface);
  border: 1.5px solid var(--surface-border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.step-label {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  display: flex; align-items: center; gap: .5rem;
}
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.6rem; height: 1.6rem;
  background: var(--accent); color: #fff;
  border-radius: 50%; font-size: .8rem; font-weight: 700;
  flex-shrink: 0;
}

/* Tabs */
.input-tabs {
  display: flex; gap: .4rem; margin-bottom: .85rem;
}
.tab-btn {
  padding: .4rem .85rem;
  border-radius: var(--radius-sm);
  font-size: .85rem; font-weight: 500;
  border: 1.5px solid var(--surface-border);
  background: var(--bg-light);
  color: var(--text-muted);
  transition: all .15s;
}
.tab-btn.active {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }
#tab-wifi { display: flex; flex-direction: column; gap: .5rem; }
.wifi-hidden { display: flex; align-items: center; gap: .4rem; font-size: .9rem; width: auto; }
.wifi-hidden input { width: auto; }

/* Design row */
.design-row {
  display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: .85rem;
}
.color-picker-wrap, .style-wrap {
  display: flex; flex-direction: column; gap: .3rem;
  font-size: .8rem; font-weight: 500; color: var(--text-muted);
}
.color-picker-wrap input[type="color"] {
  width: 3rem; height: 2rem;
  padding: .1rem .2rem; cursor: pointer;
  border-radius: var(--radius-sm); border: 1.5px solid var(--surface-border);
}
.style-wrap select { width: auto; min-width: 120px; }

/* Center image */
.center-image-wrap { margin-top: .25rem; }
.center-image-wrap > label { font-size: .85rem; font-weight: 500; color: var(--text-muted); display: block; margin-bottom: .5rem; }
.center-options { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.emoji-picker { display: flex; gap: .3rem; flex-wrap: wrap; }
.emoji-btn {
  padding: .35rem .5rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--surface-border);
  background: var(--bg-light); font-size: 1rem;
  cursor: pointer; transition: all .12s;
  line-height: 1;
}
.emoji-btn:hover, .emoji-btn.active { background: var(--accent-light); border-color: var(--accent); }
.emoji-btn:first-child { font-size: .75rem; }
.upload-logo-label { cursor: pointer; }
.upload-logo-btn {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .4rem .8rem;
  border-radius: var(--radius-sm);
  border: 1.5px dashed var(--surface-border);
  background: var(--bg-light); font-size: .85rem; font-weight: 500;
  transition: all .12s;
}
.upload-logo-btn:hover { border-color: var(--accent); background: var(--accent-light); }
.clear-center-btn {
  padding: .3rem .6rem; font-size: .8rem;
  border-radius: var(--radius-sm); border: 1.5px solid var(--danger);
  color: var(--danger); background: #fff3f3;
}

/* Format cards */
.format-cards {
  display: flex; gap: .6rem; margin-bottom: .85rem; flex-wrap: wrap;
}
.format-card {
  flex: 1; min-width: 100px;
  display: flex; flex-direction: column; align-items: center; gap: .25rem;
  padding: .85rem .5rem;
  border: 1.5px solid var(--surface-border);
  border-radius: var(--radius-sm);
  cursor: pointer; text-align: center;
  transition: all .15s;
}
.format-card input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.format-card:has(input:checked) {
  border-color: var(--accent); background: var(--accent-light);
}
.format-icon { font-size: 1.5rem; }
.format-name { font-size: .85rem; font-weight: 600; }
.format-desc { font-size: .75rem; color: var(--text-muted); }

.d3-options {
  display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem;
}
.text-options label { font-size: .85rem; font-weight: 500; color: var(--text-muted); display: block; margin-bottom: .35rem; }

/* Download buttons */
.download-section { display: flex; flex-direction: column; gap: .6rem; }
.btn-download {
  display: flex; align-items: center; gap: .6rem;
  padding: .8rem 1.2rem; border-radius: var(--radius-sm);
  font-weight: 600; font-size: .95rem;
  transition: all .15s var(--ease-out);
}
.btn-primary {
  background: var(--accent); color: #fff;
  box-shadow: 0 2px 8px rgba(37,99,235,.3);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); transform: translateY(-1px); }
.btn-secondary {
  background: var(--bg-light); color: var(--text);
  border: 1.5px solid var(--surface-border);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-light); }
.btn-tertiary {
  background: transparent; color: var(--text-muted);
  border: 1.5px solid var(--surface-border);
  font-size: .85rem;
}
.btn-tertiary:hover:not(:disabled) { color: var(--text); border-color: var(--text-muted); }
.btn-download:disabled { opacity: .45; cursor: not-allowed; transform: none !important; }
.btn-icon { font-size: 1.1rem; }

.privacy-badge {
  font-size: .8rem; color: var(--text-muted);
  padding: .6rem .85rem;
  background: #f0fdf4; border-radius: var(--radius-sm);
  border: 1px solid #bbf7d0;
}

/* Print warnings */
.print-warnings { font-size: .85rem; color: var(--warning); background: #fff8ed; border: 1px solid #fde68a; border-radius: var(--radius-sm); padding: .6rem .85rem; }
.inline-warning {
  font-size: .85rem; color: var(--warning); background: #fff8ed; border: 1px solid #fde68a; border-radius: var(--radius-sm); padding: .6rem .85rem; margin-top: .5rem;
}

/* =============================================================
   8. Preview panel
   ============================================================= */
.tool-preview { display: flex; flex-direction: column; gap: 1.25rem; }

.preview-label {
  font-size: .9rem; font-weight: 600; margin-bottom: .6rem; color: var(--text-muted);
}
.preview-hint { font-size: .78rem; font-weight: 400; }

.qr-preview-box {
  background: var(--bg-light); border: 1.5px solid var(--surface-border);
  border-radius: var(--radius); padding: 1rem;
  min-height: 180px; display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.qr-preview-box > canvas, .qr-preview-box > svg { border-radius: var(--radius-sm); }
.preview-placeholder { color: var(--text-muted); font-size: .9rem; text-align: center; }

.canvas-3d-container {
  background: #1a1a2e;
  border-radius: var(--radius);
  width: 100%; height: 300px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative;
}
.preview-3d-placeholder { color: #888; font-size: .85rem; }
#canvas-3d-container canvas { border-radius: var(--radius); }
.webgl-error { font-size: .85rem; color: var(--warning); padding: .6rem .85rem; background: #fff8ed; border-radius: var(--radius-sm); border: 1px solid #fde68a; }

/* =============================================================
   9. Ad slots
   ============================================================= */
.ad-slot {
  display: block;
  margin: 1rem auto;
  text-align: center;
}
/* sin fondo ni borde: los ins colapsan a 0 si no hay anuncio */
.ad-leaderboard { max-width: 748px; }
.ad-in-content  { max-width: 356px; }

/* Corner ad */
.ad-corner {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 200;
  background: #f5f5f5; border: 2px dashed #ccc;
  border-radius: var(--radius-sm);
  padding: 1rem 1.5rem;
  display: flex; flex-direction: column; align-items: center; gap: .25rem;
  color: #999; min-width: 200px;
  box-shadow: 0 4px 20px rgba(0,0,0,.12);
}
.ad-corner-close {
  position: absolute; top: .3rem; right: .4rem;
  font-size: .8rem; color: #999;
  padding: .15rem .35rem; border-radius: 4px;
}
.ad-corner-close:hover { background: #e5e5e5; color: #666; }
.ad-corner .ad-size { font-size: .7rem; }

/* Popup ad */
.ad-popup {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,.5); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.ad-popup[hidden] { display: none; }
.ad-popup-inner {
  background: var(--bg); border-radius: var(--radius);
  padding: 2rem; position: relative; width: min(760px, calc(100vw - 2rem));
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.ad-popup-close {
  position: absolute; top: .75rem; right: .75rem;
  font-size: 1rem; font-weight: 700; color: var(--text-muted);
  padding: .3rem .5rem; border-radius: 6px;
}
.ad-popup-close:hover { background: var(--bg-light); }
.ad-popup .ad-label { font-weight: 700; font-size: .8rem; margin-bottom: .75rem; }
.ad-popup-slot {
  height: 100px; background: #f5f5f5; border: 2px dashed #ccc;
  border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center;
  color: #999; font-size: .8rem;
}

/* =============================================================
   10. Content sections
   ============================================================= */
.content-section { padding: 4rem 0; }
.content-section h2 {
  font-family: var(--serif);
  font-size: clamp(1.5rem, 3vw, 2rem);
  margin-bottom: 2rem; text-align: center;
}

/* Steps */
.steps-grid { display: grid; gap: 1.5rem; }
.step-card {
  background: var(--surface);
  border: 1.5px solid var(--surface-border);
  border-radius: var(--radius); padding: 1.5rem;
}
.step-icon { width: 3rem; height: 3rem; color: var(--accent); margin-bottom: 1rem; }
.step-card h3 { font-size: 1.1rem; margin-bottom: .5rem; }
.step-card p { font-size: .95rem; color: var(--text-muted); }

/* Use cases */
.use-cases-grid { display: grid; gap: 1rem; }
.use-case {
  background: var(--bg); border: 1.5px solid var(--surface-border);
  border-radius: var(--radius); padding: 1.25rem;
  display: flex; flex-direction: column; gap: .4rem;
}
.use-icon { font-size: 1.75rem; }
.use-case h3 { font-size: 1rem; font-weight: 600; }
.use-case p { font-size: .9rem; color: var(--text-muted); }

/* SEO text */
.text-content { max-width: 72ch; }
.text-content h2 { text-align: left; }
.text-content h3 { font-size: 1.15rem; margin-top: 1.5rem; margin-bottom: .5rem; }
.text-content p { margin-bottom: .85rem; font-size: .97rem; color: #333; }

/* FAQ */
.faq-list { display: flex; flex-direction: column; gap: .6rem; max-width: 800px; margin-inline: auto; }
.faq-item {
  border: 1.5px solid var(--surface-border);
  border-radius: var(--radius-sm);
}
.faq-item summary {
  padding: 1rem 1.25rem;
  font-weight: 600; font-size: .97rem;
  list-style: none; display: flex; justify-content: space-between; align-items: center;
}
.faq-item summary::after { content: '↓'; font-size: .8rem; color: var(--text-muted); transition: transform .2s; }
.faq-item[open] summary::after { transform: rotate(180deg); }
.faq-item p { padding: 0 1.25rem 1rem; font-size: .9rem; color: var(--text-muted); }

/* =============================================================
   11. Footer
   ============================================================= */
.site-footer {
  background: var(--bg-light);
  border-top: 1px solid var(--surface-border);
  padding: 2rem 0;
}
.footer-inner { text-align: center; display: flex; flex-direction: column; gap: .4rem; }
.footer-brand { font-size: 1.1rem; font-weight: 600; }
.footer-brand strong { color: var(--accent); }
.footer-links a { color: var(--text-muted); font-size: .85rem; }
.footer-links a:hover { color: var(--text); text-decoration: underline; }
.footer-copy { font-size: .8rem; color: var(--text-muted); }

/* =============================================================
   12. Responsive
   ============================================================= */
@media (min-width: 720px) {
  .steps-grid { grid-template-columns: repeat(3, 1fr); }
  .use-cases-grid { grid-template-columns: repeat(2, 1fr); }
  .canvas-3d-container { height: 350px; }
}

@media (min-width: 960px) {
  .tool-layout {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
  .use-cases-grid { grid-template-columns: repeat(3, 1fr); }
  .canvas-3d-container { height: 420px; }
  .preview-2d-wrap .qr-preview-box { min-height: 220px; }
}

@media (max-width: 540px) {
  .site-header nav a { display: none; }
  .format-cards { flex-direction: column; }
  .format-card { flex-direction: row; justify-content: flex-start; text-align: left; }
  .ad-corner { display: none; }
  .lang-selector { display: flex; }
}

/* =============================================================
   13. Reduced-motion
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  .btn-primary:hover:not(:disabled) { transform: none; }
}

/* =============================================================
   14. Language selector
   ============================================================= */
.lang-selector {
  position: relative;
  display: flex;
  align-items: center;
}
.lang-toggle {
  display: flex;
  align-items: center;
  gap: .3rem;
  padding: .3rem .55rem;
  border: 1.5px solid var(--surface-border);
  border-radius: 8px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg);
  cursor: pointer;
  transition: border-color .15s, color .15s;
  white-space: nowrap;
}
.lang-toggle:hover {
  border-color: var(--accent);
  color: var(--text);
}
.lang-arrow {
  font-size: .65rem;
  opacity: .6;
  transition: transform .15s;
}
.lang-toggle[aria-expanded="true"] .lang-arrow {
  transform: rotate(180deg);
}
.lang-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1.5px solid var(--surface-border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,.1);
  min-width: 90px;
  z-index: 200;
  overflow: hidden;
}
.lang-option {
  display: flex;
  align-items: center;
  gap: .45rem;
  width: 100%;
  padding: .5rem .8rem;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: 0;
  cursor: pointer;
  text-align: left;
  transition: background .12s, color .12s;
}
.lang-option:hover {
  background: var(--bg-light);
  color: var(--text);
}
.lang-option.lang-active {
  color: var(--accent);
  font-weight: 700;
  background: var(--accent-light);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .lang-toggle { background: #1e1e1e; color: #aaa; border-color: #333; }
  :root:not([data-theme="light"]) .lang-dropdown { background: #1e1e1e; border-color: #333; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
  :root:not([data-theme="light"]) .lang-option:hover { background: #2a2a2a; color: #fff; }
  :root:not([data-theme="light"]) .lang-option.lang-active { background: #172041; color: #60a5fa; }
}
