/* =========================================================
   Brandsplus AR – UI
   Industrieller Look: Tinte, Papier, roter Stempel, Plus-Raster.
   Eigene CI-Schrift? -> woff2 nach app/fonts/ legen und unten
   bei @font-face eintragen (lokal hosten, kein Google-CDN).
   ========================================================= */

/*
@font-face {
  font-family: "BrandDisplay";
  src: url("fonts/BrandDisplay-Bold.woff2") format("woff2");
  font-weight: 800;
  font-display: swap;
}
*/

:root {
  --ink: #0e0e0e;
  --ink-2: #181818;
  --ink-3: #232323;
  --paper: #f3f0ea;
  --muted: #9c978f;
  --line: rgba(243, 240, 234, 0.14);
  --accent: #e3261c;
  --accent-ink: #ffffff;
  --ok: #3dbe6b;
  --warn: #f0a020;
  --bad: #e3261c;
  --font: "Inter", "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  --font-display: "BrandDisplay", "Barlow Condensed", "Oswald", "Arial Narrow",
    "Helvetica Neue", Arial, sans-serif;
  --radius: 3px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --plus-grid: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28'%3E%3Cpath d='M14 10v8M10 14h8' stroke='%23F3F0EA' stroke-opacity='.07' stroke-width='1.5'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--ink) var(--plus-grid);
  color: var(--paper);
  font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
a { color: inherit; }
button { font: inherit; color: inherit; }

/* ---------- Bausteine ---------- */

.rubric {
  display: inline-flex; align-items: center; gap: 10px;
  margin: 0 0 14px;
  font: 700 12px/1 var(--font);
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted);
}
.rubric::before {
  content: ""; width: 10px; height: 10px; background: var(--accent); flex: none;
}

.display {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-stretch: condensed;
  text-transform: uppercase;
  line-height: 0.92;
  letter-spacing: -0.01em;
  font-size: clamp(40px, 12.5vw, 76px);
  text-wrap: balance;
}

.stamp {
  display: inline-block;
  padding: 6px 10px 5px;
  border: 3px solid var(--accent);
  color: var(--accent);
  font: 800 13px/1 var(--font);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transform: rotate(-8deg);
  background: rgba(14, 14, 14, 0.55);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 56px; padding: 0 22px;
  border: 0; border-radius: var(--radius);
  font: 800 15px/1 var(--font);
  letter-spacing: 0.08em; text-transform: uppercase;
  text-decoration: none; cursor: pointer;
  transition: transform 0.12s ease, opacity 0.2s ease, background 0.2s ease;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: transparent; color: var(--paper); box-shadow: inset 0 0 0 1px var(--line); }
.btn-block { width: 100%; }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: 12px; }

.icon-btn {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: rgba(14, 14, 14, 0.55);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  color: var(--paper); cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--line);
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.is-pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: inset 0 0 0 1px var(--line), 0 0 0 0 rgba(227, 38, 28, 0.6); }
  50% { box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 10px rgba(227, 38, 28, 0); }
}

/* ---------- AR-Bühne ---------- */

.ar-stage {
  position: fixed; inset: 0; overflow: hidden;
  background: #000; z-index: 0;
}
.ar-stage video, .ar-stage canvas { touch-action: none; }

/* Video-Fenster (wenn das Motiv aus dem Bild ist) */
.ar-pip {
  position: fixed; left: 0; top: 0; width: 2px; height: 2px;
  overflow: hidden; opacity: 0; pointer-events: none; z-index: 15;
}
.ar-pip-slot { position: relative; }
.ar-pip-slot video {
  position: absolute; left: 0; top: 0; width: 100%; height: 100%;
  object-fit: contain; opacity: 0; background: #000;
}
.ar-pip-close { display: none; }
.ar-pip.is-open {
  left: 16px; right: 16px; top: auto; width: auto; height: auto;
  bottom: calc(var(--safe-b) + 96px);
  max-width: 480px; margin: 0 auto;
  opacity: 1; pointer-events: auto;
  border: 2px solid var(--paper);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  animation: pip-in 0.28s ease-out;
}
.ar-pip.is-open .ar-pip-slot video.is-active {
  position: relative; display: block; height: auto; max-height: 55vh; opacity: 1;
}
.ar-pip.is-open .ar-pip-close {
  display: grid; place-items: center;
  position: absolute; top: 8px; right: 8px;
  width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: rgba(14, 14, 14, 0.7); color: var(--paper); cursor: pointer;
}
.ar-pip-close svg { width: 16px; height: 16px; }
@keyframes pip-in { from { transform: translateY(16px); opacity: 0; } }

/* ---------- HUD über dem Kamerabild ---------- */

.hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-top {
  position: absolute; left: 0; right: 0; top: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(var(--safe-t) + 14px) 16px 28px;
  background: linear-gradient(rgba(0, 0, 0, 0.55), transparent);
}
.hud-title {
  flex: 1; min-width: 0; text-align: center;
  font: 800 12px/1.2 var(--font); letter-spacing: 0.16em; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.scan {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(72vw, 320px);
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  pointer-events: none; text-align: center;
  transition: opacity 0.25s ease;
}
.scan.is-hidden { opacity: 0; }
.scan-frame { position: relative; width: 100%; aspect-ratio: var(--scan-ar, 3 / 4); }
.scan-frame i {
  position: absolute; width: 34px; height: 34px;
  border: 0 solid var(--accent); animation: breathe 1.8s ease-in-out infinite;
}
.scan-frame i:nth-child(1) { left: 0; top: 0; border-left-width: 4px; border-top-width: 4px; }
.scan-frame i:nth-child(2) { right: 0; top: 0; border-right-width: 4px; border-top-width: 4px; }
.scan-frame i:nth-child(3) { left: 0; bottom: 0; border-left-width: 4px; border-bottom-width: 4px; }
.scan-frame i:nth-child(4) { right: 0; bottom: 0; border-right-width: 4px; border-bottom-width: 4px; }
@keyframes breathe { 50% { transform: scale(0.92); opacity: 0.7; } }
.scan p {
  margin: 0; padding: 8px 14px;
  background: rgba(14, 14, 14, 0.7); border-radius: var(--radius);
  font: 700 14px/1.3 var(--font);
}
.scan-thumbs { display: flex; gap: 8px; justify-content: center; }
.scan-thumbs img {
  width: 44px; height: 56px; object-fit: cover;
  border: 2px solid var(--paper); opacity: 0.9;
}
.cta {
  position: absolute; left: 16px; right: 16px;
  bottom: calc(var(--safe-b) + 20px);
  max-width: 480px; margin: 0 auto;
  animation: cta-in 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes cta-in { from { transform: translateY(30px); opacity: 0; } }

/* ---------- Viewer-Screens ---------- */

.screen {
  position: fixed; inset: 0; z-index: 20;
  display: flex; flex-direction: column;
  padding: calc(var(--safe-t) + 18px) 20px calc(var(--safe-b) + 20px);
  background: var(--ink) var(--plus-grid);
  overflow-y: auto;
}
.topbar { display: flex; align-items: center; justify-content: space-between; }
.brand-logo { height: 26px; width: auto; display: block; }
.tag {
  font: 800 11px/1 var(--font); letter-spacing: 0.16em; text-transform: uppercase;
  padding: 7px 9px; box-shadow: inset 0 0 0 1px var(--line); border-radius: var(--radius);
}
.intro-body {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  padding: 28px 0;
  width: 100%; max-width: 520px; margin: 0 auto;
}
.intro-body .lead { margin: 16px 0 0; color: var(--muted); max-width: 34ch; }
.target-strip {
  position: relative; display: flex; align-items: flex-end; gap: 12px;
  margin: 30px 0 6px; min-height: 120px;
}
.target-strip img {
  height: 132px; width: auto; max-width: 42%;
  object-fit: cover; border: 3px solid var(--paper);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}
.target-strip img:nth-child(odd) { transform: rotate(-3deg); }
.target-strip img:nth-child(even) { transform: rotate(2.5deg); }
.target-strip .stamp { position: absolute; left: min(40%, 150px); top: 8px; }
.steps {
  list-style: none; counter-reset: s; margin: 26px 0 0; padding: 0;
  display: grid; gap: 10px;
}
.steps li {
  counter-increment: s; display: flex; align-items: center; gap: 12px;
  font-weight: 600;
}
.steps li::before {
  content: counter(s, decimal-leading-zero);
  font: 800 12px/1 var(--font); letter-spacing: 0.1em; color: var(--accent);
  width: 30px; flex: none;
}
.intro-actions { width: 100%; max-width: 520px; margin: 0 auto; }
.fineprint { margin: 14px 0 0; font-size: 12px; color: var(--muted); text-align: center; }
.fineprint a { color: var(--muted); }

.screen-status { justify-content: center; align-items: center; z-index: 30; }
.status-box {
  width: 100%; max-width: 360px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
}
.status-box p { margin: 0; font-weight: 600; }
.status-box .hint { font-weight: 400; color: var(--muted); font-size: 14px; }
.spinner {
  width: 28px; height: 28px; background: var(--accent);
  animation: spin 1.1s cubic-bezier(0.6, 0, 0.4, 1) infinite;
}
@keyframes spin { 50% { transform: rotate(180deg) scale(0.7); } 100% { transform: rotate(360deg); } }
.progress { width: 100%; height: 4px; background: var(--line); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.2s ease; }

/* =========================================================
   Studio
   ========================================================= */

.studio { min-height: 100%; }
.studio-wrap { max-width: 1080px; margin: 0 auto; padding: 24px 20px 80px; }
.studio-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding-bottom: 20px; border-bottom: 1px solid var(--line);
}
.studio-head .brand { display: flex; align-items: center; gap: 14px; }
.studio-head h1 {
  margin: 0; font: 800 14px/1 var(--font); letter-spacing: 0.16em; text-transform: uppercase;
}
.studio-intro { padding: 36px 0 12px; max-width: 720px; }
.studio-intro .display { font-size: clamp(38px, 7vw, 68px); }
.studio-intro p { color: var(--muted); margin: 16px 0 0; }

.block { padding: 36px 0; border-bottom: 1px solid var(--line); }
.block-head { display: flex; align-items: baseline; gap: 16px; margin-bottom: 22px; }
.block-num { font: 800 13px/1 var(--font); color: var(--accent); letter-spacing: 0.1em; }
.block-head h2 {
  margin: 0; font-family: var(--font-display); font-weight: 800; font-stretch: condensed;
  text-transform: uppercase; font-size: clamp(26px, 4vw, 34px); line-height: 1;
}
.block-head .sub { margin-left: auto; color: var(--muted); font-size: 14px; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, .field > label.lbl {
  font: 700 11px/1 var(--font); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
}
.field small { color: var(--muted); font-size: 12px; }
input[type="text"], input[type="url"], input[type="number"], select {
  width: 100%; min-height: 46px; padding: 0 12px;
  background: var(--ink-2); color: var(--paper);
  border: 1px solid var(--line); border-radius: var(--radius);
  font: 500 15px/1 var(--font);
}
input:focus, select:focus, .drop:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type="color"] {
  width: 46px; height: 46px; padding: 3px; border: 1px solid var(--line);
  background: var(--ink-2); border-radius: var(--radius); cursor: pointer;
}
input[type="range"] { width: 100%; accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.targets { display: grid; gap: 18px; }
.tcard {
  background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px;
}
.tcard > header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.tnum { font: 800 12px/1 var(--font); letter-spacing: 0.16em; text-transform: uppercase; }
.tnum::before { content: "+ "; color: var(--accent); }
.link-btn {
  background: none; border: 0; padding: 6px 0; cursor: pointer;
  font: 700 12px/1 var(--font); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted);
}
.link-btn:hover { color: var(--paper); }
.link-btn.danger:hover { color: var(--accent); }
.tmedia { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.drop {
  position: relative; display: flex; flex-direction: column; justify-content: flex-end;
  min-height: 220px; overflow: hidden; cursor: pointer;
  background: var(--ink-3) var(--plus-grid);
  border: 1px dashed rgba(243, 240, 234, 0.3); border-radius: var(--radius);
}
.drop input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; z-index: 3; }
.drop-preview {
  position: absolute; inset: 0; padding: 10px;
  display: flex; align-items: center; justify-content: center;
}
.drop-preview canvas, .drop-preview video {
  max-width: 100%; max-height: 100%; display: block; pointer-events: none;
}
.tcard .note {
  margin: 10px 0 0; padding-left: 12px; border-left: 3px solid var(--warn);
  font-size: 13px; color: var(--paper);
}
.drop-label {
  position: relative; z-index: 2; padding: 12px;
  background: linear-gradient(transparent, rgba(14, 14, 14, 0.9) 40%);
  font-weight: 700; display: flex; flex-direction: column; gap: 3px;
}
.drop-label small { font-weight: 400; color: var(--muted); font-size: 12px; }
.drop.has-file { border-style: solid; }
.drop.has-file .drop-label { opacity: 0; transition: opacity 0.2s; }
.drop.has-file:hover .drop-label { opacity: 1; }
.quality {
  margin-top: 12px; padding: 12px 14px; border-radius: var(--radius);
  background: var(--ink-3); font-size: 14px; display: flex; gap: 12px; align-items: flex-start;
}
.quality b { display: block; }
.badge {
  flex: none; font: 800 11px/1 var(--font); letter-spacing: 0.12em; text-transform: uppercase;
  padding: 6px 8px; border-radius: var(--radius); color: #0e0e0e;
}
.badge.good { background: var(--ok); }
.badge.ok { background: var(--warn); }
.badge.weak { background: var(--bad); color: #fff; }
.badge.unknown { background: var(--muted); }
.topts { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.topts summary {
  cursor: pointer; font: 700 12px/1 var(--font); letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); padding: 6px 0; list-style: none;
}
.topts summary::before { content: "+ "; color: var(--accent); }
.topts[open] summary::before { content: "– "; }
.topts .grid { margin-top: 14px; }

.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 20px; }
.compile-status { margin-top: 18px; display: grid; gap: 10px; max-width: 520px; }
.compile-status p { margin: 0; color: var(--muted); font-size: 14px; }

.export-grid { display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: start; }
.qr-box {
  background: #fff; padding: 12px; border-radius: var(--radius);
  aspect-ratio: 1; display: grid; place-items: center;
}
.qr-box svg { width: 100%; height: auto; display: block; }
.qr-box .empty { color: #777; font-size: 13px; text-align: center; }
.url-line {
  font: 600 14px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-all; padding: 12px; background: var(--ink-2);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.checklist { margin: 16px 0 0; padding-left: 18px; color: var(--muted); font-size: 14px; }
.checklist li { margin: 4px 0; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-b) + 24px); z-index: 50;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px); padding: 12px 16px;
  background: var(--paper); color: var(--ink); border-radius: var(--radius);
  font-weight: 700; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  animation: cta-in 0.25s ease-out;
}
.toast.is-error { background: var(--accent); color: #fff; }

.test-layer { position: fixed; inset: 0; z-index: 40; background: #000; }
.test-status {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 12; width: min(86vw, 360px); text-align: center;
  display: flex; flex-direction: column; gap: 16px; align-items: center;
}

@media (max-width: 720px) {
  .tmedia { grid-template-columns: 1fr; }
  .export-grid { grid-template-columns: 1fr; }
  .qr-box { max-width: 260px; }
  .block-head { flex-wrap: wrap; }
  .block-head .sub { margin-left: 0; width: 100%; }
}
