/* Phase 3 of perch-store-demo. Shares the BoxOwl visual language with
   boxowl.me but adds explicit DEMO branding and a --userAccent token that
   the personal-state hero rebinds at runtime from the user's preferences. */

:root {
  --boxowlNavy: #1F1F1F;
  --boxowlCyan: #00d4ff;
  --purple: #BD7AFB;
  --white: #ffffff;
  --grayLight: #c0c0c0;
  --grayMid: #404040;
  --grayDark: #303030;
  --cardBg: #262626;
  --cardBorder: #333333;
  --warn: #f4b942;
  --danger: #ff5f5f;
  --success: #4cd97b;

  /* Demo-only tokens */
  --demoAccent: #ff9933;       /* the DEMO badge colour */
  --userAccent: var(--boxowlCyan);  /* rebound by hero-state.js in personal state */
  --demographicTint: #6a7afc;  /* rebound by hero-state.js in demographic state */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  background: var(--boxowlNavy);
  color: var(--white);
  min-height: 100vh;
}

a { color: var(--boxowlCyan); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0 0 0.5rem; line-height: 1.2; }
h1 { font-size: 1.8rem; font-weight: 700; }
h2 { font-size: 1.3rem; font-weight: 600; }
h3 { font-size: 1.05rem; font-weight: 600; }

main { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1.5rem 4rem; }

/* ---------- Header / nav ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--cardBorder);
  background: rgba(0, 0, 0, 0.2);
}
.brand { display: flex; align-items: center; gap: 0.6rem; }
.brand a { display: flex; align-items: center; gap: 0.6rem; color: var(--white); }
.brand a:hover { text-decoration: none; }
.brand img { width: 28px; height: 28px; }
.brand-name { font-weight: 700; letter-spacing: 0.02em; }

.demo-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: var(--demoAccent);
  color: var(--boxowlNavy);
  margin-left: 0.5rem;
  vertical-align: middle;
}

.nav-links { display: flex; gap: 1.25rem; align-items: center; }
/* `:not(.btn)` keeps button anchors from inheriting the grey link color —
   .btn-primary's navy `color` rule has lower specificity than `.nav-links a`
   and would otherwise render the "Sign in with BoxOwl" text in grey on cyan
   (unreadable). */
.nav-links a:not(.btn) { color: var(--grayLight); font-weight: 500; font-size: 0.95rem; }
.nav-links a:not(.btn):hover { color: var(--white); text-decoration: none; }
.nav-cart {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--cardBorder);
}
.nav-cart-count {
  display: inline-block;
  background: var(--boxowlCyan);
  color: var(--boxowlNavy);
  font-weight: 700;
  font-size: 0.75rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  min-width: 1.1rem;
  text-align: center;
}
.nav-cart-count[data-empty="true"] { display: none; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  border: 1px solid var(--cardBorder);
  background: var(--cardBg);
  padding: 2.5rem 2rem;
  margin-bottom: 2rem;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.5rem;
}
.hero-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: 0.9;
  pointer-events: none;
}
.hero-content {
  position: relative;
  z-index: 1;
  max-width: 640px;
}
.hero-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--grayLight);
  margin-bottom: 0.25rem;
}
.hero h1 { font-size: 2rem; margin-bottom: 0.4rem; }
.hero p { color: var(--grayLight); margin: 0 0 1rem; max-width: 480px; line-height: 1.5; }
.hero-cta {
  display: inline-flex;
  align-items: center;
  padding: 0.7rem 1.2rem;
  border-radius: 10px;
  background: var(--userAccent);
  color: var(--boxowlNavy);
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: inherit;
  font-size: 0.95rem;
}
.hero-cta:hover { opacity: 0.9; text-decoration: none; }
.hero[data-state="personal"] { border-color: var(--userAccent); }
.hero[data-state="demographic"] .hero-eyebrow { color: var(--demographicTint); }

/* ---------- Buttons / forms ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.1rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
  border: 1px solid transparent;
  transition: opacity 0.15s, background 0.15s;
}
.btn-primary { background: var(--boxowlCyan); color: var(--boxowlNavy); }
.btn-primary:hover { opacity: 0.9; text-decoration: none; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-secondary { background: transparent; color: var(--grayLight); border-color: var(--cardBorder); }
.btn-secondary:hover { color: var(--white); border-color: var(--grayLight); text-decoration: none; }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: rgba(255, 95, 95, 0.1); text-decoration: none; }
.btn-small { padding: 0.4rem 0.75rem; font-size: 0.8rem; }

/* ---------- Catalog grid ---------- */
.section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
  color: var(--grayLight);
  margin: 2rem 0 1rem;
}
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
}
.product-card {
  background: var(--cardBg);
  border: 1px solid var(--cardBorder);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, transform 0.15s;
}
.product-card:hover { border-color: var(--grayLight); transform: translateY(-1px); }
.product-card[data-hero="true"] { border-color: var(--userAccent); }
.product-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--grayDark);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.product-image img { width: 100%; height: 100%; object-fit: cover; }
.product-image-placeholder {
  color: var(--grayLight);
  font-size: 0.8rem;
  text-align: center;
  padding: 1rem;
  line-height: 1.4;
}
.product-image-placeholder strong { display: block; font-size: 1rem; color: var(--white); margin-bottom: 0.25rem; }
.hero-flag {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  background: var(--userAccent);
  color: var(--boxowlNavy);
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
}
.unavailable-flag {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: var(--grayDark);
  color: var(--grayLight);
  font-size: 0.7rem;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
}
.product-body { padding: 1rem; display: flex; flex-direction: column; gap: 0.35rem; flex: 1; }
.product-name { font-weight: 600; font-size: 1rem; }
.product-tagline { font-size: 0.85rem; color: var(--grayLight); line-height: 1.4; flex: 1; }
.product-price-row { display: flex; align-items: center; justify-content: space-between; margin-top: 0.5rem; gap: 0.5rem; }
.product-price { font-weight: 700; font-size: 1rem; }

/* ---------- Cards / sections ---------- */
.card {
  background: var(--cardBg);
  border: 1px solid var(--cardBorder);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.card h2 { margin-bottom: 0.25rem; }
.card .subtle { color: var(--grayLight); font-size: 0.9rem; margin-top: 0; }

/* ---------- Cart / list rows ---------- */
.line-row {
  display: grid;
  grid-template-columns: 64px 1fr auto auto;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.line-row:last-child { border-bottom: none; }
.line-row img {
  width: 64px; height: 64px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--grayDark);
}
.line-row .meta { display: flex; flex-direction: column; gap: 0.15rem; }
.line-row .meta-name { font-weight: 600; }
.line-row .meta-sku { font-size: 0.75rem; color: var(--grayLight); font-family: 'SF Mono', monospace; }
.line-row .qty { font-size: 0.9rem; color: var(--grayLight); }
.totals { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--cardBorder); display: flex; justify-content: space-between; font-weight: 600; font-size: 1.05rem; }

/* ---------- Banners / alerts ---------- */
.alert {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
  line-height: 1.5;
}
.alert.info { background: rgba(0, 212, 255, 0.08); border: 1px solid rgba(0, 212, 255, 0.25); }
.alert.warn { background: rgba(244, 185, 66, 0.08); border: 1px solid rgba(244, 185, 66, 0.25); color: var(--warn); }
.alert.error { background: rgba(255, 95, 95, 0.08); border: 1px solid rgba(255, 95, 95, 0.25); color: var(--danger); }
.alert.success { background: rgba(76, 217, 123, 0.08); border: 1px solid rgba(76, 217, 123, 0.25); color: var(--success); }

/* ---------- Misc ---------- */
.loading {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--grayLight);
}
.loading-spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--cardBorder);
  border-top-color: var(--boxowlCyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

footer {
  border-top: 1px solid var(--cardBorder);
  padding: 1.5rem;
  text-align: center;
  color: var(--grayLight);
  font-size: 0.8rem;
  line-height: 1.6;
}
footer p { margin: 0.25rem 0; }
footer a { color: var(--boxowlCyan); }

.kv-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 0.9rem;
}
.kv-row:last-child { border-bottom: none; }
.kv-label { color: var(--grayLight); }
.kv-value { font-weight: 500; }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--grayLight);
}
.empty-state h2 { color: var(--white); margin-bottom: 0.5rem; }

.formal-link { color: var(--grayLight); text-decoration: underline; }
