/* Magic Carpet HUD — twilight-and-gold glass over live camera.
   The AR carpet is the hero; the overlay stays quiet and premium.
   Identity pulled from the asset: gold tassels (#F5C56B), night-sky violet. */
:root {
  --ink: 11, 10, 31;            /* deep night, for scrims (rgb triplet) */
  --gold: #f5c56b;
  --gold-hi: #ffe4a8;
  --violet: #7b5cff;
  --ember: #ff4d5e;
  --glass: rgba(var(--ink), .46);
  --stroke: rgba(255, 255, 255, .14);
  --shadow: 0 8px 30px rgba(0, 0, 0, .35);
  --r: 18px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; } /* load-bearing (rosaGres lesson) */
html, body { height: 100%; background: #06060f; overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif; color: #fff;
  -webkit-font-smoothing: antialiased; }

#stage { position: fixed; inset: 0; }
#cam { position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; transform: scaleX(-1); }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; }

/* Vignette + top/bottom scrims: focuses the eye and keeps controls legible
   over any camera feed without a heavy chrome bar. */
#stage::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  z-index: 1;
  background:
    linear-gradient(rgba(var(--ink), .38), transparent 22%, transparent 74%, rgba(var(--ink), .5)),
    radial-gradient(130% 100% at 50% 50%, transparent 58%, rgba(var(--ink), .45)); }

#hud { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
#hud button, #hud .chip { pointer-events: auto; }

/* ---- Gesture legend (top-left): the spell book ---- */
#legend { position: absolute; top: max(14px, env(safe-area-inset-top)); left: 14px;
  display: flex; flex-direction: column; gap: 9px; }
.chip { display: flex; align-items: center; gap: 9px;
  background: var(--glass); backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border-radius: 999px; padding: 7px 15px 7px 8px;
  font-size: 13px; font-weight: 600; letter-spacing: .01em;
  border: 1px solid var(--stroke); box-shadow: var(--shadow);
  transition: transform .18s cubic-bezier(.2,.9,.3,1.4), border-color .18s, box-shadow .18s; }
.chip span { display: grid; place-items: center; width: 28px; height: 28px;
  border-radius: 50%; background: rgba(255, 255, 255, .08); font-size: 15px; }
/* Signature moment: performing a gesture lights its chip like casting a spell. */
.chip.active { transform: scale(1.14); border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold), 0 0 22px rgba(245, 197, 107, .65), var(--shadow); }
.chip.active span { background: rgba(245, 197, 107, .22); }

/* ---- Controls (top-right): quiet glass groups ---- */
#controls { position: absolute; right: 14px; top: max(14px, env(safe-area-inset-top));
  display: flex; flex-direction: column; gap: 9px; align-items: flex-end; }
.group { display: flex; gap: 3px; background: var(--glass);
  backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border-radius: 999px; padding: 4px; border: 1px solid var(--stroke); box-shadow: var(--shadow); }
.group button { min-height: 36px; min-width: 40px; background: transparent; color: #fff;
  border: 0; border-radius: 999px; padding: 6px 13px; font-size: 13px; font-weight: 600;
  font-variant-numeric: tabular-nums; cursor: pointer;
  transition: background .16s, color .16s; }
.group button:hover { background: rgba(255, 255, 255, .08); }
.group button.on { background: linear-gradient(180deg, var(--gold-hi), var(--gold));
  color: #2a1c00; box-shadow: 0 2px 10px rgba(245, 197, 107, .4); }

/* ---- Record (bottom-center): the lamp ---- */
#recWrap { position: absolute; bottom: max(26px, env(safe-area-inset-bottom));
  left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 12px; }
#recBtn { position: relative; width: 76px; height: 76px; border-radius: 50%; cursor: pointer;
  border: 3px solid rgba(255, 255, 255, .92); background: transparent;
  transition: transform .2s; }
#recBtn::after { content: ""; position: absolute; inset: 7px; border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #ff8a72, var(--ember) 68%);
  box-shadow: 0 0 18px rgba(255, 77, 94, .55); transition: border-radius .25s, inset .2s; }
#recBtn:hover { transform: scale(1.05); }
#recBtn.rec::after { inset: 22px; border-radius: 6px; }
#recBtn.rec { animation: lamp 1.3s ease-in-out infinite; }
@keyframes lamp {
  50% { box-shadow: 0 0 0 12px rgba(245, 197, 107, .12), 0 0 34px rgba(123, 92, 255, .4); } }
#recClock { font-variant-numeric: tabular-nums; font-weight: 700; letter-spacing: .04em;
  background: rgba(var(--ink), .6); backdrop-filter: blur(10px);
  padding: 4px 12px; border-radius: 999px; font-size: 13px;
  border: 1px solid var(--stroke); }
#recClock::before { content: "●"; color: var(--ember); margin-right: 6px; font-size: 10px;
  vertical-align: middle; animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: .25; } }

#toast { position: absolute; bottom: 132px; left: 50%; transform: translateX(-50%);
  background: rgba(var(--ink), .82); backdrop-filter: blur(10px);
  padding: 9px 18px; border-radius: 999px; font-size: 13px; font-weight: 500;
  border: 1px solid var(--stroke); box-shadow: var(--shadow); white-space: nowrap; }

/* ---- Gate (loading / errors): the threshold ---- */
#gate { position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 22px; z-index: 10;
  background: radial-gradient(ellipse at 50% 38%, #241a4d, #0a0817 70%); text-align: center; }
#gate::before { content: "🪄"; font-size: 46px; filter: drop-shadow(0 0 20px rgba(123, 92, 255, .6));
  animation: float 3.4s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-10px) rotate(-4deg); } }
#gateMsg { font-size: 16px; font-weight: 500; padding: 0 34px; line-height: 1.55;
  max-width: 340px; letter-spacing: .01em; color: rgba(255, 255, 255, .9); }

/* ---- Preview (after recording): the reveal ---- */
#preview { position: absolute; inset: 0; z-index: 20;
  background: radial-gradient(ellipse at 50% 40%, rgba(36, 26, 77, .96), rgba(6, 6, 15, .97));
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom); }
#playback { max-width: 92%; max-height: 66%; border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .08); }
#previewBtns { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
#previewBtns button, #previewBtns a { min-height: 46px; display: inline-flex; align-items: center;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold)); color: #2a1c00; border: 0;
  border-radius: 999px; padding: 0 24px; font-size: 15px; font-weight: 700;
  text-decoration: none; cursor: pointer; box-shadow: 0 6px 20px rgba(245, 197, 107, .35);
  transition: transform .15s; }
#previewBtns button:hover, #previewBtns a:hover { transform: translateY(-2px); }
#previewBtns #closePreview { background: rgba(255, 255, 255, .1); color: #fff;
  box-shadow: none; backdrop-filter: blur(8px); }

/* ---- Escape (in-app browser: the camera is blocked in here) ---- */
#escape { position: absolute; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  padding: env(safe-area-inset-top) 22px env(safe-area-inset-bottom);
  background: radial-gradient(ellipse at 50% 38%, #241a4d, #0a0817 72%); }
.escCard { width: 100%; max-width: 340px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 15px; }
.escCard::before { content: "🪄"; font-size: 44px;
  filter: drop-shadow(0 0 20px rgba(123, 92, 255, .6));
  animation: float 3.4s ease-in-out infinite; }
#escTitle { font-size: 21px; font-weight: 800; letter-spacing: .01em; }
#escBody { font-size: 15px; line-height: 1.55; color: rgba(255, 255, 255, .82); }
#escBtn { min-height: 50px; padding: 0 28px; border: 0; border-radius: 999px; cursor: pointer;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold)); color: #2a1c00;
  font-size: 16px; font-weight: 800; box-shadow: 0 6px 22px rgba(245, 197, 107, .4); }
#escSteps { text-align: left; padding-left: 22px; margin: 2px 0; font-size: 14px;
  line-height: 1.6; color: rgba(255, 255, 255, .9); }
#escSteps li { margin: 5px 0; }
#escSteps b { color: var(--gold-hi); }
#escCopy { min-height: 42px; padding: 0 20px; border-radius: 999px; cursor: pointer;
  background: rgba(255, 255, 255, .1); color: #fff; border: 1px solid var(--stroke);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font-size: 14px; font-weight: 600; }
#escCopied { font-size: 13px; color: var(--gold-hi); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  #recBtn.rec, #gate::before, #recClock::before, .escCard::before { animation: none; }
  .chip { transition: none; }
}
