:root {
  --void: #070916;
  --night: #0c1230;
  --mist: #e8ecf8;
  --pearl: #c7d3ed;
  --text-main: #f8f6f2;
  --text-muted: #aeb9d4;
  --gold: #d7ac62;
  --gold-light: #ffe1a6;
  --moon: #b7cbff;
  --error: #ffb3bc;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --radius-card: 1.25rem;
  --radius-pill: 62.5rem;
  --motion-enter: 520ms;
  --motion-float: 2400ms;
  --ease-ritual: cubic-bezier(0.22, 0.8, 0.2, 1);
  --ease-arrive: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }

html,
body,
.ar-page,
a-scene { width: 100%; min-height: 100%; margin: 0; overflow: hidden; }

body {
  background: var(--void);
  color: var(--text-main);
  font-family: "Noto Sans SC", "DM Sans", system-ui, sans-serif;
}

.ar-page {
  position: fixed;
  inset: 0;
  min-height: 100svh;
  isolation: isolate;
}

/* MindAR appends the camera video next to the scene. Keep an explicit
   three-layer stack: camera → WebGL → HTML controls. Safari can otherwise
   composite the video over A-Frame's canvas. */
.ar-page > video {
  position: fixed !important;
  inset: 0;
  z-index: 0 !important;
}

a-scene,
a-scene canvas {
  position: fixed !important;
  inset: 0;
  z-index: 1 !important;
  display: block;
  background: transparent !important;
}

.ar-intro,
.ar-overlay { position: fixed; inset: 0; z-index: 2; pointer-events: none; }

.ar-intro {
  display: grid;
  align-content: end;
  gap: var(--space-5);
  padding: max(2rem, env(safe-area-inset-top)) max(1.5rem, env(safe-area-inset-right)) max(2rem, env(safe-area-inset-bottom)) max(1.5rem, env(safe-area-inset-left));
  background:
    radial-gradient(circle at 50% 20%, color-mix(in srgb, var(--moon) 24%, transparent), transparent 38%),
    linear-gradient(180deg, color-mix(in srgb, var(--void) 12%, transparent), var(--void) 84%);
  transition: opacity var(--motion-enter) var(--ease-ritual), visibility var(--motion-enter) var(--ease-ritual);
}

.ar-intro::before {
  content: "";
  position: absolute;
  inset: 8% 7% 18%;
  border: 1px solid color-mix(in srgb, var(--pearl) 24%, transparent);
  border-radius: var(--radius-card);
  pointer-events: none;
}

.ar-intro > * { position: relative; max-width: 34rem; }

.eyebrow,
.reading-label,
.camera-note,
.brand-lockup,
.status-capsule { letter-spacing: 0.12em; text-transform: uppercase; }

.eyebrow { margin: 0; color: var(--gold); font-size: 0.75rem; font-weight: 700; }
.eyebrow span { margin-right: var(--space-2); }

h1,
h2 { font-family: "Cormorant Garamond", "Noto Serif SC", serif; font-weight: 600; }
h1 { margin: 0; font-size: clamp(3.5rem, 16vw, 6.5rem); line-height: 0.86; }
h1 em { color: var(--gold-light); font-style: italic; }

.ar-copy { margin: 0; color: var(--text-muted); font-size: 1rem; line-height: 1.7; }

.launch-button,
.reset-button { border: 0; font: inherit; cursor: pointer; pointer-events: auto; }

.launch-button {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
  min-height: 3.25rem;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-pill);
  background: linear-gradient(120deg, var(--gold), var(--gold-light));
  color: var(--void);
  font-weight: 700;
  box-shadow: 0 0.75rem 2rem color-mix(in srgb, var(--gold) 24%, transparent);
  transition: transform 180ms var(--ease-arrive), filter 180ms ease;
}

.launch-button:active { transform: scale(0.97); filter: brightness(0.94); }
.launch-button:focus-visible,
.reset-button:focus-visible { outline: 2px solid var(--moon); outline-offset: 3px; }

.camera-note { margin: 0; color: var(--text-muted); font-size: 0.6875rem; line-height: 1.5; }

.ar-intro.is-hidden { opacity: 0; visibility: hidden; }

.ar-overlay { display: flex; flex-direction: column; justify-content: space-between; padding: max(1.25rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1.25rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left)); }
.brand-lockup { align-self: center; color: var(--mist); font-family: "DM Sans", sans-serif; font-size: 0.75rem; font-weight: 700; text-shadow: 0 0 1.5rem var(--void); }
.brand-lockup:first-letter { color: var(--gold); }

.status-capsule {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 2.5rem;
  padding: var(--space-2) var(--space-4);
  border: 1px solid color-mix(in srgb, var(--pearl) 34%, transparent);
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--night) 68%, transparent);
  color: var(--mist);
  backdrop-filter: blur(0.75rem);
  font-size: 0.6875rem;
  font-weight: 700;
}

.status-star { color: var(--gold); }
.status-capsule[data-state="found"] { border-color: color-mix(in srgb, var(--gold) 64%, transparent); color: var(--gold-light); }
.status-capsule[data-state="error"] { border-color: var(--error); color: var(--error); }

.reading-card {
  align-self: center;
  width: min(100%, 28rem);
  padding: var(--space-5);
  border: 1px solid color-mix(in srgb, var(--pearl) 36%, transparent);
  border-radius: var(--radius-card);
  background: linear-gradient(135deg, color-mix(in srgb, var(--night) 86%, transparent), color-mix(in srgb, var(--void) 74%, transparent));
  backdrop-filter: blur(1rem);
  box-shadow: 0 1.25rem 3rem color-mix(in srgb, var(--void) 48%, transparent);
  pointer-events: auto;
  transform-origin: bottom center;
  animation: reading-arrive var(--motion-enter) var(--ease-arrive) both;
}
.reading-label { margin: 0 0 var(--space-3); color: var(--gold); font-size: 0.6875rem; font-weight: 700; }
.reading-card h2 { margin: 0; font-size: 2rem; line-height: 1; }
.reading-card p:last-child { margin: var(--space-3) 0 0; color: var(--pearl); font-size: 0.875rem; line-height: 1.65; }

.reset-button { align-self: center; margin-top: var(--space-4); padding: var(--space-2) var(--space-4); background: transparent; color: var(--mist); text-decoration: underline; text-underline-offset: 0.25rem; pointer-events: auto; }

@keyframes reading-arrive { from { opacity: 0; transform: translateY(1rem) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
}
