/* Costco vs Amazon — styles. Light theme, system fonts, no external assets. */

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --ink: #0f172a;
  --muted: #475569;
  --line: #e2e8f0;
  --brand: #1d4ed8;
  --brand-dark: #1e40af;
  --win: #15803d;
  --win-bg: #dcfce7;
  --lose: #b45309;
  --lose-bg: #fef3c7;
  --tie-bg: #e2e8f0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
}

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 1rem; }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--brand); color: #fff; padding: 0.5rem 1rem; z-index: 100;
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.header-inner { display: flex; align-items: center; justify-content: space-between; padding-top: 0.75rem; padding-bottom: 0.75rem; }
.site-title { margin: 0; font-size: 1.15rem; font-weight: 800; }
.site-title a { color: var(--ink); text-decoration: none; }
.site-title .vs { color: var(--brand); font-weight: 600; }
.nav-list { list-style: none; margin: 0; padding: 0; display: flex; gap: 1rem; flex-wrap: wrap; }
.nav-list a { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.95rem; }
.nav-list a:hover, .nav-list a:focus { color: var(--brand); text-decoration: underline; }

/* First-run notice (dismissible banner, not a modal) */
.first-run-banner { background: #1e293b; color: #f1f5f9; padding: 0.55rem 0; }
.first-run-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.first-run-inner p { margin: 0; font-size: 0.9rem; }
.first-run-inner a { color: #bfdbfe; }
.first-run-banner .btn { border-color: #64748b; background: transparent; color: #fff; flex-shrink: 0; }
.first-run-banner .btn:hover { border-color: #fff; color: #fff; }

/* Hero */
.hero { background: linear-gradient(180deg, #eff6ff, var(--bg)); padding: 2.5rem 0 1.5rem; }
.hero h1 { font-size: 2rem; margin: 0 0 0.5rem; letter-spacing: -0.02em; }
.tagline { font-size: 1.1rem; color: var(--muted); max-width: 40rem; margin: 0 0 1rem; }
.sample-notice {
  background: #fffbeb; border: 1px solid #fcd34d; border-left: 4px solid #d97706;
  border-radius: 8px; padding: 0.75rem 1rem; max-width: 46rem; font-size: 0.95rem; margin: 0;
}

/* Sections */
section.wrap { padding-top: 2rem; padding-bottom: 1rem; }
h2 { font-size: 1.5rem; margin: 0 0 0.75rem; letter-spacing: -0.01em; }
.section-lede { color: var(--muted); max-width: 46rem; margin: 0 0 1.25rem; }

/* Controls */
.controls { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.control-group { display: flex; flex-direction: column; gap: 0.25rem; min-width: 12rem; flex: 1 1 16rem; }
.control-group label { font-weight: 600; font-size: 0.9rem; }
input[type="search"], input[type="text"], input[type="number"], input[type="url"], input[type="password"], select {
  font: inherit; padding: 0.55rem 0.75rem; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface); color: var(--ink); width: 100%;
}
input:focus, select:focus, button:focus { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Chips */
.chips { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0 0 1rem; }
.chip {
  font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  border-radius: 999px; padding: 0.35rem 0.9rem;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }

/* Summary + banner */
.summary-bar {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.9rem 1.1rem; font-weight: 600; box-shadow: var(--shadow); margin: 0 0 1rem;
}
.data-banner {
  background: #fff7ed; border: 1px dashed #d97706; border-radius: 8px;
  padding: 0.6rem 0.9rem; font-size: 0.9rem; margin: 0 0 1.25rem; color: #7c2d12;
}
.data-banner a { color: var(--brand); }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 0.6rem;
}
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; }
.card h3 { margin: 0; font-size: 1.05rem; line-height: 1.3; }
.badge {
  flex-shrink: 0; font-size: 0.75rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em;
  border-radius: 999px; padding: 0.25rem 0.65rem; white-space: nowrap;
}
.badge.costco { background: var(--win-bg); color: var(--win); }
.badge.amazon { background: var(--lose-bg); color: var(--lose); }
.badge.tie { background: var(--tie-bg); color: var(--muted); }
.badge.mine { background: #e0e7ff; color: var(--brand-dark); }
.card-meta { color: var(--muted); font-size: 0.85rem; margin: 0; }
.card-blurb { font-size: 0.9rem; color: var(--muted); margin: 0; font-style: italic; }
.price-rows { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.price-cell { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 0.5rem 0.65rem; }
.price-cell .store { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.price-cell .price { font-size: 1.15rem; font-weight: 800; }
.price-cell .unit-price { font-size: 0.8rem; color: var(--muted); }
.price-cell.cheaper { border-color: var(--win); }
.price-cell.cheaper .price { color: var(--win); }
.savings-line { margin: 0; font-size: 0.9rem; font-weight: 600; }
.savings-line .pos { color: var(--win); }
.savings-line .neg { color: var(--lose); }
.card-actions { display: flex; gap: 0.5rem; margin-top: auto; padding-top: 0.25rem; }

/* Buttons */
.btn {
  font: inherit; font-weight: 600; cursor: pointer; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); border-radius: 8px; padding: 0.5rem 1rem;
  display: inline-block; text-decoration: none; text-align: center;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); color: #fff; }
.btn-small { padding: 0.3rem 0.7rem; font-size: 0.85rem; }
.btn-danger { color: #b91c1c; }
.btn-danger:hover { border-color: #b91c1c; color: #b91c1c; }
.btn-file { cursor: pointer; }
.btn-file input { position: absolute; left: -9999px; }

/* Form */
#item-form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.9rem; }
.field { display: flex; flex-direction: column; gap: 0.25rem; }
.field label { font-weight: 600; font-size: 0.9rem; }
.form-actions { display: flex; gap: 0.75rem; margin-top: 1rem; flex-wrap: wrap; }
.form-error { color: #b91c1c; background: #fef2f2; border: 1px solid #fecaca; border-radius: 8px; padding: 0.6rem 0.9rem; font-size: 0.9rem; }

.csv-tools { margin-top: 1.5rem; }
.csv-tools h3 { margin: 0 0 0.25rem; font-size: 1.1rem; }
.csv-hint { font-size: 0.85rem; color: var(--muted); }
.csv-hint code { background: var(--tie-bg); padding: 0.1rem 0.35rem; border-radius: 4px; font-size: 0.8rem; word-break: break-all; }

/* Methodology prose */
.prose { max-width: 46rem; }
.prose h3 { margin: 1.25rem 0 0.5rem; font-size: 1.1rem; }
.prose p, .prose li { color: #1e293b; }
.prose ul { padding-left: 1.25rem; }
.prose a { color: var(--brand); }

/* Data sources (BYOK) panel */
.pill {
  font-size: 0.7rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em;
  background: #e0e7ff; color: var(--brand-dark); border-radius: 999px; padding: 0.2rem 0.6rem;
  vertical-align: middle;
}
.notice-box {
  background: #fffbeb; border: 1px solid #fcd34d; border-left: 4px solid #d97706;
  border-radius: 8px; padding: 0.75rem 1rem; font-size: 0.92rem; max-width: 46rem; margin: 0 0 1rem;
}
.ds-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.field-hint { font-size: 0.82rem; color: var(--muted); margin: 0.15rem 0 0; }
.field-hint code { background: var(--tie-bg); padding: 0.1rem 0.35rem; border-radius: 4px; font-size: 0.78rem; }
.mapping { margin-top: 1rem; border: 1px solid var(--line); border-radius: 8px; padding: 0.6rem 0.9rem; }
.mapping summary { cursor: pointer; font-weight: 600; font-size: 0.95rem; }
.mapping-grid { margin-top: 0.75rem; }
.form-ok { color: var(--win); background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 8px; padding: 0.6rem 0.9rem; font-size: 0.9rem; }
.cors-note {
  background: var(--bg); border: 1px dashed var(--line); border-radius: 8px;
  padding: 0.6rem 0.9rem; font-size: 0.88rem; color: var(--muted); max-width: 46rem; margin: 1rem 0 0;
}
.ds-history { margin-top: 1.5rem; }
.ds-history h3 { margin: 0 0 0.25rem; font-size: 1.1rem; }
.ds-history ul { list-style: none; margin: 0.5rem 0 0; padding: 0; max-width: 46rem; }
.ds-history li {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 0.5rem 0.8rem; font-size: 0.9rem; margin-bottom: 0.4rem;
}
.ds-history .hist-sub { color: var(--muted); font-size: 0.82rem; display: block; }
.ds-history h4 { font-size: 0.95rem; margin: 1rem 0 0.25rem; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); margin-top: 2.5rem; padding: 1.5rem 0; }
.footer-nav { margin-bottom: 0.75rem; }
.affiliation { font-size: 0.85rem; color: var(--muted); max-width: 46rem; margin: 0 0 0.5rem; }
.copyright { font-size: 0.8rem; color: var(--muted); margin: 0; }

.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.empty a { color: var(--brand); }

/* Legal pages */
.legal-page main { padding: 2rem 0 3rem; }
.legal-page h1 { font-size: 1.75rem; }
.legal-meta { color: var(--muted); font-size: 0.9rem; }

@media (max-width: 560px) {
  .hero h1 { font-size: 1.6rem; }
  .header-inner { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .controls { flex-direction: column; }
}
