/* =============================================================
   CodiClean — hoja de estilos única
   1 Tokens · 2 Reset · 3 Utilidades · 4 Tipografía · 5 Cabecera
   6 Hero · 7 Pestañas de lenguaje · 8 Herramienta (editor) · 9 Acciones
   10 Estados y errores · 11 Anuncios · 12 Contenido · 13 FAQ
   14 Más herramientas · 15 Footer · 16 Responsive · 17 Reduced-motion
   ============================================================= */

/* ===================== 1. TOKENS ===================== */
:root {
  --bg: #0a0d13;
  --surface: #10141d;
  --surface-2: #161b27;
  --editor-bg: #0d1117;
  --ink: #e7eaf2;
  --ink-2: #aab1c2;
  --muted: #747d90;
  --line: #232a3a;
  --line-2: #1a2030;
  --accent: #2dd4a8;
  --accent-2: #f5a623;
  --accent-ink: #06231b;
  --accent-soft: rgba(45, 212, 168, .13);
  --ok: #2dd4a8;
  --ok-soft: rgba(45, 212, 168, .13);
  --warn: #f5a623;
  --warn-soft: rgba(245, 166, 35, .13);
  --bad: #ef5a6f;
  --bad-soft: rgba(239, 90, 111, .14);

  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .28);
  --shadow: 0 4px 18px -4px rgba(0, 0, 0, .45), 0 1px 3px rgba(0, 0, 0, .3);
  --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .55), 0 4px 16px -6px rgba(0, 0, 0, .35);
  --ease-out: cubic-bezier(.16, 1, .3, 1);

  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --gutter: clamp(1rem, 4vw, 2rem);
  --maxw: 1180px;
}

/* ===================== 2. RESET ===================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 5rem; tab-size: 2; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  background-image:
    radial-gradient(640px 400px at 92% -6%, rgba(45, 212, 168, .10), transparent 62%),
    radial-gradient(560px 380px at -6% 12%, rgba(245, 166, 35, .07), transparent 60%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
img, svg, canvas, video { 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; }
textarea { resize: vertical; }
a { color: inherit; text-decoration: none; }
p { text-wrap: pretty; }
h1, h2, h3 { text-wrap: balance; line-height: 1.14; letter-spacing: -.01em; font-weight: 700; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }

/* ===================== 3. UTILIDADES ===================== */
.container { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
.container + .container { margin-top: clamp(2rem, 5vw, 3.5rem); }
.skip-link {
  position: fixed; top: -100px; left: 1rem; z-index: 999;
  padding: .6rem 1rem; background: var(--accent); color: var(--accent-ink);
  border-radius: 8px; font-weight: 600; transition: top .2s var(--ease-out);
}
.skip-link:focus { top: 1rem; }
.noscript-note {
  margin: 1rem var(--gutter); padding: .9rem 1.1rem; background: var(--warn-soft);
  color: var(--warn); border: 1px solid rgba(245, 166, 35, .3); border-radius: var(--radius-sm);
  max-width: var(--maxw); margin-inline: auto;
}
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0;
}

/* ===================== 4. TIPOGRAFÍA ===================== */
.eyebrow {
  display: inline-flex; align-items: center; gap: .4em;
  font-size: .8rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--accent); margin-bottom: .75rem;
}
h1 { font-size: clamp(2rem, 4.6vw, 3rem); max-width: 20ch; }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); margin-bottom: .6em; }
h3 { font-size: 1.1rem; margin-bottom: .4em; }
.hero-sub { color: var(--ink-2); font-size: clamp(1rem, 1.6vw, 1.15rem); max-width: 62ch; margin-top: .9rem; }
.section-sub { color: var(--ink-2); margin-top: -.3rem; margin-bottom: 1.4rem; max-width: 62ch; }
code, .code-inline { font-family: var(--mono); font-size: .92em; background: var(--surface-2); padding: .12em .4em; border-radius: 5px; border: 1px solid var(--line); }

/* ===================== 5. CABECERA ===================== */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(10, 13, 19, .82); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-2);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-block: .85rem; }
.brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 800; font-size: 1.15rem; letter-spacing: -.01em; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(155deg, var(--accent), #17a888); color: var(--accent-ink);
}
.site-nav { display: flex; align-items: center; gap: 1.4rem; }
.site-nav a { color: var(--ink-2); font-size: .92rem; font-weight: 500; transition: color .2s var(--ease-out); }
.site-nav a:hover { color: var(--ink); }
.site-nav .btn { padding: .5rem 1rem; }

/* ===================== 6. HERO ===================== */
.hero { padding-block: clamp(2.2rem, 6vw, 3.6rem) clamp(1.4rem, 3vw, 2rem); text-align: center; }
.hero h1 { margin-inline: auto; }
.hero-sub { margin-inline: auto; }

/* ===================== 7. PESTAÑAS DE LENGUAJE ===================== */
.lang-tabs {
  display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem;
  margin: 1.6rem auto 0; max-width: 640px;
}
.lang-tab {
  display: inline-flex; align-items: center; gap: .45em;
  padding: .55rem 1.1rem; border-radius: 999px; font-weight: 600; font-size: .92rem;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2);
  transition: background .2s var(--ease-out), color .2s var(--ease-out), border-color .2s var(--ease-out);
}
.lang-tab:hover { color: var(--ink); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.lang-tab.is-active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ===================== 8. HERRAMIENTA (editor) ===================== */
.tool-card {
  margin-top: 1.6rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: clamp(1rem, 2.4vw, 1.6rem);
}
.editor-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.editor-panel {
  display: flex; flex-direction: column; background: var(--editor-bg);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.editor-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .6rem .9rem; border-bottom: 1px solid var(--line-2); background: var(--surface-2);
}
.editor-panel-head h3 { margin: 0; font-size: .82rem; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--ink-2); }
.editor-panel-head .dots { display: inline-flex; gap: 5px; }
.editor-panel-head .dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.editor-textarea {
  flex: 1; min-height: 260px; width: 100%; padding: 1rem; border: 0; background: transparent;
  color: var(--ink); font-family: var(--mono); font-size: .88rem; line-height: 1.55;
  white-space: pre; overflow: auto; tab-size: 2;
}
.editor-textarea::placeholder { color: var(--muted); white-space: pre-line; }
.editor-textarea[readonly] { color: var(--ink-2); }
.editor-textarea.is-dragover { outline: 2px dashed var(--accent); outline-offset: -6px; }
.editor-stats {
  display: flex; gap: .9rem; flex-wrap: wrap; padding: .5rem .9rem; font-size: .78rem;
  color: var(--muted); border-top: 1px solid var(--line-2); background: var(--surface-2);
}
.editor-stats strong { color: var(--ink-2); font-weight: 600; }

/* ===================== 9. ACCIONES ===================== */
.action-row { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.1rem; }
.utility-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .7rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  padding: .72rem 1.3rem; border-radius: var(--radius-sm); font-weight: 700; font-size: .92rem;
  transition: transform .15s var(--ease-out), background .2s var(--ease-out), border-color .2s var(--ease-out), opacity .2s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, white 12%); }
.btn-secondary { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.btn-secondary:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.btn-ghost { background: transparent; color: var(--ink-2); border: 1px solid var(--line); }
.btn-ghost:hover { color: var(--ink); border-color: var(--line-2); background: var(--surface-2); }
.btn-sm { padding: .5rem .9rem; font-size: .84rem; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn .btn-icon { font-size: 1.05em; line-height: 1; }

.example-link { font-size: .84rem; color: var(--accent); font-weight: 600; align-self: center; margin-left: auto; }
.example-link:hover { text-decoration: underline; }

/* ===================== 10. ESTADOS Y ERRORES ===================== */
.tool-card[data-state="working"] .editor-panel--output { position: relative; }
.tool-card[data-state="working"] .editor-panel--output::after {
  content: ""; position: absolute; inset: 0; background: var(--editor-bg);
  background-image: linear-gradient(90deg, transparent, rgba(45,212,168,.08), transparent);
  background-size: 200% 100%; animation: shimmer 1.1s linear infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.status-banner {
  display: none; align-items: flex-start; gap: .6rem; margin-top: 1rem; padding: .85rem 1rem;
  border-radius: var(--radius-sm); font-size: .9rem; line-height: 1.5;
}
.tool-card[data-state="error"] .status-banner {
  display: flex; background: var(--bad-soft); color: var(--bad); border: 1px solid rgba(239,90,111,.35);
}
.status-banner code { background: rgba(0,0,0,.25); border-color: rgba(239,90,111,.3); color: inherit; }

.stats-result {
  display: none; flex-wrap: wrap; gap: 1.2rem; margin-top: 1rem; padding: .85rem 1.1rem;
  border-radius: var(--radius-sm); background: var(--ok-soft); border: 1px solid rgba(45,212,168,.3);
  font-size: .88rem; color: var(--ink-2);
}
.tool-card[data-state="done"] .stats-result { display: flex; }
.stats-result strong { color: var(--ok); font-weight: 700; }

.privacy-badge {
  margin-top: 1.1rem; font-size: .86rem; color: var(--ink-2);
  display: flex; align-items: center; gap: .5em; flex-wrap: wrap;
}
.honest-limit { margin-top: .35rem; font-size: .8rem; color: var(--muted); }
.copied-flag {
  display: inline-block; margin-left: .5rem; font-size: .78rem; font-weight: 700; color: var(--ok);
  opacity: 0; transition: opacity .2s var(--ease-out);
}
.copied-flag.is-shown { opacity: 1; }

/* ===================== 11. ANUNCIOS ===================== */
.ad-slot {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem;
  border: 1px dashed var(--line); border-radius: var(--radius-sm); background: var(--surface);
  color: var(--muted); font-size: .72rem; letter-spacing: .05em; text-transform: uppercase;
  margin-inline: auto;
}
.ad-slot strong { font-size: .68rem; color: var(--muted); font-weight: 700; }
.ad-slot--header, .ad-slot--prefooter { width: 100%; max-width: 728px; min-height: 90px; }
.ad-slot--incontent { width: 100%; min-height: 250px; }
.ad-slot--sidebar { width: 300px; max-width: 100%; min-height: 250px; }

/* ===================== 12. CONTENIDO ===================== */
.section-tint { background: var(--surface); border-block: 1px solid var(--line-2); }
.prose-section { padding-block: clamp(2rem, 5vw, 3rem); }
.content-with-sidebar { display: grid; grid-template-columns: 1fr; gap: 2rem; align-items: start; }
.content-main p + p, .content-main p + h3 { margin-top: 1rem; }
.content-main p { color: var(--ink-2); }
.content-main ul { padding-left: 1.2rem; color: var(--ink-2); margin-top: .6rem; }
.content-main li + li { margin-top: .4rem; }
.how-it-works { list-style: none; display: grid; gap: 1rem; margin-top: 1.2rem; counter-reset: step; }
.how-it-works li { position: relative; padding-left: 2.6rem; color: var(--ink-2); }
.how-it-works li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: -.1rem; width: 1.9rem; height: 1.9rem; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: .85rem;
  display: grid; place-items: center;
}
.how-it-works strong { color: var(--ink); }
.lang-support-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; margin-top: 1.4rem;
}
.lang-support-card {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .9rem 1rem;
}
.lang-support-card h3 { font-size: .95rem; margin-bottom: .25rem; }
.lang-support-card p { font-size: .82rem; color: var(--muted); }

/* ===================== 13. FAQ ===================== */
.faq-list { display: grid; gap: .7rem; margin-top: 1.2rem; }
.faq-item {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
}
.faq-item summary {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  font-weight: 600; font-size: .96rem;
}
.faq-item summary::after { content: "+"; color: var(--accent); font-size: 1.3rem; font-weight: 400; flex: none; }
.faq-item[open] summary::after { content: "\2212"; }
.faq-item p { margin-top: .7rem; color: var(--ink-2); font-size: .92rem; }

/* ===================== 14. MÁS HERRAMIENTAS ===================== */
.more-tools { padding-block: clamp(2rem, 5vw, 3rem); }
.more-tools-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-top: 1.2rem; }
.more-tool-card {
  display: block; padding: 1.1rem 1.2rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); transition: border-color .2s var(--ease-out), transform .2s var(--ease-out);
}
.more-tool-card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); transform: translateY(-2px); }
.more-tool-name { display: block; font-weight: 700; color: var(--ink); margin-bottom: .3rem; }
.more-tool-desc { display: block; font-size: .85rem; color: var(--muted); }

/* ===================== 15. FOOTER ===================== */
.site-footer { border-top: 1px solid var(--line-2); padding-block: 1.6rem; margin-top: 2rem; }
.footer-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .8rem; }
.footer-brand { font-size: .88rem; color: var(--muted); }
.footer-nav { display: flex; gap: 1.2rem; }
.footer-nav a { font-size: .86rem; color: var(--ink-2); }
.footer-nav a:hover { color: var(--ink); }
.footer-credits { font-size: .74rem; color: var(--muted); margin-top: .6rem; }

/* ===================== 16. RESPONSIVE ===================== */
@media (min-width: 720px) {
  .editor-grid { grid-template-columns: 1fr 1fr; }
  .editor-textarea { min-height: 340px; }
}
@media (min-width: 960px) {
  .content-with-sidebar { grid-template-columns: 1fr 300px; }
  .site-nav { display: flex; }
}
@media (max-width: 719px) {
  .site-nav a:not(.btn) { display: none; }
}

/* ===================== 17. REDUCED-MOTION ===================== */
@media (prefers-reduced-motion: reduce) {
  .tool-card[data-state="working"] .editor-panel--output::after { animation: none; opacity: .5; }
}
