/* Gini Raksha mask try-on page */
:root {
  --ink: #113d48;
  --ink-deep: #0c2c34;
  --night: #071b20;
  --blue: #1d75bb;
  --fire: #ffc21f;
  --fire-deep: #ff8a1a;
  --red: #e8253f;
  --white: #fff;
  --soft: rgba(255, 255, 255, .78);
  --title: "Manrope", system-ui, sans-serif;
  --body: "Inter", system-ui, sans-serif;
  --script: "Montez", cursive;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--night); }
body { font: 16px/1.6 var(--body); color: var(--white); -webkit-font-smoothing: antialiased; overflow: hidden; }
svg { width: 1.2em; height: 1.2em; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
a { color: var(--fire); }
button { font: inherit; }

.stage {
  position: fixed; inset: 0; overflow: hidden;
  height: 100vh; height: 100dvh;
  background:
    radial-gradient(60% 45% at 50% 52%, rgba(255, 120, 40, .22), transparent 70%),
    radial-gradient(120% 90% at 50% 100%, var(--ink) 0%, var(--ink-deep) 45%, var(--night) 100%);
}
.stage[data-mode="camera"], .stage[data-mode="photo"] { background: #000; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
/* The live camera shows behind the canvas, mirrored like a selfie camera; the canvas on
   top draws only the mask, mirrored the same way (mask.js keeps the two lined up). */
#cam { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; visibility: hidden; }
.stage[data-mode="camera"] #cam { visibility: visible; transform: scaleX(-1); }
#view { z-index: 1; }
.intro, .live, .loading, .toast { z-index: 2; }

/* ---------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .55em;
  min-height: 52px; padding: .8em 1.6em; border-radius: 48px; border: 2px solid transparent;
  font: 700 1rem/1.2 var(--title); text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: transform .15s, background .2s, color .2s, border-color .2s;
}
.btn:active { transform: scale(.97); }
.btn.fire { background: var(--fire); color: #3a1206; box-shadow: 0 10px 30px rgba(255, 140, 30, .35); }
.btn.fire:hover { background: #ffd24f; }
.btn.ghost { background: rgba(255, 255, 255, .06); color: var(--white); border-color: rgba(255, 255, 255, .55); }
.btn.ghost:hover { background: var(--white); color: var(--ink-deep); }
.btn:focus-visible, .round:focus-visible, .shutter:focus-visible, .link:focus-visible { outline: 3px solid var(--fire); outline-offset: 3px; }
.link { background: none; border: 0; color: var(--soft); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 6px; font-size: .9rem; }
.link:hover { color: var(--white); }

/* ---------- start screen */
.intro {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  padding: calc(12px + var(--safe-t)) 20px calc(16px + var(--safe-b));
  pointer-events: none;
}
.intro > * { pointer-events: auto; }
.stage:not([data-mode="intro"]) .intro { display: none; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.logo img { width: 128px; height: auto; display: block; }
.back { color: var(--soft); font-size: .9rem; text-decoration: none; }
.back:hover { color: var(--white); }
.intro-text { text-align: center; margin-top: 14px; }
.kicker { font-family: var(--script); color: var(--fire); font-size: 1.9rem; line-height: 1; margin: 0 0 .1em; }
h1 { font: 800 clamp(1.75rem, 7vw, 3.4rem)/1.1 var(--title); margin: 0 0 .35em; letter-spacing: -.01em; }
.lead { color: var(--soft); margin: 0 auto; max-width: 30em; font-size: .98rem; }
.mask-spot { flex: 1; min-height: 200px; pointer-events: none; }
.intro-actions { text-align: center; }
.btn-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.btn-row .btn { flex: 1 1 0; max-width: 230px; }
.note { color: var(--soft); font-size: .82rem; margin: 12px 0 2px; }

@media (min-width: 860px) and (min-aspect-ratio: 5/4) {
  .intro {
    display: grid; grid-template-columns: minmax(340px, 1fr) 1.15fr;
    grid-template-rows: auto 1fr auto 1fr; column-gap: 32px;
    padding: 24px max(40px, 5vw) 32px;
  }
  .bar { grid-column: 1 / -1; }
  .intro-text { grid-column: 1; grid-row: 2; align-self: end; text-align: left; margin: 28px 0 0; }
  .lead { margin: 0; font-size: 1.1rem; }
  .intro-actions { grid-column: 1; grid-row: 3; text-align: left; margin-top: 28px; }
  .btn-row { justify-content: flex-start; }
  .mask-spot { grid-column: 2; grid-row: 2 / 5; }
  .logo img { width: 160px; }
  .kicker { font-size: 2.4rem; }
}
@media (max-height: 640px) and (max-width: 859px) {
  .kicker { display: none; }
  .lead { font-size: .9rem; }
  .note { display: none; }
}

/* ---------- camera / photo view */
.live { position: absolute; inset: 0; pointer-events: none; }
.live > * { pointer-events: auto; }
.round {
  width: 52px; height: 52px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer;
  background: rgba(7, 27, 32, .55); color: var(--white); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.round svg { width: 24px; height: 24px; }
.close { position: absolute; top: calc(14px + var(--safe-t)); left: 14px; }
.hint {
  position: absolute; top: calc(22px + var(--safe-t)); left: 50%; transform: translateX(-50%);
  margin: 0; padding: 8px 16px; border-radius: 30px; max-width: calc(100% - 150px);
  background: rgba(7, 27, 32, .6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  font: 600 .9rem/1.3 var(--title); text-align: center; transition: opacity .3s;
}
.hint:empty { opacity: 0; }
.controls {
  position: absolute; left: 0; right: 0; bottom: calc(22px + var(--safe-b));
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; justify-items: center; padding: 0 24px;
}
.shutter {
  width: 78px; height: 78px; border-radius: 50%; border: 4px solid var(--white); background: transparent;
  padding: 5px; cursor: pointer;
}
.shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: var(--white); transition: transform .12s; }
.shutter:active span { transform: scale(.88); }
.fire-btn[aria-pressed="true"] { background: var(--fire); color: #3a1206; box-shadow: 0 0 24px rgba(255, 150, 30, .7); }
.flash { position: absolute; inset: 0; background: #fff; opacity: .85; pointer-events: none; animation: flash .35s ease-out forwards; }
@keyframes flash { to { opacity: 0; } }

/* ---------- loading and messages */
.loading {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px;
  background: rgba(7, 27, 32, .72); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  font: 600 1rem var(--title); text-align: center; padding: 20px;
}
.loading[hidden] { display: none; }
.loading p { margin: 0; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, .2); border-top-color: var(--fire); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast {
  position: absolute; left: 50%; bottom: calc(120px + var(--safe-b)); transform: translateX(-50%);
  width: min(440px, calc(100% - 32px)); padding: 14px 18px; border-radius: 14px;
  background: var(--white); color: var(--ink-deep); font-size: .95rem; line-height: 1.45;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .35); z-index: 5;
}
.toast[hidden] { display: none; }
.noscript { position: absolute; inset: auto 20px 40px; text-align: center; }

/* ---------- sheets */
.sheet {
  width: min(480px, calc(100% - 24px)); max-height: calc(100% - 24px); overflow: auto;
  border: 0; border-radius: 22px; padding: 22px; background: var(--ink-deep); color: var(--white);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
}
.sheet::backdrop { background: rgba(4, 14, 17, .7); }
.sheet h2 { font: 800 1.4rem/1.2 var(--title); margin: 0 0 14px; }
.sheet p { color: var(--soft); margin: 0 0 12px; }
.sheet img { width: 100%; height: auto; max-height: 58vh; object-fit: contain; border-radius: 14px; display: block; background: #000; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 6px; }
.sheet-actions .btn { flex: 1 1 140px; min-height: 48px; padding: .7em 1.2em; }
.sheet .note { text-align: center; margin-top: 8px; }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
  .flash { animation: none; opacity: 0; }
}
