/*
 * Señalética de parque nacional: letreros de sendero (Big Shoulders Display), lecturas de instrumento
 * para los precios (Spline Sans Mono), curvas de nivel de fondo y un naranja "marca de sendero" que se
 * reserva para lo que importa: las bajas y el precio más barato.
 */
:root {
  --paper: #f2eee3;
  --card: #fbf9f3;
  --ink: #1b211c;
  --muted: #5f675f;
  --line: #ddd7c7;
  --forest: #1f3a2d;
  --forest-2: #2c5240;
  --on-forest: #f2eee3;
  --blaze: #d9541e;
  --blaze-soft: #f8e1d4;
  --accent: #2c5240;
  --accent-soft: #e3eadf;
  --grid: #e4dfd1;
  --topo: rgba(242, 238, 227, .09);
  --display: 'Big Shoulders Display', 'Arial Narrow', sans-serif;
  --body: 'Atkinson Hyperlegible', system-ui, sans-serif;
  --mono: 'Spline Sans Mono', ui-monospace, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #101611;
    --card: #172019;
    --ink: #ebe6d8;
    --muted: #9ba597;
    --line: #29352b;
    --forest: #0b120d;
    --forest-2: #1d2e22;
    --on-forest: #ebe6d8;
    --blaze: #ff7a3d;
    --blaze-soft: #3a2116;
    --accent: #8cc5a0;
    --accent-soft: #1d2e22;
    --grid: #253027;
    --topo: rgba(235, 230, 216, .06);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.55 var(--body); background: var(--paper); color: var(--ink); }
a { color: var(--accent); text-underline-offset: 3px; }
h1, h2, .brand { font-family: var(--display); font-weight: 800; letter-spacing: .01em; line-height: 1.02; }
h1 { font-size: clamp(2rem, 4.5vw, 2.9rem); margin: 6px 0 14px; text-transform: uppercase; }
h2 { font-size: 1.5rem; margin: 0; text-transform: uppercase; }
small, .muted { color: var(--muted); font-weight: 400; }
.small { font-size: .82rem; }
code { font-family: var(--mono); background: var(--accent-soft); padding: 1px 5px; border-radius: 4px; font-size: .88em; }
:focus-visible { outline: 3px solid var(--blaze); outline-offset: 2px; }

/* Curvas de nivel: un patrón SVG liviano, repetido */
.topo {
  background-color: var(--forest);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='320' height='160' viewBox='0 0 320 160'%3E%3Cg fill='none' stroke='%23f2eee3' stroke-opacity='.09' stroke-width='1.2'%3E%3Cpath d='M-10 120c40-30 70-10 110-30s60-60 110-50 70 40 120 20'/%3E%3Cpath d='M-10 135c45-28 80-6 120-26s58-52 104-44 72 40 116 24'/%3E%3Cpath d='M-10 150c48-24 86-2 128-22s60-44 100-38 74 38 112 26'/%3E%3Cpath d='M-10 100c38-34 64-16 100-34s62-66 116-58 66 40 124 16'/%3E%3Cpath d='M150 60c10-14 34-18 46-6s2 30-18 30-38-10-28-24z'/%3E%3Cpath d='M138 62c14-24 52-30 72-10s4 48-28 48-62-14-44-38z'/%3E%3C/g%3E%3C/svg%3E");
  color: var(--on-forest);
}

/* Encabezado */
.top { display: flex; align-items: center; gap: 18px; padding: 14px 24px; flex-wrap: wrap; }
.brand { color: var(--on-forest); text-decoration: none; font-size: 1.7rem; text-transform: uppercase; display: inline-flex; align-items: center; gap: 10px; }
.brand svg { width: 30px; height: 30px; flex: none; }
.search { flex: 1; min-width: 220px; max-width: 560px; margin: 0 0 0 auto; position: relative; }
.search input { width: 100%; padding: 11px 16px 11px 40px; border: 0; border-radius: 999px; background: var(--paper); color: var(--ink); font: inherit; }
.search::before { content: ''; position: absolute; left: 15px; top: 50%; width: 13px; height: 13px; margin-top: -8px; border: 2px solid var(--muted); border-radius: 50%; }
.search::after { content: ''; position: absolute; left: 27px; top: 50%; width: 7px; height: 2px; margin-top: 4px; background: var(--muted); transform: rotate(45deg); }
.cats { display: flex; gap: 2px; overflow-x: auto; padding: 0 18px; background: var(--forest-2); scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.cats a { white-space: nowrap; padding: 10px 12px; color: var(--on-forest); opacity: .82; text-decoration: none; font-size: .9rem; border-bottom: 3px solid transparent; }
.cats a:hover, .cats a[aria-current] { opacity: 1; border-bottom-color: var(--on-forest); }
.cats a.deals { opacity: 1; color: #fff; background: var(--blaze); border-radius: 0; font-weight: 700; }
.cats a.deals:hover { border-bottom-color: #fff; }

main { max-width: 1200px; margin: 0 auto; padding: 22px 24px 56px; }
.foot { border-top: 1px solid var(--line); max-width: 1200px; margin: 0 auto; padding: 18px 24px 40px; color: var(--muted); font-size: .85rem; display: flex; gap: 18px; flex-wrap: wrap; justify-content: space-between; }
.foot p { margin: 0; max-width: 640px; }
.crumbs { margin: 0 0 6px; font-size: .85rem; color: var(--muted); font-family: var(--mono); letter-spacing: -.01em; }
.crumbs a { color: var(--muted); }

/* Portada */
.hero { margin: -22px -24px 26px; padding: 54px 24px 46px; }
.hero-inner { max-width: 1200px; margin: 0 auto; }
.hero h1 { font-size: clamp(2.6rem, 8vw, 5.4rem); margin: 0; max-width: 11ch; line-height: .92; }
.hero h1 em { font-style: normal; color: var(--blaze); }
.hero p { max-width: 54ch; font-size: 1.08rem; opacity: .88; margin: 16px 0 0; }
.hero .stats { display: flex; gap: 28px; flex-wrap: wrap; margin-top: 26px; font-family: var(--mono); font-size: .85rem; }
.hero .stats strong { display: block; font-size: 1.6rem; font-family: var(--display); font-weight: 800; letter-spacing: .02em; }
.lead { margin: -6px 0 22px; max-width: 70ch; }
main h2 { margin: 30px 0 12px; }

/* Bloques */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 4px; padding: 18px 20px; margin-bottom: 18px; }
.card h2 { margin-bottom: 12px; }
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar h2 { margin: 0; }
.grow { flex: 1; min-width: 160px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--card); }
.seg a { padding: 6px 14px; text-decoration: none; color: var(--muted); font-size: .9rem; }
.seg a.on { background: var(--forest-2); color: var(--on-forest); }
.btn { display: inline-block; padding: 12px 22px; border-radius: 3px; background: var(--forest-2); color: var(--on-forest); font-family: var(--display); font-weight: 800; font-size: 1.15rem; letter-spacing: .04em; text-transform: uppercase; text-decoration: none; }
.btn:hover { background: var(--forest); }
button.btn { border: 0; cursor: pointer; }
.btn.secondary { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.pill { display: inline-block; padding: 1px 10px; border-radius: 99px; border: 1px solid var(--line); font-size: .78rem; color: var(--muted); }
.pill.best { border-color: var(--blaze); color: var(--blaze); font-weight: 700; }
select { padding: 8px 12px; border: 1px solid var(--line); border-radius: 3px; background: var(--card); color: var(--ink); font: inherit; }

/* Tiles de categorías: letreros de sendero */
.tiles { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.tiles a { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 14px 40px 14px 16px; background: var(--forest-2); color: var(--on-forest); border-radius: 3px; text-decoration: none; transition: transform .15s ease, background .15s ease; }
.tiles a::after { content: '→'; position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font-family: var(--mono); opacity: .6; transition: transform .15s ease, opacity .15s; }
.tiles a:hover { background: var(--forest); transform: translateX(3px); }
.tiles a:hover::after { opacity: 1; transform: translate(3px, -50%); }
.tiles strong { font-family: var(--display); font-size: 1.3rem; text-transform: uppercase; letter-spacing: .02em; line-height: 1.05; }
.tiles .muted { color: var(--on-forest); opacity: .7; font-family: var(--mono); font-size: .8rem; }
.brands { display: flex; flex-wrap: wrap; gap: 6px; }
.brands .pill { text-decoration: none; padding: 4px 12px; font-size: .88rem; color: var(--ink); background: var(--card); }
.brands .pill:hover { border-color: var(--ink); }

/* Grilla de productos */
.grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.item { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 4px; padding: 10px 10px 12px; display: flex; flex-direction: column; gap: 4px; transition: border-color .15s, box-shadow .15s; }
.item:hover { border-color: var(--muted); box-shadow: 0 6px 18px -12px rgba(0, 0, 0, .35); }
.item a { text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: 8px; }
.item img, .noimg { width: 100%; height: auto; aspect-ratio: 1; object-fit: contain; background: #fff; border-radius: 2px; }
.noimg { display: block; background: var(--accent-soft); }
.item .title { font-size: .92rem; line-height: 1.3; }
.item .price { font-family: var(--mono); font-weight: 600; font-size: 1.08rem; letter-spacing: -.02em; margin-top: auto; }
.item > .muted { font-size: .82rem; }
.drop { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 2px; background: var(--blaze); color: #fff; font-size: .82rem; font-weight: 700; }
.pager { display: flex; justify-content: center; align-items: center; gap: 22px; margin: 26px 0; font-family: var(--mono); font-size: .9rem; }

/* Ficha de producto */
.product { display: grid; grid-template-columns: minmax(0, 440px) minmax(0, 1fr); gap: 32px; margin-bottom: 22px; align-items: start; }
.product-media img { width: 100%; height: auto; background: #fff; border-radius: 4px; border: 1px solid var(--line); }
.product-info h1 { font-size: clamp(1.9rem, 3.6vw, 2.6rem); }
.now { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 10px 0 6px; }
.now strong { font-family: var(--mono); font-size: 2.4rem; font-weight: 600; letter-spacing: -.04em; }
.now s { font-family: var(--mono); }

/* Altímetro de precio: dónde está hoy entre el mínimo y el máximo del período */
.altimeter { margin: 18px 0 20px; padding: 14px 16px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 4px; }
.altimeter-verdict { font-family: var(--display); font-weight: 800; font-size: 1.35rem; text-transform: uppercase; letter-spacing: .02em; margin: 0 0 10px; }
.altimeter-verdict.low { color: var(--forest-2); }
.altimeter-verdict.high { color: var(--blaze); }
@media (prefers-color-scheme: dark) { .altimeter-verdict.low { color: var(--accent); } }
.altimeter-track { position: relative; height: 10px; border-radius: 99px; background: linear-gradient(90deg, var(--forest-2), #a9a46a 50%, var(--blaze)); }
.altimeter-mark { position: absolute; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; background: var(--card); border: 4px solid var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, .3); }
.altimeter-scale { display: flex; justify-content: space-between; margin-top: 8px; font-family: var(--mono); font-size: .78rem; color: var(--muted); }

/* Tablas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 400; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; font-family: var(--mono); }
td.num { white-space: nowrap; font-family: var(--mono); }
tr.current td { background: var(--accent-soft); }

/* Gráfico */
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--grid); }
.chart .axis { fill: var(--muted); font-family: var(--mono); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .85rem; margin: 8px 0 0; }
.legend i { display: inline-block; width: 14px; height: 4px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }

/* Panel y formularios */
.card.narrow { max-width: 440px; }
label { display: block; font-weight: 700; margin: 12px 0 4px; }
input[type=email], input[type=password] { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 3px; background: var(--paper); color: var(--ink); font: inherit; margin-top: 4px; }
button.link { background: none; border: 0; color: var(--muted); padding: 0; font: inherit; cursor: pointer; text-decoration: underline; }
.bad { color: var(--blaze); font-weight: 700; }
ul.plain { list-style: none; padding: 0; margin: 0; } ul.plain li { padding: 3px 0; }
.match-sides { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.match-side { display: flex; gap: 12px; align-items: flex-start; }
.match-side img { width: 120px; height: 120px; object-fit: contain; background: #fff; border-radius: 2px; flex: none; }
.match-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* Entrada: los productos aparecen escalonados una sola vez */
@media (prefers-reduced-motion: no-preference) {
  .grid .item { animation: rise .45s ease both; }
  .grid .item:nth-child(2) { animation-delay: .03s; } .grid .item:nth-child(3) { animation-delay: .06s; }
  .grid .item:nth-child(4) { animation-delay: .09s; } .grid .item:nth-child(5) { animation-delay: .12s; }
  .grid .item:nth-child(6) { animation-delay: .15s; } .grid .item:nth-child(n+7) { animation-delay: .18s; }
  .hero h1, .hero p, .hero .stats { animation: rise .6s ease both; }
  .hero p { animation-delay: .08s; } .hero .stats { animation-delay: .16s; }
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (max-width: 760px) {
  .top { padding: 12px 16px; gap: 10px; }
  .brand { font-size: 1.45rem; }
  .search { margin: 0; flex-basis: 100%; }
  main { padding: 16px 16px 44px; }
  .hero { margin: -16px -16px 22px; padding: 36px 16px 32px; }
  .hero .stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; font-size: .74rem; }
  .hero .stats strong { font-size: 1.35rem; }
  .product { grid-template-columns: 1fr; gap: 18px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .match-sides { grid-template-columns: 1fr; }
  .match-side img { width: 80px; height: 80px; }
  .foot { padding: 16px; }
}

/* Móvil: "Dónde comprarlo" como tarjetas, y el gráfico con ancho mínimo legible (se desliza) */
.chart-wrap { overflow-x: auto; }
@media (max-width: 760px) {
  .chart { min-width: 620px; }
  table.where thead { display: none; }
  table.where tr { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "store price" "prod prod" "link link"; gap: 4px 12px; padding: 12px 8px; border-bottom: 1px solid var(--line); }
  table.where td { border: 0; padding: 0; background: none; }
  table.where tr.current { background: var(--accent-soft); }
  table.where td:nth-child(1) { grid-area: store; font-weight: 700; }
  table.where td:nth-child(2) { grid-area: prod; }
  table.where td:nth-child(3) { grid-area: price; text-align: right; }
  table.where td:nth-child(4) { grid-area: link; font-size: .9rem; }
}

/* Comparación entre tiendas, junto al precio */
.compare { margin: 12px 0 16px; padding: 14px 16px; border-radius: 4px; }
.compare p { margin: 0; }
.compare p + p { margin-top: 10px; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.compare.cheaper { background: var(--blaze-soft); border-left: 5px solid var(--blaze); }
.compare.cheaper strong { font-size: 1.1rem; }
.compare.cheaper .btn { background: var(--blaze); color: #fff; }
.compare.best { background: var(--accent-soft); border-left: 5px solid var(--forest-2); font-weight: 700; }
