/* ============================================================== *
 *  gallery.css — The Gallery, compare overlay, and command palette
 * ============================================================== */

/* ---- landing → gallery link ---- */
.landing__gallery-link {
  display: inline-flex;
  align-self: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.4rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--text-mid);
  transition: color var(--t-fast);
}
.landing__gallery-link svg { width: 17px; height: 17px; color: var(--accent); transition: transform var(--t-med) var(--ease-out); }
.landing__gallery-link:hover { color: var(--paper); }
.landing__gallery-link:hover svg { transform: translateX(5px); }

/* ============================================================== *
 *  Gallery view
 * ============================================================== */
.gallery {
  --sel: #d8a566; /* one consistent "compare" colour, independent of brand accent */
  position: relative;
  width: min(100% - 2.4rem, var(--maxw));
  margin-inline: auto;
  padding-top: calc(var(--topbar-h) + clamp(2rem, 6vh, 4rem));
  padding-bottom: clamp(4rem, 10vh, 7rem);
}
.gallery.is-comparing { padding-bottom: clamp(6.5rem, 12vh, 8.5rem); }
.gallery__head { max-width: 64ch; margin-bottom: clamp(1.6rem, 4vh, 2.4rem); }
.gallery__kicker {
  display: inline-flex; align-items: center; gap: 0.75rem;
  font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.24em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 0.9rem;
}
.gallery__kicker::before { content: ''; width: 36px; height: 1px; background: var(--accent); opacity: 0.7; }
.gallery__title { font-size: clamp(2.8rem, 8vw, 5.2rem); font-weight: 500; color: var(--paper); }
.gallery__intro { margin-top: 1rem; color: var(--text-mid); font-size: clamp(1rem, 1.4vw, 1.12rem); }
.gallery__intro strong { color: var(--paper); font-weight: 600; }

/* controls */
.gallery__controls {
  position: sticky;
  top: var(--topbar-h);
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.8rem 1rem;
  padding: 1rem 0;
  margin-bottom: 0.4rem;
  background: linear-gradient(180deg, var(--ink-950) 70%, transparent);
}
.gallery__field {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex: 1 1 240px;
  min-height: 48px;
  padding: 0 0.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-mid);
}
.gallery__field:focus-within { border-color: color-mix(in srgb, var(--accent) 55%, transparent); color: var(--text-hi); }
.gallery__field svg { width: 18px; height: 18px; flex: none; }
.gallery__search {
  flex: 1; min-width: 0;
  background: none; border: none; outline: none;
  color: var(--text-hi); font-family: var(--font-body); font-size: 0.98rem;
}
.gallery__search::placeholder { color: var(--text-lo); }

.gallery__selects { display: flex; flex-wrap: wrap; gap: 0.6rem; }

/* home-made dark dropdown */
.gx-select { position: relative; }
.gx-select__btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  min-height: 48px; padding: 0 0.9rem;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text-hi);
  font-family: var(--font-body); font-size: 0.92rem;
  transition: border-color var(--t-fast);
}
.gx-select__btn:hover,
.gx-select.is-open .gx-select__btn { border-color: var(--line-strong); }
.gx-select__cap { font-family: var(--font-mono); font-size: 0.58rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-lo); }
.gx-select__value { font-weight: 500; }
.gx-select__chev { width: 16px; height: 16px; color: var(--text-mid); transition: transform var(--t-fast); }
.gx-select.is-open .gx-select__chev { transform: rotate(180deg); }

.gx-select__menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40;
  min-width: 220px; max-width: 90vw; max-height: 340px; overflow-y: auto;
  padding: 0.4rem; margin: 0;
  background: var(--ink-850);
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  box-shadow: 0 30px 70px -24px rgba(0, 0, 0, 0.9);
  outline: none;
}
.gx-select__opt {
  display: flex; align-items: center;
  padding: 0.55rem 0.7rem; border-radius: var(--radius-sm);
  font-size: 0.92rem; color: var(--text-mid); cursor: pointer;
}
.gx-select__opt.is-focused { background: var(--surface-2); color: var(--text-hi); }
.gx-select__opt.is-active { color: var(--paper); }
.gx-select__opt.is-active::after { content: '✓'; margin-left: auto; padding-left: 0.6rem; color: var(--accent); }
.gallery__compare-toggle {
  display: inline-flex; align-items: center; gap: 0.45rem;
  min-height: 48px; padding: 0 1.1rem;
  border: 1px solid var(--line); border-radius: var(--radius);
  font-family: var(--font-mono); font-size: 0.8rem; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--text-mid);
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}
.gallery__compare-toggle svg { width: 18px; height: 18px; }
.gallery__compare-toggle:hover { color: var(--text-hi); border-color: var(--line-strong); }
.gallery__compare-toggle.is-active { background: var(--accent); border-color: var(--accent); color: #0c0a06; }

.gallery__surprise {
  display: inline-flex; align-items: center; gap: 0.45rem;
  min-height: 48px; padding: 0 1.1rem;
  border: 1px solid var(--line); border-radius: var(--radius);
  font-family: var(--font-mono); font-size: 0.8rem; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--text-mid);
  transition: color var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.gallery__surprise svg { width: 18px; height: 18px; }
.gallery__surprise:hover { color: var(--text-hi); border-color: var(--line-strong); }
.gallery__surprise:active { transform: scale(0.97); }

.gallery__decades { display: flex; flex-wrap: wrap; gap: 0.5rem; width: 100%; }
.gallery__count {
  margin: 0.4rem 0 1.2rem;
  font-family: var(--font-mono); font-size: 0.74rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-lo);
}

/* grid + cards */
.gallery__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: clamp(0.8rem, 1.6vw, 1.2rem);
}
.gallery__cell { --accent: #fff; }
.gallery-card {
  position: relative;
  display: flex; flex-direction: column;
  width: 100%; text-align: left; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--ink-850);
  transition: transform var(--t-med) var(--ease-out), border-color var(--t-med), box-shadow var(--t-med);
}
.gallery-card:hover, .gallery-card:focus-visible {
  transform: translateY(-5px);
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  box-shadow: 0 26px 60px -34px rgba(0, 0, 0, 0.9);
}
.gallery-card:active { transform: translateY(-2px) scale(0.99); }
.gallery-card__media { aspect-ratio: 4 / 3; width: 100%; border-bottom: 1px solid var(--line); }
.gallery-card__media .media__img { transition: transform var(--t-slow) var(--ease-out); }
.gallery-card:hover .gallery-card__media .media__img { transform: scale(1.05); }
.gallery-card__info { display: flex; flex-direction: column; gap: 0.15rem; padding: 0.85rem 0.95rem 1rem; }
.gallery-card__brand { font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }
.gallery-card__name { font-family: var(--font-display); font-weight: 500; font-size: 1.2rem; color: var(--paper); line-height: 1.05; }
.gallery-card__year { font-family: var(--font-mono); font-size: 0.76rem; color: var(--text-lo); }

/* compare-mode selection */
.gallery-card__tick {
  position: absolute; top: 0.7rem; right: 0.7rem;
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid #0c0a06; background: var(--sel);
  opacity: 0; transform: scale(0.6);
  transition: opacity var(--t-fast), transform var(--t-fast);
}
.gallery-card__tick::after {
  content: ''; position: absolute; inset: 0;
  background: no-repeat center/14px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 13l4 4L19 7' fill='none' stroke='%230c0a06' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.is-comparing .gallery-card { cursor: copy; }
.gallery-card.is-selected { border-color: var(--sel); box-shadow: 0 0 0 2px var(--sel); }
.gallery-card.is-selected .gallery-card__tick { opacity: 1; transform: scale(1); }

.gallery__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
  padding: clamp(3rem, 8vh, 5rem) 1rem;
  text-align: center;
}
.gallery__empty-art { width: 130px; color: var(--text-lo); opacity: 0.7; }
.gallery__empty-text { color: var(--text-mid); font-family: var(--font-mono); font-size: 0.95rem; }

/* ---- compare tray ---- */
.compare-tray {
  position: fixed;
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 90;
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 0.7rem 1rem;
  width: min(680px, calc(100% - 2rem));
  padding: 0.8rem 1rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink-850) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.9);
}
.compare-tray__label { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-lo); }
.compare-tray__slots { display: flex; flex: 1; flex-wrap: wrap; gap: 0.4rem; min-width: 120px; }
.compare-tray__chip {
  padding: 0.35rem 0.7rem; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 50%, transparent);
  font-family: var(--font-mono); font-size: 0.74rem; color: var(--text-hi);
}
.compare-tray__hint { font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-lo); }
.compare-tray__count { display: none; font-family: var(--font-mono); font-size: 0.82rem; color: var(--text-mid); white-space: nowrap; }
.compare-tray__actions { display: flex; gap: 0.5rem; }
.compare-tray__actions .btn { min-height: 42px; padding: 0.5rem 1rem; }
.btn[disabled] { opacity: 0.4; pointer-events: none; }

@media (max-width: 700px) {
  /* free up vertical space on phones: stop pinning the controls, and let the
     14 decade chips scroll in a single row instead of wrapping to 3 rows */
  .gallery__controls { position: static; background: none; }
  .gallery__decades { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 0.35rem; scrollbar-width: thin; }
  .gallery__decades .chip { flex: none; }
}
@media (max-width: 600px) {
  /* slim, single-line compare tray (count instead of chips) */
  .compare-tray { flex-wrap: nowrap; }
  .compare-tray__slots { display: none; }
  .compare-tray__count { display: inline; }
}
@media (max-width: 540px) {
  .gallery__selects { flex: 1 1 100%; }
  .gx-select { flex: 1; }
  .gx-select__btn { width: 100%; }
  .gx-select__menu { min-width: 100%; }
  .compare-tray { border-radius: var(--radius-lg); }
}

/* ============================================================== *
 *  Compare modal
 * ============================================================== */
.modal:has(.modal__body--compare) { width: min(820px, 100%); }
.modal__body--compare {
  flex: 1;
  display: block;
  overflow-y: auto;
  padding: clamp(1.6rem, 3vw, 2.6rem);
}
.compare__title { font-size: clamp(1.5rem, 3vw, 2rem); margin-bottom: 1.3rem; color: var(--paper); }
.compare__cars { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.4rem; }
.compare__media { aspect-ratio: 4 / 3; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--ink-900); }
.compare__media .media { width: 100%; height: 100%; }
.compare__media .media__img { object-fit: contain; }
.compare__year { margin-top: 0.6rem; font-family: var(--font-mono); font-size: 0.76rem; color: var(--accent); }
.compare__name { font-family: var(--font-display); font-weight: 600; font-size: clamp(1.1rem, 2.4vw, 1.5rem); color: var(--paper); }
.compare__specs { display: flex; flex-direction: column; gap: 0; }
.compare__row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.1rem 1rem;
  padding: 0.7rem 0; border-top: 1px solid var(--line);
}
.compare__row dt {
  grid-column: 1 / -1;
  font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-lo); margin-bottom: 0.25rem;
}
.compare__row dd { font-family: var(--font-mono); font-weight: 700; font-size: 1.02rem; color: var(--text-hi); }

/* ============================================================== *
 *  Command palette (global search)
 * ============================================================== */
.cmd-overlay {
  position: fixed; inset: 0; z-index: 1200;
  display: flex; justify-content: center; align-items: flex-start;
  padding: clamp(3rem, 12vh, 8rem) 1rem 2rem;
  background: rgba(4, 4, 7, 0.6);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  opacity: 0; transition: opacity var(--t-med) var(--ease-out);
}
.cmd-overlay.is-open { opacity: 1; }
.cmd {
  width: min(620px, 100%);
  background: var(--ink-850);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 40px 110px -30px rgba(0, 0, 0, 0.9);
  overflow: hidden;
  transform: translateY(-10px); transition: transform var(--t-med) var(--ease-out);
}
.cmd-overlay.is-open .cmd { transform: none; }
.cmd__field { display: flex; align-items: center; gap: 0.7rem; padding: 1rem 1.1rem; border-bottom: 1px solid var(--line); color: var(--text-mid); }
.cmd__field svg { width: 20px; height: 20px; flex: none; }
.cmd__input { flex: 1; min-width: 0; background: none; border: none; outline: none; color: var(--text-hi); font-family: var(--font-body); font-size: 1.05rem; }
.cmd__input::placeholder { color: var(--text-lo); }
.cmd__esc { font-family: var(--font-mono); font-size: 0.66rem; color: var(--text-lo); border: 1px solid var(--line); border-radius: 4px; padding: 0.1rem 0.4rem; }
.cmd__list { max-height: min(52vh, 440px); overflow-y: auto; padding: 0.5rem; margin: 0; }
.cmd__item {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.6rem 0.7rem; border-radius: var(--radius); cursor: pointer;
}
.cmd__item.is-active { background: var(--surface-2); }
.cmd__art { width: 42px; height: 42px; flex: none; display: grid; place-items: center; color: var(--accent); }
.cmd__art--car svg { width: 100%; }
.cmd__text { display: flex; flex-direction: column; min-width: 0; }
.cmd__label { font-family: var(--font-display); font-weight: 600; font-size: 1.02rem; color: var(--paper); }
.cmd__sub { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-lo); }
.cmd__kind { margin-left: auto; font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); }
.cmd__empty { padding: 1.4rem; text-align: center; color: var(--text-mid); }
