/* Google-inspired styling — clean, generous spacing, subtle. */
:root {
  --text: #202124;
  --text-muted: #4d5156;
  --text-soft: #70757a;
  --link: #1a0dab;
  --link-visited: #681da8;
  --border: #dfe1e5;
  --border-hover: #c0c4c8;
  --shadow: 0 2px 8px rgba(32, 33, 36, .10);
  --shadow-hover: 0 4px 12px rgba(32, 33, 36, .15);
  --bg: #ffffff;
  --bg-soft: #f8f9fa;
  --accent: #1a73e8;
  /* CMYK process colours */
  --cmyk-c: #00B4D8;
  --cmyk-m: #D90368;
  --cmyk-y: #F5C800;
  --cmyk-k: #1a1a1a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

/* ---------- Home page ---------- */
.home {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 22vh;
}

.home-main {
  width: 100%;
  max-width: 600px;
  padding: 0 20px;
  text-align: center;
}

.brand {
  font-family: 'Product Sans', arial, sans-serif;
  font-size: 92px;
  font-weight: 500;
  margin: 0 0 8px;
  letter-spacing: -2px;
}

/* S-i-m-p-l-e → C-M-Y-K-C-M */
.brand-s { color: var(--cmyk-c); }
.brand-i { color: var(--cmyk-m); }
.brand-m { color: var(--cmyk-y); }
.brand-p { color: var(--cmyk-k); }
.brand-l { color: var(--cmyk-c); }
.brand-e { color: var(--cmyk-m); }

.tagline {
  color: var(--text-soft);
  font-size: 14px;
  margin: 0 0 28px;
}

.search-form {
  margin: 0 auto;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: 46px;
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: none;
  background: var(--bg);
  transition: box-shadow .15s, border-color .15s;
}

.search-box:hover,
.search-box:focus-within {
  box-shadow: var(--shadow);
  border-color: transparent;
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 16px;
  height: 100%;
  color: var(--text);
  background: transparent;
}

.search-buttons {
  margin-top: 28px;
}

.btn {
  background: var(--bg-soft);
  border: 1px solid var(--bg-soft);
  border-radius: 4px;
  color: #3c4043;
  font-family: arial, sans-serif;
  font-size: 14px;
  padding: 0 16px;
  height: 36px;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s, background .15s;
}

.btn:hover {
  box-shadow: 0 1px 1px rgba(0,0,0,.1);
  background: #f8f9fa;
  border-color: #dadce0;
  color: #202124;
}

.footer-note {
  margin-top: 56px;
  font-size: 13px;
  color: var(--text-soft);
}

/* ---------- Results page ---------- */
.results-header {
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 28px;
  max-width: 780px;
  margin: 0 auto;
  padding: 16px 28px;
}

.brand-small {
  font-family: 'Product Sans', arial, sans-serif;
  font-size: 28px;
  font-weight: 500;
  text-decoration: none;
  letter-spacing: -1px;
  white-space: nowrap;
}

.search-form-inline {
  flex: 1;
  max-width: 600px;
}

.search-box.small {
  height: 40px;
  padding: 0 14px;
}

.search-box.small .search-input { font-size: 15px; }

.results-meta {
  max-width: 780px;
  margin: 0 auto;
  padding: 12px 28px;
  font-size: 13px;
  color: var(--text-soft);
  border-bottom: 1px solid var(--border);
}

.results-meta code {
  background: var(--bg-soft);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 12px;
}

.results-list {
  max-width: 780px;
  margin: 0 auto;
  padding: 24px 28px 80px;
}

.result {
  margin-bottom: 12px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 16px 20px;
  border: 1.5px solid var(--border);
  border-radius: 16px;
  background: var(--bg);
  opacity: 1;
  transform: translateY(0);
  transition: opacity .25s ease, transform .25s ease, box-shadow .15s, border-color .15s;
}

.result:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow);
}

.result-new {
  opacity: 0;
  transform: translateY(10px);
}

.result-thumb {
  flex-shrink: 0;
  width: 116px;
  height: 88px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-thumb img.thumb-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.result-thumb.result-thumb-logo {
  background: #fff;
}

.result-thumb img.thumb-logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
}

.result-body {
  flex: 1;
  min-width: 0;
}

.warn {
  color: #b3261e;
  font-style: italic;
}

.result-source {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 2px;
  overflow-wrap: anywhere;
}

.result-title {
  display: inline-block;
  font-size: 20px;
  line-height: 1.3;
  color: var(--link);
  text-decoration: none;
  margin-bottom: 4px;
}

.result-title:hover { text-decoration: underline; }
.result-title:visited { color: var(--link-visited); }

.result-snippet {
  margin: 4px 0 6px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.58;
}

.result-why {
  margin-top: 8px;
}

.result-why summary {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-soft);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2px 10px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background .12s, border-color .12s;
}

.result-why summary::-webkit-details-marker { display: none; }
.result-why summary::marker { display: none; }

.result-why summary:hover {
  background: #ecedef;
  border-color: var(--border-hover);
}

.result-why-text {
  margin: 8px 0 0 2px;
  font-size: 12px;
  color: var(--text-soft);
  font-style: italic;
  line-height: 1.5;
}

.error-box {
  background: #fce8e6;
  border: 1px solid #f3b9b3;
  border-radius: 8px;
  padding: 16px 20px;
  color: #b3261e;
  margin-top: 16px;
}

.error-box p {
  margin: 8px 0 0;
  font-size: 14px;
  color: #5f2120;
}

.no-results {
  color: var(--text-soft);
  font-size: 15px;
  margin-top: 24px;
}

.status-text {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Products grid (transactional queries) ---------- */
.products-grid {
  max-width: 860px;
  margin: 0 auto;
  padding: 20px 28px 80px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  align-items: start;
}

.product-card {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  opacity: 1;
  transform: translateY(0) scale(1);
  transition: opacity .25s ease, transform .25s ease,
              box-shadow .15s, border-color .15s;
  text-decoration: none;
  display: block;
}

.product-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-hover);
  transform: scale(1.025);
}

.product-card-new {
  opacity: 0;
  transform: translateY(8px);
}

/* Square image container with shimmer skeleton */
.product-image-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #f8f9fa;
  overflow: hidden;
}

.product-skeleton {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    #f0f0f0 25%,
    #e4e4e4 50%,
    #f0f0f0 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}

@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.product-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 14px;
  background: #fff;
  /* Subtle quality boost — costs zero latency */
  filter: contrast(1.04) saturate(1.08);
  opacity: 0;
  transition: opacity .22s ease;
}

.product-image.loaded {
  opacity: 1;
}

.product-info {
  padding: 10px 14px 14px;
  border-top: 1px solid var(--border);
}

.product-name {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 400;
  color: var(--text);
  line-height: 1.35;
  /* Clamp to 2 lines */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-price {
  margin: 0 0 3px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.2px;
}

.product-merchant {
  margin: 0;
  font-size: 11px;
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 640px) {
  .brand { font-size: 64px; }
  .home { padding-top: 15vh; }
  .header-inner { flex-direction: column; align-items: stretch; gap: 12px; padding: 12px 16px; }
  .results-meta, .results-list { padding-left: 16px; padding-right: 16px; }
  .products-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; padding-left: 16px; padding-right: 16px; }
}
