/* Vectoretta — design tokens */
:root {
  --bg: oklch(99% 0.004 80);
  --surface: oklch(100% 0 0);
  --surface-2: oklch(97.5% 0.004 80);
  --ink: oklch(18% 0.012 260);
  --ink-2: oklch(36% 0.012 260);
  --muted: oklch(54% 0.01 260);
  --hairline: oklch(91% 0.005 80);
  --hairline-strong: oklch(85% 0.006 80);
  --accent: oklch(52% 0.11 200);
  --accent-soft: oklch(95% 0.025 200);
  --accent-ink: oklch(34% 0.09 200);
  --warn: oklch(62% 0.13 50);
  --good: oklch(58% 0.12 155);
  --shadow-sm: 0 1px 0 rgba(20,25,40,.04), 0 1px 2px rgba(20,25,40,.04);
  --shadow-md: 0 1px 0 rgba(20,25,40,.04), 0 6px 18px -8px rgba(20,25,40,.12);
  --shadow-lg: 0 1px 0 rgba(20,25,40,.05), 0 24px 60px -24px rgba(20,25,40,.18), 0 8px 20px -12px rgba(20,25,40,.10);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --font-display: "Inter Tight", "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-sans: "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

[data-theme="dark"] {
  --bg: oklch(14% 0.01 260);
  --surface: oklch(17% 0.012 260);
  --surface-2: oklch(20% 0.012 260);
  --ink: oklch(96% 0.005 80);
  --ink-2: oklch(82% 0.008 80);
  --muted: oklch(64% 0.012 260);
  --hairline: oklch(26% 0.012 260);
  --hairline-strong: oklch(34% 0.014 260);
  --accent: oklch(75% 0.13 195);
  --accent-soft: oklch(28% 0.05 200);
  --accent-ink: oklch(85% 0.10 195);
  --shadow-sm: 0 1px 0 rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);
  --shadow-md: 0 1px 0 rgba(0,0,0,.4), 0 6px 18px -8px rgba(0,0,0,.5);
  --shadow-lg: 0 1px 0 rgba(0,0,0,.5), 0 24px 60px -24px rgba(0,0,0,.6), 0 8px 20px -12px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
  font-variant-numeric: tabular-nums;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; padding: 0; }
input { font-family: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------------- Top bar ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in oklch, var(--bg) 78%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--hairline);
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 14px 32px;
  display: flex; align-items: center; gap: 28px;
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 600; font-size: 16px; letter-spacing: -0.01em; }
.spacer { flex: 1; }
.pill-toggle {
  display: flex; padding: 3px; border: 1px solid var(--hairline); border-radius: 999px;
  background: var(--surface);
}
.pill-toggle button {
  padding: 5px 10px; font-size: 12.5px; color: var(--muted); border-radius: 999px;
  display: flex; align-items: center; gap: 6px;
}
.pill-toggle button.on { background: var(--ink); color: var(--bg); }

/* ---------------- Section frame ---------------- */
.page { max-width: 1280px; margin: 0 auto; padding: 0 32px; }
.section { padding: 48px 0 32px; }

/* ---------------- Hero ---------------- */
.hero { padding: 56px 0 24px; position: relative; }
.hero-grid {
  position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(to right, var(--hairline) 1px, transparent 1px),
    linear-gradient(to bottom, var(--hairline) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 60% 70% at 50% 30%, black 30%, transparent 75%);
  opacity: .55;
}
.hero-inner { position: relative; z-index: 1; text-align: center; padding-top: 48px; }
.hero h1 {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(36px, 5vw, 56px); line-height: 1.1; letter-spacing: -0.035em;
  margin: 0 auto 14px; max-width: 16ch;
}
.hero h1 em { font-style: normal; color: var(--accent); }
.hero p.lede { color: var(--muted); font-size: 16px; max-width: 50ch; margin: 0 auto 36px; }

/* Hero search bar */
.searchbar-wrap { position: relative; max-width: 720px; margin: 0 auto; }
.searchbar-glow {
  position: absolute; inset: -24px -40px; border-radius: 28px;
  background: radial-gradient(60% 80% at 50% 100%, color-mix(in oklch, var(--accent) 22%, transparent), transparent 60%);
  filter: blur(24px); opacity: .8; z-index: 0; pointer-events: none;
  transition: opacity .35s ease;
}
.searchbar {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 16px; padding: 10px 10px 10px 18px;
  box-shadow: var(--shadow-lg);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.searchbar:focus-within {
  border-color: color-mix(in oklch, var(--accent) 60%, var(--hairline));
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg), 0 0 0 4px color-mix(in oklch, var(--accent) 14%, transparent);
}
.searchbar svg.search-icon { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }
.searchbar input {
  flex: 1; border: none; outline: none; background: transparent; color: var(--ink);
  font-size: 17px; padding: 12px 0; min-width: 0;
}
.searchbar input::placeholder { color: var(--muted); }
.searchbar .submit {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--ink); color: var(--bg); padding: 9px 14px; border-radius: 10px; font-size: 13.5px; font-weight: 500;
}
.searchbar .submit:hover { transform: translateY(-1px); }
.searchbar .submit:disabled { opacity: 0.6; cursor: not-allowed; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 22px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: 999px; border: 1px solid var(--hairline);
  background: var(--surface); font-size: 13px; color: var(--ink-2);
  transition: all .15s ease;
}
.chip:hover { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }
.chip .icon { width: 12px; height: 12px; color: var(--muted); }
.chip:hover .icon { color: var(--accent); }
.chip:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------------- Search animation ---------------- */
.search-anim {
  position: relative;
  width: 100%;
  height: 400px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--hairline);
}
.search-anim-canvas {
  width: 100%;
  height: 100%;
  display: block;
}
.search-anim-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  pointer-events: none;
}
.search-anim-words {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 400px;
}
.search-anim-word {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  padding: 6px 14px;
  background: color-mix(in oklch, var(--surface) 90%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  animation: wordFloat 2s ease-in-out infinite alternate, wordAppear 0.5s ease backwards;
}
@keyframes wordFloat {
  0% { transform: translateY(0); }
  100% { transform: translateY(-6px); }
}
@keyframes wordAppear {
  from { opacity: 0; transform: translateY(12px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.search-anim-status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--muted);
  background: color-mix(in oklch, var(--surface) 85%, transparent);
  backdrop-filter: blur(8px);
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  animation: fadeIn 0.6s ease 0.3s backwards;
}
.search-anim-spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--hairline);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ---------------- Results section ---------------- */
.results-section-wrap {
  animation: fadeIn 0.4s ease;
}
.results-shell { display: grid; grid-template-columns: 220px 1fr; gap: 32px; }
.facets h4 {
  font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em;
  font-size: 11px; color: var(--muted); margin: 0 0 10px; font-weight: 500;
}
.facet-group { padding: 16px 0; border-top: 1px solid var(--hairline); }
.facet-group:first-of-type { border-top: none; padding-top: 0; }
.facet-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; font-size: 13.5px; color: var(--ink-2); }
.facet-row:hover { color: var(--ink); }
.facet-row .count { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); }
.facet-check {
  width: 14px; height: 14px; border: 1px solid var(--hairline-strong); border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.facet-check.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.facet-check.on::after { content: ""; width: 6px; height: 3px; border-left: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg) translate(0px, -1px); }

.results-main { min-width: 0; }
.results-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px;
}
.query-recap { font-size: 13.5px; color: var(--muted); }
.query-recap .q { color: var(--ink); font-weight: 500; }

.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.product {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius-md); overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
  animation: cardIn .5s cubic-bezier(.2,.8,.2,1) backwards;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.product:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--hairline-strong); }
.product .img {
  aspect-ratio: 4 / 3; position: relative;
  background: var(--surface-2);
  background-image:
    repeating-linear-gradient(135deg, transparent 0 12px, color-mix(in oklch, var(--ink) 4%, transparent) 12px 13px);
  display: flex; align-items: center; justify-content: center;
}
.product .img-tag { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }
.product .img .score {
  position: absolute; top: 10px; right: 10px;
  font-family: var(--font-mono); font-size: 11px;
  background: color-mix(in oklch, var(--surface) 86%, transparent); backdrop-filter: blur(4px);
  border: 1px solid var(--hairline); border-radius: 6px; padding: 3px 7px; color: var(--ink-2);
}
.product .img .score b { color: var(--accent); font-weight: 600; }
.product .body { padding: 14px 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.product .meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.product .title { font-size: 14px; font-weight: 500; line-height: 1.35; color: var(--ink); }
.product .price { font-family: var(--font-mono); font-size: 13.5px; color: var(--ink); white-space: nowrap; }
.cat-badge { font-size: 11px; font-family: var(--font-mono); color: var(--muted); border: 1px solid var(--hairline); padding: 2px 6px; border-radius: 4px; }
.product .why {
  display: flex; gap: 8px; padding-top: 10px; border-top: 1px dashed var(--hairline);
  font-size: 12px; color: var(--muted); line-height: 1.45;
  transition: color .2s ease;
}
.product:hover .why { color: var(--ink-2); }
.product .why svg { width: 12px; height: 12px; flex-shrink: 0; margin-top: 2px; color: var(--accent); }

/* ---------------- Footer ---------------- */
.footer { padding: 56px 0 64px; color: var(--muted); font-size: 12.5px; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--hairline); margin-top: 64px; }

/* animations */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--accent) 50%, transparent); }
  70% { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* responsive */
@media (max-width: 1100px) {
  .results-shell { grid-template-columns: 1fr; }
  .result-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .result-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
