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

:root {
  --bg: #07070b;
  --ink: #f4f2ec;
  --muted: rgba(244, 242, 236, 0.58);
  --faint: rgba(244, 242, 236, 0.38);
  --line: rgba(244, 242, 236, 0.16);
  --pill: rgba(255, 255, 255, 0.07);
  --serif: "Instrument Serif", "Times New Roman", serif;
  --sans: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.hidden { display: none !important; }

/* ── Landing ── */
#landing {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 32px 24px calc(32px + env(safe-area-inset-bottom));
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 42%, #12121c 0%, var(--bg) 70%);
}

.landing-glow {
  position: absolute;
  inset: auto;
  width: min(80vw, 640px);
  height: min(80vw, 640px);
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(80, 130, 200, 0.16) 0%, rgba(180, 110, 40, 0.06) 42%, transparent 70%);
  filter: blur(12px);
  pointer-events: none;
  z-index: 0;
}

.demo-badge {
  position: absolute;
  top: calc(20px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--faint);
  border: 1px solid var(--line);
  border-radius: 100px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.03);
}

.landing-inner {
  position: relative;
  z-index: 1;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  max-width: 420px;
}

.tagline {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--muted);
}

.landing-inner h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(40px, 9vw, 64px);
  letter-spacing: -0.03em;
  line-height: 0.95;
  color: var(--ink);
}

.lede {
  font-size: 15px;
  line-height: 1.5;
  color: var(--muted);
  max-width: 28em;
}

#landing-swatches {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
}

.landing-swatch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 7px;
  border: 1px solid var(--line);
  border-radius: 100px;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--muted);
  background: var(--pill);
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
  display: inline-block;
  flex-shrink: 0;
}

.btn-primary,
#btn-start,
#btn-enable-camera,
#btn-retry,
#btn-cart {
  appearance: none;
  font-family: inherit;
  cursor: pointer;
}

#btn-start,
#btn-enable-camera,
#btn-retry {
  margin-top: 10px;
  padding: 15px 36px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.94);
  color: #0b0b0f;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  transition: transform 0.2s ease, background 0.2s ease, opacity 0.2s ease;
}

#btn-start:hover,
#btn-enable-camera:hover,
#btn-retry:hover { background: #fff; transform: translateY(-1px); }

#btn-start:disabled { opacity: 0.45; cursor: wait; transform: none; }

#btn-start:focus-visible,
#btn-enable-camera:focus-visible,
#btn-retry:focus-visible,
#btn-cart:focus-visible,
.lens-btn:focus-visible,
.btn-text:focus-visible,
#btn-close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.privacy-note {
  font-size: 12px;
  line-height: 1.45;
  color: var(--faint);
  max-width: 26em;
}

/* ── Gate: permission, loading, errors ── */
#gate {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px calc(32px + env(safe-area-inset-bottom));
  background:
    radial-gradient(ellipse at 50% 40%, #141422 0%, var(--bg) 72%);
}

.gate-panel {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 360px;
}

.gate-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--pill);
  display: grid;
  place-items: center;
  margin-bottom: 4px;
}

.gate-icon svg { width: 24px; height: 24px; stroke: var(--ink); fill: none; stroke-width: 1.6; }

.gate-icon.is-error { border-color: rgba(232, 176, 120, 0.35); }

.gate-panel h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(28px, 7vw, 36px);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.gate-panel p {
  font-size: 15px;
  line-height: 1.5;
  color: var(--muted);
}

.btn-text {
  appearance: none;
  background: none;
  border: 0;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 8px 12px;
}

.btn-text:hover { color: var(--ink); }

.spinner {
  width: 36px;
  height: 36px;
  border: 1.5px solid rgba(255, 255, 255, 0.14);
  border-top-color: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 6px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── AR view ── */
#ar-view {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

#ar-view.is-on {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

#canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

#btn-close {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top));
  left: 16px;
  z-index: 3;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(10px);
  display: grid;
  place-items: center;
}

#btn-close svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; }

#demo-chip {
  position: absolute;
  top: calc(22px + env(safe-area-inset-top));
  left: 64px;
  z-index: 3;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  pointer-events: none;
}

#lens-label {
  position: absolute;
  top: calc(22px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.78);
  pointer-events: none;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.45);
}

#tracking-hint {
  position: absolute;
  top: 44%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  font-size: 14px;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.72);
  text-align: center;
  pointer-events: none;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.55);
  transition: opacity 0.35s ease;
}

#tracking-hint.is-off { opacity: 0; }

#ui {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 3;
  padding: 28px 20px calc(28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.28) 55%, transparent 100%);
}

#lens-switcher {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}

.lens-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 8px 8px;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.78);
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0.01em;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.lens-btn:hover { background: rgba(255, 255, 255, 0.14); }

.lens-btn.active {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.8);
  color: #fff;
  transform: translateY(-1px);
}

.lens-btn .swatch { width: 16px; height: 16px; }

#btn-cart {
  width: 100%;
  max-width: 360px;
  padding: 16px;
  border-radius: 100px;
  border: none;
  background: #fff;
  color: #0b0b0f;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#btn-cart:hover { opacity: 0.9; }
#btn-cart:disabled { opacity: 0.45; cursor: not-allowed; }

#toast {
  position: absolute;
  left: 50%;
  bottom: calc(168px + env(safe-area-inset-bottom));
  transform: translate(-50%, 8px);
  z-index: 5;
  max-width: min(360px, calc(100% - 40px));
  background: rgba(12, 12, 16, 0.92);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 14px 18px;
  font-size: 14px;
  line-height: 1.4;
  text-align: center;
  color: var(--ink);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  white-space: normal;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 420px) {
  #demo-chip { display: none; }
}

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