/* ============================================================
   THINGS PEOPLE LOVE — styles
   ============================================================ */

:root {
  --cream: #F7F3EE;
  --ink: #1A1714;
  --muted: #7A7066;
  --border: #E0D9D0;
  --accent: #C4622D;
  --accent-light: #F5E8DF;
  --success: #2D6A4F;
  --card-bg: #FFFFFF;
  --tag-bg: #F0EBE3;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--cream);
  color: var(--ink);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
}


/* ── API key screen ─────────────────────────────────────── */

#api-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.api-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem;
  max-width: 420px;
  width: 100%;
  text-align: center;
}

.api-card h1 { font-family: 'Playfair Display', serif; font-size: 28px; margin-bottom: 8px; }
.api-card h1 em { font-style: italic; color: var(--accent); }
.api-card p { color: var(--muted); font-size: 14px; line-height: 1.6; margin-bottom: 1.5rem; }

.api-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  background: var(--cream);
  color: var(--ink);
  margin-bottom: 12px;
  outline: none;
}
.api-input:focus { border-color: var(--accent); }

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-primary:hover { opacity: 0.85; }

.api-note { font-size: 11px; color: var(--muted); margin-top: 10px; }


/* ── App shell ──────────────────────────────────────────── */

#app {
  display: none;
  max-width: 680px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.app-header {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.app-header h1 { font-family: 'Playfair Display', serif; font-size: 32px; letter-spacing: -0.5px; }
.app-header h1 em { font-style: italic; color: var(--accent); }
.app-header p { color: var(--muted); font-size: 13px; margin-top: 4px; }

.day-counter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px;
}
.refresh-dots { display: flex; gap: 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.dot.used { background: var(--accent); }


/* ── Controls panel ─────────────────────────────────────── */

.controls {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.section-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.price-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 1.25rem;
}

.price-btn {
  padding: 9px 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--cream);
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}
.price-btn:hover { border-color: var(--accent); color: var(--ink); }
.price-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.cats-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.cats-toggle {
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  background: none;
  border: none;
  font-family: 'DM Sans', sans-serif;
}

.cat-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }

.cat-pill {
  padding: 5px 11px;
  border-radius: 20px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}
.cat-pill:hover { opacity: 0.85; }
.cat-pill.off {
  background: var(--cream);
  color: var(--muted);
  border-color: var(--border);
}

.save-defaults {
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}
.save-defaults input { accent-color: var(--accent); }

.go-btn {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-family: 'Playfair Display', serif;
  font-size: 18px;
  font-style: italic;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 1rem;
}
.go-btn:hover { background: #B0561F; }
.go-btn:disabled { background: var(--border); color: var(--muted); cursor: not-allowed; }


/* ── Lockout screen ─────────────────────────────────────── */

#lockout { display: none; text-align: center; padding: 3rem 1rem; }
#lockout h2 { font-family: 'Playfair Display', serif; font-size: 26px; margin-bottom: 8px; }

.countdown {
  font-family: 'Playfair Display', serif;
  font-size: 48px;
  color: var(--accent);
  margin: 1rem 0;
  letter-spacing: 2px;
}


/* ── Loading state ──────────────────────────────────────── */

#loading { display: none; text-align: center; padding: 3rem 0; }

.loading-text {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 20px;
  color: var(--muted);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 1rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }


/* ── Results / product cards ────────────────────────────── */

#products { display: none; }

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1rem;
}

.results-title { font-family: 'Playfair Display', serif; font-size: 20px; }

.refresh-btn {
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  background: none;
  border: none;
  font-family: 'DM Sans', sans-serif;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.refresh-btn:disabled { color: var(--muted); cursor: not-allowed; text-decoration: none; }

.back-btn {
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  background: none;
  border: none;
  font-family: 'DM Sans', sans-serif;
  text-decoration: underline;
  text-underline-offset: 2px;
  margin-bottom: 1rem;
  display: block;
}

.product-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem;
  margin-bottom: 10px;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.product-card.visible { opacity: 1; transform: translateY(0); }

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
  gap: 10px;
}
.card-cat {
  font-size: 11px;
  padding: 3px 9px;
  background: var(--tag-bg);
  border-radius: 20px;
  color: var(--muted);
  white-space: nowrap;
}
.card-price { font-size: 13px; font-weight: 500; color: var(--ink); white-space: nowrap; }
.card-name { font-family: 'Playfair Display', serif; font-size: 17px; margin-bottom: 4px; line-height: 1.3; }
.card-brand { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.card-why { font-size: 13px; color: var(--ink); line-height: 1.6; margin-bottom: 10px; }

.card-quote {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  padding: 8px 12px;
  background: var(--cream);
  border-left: 2px solid var(--border);
  border-radius: 0 6px 6px 0;
  margin-bottom: 10px;
  font-style: italic;
}

.card-footer { display: flex; flex-direction: column; gap: 8px; }
.card-footer-row { display: flex; justify-content: space-between; align-items: center; }
.card-where { font-size: 11px; color: var(--muted); }
.love-signal { font-size: 11px; color: var(--accent); font-weight: 500; }

.card-score { display: flex; align-items: center; gap: 6px; }
.stars { color: #C4622D; font-size: 13px; letter-spacing: 1px; }
.score-num { font-size: 12px; font-weight: 500; color: var(--ink); }
.score-count { font-size: 11px; color: var(--muted); }
.score-source { font-size: 11px; color: var(--muted); }

.buy-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--accent);
  padding: 5px 12px;
  border-radius: 20px;
  transition: all 0.15s;
}
.buy-link:hover { background: var(--accent); color: #fff; }


/* ── Utility ────────────────────────────────────────────── */

.error-msg {
  background: #FFF0EC;
  border: 1px solid #FBBCB0;
  border-radius: 10px;
  padding: 1rem;
  font-size: 13px;
  color: #7A2A1A;
  margin-bottom: 1rem;
}

.change-key {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  margin-top: 2rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  background: none;
  border: none;
  font-family: 'DM Sans', sans-serif;
  width: 100%;
}

.reset-btn {
  font-size: 11px;
  color: var(--border);
  text-align: center;
  margin-top: 0.5rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  background: none;
  border: none;
  font-family: 'DM Sans', sans-serif;
  width: 100%;
}
.reset-btn:hover { color: var(--muted); }

.share-btn {
  margin-top: 1.5rem;
  padding: 10px 22px;
  border: 1px solid var(--accent);
  border-radius: 20px;
  background: none;
  color: var(--accent);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.share-btn:hover { background: var(--accent); color: #fff; }