:root {
  --bg: #f6f4f1;
  --surface: #ffffff;
  --text: #1d1d1f;
  --muted: #6b6b70;
  --border: #e3e0db;
  --accent: #c92a2a;
  --radius: 10px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141416;
    --surface: #1e1e21;
    --text: #ececef;
    --muted: #9a9aa2;
    --border: #2f2f34;
    --accent: #ff6b6b;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: inherit; }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }

.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;
}
.status { margin: 0 0 6px; }

.filters { position: sticky; top: 0; z-index: 2; background: var(--bg); padding-top: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.filters input, .filters button, .sheet input, .sheet select, .sheet button {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 12px;
}
.filters button, .sheet button { cursor: pointer; }
#q { width: 100%; padding: 10px 14px; border-radius: 10px; }
.row { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.quick { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.quick button { flex: none; }
.presets button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.filters-btn { margin-left: auto; flex: none; display: inline-flex; align-items: center; gap: 6px; }
.filters-btn .count {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: .75rem; font-weight: 700;
  display: inline-grid; place-items: center;
}
.filters-btn .count[hidden] { display: none; }

/* Ventana de filtros */
dialog {
  width: min(520px, calc(100% - 32px)); max-height: min(720px, calc(100% - 32px));
  padding: 0; border: 1px solid var(--border); border-radius: 16px;
  background: var(--surface); color: var(--text);
  box-shadow: 0 20px 50px rgb(0 0 0 / .25);
}
dialog::backdrop { background: rgb(0 0 0 / .45); }
.sheet { display: flex; flex-direction: column; max-height: inherit; }
.sheet-head, .sheet-foot { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; }
.sheet-head { border-bottom: 1px solid var(--border); }
.sheet-head h2 { margin: 0; font-size: 1.1rem; }
.sheet-foot { border-top: 1px solid var(--border); gap: 12px; }
.sheet-body { overflow-y: auto; padding: 6px 18px 12px; }
.sheet .icon-btn { border: 0; background: none; font-size: 1.1rem; padding: 4px 8px; color: var(--muted); }
.sheet .link-btn { border: 0; background: none; text-decoration: underline; padding: 8px 4px; }
.sheet .primary { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; padding: 10px 18px; }
fieldset { border: 0; margin: 0; padding: 14px 0 6px; }
fieldset + fieldset { border-top: 1px solid var(--border); }
/* float evita que la línea divisoria del fieldset atraviese la leyenda */
legend { float: left; width: 100%; font-weight: 600; padding: 0; margin-bottom: 10px; }
legend + * { clear: both; }
.dates { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.dates label { display: flex; flex-direction: column; gap: 4px; font-size: .82rem; color: var(--muted); }
.dates input, #municipality { width: 100%; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: .85rem; padding: 6px 12px; border-radius: 999px; }
.sheet .chip[aria-pressed="true"] { background: var(--c); border-color: var(--c); color: #fff; }

.day { margin: 28px 0 12px; font-size: 1.1rem; }
.day small { color: var(--muted); font-weight: 400; text-transform: none; }
.ongoing summary { cursor: pointer; font-weight: 600; margin: 20px 0 8px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.card {
  position: relative; display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 1px 2px rgb(0 0 0 / .04);
  transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgb(0 0 0 / .10); }
.card:focus-within { outline: 2px solid var(--c); outline-offset: 2px; }

.media {
  position: relative; aspect-ratio: 16 / 10; overflow: hidden;
  background: linear-gradient(135deg, var(--c), color-mix(in srgb, var(--c) 55%, #000));
}
.media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .3s ease; }
.card:hover .media img { transform: scale(1.04); }
.ph {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 3.2rem; color: rgb(255 255 255 / .85); text-shadow: 0 2px 12px rgb(0 0 0 / .2);
}
.badge {
  position: absolute; top: 10px; left: 10px; min-width: 50px; padding: 5px 8px 4px;
  display: flex; flex-direction: column; align-items: center; line-height: 1.05;
  background: var(--surface); color: var(--text); border-radius: 10px;
  box-shadow: 0 2px 8px rgb(0 0 0 / .18);
}
.badge .d { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.badge .m { font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--c); }
.price {
  position: absolute; top: 10px; right: 10px; max-width: 55%;
  padding: 4px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600;
  background: rgb(0 0 0 / .62); color: #fff; backdrop-filter: blur(4px);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.content { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px 14px; flex: 1; }
.cat { align-self: flex-start; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--c); }
.card h3 { margin: 0 0 2px; font-size: 1.05rem; line-height: 1.3; }
.card h3 a { text-decoration: none; }
.card h3 a::after { content: ""; position: absolute; inset: 0; } /* toda la tarjeta es clicable */
.info { margin: 0; font-size: .86rem; color: var(--muted); padding-left: 20px; position: relative; }
.info::before { position: absolute; left: 0; top: 0; width: 16px; text-align: center; }
.info.when::before { content: "🕒"; font-size: .8rem; }
.info.where::before { content: "📍"; font-size: .8rem; }
.desc {
  margin: 4px 0 0; font-size: .85rem; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.actions { margin-top: auto; padding-top: 10px; }
.btn {
  position: relative; z-index: 1; display: inline-block; padding: 6px 14px; border-radius: 8px;
  background: var(--c); color: #fff; font-size: .85rem; font-weight: 600; text-decoration: none;
}
.btn:hover { filter: brightness(1.1); }

.empty { text-align: center; color: var(--muted); padding: 48px 0; }
.foot { color: var(--muted); font-size: .8rem; padding-top: 24px; padding-bottom: 32px; }

@media (max-width: 600px) {
  .grid { grid-template-columns: 1fr; }
  .media { aspect-ratio: 2 / 1; }
  .filters-btn .label { display: none; } /* solo icono y contador */
  .filters-btn { padding: 7px 10px; }
  /* En móvil, la ventana de filtros sale desde abajo */
  dialog { width: 100%; max-width: none; margin: auto 0 0; border-radius: 16px 16px 0 0; max-height: 88vh; }
}
