/* ============================================================
   ClearPick — style.css
   ============================================================ */

:root {
  --navy:        #0f172a;
  --green:       #059669;
  --green-mid:   #047857;
  --green-light: #d1fae5;
  --green-glow:  rgba(5, 150, 105, 0.18);
  --blue:        #2563eb;
  --blue-light:  #dbeafe;
  --coral:       #dc2626;
  --coral-light: #fee2e2;
  --bg:          #f6f5f1;
  --surface:     #ffffff;
  --border:      rgba(15, 23, 42, 0.11);
  --border-md:   rgba(15, 23, 42, 0.20);
  --text:        #1e293b;
  --text-muted:  #64748b;
  --text-hint:   #94a3b8;
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   14px;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ─────────────────────────────────────────────── */

.app-header {
  background: var(--navy);
  padding-top: env(safe-area-inset-top, 0px);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
}

.header-inner {
  padding: 14px 16px 12px;
}

.logo-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  margin-bottom: 0;
}

.logo-btn:active .logo-icon {
  opacity: 0.75;
}

.logo-icon {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}

.logo-name {
  font-size: 30px;
  font-weight: 300;
  color: white;
  letter-spacing: -0.03em;
  line-height: 1;
}

.logo-name em {
  font-style: normal;
  font-weight: 700;
  color: #34d399;
}

.tagline {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.45);
  padding-left: 54px;
  font-weight: 600;
}

/* ── Category nav ───────────────────────────────────────── */

.category-tabs {
  display: flex;
  gap: 0;
  padding: 0 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.category-tabs::-webkit-scrollbar { display: none; }

.cat-tab {
  padding: 9px 14px 8px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: rgba(255, 255, 255, 0.45);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}

.cat-tab.active {
  color: #34d399;
  border-bottom-color: #34d399;
}

.cat-tab:not(.active):hover {
  color: rgba(255, 255, 255, 0.75);
}

/* ── Main ───────────────────────────────────────────────── */

.app-main {
  flex: 1;
  padding: 14px 12px;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
  /* JS sets padding-top dynamically to match fixed header height */
}

/* Spacer div that pushes content below the fixed header */
.header-spacer {
  flex-shrink: 0;
}

/* ── Compare grid ───────────────────────────────────────── */

.compare-grid {
  display: flex;
  flex-direction: column;
  gap: 25px;
  margin-bottom: 14px;
  padding-top: 25px;
}

/* ── Product card ───────────────────────────────────────── */

.product-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 14px;
}

/* Two fields side by side within a card */
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 8px;
}

.field-row .field {
  margin-bottom: 0;
}

.field-row.row-brand {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.field-row.row-details {
  grid-template-columns: 1fr 1fr 1fr;
}

.product-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: -14px -14px 12px -14px;
  padding: 10px 14px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.product-card.card-a .product-head {
  background: var(--blue-light);
}

.product-card.card-b .product-head {
  background: var(--coral-light);
}

.product-head-left {
  display: flex;
  align-items: center;
  gap: 7px;
}

.pdot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.card-a .pdot { background: var(--blue); }
.card-b .pdot { background: var(--coral); }

.product-head-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.card-a .product-head-label { color: #1d4ed8; }
.card-b .product-head-label { color: #b91c1c; }

/* ── Form fields ────────────────────────────────────────── */

.field {
  margin-bottom: 8px;
}

.field:last-child {
  margin-bottom: 0;
}

.field-label {
  font-size: 11px;
  color: var(--text-hint);
  font-weight: 500;
  margin-bottom: 3px;
  display: block;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  height: 35px;
  border: 1px solid var(--border-md);
  border-radius: var(--radius-sm);
  padding: 0 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="number"] { font-variant-numeric: tabular-nums; }

input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-glow);
  background: white;
}

input::placeholder { color: var(--text-hint); }

/* Remove number spinners */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }
input[type="number"] { -moz-appearance: textfield; }

.size-row {
  display: grid;
  grid-template-columns: 1fr 14px 1fr;
  align-items: center;
  gap: 2px;
}

.size-sep {
  text-align: center;
  font-size: 11px;
  color: var(--text-hint);
}

/* ── Results section ────────────────────────────────────── */

.results-section {
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* Results table */
.results-table {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 10px;
}

.results-head {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  background: #f1f5f9;
  border-bottom: 1px solid var(--border-md);
}

.rh-cell {
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 5px;
}

.rh-cell + .rh-cell {
  border-left: 1px solid var(--border);
  justify-content: flex-end;
}

.result-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  border-top: 1px solid var(--border);
}

.r-metric {
  padding: 11px 10px;
  font-size: 12px;
  color: var(--text-muted);
  align-self: center;
  line-height: 1.3;
}

.r-val {
  padding: 11px 10px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  text-align: right;
  border-left: 1px solid var(--border);
  align-self: center;
  font-variant-numeric: tabular-nums;
}

.r-val.winner { color: var(--green-mid); }
.r-val.loser  { color: var(--text-hint); font-weight: 400; }

/* Winner banner */
.winner-banner {
  border-radius: 0;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
  min-height: 0;
}

.winner-banner:empty { display: none; }
.winner-banner.a    { background: var(--blue);  color: white; }
.winner-banner.b    { background: var(--coral); color: white; }
.winner-banner.tie  { background: #334155;      color: rgba(255,255,255,0.85); }

/* ── Footer ─────────────────────────────────────────────── */

.app-footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-hint);
  padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
}

/* ── Utilities ──────────────────────────────────────────── */

[hidden] { display: none !important; }

/* ── Winner bar (top position) ──────────────────────────────── */

/* Override: banner now lives above the grid, needs bottom margin */
#winner-banner {
  margin-bottom: 12px;
}

#winner-banner:empty {
  display: none;
  margin: 0;
}

/* Savings badge inside banner */
.pct-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  margin-left: 4px;
  vertical-align: middle;
}

.winner-banner.a .pct-badge,
.winner-banner.b .pct-badge {
  background: rgba(255,255,255,0.22);
  color: white;
}

/* ── Select fields ──────────────────────────────────────────── */

select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--border-md);
  border-radius: var(--radius-sm);
  padding: 0 28px 0 9px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

select:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-glow);
}

/* ── Sheet size toggle ──────────────────────────────────────── */

.size-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  color: var(--green-mid);
  background: none;
  border: 1px solid var(--green-mid);
  border-radius: 20px;
  padding: 4px 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  margin-top: 2px;
}

.size-toggle-btn:hover,
.size-toggle-btn.active {
  background: var(--green-light);
}

/* ── Winner bar in sticky header ────────────────────────────── */

.app-header .winner-banner {
  margin: 0;
}

.app-header .winner-banner:empty {
  display: none;
}

/* Remove the old top-of-main margin rule since banner moved to header */
#winner-banner {
  margin-bottom: 0;
}

/* ── Category dropdown in header ────────────────────────────── */

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.category-select {
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.80);
  font-family: inherit;
  font-size: 11px;
  padding: 5px 22px 5px 8px;
  cursor: pointer;
  flex-shrink: 0;
  max-width: 140px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='rgba(255,255,255,0.6)' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
}

.category-select:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.4);
}

/* Override: size toggle btn in product head — on light tinted background */
.card-a .product-head .size-toggle-btn {
  font-size: 11px;
  padding: 3px 8px;
  color: #1d4ed8;
  border-color: rgba(37,99,235,0.35);
  background: rgba(37,99,235,0.08);
  margin-top: 0;
}

.card-b .product-head .size-toggle-btn {
  font-size: 11px;
  padding: 3px 8px;
  color: #b91c1c;
  border-color: rgba(220,38,38,0.35);
  background: rgba(220,38,38,0.08);
  margin-top: 0;
}

.card-a .product-head .size-toggle-btn:hover,
.card-a .product-head .size-toggle-btn.active {
  background: rgba(37,99,235,0.16);
  border-color: rgba(37,99,235,0.6);
}

.card-b .product-head .size-toggle-btn:hover,
.card-b .product-head .size-toggle-btn.active {
  background: rgba(220,38,38,0.16);
  border-color: rgba(220,38,38,0.6);
}

/* ── Winner banner two-line layout ──────────────────────────── */

.banner-line1 {
  font-size: 21px;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 6px;
  text-align: center;
  /* Shrink gracefully for long brand names */
  overflow-wrap: break-word;
}

.banner-line2 {
  font-size: 16px;
  font-weight: 600;
  opacity: 0.92;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  text-align: center;
}

.banner-line2 strong {
  font-weight: 700;
}

/* ── Winner banner reveal animation ────────────────────────── */

@keyframes bannerReveal {
  from {
    opacity: 0;
    transform: scaleY(0.88);
    transform-origin: top;
  }
  to {
    opacity: 1;
    transform: scaleY(1);
    transform-origin: top;
  }
}

.winner-banner.banner-reveal {
  animation: bannerReveal 0.2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* ── Ply segmented control ──────────────────────────────────── */

.ply-inline {
  flex: 0 0 38%;
  margin-bottom: 0;
}

.ply-inline .ply-buttons {
  width: 100%;
  height: 42px;
}

.ply-inline .ply-btn {
  font-size: 13px;
}

.row-brand .field select {
  height: 42px;
}

.row-details .field select,
.row-details .field input[type="number"] {
  height: 42px;
}

.ply-buttons {
  display: flex;
  gap: 0;
  border: 1px solid var(--border-md);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.ply-btn {
  flex: 1;
  height: 100%;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-muted);
  background: var(--bg);
  border: none;
  border-right: 1px solid var(--border-md);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.ply-btn:last-child { border-right: none; }

.ply-btn.active {
  background: #b0b0b0;
  color: white;
}

.ply-btn:not(.active):hover {
  background: #e8e7e3;
}

/* ── Header warning banner ──────────────────────────────────── */

.warning-banner {
  display: none;
  background: #854d0e;
  color: #fef9c3;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
  border-radius: 0;
}

.warning-banner.visible {
  display: block;
}

.warn-icon {
  font-size: 13px;
  margin-right: 4px;
  opacity: 0.85;
}

/* ── See Results button ──────────────────────────────────────── */

.see-results-btn {
  display: block;
  width: 100%;
  padding: 14px;
  margin-bottom: 14px;
  background: var(--green);
  color: white;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  letter-spacing: 0.01em;
}

.see-results-btn:active {
  background: var(--green-mid);
  transform: scale(0.98);
}

/* ── Share button ────────────────────────────────────────────── */

.share-btn {
  display: block;
  width: 100%;
  padding: 10px 16px;
  background: var(--green);
  color: white;
  font-size: 0; /* kills any stale ::after from old cached CSS */
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-top: 2px solid var(--green-mid);
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: background 0.15s;
}

#share-label {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.share-btn:active {
  background: var(--green-mid);
}

.share-btn::after, .share-btn::before { content: none !important; }

/* ── Home screen ─────────────────────────────────────────────── */

.home-intro {
  font-size: 15px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 20px;
  text-align: center;
}

.category-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.cat-card {
  background: white;
  border: 2px solid var(--green);
  border-radius: var(--radius-lg);
  padding: 24px 16px 18px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transition: background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.cat-card:active {
  background: var(--green-light);
  transform: scale(0.97);
}

.cat-card-icon {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cat-card-icon i {
  font-size: 48px;
  color: var(--green);
}

.cat-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--green-mid);
  text-align: center;
  line-height: 1.3;
}

/* home-btn removed — logo is now the home link */

/* ── Wizard ─────────────────────────────────────────────────── */

.wiz-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 24px 20px;
  max-width: 480px;
  margin: 0 auto;
}

.wiz-progress {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.wiz-pip {
  height: 4px;
  flex: 1;
  border-radius: 2px;
  background: #D3D1C7;
}
.wiz-pip.done   { background: #059669; }
.wiz-pip.active { background: #059669; opacity: 0.55; }

.wiz-step-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
  margin-bottom: 12px;
}

.wiz-product-id {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #059669;
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 20px;
}

.wiz-product-id i {
  font-size: 28px;
  color: #059669;
}

.wiz-brand-side {
  margin-left: auto;
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}

.wiz-prompt {
  font-size: 20px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 8px;
}

.wiz-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 18px;
  line-height: 1.5;
}

.wiz-brand-label {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  margin-top: 0;
}

.wiz-field-label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 6px;
  margin-top: 16px;
}

.wiz-select {
  width: 100%;
  height: 60px;
  font-size: 20px;
  border: 1px solid var(--border-md);
  border-radius: var(--radius-md);
  background: white;
  color: var(--text);
  padding: 0 40px 0 16px;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

.wiz-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.wiz-row .wiz-field-label {
  margin-top: 0;
}

.wiz-row .wiz-big-input {
  width: 100%;
  box-sizing: border-box;
  font-size: 26px;
  background: white;
}

.wiz-big-input {
  width: 100%;
  height: 60px;
  font-size: 26px;
  font-weight: 500;
  text-align: center;
  border: 1px solid var(--border-md);
  border-radius: var(--radius-md);
  background: white;
  color: var(--text);
  font-family: inherit;
  box-sizing: border-box;
}

.wiz-big-input:focus {
  outline: none;
  border-color: #059669;
}

.wiz-ply-buttons {
  display: flex;
  width: 100%;
  height: 50px;
  border: 1px solid var(--border-md);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-top: 6px;
}

.wiz-nav {
  display: flex;
  gap: 10px;
  margin-top: 28px;
}

.wiz-btn-back {
  flex: 1;
  height: 52px;
  background: var(--bg);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-md);
  font-size: 15px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
}

.wiz-btn-next {
  flex: 2;
  height: 52px;
  background: #059669;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  color: white;
  cursor: pointer;
  font-family: inherit;
}

.wiz-btn-next:active { opacity: 0.88; }
.wiz-btn-back:active  { background: #e8e7e3; }

/* ── Action bar (results screen) ────────────────────────────── */

#action-bar {
  display: flex;
  gap: 8px;
  padding: 14px 0 6px;
}

.action-btn {
  flex: 1;
  height: 46px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
}

.action-btn:active { opacity: 0.75; }

.action-primary {
  background: #059669;
  border: none;
  color: white;
  flex: 2;
}

.action-green {
  background: #059669;
  border: none;
  color: white;
}

.action-secondary {
  background: var(--bg);
  border: 1px solid var(--border-md);
  color: var(--text-muted);
}
