:root {
  --night: #14061c;
  --plum: #2b0b2a;
  --plum-2: #3a0d24;
  --maroon: #5c0f1f;
  --sindoor: #d7263d;
  --gold: #e9b44c;
  --gold-2: #f7d98a;
  --gold-deep: #b9862f;
  --moon: #fff3d1;
  --cream: #f8eedf;
  --muted: #cbb49b;
  --leaf: #3f7d20;
  --marigold: #ffa21f;
  --marigold-2: #f26b0f;

  --display: "Rozha One", "Tiro Devanagari Hindi", Georgia, serif;
  --body: "Mukta", "Segoe UI", sans-serif;
  --radius: 18px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.55;
  color: var(--cream);
  background: var(--night);
  overflow-x: hidden;
}

/* ---------- Night sky ---------- */
.sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1px 1px at 12% 18%, #fff8 50%, transparent 51%),
    radial-gradient(1px 1px at 28% 62%, #fff6 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 44% 12%, #fff9 50%, transparent 51%),
    radial-gradient(1px 1px at 58% 78%, #fff5 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 72% 34%, #fff8 50%, transparent 51%),
    radial-gradient(1px 1px at 86% 70%, #fff6 50%, transparent 51%),
    radial-gradient(1px 1px at 92% 14%, #fff7 50%, transparent 51%),
    radial-gradient(1px 1px at 6% 86%, #fff5 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 36% 90%, #fff6 50%, transparent 51%),
    radial-gradient(1px 1px at 66% 8%, #fff7 50%, transparent 51%),
    radial-gradient(60vmax 50vmax at 85% -10%, #5c0f1f99, transparent 70%),
    radial-gradient(70vmax 60vmax at -10% 110%, #3a0d2499, transparent 70%),
    linear-gradient(180deg, #14061c 0%, #1e0822 55%, #2a0a1e 100%);
}
/* Jaali (lattice) watermark */
.sky::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cg fill='none' stroke='%23e9b44c' stroke-width='1.2'%3E%3Cpath d='M28 4 52 28 28 52 4 28Z'/%3E%3Ccircle cx='28' cy='28' r='9'/%3E%3Cpath d='M28 19v18M19 28h18'/%3E%3C/g%3E%3C/svg%3E");
}

/* ---------- Marigold toran ---------- */
.toran {
  position: relative;
  height: 74px;
  overflow: hidden;
  pointer-events: none;
}
.toran::before {
  /* the main garland rope of marigolds */
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 22px;
  background:
    radial-gradient(circle at 11px 11px, var(--gold-2) 0 3px, var(--marigold) 4px 8px, var(--marigold-2) 9px 10px, transparent 11px) 0 0 / 20px 22px repeat-x;
  filter: drop-shadow(0 3px 4px #0006);
}
.strand {
  position: absolute;
  top: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform-origin: top center;
  animation: sway 5s ease-in-out infinite;
}
.strand i {
  display: block;
  width: 15px;
  height: 15px;
  margin-top: -3px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--gold-2) 0 2px, var(--marigold) 3px 5px, var(--marigold-2) 6px 7px);
}
.strand i:nth-child(even) { background: radial-gradient(circle, #fff1c2 0 2px, #ffd23f 3px 5px, #f2a50f 6px 7px); }
.strand b {
  /* mango leaf */
  display: block;
  width: 12px;
  height: 22px;
  margin-top: -2px;
  border-radius: 50% 50% 50% 50% / 30% 30% 70% 70%;
  background: linear-gradient(90deg, #2f6418, var(--leaf));
}
@keyframes sway { 50% { transform: rotate(3deg); } }

/* ---------- Layout ---------- */
main {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 0 24px 40px;
}

/* ---------- Hero ---------- */
.hero {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  align-items: center;
  gap: 32px;
  padding: 24px 0 40px;
}
.hero.compact { grid-template-columns: 1fr; padding: 8px 0 24px; }
.hero.compact .hero-art, .hero.compact .lede { display: none; }
.hero.compact h1 { font-size: clamp(1.8rem, 3.4vw, 2.4rem); }

.eyebrow {
  margin: 0 0 14px;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  color: var(--gold-2);
}
.eyebrow span { font-family: var(--display); font-size: 1.1rem; }

h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2.4rem, 5.6vw, 4.4rem);
  line-height: 1.05;
  color: var(--moon);
  text-shadow: 0 0 40px #fff3d133;
}
h1 em {
  font-style: normal;
  background: linear-gradient(100deg, var(--gold-2), var(--gold) 45%, var(--marigold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.lede { max-width: 34em; margin: 18px 0 0; color: var(--muted); }
.lede i { color: var(--gold-2); }

.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 22px;
  border-radius: 999px;
  border: 1.5px solid transparent;
  font: 600 1rem/1 var(--body);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s;
}
.btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn:active { transform: scale(0.97); }
.btn:focus-visible, .icon-btn:focus-visible, .shutter:focus-visible { outline: 3px solid var(--gold-2); outline-offset: 3px; }
.btn-gold {
  color: #3a0d10;
  background: linear-gradient(180deg, var(--gold-2), var(--gold) 60%, var(--gold-deep));
  box-shadow: 0 6px 24px #e9b44c40, inset 0 1px 0 #fff8;
}
.btn-gold:hover { box-shadow: 0 8px 32px #e9b44c70, inset 0 1px 0 #fff8; }
.btn-ghost { color: var(--gold-2); background: #ffffff08; border-color: #e9b44c80; }
.btn-ghost:hover { background: #e9b44c1a; }
.btn[disabled] { opacity: 0.5; cursor: wait; }

.model-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}
.model-status.ready { color: var(--gold-2); }
.model-status.error { color: #ff9a9a; }
.flame {
  width: 10px;
  height: 14px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: radial-gradient(circle at 50% 70%, #fff6c9, #ffb627 55%, #f26b0f);
  box-shadow: 0 0 12px #ffb627;
  animation: flicker 1.2s ease-in-out infinite alternate;
}
@keyframes flicker { to { transform: scale(0.85, 1.1) rotate(-3deg); opacity: 0.8; } }

/* Hero art */
.hero-art { display: grid; place-items: center; }
.chalni-art { width: min(420px, 100%); height: auto; overflow: visible; }
.moon-glow { animation: glow 5s ease-in-out infinite; transform-origin: 232px 168px; }
@keyframes glow { 50% { opacity: 0.6; transform: scale(1.06); } }
.sieve { animation: drift 9s ease-in-out infinite; transform-origin: 200px 200px; }
@keyframes drift { 50% { transform: translate(10px, -6px) rotate(6deg); } }
.diya-glow { filter: blur(10px); opacity: 0.7; animation: flicker 1.4s ease-in-out infinite alternate; transform-origin: 0 -20px; }

/* ---------- Result ---------- */
.result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: 32px;
  align-items: start;
}
.stage-col { position: sticky; top: 16px; }

.stage {
  position: relative;
  border-radius: var(--radius);
  padding: 10px;
  background:
    linear-gradient(var(--plum), var(--plum)) padding-box,
    linear-gradient(135deg, var(--gold-2), var(--gold-deep) 40%, var(--gold) 70%, var(--gold-2)) border-box;
  border: 2px solid transparent;
  box-shadow: 0 20px 60px #0008, 0 0 0 6px #e9b44c14;
}
.stage canvas { display: block; width: 100%; height: auto; border-radius: 10px; }
#scanCanvas { position: absolute; inset: 10px; width: calc(100% - 20px); height: calc(100% - 20px); pointer-events: none; }
.stage.done #scanCanvas { display: none; }
#photoCanvas { transition: opacity 0.4s; }
.stage.reveal #photoCanvas { animation: reveal 0.9s ease-out; }
@keyframes reveal { from { opacity: 0; transform: scale(0.98); filter: brightness(1.8) saturate(0.4); } }

.scan-msg {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  padding: 10px 20px;
  border-radius: 999px;
  background: #14061ccc;
  border: 1px solid #e9b44c66;
  text-align: center;
  white-space: nowrap;
  font-family: var(--display);
  font-size: 1.1rem;
  color: var(--gold-2);
  backdrop-filter: blur(6px);
}
.scan-msg small { display: block; font: 500 0.75rem var(--body); color: var(--muted); letter-spacing: 0.05em; }
.stage.done .scan-msg { display: none; }

.stage-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

/* ---------- Offers ---------- */
.offers-head { margin-bottom: 8px; }
.offers-head .hi { margin: 0; font-family: var(--display); font-size: 1.3rem; color: var(--marigold); }
.offers-head h2 { margin: 2px 0 4px; font-family: var(--display); font-weight: 400; font-size: clamp(1.7rem, 3vw, 2.3rem); color: var(--moon); line-height: 1.15; }
.asof { margin: 0; font-size: 0.85rem; color: var(--muted); }

.group { margin-top: 26px; animation: rise 0.6s both; }
.group:nth-child(2) { animation-delay: 0.12s; }
.group:nth-child(3) { animation-delay: 0.24s; }
.group:nth-child(4) { animation-delay: 0.36s; }
.group:nth-child(5) { animation-delay: 0.48s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

.group-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 10px;
  margin-bottom: 14px;
  border-bottom: 1px solid #e9b44c33;
}
.group-num {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-family: var(--display);
  color: #3a0d10;
  background: radial-gradient(circle at 35% 30%, var(--moon), var(--gold-2) 55%, var(--gold));
  box-shadow: 0 0 16px #fff3d155;
}
.group-num.festive { background: radial-gradient(circle at 35% 30%, #ffd9a0, var(--marigold) 60%, var(--marigold-2)); }
.group-title { flex: 1; min-width: 0; }
.group-title h3 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 1.35rem; line-height: 1.2; }
.group-title p { margin: 0; font-size: 0.85rem; color: var(--muted); }
.see-all { flex-shrink: 0; color: var(--gold-2); font-size: 0.9rem; font-weight: 500; text-decoration: none; }
.see-all:hover { text-decoration: underline; }

.cards {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 196px;
  gap: 14px;
  overflow-x: auto;
  padding: 4px 2px 14px;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
  scrollbar-color: #e9b44c55 transparent;
}
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  scroll-snap-align: start;
  padding: 10px 10px 12px;
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff0d, #ffffff05);
  border: 1px solid #e9b44c2e;
  color: inherit;
  text-decoration: none;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.card:hover { transform: translateY(-4px); border-color: #e9b44c99; box-shadow: 0 12px 30px #0007; }

/* Jharokha (arched window) product frame */
.card-img {
  display: grid;
  place-items: center;
  aspect-ratio: 1 / 1.05;
  padding: 14px 12px 10px;
  border-radius: 999px 999px 10px 10px;
  background: radial-gradient(circle at 50% 35%, #fffaf0, var(--cream) 70%, #ecdcc2);
  box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 5px #e9b44c88;
}
.card-img img { max-width: 100%; max-height: 100%; object-fit: contain; mix-blend-mode: multiply; }

.badge-off {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 3px 8px 3px 10px;
  font: 700 0.78rem/1.3 var(--body);
  color: #fff;
  background: var(--sindoor);
  clip-path: polygon(8px 0, 100% 0, 100% 100%, 8px 100%, 0 50%);
  box-shadow: 0 2px 6px #0006;
}
.card-brand { margin: 10px 0 0; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--gold-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-title {
  margin: 2px 0 6px;
  font-size: 0.88rem;
  line-height: 1.35;
  color: var(--cream);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 0.75rem; color: var(--muted); }
.rating { padding: 0 6px; border-radius: 4px; font-weight: 700; color: #fff; background: #388e3c; }
.assured { color: var(--gold-2); font-weight: 500; }
.price-row { display: flex; align-items: baseline; gap: 8px; margin-top: auto; padding-top: 8px; }
.price { font-family: var(--display); font-size: 1.3rem; color: var(--moon); }
.mrp { font-size: 0.82rem; color: var(--muted); text-decoration: line-through; }
.save { font-size: 0.78rem; font-weight: 700; color: #7fdc84; }
.buy {
  margin-top: 10px;
  padding: 8px 0;
  border-radius: 999px;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #3a0d10;
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
}

.empty-note {
  margin-top: 20px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px dashed #e9b44c66;
  color: var(--muted);
}

/* ---------- Footer ---------- */
.foot {
  padding: 22px 24px 32px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  border-top: 1px solid transparent;
  border-image: repeating-linear-gradient(90deg, var(--gold) 0 10px, transparent 10px 16px, var(--sindoor) 16px 22px, transparent 22px 28px) 1;
}
.foot p { margin: 0; }
.heart { color: var(--sindoor); }

/* ---------- Camera ---------- */
.camera {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: #0b0310f2;
  backdrop-filter: blur(6px);
}
.camera-frame { position: relative; flex: 1; display: grid; place-items: center; min-height: 0; padding: 16px; }
.camera video {
  max-width: 100%;
  max-height: 100%;
  border-radius: 20px;
  border: 3px solid var(--gold);
  box-shadow: 0 0 0 8px #e9b44c22, 0 0 60px #fff3d122;
}
.camera video.mirrored { transform: scaleX(-1); }
.camera-msg { position: absolute; max-width: 26em; padding: 0 24px; text-align: center; color: var(--cream); }
.camera-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 48px;
  padding: 18px 16px calc(24px + env(safe-area-inset-bottom));
}
.icon-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1.5px solid #e9b44c80;
  background: #ffffff0d;
  color: var(--gold-2);
  font-size: 1.2rem;
  cursor: pointer;
}
.icon-btn.invisible { visibility: hidden; }
.shutter {
  width: 76px;
  height: 76px;
  padding: 6px;
  border-radius: 50%;
  border: 3px solid var(--gold-2);
  background: transparent;
  cursor: pointer;
}
.shutter span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #fffaf0, var(--moon) 50%, #e9c98a);
  box-shadow: 0 0 24px #fff3d188;
  transition: transform 0.12s;
}
.shutter:active span { transform: scale(0.88); }
.shutter[disabled] { opacity: 0.4; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .result { grid-template-columns: minmax(0, 1fr); }
  .stage-col { position: static; }
}
@media (max-width: 720px) {
  body { font-size: 16px; }
  main { padding: 0 16px 32px; }
  .hero { grid-template-columns: 1fr; gap: 8px; padding-top: 8px; }
  .hero-art { order: -1; }
  .chalni-art { width: min(240px, 70vw); }
  .actions .btn { flex: 1 1 auto; justify-content: center; }
  .cards { grid-auto-columns: 170px; }
  .toran { height: 60px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
