/* ─────────────────────────────────────────────────────────────────────────────
   SnapShop — Botanical Boutique Design
   ───────────────────────────────────────────────────────────────────────────── */

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

/* ── Design tokens ───────────────────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --cream:      #FBF7F0;
  --cream-dark: #F5EFE3;
  --surface:    #FEFCF8;

  /* Text */
  --ink:        #3D2B1F;
  --ink-2:      #7A5842;
  --ink-3:      #B09480;

  /* Accents */
  --coffee:     #6F4E37;
  --caramel:    #A47551;
  --tan:        #C4A882;
  --blush:      #E8C4C4;
  --blush-d:    #D4A5A5;
  --sage:       #A3B18A;
  --sage-d:     #7A9168;

  /* Borders */
  --border:     #DDD0BF;
  --border-l:   #EDE5D8;

  /* Radii */
  --r-sm:  10px;
  --r-md:  18px;
  --r-lg:  26px;
  --r-xl:  36px;

  /* Shadows */
  --shadow-xs: 0 1px 4px rgba(111,78,55,.06);
  --shadow-sm: 0 3px 14px rgba(111,78,55,.09);
  --shadow-md: 0 8px 32px rgba(111,78,55,.12);
  --shadow-lg: 0 18px 52px rgba(111,78,55,.15);

  /* Motion */
  --ease:     cubic-bezier(.4,0,.2,1);
  --ease-out: cubic-bezier(0,0,.2,1);
}

/* ── Base ────────────────────────────────────────────────────────────────── */
html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Lato', Georgia, sans-serif;
  background: var(--cream);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

/* ── Top nav ─────────────────────────────────────────────────────────────── */
.top-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 1.4rem 2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border-l);
}

.nav-sprig {
  opacity: 0.9;
  flex-shrink: 0;
}

.logo {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--coffee);
  display: flex;
  align-items: center;
  gap: 0.2rem;
  user-select: none;
}
.logo span { color: var(--caramel); }

.logo-flower {
  margin-left: 0.1rem;
  flex-shrink: 0;
  position: relative;
  top: -2px;
}

/* ── Hero ────────────────────────────────────────────────────────────────── */
.hero {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border-bottom: 1px solid var(--border-l);
  padding: 5rem 2rem 4.5rem;
}

.botanical {
  position: absolute;
  top: 0;
  opacity: 0.85;
  pointer-events: none;
}
.botanical-left  { left: -10px; }
.botanical-right { right: -10px; transform: scaleX(-1); }

.hero-content {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 600px;
  margin: 0 auto;
}

.hero-eyebrow {
  font-family: 'Lato', sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--tan);
  margin-bottom: 1rem;
}

.hero-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(2.4rem, 5.5vw, 3.8rem);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 1.4rem;
}
.hero-title em {
  font-style: italic;
  font-weight: 600;
  color: var(--coffee);
}

.hero-sub {
  font-size: 1rem;
  font-weight: 300;
  color: var(--ink-2);
  line-height: 1.75;
  max-width: 440px;
  margin: 0 auto 2rem;
}

.floral-divider {
  display: flex;
  justify-content: center;
  margin-top: 0.5rem;
}

/* ── Upload section ──────────────────────────────────────────────────────── */
#upload-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3.5rem 1.5rem 3rem;
  gap: 1.4rem;
}

#drop-zone {
  border: 1.8px dashed var(--border);
  border-radius: var(--r-xl);
  padding: 3.5rem 2.5rem 3rem;
  max-width: 540px;
  width: 100%;
  text-align: center;
  cursor: pointer;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  transition:
    border-color 0.25s var(--ease),
    background   0.25s var(--ease),
    box-shadow   0.25s var(--ease),
    transform    0.2s  var(--ease);
  outline: none;
}

#drop-zone:hover,
#drop-zone:focus {
  border-color: var(--blush-d);
  background: #FEFAF6;
  box-shadow: 0 0 0 6px rgba(232,196,196,.18), var(--shadow-sm);
  transform: translateY(-2px);
}

#drop-zone.drag-over {
  border-color: var(--caramel);
  background: #FDF6ED;
  box-shadow: 0 0 0 6px rgba(196,168,130,.2), var(--shadow-md);
  transform: translateY(-3px);
}

.drop-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--cream-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.6rem;
  transition: background 0.22s, transform 0.22s var(--ease);
  border: 1px solid var(--border-l);
}

#drop-zone:hover .drop-icon,
#drop-zone.drag-over .drop-icon {
  background: #F9EDE6;
  transform: scale(1.07) rotate(-3deg);
}

.drop-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.5rem;
  letter-spacing: 0.01em;
}

.drop-sub {
  font-size: 0.92rem;
  font-weight: 300;
  color: var(--ink-3);
  margin-bottom: 0.35rem;
}

.browse-link {
  color: var(--caramel);
  cursor: pointer;
  font-weight: 400;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  transition: color 0.15s;
}
.browse-link:hover { color: var(--coffee); }

.drop-hint {
  margin-top: 1.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--border);
}

.upload-invite {
  font-size: 0.82rem;
  font-weight: 300;
  color: var(--ink-3);
  font-style: italic;
  max-width: 380px;
  text-align: center;
  line-height: 1.6;
}

/* ── Scan state ──────────────────────────────────────────────────────────── */
#scan-section {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 3rem 1.5rem 4rem;
  animation: fadeIn 0.35s var(--ease) both;
}

.scan-label {
  font-family: 'Playfair Display', serif;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--ink-3);
  text-align: center;
  margin-bottom: 1.5rem;
  letter-spacing: 0.03em;
}

.scan-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 300px;
}

.scan-image-frame {
  position: relative;
  width: 100%;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--cream-dark);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-l);
}

.scan-image-frame img {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: cover;
}

/* Corner brackets in warm brown */
.scan-corners { position: absolute; inset: 0; pointer-events: none; }

.corner {
  position: absolute;
  width: 18px;
  height: 18px;
  border-color: var(--caramel);
  border-style: solid;
  opacity: 0.75;
}
.corner.tl { top: 10px; left: 10px;   border-width: 1.8px 0 0 1.8px; border-radius: 3px 0 0 0; }
.corner.tr { top: 10px; right: 10px;  border-width: 1.8px 1.8px 0 0; border-radius: 0 3px 0 0; }
.corner.bl { bottom: 10px; left: 10px;  border-width: 0 0 1.8px 1.8px; border-radius: 0 0 0 3px; }
.corner.br { bottom: 10px; right: 10px; border-width: 0 1.8px 1.8px 0; border-radius: 0 0 3px 0; }

/* Warm blush sweeping scan line */
.scan-line {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(232,196,196,.3) 15%,
    rgba(196,168,130,.9) 50%,
    rgba(232,196,196,.3) 85%,
    transparent 100%
  );
  box-shadow: 0 0 18px 8px rgba(196,168,130,.3);
  animation: scanSweep 2.2s cubic-bezier(.4,0,.6,1) infinite;
}

@keyframes scanSweep {
  0%       { top: 0%;   opacity: 0; }
  6%       { opacity: 1; }
  47%      { top: 99%;  opacity: 1; }
  50%      { top: 100%; opacity: 0; }
  50.001%  { top: 0%;   opacity: 0; }
  100%     { top: 0%;   opacity: 0; }
}

/* Floating petals */
.scan-petals {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.petal {
  position: absolute;
  bottom: -12px;
  width: 9px;
  height: 14px;
  background: rgba(232, 196, 196, 0.65);
  border-radius: 50% 50% 50% 0;
  animation: floatPetal 3.5s ease-in-out infinite;
  will-change: transform, opacity;
}
.p1 { left: 12%; animation-delay: 0s; }
.p2 { left: 28%; animation-delay: 0.7s;  transform: rotate(25deg); width: 7px; height: 11px; }
.p3 { left: 52%; animation-delay: 1.4s;  background: rgba(163,177,138,.5); }
.p4 { left: 68%; animation-delay: 0.35s; transform: rotate(-18deg); width: 8px; height: 12px; }
.p5 { left: 84%; animation-delay: 1.05s; background: rgba(196,168,130,.55); width: 7px; height: 10px; }

@keyframes floatPetal {
  0%   { transform: translateY(0) rotate(0deg);    opacity: 0; }
  8%   { opacity: 0.75; }
  90%  { opacity: 0.2; }
  100% { transform: translateY(-220px) rotate(200deg); opacity: 0; }
}

/* Scan footer */
.scan-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  margin-top: 1.6rem;
}

.scan-dots {
  display: flex;
  gap: 7px;
  align-items: center;
}
.scan-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--blush);
  animation: dotBounce 1.4s ease infinite;
}
.scan-dots span:nth-child(2) { animation-delay: 0.2s; background: var(--tan); }
.scan-dots span:nth-child(3) { animation-delay: 0.4s; background: var(--sage); }

@keyframes dotBounce {
  0%, 60%, 100% { transform: translateY(0);    opacity: 0.4; }
  30%            { transform: translateY(-6px); opacity: 1;   }
}

.scan-status {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 0.88rem;
  color: var(--ink-3);
  letter-spacing: 0.06em;
  min-height: 1.3em;
}

/* ── Sort bar ────────────────────────────────────────────────────────────── */
#sort-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  max-width: 1180px;
  margin: 0 auto 1.5rem;
  padding: 1.1rem 2rem;
  border-bottom: 1px solid var(--border-l);
  animation: fadeIn 0.3s var(--ease) both;
}

.results-count {
  flex: 1;
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 0.88rem;
  color: var(--ink-3);
}

.sort-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
}
.sort-controls label {
  color: var(--ink-3);
  font-weight: 300;
  letter-spacing: 0.02em;
}
.sort-controls select {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 0.4rem 1.8rem 0.4rem 0.7rem;
  font-family: 'Lato', sans-serif;
  font-size: 0.82rem;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23B09480' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.55rem center;
  transition: border-color 0.18s;
}
.sort-controls select:focus { border-color: var(--caramel); }

.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1.5px solid var(--border);
  background: none;
  border-radius: var(--r-sm);
  padding: 0.42rem 0.9rem;
  font-family: 'Lato', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-2);
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.btn-outline:hover {
  border-color: var(--caramel);
  color: var(--coffee);
  background: #FDF6ED;
}

/* ── Results section ─────────────────────────────────────────────────────── */
#results-section {
  padding: 0 1.75rem 4rem;
  animation: fadeIn 0.3s var(--ease) both;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  max-width: 1180px;
  margin: 0 auto;
}

/* ── Product card ────────────────────────────────────────────────────────── */
.product-card {
  background: var(--surface);
  border: 1px solid var(--border-l);
  border-radius: var(--r-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xs);
  transition:
    transform   0.24s var(--ease),
    box-shadow  0.24s var(--ease),
    border-color 0.24s;
  animation: fadeUp 0.45s var(--ease-out) both;
}
.product-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-md);
  border-color: var(--border);
}

/* Staggered fade-in for first 12 */
.product-card:nth-child(1)  { animation-delay: 0.00s; }
.product-card:nth-child(2)  { animation-delay: 0.05s; }
.product-card:nth-child(3)  { animation-delay: 0.10s; }
.product-card:nth-child(4)  { animation-delay: 0.15s; }
.product-card:nth-child(5)  { animation-delay: 0.20s; }
.product-card:nth-child(6)  { animation-delay: 0.25s; }
.product-card:nth-child(7)  { animation-delay: 0.30s; }
.product-card:nth-child(8)  { animation-delay: 0.35s; }
.product-card:nth-child(9)  { animation-delay: 0.40s; }
.product-card:nth-child(10) { animation-delay: 0.45s; }
.product-card:nth-child(11) { animation-delay: 0.50s; }
.product-card:nth-child(12) { animation-delay: 0.55s; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0);    }
}

.card-image-wrap {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: var(--cream-dark);
}

.card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.45s var(--ease);
}
.product-card:hover .card-image { transform: scale(1.06); }

/* Thumbnail-only fallback: contain instead of cover so small images
   aren't upscaled and blurred. Adds a little padding inside the frame. */
.has-thumbnail-only .card-image {
  object-fit: contain;
  padding: 0.75rem;
  background: var(--cream-dark);
}

/* Match badges — pure CSS nth-child, no JS needed */
.card-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  display: none;
  font-family: 'Lato', sans-serif;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.22rem 0.6rem;
  border-radius: 20px;
}

/* 1st card: blush pill "Perfect Match" */
.results-grid .product-card:nth-child(1) .card-badge {
  display: block;
  background: var(--blush);
  color: var(--coffee);
}
.results-grid .product-card:nth-child(1) .card-badge::before { content: "Perfect Match"; }

/* 2nd–4th: sage pill "Top Pick" */
.results-grid .product-card:nth-child(2) .card-badge,
.results-grid .product-card:nth-child(3) .card-badge,
.results-grid .product-card:nth-child(4) .card-badge {
  display: block;
  background: var(--sage);
  color: #fff;
}
.results-grid .product-card:nth-child(2) .card-badge::before,
.results-grid .product-card:nth-child(3) .card-badge::before,
.results-grid .product-card:nth-child(4) .card-badge::before { content: "Top Pick"; }

/* Card body */
.card-body {
  padding: 0.9rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  flex: 1;
  background: var(--surface);
}

.card-source {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.card-title {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--ink);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.7rem;
}

.card-price {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--coffee);
  letter-spacing: 0.01em;
}

.card-btn {
  display: inline-flex;
  align-items: center;
  background: var(--coffee);
  color: var(--cream);
  text-decoration: none;
  border-radius: 20px;
  padding: 0.36rem 0.85rem;
  font-family: 'Lato', sans-serif;
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.2s var(--ease), transform 0.15s;
}
.card-btn:hover {
  background: var(--caramel);
  transform: scale(1.04);
}

/* ── Error state ─────────────────────────────────────────────────────────── */
#error-bar {
  padding: 0 1.5rem 2rem;
  display: flex;
  justify-content: center;
  animation: fadeIn 0.28s var(--ease) both;
}

.error-inner {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  max-width: 520px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 1.1rem 1.4rem;
  box-shadow: var(--shadow-xs);
}

.error-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(232,196,196,.3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--caramel);
}

#error-text {
  font-size: 0.88rem;
  font-weight: 300;
  color: var(--ink-2);
  flex: 1;
  line-height: 1.55;
}

#error-dismiss {
  background: var(--coffee);
  color: var(--cream);
  border: none;
  border-radius: 20px;
  padding: 0.42rem 1rem;
  font-family: 'Lato', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.18s;
}
#error-dismiss:hover { background: var(--caramel); }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.site-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 2.5rem 2rem;
  background: var(--surface);
  border-top: 1px solid var(--border-l);
  margin-top: auto;
}

.footer-text {
  font-size: 0.74rem;
  font-weight: 300;
  color: var(--ink-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── Shared keyframes ────────────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Responsive: tablet ──────────────────────────────────────────────────── */
@media (max-width: 960px) {
  .botanical { display: none; }
  .hero { padding: 4rem 2rem 3.5rem; }
  .results-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ── Responsive: mobile ──────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .top-nav { padding: 1.1rem 1rem; gap: 0.4rem; }
  .logo { font-size: 1.25rem; }

  .hero { padding: 3rem 1.25rem 2.5rem; }
  .hero-title { font-size: 2.1rem; }
  .hero-sub { font-size: 0.92rem; }

  #upload-section { padding: 2.5rem 1rem 2.5rem; }
  #drop-zone { padding: 2.8rem 1.5rem 2.5rem; border-radius: var(--r-lg); }
  .drop-title { font-size: 1.05rem; }

  #results-section { padding: 0 0.75rem 3rem; }
  .results-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  #sort-bar { padding: 0.9rem 1rem; gap: 0.6rem; }
  .results-count { width: 100%; }

  .card-body { padding: 0.7rem 0.75rem 0.8rem; }
  .card-price { font-size: 0.88rem; }
  .card-btn { padding: 0.3rem 0.65rem; font-size: 0.7rem; }

  .site-footer { padding: 2rem 1rem; }
}
