/* =========================================================
   TOKENS
========================================================= */
:root {
  --ink: #14181D;
  --ink-soft: #6B7280;
  --paper: #FFFFFF;
  --paper-soft: #F4F5F6;
  --line: #E4E6E8;
  --line-strong: #C7CBCF;

  --cobalt: #2A5CAA;   /* azul altiplano — acento primario */
  --ochre: #C97A2B;    /* tierra andina — acento secundario, uso puntual */

  --font-display: "Space Grotesk", "Arial Narrow", sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "IBM Plex Mono", "Courier New", monospace;

  --radius: 3px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--cobalt);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* =========================================================
   HEADER
========================================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.site-header__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 32px;
  max-width: 1400px;
  margin: 0 auto;
}

.logo {
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  white-space: nowrap;
}

.logo__mark {
  width: 9px;
  height: 9px;
  background: var(--cobalt);
  display: inline-block;
  transform: rotate(45deg);
  flex-shrink: 0;
}

.logo__place {
  color: var(--ink-soft);
  font-weight: 500;
}

/* Signature: regla de altitud — marcas tipo escala junto al buscador */
.search {
  flex: 1;
  max-width: 460px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--paper-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 16px;
  transition: border-color 0.15s ease;
}

.search:focus-within {
  border-color: var(--cobalt);
}

.search__icon {
  width: 16px;
  height: 16px;
  color: var(--ink-soft);
  flex-shrink: 0;
}

.search input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
}

.search input::placeholder { color: var(--ink-soft); }
.search input:focus { outline: none; }

/* Botón de carrito / selección */
.cart-button {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  color: var(--ink);
  flex-shrink: 0;
  transition: border-color 0.15s ease;
}

.cart-button:hover { border-color: var(--cobalt); }

.cart-button svg { width: 18px; height: 18px; flex-shrink: 0; }

.cart-button__label {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 13.5px;
  white-space: nowrap;
}

.cart-button__count {
  background: var(--ochre);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 11px;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* Category nav — fila de altitud/escala como referencia al vuelo */
.category-nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 0 32px 10px;
  max-width: 1400px;
  margin: 0 auto;
  scrollbar-width: none;
}
.category-nav::-webkit-scrollbar { display: none; }

.category-nav__item {
  flex-shrink: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13.5px;
  padding: 7px 14px;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  border-radius: var(--radius);
  transition: color 0.15s ease, background 0.15s ease;
}

.category-nav__item:hover {
  color: var(--ink);
}

.category-nav__item--active {
  color: var(--paper);
  background: var(--cobalt);
}

/* Tag row */
.tag-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 32px 14px;
  max-width: 1400px;
  margin: 0 auto;
  border-top: 1px dashed var(--line);
  padding-top: 12px;
  scrollbar-width: none;
}
.tag-row::-webkit-scrollbar { display: none; }

.tag {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 5px 11px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.tag:hover { border-color: var(--ochre); }

.tag--active {
  background: var(--ochre);
  border-color: var(--ochre);
  color: var(--paper);
}

/* =========================================================
   RESULTS / GRID
========================================================= */
.results {
  padding: 22px 32px 96px;
  max-width: 1400px;
  margin: 0 auto;
}

.results__bar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0 0 16px;
}

.results__count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-soft);
  margin: 0;
}

.results__clear {
  font-family: var(--font-mono);
  font-size: 12px;
  background: none;
  border: none;
  color: var(--cobalt);
  cursor: pointer;
  padding: 0;
}

.results__clear:hover { text-decoration: underline; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px 16px;
}

.card {
  cursor: pointer;
  border: none;
  background: none;
  text-align: left;
  padding: 0;
  width: 100%;
}

.card__frame {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--paper-soft);
  border-radius: var(--radius);
}

.card__thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card__preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none; /* deja que el click llegue a la tarjeta */
}

.card__preview--visible { opacity: 1; }

.card__duration-hint {
  position: absolute;
  bottom: 6px;
  right: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--paper);
  background: rgba(20,24,29,0.6);
  padding: 2px 6px;
  border-radius: var(--radius);
  transition: opacity 0.15s ease;
}

.card__frame--previewing .card__duration-hint { opacity: 0; }

/* Botón "+ Agregar" / "✓ En selección" sobre la miniatura */
.card__add {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 5px 9px;
  border: 1px solid rgba(255,255,255,0.5);
  background: rgba(20,24,29,0.55);
  color: var(--paper);
  border-radius: 999px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.card:hover .card__add,
.card:focus-within .card__add,
.card__add--active {
  opacity: 1;
}

.card__add:hover {
  border-color: var(--paper);
}

.card__add--active {
  background: var(--cobalt);
  border-color: var(--cobalt);
}

.card__title-overlay {
  position: absolute;
  inset: auto 0 0 0;
  padding: 20px 10px 8px;
  background: linear-gradient(to top, rgba(20,24,29,0.82), transparent);
  color: var(--paper);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 12.5px;
  line-height: 1.3;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.card:hover .card__title-overlay,
.card:focus-visible .card__title-overlay {
  opacity: 1;
}

.card__meta {
  padding: 8px 1px 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.card__category {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--cobalt);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.card__location {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-soft);
  white-space: nowrap;
}

.empty-state {
  padding: 64px 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-soft);
}

/* =========================================================
   MODAL
========================================================= */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 29, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}

.modal[hidden] { display: none; }

.modal__panel {
  width: 100%;
  max-width: 920px;
  background: var(--ink);
  border-radius: var(--radius);
  overflow: hidden;
}

.modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px 20px;
  gap: 16px;
}

.modal__title {
  color: var(--paper);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  margin: 0 0 4px;
}

.modal__meta {
  color: rgba(255,255,255,0.55);
  font-family: var(--font-mono);
  font-size: 11px;
  margin: 0;
}

.modal__close {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.3);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 6px 10px;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: var(--radius);
}

.modal__close:hover {
  border-color: var(--ochre);
  color: var(--ochre);
}

.modal__frame-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
}

.modal__frame-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* Panel de selección */
.modal__panel--cart {
  max-width: 560px;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
}

.cart-list {
  overflow-y: auto;
  padding: 0 20px;
  flex: 1;
}

.cart-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.cart-item__thumb {
  width: 64px;
  height: 40px;
  object-fit: cover;
  border-radius: var(--radius);
  flex-shrink: 0;
}

.cart-item__info { flex: 1; min-width: 0; }

.cart-item__title {
  color: var(--paper);
  font-size: 13px;
  font-weight: 500;
  margin: 0 0 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cart-item__meta {
  color: rgba(255,255,255,0.5);
  font-family: var(--font-mono);
  font-size: 11px;
  margin: 0;
}

.cart-item__remove {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.55);
  cursor: pointer;
  font-size: 13px;
  padding: 4px 6px;
  flex-shrink: 0;
}

.cart-item__remove:hover { color: var(--ochre); }

.cart-empty {
  padding: 32px 20px 40px;
  color: rgba(255,255,255,0.55);
  font-family: var(--font-mono);
  font-size: 12.5px;
  text-align: center;
  margin: 0;
}

.cart-actions {
  display: flex;
  gap: 10px;
  padding: 16px 20px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-wrap: wrap;
}

.cart-actions__btn {
  flex: 1;
  min-width: 160px;
  text-align: center;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 13px;
  padding: 11px 14px;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.3);
  background: transparent;
  color: var(--paper);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.cart-actions__btn:hover {
  border-color: var(--paper);
}

.cart-actions__btn--whatsapp {
  background: #25D366;
  border-color: #25D366;
  color: #0B1B12;
}

.cart-actions__btn--whatsapp:hover {
  background: #1fb958;
  border-color: #1fb958;
}

/* =========================================================
   FOOTER
========================================================= */
.footer {
  border-top: 1px solid var(--line);
  padding: 28px 32px 40px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-soft);
}

.footer__inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

/* =========================================================
   RESPONSIVE
========================================================= */
@media (max-width: 700px) {
  .site-header__top {
    flex-wrap: wrap;
    padding: 14px 20px;
  }
  .logo { order: 1; }
  .cart-button { order: 2; }
  .search { order: 3; max-width: 100%; flex-basis: 100%; }
  .cart-button__label { display: none; }
  .category-nav, .tag-row, .results, .footer__inner {
    padding-left: 20px;
    padding-right: 20px;
  }
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px 10px;
  }
}
