/* ==========================================================================
   Scan It Rate It — Product Site
   HTML5 / CSS3 / WCAG 2.1 AA accessible
   ========================================================================== */

/* --- Reset & base ---------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

:root {
  --bg: #0b1020;
  --bg-elev: #121833;
  --bg-card: #1a2244;
  --border: #2a3563;
  --text: #f3f5fb;
  --text-dim: #b6bedc;
  --muted: #8892b8;
  --primary: #4f8cff;
  --primary-hover: #3a73e6;
  --accent: #00d4a4;
  --danger: #ff4f6d;
  --warning: #ffb547;
  --focus: #ffd166;
  --radius: 10px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  --max: 1140px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img,
svg {
  max-width: 100%;
  height: auto;
  display: block;
}

a:not(.btn) {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

a:not(.btn):hover { color: var(--primary-hover); }

a.btn { text-decoration: none; }

/* --- Accessibility: skip link & focus styles ------------------------------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--focus);
  color: #000;
  padding: 0.75rem 1rem;
  font-weight: 700;
  z-index: 999;
  border-radius: 0 0 var(--radius) 0;
}

.skip-link:focus {
  left: 0;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

/* --- Layout containers ----------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 1.25rem;
}

main {
  flex: 1;
}

/* --- Header & nav ---------------------------------------------------------- */
.site-header {
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.15rem;
}

.brand-mark {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 0.9rem;
}

.nav-list {
  display: flex;
  gap: 0.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
  align-items: center;
}

.nav-list a {
  color: var(--text-dim);
  text-decoration: none;
  padding: 0.5rem 0.85rem;
  border-radius: 6px;
}

.nav-list a:hover,
.nav-list a[aria-current="page"] {
  background: var(--bg-card);
  color: var(--text);
}

.nav-toggle {
  display: none;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
}

@media (max-width: 720px) {
  .nav-toggle { display: inline-flex; }
  .nav-list {
    display: none;
    position: absolute;
    inset: 100% 0 auto 0;
    flex-direction: column;
    gap: 0;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 1.25rem 1rem;
  }
  .nav-list.open { display: flex; }
  .nav-list a { padding: 0.75rem 0.5rem; display: block; }
}

/* --- Buttons --------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
  min-height: 44px; /* touch target */
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg-card); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-block { width: 100%; }

/* --- Hero ------------------------------------------------------------------ */
.hero {
  padding: 4rem 0 3rem;
  background:
    radial-gradient(1200px 400px at 80% -50px, rgba(79, 140, 255, 0.18), transparent 60%),
    radial-gradient(800px 400px at 0% 0%, rgba(0, 212, 164, 0.12), transparent 60%);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 2.5rem;
  align-items: center;
}

@media (max-width: 860px) {
  .hero-grid { grid-template-columns: 1fr; }
}

.eyebrow {
  display: inline-block;
  background: var(--bg-card);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  margin-bottom: 1rem;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.25rem);
  line-height: 1.1;
  margin: 0 0 1rem;
  letter-spacing: -0.02em;
}

.lede {
  color: var(--text-dim);
  font-size: 1.125rem;
  margin: 0 0 1.75rem;
  max-width: 56ch;
}

.cta-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Phone mock */
.phone {
  --w: 280px;
  width: var(--w);
  height: calc(var(--w) * 2);
  margin: 0 auto;
  background: #0c1230;
  border: 1px solid var(--border);
  border-radius: 36px;
  position: relative;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.phone::before {
  content: "";
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: 90px;
  height: 18px;
  background: #000;
  border-radius: 99px;
}

.phone-screen {
  position: absolute;
  inset: 50px 14px 14px;
  background: linear-gradient(180deg, #161e44, #0d142f);
  border-radius: 22px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.phone-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 0.75rem;
}

.phone-card .bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  margin-bottom: 0.5rem;
}
.phone-card .bar.short { width: 40%; }
.phone-card .bar.dim { background: rgba(255, 255, 255, 0.08); }

.phone-card.accent {
  background: rgba(0, 212, 164, 0.12);
  border-color: rgba(0, 212, 164, 0.3);
}

/* --- Sections -------------------------------------------------------------- */
section {
  padding: 4rem 0;
}

.section-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.section-header h2 {
  font-size: clamp(1.6rem, 3vw, 2.25rem);
  margin: 0 0 0.5rem;
  letter-spacing: -0.01em;
}

.section-header p {
  color: var(--text-dim);
  margin: 0;
  max-width: 60ch;
  margin-inline: auto;
}

/* --- Feature grid ---------------------------------------------------------- */
.features {
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}

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

.feature h3 {
  margin: 0.75rem 0 0.5rem;
  font-size: 1.15rem;
}

.feature p {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.95rem;
}

.icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: rgba(79, 140, 255, 0.15);
  color: var(--primary);
  border-radius: 10px;
  font-size: 1.25rem;
  font-weight: 800;
}

/* --- How it works ---------------------------------------------------------- */
.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 0;
}

.steps li {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem;
  position: relative;
}

.steps li::before {
  counter-increment: step;
  content: counter(step, decimal-leading-zero);
  display: inline-block;
  font-weight: 800;
  color: var(--accent);
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.steps h3 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

.steps p {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.95rem;
}

/* --- Auth / forms ---------------------------------------------------------- */
.auth-wrap {
  max-width: 440px;
  margin: 3rem auto;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}

.auth-wrap h1 {
  font-size: 1.75rem;
  margin: 0 0 0.25rem;
}

.auth-wrap .lede {
  font-size: 1rem;
  margin-bottom: 1.5rem;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--bg-card);
  padding: 0.25rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
}

.tabs button {
  flex: 1;
  background: transparent;
  border: 0;
  color: var(--text-dim);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  min-height: 40px;
}

.tabs button[aria-selected="true"] {
  background: var(--primary);
  color: #fff;
}

.field {
  margin-bottom: 1rem;
}

.field label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text);
}

.field input,
.field textarea,
.field select {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem 0.85rem;
  font: inherit;
  min-height: 44px;
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--primary);
  outline: 2px solid rgba(79, 140, 255, 0.35);
  outline-offset: 1px;
}

.field .hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.field .error {
  font-size: 0.85rem;
  color: var(--danger);
  margin-top: 0.4rem;
  display: none;
}

.field.has-error input,
.field.has-error textarea {
  border-color: var(--danger);
}

.field.has-error .error { display: block; }

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin: 1.25rem 0;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.divider span { padding: 0 0.75rem; }

.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  display: none;
}

.alert.show { display: block; }

.alert-error {
  background: rgba(255, 79, 109, 0.12);
  border: 1px solid rgba(255, 79, 109, 0.4);
  color: #ffb6c2;
}

.alert-success {
  background: rgba(0, 212, 164, 0.12);
  border: 1px solid rgba(0, 212, 164, 0.4);
  color: #93f0d3;
}

.alert-info {
  background: rgba(79, 140, 255, 0.12);
  border: 1px solid rgba(79, 140, 255, 0.4);
  color: #c8d8ff;
}

.auth-foot {
  text-align: center;
  margin-top: 1.25rem;
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* --- My Products page ------------------------------------------------------ */
.page-header {
  padding: 2.5rem 0 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

.page-header h1 {
  margin: 0 0 0.25rem;
  font-size: clamp(1.75rem, 3vw, 2.25rem);
}

.page-header p {
  margin: 0;
  color: var(--text-dim);
}

.user-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.user-bar .user-info {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text-dim);
  font-size: 0.95rem;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  display: grid;
  place-items: center;
  font-weight: 700;
  color: var(--accent);
  border: 1px solid var(--border);
}

.toolbar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.toolbar .search {
  flex: 1 1 220px;
  min-width: 0;
}

.toolbar .search input {
  width: 100%;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  min-height: 44px;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.product-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.product-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.product-card h3 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.product-card .barcode {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  color: var(--muted);
  font-size: 0.8rem;
}

.product-card .rating {
  color: var(--warning);
  letter-spacing: 0.1em;
  font-size: 0.95rem;
}

.product-card .rating .visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

.product-card .notes {
  color: var(--text-dim);
  font-size: 0.95rem;
  background: var(--bg-card);
  border-left: 3px solid var(--accent);
  padding: 0.6rem 0.75rem;
  border-radius: 0 6px 6px 0;
  white-space: pre-wrap;
}

.product-card footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  font-size: 0.8rem;
  color: var(--muted);
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
}

.empty-state h2 {
  color: var(--text);
  margin: 0 0 0.5rem;
}

/* --- Modal ----------------------------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 22, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.modal.open { display: flex; }

.modal-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.modal-card h2 {
  margin: 0 0 1rem;
  font-size: 1.25rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* --- Footer ---------------------------------------------------------------- */
.site-footer {
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  margin-top: 2rem;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.footer-grid {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.footer-links {
  display: flex;
  gap: 1.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-links a {
  color: var(--text-dim);
  text-decoration: none;
}

.footer-links a:hover { color: var(--text); }

/* Visually hidden utility for screen readers */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* --- High contrast tweak --------------------------------------------------- */
@media (prefers-contrast: more) {
  :root {
    --text-dim: #e6eaf6;
    --border: #4d5a93;
  }
}
