/* =============================================================
   1. Tokens (custom properties)
   ============================================================= */
:root {
  --bg: #f7f5ef;
  --bg-elevated: #ffffff;
  --bg-featured: #eafaf3;
  --text: #101826;
  --text-muted: #55606b;
  --border: #e2ddd0;
  --accent: #0f9d67;
  --accent-ink: #ffffff;
  --accent-soft: #d9f2e6;
  --danger: #c0392b;
  --danger-soft: #fbe9e7;
  --cream: #fffdf8;

  --sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --display: "Sora", "Inter", system-ui, sans-serif;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --gutter: clamp(1rem, 4vw, 2.5rem);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1210;
    --bg-elevated: #121b18;
    --bg-featured: #0f2a20;
    --text: #eef2f0;
    --text-muted: #9bb0a8;
    --border: #223129;
    --accent: #22c17f;
    --accent-ink: #06150f;
    --accent-soft: #163a2b;
    --danger: #ff6b5c;
    --danger-soft: #351917;
    --cream: #101815;
  }
}

:root[data-theme="dark"] {
  --bg: #0b1210;
  --bg-elevated: #121b18;
  --bg-featured: #0f2a20;
  --text: #eef2f0;
  --text-muted: #9bb0a8;
  --border: #223129;
  --accent: #22c17f;
  --accent-ink: #06150f;
  --accent-soft: #163a2b;
  --danger: #ff6b5c;
  --danger-soft: #351917;
  --cream: #101815;
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; scroll-behavior: smooth; overflow-x: clip; }
body {
  background: var(--bg);
  color: var(--text);
  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%; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
a.text-link { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
p { text-wrap: pretty; }
h1, h2, h3, h4 { text-wrap: balance; line-height: 1.1; font-family: var(--display); }
ul, ol { padding-left: 1.2em; }
::selection { background: var(--accent); color: var(--accent-ink); }

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

/* =============================================================
   3. Utilities (skip-link, sr-only, container)
   ============================================================= */
.skip-link {
  position: fixed; top: -100px; left: 1rem;
  padding: .6rem 1rem; background: var(--text); color: var(--bg);
  z-index: 9999; border-radius: 8px; font-weight: 600;
  transition: top .2s var(--ease-out);
}
.skip-link:focus { top: 1rem; }

.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;
}

.container {
  width: 100%;
  max-width: 880px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* =============================================================
   4. Typography
   ============================================================= */
.h1 {
  font-size: clamp(1.7rem, 5.6vw, 2.7rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  max-width: 20ch;
}
.subtitle {
  color: var(--text-muted);
  font-size: clamp(0.95rem, 2.4vw, 1.1rem);
  margin-top: .5rem;
  max-width: 46ch;
}
.trust-row {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  list-style: none;
  padding: 0;
  margin: 1rem 0 1.2rem;
}
.trust-row li {
  font-size: .74rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .35rem .75rem;
}
.section-title {
  font-size: clamp(1.3rem, 3.4vw, 1.7rem);
  font-weight: 700;
  margin-bottom: .9rem;
}
.eyebrow {
  display: inline-block;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent);
}

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

/* --- Header --- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: .9rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.15rem;
}
.brand__mark {
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
  font-size: .95rem;
}
.header-note {
  font-size: .82rem;
  color: var(--text-muted);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .6rem 1.05rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: .9rem;
  transition: transform .15s var(--ease-out), background .15s var(--ease-out), box-shadow .15s var(--ease-out);
}
.btn--accent {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn--accent:hover { transform: translateY(-1px); box-shadow: 0 6px 16px -6px rgb(15 157 103 / 45%); }
.btn--ghost {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
}
.btn--ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: .65; cursor: default; transform: none; }
.btn--icon svg { width: 16px; height: 16px; }

/* --- Tool card shell --- */
.tool-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(1rem, 3vw, 1.6rem);
  box-shadow: 0 1px 2px rgb(16 24 38 / 4%), 0 12px 32px -18px rgb(16 24 38 / 18%);
}

.tool-noscript {
  background: var(--danger-soft);
  border: 1px solid rgb(192 57 43 / 25%);
  border-radius: var(--radius-md);
  padding: .9rem 1.1rem;
  margin-bottom: 1rem;
  font-size: .9rem;
}

.tool-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.tool-status {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .85rem;
  color: var(--text-muted);
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted);
  flex: none;
}
[data-tool-card][data-state="loading"] .status-dot { background: #d9a441; animation: pulse 1.1s ease-in-out infinite; }
[data-tool-card][data-state="done"] .status-dot { background: var(--accent); }
[data-tool-card][data-state="error"] .status-dot { background: var(--danger); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.tool-error {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  background: var(--danger-soft);
  border: 1px solid rgb(192 57 43 / 25%);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: .9rem 1.1rem;
  margin-bottom: 1rem;
  font-size: .9rem;
}
.tool-error[hidden] { display: none; }

/* --- Rate cards --- */
.rates-featured {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .75rem;
  margin-bottom: .75rem;
}
.rates-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .6rem;
  margin-bottom: 1.1rem;
}
/* 5 tarjetas no dividen justo por 2 ni por 3 — sin esto la última (Tarjeta)
   queda sola/descolgada en su fila. Le hacemos ocupar lo que sobra. */
.rates-grid > :last-child { grid-column: 1 / -1; }
.rate-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: .85rem .95rem;
  background: var(--bg-elevated);
  transition: opacity .3s var(--ease-out), box-shadow .2s var(--ease-out);
}
.rate-card--featured {
  padding: 1rem 1.1rem;
  background: var(--bg-featured);
  border-color: var(--accent-soft);
}
.rate-card--featured.rate-card--blue { position: relative; }
.rate-card--featured.rate-card--blue::after {
  content: "Más buscado";
  position: absolute;
  top: .6rem; right: .6rem;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: .18rem .5rem;
  border-radius: 999px;
}
.rate-card__name {
  font-size: 1rem;
  font-weight: 700;
}
.rate-card--featured .rate-card__name { font-size: 1.15rem; }
.rate-card__sub {
  font-size: .74rem;
  color: var(--text-muted);
  margin-top: .1rem;
  margin-bottom: .6rem;
}
.rate-card__rows { display: flex; gap: 1rem; }
.rate-card__row { display: flex; flex-direction: column; gap: .1rem; }
.rate-card__row span { font-size: .72rem; color: var(--text-muted); }
.rate-card__row strong {
  font-family: var(--display);
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
  font-weight: 700;
}
.rate-card--featured .rate-card__row strong { font-size: 1.55rem; }
.rate-card.is-unavailable .rate-card__row strong { color: var(--text-muted); font-weight: 500; }
.rate-card.is-loaded .rate-card__row strong { animation: settle .35s var(--ease-out); }
@keyframes settle { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.limits-note {
  font-size: .8rem;
  color: var(--text-muted);
  display: flex;
  align-items: flex-start;
  gap: .45rem;
  padding-top: .2rem;
}
.limits-note svg { flex: none; width: 15px; height: 15px; margin-top: .15rem; color: var(--accent); }

/* --- Converter --- */
.converter {
  margin-top: 1.3rem;
  padding-top: 1.2rem;
  border-top: 1px dashed var(--border);
}
.converter__title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: .8rem;
}
.converter__grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: .5rem;
  align-items: end;
}
.field label {
  display: block;
  font-size: .74rem;
  color: var(--text-muted);
  margin-bottom: .3rem;
}
.field input, .field select {
  width: 100%;
  padding: .6rem .7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-variant-numeric: tabular-nums;
}
.field input:focus, .field select:focus { border-color: var(--accent); }
.converter__swap {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  font-size: 1.05rem;
  margin-inline: auto;
  transition: transform .2s var(--ease-out), border-color .2s var(--ease-out);
}
.converter__swap:hover { border-color: var(--accent); transform: rotate(180deg); }
.converter__result-row {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: .7rem;
  flex-wrap: wrap;
}
.converter__result {
  font-family: var(--display);
  font-size: 1.4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.converter__hint {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: .35rem;
}
.copy-btn {
  font-size: .78rem;
  padding: .35rem .7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
}
.copy-btn:hover { border-color: var(--accent); color: var(--accent); }

/* --- Ad slots --- */
.ad-slot {
  min-height: 90px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-size: .78rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-block: 1.6rem;
}

/* --- How it works --- */
.steps {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
  margin-top: 1.2rem;
}
.step {
  display: flex;
  gap: .9rem;
  align-items: flex-start;
}
.step__icon {
  flex: none;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid; place-items: center;
}
.step__icon svg { width: 20px; height: 20px; }
.step h3 { font-size: .98rem; margin-bottom: .2rem; }
.step p { font-size: .88rem; color: var(--text-muted); }

/* --- SEO text --- */
.prose { font-size: .96rem; color: var(--text-muted); }
.prose p { margin-bottom: .9rem; }
.prose strong { color: var(--text); }

/* --- FAQ --- */
.faq-item {
  border-bottom: 1px solid var(--border);
  padding-block: .9rem;
}
.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  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::after {
  content: "+";
  font-size: 1.3rem;
  color: var(--accent);
  transition: transform .2s var(--ease-out);
  flex: none;
}
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item p { margin-top: .6rem; color: var(--text-muted); font-size: .92rem; }

/* --- Footer --- */
.site-footer {
  border-top: 1px solid var(--border);
  padding-block: 1.6rem;
  margin-top: 2rem;
}
.footer-links {
  display: flex;
  gap: 1.1rem;
  flex-wrap: wrap;
  font-size: .82rem;
  color: var(--text-muted);
  margin-bottom: .6rem;
}
.footer-fine {
  font-size: .76rem;
  color: var(--text-muted);
  max-width: 70ch;
}

/* =============================================================
   6. Sections
   ============================================================= */
.hero-section { padding-block: .4rem 1.4rem; }
.content-section { padding-block: 2.2rem; }
.content-section + .content-section { border-top: 1px solid var(--border); }

/* =============================================================
   7. Effects
   ============================================================= */
.reveal-fade { animation: fadeIn .4s var(--ease-out); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* =============================================================
   8. Responsive
   ============================================================= */
@media (min-width: 540px) {
  .rates-grid { grid-template-columns: repeat(3, 1fr); }
  .rates-grid > :last-child { grid-column: span 2; }
}
@media (min-width: 720px) {
  .rates-grid { grid-template-columns: repeat(5, 1fr); }
  .rates-grid > :last-child { grid-column: auto; }
  .steps { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 960px) {
  .container { max-width: 960px; }
}
@media (min-width: 1280px) {
  .container { max-width: 1040px; }
}

/* =============================================================
   9. Reduced-motion (only intrusive effects)
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .status-dot { animation: none; }
  .rate-card.is-loaded .rate-card__row strong { animation: none; }
  .reveal-fade { animation: none; }
  .converter__swap:hover { transform: none; }
}
