/* LivePix viewer. Plain CSS, no external fonts or images. */
:root {
  color-scheme: light dark;
  --bg: #fbf7f2;
  --fg: #2b2522;
  --muted: #6b605a;
  --card: #ffffff;
  --line: #d9cfc6;
  --btn-bg: #2b2522;
  --btn-fg: #ffffff;
  --btn2-bg: transparent;
  --btn2-fg: #2b2522;
  --focus: #1a5fb4;
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 100%;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171412;
    --fg: #f4eee8;
    --muted: #b9aea6;
    --card: #221e1b;
    --line: #4a413b;
    --btn-bg: #f4eee8;
    --btn-fg: #171412;
    --btn2-fg: #f4eee8;
    --focus: #8cb8ff;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--fg); }
body { min-height: 100vh; display: flex; flex-direction: column; align-items: center; }
main {
  width: 100%; max-width: 640px; flex: 1;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
h1 { font-size: 1.25rem; margin: 4px 0 0; text-align: center; font-weight: 600; }
p { margin: 0; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

/* Photo / video stage: always the photo's aspect ratio (set via --ar). */
.stage {
  position: relative;
  width: min(100%, calc(72vh * var(--ar, 0.75)));
  width: min(100%, calc(72svh * var(--ar, 0.75)));
  aspect-ratio: var(--ar, 0.75);
  background: #000;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
}
/* Fallback for browsers without aspect-ratio (pre-2021): padding box, full width. */
@supports not (aspect-ratio: 1) {
  .stage { width: 100%; height: 0; padding-top: var(--pt, 133.333%); }
}

.stage video, .stage img.poster {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; background: #000; display: block;
}
.stage img.poster[hidden] { display: none; }
/* Wide (landscape) photos are short on a phone and are often group shots: put the
   Play button and loading pill centred just BELOW the photo instead of over people. */
.stage.wide { overflow: visible; margin-bottom: 88px; box-shadow: none; }
.stage.wide video, .stage.wide img.poster { border-radius: 6px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18); }
.stage.wide .play, .stage.wide .loading { bottom: -86px; }
.stage.wide .play { background: var(--btn-bg); color: var(--btn-fg); border-color: var(--btn-bg); }
.stage.wide .play:focus-visible { outline-color: var(--focus); }
/* Play: lower third of the photo, clear of faces (which are usually in the upper half). */
.play {
  position: absolute; left: 50%; bottom: 9%; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 12px;
  min-height: 76px; min-width: 180px; justify-content: center; padding: 0 32px 0 24px;
  font: inherit; font-size: 1.4rem; font-weight: 750; white-space: nowrap;
  color: #fff; background: rgba(20, 16, 14, 0.72);
  border: 3px solid #fff; border-radius: 999px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}
.play svg { width: 34px; height: 34px; flex: none; }
.play:active { transform: translateX(-50%) scale(0.97); }
.play:focus-visible { outline: 4px solid #fff; outline-offset: 4px; }
/* Loading: spinner + words (never colour alone), lower third like the Play button. */
.loading {
  position: absolute; left: 50%; bottom: 9%; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 12px; max-width: 92%;
  min-height: 56px; padding: 10px 22px; border-radius: 999px;
  background: rgba(20, 16, 14, 0.78); color: #fff; font-size: 1.05rem; font-weight: 650; white-space: nowrap;
  pointer-events: none;
}
.loading[hidden] { display: none; }
.spinner {
  width: 26px; height: 26px; flex: none; border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.35); border-top-color: #fff;
  animation: lp-spin 0.9s linear infinite;
}
@keyframes lp-spin { to { transform: rotate(360deg); } }
.play[hidden] { display: none; }

.status {
  min-height: 1.4em; text-align: center; color: var(--muted); font-size: 0.95rem; max-width: 34em;
}
.status.warn { color: var(--fg); font-weight: 600; }
.status.warn::before { content: "\26A0\FE0E  "; } /* warning sign, text glyph: not colour-dependent */

.actions { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 56px; padding: 12px 20px;
  font: inherit; font-size: 1.1rem; font-weight: 650; text-decoration: none; text-align: center;
  border-radius: var(--radius); cursor: pointer; -webkit-tap-highlight-color: transparent;
  border: 2px solid var(--btn-bg); background: var(--btn-bg); color: var(--btn-fg);
}
.btn.secondary { background: var(--btn2-bg); color: var(--btn2-fg); border-color: var(--fg); }
.btn svg { width: 24px; height: 24px; flex: none; }
.btn[hidden] { display: none; }
.hint { font-size: 0.9rem; color: var(--muted); text-align: center; }
.small-link { display: flex; align-items: center; justify-content: center; min-height: 48px; font-size: 0.95rem; text-align: center; padding: 6px 8px; }

footer {
  width: 100%; text-align: center; padding: 18px 16px max(18px, env(safe-area-inset-bottom));
  color: var(--muted); font-size: 0.85rem;
}
footer .code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: 0.12em; }
footer .brand { font-weight: 700; letter-spacing: 0.02em; color: var(--fg); }

/* Home / 404 */
.hero { text-align: center; padding-top: 6vh; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.hero .logo { font-size: 2.2rem; font-weight: 800; letter-spacing: -0.01em; }
.hero p { font-size: 1.1rem; max-width: 26em; }
form.code-form { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 12px; }
form.code-form label { font-weight: 600; text-align: center; }
form.code-form input {
  font: inherit; font-size: 1.6rem; letter-spacing: 0.2em; text-align: center; text-transform: uppercase;
  min-height: 60px; padding: 8px 12px; border-radius: var(--radius);
  border: 2px solid var(--fg); background: var(--card); color: var(--fg);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* AR overlay */
.ar-overlay { position: fixed; inset: 0; z-index: 1000; background: #000; color: #fff; }
.ar-stage { position: absolute; inset: 0; overflow: hidden; z-index: 0; }
.ar-ui { position: absolute; inset: 0; z-index: 2; pointer-events: none; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: max(16px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom)); }
.ar-ui > * { pointer-events: auto; }
.ar-msg { background: rgba(0, 0, 0, 0.66); padding: 12px 18px; border-radius: 12px; font-size: 1.05rem; text-align: center; max-width: 30em; }
.ar-frame { pointer-events: none !important; width: min(70vw, 50vh * var(--ar, 0.75)); aspect-ratio: var(--ar, 0.75); border: 3px dashed rgba(255, 255, 255, 0.85); border-radius: 8px; }
.ar-frame[hidden] { display: none; }
.ar-close { margin-top: auto; background: #fff; color: #111; border-color: #fff; min-width: 220px; }
.ar-tap { position: absolute; inset: 0; z-index: 3; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.35); border: 0; color: #fff; font: inherit; font-size: 1.3rem; font-weight: 700; }
.ar-tap[hidden] { display: none; }
body.ar-open { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .spinner { border-style: dotted; } /* still visibly "busy" without motion; the text says so too */
}

/* Phones in landscape: give the video the available height. */
@media (orientation: landscape) and (max-height: 540px) {
  main { padding-top: 6px; gap: 10px; }
  h1 { display: none; }
  .stage { width: min(100%, calc((100vh - 12px) * var(--ar, 0.75))); width: min(100%, calc((100svh - 12px) * var(--ar, 0.75))); border-radius: 0; }
  /* The photo fills the screen height here, so the button goes back over its lower edge. */
  .stage.wide { margin-bottom: 0; }
  .stage.wide .play, .stage.wide .loading { bottom: 6%; }
  .stage.wide .play { background: rgba(20, 16, 14, 0.72); color: #fff; border-color: #fff; }
}