/* Euro Rastro · paleta 2 (clara y limpia)
   Layout: banda oscura de cabecera + hero fotográfico, cuerpo claro en tarjetas blancas,
   números de pieza en mono como detalle de taller. */
:root {
  --bg: #F4F6F3;
  --surface: #FFFFFF;
  --ink: #1C1F22;
  --ink-2: #3A3F45;
  --muted: #5C6168;
  --line: #DADDD6;
  --brand: #7CC242;
  --accent: #4C8422;
  --accent-hover: #3F6F1C;
  --soft: #E8F5DC;
  --soft-ink: #2F5512;
  --warn-bg: #FFF4D6; --warn-ink: #7A5200;
  --bad-bg: #FBE7E4; --bad-ink: #8F2A1D;
  --info-bg: #E5EEF8; --info-ink: #1F4E80;
  --f-display: "Archivo", "Arial Narrow", system-ui, sans-serif;
  --f-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --r: 10px;
  --wrap: 1180px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; animation: none !important; } }
body { background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.6; margin: 0; }
h1, h2, h3, h4 { font-family: var(--f-display); font-stretch: 112%; line-height: 1.12; margin: 0; text-wrap: balance; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--accent); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.mono { font-family: var(--f-mono); font-size: 0.92em; letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; border-radius: 8px; border: 1px solid transparent; font-weight: 600; font-size: 14px; text-decoration: none; cursor: pointer; transition: background .15s, border-color .15s, transform .1s; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn-ghost:hover { background: var(--ink); color: #fff; }
.btn-light { background: transparent; color: #fff; border-color: rgba(255,255,255,.55); }
.btn-light:hover { background: rgba(255,255,255,.1); border-color: #fff; }
.btn-soft { background: var(--soft); color: var(--soft-ink); }
.btn-soft:hover { background: #d7edc3; }
.btn-danger { background: transparent; color: var(--bad-ink); border-color: #e3b5ad; }
.btn-danger:hover { background: var(--bad-bg); }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 13px; }
.btn svg { width: 18px; height: 18px; flex: none; }

/* Pills */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: #EEF0EC; color: var(--ink-2); white-space: nowrap; }
.pill.ok { background: var(--soft); color: var(--soft-ink); }
.pill.warn { background: var(--warn-bg); color: var(--warn-ink); }
.pill.bad { background: var(--bad-bg); color: var(--bad-ink); }
.pill.info { background: var(--info-bg); color: var(--info-ink); }
.pill.dark { background: var(--ink); color: #fff; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* Formularios */
.field { display: grid; gap: 6px; min-width: 0; }
.field label, .label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.input, select.input, textarea.input { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
textarea.input { min-height: 96px; resize: vertical; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,194,66,.25); }
.error { color: var(--bad-ink); font-size: 13px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check { position: relative; }
.check input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.check span { display: inline-flex; align-items: center; min-height: 38px; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 13px; font-weight: 500; cursor: pointer; }
.check input:checked + span { background: var(--ink); color: #fff; border-color: var(--ink); }
.check input:focus-visible + span { outline: 3px solid var(--brand); outline-offset: 2px; }

/* Fotos con respaldo si no cargan */
.ph { background-color: #2A2D31; background-image: var(--img); background-size: cover; background-position: center; position: relative; }
.ph::after { content: ""; position: absolute; inset: 0; background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.035) 0 10px, transparent 10px 20px); pointer-events: none; }
.ph.has-img::after { display: none; }

/* Tarjeta de pieza */
.part { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; display: flex; flex-direction: column; min-width: 0; cursor: pointer; transition: border-color .15s, transform .15s; text-align: left; padding: 0; }
.part:hover { border-color: var(--accent); transform: translateY(-2px); }
.part .ph { aspect-ratio: 4 / 3; }
.part .tag { position: absolute; top: 10px; left: 10px; z-index: 1; }
.part-body { padding: 14px; display: grid; gap: 6px; flex: 1; align-content: start; }
.part-body h3 { font-size: 16px; font-stretch: 100%; letter-spacing: 0; }
.part-num { font-family: var(--f-mono); font-size: 12.5px; color: var(--ink-2); background: #F1F3EF; padding: 2px 7px; border-radius: 4px; justify-self: start; }
.part-fit { font-size: 12.5px; color: var(--muted); }
.part-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); }
.price { font-family: var(--f-display); font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.price.q { font-family: var(--f-body); font-size: 13px; font-weight: 600; color: var(--accent); }

/* Modal */
dialog { border: none; padding: 0; border-radius: 14px; width: min(860px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgba(20,22,24,.6); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal-body { padding: 20px; }
.icon-btn { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; flex: none; }
.icon-btn:hover { border-color: var(--ink); }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; font-weight: 500; opacity: 0; transition: .2s; z-index: 100; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.demo-bar { background: var(--warn-bg); color: var(--warn-ink); font-size: 13px; text-align: center; padding: 7px 16px; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--r); background: var(--surface); }
.empty strong { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }

/* =====================================================================
   Animaciones (estilo de la referencia). Todo se desactiva con
   prefers-reduced-motion. Si el JS no corre, el contenido queda visible.
   ===================================================================== */
:root { --ease-out: cubic-bezier(.16, 1, .3, 1); }

/* Aparición al hacer scroll */
.anim [data-reveal] { opacity: 0; transform: translateY(28px); transition: opacity .8s var(--ease-out), transform .8s var(--ease-out); transition-delay: calc(var(--i, 0) * 80ms); }
.anim [data-reveal="left"] { transform: translateX(-36px); }
.anim [data-reveal="right"] { transform: translateX(36px); }
.anim [data-reveal="zoom"] { transform: scale(.94); }
.anim [data-reveal].in { opacity: 1; transform: none; }

/* Titular del inicio palabra por palabra */
.words .w { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: .16em; margin-bottom: -.16em; }
.words .w > span { display: inline-block; }
.anim .words .w > span { transform: translateY(105%); animation: wordUp .9s var(--ease-out) forwards; animation-delay: calc(120ms + var(--i, 0) * 70ms); }
@keyframes wordUp { to { transform: none; } }
.anim .hero-fade { opacity: 0; animation: fadeUp .9s var(--ease-out) forwards; animation-delay: var(--d, .5s); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

/* Foto del inicio: acercamiento lento */
.anim .hero > .ph.has-img { animation: kenburns 22s ease-out both; transform-origin: 70% 40%; }
@keyframes kenburns { from { transform: scale(1.12); } to { transform: scale(1); } }

/* Cinta de marcas infinita */
.marquee { overflow: hidden; flex: 1; min-width: 0; -webkit-mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent); mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent); }
.marquee-track { display: flex; gap: 40px; width: max-content; animation: marquee 32s linear infinite; }
.marquee:hover .marquee-track, .marquee:focus-within .marquee-track { animation-play-state: paused; }
@keyframes marquee { to { transform: translateX(calc(-50% - 20px)); } }

/* Texto que rueda en los botones al pasar el mouse */
.roll { display: inline-block; overflow: hidden; line-height: 1.25; height: 1.25em; vertical-align: middle; }
.roll > span { display: block; transition: transform .45s var(--ease-out); text-shadow: 0 1.25em 0 currentColor; }
.btn:hover .roll > span, .btn:focus-visible .roll > span { transform: translateY(-1.25em); }

/* Brillo que cruza el botón principal */
.btn-primary { position: relative; overflow: hidden; isolation: isolate; }
.btn-primary::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.28) 50%, transparent 70%); transform: translateX(-120%); transition: transform .7s var(--ease-out); }
.btn-primary:hover::before { transform: translateX(120%); }

/* Tarjetas de piezas al cargar resultados */
.anim .part.pop { animation: cardIn .6s var(--ease-out) backwards; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes cardIn { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }
.car { transition: transform .25s var(--ease-out), border-color .2s, box-shadow .25s; }
.car:hover { transform: translateY(-4px); box-shadow: 0 14px 30px -18px rgba(28,31,34,.45); border-color: var(--accent); }
.part:hover { box-shadow: 0 14px 30px -18px rgba(28,31,34,.45); }

/* Pestañas del buscador: indicador deslizante */
.tabs { position: relative; }
.tabs .tab { position: relative; z-index: 1; transition: color .2s; }
.tabs.has-ind .tab[aria-selected="true"] { background: transparent; box-shadow: none; }
.tab-ind { position: absolute; top: 4px; bottom: 4px; left: 4px; border-radius: 7px; background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.1); transition: transform .45s var(--ease-out), width .45s var(--ease-out); }
[data-panel]:not([hidden]) { animation: fadeUp .45s var(--ease-out); }

/* Cabecera compacta al bajar */
.top .wrap { transition: min-height .3s var(--ease-out); }
.top.scrolled { box-shadow: 0 8px 24px -12px rgba(0,0,0,.5); }
.top.scrolled .wrap { min-height: 54px; }

/* Pasos con línea que se dibuja */
.steps { position: relative; }
.steps::before { content: ""; position: absolute; left: 17px; top: 18px; bottom: 18px; width: 2px; background: rgba(124,194,66,.35); transform-origin: top; transform: scaleY(1); }
.anim .steps:not(.in)::before { transform: scaleY(0); }
.steps::before { transition: transform 1.2s var(--ease-out) .2s; }
.steps li { position: relative; }
.steps li::before { position: relative; z-index: 1; }

/* Modal */
dialog[open] { animation: dlgIn .4s var(--ease-out); }
dialog[open]::backdrop { animation: fadeIn .3s ease; }
@keyframes dlgIn { from { opacity: 0; transform: translateY(24px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } }

/* Volver arriba */
.to-top { position: fixed; right: calc(16px + env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 40; width: 46px; height: 46px; border-radius: 50%; border: none; background: var(--ink); color: #fff; cursor: pointer; display: grid; place-items: center; box-shadow: 0 8px 20px -8px rgba(0,0,0,.5); opacity: 0; transform: translateY(16px); pointer-events: none; transition: opacity .3s, transform .3s var(--ease-out), background .2s; }
.to-top.show { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { background: var(--accent); }

/* Panel: cambio de vista */
.main.swap > * { animation: fadeUp .5s var(--ease-out) backwards; }
.main.swap > *:nth-child(2) { animation-delay: .05s; }
.main.swap > *:nth-child(3) { animation-delay: .1s; }
.main.swap > *:nth-child(4) { animation-delay: .15s; }
.stat { transition: transform .25s var(--ease-out), border-color .2s; }
.stat:hover { transform: translateY(-3px); }

@media (prefers-reduced-motion: reduce) {
  .anim [data-reveal], .anim .words .w > span, .anim .hero-fade, .anim .part.pop { opacity: 1 !important; transform: none !important; animation: none !important; }
  .marquee-track { animation: none; flex-wrap: wrap; }
  .marquee-track .dup { display: none; }
  .marquee { -webkit-mask-image: none; mask-image: none; }
  .roll > span { transition: none; }
}

/* Detalles extra */
.hero { overflow: hidden; }
.brand-btn { white-space: nowrap; flex: none; transition: color .2s, border-color .2s, transform .3s var(--ease-out); }
.brand-btn:hover { transform: translateY(-2px); }
.nav a { position: relative; }
.nav a::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 4px; height: 2px; background: var(--brand); transform: scaleX(0); transform-origin: left; transition: transform .35s var(--ease-out); }
.nav a:hover::after, .nav a:focus-visible::after { transform: scaleX(1); }
.cat .cap b { display: inline-flex; align-items: center; gap: 6px; }
.cat .cap b::after { content: "→"; opacity: 0; transform: translateX(-6px); transition: opacity .3s, transform .3s var(--ease-out); color: var(--brand); }
.cat:hover .cap b::after, .cat:focus-visible .cap b::after { opacity: 1; transform: none; }
.how > div { transition: transform .3s var(--ease-out), border-color .2s, box-shadow .3s; }
.how > div:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: 0 14px 30px -18px rgba(28,31,34,.45); }
.car-card { transition: transform .25s var(--ease-out), border-color .2s, box-shadow .25s; }
.car-card:hover { transform: translateY(-4px); box-shadow: 0 14px 30px -18px rgba(28,31,34,.45); }
.ph { transition: background-color .4s; }
.ph.has-img { animation: imgIn .7s ease both; }
@keyframes imgIn { from { filter: brightness(.6) saturate(.6); } to { filter: none; } }
.anim .hero > .ph.has-img { animation: kenburns 22s ease-out both; }
.bar i { transition: width 1s var(--ease-out) .2s; }
.toast { transition: opacity .3s, transform .4s var(--ease-out); }
.chip-x { animation: fadeUp .35s var(--ease-out) backwards; }
.thumb { animation: cardIn .35s var(--ease-out) backwards; }
/* Evita desborde lateral mientras los elementos entran desde los lados */
html, body { overflow-x: clip; }

[hidden] { display: none !important; }
