/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #f1f4f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #101828;
  --text-muted: #536077;
  --text-faint: #8592a6;

  --accent: #0b5fff;
  --accent-dark: #0847c4;
  --accent-tint: #eaf1ff;
  --success: #16a34a;
  --success-tint: #eafaf0;
  --danger: #dc2626;
  --danger-tint: #fdeaea;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 4px 16px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .12);

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

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --container: 1180px;
}

/* =============================================================
   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 {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -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; }
p { text-wrap: pretty; }
h1, h2, h3, h4 { text-wrap: balance; line-height: 1.15; letter-spacing: -0.01em; font-weight: 700; }
ul { list-style: none; padding: 0; }
input, select { font: inherit; color: inherit; }
::selection { background: var(--accent); color: #fff; }

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

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

/* =============================================================
   3. Utilidades
   ============================================================= */
.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: 1.25rem; }

[id] { scroll-margin-top: 84px; }

.skip-link {
  position: fixed; top: -100px; left: 1rem;
  padding: .6rem 1rem; background: var(--text); color: #fff;
  z-index: 9999; border-radius: 8px; font-weight: 600;
  transition: top .2s var(--ease-out);
}
.skip-link:focus { top: 1rem; }

/* =============================================================
   4. Tipografía
   ============================================================= */
h2 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); margin-bottom: .75rem; }
h3 { font-size: 1.1rem; margin-bottom: .4rem; }
.content-section p { color: var(--text-muted); max-width: 70ch; }
.content-section p + p { margin-top: .75rem; }

/* =============================================================
   5. Componentes
   ============================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .75rem 1.25rem; border-radius: var(--radius-sm);
  font-weight: 600; font-size: .95rem;
  transition: transform .15s var(--ease-out), background .15s var(--ease-out), box-shadow .15s var(--ease-out);
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: var(--accent-tint); color: var(--accent-dark); }
.btn-secondary:hover { background: #dce8ff; }
.btn-ghost { background: var(--surface-2); color: var(--text); }
.btn-ghost:hover { background: var(--border); }

.field { display: flex; flex-direction: column; gap: .4rem; }
.field label, .field-label-static { font-size: .85rem; font-weight: 600; color: var(--text-muted); }
.field-row {
  display: flex; align-items: center; gap: .5rem;
  background: var(--surface-2); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 0 .85rem;
  transition: border-color .15s var(--ease-out);
}
.field-row:focus-within { border-color: var(--accent); background: var(--surface); }
.field-row input[type="text"] {
  flex: 1; border: 0; background: none; padding: .7rem 0; min-width: 0;
  font-size: 1.05rem; font-weight: 600; color: var(--text);
}
.field-row input[type="text"]:focus { outline: 0; }
.field-suffix { font-size: .85rem; color: var(--text-faint); font-weight: 600; }
.field-range { width: 100%; margin-bottom: .35rem; accent-color: var(--accent); cursor: pointer; }
.field-error { color: var(--danger); font-size: .82rem; font-weight: 600; }
.field.has-error .field-row { border-color: var(--danger); background: var(--danger-tint); }

select#trip-fuel-type {
  width: 100%; padding: .75rem .85rem; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--surface-2); color: var(--text);
  font-weight: 600; font-size: .95rem; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23536077' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .85rem center;
}
select#trip-fuel-type:focus { outline: 0; border-color: var(--accent); }

.stepper { display: flex; align-items: center; background: var(--surface-2); border: 1.5px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.stepper-btn { padding: .7rem 1rem; font-size: 1.1rem; font-weight: 700; color: var(--accent); }
.stepper-btn:hover { background: var(--accent-tint); }
.stepper input { flex: 1; text-align: center; border: 0; background: none; padding: .7rem 0; font-size: 1.05rem; font-weight: 600; }
.stepper input:focus { outline: 0; }

.segmented { display: flex; background: var(--surface-2); border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 3px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  flex: 1; text-align: center; padding: .6rem .5rem; border-radius: calc(var(--radius-sm) - 3px);
  font-weight: 600; font-size: .9rem; color: var(--text-muted); cursor: pointer;
  transition: background .15s var(--ease-out), color .15s var(--ease-out);
}
.segmented input:checked + label { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }
.segmented input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }

/* =============================================================
   6. Secciones
   ============================================================= */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.site-header__inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.logo { display: flex; align-items: center; gap: .5rem; font-weight: 800; font-size: 1.05rem; color: var(--text); }
.logo svg { color: var(--accent); }
.site-nav { display: none; gap: 1.5rem; font-weight: 600; font-size: .92rem; color: var(--text-muted); }
.site-nav a:hover { color: var(--accent); }

.page-grid { padding-block: 2rem 4rem; display: grid; gap: 2.5rem; }
.page-main { min-width: 0; display: flex; flex-direction: column; gap: 3rem; }
.page-aside { display: none; }

.hero { display: flex; flex-direction: column; gap: 1.25rem; padding-top: .5rem; }
.hero h1 { font-size: clamp(1.7rem, 1.3rem + 2vw, 2.5rem); max-width: 22ch; }
.hero-subtitle { color: var(--text-muted); font-size: 1.05rem; max-width: 62ch; }

.tool-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.5rem; box-shadow: var(--shadow);
}
.tool-card--secondary { box-shadow: var(--shadow-sm); }
.tool-subtitle { color: var(--text-muted); margin-bottom: 1.25rem; }

.tool-grid { display: grid; grid-template-columns: 1fr; gap: 1.1rem; margin-bottom: 1.5rem; }
.tool-grid--compact { margin-bottom: 1.25rem; }

.results { display: grid; grid-template-columns: repeat(2, 1fr); gap: .85rem; margin-bottom: .85rem; }
.result-card {
  background: var(--surface-2); border-radius: var(--radius); padding: 1.1rem 1.2rem;
  display: flex; flex-direction: column; gap: .3rem;
  transition: transform .2s var(--ease-out);
}
.result-label { font-size: .8rem; font-weight: 600; color: var(--text-muted); }
.result-value { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.01em; }
.result-sub { font-size: .85rem; font-weight: 600; color: var(--text-muted); }
.result-card--primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark)); color: #fff;
  grid-column: 1 / -1; padding: 1.4rem 1.4rem;
}
.result-card--primary .result-label { color: rgba(255,255,255,.85); }
.result-card--primary .result-value { font-size: clamp(2rem, 1.7rem + 1vw, 2.6rem); }
.result-card--primary .result-sub { color: rgba(255,255,255,.85); }

.results--secondary { grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.result-mini {
  background: var(--surface-2); border-radius: var(--radius-sm); padding: .75rem .6rem;
  display: flex; flex-direction: column; gap: .25rem; text-align: center;
}
.result-mini span { font-size: .72rem; color: var(--text-muted); font-weight: 600; }
.result-mini strong { font-size: 1.05rem; font-weight: 700; }

.tool-result-sentence { font-size: 1.15rem; font-weight: 600; margin: 1rem 0; padding: 1rem 1.2rem; background: var(--accent-tint); border-radius: var(--radius); color: var(--text); }
.tool-result-sentence strong { color: var(--accent-dark); font-size: 1.3rem; }

.tool-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1rem; }
.copy-feedback { min-height: 1.2em; font-size: .85rem; font-weight: 600; color: var(--success); margin-bottom: .5rem; }

.privacy-badge { font-size: .85rem; color: var(--text-muted); background: var(--success-tint); border-radius: var(--radius-sm); padding: .6rem .85rem; margin-bottom: .5rem; }
.honest-limits { font-size: .8rem; color: var(--text-faint); }

.recent-calcs { margin-top: 1.25rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.recent-calcs summary { cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--text-muted); }
.recent-calcs summary:hover { color: var(--accent); }
.recent-calcs ul { margin-top: .75rem; display: flex; flex-direction: column; gap: .4rem; }
.recent-calcs li { display: flex; justify-content: space-between; gap: .5rem; align-items: center; }
.recent-calcs button.recent-item {
  flex: 1; text-align: left; background: var(--surface-2); border-radius: var(--radius-sm);
  padding: .55rem .75rem; font-size: .85rem; color: var(--text); font-weight: 500;
}
.recent-calcs button.recent-item:hover { background: var(--accent-tint); }

.formula-box {
  background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius);
  padding: 1rem 1.25rem; font-size: 1.05rem; color: var(--text); max-width: 60ch;
}

.content-section--steps .steps-grid { display: grid; gap: 1.25rem; grid-template-columns: 1fr; }
.step { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.step-number {
  display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem;
  border-radius: 50%; background: var(--accent-tint); color: var(--accent-dark); font-weight: 800; margin-bottom: .6rem;
}

.example-list { display: flex; flex-direction: column; gap: .3rem; margin: .75rem 0; color: var(--text); }
.example-list li { padding-left: 1.2rem; position: relative; }
.example-list li::before { content: "•"; position: absolute; left: 0; color: var(--accent); font-weight: 800; }

.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.1rem; }

.tips-list { display: grid; gap: .75rem; grid-template-columns: 1fr; }
.tips-list li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .85rem 1rem; color: var(--text-muted); font-size: .92rem; }
.tips-list li strong { color: var(--text); }

.related-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
.related-card {
  display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.25rem; transition: transform .18s var(--ease-out), box-shadow .18s var(--ease-out), border-color .18s var(--ease-out);
}
.related-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--accent); }
.related-card h3 { color: var(--accent-dark); font-size: 1rem; }
.related-card p { color: var(--text-muted); font-size: .88rem; margin-top: .3rem; }

.faq-list { display: flex; flex-direction: column; gap: .6rem; }
.faq-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .9rem 1.1rem; }
.faq-item summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 1rem; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; font-size: 1.2rem; color: var(--accent); flex-shrink: 0; }
.faq-item[open] summary::after { content: "−"; }
.faq-item p { margin-top: .6rem; color: var(--text-muted); }

/* ---- Ad slots ---- */
.ad-slot {
  position: relative; display: flex; align-items: center; justify-content: center;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text-faint);
}
.ad-slot__label { font-size: .75rem; font-weight: 700; letter-spacing: .08em; color: var(--text-faint); }
.ad-slot--leaderboard { min-height: 90px; }
.ad-slot--incontent { min-height: 250px; }
.ad-slot--sidebar { min-height: 600px; }

.ad-floating-mobile {
  position: fixed; left: .75rem; right: .75rem; bottom: .75rem; z-index: 60;
  min-height: 56px; display: flex; align-items: center; justify-content: center;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); box-shadow: var(--shadow-lg);
}
.ad-floating-close {
  position: absolute; top: -10px; right: -10px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--text); color: #fff; font-size: .8rem; display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
}

.ad-interstitial { border: 0; border-radius: var(--radius-lg); padding: 0; max-width: 92vw; width: 420px; box-shadow: var(--shadow-lg); }
.ad-interstitial::backdrop { background: rgba(16,24,40,.55); }
.ad-interstitial__inner { position: relative; padding: 2.5rem 1.5rem 1.5rem; display: flex; flex-direction: column; align-items: center; gap: 1rem; }
.ad-interstitial__inner .ad-slot__label { font-size: 1rem; }
.ad-interstitial__note { font-size: .82rem; color: var(--text-faint); text-align: center; }
.ad-interstitial__close {
  position: absolute; top: .6rem; right: .6rem; width: 30px; height: 30px; border-radius: 50%;
  background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: .9rem;
}
.ad-interstitial__close:hover { background: var(--border); }

.site-footer { background: var(--surface); border-top: 1px solid var(--border); padding-block: 2.5rem 1.5rem; margin-top: 1rem; }
.footer-grid { display: grid; gap: 2rem; grid-template-columns: 1fr; margin-bottom: 1.5rem; }
.footer-brand p { color: var(--text-muted); font-size: .88rem; margin-top: .5rem; max-width: 34ch; }
.logo-text { font-weight: 800; font-size: 1.05rem; }
.footer-links h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); margin-bottom: .6rem; }
.footer-links { display: flex; flex-direction: column; gap: .5rem; }
.footer-links a { color: var(--text-muted); font-size: .9rem; }
.footer-links a:hover { color: var(--accent); }
.footer-copy { text-align: center; font-size: .78rem; color: var(--text-faint); border-top: 1px solid var(--border); padding-top: 1.25rem; }

/* =============================================================
   7. Efectos
   ============================================================= */
.result-value, .tool-result-sentence strong { transition: opacity .15s var(--ease-out); }

/* =============================================================
   8. Responsive
   ============================================================= */
@media (min-width: 540px) {
  .tool-grid { grid-template-columns: 1fr 1fr; }
  .results--secondary { grid-template-columns: repeat(3, 1fr); }
  .steps-grid { grid-template-columns: repeat(3, 1fr); }
  .related-grid { grid-template-columns: 1fr 1fr; }
  .tips-list { grid-template-columns: 1fr 1fr; }
  .footer-grid { grid-template-columns: 1.4fr 1fr 1fr; }
}

@media (min-width: 720px) {
  .site-nav { display: flex; }
  .results { grid-template-columns: repeat(4, 1fr); }
  .result-card--primary { grid-column: span 4; }
}

@media (min-width: 960px) {
  .tool-card { padding: 2rem; }
  .related-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1280px) {
  .page-grid { grid-template-columns: 1fr 300px; align-items: start; }
  .page-aside { display: block; position: sticky; top: 88px; }
  .ad-floating-mobile { display: none; }
}

/* =============================================================
   9. Reduced motion (solo lo intrusivo)
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn, .related-card, .result-card { transition: none; }
}
