/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #faf9f6;
  --bg-alt: #f1efe7;
  --card: #ffffff;
  --ink: #15171c;
  --ink-soft: #565b66;
  --ink-faint: #8b8f99;
  --line: #e4e1d6;
  --line-strong: #d2cebf;

  --accent: #ff5a1f;
  --accent-ink: #a3320a;
  --accent-soft: #ffe6d8;
  --accent-2: #14151a;

  --good: #1f9d55;
  --good-bg: #e8f7ee;
  --warn: #b9790a;
  --warn-bg: #fdf1dc;
  --bad: #d3402c;
  --bad-bg: #fceae7;

  --display: "Space Grotesk", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-card: 0 1px 2px rgba(20, 18, 10, 0.04), 0 12px 32px -16px rgba(20, 18, 10, 0.14);
  --shadow-pop: 0 20px 60px -20px rgba(0, 0, 0, 0.35);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-soft: cubic-bezier(0.25, 0.46, 0.45, 0.94);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131315;
    --bg-alt: #1a1a1d;
    --card: #1c1c20;
    --ink: #f1efe9;
    --ink-soft: #b7b6bd;
    --ink-faint: #82818a;
    --line: #2c2c31;
    --line-strong: #3a3a41;
    --accent-soft: #3a2013;
    color-scheme: dark;
  }
}

/* =============================================================
   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);
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  overscroll-behavior-y: none;
}
img, svg, video, canvas { 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; }
input, select, textarea { font: inherit; color: inherit; }
p { text-wrap: pretty; }
h1, h2, h3, h4 { text-wrap: balance; line-height: 1.08; letter-spacing: -0.01em; font-family: var(--display); }
ul { list-style: none; padding: 0; }
::selection { background: var(--accent); color: #fff; }

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* =============================================================
   3. Utilities
   ============================================================= */
.container { width: 100%; max-width: 1140px; margin: 0 auto; padding: 0 20px; }
.is-hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.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;
  transition: top .25s var(--ease-out);
}
.skip-link:focus { top: 1rem; }

.eyebrow {
  display: inline-flex; align-items: center; gap: .4em;
  font-family: var(--mono); font-size: .78rem; letter-spacing: .06em;
  text-transform: uppercase; color: var(--accent-ink);
  background: var(--accent-soft); padding: .3em .7em; border-radius: 999px;
}

/* =============================================================
   4. Typography
   ============================================================= */
h1 { font-size: clamp(1.9rem, 1.35rem + 2.4vw, 3.1rem); font-weight: 700; }
h2 { font-size: clamp(1.5rem, 1.2rem + 1.3vw, 2.15rem); font-weight: 700; }
h3 { font-size: clamp(1.1rem, 1rem + .5vw, 1.35rem); font-weight: 600; }
.lede { font-size: clamp(1.02rem, .96rem + .3vw, 1.2rem); color: var(--ink-soft); max-width: 62ch; }
.section-head { max-width: 68ch; margin: 0 auto 2.2rem; text-align: center; }
.section-head h2 { margin-top: .5rem; }
.section-head p { color: var(--ink-soft); margin-top: .6rem; }

/* =============================================================
   5. Components
   ============================================================= */

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  padding: .8em 1.3em; border-radius: 999px; font-weight: 600; font-size: .96rem;
  transition: transform .2s var(--ease-out), box-shadow .2s var(--ease-out), background .2s var(--ease-out);
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 8px 20px -8px rgba(255, 90, 31, .55); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 26px -8px rgba(255, 90, 31, .6); }
.btn-secondary { background: var(--card); color: var(--ink); border: 1px solid var(--line-strong); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: transparent; color: var(--ink-soft); padding: .5em .8em; }
.btn-ghost:hover { color: var(--ink); }
.btn-block { width: 100%; }
.btn-lg { padding: 1em 1.5em; font-size: 1.05rem; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* --- Card --- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

/* --- Segmented control --- */
.segmented {
  display: inline-flex; padding: 4px; background: var(--bg-alt);
  border: 1px solid var(--line); border-radius: 999px; gap: 2px;
}
.segmented button {
  padding: .55em 1.1em; border-radius: 999px; font-weight: 600; font-size: .88rem;
  color: var(--ink-soft); transition: background .2s var(--ease-out), color .2s var(--ease-out);
}
.segmented button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* --- Field --- */
.field { display: flex; flex-direction: column; gap: .4rem; }
.field label, .field-label { font-size: .82rem; font-weight: 600; color: var(--ink-soft); }
.field input[type="text"],
.field input[type="url"],
.field input[type="password"],
.field input[type="number"],
.field textarea,
.field select {
  width: 100%; padding: .75em .9em; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--bg); color: var(--ink);
  transition: border-color .2s var(--ease-out), box-shadow .2s var(--ease-out);
}
.field textarea { resize: vertical; min-height: 4.5em; font-family: var(--mono); font-size: .92rem; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none;
}
.field-row { display: grid; grid-template-columns: 1fr; gap: .8rem; }
.hint { font-size: .8rem; color: var(--ink-faint); }

.color-field { display: flex; align-items: center; gap: .6rem; }
.color-field input[type="color"] {
  width: 42px; height: 42px; padding: 0; border-radius: 10px; border: 1px solid var(--line-strong);
  background: none; cursor: pointer;
}
.color-field input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
.color-field input[type="color"]::-webkit-color-swatch { border-radius: 7px; border: none; }
.color-field code { font-family: var(--mono); font-size: .82rem; color: var(--ink-soft); }

/* --- Style / format pickers (icon cards) --- */
.pick-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; }
.pick-grid.pick-4 { grid-template-columns: repeat(2, 1fr); }
.pick-card {
  display: flex; flex-direction: column; align-items: center; gap: .4rem;
  padding: .8rem .5rem; border-radius: var(--radius-sm); border: 1.5px solid var(--line);
  background: var(--bg); text-align: center; transition: border-color .2s var(--ease-out), background .2s var(--ease-out);
}
.pick-card svg, .pick-card .pick-emoji { width: 30px; height: 30px; }
.pick-card .pick-emoji { font-size: 26px; line-height: 1; }
.pick-card span { font-size: .78rem; font-weight: 600; color: var(--ink-soft); }
.pick-card[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.pick-card[aria-pressed="true"] span { color: var(--accent-ink); }
.pick-card:hover { border-color: var(--accent); }

/* --- Center (emoji/logo) --- */
.center-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.emoji-pick {
  width: 42px; height: 42px; border-radius: 10px; border: 1.5px solid var(--line);
  font-size: 20px; display: flex; align-items: center; justify-content: center;
  background: var(--bg); transition: border-color .2s var(--ease-out), transform .15s var(--ease-out);
}
.emoji-pick:hover { border-color: var(--accent); transform: translateY(-1px); }
.emoji-pick[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.upload-btn {
  padding: .6em 1em; border-radius: 10px; border: 1.5px dashed var(--line-strong);
  font-size: .85rem; font-weight: 600; color: var(--ink-soft); background: var(--bg);
}
.upload-btn:hover { border-color: var(--accent); color: var(--accent-ink); }
.clear-center { font-size: .8rem; color: var(--ink-faint); text-decoration: underline; }
.clear-center:hover { color: var(--bad); }

/* --- Tool card layout --- */
.tool-section { padding: 2.2rem 0 1rem; }
.tool-card { padding: 0; overflow: hidden; }
.tool-grid {
  display: grid; grid-template-columns: 1fr; gap: 0;
}
.tool-panel { padding: 1.4rem 1.3rem; border-bottom: 1px solid var(--line); }
.tool-preview { padding: 1.4rem 1.3rem; background: var(--bg-alt); }
.control-group { padding: 1.1rem 0; border-top: 1px solid var(--line); }
.control-group:first-child { border-top: none; padding-top: 0; }
.control-group-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .8rem; }
.control-group-head h3 { display: flex; align-items: center; gap: .5rem; font-size: 1rem; }
.control-group-head .step-num {
  width: 22px; height: 22px; border-radius: 999px; background: var(--accent); color: #fff;
  font-size: .72rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none;
}

/* --- QR preview --- */
.qr-preview-wrap {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 1; width: 100%; max-width: 320px; margin: 0 auto;
  background: #fff; border-radius: var(--radius-sm); border: 1px solid var(--line);
  padding: 14px;
}
.qr-preview-wrap canvas, .qr-preview-wrap svg, .qr-preview-wrap img { width: 100%; height: 100%; }
.download-row { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; justify-content: center; }

/* --- 3D viewer --- */
.viewer-3d {
  position: relative; width: 100%; aspect-ratio: 4/3; border-radius: var(--radius-sm);
  overflow: hidden; border: 1px solid var(--line); background:
    linear-gradient(135deg, #22242b, #14151a);
  margin-top: 1rem;
}
.viewer-3d canvas { width: 100%; height: 100%; touch-action: none; }
.viewer-3d .viewer-state {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: .6rem; color: #cfd1d8; font-size: .85rem; text-align: center; padding: 1rem;
}
.viewer-3d .viewer-state.is-hidden { display: none; }
.viewer-3d .viewer-hint {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  font-size: .72rem; color: #cfd1d8; background: rgba(0,0,0,.35); padding: .3em .7em; border-radius: 999px;
  pointer-events: none;
}
.spin {
  width: 26px; height: 26px; border-radius: 50%; border: 3px solid rgba(255,255,255,.25);
  border-top-color: var(--accent); animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Warnings / quality readout --- */
.quality-list { display: flex; flex-direction: column; gap: .5rem; margin-top: 1rem; }
.quality-item {
  display: flex; align-items: flex-start; gap: .6rem; padding: .6em .8em;
  border-radius: var(--radius-sm); font-size: .84rem; background: var(--good-bg); color: var(--good);
}
.quality-item.is-warn { background: var(--warn-bg); color: var(--warn); }
.quality-item.is-bad { background: var(--bad-bg); color: var(--bad); }
.quality-item .q-ico { flex: none; margin-top: .1em; }
.quality-item b { font-family: var(--mono); }

/* --- Privacy / limits badge --- */
.badge-row { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.1rem; }
.badge-chip {
  display: inline-flex; align-items: center; gap: .45em; font-size: .78rem; color: var(--ink-soft);
  background: var(--bg-alt); border: 1px solid var(--line); padding: .4em .75em; border-radius: 999px;
}

/* --- Ad slots --- */
.ad-slot {
  display: flex; align-items: center; justify-content: center;
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius-sm);
  color: var(--ink-faint); font-size: .78rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; background: var(--bg-alt);
}
.ad-slot span { opacity: .7; }
.ad-slot--leaderboard { min-height: 90px; width: 100%; margin: 1.6rem 0; }
.ad-slot--incontent { min-height: 250px; width: 100%; margin: 2.2rem 0; }
.ad-slot--corner {
  position: fixed; right: 16px; bottom: 16px; z-index: 500;
  width: 260px; min-height: 90px; background: var(--card); box-shadow: var(--shadow-pop);
  flex-direction: column; gap: .3rem; padding: .8rem; text-align: center;
}
.ad-slot--corner .ad-close {
  position: absolute; top: 4px; right: 6px; font-size: 1rem; color: var(--ink-faint); padding: .2em .5em;
}
.ad-slot--corner.is-hidden { display: none; }

/* --- Download popup (dialog) --- */
.download-dialog {
  border: none; border-radius: var(--radius); padding: 0; max-width: 380px; width: calc(100% - 2.4rem);
  box-shadow: var(--shadow-pop); background: var(--card); color: var(--ink);
}
.download-dialog::backdrop { background: rgba(10, 9, 6, .55); backdrop-filter: blur(2px); }
.download-dialog .dd-inner { padding: 1.3rem; }
.download-dialog .dd-close {
  position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center; color: var(--ink-soft); font-size: 1.1rem;
}
.download-dialog .dd-close:hover { background: var(--bg-alt); color: var(--ink); }
.download-dialog .ad-slot { min-height: 200px; margin: 1rem 0 0; }

/* =============================================================
   6. Sections
   ============================================================= */

/* --- Header --- */
.site-header {
  position: sticky; top: 0; z-index: 300; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: .5rem; font-family: var(--display); font-weight: 700; font-size: 1.15rem; }
.brand .brand-mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--accent-2);
  display: flex; align-items: center; justify-content: center; color: var(--accent);
}
.site-nav { display: none; align-items: center; gap: 1.6rem; font-size: .9rem; font-weight: 600; color: var(--ink-soft); }
.site-nav a:hover { color: var(--accent-ink); }

/* --- Hero --- */
.hero { padding: 2.6rem 0 0; text-align: center; }
.hero .eyebrow { margin-bottom: 1rem; }
.hero .lede { margin: .9rem auto 0; }

/* --- Cómo funciona --- */
.steps-section { padding: 3.4rem 0; }
.steps-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
.step-card { padding: 1.4rem; display: flex; flex-direction: column; gap: .6rem; }
.step-card .step-num {
  width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-ink);
  font-family: var(--mono); font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.step-card p { color: var(--ink-soft); font-size: .93rem; }

/* --- SEO text --- */
.seo-text { padding: 1rem 0 2.6rem; }
.seo-text .prose { max-width: 72ch; margin: 0 auto; display: flex; flex-direction: column; gap: 1rem; color: var(--ink-soft); }
.seo-text .prose h2, .seo-text .prose h3 { color: var(--ink); margin-top: .6rem; }

/* --- Ideas de uso --- */
.usos-section { padding: 3.4rem 0; background: var(--bg-alt); }
.usos-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
.uso-card { padding: 1.3rem; display: flex; flex-direction: column; gap: .5rem; }
.uso-card .uso-emoji { font-size: 1.8rem; }
.uso-card p { color: var(--ink-soft); font-size: .9rem; }

/* --- FAQ --- */
.faq-section { padding: 3.4rem 0; }
.faq-list { max-width: 74ch; margin: 0 auto; display: flex; flex-direction: column; gap: .7rem; }
.faq-item { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); overflow: hidden; }
.faq-item summary {
  padding: 1rem 1.1rem; font-weight: 600; cursor: pointer; list-style: none;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary .faq-ico { flex: none; transition: transform .25s var(--ease-out); color: var(--accent); }
.faq-item[open] summary .faq-ico { transform: rotate(45deg); }
.faq-item .faq-a { padding: 0 1.1rem 1.1rem; color: var(--ink-soft); font-size: .93rem; }

/* --- Footer --- */
.site-footer { padding: 2.4rem 0; border-top: 1px solid var(--line); }
.footer-inner { display: flex; flex-direction: column; gap: 1rem; align-items: center; text-align: center; }
.footer-links { display: flex; gap: 1.2rem; flex-wrap: wrap; justify-content: center; font-size: .84rem; color: var(--ink-soft); }
.footer-links a:hover { color: var(--accent-ink); }
.footer-credits { font-size: .76rem; color: var(--ink-faint); max-width: 60ch; }
.footer-copy { font-size: .8rem; color: var(--ink-faint); }

/* --- noscript --- */
.noscript-note {
  background: var(--warn-bg); color: var(--warn); text-align: center;
  padding: .8rem 1rem; font-size: .88rem; font-weight: 600;
}

/* =============================================================
   7. Effects
   ============================================================= */
.reveal { opacity: 1; transform: none; }
[data-reveal] { opacity: 0; transform: translateY(14px); transition: opacity .6s var(--ease-out), transform .6s var(--ease-out); }
[data-reveal].is-visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  [data-reveal] { opacity: 1; transform: none; transition: none; }
}

/* =============================================================
   8. Responsive
   ============================================================= */
@media (min-width: 540px) {
  .steps-grid { grid-template-columns: repeat(3, 1fr); }
  .usos-grid { grid-template-columns: repeat(2, 1fr); }
  .download-row { justify-content: flex-start; }
}

@media (min-width: 720px) {
  .site-nav { display: flex; }
  .field-row.two-col { grid-template-columns: 1fr 1fr; }
  .pick-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 960px) {
  .tool-grid { grid-template-columns: 1fr 1fr; }
  .tool-panel { border-bottom: none; border-right: 1px solid var(--line); max-height: 900px; overflow-y: auto; }
  .usos-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1280px) {
  .container { padding: 0 32px; }
}

/* =============================================================
   9. Reduced-motion (intrusive only)
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  .spin { animation-duration: 1.6s; }
}
